11-01-2007 8:12 PM
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.
11-01-2007 8:41 PM
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
11-01-2007 8:16 PM
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
11-01-2007 8:17 PM
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.
11-01-2007 8:18 PM
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
11-01-2007 8:41 PM
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
01-30-2008 7:11 AM
hi seshu,
first of all thanks, i saw ur reply in this thread and it solved my problem.
thanks
01-30-2008 7:22 AM
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
11-02-2007 1:57 AM
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///
01-30-2008 7:39 AM
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.