Application Development 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: 

dynamic internal table

Former Member
0 Kudos

lets take an example

i have itab with single field matnr

itab

field name - matnr

records

1001

1002

1003

now at present i have three records

now i want make this as fields of another internal table itab2

itab2

1001 1002 1003

may be this is simple i can try it out

but the problem is the number of record in itab1 r not fixed so for that purpose i have create itab2 as dynamic internal table.

i have done it but here i am not able to call the required dynamic table into my report.

using this syntax iam creating an dynamic internal table

DATA: BEGIN OF STRUCT OCCURS 10,

FILDNAME(15) TYPE C,

ABPTYPE(5) TYPE C,

LENGTH TYPE I,

END OF STRUCT.

DATA: BEGIN OF INCTABL OCCURS 10,

LINE(72),

END OF INCTABL.

DATA: LNG TYPE I, TYPESRTING(6).

data : begin of it_vbkd occurs 0,

bzirk like vbkd-bzirk,

end of it_vbkd.

select bzirk from vbkd into corresponding fields of table it_vbkd.

sort it_vbkd by bzirk.

delete adjacent duplicates from it_vbkd.

delete it_vbkd where bzirk = ' '.

STRUCT-FILDNAME = 'amtbnd'. STRUCT-ABPTYPE = 'c'. STRUCT-LENGTH = '30'.

APPEND STRUCT. CLEAR STRUCT.

loop at it_vbkd.

STRUCT-FILDNAME = it_vbkd-bzirk. STRUCT-ABPTYPE = 'bzirk'.

APPEND STRUCT. CLEAR STRUCT.

endloop.

STRUCT-FILDNAME = 'others'. STRUCT-ABPTYPE = 'n'.

APPEND STRUCT. CLEAR STRUCT.

STRUCT-FILDNAME = 'total'. STRUCT-ABPTYPE = 'n'.

APPEND STRUCT. CLEAR STRUCT.

INCTABL-LINE = 'program zdynpro.'. APPEND INCTABL.

INCTABL-LINE = 'data: begin of dyntab occurs 10,'. APPEND INCTABL.

LOOP AT STRUCT.

INCTABL-LINE = STRUCT-FILDNAME.

LNG = STRLEN( STRUCT-FILDNAME ).

IF NOT STRUCT-LENGTH IS INITIAL .

TYPESRTING(1) = '('.

TYPESRTING+1 = STRUCT-LENGTH.

TYPESRTING+5 = ')'.

CONDENSE TYPESRTING NO-GAPS.

INCTABL-LINE+LNG = TYPESRTING.

ENDIF.

INCTABL-LINE+20 = 'type '.

INCTABL-LINE+27 = STRUCT-ABPTYPE.

INCTABL-LINE+33 = ','.

APPEND INCTABL.

ENDLOOP.

INCTABL-LINE = 'end of dyntab. '.

APPEND INCTABL.

INCTABL-LINE = ' '. APPEND INCTABL.

INCTABL-LINE = 'dyntab-amtbnd = ''a1''.'. APPEND INCTABL.

INCTABL-LINE = 'append dyntab.'. APPEND INCTABL.

INCTABL-LINE = ' '. APPEND INCTABL.

INCTABL-LINE = 'EXPORT dyntab TO MEMORY ID '001'.'.APPEND INCTABL.

  • Create and run the dynamic program

INSERT REPORT 'zdynpro'(001) FROM INCTABL. "PROGRAM TYPE 'S' .

DATA : LIST1 TYPE ABAPLIST occurs 0 with header line.

DATA LIST2 TYPE TABLE OF abaplist.

SUBMIT ZDYNpro EXPORTING LIST TO MEMORY AND RETURN.

this report is generating an report

program zdynpro.

data: begin of dyntab occurs 10,

i_amtbd-amtbnd(30) type c ,

AN type bzirk ,

BH type bzirk ,

CENTRE type bzirk ,

RM type bzirk ,

i_data-others type n ,

i_data-total type n ,

end of dyntab.

append dyntab.

i have to loop at dyntab (dynamic internal table) present in this report where ever required

i have tried export and import i am not able to get required result

i have idea about LIST_FROM_MEMORY but dont know to use exactly to my requirement.

if possible can i make this as an include program but the problem is one report cannot have two reports

how do i make it as subroutine or type pools or any other thing to call the internal table (dyntab) into my report and do calculations. at present iam able to display the contents of internal table but i need to do further calculations.

4 REPLIES 4

Former Member
0 Kudos

Hi,

check this

http://www.sap-img.com/ab030.htm

https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/dynamicInternalTable&

<b>Reward if helpful.</b>

regards

Umasankar

uwe_schieferstein
Active Contributor
0 Kudos

Hello Madan

Please have a look at my sample report<b> ZUS_SDN_RTTI_CREATE_STRUCTUR_1</b> in thread

The report demonstrates how to use the RTTI in order to build complex itabs, i.e. an itab having another internal tables as field.

Regards

Uwe

Former Member
0 Kudos

Hi Madan,

Please check the thread given below:

Regards

Kannaiah

Former Member
0 Kudos

thnaks..