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 are the differences between primary and secondary indexes?

823


What is an update task?

778


Can we make use of flow logic control key words in abap/4 and vice-versa?

770


Explain how do you move on to the next screen in interactive reporting?

754


why particularly lock object name starts with EZ OR EY?

1706






Explain what is a foreign key relationship? Explain this with the help of an example.

798


Hat are the different types of mode (run code) in call transaction method?

768


What are plan versions used for? : sap abap hr

740


In which particular scenario we use sorted table and which particular scenario we use standard table?

1189


What is the modification assistant?

764


How will you define org structure in MM?

1055


BDC program to migrate data to SAP R/3 database. The data will be uploaded using transaction ME11. (Session Method) plz mention the detail coding Tahnks, Rahul

1859


Difference between stand alone CRM and back-end CRM

3973


What are the components of sap scripts? : abap hr

762


java script for push button in adobe forms.

2086