Skip to Content
0

SDK - Create Sales Order and send for approval

Jan 13, 2017 at 06:14 AM

634

avatar image

Hi guys,

I am creating sales orders via the DI API. In SAP when these are created they are sent for approval. How can I do this with the DI API?

10 |10000 characters needed characters left characters exceeded

What is DI API? This tag is specifically about some Fiori app. If this is not what your question is regarding then use a different tag. Won't get any replies otherwise.

0
* Please Login or Register to Answer, Follow or Comment.

6 Answers

Best Answer
DIEGO LOTHER Jan 29, 2017 at 08:14 PM
2

Hi Costas,

Sorry for the delay, I was very busy in the last days, and I needed to search more about this topic.

My considerations is the following:

Is it possible work with approval procedure on DI API?

Yes, but have constraints.

How enable approval procedure on DI API?

Go To -> Administration>System Initialization> General Settings. On the BP Tab, there is a check box to activate approval procedures via the DI.

What is the constraints?

On DI API is not possible trigger Approval Procedures based on User Queries, because it is not possible to get User Defined Value from FMS (formatted search) in DI. Look SAP Note (https://launchpad.support.sap.com/#/notes/1681542/E)

How can I configure my Approval procedure to work with DI API?

Set up your approval procedure to launch always.

Or use pre defined terms

How to know if the document will launch approval procedure?

A sample code:

                Documents oDoc = oCompany.GetBusinessObject(BoObjectTypes.oOrders);
                oDoc.CardCode = "C00007";
                oDoc.DocDueDate = DateTime.Now;
                oDoc.Lines.ItemCode = "LM4029SB";
                oDoc.Lines.Quantity = 2;


                oDoc.GetApprovalTemplates();
                if (oDoc.Document_ApprovalRequests.Count > 0 && oDoc.Document_ApprovalRequests.ApprovalTemplatesID > 0)
                {
                    //Your document will fire an approval procedure
                    //If you want to add some remarks to your approval you can do this
                    oDoc.Document_ApprovalRequests.SetCurrentLine(0);
                    oDoc.Document_ApprovalRequests.Remarks = "Add Doc from DI";
                }


                if (oDoc.Add() != 0)
                    MessageBox.Show(oCompany.GetLastErrorDescription());
                else
                    MessageBox.Show(oCompany.GetNewObjectKey());

Hope it helps.

Kind Regards.

Diego Lother


img1.png (16.1 kB)
img2.png (62.2 kB)
Share
10 |10000 characters needed characters left characters exceeded
DIEGO LOTHER Jan 18, 2017 at 06:52 PM
0

Hi Costas,

Did you check if your config "activate approval procedures via the DI" are enabled?

Administration>System Initialisation> General Settings. On the BP Tab, there is a check box to activate approval procedures via the DI.

This will the make your DI add on work with the approvals processes on standard SAP documents.

Hope it helps.

Kind Regards,

Diego Lother

Share
10 |10000 characters needed characters left characters exceeded
Costas Ioannou Jan 24, 2017 at 02:08 PM
0

Hi thanks for the reply,

this is checked. Do I also need to do something in my code, because we are not getting any notifications.

Share
10 |10000 characters needed characters left characters exceeded
Costas Ioannou Jan 30, 2017 at 02:28 PM
0

Hi, thanks so much for all the effort you put into this. I really appreciate it.

I used the code and set the procedure to launch always. However, it does not add the order. I get an error, As seen:


screenshot-2.png (3.3 kB)
Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Costas,

This error occurred because your company is active the customer Credit limit restriction, and with this function, the SAP validates if the customer has credit limit enough for add the document.

To enable/disable this function go to Administration->System Initialization-> General Settings -> BP Tab

The credit limit for the BP is set up on Business Master Data Form on Payment Terms Tab.

In your case to test, you can disable the credit limit functionality or add a credit limit bigger for your customer.

Kind Regards,

Diego Lother

img1.png (42.4 kB)
img2.png (41.2 kB)
0
Costas Ioannou Jan 31, 2017 at 01:02 PM
0

Thanks that's works. However the customer uses credit limits and commitment limits. Is there a way to add it with these enabled?

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Costas,

I unknow a workaround to this situation. :(

Maybe someone else in this board have some approach for this situation.

P.S: Don't forget to close the question, after you get answers.

Kind Regards,

Diego Lother

0
Costas Ioannou Feb 01, 2017 at 06:56 AM
0

Thanks one more thing. I noticed that the approval does pass, but the notification does not fire on the other user. He only sees it when a sales order is added manual and is then fired. How can I force the notification for the approval process?

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Costas,

I created the following Approval template in my test environment.

Then, I ran the sample that I posted on last answer, and I had used the manager user to log on di api when I ran the sample. All messages of the process were received correctly on my test environment.

Kind Regards,

Diego Lother

img1.png (31.6 kB)
img2.png (68.0 kB)
img3.png (69.2 kB)
img4.png (33.4 kB)
0