‎2007 Oct 04 11:06 AM
Hi all,
I need to create a FM with an interface like this:
IMPORTING
strucname
CHANGING
ls_data.
ls_data is unstructured, I think it will be TYPE ANY, in the field STRUCNAME I will receive the name of the structure in order to read and change the content of ls_data.
How can I manage this?
I cannot use something like:
CASE strucname.
when 'EKKO'.
when 'VBAK'.
ENDCASE.
because I don't know in advance which are the structures that will be used to call the function.
Thank you for any support
Bye
Paola
‎2007 Oct 04 1:19 PM
1. validate the structure name and create a data reference of the structure dynamically and assign values
to the dynamic structure
2. check the following sample code which helps to achieve ur requirement
DATA dref TYPE REF TO data.
FIELD-SYMBOLS: <wa> TYPE ANY,
<comp> TYPE ANY.
CREATE DATA dref TYPE (strucname).
ASSIGN dref->* TO <wa>.
DO.
ASSIGN COMPONENT sy-index
OF STRUCTURE <wa> TO <comp>.
IF sy-subrc = 0.
<comp> = assign values according to the datatype.
ELSE.
EXIT.
ENDIF.
ENDDO.
Message was edited by:
Rajesh
‎2007 Oct 04 11:10 AM
Paola,
Use the strucname as an include structure for your table instead of writing a condition as u never know what structure your ls_data will be of and if u write case, u will have to consider all tables...
Reward if helpful,
Karthik
‎2007 Oct 04 1:08 PM
Hi Karthik,
sorry but I cannot understand your point.
Con you please attach some code example?
Thank you very much
Bye
Paola
‎2007 Oct 04 1:19 PM
1. validate the structure name and create a data reference of the structure dynamically and assign values
to the dynamic structure
2. check the following sample code which helps to achieve ur requirement
DATA dref TYPE REF TO data.
FIELD-SYMBOLS: <wa> TYPE ANY,
<comp> TYPE ANY.
CREATE DATA dref TYPE (strucname).
ASSIGN dref->* TO <wa>.
DO.
ASSIGN COMPONENT sy-index
OF STRUCTURE <wa> TO <comp>.
IF sy-subrc = 0.
<comp> = assign values according to the datatype.
ELSE.
EXIT.
ENDIF.
ENDDO.
Message was edited by:
Rajesh
‎2007 Oct 04 2:20 PM
Hi Rajesh
sorry: it seemed all clear at the beginning, but now I cannot understand how to assign the values I have in ls_data before changing them.
Thanks
Paola
‎2007 Oct 04 2:22 PM
I found a little problem with the code, so I asked for a new explanation
‎2007 Oct 11 3:54 PM