05-30-2011 11:33 AM
Hi,
Is it possible to pass a table parameter of user defined type, from the calling program, to a user defined function module? If yes then how to do it? If no then is there a work around for this?
Thanks in advance!!!!
Regards,
Sriram.
05-30-2011 12:07 PM
Hi,
You may define an importing/exporting/changing paramer from type STANDARD TABLE. Of course, to access the table's data in the MF's body, you'll certaily have to make use of data refenreces or instructions like ASSIGN COMPONENT to dynamically acces the table's fields.
Regards
05-30-2011 12:07 PM
Hi,
You may define an importing/exporting/changing paramer from type STANDARD TABLE. Of course, to access the table's data in the MF's body, you'll certaily have to make use of data refenreces or instructions like ASSIGN COMPONENT to dynamically acces the table's fields.
Regards
05-30-2011 12:21 PM
Hi,
Thanks for your reply but I didn';t get you. In the calling program I have defined type
TYPES BEGIN OF ty_bkpf.
INCLUDE STRUCTURE bkpf.
TYPES flag TYPE c.
TYPES END OF ty_bkpf.
Then I'm creating internal table as below.
DATA it_bkpf TYPE STANDARD TABLE OF ty_bkpf.
Now I'm creating a FM where I want to pass it_bkpf. In tables parameters of the FM how to pass it_bkpf? if I define it_bkpf LIKE bkpf then i cannot straight away pass it_bkpf as parameter from calling program.
Regards,
Sriram
05-30-2011 12:37 PM
Hi Sriram,
Create a structure in SE11, having all fields of table BKPF and additional field 'flag' TYPE c. Use this structure to define the internal table it_bkpf in TABLES of FM.
Thanks & Regards
Radhika
05-30-2011 12:50 PM
05-30-2011 1:09 PM
A type defined in your program is only visible within your program. It is unknown to your function module. Function module parameters must either have a generic definition (Blank = ANY, STANDARD TABLE, C, CLIKE etc.) a basic type (T, I etc.) or be defined in the data dictionary.
One possible workaround - depending on what you're trying to achieve - is to define the type in the function module and the calling program, then pass the reference from the program to the FM.
e.g.
Calling program
TYPES my_table_type ...
DATA: my_table TYPE my_table_type,
r_data TYPE REF TO DATA.
...
* populate my_table
GET REFERENCE OF my_table INTO r_data.
CALL FUNCTION MODULE 'Z_MYFM' EXPORTING ir_data = r_data.
FM
TYPES my_table_type ...
FIELD-SYMBOLS: <my_table> TYPE my_table_type.
ASSIGN ir_data->* TO <my_table>.
05-30-2011 1:05 PM
Hi Sriram_14880,
you can always declare the function module import or tables parameters as TYPE ANY or TYPE STANDARD TABLE.
But then you can bot access the fields of the line structure directly but only by assignment.
I guess you are better of by creating structures and/or data elements and related table types in Data Dictionary because then you can use the fields not only in programs but anywhere, screens, functions etc.
Regards,
Clemens