Skip to Content
author's profile photo Former Member
Former Member

dynamic internal table

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Aug 04, 2007 at 04: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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 04, 2007 at 08:17 PM

    Hello Madan

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

    Creation of table of table dynamically

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 05, 2007 at 06:09 AM

    Hi Madan,

    Please check the thread given below:

    dynamic-field-catalouge

    Regards

    Kannaiah

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 18, 2008 at 08:41 AM

    thnaks..

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.