‎2006 Dec 26 10:53 AM
Hi all.
I'm trying to update values from one internal table to another internal table for particular fields. The fields to be updates is specified in CARRIER-FIELD_NAME.
I have to pick particular field value from internal table ITAB1 and update it into corresponding field of internal table ITAB2.
for example: if carrier-field_name has value FROMDATE, then I have to fetch value of ITAB1-FROMDATE and update it into ITAB2-FROMDATE.
Following code sniplet is written by me to do the functionality, but the statement
<fs1> = <fs> , is not puting fetched data into internal table ITAB2.
Can anyone help me out with this ?
FIELD-SYMBOLS: <fs> TYPE ANY,
<fs1> TYPE ANY.
LOOP AT itab1.
LOOP AT carrier.
field = carrier-field_name.
CONCATENATE 'ITAB1-' field INTO val1.
ASSIGN (val1) TO <fs>.
CONCATENATE 'ITAB2-' field INTO val2.
ASSIGN val2 TO <fs1>.
<fs1> = <fs>.
APPEND itab2.
ENDLOOP.
ENDLOOP.
‎2006 Dec 26 11:07 AM
Hi
I believe you should append the record to ITAB2 out of the loop of the CARRIER table.
Try to use ASSIGN COMPONENT in this way
LOOP AT itab1.
LOOP AT carrier.
field = carrier-field_name.
ASSIGN COMPONENT FIELD OF STRUCTURE ITAB1 TO <FS>.
IF SY-SUBRC = 0.
ASSIGN COMPONENT FIELD OF STRUCTURE ITAB2 TO <FS1>.
IF SY-SUBRC = 0.
<fs1> = <fs>.
ENDIF.
ENDIF.
ENDLOOP.
IF NOT ITAB2 IS INITIAL.
APPEND itab2.
ENDIF
ENDLOOP.
Max
‎2006 Dec 26 11:07 AM
Hi
I believe you should append the record to ITAB2 out of the loop of the CARRIER table.
Try to use ASSIGN COMPONENT in this way
LOOP AT itab1.
LOOP AT carrier.
field = carrier-field_name.
ASSIGN COMPONENT FIELD OF STRUCTURE ITAB1 TO <FS>.
IF SY-SUBRC = 0.
ASSIGN COMPONENT FIELD OF STRUCTURE ITAB2 TO <FS1>.
IF SY-SUBRC = 0.
<fs1> = <fs>.
ENDIF.
ENDIF.
ENDLOOP.
IF NOT ITAB2 IS INITIAL.
APPEND itab2.
ENDIF
ENDLOOP.
Max
‎2006 Dec 26 11:29 AM
‎2006 Dec 26 11:11 AM
Hi,
try this code,u'll surely get it.
tables:sflight.
data:begin of itab1 occurs 0,
carrid like sflight-carrid,
connid like sflight-connid,
fldate like sflight-fldate,
end of itab1.
data:begin of carrier occurs 0,
field_name like sflight-fldate,
end of carrier.
data:begin of itab2 occurs 0,
carrid like sflight-carrid,
connid like sflight-connid,
fldate like sflight-fldate,
end of itab2.
suppose if the field is fldate,then itab2 will be updated by fldate field with data taken from itab1.
carrier-field_name = 'fldate'.
select carrid connid fldate from sflight into table itab1.
case carrier-field_name.
when 'fldate'.
loop at itab1.
itab2-fldate = itab1-fldate.
append itab2.
endloop.
endcase.
Regards,
Sowjanya