Google Search - Blog...........

ABAP - Sample Program To Get All The Tables Of A T-Code.

REPORT ZPOO_FIND_TABLE2 NO STANDARD PAGE HEADING.

*&---------------------------------------------------------------------*
** TITLE: Program to get all the tables of a TCode
***************************** DECLARATIONS **************************
TABLES : TSTC, tstct.

TABLES : DD03l, DD02l.

DATA : Program like sy-repid.

DATA : BEGIN OF I_FINAL OCCURS 0,

tabname LIKE dd02l-tabname,

TABCLASS LIKE dd02l-tabCLASS,

TEXT LIKE DD02T-DDTEXT,

END OF I_FINAL.

DATA : BEGIN of ITAB Occurs 0,

name like dd02l-tabname,

END OF ITAB.

DATA : TCD(100) TYPE C.

DATA : var1 LIKE dd02l-tabname.

DATA : DESC LIKE TSTCT-TTEXT.

****************************** SELECTION SCREEN ************************

selection-screen skip.

SELECTION-SCREEN : BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.

PARAMETERS : r1 RADIOBUTTON GROUP r DEFAULT 'X'.

Parameters : Tcode like sy-tcode.

selection-screen skip.

PARAMETERS : r2 RADIOBUTTON GROUP r.

Parameters : Prog like sy-repid.

SELECTION-SCREEN END OF BLOCK b2.

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE text-001.

select-options : Type for dd02l-tabclass .

SELECTION-SCREEN END OF BLOCK B1 .

****************************** AT SELECTION SCREEN **********************

at selection-screen.

if r1 = 'X' and Tcode is initial.

message e001(00) with 'Enter Transaction Code' .

elseif r2 = 'X' and Prog is initial.

message e001(00) with 'Enter Program Name' .

endif.

****************************** START OF SELECTION **********************

START-OF-SELECTION.

if r1 = 'X'.

Prog = ' '.

select single * from TSTC where tcode = tcode.

if sy-subrc = 0.

program = TSTC-PGMNA.

select single TTEXT from tstct into desc where tcode = tcode and SPRSL = 'E'.

else.

Write :/ 'Invalid Transaction Code'.

exit.

endif.

elseif r2 = 'X'.

Tcode = ' '.

program = Prog.

endif.

CALL FUNCTION 'GET_TABLES'

EXPORTING

PROGNAME = Program

TABLES

TABLES_TAB = itab.

if itab is initial.

skip.

skip.

skip.

skip.

skip.

WRITE :/40 'No Data Found' color 6 INTENSIFIED OFF.

ELSE.

PERFORM : categorize.

endif.

************************** END OF SELECTION ********************************

END-OF-SELECTION.

LOOP AT I_FINAL.

WRITE :/4 I_FINAL-tabname COLOR 2 INTENSIFIED OFF NO-GAP HOTSPOT ON, 35 I_FINAL-TABCLASS COLOR 2 INTENSIFIED OFF NO-GAP,

50 I_FINAL-TEXT COLOR 2 INTENSIFIED OFF NO-GAP.

ENDLOOP.

************************** AT LINE SELECTION ********************************

AT LINE-SELECTION.

TCD = SY-LISEL.

var1 = TCD+3(30).

set parameter id 'DTB' FIELD VAR1.

call transaction 'SE11' and skip first screen.

************************** TOP OF PAGE ********************************

TOP-OF-PAGE.

WRITE :/45 'TABLE DETAILS RELATED TO THE TRANSACTION CODE' COLOR 7 .

WRITE :/2 'DATE : ' COLOR 1, SY-DATUM COLOR 1 INTENSIFIED OFF NO-GAP.

WRITE :/2 'TRANSACTION CODE : ' COLOR 1, Tcode COLOR 1 INTENSIFIED OFF NO-GAP.

WRITE :/2 'TCODE DESCRIPTION : ' COLOR 1, desc COLOR 1 INTENSIFIED OFF NO-GAP.

WRITE :/2 'PROGRAM NAME : ' COLOR 1, PROGRAM COLOR 1 INTENSIFIED OFF NO-GAP.

SKIP 1.

WRITE :/1(140) SY-ULINE.

WRITE :/4 'TABLE NAME' COLOR 5 INTENSIFIED OFF NO-GAP,35 'TABLE TYPE' COLOR 5 INTENSIFIED OFF NO-GAP,

55 'DESCRIPTION' COLOR 5 INTENSIFIED OFF NO-GAP.

WRITE :/1(140) SY-ULINE.

.

*&---------------------------------------------------------------------*

*& Form categorize

*&---------------------------------------------------------------------*

* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text *----------------------------------------------------------------------* FORM categorize . SELECT dd02l~tabname dd02l~tabCLASS DD02T~DDTEXT FROM dd02l INNER JOIN DD02T ON dd02l~tabname = dd02T~tabname INTO TABLE I_FINAL FOR ALL ENTRIES IN itab WHERE DD02L~TABNAME = ITAB-NAME AND TABCLASS IN TYPE AND DDLANGUAGE = 'E'. if sy-subrc <> 0.

skip.

skip.

skip.

skip.

skip.

WRITE :/40 'No Data Found' color 6 INTENSIFIED OFF.

endif.

ENDFORM. " categorize

No comments:

Post a Comment