‎2005 Nov 03 1:04 PM
I have problem with assign component:
in a method, i have an exporting parameter type any table.
Therefore i do not know the structure of this. Now i want to fill this table with
assign component 1 of structure it_example[] to <p>.
<p> = "xyz".
Having a structure this is no problem, but a table is not a structure and therefore im getting result code of 4.
Outsite methods i can use tables with headerlines, and the headerline has a structure so with the assign i can fill the header line.
In OO context, tables with headerlines are not allowed. So how can i fill the table if i do not have a glue what the structure looks like? Any idea?
‎2005 Nov 03 1:23 PM
Hi Rainer,
You can use this format.
DATA: dref TYPE REF TO DATA.
FIELD-SYMBOLS: <fs> TYPE ANY.
CREATE DATA dref TYPE <table>.
ASSIGN dref->* TO <fs>.
Here 'create data' creates anonymous data object of the table.The dref points to the work area of the table.
Then assign the workarea to the field symbol.
Regards.
Lavanya.
‎2005 Nov 03 1:07 PM
HI Rainer,
i think you have to define a structure and use this.
E.g.
data wa_example type "same type of it_example".
Use the assign with this structure, and after append it to the table.
Bye
enzo
‎2005 Nov 03 1:10 PM
I really want to avoid haveing an additional paramter in the siganture of the method.
DATA:
wa_internal like line of <imported_table>
didnt worked either
‎2005 Nov 03 1:08 PM
hi,
try with this
assign component 1 of structure it_example to <p>.
cheers,
sasi
‎2005 Nov 03 1:11 PM
‎2005 Nov 03 1:12 PM
Hi,
Use something similar to the following,
FIELD-SYMBOLS: <fs>, <fval>.
ASSIGN LOCAL COPY OF INITIAL LINE OF it_example
TO <fs>.
IF <fs> IS ASSIGNED.
ASSIGN COMPONENT 1 OF STRUCTURE <fs> TO <fval>.
IF <fval> IS ASSIGNED.
<fval> = 'xyz'.
ENDIF.
APPEND <fs> TO it_example.
ENDIF.
Hope this helps..
Sri
‎2005 Nov 03 1:13 PM
Hi Rainer,
check with this code.Hope it works.
LOOP AT datatab.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE
datatab TO <fs>.
IF sy-subrc <> 0.
EXIT.
ENDIF.
ENDDO.
ENDLOOP.
reward me if this works.
Thanks,
Vamsi.
‎2005 Nov 03 1:16 PM
Hi,
as you want to fill the table - not any non-existing header line, you must populate the table record by record, that means LOOP.
field-symbols:
<fs> type any.
loop at it_example assigning <fs>.
assign component 1 of structure <fs> to <p>.
<p> = "xyz".
endloop." at it_example assigning <fs>.
fast. efficient.
C.
‎2005 Nov 03 1:23 PM
Hi Rainer,
You can use this format.
DATA: dref TYPE REF TO DATA.
FIELD-SYMBOLS: <fs> TYPE ANY.
CREATE DATA dref TYPE <table>.
ASSIGN dref->* TO <fs>.
Here 'create data' creates anonymous data object of the table.The dref points to the work area of the table.
Then assign the workarea to the field symbol.
Regards.
Lavanya.
‎2005 Nov 03 1:42 PM
Hi,
assign local copy solved it too, but is not allowed in OO context.
Yours is the solution except that
CREATE DATA dref like line of datatable.
ASSIGN dref->* TO <fs>.
is the 100% solution
Otherwise youre getting problems with
insert <fs> into table datatable.
Thanks a lot to you both.