‎2012 Feb 23 5:46 AM
Hello all,
Is it possible to check whether all tables starting with S has got data in a single shot?
Thanks,
Regards,
Hasan
‎2012 Feb 23 6:12 AM
‎2012 Feb 23 10:21 AM
Not possible from ABAP. If you explain more about the context, maybe a different solution is possible.
Thomas
‎2012 Feb 23 11:59 AM
Hi Hasan,
In table DD02T you can find all table names.
First copy this table to an internal table, then loop over it.
Check if the first character of the table name contains the 'S'.
If so, append these to a new table.
Then, for each table you can try to read the first line, if sy-subrc = 0, the table contains data. Otherwise, it is empty.
Be aware, this might take a very long time. There are over a million tables in DD02T. And if you want to check for many tables if they have any content, this would impose a lot of effort on your database.
Best regards,
Steven
‎2012 Feb 27 12:33 PM
REPORT ztest_ssp.
TYPES: BEGIN OF ty_dd02l,
tabname TYPE tabname,
tabclass TYPE tabclass,
lines TYPE i,
END OF ty_dd02l.
DATA: it_dd02l TYPE TABLE OF ty_dd02l,
wa_dd02l TYPE ty_dd02l,
lv_tabname TYPE tabname,
lv_int TYPE i.
* ALV variables declaration:
DATA: lr_table TYPE REF TO cl_salv_table,
lr_functions TYPE REF TO cl_salv_functions,
lr_msg TYPE REF TO cx_salv_msg,
lv_text TYPE string.
FIELD-SYMBOLS: <tab_name> TYPE ty_dd02l,
<fs> TYPE any.
SELECT-OPTIONS: so_tabnm FOR lv_tabname.
PARAMETERS: p_test TYPE xfeld AS CHECKBOX.
SELECT tabname tabclass
FROM dd02l
INTO TABLE it_dd02l
WHERE tabname IN so_tabnm
AND tabclass = 'TRANSP'.
LOOP AT it_dd02l ASSIGNING <tab_name>.
lv_tabname = <tab_name>-tabname.
SELECT COUNT(*)
FROM (lv_tabname)
INTO lv_int.
IF lv_int = 0.
DELETE TABLE it_dd02l FROM <tab_name>.
ELSE.
<tab_name>-lines = lv_int.
ENDIF.
CLEAR lv_int.
ENDLOOP.
TRY.
cl_salv_table=>factory( IMPORTING r_salv_table = lr_table
CHANGING t_table = it_dd02l ).
CATCH cx_salv_msg INTO lr_msg.
lv_text = lr_msg->get_text( ).
MESSAGE e000(zmmps) WITH lv_text.
ENDTRY.
lr_functions = lr_table->get_functions( ).
lr_functions->set_all( abap_true ).
* Next we need to display the grid, for this we use the DISPLAY method .
lr_table->display( ).
‎2012 Feb 27 1:55 PM
Hello Steven,
Thanks a lot for your detailed information & coding.
I will try n let you know...
Regards,
Hasan