2023 Oct 05 3:16 PM
Hello everyone,
I have this code to display the SFLIGHTS table data. But I need to edit it to be able to find all tables which are in my system, not only SFLIGHTS. How can I make this please?
REPORT ZTEST_PROGRAM.
DATA: gv_table_name TYPE DDOBJNAME,
gv_num_records TYPE I.
PARAMETERS: p_tabnam TYPE dd02l-tabname OBLIGATORY,
p_num_re TYPE I DEFAULT 20.
AT SELECTION-SCREEN ON help-REQUEST FOR p_tabnam.
START-OF-SELECTION.
PERFORM display_table_data.
END-OF-selection.
FORM fetch_table_list.
DATA: lt_table_list TYPE STANDARD TABLE OF DFIES,
ls_table_list TYPE dd02l.
gv_table_name = p_tabnam.
CALL FUNCTION 'DDIF_FIELDINFO_GET'
EXPORTING
tabname = gv_table_name
TABLES
dfies_tab = lt_table_list.
* LOOP AT lt_table_list INTO ls_table_list.
* CONCATENATE ls_table_list-tabname ' -' ls_table_list-tabname INTO ls_table_list-tabname SEPARATED BY space.
* MOVE-CORRESPONDING ls_table_list TO lt_table_list.
* MODIFY lt_table_list TRANSPORTING tabname.
* ENDLOOP.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'P_TABLE_NAME'
value_org = 'S'
multiple = ' '
TABLES
value_tab = lt_table_list
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE 'Error in fetching table list' TYPE 'E'.
ENDIF.
ENDFORM.
FORM display_table_data.
DATA: lt_table_data TYPE TABLE OF sflights,
ls_table_data TYPE sflights.
gv_table_name = p_tabnam. "global variable
* SELECT * FROM (gv_table_name) INTO TABLE lt_table_data UP TO gv_num_records ROWS.
SELECT *
INTO TABLE lt_table_data
FROM (gv_table_name) UP TO p_num_re ROWS.
LOOP AT lt_table_data INTO ls_table_data.
WRITE: / ls_table_data-carrid,
ls_table_data-connid,
ls_table_data-fldate.
* ls_table_data-price.
ENDLOOP.
CALL FUNCTION 'SRTT_TABLE_DISPLAY'
EXPORTING
TABLE = 'sflights'
IV_TITLE = 'Flight List'
TABLES
table_content = lt_table_data. "display content from the internal table lt_table_data.
FIELD-SYMBOLS: <fs_field> TYPE ANY.
DESCRIBE TABLE lt_table_data LINES sy-tabix.
WRITE: / 'Number of Records Displayed:', sy-tabix.
ENDFORM:
2023 Oct 05 3:51 PM
Try
CALL FUNCTION 'RS_DD_F4_OBJECT'
EXPORTING
objname = p_tabnam
objtype = 'T'
suppress_selection = 'X'
2023 Oct 05 7:06 PM
I tried your solution with the help of searching in google but allways some wrongs . Should I change something in my code? Can you explain more please? this is my first program in ABAP.
2023 Oct 06 8:41 AM
2023 Oct 05 5:36 PM
Hi,
You can also check table TADIR with PGMID = 'R3TR' OBJECT = 'TABL'.
2023 Oct 05 6:53 PM
I advise anyone to check systematically the format of the question after posting one, because of the many forum bugs.
To fix them, use Actions > Edit.
2023 Oct 05 6:58 PM
You want "to find all tables in the system", I guess you know they are listed in the table DD02L because your program already refers to DD02L, but what exactly do you want to do after you get all the tables? Display an ALV with the list of all tables instead of flights? Table names and their titles? Or just permit F4 on the selection screen to show all tables and select one?
2023 Oct 05 7:04 PM
As you see in photo, I select a table, open it, display table data and be able to edit it. other question, when I create some table, will it locate automatically in the table DD02L ?
2023 Oct 06 9:07 AM
It looks like you're working from some old training material. It's probably a good idea to find something more modern. FORMs for example, are obsolete now and should only be used under specific circumstances.
2023 Oct 06 3:25 PM
You're new in ABAP and also in the forum, it seems, you can still fix the formatting of your code (Actions > Edit > button CODE formatting).
2023 Oct 06 3:26 PM
Sorry. I didn't understand your first question. And I didn't understand your second question.
2023 Oct 06 5:17 PM
Thanks for the nice formatting of ABAP code, it looks great now !
2023 Oct 06 5:18 PM
Oh I now understand your latest question "when I create some table, will it locate automatically in the table DD02L ?"
Yes.