08-03-2006 9:52 PM
Hi all,
I have a table 'tab' with some records and this table 'tab' has two keys. I want to read a particular record with the two keys(I have these two key values). This record has a field unit of measure which is always 'L' and I want to overwrite Unit of measure value to 'Kg' in that field and modify the table with that row entry.
How can I do this. Please help..... Waiting....
08-04-2006 6:01 AM
Hi Raju,
Do like tjis:-
read table itab with key key1 = ? key2 = ?.
itab-unit = 'KG'.
modify itab index sy-tabix.
Hope this helps.
Reward if helpful.
Regards
-
Sachin Dhingra
08-03-2006 9:58 PM
READ TABLE TAB WITH KEY KEY1 = VALUE1
KEY2 = VALUE2.
IF SY-SUBRC EQ 0.
UOMFIELD = 'KG'.
MODIFY TAB.
ENDIF.
08-03-2006 10:15 PM
Hi,
Check this code :
select fld1 fld2 form Ztable into table i_tab.
loop at i_tab where fld1 = <val1> and
fld2 = <val2>.
i_tab-fld2 = 'kg'.
modify i_tab.
endloop.
Changed code :
<b>
loop at i_tab where unit = 'L'.
i_tab-unit = 'kg'.
modify i_tab.
endloop.</b>
modify ztable from table i_tab.
Regards
Appana
*Reward Points for helpful answers
Message was edited by: L Appana
08-03-2006 10:29 PM
Hi Guys,
Thanks for the replies. I will show how my table looks like
key1 key2 name unit amount
-
1 2 asd P 100.00
3 4 ash L 200.00
5 6 adsf P 300.00
-
Let us say I have the key values 3 and 4. Here I want to read the record with keys 3 and 4 and overwrite the value 'L' in the field of the record with 'Kg' and modify the table with that record. SO modified table should look like....
key1 key2 name unit amount
-
1 2 asd P 100.00
3 4 ash Kg 200.00
5 6 adsf P 300.00
-
Please help. Waiting for replies......
08-03-2006 10:31 PM
Sorry I have formatting problems. here is my table
key1 | key2 | name | unit |amount
-
1 | 2 | asd | P | 100.00
3 | 4 | ash | L | 200.00
5 | 6 | adsf | P |300.00
-
I want the table to be modifed as
key1 | key2 | name | unit |amount
-
1 | 2 | asd | P | 100.00
3 | 4 | ash | Kg | 200.00
5 | 6 | adsf | P |300.00
-
08-03-2006 10:36 PM
08-03-2006 10:37 PM
Use te code button above and enclose your lines between the tags to keep the format intact.
08-03-2006 10:39 PM
08-03-2006 10:47 PM
In that case all you have to do is as follows
CLEAR itab-unit.
itab-unit = 'KG'.
MODIFY itab TRANSPORTING unit WHERE unit = 'L'.
08-04-2006 7:30 AM
read table ITAB with key KEY1 = 3
KEY2 = 4.
IF SY-SUBRC = 0.
ITAB-NAME = 'KG'.
MODIFY ITAB INDEX SY-TABIX TRANSPORTING NAME.
ENDIF.
Regards
Srikanth.
08-03-2006 10:25 PM
Are you talking about internal table or database table? It looks like you are talking about database table. Is it standard SAP or custom table? If it is standard SAP table, I don't suggest you modify them this way. Let us know the table name. If it is custom table, you are saying that it has two key fields key1 and key2, let us say. Is UOM one of them or is it a non-key field?
08-04-2006 6:01 AM
Hi Raju,
Do like tjis:-
read table itab with key key1 = ? key2 = ?.
itab-unit = 'KG'.
modify itab index sy-tabix.
Hope this helps.
Reward if helpful.
Regards
-
Sachin Dhingra
08-04-2006 7:45 AM
Hi Raju,
Let this be internal table it_test
key1 | key2 | name | unit |amount
------------------------------------
1 | 2 | asd | P | 100.00
3 | 4 | ash | L | 200.00
5 | 6 | adsf | P |300.00
-------------------------------------
Lets assume that ( name = L ) can occur mulitple times
for different records in the internal table.
Then add this chunk of code to modify the contents of the field name form <b>L</b> to <b>Kg</b>.
LOOP AT it_test WHERE name = 'L'.
it_test-name = 'Kg'.
MODIFY it_test INDEX sy-tabix TRANSPORTING name.
ENDLOOP.
Regards,
AS