Skip to Content
author's profile photo Former Member
Former Member

modify contents in a table

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....

Add comment
10|10000 characters needed characters exceeded

5 Answers

  • Posted on Aug 04, 2006 at 05: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

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 03, 2006 at 08:58 PM

    READ TABLE TAB WITH KEY KEY1 = VALUE1

    KEY2 = VALUE2.

    IF SY-SUBRC EQ 0.

    UOMFIELD = 'KG'.

    MODIFY TAB.

    ENDIF.

    Add comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 03, 2006 at 09: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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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.

  • Posted on Aug 03, 2006 at 09: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?

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 04, 2006 at 06: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

    Add comment
    10|10000 characters needed characters exceeded