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: 

Sales Order Update during Delivery Creation

Former Member
0 Kudos
1,193

Hi,

I have a requirement to update one of the customer specific sales order header table field during the creation of delivery.I'm trying to do this through the delivery user exit USEREXIT_SAVE_DOCUMENT program MV50AFZ1.

I have a structure CVBAK available, but if i update customer specific the field in the CVBAK it's not changing the sales order.I won't be able to use BAPI or BDC to update SO from the exit, because during this delivery process the current sales order is being used, so system doesn't allow me to acces the sales order.

Please give me the solution for my problem.

Thanks

1 ACCEPTED SOLUTION

ferry_lianto
Active Contributor
0 Kudos
314

Hi,

Please try this FM.

RV_SALES_DOCUMENT_UPDATE

RV_SALES_DOCUMENT_UPDATE_DIA

Regards,

Ferry Lianto

11 REPLIES 11

Former Member
0 Kudos
314

Hi

Have you tried to use the form USEREXIT_SAVE_DOCUMENT_PREPARE instead of USEREXIT_SAVE_DOCUMENT ?

Max

0 Kudos
314

Yes, I have used both but it didn't work.

Do you have any idea what are all the internal tables, structure and fields to be populate inorder to update the sales order.

I have used only the following statement

CVBAK-ORDER_CLOSED = 'X'.

Thanks.

0 Kudos
314

Hi

Probably the table VBAK is not updated by delivery transaction, so u can try to update that field (if it's custom field) by yourself.

U can create a you function module for updating and call it in USEREXIT_SAVE_DOCUMENT:

FORM USEREXIT_SAVE_DOCUMENT.

CALL FUNCTION 'Z_VBAK_UPDATE'

IN UPDATE TASK

EXPORTING

VBAK = VBAK.

ENDFORM.

In 'Z_VBAK_UPDATE' insert the code to update VBAK, you can also try to call the BAPI here, perhaps (the fm is called in update tusk) in this moment all blocks are released.

Max

0 Kudos
314

Hi Max,

Is it advisable to write UPDATE VBAK statement in the abap program ?

Since, my field is the customer enhancement field. I can't use the BAPI BAPI_SALESORDER_CHANGE to update this.

Thanks

Former Member
0 Kudos
314

Hi,

Try this..

In the USEREXIT_SAVE_DOCUMENT of the delivery document...

Call the BAPI BAPI_SALESORDER_CHANGE IN BACKGROUND TASK..

I believe this will work..

Thanks,

Naren

Former Member
0 Kudos
314

Hi,

You can use the Extension parameter to update the custom fields in the table VBAK..

EXTENSIONIN STRUCTURE BAPIPAREX OPTIONAL

Thanks,

Naren

0 Kudos
314

Thanks naren i will try this now.

ferry_lianto
Active Contributor
0 Kudos
315

Hi,

Please try this FM.

RV_SALES_DOCUMENT_UPDATE

RV_SALES_DOCUMENT_UPDATE_DIA

Regards,

Ferry Lianto

0 Kudos
314

BAPI

CALL FUNCTION 'BAPI_SALESORDER_CHANGE' IN UPDATE

OR BACKGROUND TASK didn't work.

Do you have any other solution.

Thanks

0 Kudos
314

Hi

ORDER_CLOSED doesn't exist in the structure VBAK on my system, so I suppose it's a your custom field.

U need to create an enhancement to update the custom field by the BAPI, did you do it?

I know It's not a good thing to update directly a standard table, but if you need to update a custom field you shouldn't have any problem.

U can use a code like this to make sure to update only that field:

UPDATE VBAK SET ORDER_CLOSED = 'X' WHERE VBELN = <......>.

U can consider this solution as the last chance if you can't update it by standard functionalities.

Max

0 Kudos
314

Thanks for your reply Max.

Actually, I tried to update the SAP standard field sales organization to verify whether i can use the BAPI to solve my problem.

But when I call the BAPI_SALESORDER_CHANGE IN UPDATE TASK from program MV50AFZ1 (FORM USEREXIT_SAVE_DOCUMENT) bapi through my custom update module function module,<b> my update was terminated.</b>. I got the error message in sap inbox and it doesn't have any error information.

Also, I used with BAPI with BACKGROUND task, but the field didn't updated.

Do you have any suggestions ?

Thanks