08-04-2007 8:00 AM
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.
08-04-2007 5:21 PM
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
08-04-2007 9:17 PM
08-05-2007 7:09 AM
12-18-2008 8:41 AM