2007 Jul 23 11:00 AM
Hi friends,
how do i do the following:
i have an internal table with data and i want the internal table to be passed in a FORM routine, as i need to do some operations on the data within the table, so what i need is how to do the FORM test_itab USING ... statement.
thanks for your help,
points will be awarded instantly!
clemens
2007 Jul 23 11:05 AM
Use stmt
FORM test_itab TABLES <internal table structure>.
......
.......
endform.
2007 Jul 23 11:04 AM
Hi Clemens,
To pass an internal table to a FORM routine, please follow the procedure.
To declare the FORM
FORM test_itab USING fp_itab type Table-type.
****
Code Lines
***
ENDFORM.
To call the FORM:-
PERFORM test_itab USING itab[].
Reward points for useful answers.
Best Regards,
Ram.
2007 Jul 23 11:05 AM
Hi,
Below will give you a detailed over view of how to achive the following.
If you specify the addition TABLES, each table parameter t1 t2 ... for the subroutine called that is defined with the addition TABLES to the FORM statement must be assigned an internal table itab as the actual parameter. The assignment of the actual parameters to the formal parameters takes place using their positions in the lists t1 t2 ... and itab1 itab2 ... .
You can only specify standard tables for itab. Transfer takes place by means of a reference. If a specified table itab has a header line, this is also transferred; otherwise, the header line in the corresponding table parameter t is blank when it is called.
Note
Use of table parameters in the interface for subroutines is obsolete but a large number of subroutines have not yet been converted to appropriately typed USING or CHANGING parameters, so that they must still be supplied with data by the TABLES addition to the PERFORM statement.
Example
Static call of the internal subroutine select_sflight transferring a table parameter.
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.
SELECT *
FROM sflight
INTO TABLE flight_tab
WHERE carrid = f_carr AND
connid = f_conn.
ENDFORM.
Thanks,
Samantak
Rewards points for useful answers.
2007 Jul 23 11:05 AM
Use stmt
FORM test_itab TABLES <internal table structure>.
......
.......
endform.
2007 Jul 23 11:10 AM
Two ways to do that.
I used kna1 as an example of a structure.
(1)
DATA: table_var TYPE STANDARD TABLE OF kna1. "for example
PERFORM form_example TABLES table_var.
and then
FORM form_example TABLES table_var STRUCTURE kna1.
endform.
will transfer the table easily, but TABLES will be obsolete.
note that TABLES allows you to both pass and change the variable table.
(2)
The second way is defining the table type and using the USING.
TYPES: tt_table TYPE STANDARD TABLE OF kna1.
DATA: table_var TYPE tt_table.
in the program:
PERFORM form_example USING table_var[].
and the form will be:
FORM form_example using table_var TYPE tt_table.
ENDFORM.