cancel
Showing results for 
Search instead for 
Did you mean: 

SDK - Create Sales Order and send for approval

costas_ioannou2
Active Participant
0 Kudos

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?

Jelena
Active Contributor
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

former_member185682
Active Contributor

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

Answers (6)

Answers (6)

former_member818640
Discoverer
0 Kudos

I tried but

Approval Template using a Terms Based on User Query not working via DI (SAP B1 8.82 PL04)

Please support for me...

former_member818640
Discoverer
0 Kudos

tks everyones

costas_ioannou2
Active Participant
0 Kudos

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?

former_member185682
Active Contributor
0 Kudos

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

costas_ioannou2
Active Participant
0 Kudos

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

former_member185682
Active Contributor
0 Kudos

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

costas_ioannou2
Active Participant
0 Kudos

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:

former_member185682
Active Contributor
0 Kudos

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

costas_ioannou2
Active Participant
0 Kudos

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.

former_member185682
Active Contributor
0 Kudos

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