The first thing we need to do when we learn the SAP ABAP coding is to find out the assistance programs such as collecting system transaction codes . we can create our own ABAP report to list all transaction codes in SAP database. The report used RTTI codes to search all data in all tables in SAP.
REPORT Z_searchTABLES MESSAGE-ID z_allmes.
parameters: dbtab type c length 32,
cols type c length 132,
where type c length 132.
class gettableinfo definition.
public section.
class-methods main
importing
dbtab type csequence
cols type csequence
where type csequence. "-parameters is --CARRID EQ '002'
private section.
class-methods display
importing
value(result) type standard .
endclass.
class gettableinfo implementation.
method main.
data: field-symbols table.
desc=>describe_by_name(
exporting p_name = dbtab
receiving p_descr_ref = desc
exceptions type_not_found = 4 ).
if sy-subrc = 4.
message 'Type not found' type 'I' display like 'E'.
return.
endif.
try.
strc?= descr.
catch cx_sy_move_cast_error into error.
message error type 'I' display like 'E'.
return.
endtry.
find regex component-name in cols.
if sy-subrc <> 0.
" delete components index sy-tabix.
endif.
endloop.
try.
...
catch cx_sy_struct_creation cx_sy_table_creation into error.
message error type 'I' display like 'E'.
return.
endtry.
try.
create data table_ref type handle tabsc.
...
catch cx_sy_create_data_error into error.
message error type 'I' display like 'E'.
return.
endtry.
try.
select (cols)
from (dbtab) into corresponding fields of table table
where (where).
catch cx_sy_sql_error into error.
message error type 'I' display like 'E'.
return.
endtry.
display( ttable ).
endmethod.
method display.
DATA alv TYPE REF TO cl_salv_table.
TRY.
cl_salv_table=>factory(
IMPORTING r_salv_table = alv
CHANGING t_table = result ).
alv->display( ).
CATCH cx_salv_msg.
MESSAGE 'ALV display not possible' TYPE 'I'
DISPLAY LIKE 'E'.
ENDTRY.
endmethod.
endclass.
START-OF-SELECTION.
gettableinfo=>main( EXPORTING dbtab = dbtab
cols =cols
where =where ).
Run the report and then input the transaction codes table name. Search result will list out all transaction codes data.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment