Can you create an internal table dynamically?(at run time)

Answer Posted / ganesh sawant

REPORT Dynmic Table .

PARAMETERS: table(20),
rows TYPE i DEFAULT 100.

* Declare the variable for holding your internal table
DATA: itab TYPE REF TO data.

* Three field symbols requried 1. for acessing table data..second work area and third individual fields.
FIELD-SYMBOLS: <fs_table> TYPE ANY TABLE,
<fs_wa> TYPE ANY,
<field> TYPE ANY.
TRY.
* Create internal table
CREATE DATA itab TYPE STANDARD TABLE OF (table).
* Let our Field Symbol point to it so we can acess its data afterwords.
ASSIGN itab->* TO <fs_table>.

* put data into internal table
SELECT * FROM (table) UP TO rows ROWS INTO TABLE <fs_table>.

* Loop over internal tabel with the help of field symbol pointing to its data
LOOP AT <fs_table> ASSIGNING <fs_wa>.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE <fs_wa> TO <field>.
IF sy-subrc EQ 0.
WRITE: <field>.
ELSE.
EXIT.
ENDIF.
ENDDO.
ULINE.
ENDLOOP.
CATCH cx_sy_create_data_error.
WRITE 'Wrong Database!'.
ENDTRY.

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between retroactive accounting period, earliest retroactive accounting period? : sap abap hr

555


what are the important fields while preparing sales order,inquiry?

1907


Does the table can have multiple foreign keys?

597


What is a fall back class?

1020


What will you code in start-of-selection & end-of-selection ?

595






What is the function of the correction system? : abap data dictionary

608


What are the various types of selection screen event?

575


Explain the properties of selection screen?

654


How to debug a sapscript?

604


What is the use of message command in a report? What are the different message types?

553


Did you create help views?

554


What is an rfc?

595


Give examples of transparent table?

702


Can we set page headers to details lists?

590


What is the difference between sy-tabix and sy-index? Where it is used?

756