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

BAPI_SALESORDER_CHANGE

Former Member
0 Likes
1,937

Hi experts,

I have a scenario, where I am creating sales order & then creating delivery for fully pick. At that time fully delivered line item is grayed out in sales order for reason for rejection (VBAP-ABGRU)

But later when same delivery is changed for partially deliver quantity, my userexit for delivery should change reason for rejection for sales order to Z2. I am using BAPI_SALESORDER_CHANGE for this.

But at first attempt of BAPI_SALESORDER_CHANGE is failing because for that line item VBAP-ABGRU is non editable. Once bapi is failing, for second attempt it is becomming editable.

Can anyone suggest me how to make that grayed out line in sales order editable in first attempt?

Points will be rewarded.

Thanks,

neo

Hi experts,

I have a scenario, where I am creating sales order & then creating delivery for fully pick. At that time fully delivered line item is grayed out in sales order for reason for rejection (VBAP-ABGRU)

But later when same delivery is changed for partially deliver quantity, my userexit for delivery should change reason for rejection for sales order to Z2. I am using BAPI_SALESORDER_CHANGE for this.

But at first attempt of BAPI_SALESORDER_CHANGE is failing because for that line item VBAP-ABGRU is non editable. Once bapi is failing, for second attempt it is becomming editable.

Can anyone suggest me how to make that grayed out line in sales order editable in first attempt?

Points will be rewarded.

Thanks,

neo

9 REPLIES 9
Read only

Former Member
0 Likes
1,388

The reason you are getting an error is because the sales order does not know about the partial delivery at the point you are calling the BAPI i.e. delivery commit work has not happened.

Here is a possible solution:

1) Export your data in memory during delivery save (USEREXIT_SAVE_DOCUMENT)

2) Implement BAdI PUBLISH_AFTER_SAVE method PUBLISH_AFTER_SAVE. In this BAdI, import your data from delivery and call the BAPI to change sales order

Read only

Former Member
0 Likes
1,388

Hello neo S.

Yes . Ken Sanghvi logic should work.. Try that logic.

Thanks,

Greetson

Read only

Former Member
0 Likes
1,388

Hi Ken / Greetson,

Thanks for your reply.

I am finding difficulties to implement PUBLISH_AFTER_SAVE method for Badi DELIVERY_PUBLISH. There are no existing parameters.

Can anyone help me out with example step by step...

Points will be rewarded.

Thanks,

Read only

0 Likes
1,388

Import the value you have exported to memory during USEREXIT_SAVE_DOCUMENT and then make the reason for rejection for the sales order as 'Z2'.

Hope this helps.

Thanks,

Balaji

Read only

0 Likes
1,388

Which version of SAP are you on? The BAdI DELIVERY_PUBLISH is a classic BAdI. The method PUBLISH_AFTER_SAVE does not have any importing or exporting parameters. That is why I suggested that you export your data to memory in SAPMV50a USEREXIT_SAVE_DOCUMENT and then import it from memory in this method.

In USEREXIT_SAVE_DOCUMENT


      EXPORT xlips TO MEMORY ID 'Y_DELIVERY_PUBLISH_DATA'.

In method PUBLISH_AFTER_SAVE of implementation BAdI DELIVERY_PUBLISH


data: xlips like LIPSVB occurs 0.
  IMPORT xlips TO xlips
     FROM MEMORY ID 'Y_DELIVERY_PUBLISH_DATA'.
" Call sales order BAPI here....

Read only

0 Likes
1,388

Hi Balaji,

Thanks for reply.

I did that. But even in delivery SAVE_DOCUMENT, sales order line item is not changeble. It is failing my bapi_salesorder_change.

Any other possible solutions?

Thanks,

Read only

0 Likes
1,388

Hi,

Try this.

In USEREXIT_SAVE_DOCUMENT

EXPORT xlips TO MEMORY ID 'ZDELIVERY_PUBLISH'.

In method PUBLISH_AFTER_SAVE of implementation BAdI DELIVERY_PUBLISH

data: lv_lips like LIPSVB occurs 0.

IMPORT xlips TO lv_lips

FROM MEMORY ID 'ZDELIVERY_PUBLISH'.

After this call your BAdI to change the sales order line item reason of rejection value.

Hope this helps

Thanks,

Balaji

Read only

0 Likes
1,388

Thanks,

my mistake that I was not able to understand first time...

Leme implement this... & I'll get back to you.

& definately points will be rewarded.

Read only

Former Member
0 Likes
1,388

Hi all,

Sorry for closing this thread very late.

Even BADI for after save didn't work because during change of delivery, still sales order some fields were not getting updated untill you open it once.

To solve this issue, we added code into Sales order save document prep userexit to make sure that field is not gayed out while editing & if necessary we opened it using field modification userexit.

Thanks,