09-21-2010 11:25 AM
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
09-21-2010 11: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 ...
09-21-2010 11:30 AM
09-21-2010 11: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 ...
09-21-2010 11: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
09-21-2010 11:40 AM
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.
09-21-2010 11: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.
09-21-2010 11:50 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.
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.
09-21-2010 12:28 PM
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.
09-21-2010 11:59 AM
Hi,
modify kna1 from wa.
Hope you are not executing this statement in Production Server.
Regards
Vinod
09-21-2010 12:28 PM
>
> 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.
09-21-2010 12:21 PM
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
09-21-2010 12:28 PM
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
09-21-2010 12:50 PM
>
> 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.
09-21-2010 12:33 PM
09-22-2010 10:20 AM
agree with MATT instead of modify statement u can use BAPI
Edited by: kk.adhvaryu on Sep 22, 2010 11:21 AM