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

VBPA table not getting modified

Former Member
0 Likes
2,526

Dear Experts,

I want to update table vbpa for sold to party and shift to party.

I wrote the code as follows,

SELECT SINGLE vbeln kunnr FROM vbak INTO wa_vbak

WHERE vbeln EQ s_vbeln.

IF sy-subrc NE 0.

MESSAGE 'Sales Order Does Not Exists' TYPE 'E'.

ELSE.

SELECT SINGLE * FROM kna1 INTO WA_KNA1

WHERE kunnr EQ p_kunnr.

IF sy-subrc NE 0.

MESSAGE 'Enter Valid Sold To Party' TYPE 'E'.

ENDIF.

UPDATE vbak SET kunnr = p_kunnr

WHERE vbeln = s_vbeln.

UPDATE vbpa SET kunnr = p_kunnr

ADRNR = WA_KNA1-ADRNR

WHERE vbeln = s_vbeln

AND parvw = 'SP'.

UPDATE vbpa SET kunnr = p_kunnr

ADRNR = WA_KNA1-ADRNR

WHERE vbeln = s_vbeln

AND parvw = 'SH'.

COMMIT WORK.

ENDIF.

BUT it is updating table VBAK only. Please help.

9 REPLIES 9
Read only

Former Member
0 Likes
1,779

to be honest i cant see the problem in this code snippet why it doesnt work.

BUT the hair on my neck is stiffening when seeing this. Hard updates on VBKA and VBPA?

And finally a commit work which doesnt even check sy-subrc = 0.

Thats not something i would recommend. Try to make use of e.G. BAPI_SALESORDER_CHANGE or SD_SALESDOCUMENT_MAINTAIN if you want to change change a sales order.

Read only

0 Likes
1,779

yes i want to change the sales order, shift to party and sold to party.

Thax for the reply. I will try your suggestion.

Read only

Former Member
0 Likes
1,779

Hi

Why are you doing that?

Why are you changing that data directly by sql statament?

I don't think it's good thing to change these partners by this way: there are several tables where these data are the main keys: you risk to have many misalignments.

Anyway the function partner has a convertion routine to convert the code from/to input/output value:

SP and SH are the code for the output values, the input codes are AG and WE: you need to use these.

So VBPA doesn't changed because your query fails

Max

Read only

deepak_dhamat
Active Contributor
0 Likes
1,779

Hi ,

Dont update SAP table directly ... It is not a correct way ..

You might be disturbing data related Directly or indirectly with vbpa table for other table .

SAP never recommend to do update table directly ... You use either bapi or bapi if any ..

Do find on SDn for the same .

regards

Deepak.

Read only

0 Likes
1,779

Hi ,

Do check this BAPI

BAPI_SALESORDER_CHANGE

regards

Deepak.

Read only

Clemenss
Active Contributor
0 Likes
1,779

Hi Makarand,

congratulations!

You work in a private environment not relevant for any legal requirement at all.

Because if an auditor or tax authority knows what you are doing in your system, it depends only on the value of the orders manipulated if the action is subject to prison sentence or monetary penalty. If your auditors know and let you do, they arte in a similar situation.

Note: If you use SAP transactions it can be always detected who changed what and when.

Regards,

Clemens

Read only

Former Member
0 Likes
1,779

Hi,

I dont know why you are updating VBPA like this, But I can tell you why your update query is not working.

Its actually very simple, you are trying to update using parvw equal to "SH and SP". Those values are dispalyed due to conversion exits. so need to use "WE for SH" and "RG for SP" values.

UPDATE vbpa SET kunnr = p_kunnr

ADRNR = WA_KNA1-ADRNR

WHERE vbeln = s_vbeln

AND parvw = 'RG'. " Double check this value at domain level

UPDATE vbpa SET kunnr = p_kunnr

ADRNR = WA_KNA1-ADRNR

WHERE vbeln = s_vbeln

AND parvw = 'WE'.

Nitesh

Read only

Former Member
0 Likes
1,779

Hi,

Nitesh is right. We should always need to use the conversion exit for Partner Functions while doing modifications.

Shiva.

Read only

Former Member
0 Likes
1,779

BAPI_SALESORDER_CHANGE

use BAPI or any other func. mod for this jobs but never try direct approach its wrong and it may land u in gr8 troubles