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

How to write a perform with dynamic internal table

Former Member
0 Likes
498

Hi to all experts,

i have to read infotype 2001 2003 2002 with same pernr, begin date, end date im calling hr_read_infotype three times

can i write a single perform and call it three how to pass different tables (2001, 2002, 2003).

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
390

try the below code...



  DATA: w_subrc TYPE sy-subrc.
  DATA: w_infty(5) TYPE  c.
  data: w_string type string.
  FIELD-SYMBOLS: <f1> TYPE table.
  FIELD-SYMBOLS: <f1_wa> TYPE ANY.
  DATA: ref_tab TYPE REF TO data.

  CONCATENATE 'P' infty INTO w_infty.
  CREATE DATA ref_tab TYPE STANDARD TABLE OF (w_infty).
  ASSIGN ref_tab->* TO <f1>.

* Create dynamic work area
  CREATE DATA ref_tab TYPE (w_infty).
  ASSIGN ref_tab->* TO <f1_wa>.


  IF begda IS INITIAL.
    begda = '18000101'.
  ENDIF.

  IF endda IS INITIAL.
    endda = '99991231'.
  ENDIF.

  CALL FUNCTION 'HR_READ_INFOTYPE'
    EXPORTING
      pernr           = pernr
      infty           = infty
      begda           = '18000101'
      endda           = '99991231'
    IMPORTING
      subrc           = w_subrc
    TABLES
      infty_tab       = <f1>
    EXCEPTIONS
      infty_not_found = 1
      OTHERS          = 2.
  IF sy-subrc <> 0.
    subrc = w_subrc.

  ELSE.


  ENDIF.

Hi to all experts,

i have to read infotype 2001 2003 2002 with same pernr, begin date, end date im calling hr_read_infotype three times

can i write a single perform and call it three how to pass different tables (2001, 2002, 2003).

1 REPLY 1
Read only

Former Member
0 Likes
391

try the below code...



  DATA: w_subrc TYPE sy-subrc.
  DATA: w_infty(5) TYPE  c.
  data: w_string type string.
  FIELD-SYMBOLS: <f1> TYPE table.
  FIELD-SYMBOLS: <f1_wa> TYPE ANY.
  DATA: ref_tab TYPE REF TO data.

  CONCATENATE 'P' infty INTO w_infty.
  CREATE DATA ref_tab TYPE STANDARD TABLE OF (w_infty).
  ASSIGN ref_tab->* TO <f1>.

* Create dynamic work area
  CREATE DATA ref_tab TYPE (w_infty).
  ASSIGN ref_tab->* TO <f1_wa>.


  IF begda IS INITIAL.
    begda = '18000101'.
  ENDIF.

  IF endda IS INITIAL.
    endda = '99991231'.
  ENDIF.

  CALL FUNCTION 'HR_READ_INFOTYPE'
    EXPORTING
      pernr           = pernr
      infty           = infty
      begda           = '18000101'
      endda           = '99991231'
    IMPORTING
      subrc           = w_subrc
    TABLES
      infty_tab       = <f1>
    EXCEPTIONS
      infty_not_found = 1
      OTHERS          = 2.
  IF sy-subrc <> 0.
    subrc = w_subrc.

  ELSE.


  ENDIF.