‎2007 Nov 20 5:33 AM
Hi experts
I am using a report with following code , in which itemmaster is a workarea.
SELECT SINGLE * FROM zmartitemmaster CLIENT SPECIFIED INTO itemmaster
WHERE mandt = sy-mandt
AND prodid = prodid.
this work area has fields like itemdes1, itemdes2 and so on . Now problem is that i want to fetch its fields dynamically
so i collected dynamic fiels name inot a variable named <b>var</b> (ex concattenate 'itemdes' '1' to var)
then i am trying t fetch as
MOVE itemmaster-var to X.
but its giving a syntax error as itemmaster does not have a component called VAR.
can any body give any possible solution for getting dynamic fields contents.
Regards
Abhay
‎2007 Nov 20 5:42 AM
Hi
thanks for reply but i want to fetch its fields dynamically ,
and i am storing fields name in <b>var</b> .
so i dont understand how to do it
can you plz explain it with piece of code .
Regards
Abhay
‎2007 Nov 20 5:36 AM
‎2007 Nov 20 5:42 AM
Hi
thanks for reply but i want to fetch its fields dynamically ,
and i am storing fields name in <b>var</b> .
so i dont understand how to do it
can you plz explain it with piece of code .
Regards
Abhay
‎2007 Nov 20 5:47 AM
Hi,
You can use field symbols for it.
e.g. FIELD-SYMBOLS : <fs1>.
Using the function GET_COMPONENT_LIST you can get the fieldnames for the internal table being used in the program into another internal table.
Now, loop at the itab.
CONCATENATE 'zitemmaster-' itab-fieldname into str.
ASSIGN (str) to <fs1>.
ENDLOOP.
This will populate the value of zitemmaster-itemdes1, itemdes2 etc. one by one in the field symbol which we can use.
Hope it helps.
Regards,
Himanshu
‎2007 Nov 20 5:48 AM
Use field symbols to get the info
field-symbols: <fs> type any.
assign component Var of structure itemmaster to <fs>
Regards,
abhishek
‎2007 Nov 20 6:57 AM
Hi Himanshu and abhishek
Thanks a lot , problem solved
Regards
abhay
‎2007 Nov 20 6:58 AM