cancel
Showing results for 
Search instead for 
Did you mean: 

Standard program to close all open sales orders when price is changed.

Former Member
0 Kudos

Dear All,

I have a scenario where i need to close all the open sales orders in VA05n when there is a change in standard price.

The process goes as below.

If there is a change in standard price VK12 for a material, then all the open sales orders for that material should be close automatically(Va05n).

A call must be triggered as soon as there is a change.

Please let me know if any standard program or any confrontational changes should be done to approach this scenario. 

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Dear sudhir,

Assign reason of rejection in sales order . for bulk sales order ,Use Change sales order BAPI-

BAPI_SALESORDER_CHANGE to Close sales order-

Thanks

Jitendra

0 Kudos

Dear Sudhir,

For a similar requirement we had done like,

1. At the time of saving sales order, check Pricing date = Current date or future date.

2. In delivery order, at the time of saving Delivery Check Actual GI date = Sales order price date, if fails display error message to update the sales order.

By this, you can ensure only the revised price flow in the sales documents.

And irrespective of back dated open sales orders, at the time of delivery selected sales order which user want to continue will get update.

Regards,

OD

moazzam_ali
Active Contributor
0 Kudos

Hi

In my opinion whenever there is some change in price we always maintain new condition record in VK11 valid from that date on which new price is declared. We don't change existing condition records. Why you are changing existing condition records and why not maintaining new one in VK11.

For your query this is not possible in standard or even with ABAP it will be tricky and complex. In our company whenever price changes we run VA05N and download all open sale orders in excel file. Then copy sales order numbers and paste them in VKM3 and select all and reject. Now you may ask your ABAPER if he could use this logic and schedule a job on daily, weekly or whenever you want.

For this you need to tell the system that when a price is changed. May be whenever you run VK11 for any material or if there is anyother better idea in your mind.

What I would suggest is to do it manually. How time will it take to download a report in excel and then copy > paste > select all > reject and save. Hardly 2 minutes may be.

Thank$

venu_ch8
Active Contributor
0 Kudos

Dear MoazzaM , sorry for interruption

i have one doubt plz let me ask on this

What I would suggest is to do it manually. How time will it take to download a report in excel and then copy > paste > select all > reject and save. Hardly 2 minutes may be.

Dear Generally we will reject items in sales order-- line item level

But From your point of view in case if we have so many items are there in different documents we will do like above given

I am little bit confused dear .. plz forgive me if i am wrong  if we rejected all items in excel how it will impact in sap.. sorry once again .. i didnt get your Brilliant Logic

plz explain me thanks a lot

moazzam_ali
Active Contributor
0 Kudos

Venu

If we have 10 open orders in which some line items are completed and some are still open and we want to reject the open ones then we have two options. Go in VA01 and put reason for rejection one by one or do it from VKM3 in one go for all 10 orders. Result will be same. System will put reason for rejection only for those items which are open.

I would like to suggest you to first check in your system and if you find some different results then post a different thread instead to ask questions in every discussion. This is kind of hijacking some other member's discussion.

I think I didn't use difficult words or logic and one can understand it if he tests in his system. Hope you understand my point of concern.

Thank$

Former Member
0 Kudos

Dear Mozzam,

Thanks for your response. i understand changing the price in VK12 in not a good procedure. Ok even if we create a new condition record in VK11 against a specific material then also this process must trigger i.e, the Open sales orders with the material should be sent to blocked state . the open orders with old price should be blocked. there is a requirement from client that this process should be done in back ground and no manual intervention should be there.

I am aware of the procedures of closing all at once using MASS but the client have a scenario of changing all the material prices for every 6 months. So we cant keep on doing this every time the price changes.

If at all we go for a customized program can you guide how it should be. or at least suggest solutions which match with my requirement.

amit_tunara
Active Contributor
0 Kudos

Hi Sudhir,

I have given a glimpse of logic for this program.

ABAP code, which will check the condition tables A306 (for PR00) and KONP tables. If the program is running today, the code will scan this table for any change for today's date. If a condition record found for an article, take that article and goto Sales order tables to find out open orders. VBBE table can be useful with document category C.

Upon finding the open order, we can reject the items from sales order using a BAPI BAPI_SALESORDER_CHANGE. Following will be the parameters to be passed to BAPI.

SALESDOCUMENT = existing sales order number

    ORDER_HEADER_INX-UPDATEFLAG = U

    ORDER_ITEM_IN-ITM_NUMBER = 000010

    ORDER_ITEM_IN-REASON_REJ = '01'

Using this the item is rejected. We have to repeat the program for all sales orders where the item is there for which we found condition change.

Once 1 article is finished, check for another condition change. See below algorithm for your program.

SCAN all records in A306 table

    If Condition change found for Article A1

         Scan VBBE table for Open orders containing item A1

                For each order

                     Call BAPI for reject the item

                End For

         End Scan

   End if

End Scan

I hope this will help.

Regards,

Amit

moazzam_ali
Active Contributor
0 Kudos

Hi

We have thousands of materials and thousands of open orders on every month end closing. We have change in price almost every month but we reject open orders on end of very month by VA05N and VKM3 which I have explained earlier.

If you have this requirement from client then you have to do it. It will take a lot of testing and because you know we use different tables for maintaining price and you need to tell the system about price change in every table.

Amit has explained the logic very well but I would like to add something in that. You have to go with that Logic which Amit has shared and take help of your ABAPER and BASIS guy to schedule this job on every night at some specific time. This may reduce the system performance based on number of entries and transaction volume so it would be nice if you schedule this at night.

There are lot of threads and discussions where members are discussing about function module for reading condition records and BAPI for rejecting open orders etc. While reading table you have to take care of all pricing tables which you have in your pricing condition's access sequences.

PS:    Discuss this logic and solution with your ABAP and BASIS guys and get this requirement done by your collective efforts. Once you get your desired program you may share that here in SCN as blog or document. I will like to hear from you the updates for this solution.

Thank$

amit_tunara
Active Contributor
0 Kudos

Hi Sudhir,

As per my knowledge, there is no link in condition change and order status, a condition change (using VK12) cannot trigger change of order status.

This thing can be done using an ABAP program which has to be executed at a regular interval to check the condition change and then access any open order and upon finding, reject those items.

Regards,

Amit