cancel
Showing results for 
Search instead for 
Did you mean: 

Detect an order will become a draft before SAP B1 application does

Former Member
0 Kudos

Hi, all!

I need to know that a sales order document will become an order draft before it is created. Is there a way to detect that before SAP shows the draft remarks window (Form=50106).

This window pops up after FORM_DATA_ADD event for the sales order is sent (BeforeAction property equals True), but before the FORM_DATA_ADD event for the draft itself (BeforeAction property again equals True) is sent at which point it would be too late for me.

I'm working on SAP B1 2005 PL45.

Regards, Yavor

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

HI,

Sorry, this is for when you creating and order from a draft.....

OK. Use SP_TransactionNotification to determine draft has been created from your order....

Regards,

J.

Edited by: Janos Nagy on Sep 11, 2008 11:45 AM

Former Member
0 Kudos

Hi, Janos!

At SP_TransactionNotification I already have the document created in the database. I need to know if a draft will be created instead of an order before SAP notifies of that.

Regards, Yavor

Nussi
Active Contributor
0 Kudos

Hi Yavor,

when i understood you correctly you want to know if the user clicked "Save as Draft" ?

catch the MenuID 5907 in MenuEvent Handler.

lg David

Former Member
0 Kudos

Hi David!

I suppose I didn't explain it right.

The way it works on my PC is this:

1. I log in SAP B1 and open "Sales - A/R" tab.

2. I click on "Sales Order" option to create a new sales order

3. A "Sales Order" window shows that allows me to enter the details of the order I want to create.

4. I have an inventory item called "testItem", its price is $3.00. There is also a BP called "testBP". I select "testBP" as the customer and add one line in the order lines grid for that "testItem" setting the item quantity to 200 which makes an order total roughly $600.00 (no discount, there is some tax and shipping cost, but that's not important now).

NOTE: I have previously defined an Approval template (Modules/Administration/Approval Procedures/Approval Templates) that covers sales orders only and the only term set there is "Total Document" with ratio "Greater than" and value $500.00. There is one user assigned as originator and that's the one I logged in SAP B1 with.

6. I press "Add" button on the sales order form to create the sales order. Since the approval rule state that order will not be allowed directly if its total is more than $500.00 a window pops up that says "Generating this document requires the authorization of other users. In the table below, type remarks that are relevant for the authorizor and Click OK".

7. If I click OK a draft is created instead of a sales order. If I click Cancel the process stops and no document is created.

I have an addon that should perform certain operations should the document be an order, but should do nothing if the document turns out to be a draft. These operation should be performed before the order document is created, not after that.

To do that I try to use et_FORM_DATA_ADD event when BeforeAction=true and the event relates to the sales order to create. The problem is that I get this event before the popup window from 6. shows up and at that moment I have no way of knowing whether the document will become a draft or a sales order.

Is it possible to evaluate this situation the first time I get et_FORM_DATA_ADD event - I suppose trying to read the tables related to approval procedures might do the trick, but is there a API method to use instead?

Regards, Yavor

Former Member
0 Kudos

Yavor,

Did u try to catch the Button Click events on the form that pops the question.???

So that if the user Clicks on OK then u can proceed with the Order processing code OR if he clicks cancle then u can exit as it will create a Draft..

Did this help u.??

Vasu Natari.

Nussi
Active Contributor
0 Kudos

Hi,

i agree with vasu - try if the "approval form" create events.

if no i don't see any other way than developing your own approval function/window.

lg David

Former Member
0 Kudos

Hi Vasu!

Yes that's the way that might help me though it means I'll have to somehow rollback the specific operations I mentioned before(As I explained in my previous posts these are performed in the FORM_DATA_ADD event being fired before this popup window shows).

I was hoping there is some API method I don't know of that could evaluate the form's details and say if it would be a draft or the real document. Using approval tables doesn't seem like a good idea though.

Regards

Former Member
0 Kudos

Sorry i did not understand,

Can u plz explain a bit more..??

Vasu Natari.

Former Member
0 Kudos

Hi!

I try to create a sales order in SAP B1 application. Due to approval rules the order becomes a draft.

I'm writing an addon and I need to perform specific operations on a sales order before it is created but I should not perform these operations should the sales order become an order draft. To do that I try to hook at FORM_DATA_ADD event when the BeforeAction flag is set to true, but at that point it seem impossible. The reason is that I get two FORM_DATA_ADD events with BeforeAction flag set to true for the order followed by one FORM_DATA_ADD with BeforeAction flag set to true for the actual draft.

Is there a way to determine at the first FORM_DATA_ADD event with BeforeAction flag set to true that a draft will be created and not the actual order?

10x, Yavor

Edited by: Yavor Naumov on Sep 11, 2008 11:55 AM