0% found this document useful (0 votes)
42 views2 pages

Fetching Any Data Table Table Records Via Program

This document describes code for dynamically fetching records from any database table in ABAP. It creates a dynamic internal table and work area based on the table name passed as a parameter. It then selects up to 20 records from the database table and writes them to the internal table. The code dynamically creates the internal table structure, selects records, and outputs them without needing to know the table structure in advance.

Uploaded by

Rg
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views2 pages

Fetching Any Data Table Table Records Via Program

This document describes code for dynamically fetching records from any database table in ABAP. It creates a dynamic internal table and work area based on the table name passed as a parameter. It then selects up to 20 records from the database table and writes them to the internal table. The code dynamically creates the internal table structure, selects records, and outputs them without needing to know the table structure in advance.

Uploaded by

Rg
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Fetching the records from any database table :->

1. Long back I got a requirement , customer wanted a t-code from where they can down load n numbers of records from any database table. Below is some of its code what I implemented . 2. REPORT
YRG_DYNAMIC_INTERNAL_TABLE NO STANDARD PAGE HEADING.

DATA: w_tabname TYPE REF TO data , w_dref TYPE REF TO data. DATA : lv_tabname TYPE dd02l-tabname.

FIELD-SYMBOLS: <lt_itab> TYPE TABLE , <ls_itab> TYPE ANY .

PARAMETERS : p_tab TYPE dd02l-tabname OBLIGATORY. * Dynamic Internal Table creation CREATE DATA w_tabname TYPE TABLE OF (p_tab). ASSIGN w_tabname->* TO <lt_itab>. * Dynamic Work Area CREATE DATA w_dref LIKE LINE OF <lt_itab>. ASSIGN w_dref->* TO <ls_itab>. AT SELECTION-SCREEN ON p_tab . SELECT SINGLE tabname FROM dd02l INTO lv_tabname WHERE tabname ab. IF lv_tabname is INITIAL. MESSAGE 'DataBase Table does not exist!!' TYPE 'E'. exit. ENDIF. START-OF-SELECTION. * Dynamic Selection from data base table SELECT * FROM (p_tab) INTO CORRESPONDING FIELDS OF TABLE <lt_itab> UP TO 20 ROWS . IF <lt_itab> is NOT INITIAL. LOOP AT <lt_itab> INTO <ls_itab>. write / : <ls_itab>. ENDLOOP. ENDIF.

= p_t

3. Output :

You might also like