Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Dynamic Data Declaration

Former Member
0 Likes
617

Hi all,

Can we declare a dynamic data in a loop as :

Loop at i_abc.

.

...

Data : <f_abc> like bkpf occurs 0 with header line.

.

.

....

Endloop.

were the field symbol have names as tab1,tab2,tab3.....

the number of table created in the run time would not be know earlier.

your ideas appreicated.

thanks ,

stock

5 REPLIES 5
Read only

Former Member
0 Likes
580

Check this...

/people/ravikumar.allampallam/blog/2005/05/31/expand-the-list-of-columns-in-a-report-dynamically

/people/subramanian.venkateswaran2/blog/2004/11/19/dynamic-internal-table

/people/rich.heilman2/blog/2005/07/27/dynamic-internal-tables-and-structures--abap

Read only

0 Likes
580

Hi Ramesh,

Thanks for the links.

But we need to create internal tables with fixed columns.

The number of tables to be created within a loop is dynamic .

ur ideas appreciated.

Thanks,

stock

Read only

Former Member
0 Likes
580

Hi

check this

-charitha

Read only

0 Likes
580

Hi,

Thanks for the ideas.

I do not intend to create dynamic table as the coulmns in the new internal table created in loop would remain constant.

Thanks,

Stock

Read only

LucianoBentiveg
Active Contributor
0 Likes
580

Try this:


FORM create_corresponding_tables TABLES not_standard STRUCTURE not_standard.

DATA: progname LIKE sy-repid.
DATA: BEGIN OF repcode OCCURS 10,
              line(72),
           END OF repcode.

repcode-line = 'REPORT NEW_INFOTYPE_DATA.'.
APPEND repcode.

repcode-line = 'FORM DATA_DECLARATIONS.'.
APPEND repcode.

LOOP AT not_standard.
  CONCATENATE 'P' not_standard-infty INTO repcode-line.
  CONCATENATE 'DATA: ' repcode-line 'LIKE' repcode-line
                           'OCCURS 10 WITH HEADER LINE.'
                   INTO repcode-line SEPARATED BY space.
  APPEND repcode.
ENDLOOP.

repcode-line = 'ENDFORM.'.
APPEND repcode.

GENERATE SUBROUTINE POOL repcode NAME progname.

PERFORM data_declarations IN PROGRAM (progname).

ENDFORM. " CREATE_CORRESPONDING_TABLES

Regards.