‎2009 Aug 08 12:33 PM
Hi experts ,
I have a internal table it_temp has two fields name and value.
name value
wage1 10.00
wage2 12.00
wage3 14.00
wage4 108.00
wage5 1050.00
wage6 100.00
wage7 75.00
like this i have 237 rows.
now i have a it_final table which has the 237+1 fields as the value of names
structure of it_final.
pernr wage1 wage2 wage3 wage4 wage5 wage 6 wage7 wage8 ..... wage273.
i want to create a row of it_final by fetching the value from it_temp.
like
1 10.00 12.00 14.00 108.00 1050.00 100.00 75.00 ..... .. upto 237 values
pls suggest me what to do for such case.
thanks
Ajay
‎2009 Aug 08 1:47 PM
Hi,
Do as follows:-
Create a field symbols which is having a type as the line of it_final.
data: G_OBJ type ref to data.
field-symbols: <fs> type any
field-symbols : <FIELD> type any.
CREATE DATA G_OBJ LIKE LINE OF IT_FINAL.
* creating a work area of the internal table IT_FINAL
ASSIGN G_OBJ->* TO <FS>.
IF <FS> IS ASSIGNED.
LOOP AT IT_TEMP INTO WA.
* assigning the particular column of the workarea of it_final to a field symbol so that
* the value will be passed to that particular column of the workarea
ASSIGN COMPONENT WA-NAME OF STRUCTURE <fs> TO <FIELD>.
IF <FIELD> IS ASSIGNED.
<FIELD> = WA-VALUE.
ENDIF.
UNASSIGN : <FIELD>.
ENDLOOP.
<FS>-PERNR = 1.
APPEND <FS> TO IT_FINAL.
ENDIF.I hope you get teh concept.
regards,
Ankur Parab
Edited by: Ankur Parab on Aug 8, 2009 6:17 PM
‎2009 Aug 08 1:47 PM
Hi,
Do as follows:-
Create a field symbols which is having a type as the line of it_final.
data: G_OBJ type ref to data.
field-symbols: <fs> type any
field-symbols : <FIELD> type any.
CREATE DATA G_OBJ LIKE LINE OF IT_FINAL.
* creating a work area of the internal table IT_FINAL
ASSIGN G_OBJ->* TO <FS>.
IF <FS> IS ASSIGNED.
LOOP AT IT_TEMP INTO WA.
* assigning the particular column of the workarea of it_final to a field symbol so that
* the value will be passed to that particular column of the workarea
ASSIGN COMPONENT WA-NAME OF STRUCTURE <fs> TO <FIELD>.
IF <FIELD> IS ASSIGNED.
<FIELD> = WA-VALUE.
ENDIF.
UNASSIGN : <FIELD>.
ENDLOOP.
<FS>-PERNR = 1.
APPEND <FS> TO IT_FINAL.
ENDIF.I hope you get teh concept.
regards,
Ankur Parab
Edited by: Ankur Parab on Aug 8, 2009 6:17 PM
‎2009 Aug 09 9:49 AM
‎2009 Aug 09 10:52 AM
after loop when i try to write this
<FS>-PERNR = 1.
it is sowing and error that data object <fs> has no structure and therefore no component called pernr.
Please help hoe to do
‎2009 Aug 08 4:09 PM
Hi,
your internal table it_final Should be dynamic for this case.
Your internal table it_itab will consists of following fields
Work area
__________
name value
wage1 10.00
wage2 12.00
wage3 14.00
wage4 108.00
wage5 1050.00
wage6 100.00
wage7 75.00
.
.
.
till 237 rows.
in the it_final,
The wage columns will not be of type character as in this columns you have to store the workarea in them.
Create your dynamic internal table using the class
CL_ALV_TABLE_CREATE and method CREATE_DYNAMIC_TABLE.
You will have to create a fieldcatalog table and pass to the method.
Then use the dynamic internal table created to store your data horizontally against each wage column.
Display the output in an ALV.
Pass the WAGE values as the description for each WAGE column in the ALV.
Regards,
Akash Rana
‎2009 Aug 09 10:54 AM