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

Passing diffrent internal table in Subroutine

Former Member
0 Likes
724

Hello Frn's ,

i want to pass diffrent internal table of diffrent structure inside a subroutine . is it possible ?

if yes than Please guide me .

Example : Perfrom subroutine_1 tables itab1 .

Perfrom subroutine_1 tables itab2 .

Perfrom subroutine_1 tables itab3 .

Form subroutine_1 tables (????).

endform .

Thanks and Regards .

Priyank

Hello Frn's ,

i want to pass diffrent internal table of diffrent structure inside a subroutine . is it possible ?

if yes than Please guide me .

Example : Perfrom subroutine_1 tables itab1 .

Perfrom subroutine_1 tables itab2 .

Perfrom subroutine_1 tables itab3 .

Form subroutine_1 tables (????).

endform .

Thanks and Regards .

Priyank

5 REPLIES 5
Read only

former_member842213
Participant
0 Likes
694

PARAMETERS: p_carr TYPE sflight-carrid,

p_conn TYPE sflight-connid.

DATA sflight_tab TYPE STANDARD TABLE OF sflight.

PERFORM select_sflight TABLES sflight_tab

USING p_carr p_conn.

...

FORM select_sflight TABLES flight_tab LIKE sflight_tab

USING f_carr TYPE sflight-carrid

f_conn TYPE sflight-connid.

endform

Read only

Former Member
0 Likes
694

Hi ,

If the sub routine is written in the same program as that of perform then no need to specify table .

Else use the concept of field symbol while passing data to Subroutine

Read only

0 Likes
694

you can either use field symbols (search SCN for these) and you can also use type ANY

Read only

Former Member
0 Likes
694

Hi Priyank,

In Form defination Just declare name for your tables parameter but do not associate any type to it. e. g.

Form subroutine_1 tables t_tab.

endform

Thanks and Regards,

Vaibhav Pendse

Read only

venkat_o
Active Contributor
0 Likes
694

Hi Priyank, Here are two methods. both are correct.

PERFORM getdata_1 TABLES it_t001.
  PERFORM getdata_2 TABLES it_t001.
"      Form  GETDATA_1
*&---------------------------------------------------------------------*
FORM getdata_1  TABLES  p_it_t001.
ENDFORM.                                                    " GETDATA_1
"      Form  GETDATA_2
FORM getdata_2  TABLES   p_it_t001 STRUCTURE  it_t001.
ENDFORM.                                                    " GETDATA_2
Try this program .
REPORT  ztest_notepad.
DATA: BEGIN OF it_t001 OCCURS 0,
        bukrs TYPE t001-bukrs,
        butxt TYPE t001-butxt,
        ort01 TYPE t001-ort01,
      END OF it_t001.
DATA: length TYPE char3.
DATA: BEGIN OF it_file OCCURS 0,
        data(1000) TYPE  c,
      END OF it_file.
START-OF-SELECTION.
  SELECT * FROM t001 INTO CORRESPONDING FIELDS OF TABLE it_t001 UP TO 10 ROWS.
  PERFORM getdata_1 TABLES it_t001.
  PERFORM getdata_2 TABLES it_t001.
"      Form  GETDATA_1
FORM getdata_1  TABLES  p_it_t001.
  SELECT * FROM t001 INTO CORRESPONDING FIELDS OF TABLE it_t001 UP TO 10 ROWS.
  LOOP AT it_t001.
    CONCATENATE it_t001-bukrs it_t001-butxt it_t001-ort01 INTO it_file-data SEPARATED BY '|'.
    APPEND it_file.
    CLEAR  it_file.
  ENDLOOP.
  CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      filename = 'C:/it_t001_1.txt'
      filetype = 'ASC'
    TABLES
      data_tab = it_t001.
ENDFORM.                                                    " GETDATA_1
"      Form  GETDATA_2
FORM getdata_2  TABLES   p_it_t001 STRUCTURE  it_t001.
  SELECT * FROM t001 INTO CORRESPONDING FIELDS OF TABLE it_t001 UP TO 10 ROWS.
  LOOP AT it_t001.
    CONCATENATE it_t001-bukrs it_t001-butxt it_t001-ort01 INTO it_file-data SEPARATED BY '|'.
    APPEND it_file.
    CLEAR  it_file.
  ENDLOOP.
  CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      filename = 'C:/it_t001_2.txt'
      filetype = 'ASC'
    TABLES
      data_tab = it_t001.
ENDFORM.                                                    " GETDATA_2
Thanks Venkat.O