Skip to Content
avatar image
Former Member

modify statement

how to modify a standard table using MODIFY statement in abap??

i have used the following statement but it is not working.

data : wa type kna1.

case su-ucomm.

when 'SUBMIT'.

select single * from kna1 into wa where kunnr = kna1-kunnr.

read table i_kna1 with key kunnr = kna1-kunnr.

if sy-subrc = 0 .

modify kna1 from wa.

endcase.

can anybody suggest me anything.

resma

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

9 Answers

  • Best Answer
    Sep 21, 2010 at 10:31 AM

    read table i_kna1 with key kunnr = kna1-kunnr.

    if sy-subrc = 0 .

    modify kna1 from wa.

    endcase.

    I do not see anything modified here ...

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 21, 2010 at 10:30 AM

    search is sdn,,,,,,

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 21, 2010 at 10:31 AM

    Hello,

    First of all you need to use COMMIT WORK after the Modify statement. Also, it is advisable to use where clause after MODIFY statement.

    Hope this helps,

    Regards,

    Himanshu

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      data : wa type kna1.

      case sy-ucomm.

      when 'BACK'.

      leave program .

      when 'SUBMIT'.

      select single * from kna1 into wa where kunnr = kna1-kunnr.

      if sy-subrc = 0 .

      modify kna1 from wa.

      commit work.

      endif.

      endcase.

      endmodule.

      i am doing it through a screen.

      is this the correct format.

      can u advise me.

  • avatar image
    Former Member
    Sep 21, 2010 at 10:46 AM

    Hi,

    Modify statement without "WHERE" clause will not work in case of "READ TABLE" (as in your code), it will work only with the "LOOP" statement.

    For the "READ TABLE" try using the Modify statement with "TRANSPORTING" and "WHERE" clause. To know the correct syntax press F1 on Modify statment.

    Hope this may be helpful.

    Regards,

    Sharin.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi,

      I wrongly assumed it as an internal table instead of database table. As Maen said, there is no need of "WHERE" in case of database updation as long as WA has the same structure.

      Since it is a database updation, use "COMMIT WORK".

      Maen,

      Thanks for correcting.

      Regards,

      Sharin.

  • Sep 21, 2010 at 10:59 AM

    Hi,

    modify kna1 from wa.

    Hope you are not executing this statement in Production Server.

    Regards

    Vinod

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      >

      > Hi,

      >

      >

      modify kna1 from wa.

      >

      > Hope you are not executing this statement in Production Server.

      >

      > Regards

      > Vinod

      Judging by his code, he won't be changing anything. 😊

      selection into WA, but no changes made to WA.

  • Sep 21, 2010 at 11:21 AM

    Use Commit statement after Modify statement.

    As Modify statement inserts/overwrites a record so please specify the specific record number in where clause.

    Regards,

    Amit

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 21, 2010 at 11:28 AM

    Hi,

    Modifing a standard table from SAP and doing that the way you propose, can result in loosing support from SAP. Never modify standard SAP tables unless doing it via BAPI's provided by SAP.

    Please have a look at BAPI:

    SD_CUSTOMER_MAINTAIN_ALL

    Many others are available too.

    Best regards,

    Guido Koopmann

    Add comment
    10|10000 characters needed characters exceeded

    • >

      > Hi,

      >

      > Modifing a standard table from SAP and doing that the way you propose, can result in loosing support from SAP. Never modify standard SAP tables unless doing it via BAPI's provided by SAP.

      >

      > Please have a look at BAPI:

      > SD_CUSTOMER_MAINTAIN_ALL

      >

      > Many others are available too.

      >

      > Best regards,

      >

      > Guido Koopmann

      So important I thought I'd mention it again.

      Modifing a standard table from SAP and doing that the way you propose, can result in loosing support from SAP. Never modify standard SAP tables unless doing it via BAPI's provided by SAP.

  • avatar image
    Former Member
    Sep 21, 2010 at 11:33 AM

    This message was moderated.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 22, 2010 at 09:20 AM

    agree with MATT instead of modify statement u can use BAPI

    Edited by: kk.adhvaryu on Sep 22, 2010 11:21 AM

    Add comment
    10|10000 characters needed characters exceeded