2006 Mar 24 8:37 AM
Hello everybody,
i need to solve the following problem:
data: l_structure type DFIES-FIELDNAME,
ls_outtab type ref to data,
lt_outtab type ref to data.
fieldsymbols: <lt_outtab> type standard table,
<ls_outtab> type any.
l_structure = 'ZZ_TEST'.
* The DDIC Structure ZZ_TEST has 2 fields: A and B both CHAR10.
* Table
create data outtab type standard table of (l_structure).
assign outtab->* to <lt_outtab>.
* Workarea
create data ls_outtab type (l_structure).
assign table field ls_outtab->* to <ls_outtab>
The question now is, how can i assign the workarea <ls_outtab> a value to its field A and to its field B?
The codeline "<ls_outtab>-A = 'xyz'" gives me a syntax error.
best regards
Markus
2006 Mar 24 8:59 AM
Hi!
You can do it by::
FIELD-SYMBOLS: <field> TYPE ANY.
ASSIGN COMPONENT 'SOME_FIELDNAME' OF STRUCTURE <ls_outtab> TO <field>.
* do whatever you want with <field>
If you want to append fields to your table, you can do:
FIELD-SYMBOLS: <field> TYPE ANY,
<ls_outtab> TYPE ANY.
APPEND INITIAL LINE TO <lt_outtab>.
READ TABLE <lt_outtab> ASSIGNING <ls_outtab> INDEX sy-tfill.
ASSIGN COMPONENT 'SOME_FIELDNAME' OF STRUCTURE <ls_outtab> TO <field>.
* do whatever you want with <field>
Note that you don't need to hassle with typing - both your <ls_outtab> and <field> can be TYPE ANY.
Hope this helps.
Regards,
Igor
2006 Mar 24 8:59 AM
Hi!
You can do it by::
FIELD-SYMBOLS: <field> TYPE ANY.
ASSIGN COMPONENT 'SOME_FIELDNAME' OF STRUCTURE <ls_outtab> TO <field>.
* do whatever you want with <field>
If you want to append fields to your table, you can do:
FIELD-SYMBOLS: <field> TYPE ANY,
<ls_outtab> TYPE ANY.
APPEND INITIAL LINE TO <lt_outtab>.
READ TABLE <lt_outtab> ASSIGNING <ls_outtab> INDEX sy-tfill.
ASSIGN COMPONENT 'SOME_FIELDNAME' OF STRUCTURE <ls_outtab> TO <field>.
* do whatever you want with <field>
Note that you don't need to hassle with typing - both your <ls_outtab> and <field> can be TYPE ANY.
Hope this helps.
Regards,
Igor
2006 Mar 24 9:08 AM
Hello Markus,
After the statement <b>assign outtab->* to <lt_outtab>.</b> in your code, you can do the following -
loop at <lt_outtab> assigning <ls_outtab>.
" do your processing using <b>assign component of</b>
endloop.
Regards,
Anand Mandalika.
2006 Mar 24 9:16 AM
Hello,
thanx to for very fast answers
What i want to do is assign content to the different fields of the structure <ls_outtab> and then append this content to the table <lt_outtab>.
so at runtime <ls_outtab> has 2 fields A and B. I want to add content to field A and to field B. Then i want to append this new line to table <lt_outtab>.
regards,
Markus
2006 Mar 24 9:22 AM
Thanx Igor,
your lines
APPEND INITIAL LINE TO <lt_outtab>.
READ TABLE <lt_outtab> ASSIGNING <ls_outtab> INDEX sy-tfill.
ASSIGN COMPONENT 'SOME_FIELDNAME' OF STRUCTURE <ls_outtab> TO <field>.
* do whatever you want with <field>
are working great Thanx!
best regards,
Markus
2006 Mar 24 9:24 AM
Markus,
This is exactly what my suggestion is doing. Have you tried it? Here it is, once again, a little bit modified to make it more clear:
FIELD-SYMBOLS: <field> TYPE ANY,
<ls_outtab> TYPE ANY.
APPEND INITIAL LINE TO <lt_outtab>.
READ TABLE <lt_outtab> ASSIGNING <ls_outtab> INDEX sy-tfill.
ASSIGN COMPONENT 'A' OF STRUCTURE <ls_outtab> TO <field>.
<field> = 'Value of the field A'.
ASSIGN COMPONENT 'B' OF STRUCTURE <ls_outtab> TO <field>.
<field> = 'Value of the field B'.
Regards,
Igor
2006 Mar 24 9:25 AM
Sorry, I guess we were typing at the same time. I'm glad it works.
Igor