Application Development and Automation 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: 
Read only

updating KNA1 table

Former Member
0 Likes
6,765

Hi Experts,

i need to update kna1 table with only one field stcd2.

My requitement

select customer records for range of customers

copy kna1-sortl to kna1-stcd2 and update kna1 table.

Following is the code which i have used

IF NOT it_cdhdr[] IS INITIAL.

SELECT * FROM kna1

INTO TABLE it_kna1

WHERE kunnr EQ ls_cdhdr-objectid.

ENDIF.

LOOP AT it_kna1.

it_kna1-stcd2 = it_kna1-sortl.

MODIFY it_kna1.

CLEAR it_kna1.

ENDLOOP.

ENDIF.

after getting this records how should i update this records so that it should not

affect performance.

1. UPDATE kna1 FROM it_kna1.

COMMIT WORK.

(OR)

2.

LOOP AT it_kna1.

UPDATE kna1

SET stcd2 = it_kna1-stcd2

WHERE kunnr EQ it_kna1-kunnr..

ENDLOOP.

COMMIT WORK.

Please Advice

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
3,987

Please do not update Standard TAbles using modify or direct update statements

Please use std FM or BAPIs

9 REPLIES 9
Read only

Former Member
0 Likes
3,987

Firstly it is potentially fatal to update the standard tables.

but still for your information,

UPDATE kna1 FROM <b>table</b> it_kna1.

COMMIT WORK.

would be faster.

Regards,

Ravi

Read only

Former Member
0 Likes
3,988

Please do not update Standard TAbles using modify or direct update statements

Please use std FM or BAPIs

Read only

0 Likes
3,987

Here i need to update standard Table KNA1. its required

Can you please tell me the Fun Mods or BAPIs for updating this table.

Read only

0 Likes
3,987

Try Using: BAPI_CUSTOMER_CREATEFROMDATA1 OR BAPI_CUSTOMER_CREATEFROMDATA

Read only

0 Likes
3,987

Hi,

Recomendation is always use SAP standard transaction(XD01, in your case) to Update the standard table, but according to your requirement, it seems it is one time requirement because from the second time you can always tell the users to update that particular field in the transaction itself(XD01), so any method you use will not make much difference.

Cheers...

Santosh.

<i><b>Mark All Usefull Answers...</b></i>

Read only

0 Likes
3,987

You could use Standard Program RFBIDE00

or the BAPI - BAPI_CUSTOMER_CREATEFROMDATA1

Read only

Former Member
0 Likes
3,987

Hi Praveen

use BAPI_CUSTOMER_CHANGEFROMDATA1 to update an existing customer.

Thanks

Gareth

Read only

Former Member
0 Likes
3,987

Hi Praveen,

There is one BAPI 'sd_customer_maintain_all' which I used to Update any of Cusotmer related tables such as KNA1, KNB5. Please let me know if this is available in the system you are working. I will tell you the process.

Regards,

Vijay

Read only

0 Likes
3,987

Hi Praveen i am facing the same situation where i need to update a single field in KNA1,KNB1 and KNVV.... can you please let me know the procedure...

I have BAPI 'sd_customer_maintain_all' in my system...

Please let me know how to use that BAPI....

Thanx in advance n will reward points..