Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

how to update value in internal table from cdpos taking fname n value_new?

laxmikant_soni
Explorer
0 Kudos

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

fieldnamevalue
name1raj
name2sharma

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

2 REPLIES 2

Florian
Active Contributor
0 Kudos

Hi laxmikant,

how about a read-table assigning

Here is the link:

http://help.sap.com/abapdocu_70/en/ABAPREAD_TABLE_OUTDESC.htm

~Florian

Former Member
0 Kudos

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