2008 Mar 17 12:27 PM
Hi,
I have created a table and a structure dynamically, now is it possible to pass thse as parameters to a subroutine either as a field-symbol or as a reference variable?
If Yes, How?
-Sudheer
Hi,
I have created a table and a structure dynamically, now is it possible to pass thse as parameters to a subroutine either as a field-symbol or as a reference variable?
If Yes, How?
-Sudheer
2008 Mar 17 12:35 PM
In the definition of the subroutine, declare the parameters as field symbols.
Hope this helps.
Thanks,
Balaji
2008 Mar 17 12:46 PM
Hi Balaji,
I have tried, There is no problem in passing a field symbol in the 'perfom' statement.
perform fill-table changing <tab_lfa1>. But, In the 'form' statement how to declare the formal parameters for the field symbol?
I wrote the form statement like below.
form fill-table changing <fs> type any.
endform. " fill-table
Its saying * The name of a data oject can not start with a < and end with > *
-Sudheer
2008 Mar 17 1:02 PM
As you are trying to pass a table, you will need to keep the TABLES parm in the perform.
In the called FORM, tables p_otab will also be required. This will establish addressability to the table.
The Structure is would I would think is the issue. Since your structure is dynamic, this would indicate that the fields are variable in nature. If when creating the structure you used a standard naming convention, you could then establish addressability to each field if you know how many fields are passed. Perhaps you could add this number as one of the paramaters in the PERFORM.
perform this_form tables <dynam_table> using fld_cnt.
*&---------------------------------------------------------------------*
*& Form this_form
*&---------------------------------------------------------------------*
form this_form tables p_otab structure <dynam_struc>
using my_fld_cnt.
FIELD-SYMBOLS:
<f1> type any,
<f2> type any,
<f3> type any,
etc.
data:
field_nbr(3) type n,
field_name(32).
* here you can loop to get addressability
do my_fld_cnt times.
field_num = sy-index.
concatenate '<dynam_struc>-MYFLD' field_num into field_name.
case sy-INDEX.
when 1.
assign field_name to <f1>
when 2.
assign field_name to <f2>
.
.
.
etc.
endcase.
enddo.
endform. " this_form
2008 May 13 9:22 AM
Hi
from the SAP help for form keywords,
Field symbols are special in that their names have to be enclosed in parentheses (<>).
Regards
Saurabh Garg
2008 Mar 17 12:43 PM
I did not test this, but I would think this would work
start-of-selection.
perform this_form tables <dynam_table>.
*&---------------------------------------------------------------------*
*& Form this_form
*&---------------------------------------------------------------------*
form this_form tables p_otab structure <dynam_struc>.
endform. " this_form
<dynam_table> would be your your dynamic table
<dynam_struc> would be your structure of that table.
2008 Mar 17 1:21 PM
2008 Mar 17 1:31 PM
Sudheer,
Can you please provide code for the creation of the dynamic table and structure so I can have a better understanding of your issue.
This will allow me to test locally.
Thanks.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |