SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

How to create a dynamic internal table using 'INSERT REPORT'



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Dynamic Programming | Динамическое программирование
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Sun Nov 25, 2007 12:45 pm    Post subject: How to create a dynamic internal table using 'INSERT REPORT' Reply with quote

Example: how to create a dynamic internal table

Code:
REPORT ZCLUST1 .
*
* Example: how to create a dynamic internal table
*
* The dynamic internal table stucture
DATA: BEGIN OF STRUCT OCCURS 10,
    FILDNAME(8) TYPE C,
    ABPTYPE TYPE C,
    LENGTH TYPE I,
END OF STRUCT.

* The dynamic program source table
DATA: BEGIN OF INCTABL OCCURS 10,
    LINE(72),
END OF INCTABL.

DATA: LNG TYPE I, TYPESRTING(6).

* Sample dynamic internal table stucture
STRUCT-FILDNAME = 'field1'. STRUCT-ABPTYPE = 'c'. STRUCT-LENGTH = '6'.
APPEND STRUCT. CLEAR STRUCT.
STRUCT-FILDNAME = 'field2'. STRUCT-ABPTYPE = 'd'.
APPEND STRUCT. CLEAR STRUCT.
STRUCT-FILDNAME = 'field3'. STRUCT-ABPTYPE = 'i'.
APPEND STRUCT. CLEAR STRUCT.

* Create the dynamic internal table definition in the dyn. program
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+15 = 'type '.
  INCTABL-LINE+21 = STRUCT-ABPTYPE.
  INCTABL-LINE+22 = ','.
  APPEND INCTABL.
ENDLOOP.
INCTABL-LINE = 'end of dyntab. '.
APPEND INCTABL.

* Create the code processes the dynamic internal table
INCTABL-LINE = ' '. APPEND INCTABL.
INCTABL-LINE = 'dyntab-field1 = ''aaaaaa''.'. APPEND INCTABL.
INCTABL-LINE = 'dyntab-field1 = ''19970814''.'. APPEND INCTABL.
INCTABL-LINE = 'dyntab-field1 = 1.'. APPEND INCTABL.
INCTABL-LINE = 'append dyntab.'. APPEND INCTABL.
INCTABL-LINE = ' '. APPEND INCTABL.
INCTABL-LINE = 'loop at dyntab.'. APPEND INCTABL.
INCTABL-LINE = 'write: / dyntab.'. APPEND INCTABL.
INCTABL-LINE = 'endloop.'. APPEND INCTABL.

* Create and run the dynamic program
INSERT REPORT 'zdynpro'(001) FROM INCTABL.
SUBMIT ZDYNPRO.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Dynamic Programming | Динамическое программирование All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.