Application Development 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: 

perform statement with tables addition ??

Former Member
0 Kudos

hi all,

can someone help me in understanding perform statements with additions tables.

I know basic perform statement.

like

data : a(5) type c,

b(5) type c,

c(5) type c.

perform add.

write c.

form add.

a = b + c.

endform.

please help mein understanding perform statement with tables, Example would be great.

Thank you.

Madhu.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Try the below example program :

PERFORM get_data TABLES table1.

PERFORM get_data TABLES table2.

PERFORM get_data TABLES table3.

FORM get_data TABLES p_tab_data.

FIELD-SYMBOLS: <wa> TYPE ANY.

LOOP AT p_tab_data ASSIGNING <wa>.

ENDLOOP.

endform.

You use tables because reusability .

Thanks

Seshu

8 REPLIES 8

Former Member
0 Kudos

Hi,

Check this..


DATA: t_mara TYPE STANDARD TABLE OF mara.

PERFORM display TABLES t_mara.

*---------------------------------------------------------------------*
*       FORM display                                                  *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*  -->  LT_MARA                                                       *
*---------------------------------------------------------------------*
FORM display TABLES lt_mara STRUCTURE mara.

  LOOP AT lt_mara.
    WRITE: / lt_mara-matnr.
  ENDLOOP.

ENDFORM.

Thanks

Naren

Former Member
0 Kudos

Madhu,

In below example we are passing ITAB to the perform & using the contents in between form & end form.

TYPES: BEGIN OF ITAB_TYPE,

TEXT(50),

NUMBER TYPE I,

END OF ITAB_TYPE.

DATA: ITAB TYPE STANDARD TABLE OF ITAB_TYPE WITH

NON-UNIQUE DEFAULT KEY INITIAL SIZE 100,

BEGIN OF ITAB_LINE,

TEXT(50),

NUMBER TYPE I,

END OF ITAB_LINE,

STRUC like T005T.

...

PERFORM DISPLAY TABLES ITAB

USING STRUC.

FORM DISPLAY TABLES PAR_ITAB STRUCTURE ITAB_LINE

USING PAR like T005T.

DATA: LOC_COMPARE LIKE PAR_ITAB-TEXT.

WRITE: / PAR-LAND1, PAR-LANDX.

...

LOOP AT PAR_ITAB WHERE TEXT = LOC_COMPARE.

...

ENDLOOP.

ENDFORM.

ferry_lianto
Active Contributor
0 Kudos

Hi,

Please try something like this.


DATA: BEGIN OF ITAB OCCURS 100,
        TEXT(50),
        NUMBER TYPE I,
      END   OF ITAB.
      STRUC LIKE T005T.
...
PERFORM DISPLAY TABLES ITAB
                USING  STRUC.

FORM DISPLAY TABLES PAR_ITAB STRUCTURE ITAB
             USING  PAR STRUCTURE T005T.
  DATA LOC_COMPARE LIKE PAR_ITAB-TEXT.

  WRITE: / PAR-LAND1, PAR-LANDX.
  ...
  LOOP AT PAR_ITAB WHERE TEXT = LOC_COMPARE.
    ...
  ENDLOOP.
  ...
ENDFORM.

Regards,

Ferry Lianto

Former Member
0 Kudos

Try the below example program :

PERFORM get_data TABLES table1.

PERFORM get_data TABLES table2.

PERFORM get_data TABLES table3.

FORM get_data TABLES p_tab_data.

FIELD-SYMBOLS: <wa> TYPE ANY.

LOOP AT p_tab_data ASSIGNING <wa>.

ENDLOOP.

endform.

You use tables because reusability .

Thanks

Seshu

0 Kudos

hi seshu,

first of all thanks, i saw ur reply in this thread and it solved my problem.

thanks

0 Kudos

hi seshu,

first of all thanks, i saw ur reply in this thread and it solved my problem.

but i din't understand y v have to use following code.

FIELD-SYMBOLS: <wa> TYPE ANY.

LOOP AT p_tab_data ASSIGNING <wa>.

ENDLOOP.

can u explain me indetail with example.

thanks

Former Member
0 Kudos

Hi Check this..

TABLES allows you to pass internal tables to a subroutine.

Example

TYPES: BEGIN OF ITAB_TYPE,

TEXT(50),

NUMBER TYPE I,

END OF ITAB_TYPE.

DATA: ITAB TYPE STANDARD TABLE OF ITAB_TYPE ,

BEGIN OF ITAB_LINE,

TEXT(50),

NUMBER TYPE I,

END OF ITAB_LINE,

STRUC like T005T.

PERFORM DISPLAY TABLES ITAB

USING STRUC.

FORM DISPLAY TABLES PAR_ITAB STRUCTURE ITAB_LINE

USING PAR like T005T.

DATA: LOC_COMPARE LIKE PAR_ITAB-TEXT.

WRITE: / PAR-LAND1, PAR-LANDX.

...

LOOP AT PAR_ITAB WHERE TEXT = LOC_COMPARE.

...

ENDLOOP.

ENDFORM.

Within the subroutine DISPLAY, you can use any internal table operation to work with the internal table that you passed to it.

Note

If you use TABLES, it must always be the first addition in a PERFORM statement.

Hope this Helps///

Former Member
0 Kudos

DATA:

it_sflight TYPE TABLE OF sflight.

select carrid connid from sflight into corresponding fields of table it_sflight.

PERFORM

display TABLES it_sflight.

&----


*& Form display

&----


  • text

----


  • -->P_IT_SFLIGHT text

----


FORM display TABLES p_it_sflight STRUCTURE sflight .

data:

wa_sflight like line of p_it_sflight.

LOOP AT p_it_sflight INTO wa_sflight.

write : wa_sflight-carrid,wa_sflight-connid .

write /.

ENDLOOP.