05-21-2014 8:54 PM
hello everyone,
i want to insert value in internal table from cdpos table taking field name from fname and value from value_new.but the problem is i am not getting how to map the corresponding field of internal table with fname value which is the field name.
for example
i
fieldname | value |
---|---|
name1 | raj |
name2 | sharma |
i want to update field name1. this name1 is there in fname with updated value in value_new how to make name1 with fname value
thanks and regards
laxmikant soni
05-21-2014 9:16 PM
Hi laxmikant,
how about a read-table assigning
Here is the link:
http://help.sap.com/abapdocu_70/en/ABAPREAD_TABLE_OUTDESC.htm
~Florian
05-22-2014 6:14 AM
Hi Laxmikant,
If I have understood your requirement correctly, you need to update an internal table with latest 'value_new' from cdpos table where 'fname' = 'fieldname' .
Hope the below logic will help you:
FIELD-SYMBOLS: <wa_intab> LIKE LINE OF lt_intab. "the internal table you want to change
LOOP AT lt_intab ASSIGNING <wa_intab> .
READ TABLE lt_cdpos INTO wa_cdpos "lt_cdpos contains latest data selected from CDPOS
WITH KEY fname = <wa_intab>-fieldname.
IF sy-subrc = 0.
<wa_intab>-value = wa_cdpos-value_new.
ELSE.
"//logic if the name is not there in CDPOS
ENDIF.
CLEAR wa_cdpos.
ENDLOOP.
If you wish to improve performance, I suggest using
1. "transporting value_new" addition in READ TABLE,
2. select only the data which you require from CDPOS,
3. create the internal tables with only fields which you require,
4. when you are using SELECT,LOOP AT statements, limit records by using WHERE condition
Regards,
Kavya