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 Internal Table

Former Member
0 Likes
865

Hi,

How to create a dynamic Internal table based on the Infotype passed(dynamic). The Internal table has to be passed dynamically to FM

HR_READ_INFOTYPE.

CALL FUNCTION 'HR_READ_INFOTYPE'

EXPORTING

tclas = 'A'

pernr = p_pernr

infty = p_infty

begda = p_begda

endda = p_endda

IMPORTING

subrc = subrc

TABLES

infty_tab = < >

EXCEPTIONS

infty_not_found = 1

OTHERS = 2.

Regards

jai

4 REPLIES 4
Read only

Former Member
0 Likes
664

Hi ,

you can do like that... it works.



INFOTYPES: 0000,                                      
           0001.

data:
      PERNR LIKE P0001-PERNR   ,
      DATUM LIKE P0001-BEGDA.

CALL FUNCTION 'HR_READ_INFOTYPE'
EXPORTING
*           TCLAS           = 'A'
  PERNR           = PERNR
  INFTY           = '0000'
  BEGDA           = DATUM
  ENDDA           = DATUM
*      IMPORTING
*           SUBRC           =
TABLES
  INFTY_TAB       = P0000
EXCEPTIONS
  INFTY_NOT_FOUND = 1
  OTHERS          = 2.

note: if this help dont forget to give points...

rgs,

Miguel

Read only

Former Member
0 Likes
664

Hi Jai,

Please write a code as below. for dynamic internal table creation Please refer [http://www.sapdb.info/abap-how-to-create-a-dynamic-internal-table-and-work-area/]



 DATA:  wa_dref TYPE REF TO data,              
         FIELD-SYMBOLS: <info_itab> TYPE ANY TABLE.  

CREATE DATA wa_dref TYPE TABLE OF (p_infty). 

  ASSIGN wa_dref ->* TO <info_itab>. 


CALL FUNCTION 'HR_READ_INFOTYPE'
EXPORTING
tclas = 'A'
pernr = p_pernr
infty = p_infty
begda = p_begda
endda = p_endda
IMPORTING
subrc = subrc
TABLES
infty_tab = <info_itab>
EXCEPTIONS
infty_not_found = 1
OTHERS = 2.

Edited by: Prasath Arivazhagan on May 24, 2010 4:10 PM

Read only

0 Likes
664

This message was moderated.

Read only

Former Member
0 Likes
664

Hi

Try this:

DATA : ITAB(150) OCCURS 0.

DATA: ZNAME(8) TYPE C.

Letz say P_TABNAME holds your dynamic Infotype name, then:

Code something like: [this example shows getting data from table name held in P_TABNAME]

CLEAR ITAB. REFRESH ITAB.

FREE ITAB.

APPEND 'PROGRAM SUBPOOL.' TO ITAB.

APPEND 'FORM DOWNLOAD.' TO ITAB.

APPEND 'DATA: BEGIN OF IT_TAB OCCURS 0.' TO ITAB.

CONCATENATE 'INCLUDE STRUCTURE'

P_TABNAME

'.' INTO GW_LINE SEPARATED BY SPACE.

APPEND GW_LINE TO ITAB.

APPEND 'DATA: END OF IT_TAB.' TO ITAB.

APPEND 'DATA: LF_DATA TYPE CHAR3000.' TO ITAB.

*// Get the data from the Z table

CONCATENATE 'SELECT * FROM'

P_TABNAME

'INTO TABLE IT_TAB.' INTO GW_LINE SEPARATED BY SPACE.

APPEND GW_LINE TO ITAB.

finally,

GENERATE SUBROUTINE POOL ITAB NAME ZNAME.

IF NOT ZNAME IS INITIAL.

PERFORM DOWNLOAD IN PROGRAM (ZNAME).

ENDIF.

<....... You can build ITAB according to your requirement

Regards

Raj