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: 

modify statement

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Sandeep_Kumar
Advisor
Advisor
0 Kudos

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

14 REPLIES 14

Former Member
0 Kudos

search is sdn,,,,,,

Sandeep_Kumar
Advisor
Advisor
0 Kudos

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

Former Member
0 Kudos

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

0 Kudos

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.

Former Member
0 Kudos

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.

0 Kudos

>

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

MODIFY KNA1 FROM WA definitely works as long as WA has the same structure. No need for a WHERE. And to add: he's updating the database table KNA1 and not some internal table.

@OP: study the F1 on MODIFY.

0 Kudos

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.

Former Member
0 Kudos

Hi,

modify kna1 from wa.

Hope you are not executing this statement in Production Server.

Regards

Vinod

0 Kudos

>

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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

matt
Active Contributor
0 Kudos

>

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

Former Member
0 Kudos

This message was moderated.

Former Member
0 Kudos

agree with MATT instead of modify statement u can use BAPI

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