cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Inserting Sales Order data using DI API to SAP B1

Former Member
0 Likes
4,587

Hi everyone,
I'm creating a third party system that will insert Sales Order data using DI API to SAP B1...
I need to know if insert the data in table ORDR, is it automatically inserting the data in RDR1.?

this is my sample code.

        Dim oSO As SAPbobsCOM.Documents

        oSO = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders)

        'set value

        oSO.CardCode = "12345"

        oSO.CardName = "Phoenix"

        oSO.NumAtCard = "05314"

        lRetCode = oSO.Add()

        If lRetCode <> 0 Then

            oCompany.GetLastError(lErrCode, sErrMsg)

            MessageBox.Show("Error: " & sErrMsg & "; Code: " & lErrCode)

        End If

Accepted Solutions (1)

Accepted Solutions (1)

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Likes

Hi Weynard Lleva,

No your code is not inserting the data in line:

For Inserting the data at line:

oSO.Lines.ItemCode = ItemCode;

oSO.Lines.Quantity = Quantity;

oSO.Lines.UnitPrice = Price;

oSO.Lines.TaxCode = TaxCode;

oSO.Lines.DiscountPercent = DiscountPercent;

Hope it helps.

Thanks & Regards

Ankit Chauhan

Former Member
0 Likes

thanks.. but i cant find some columns in database. i mean i dont know what to use in oSO."COlumnNameInDatabase".
exmple is column CANCELLED in table ORDR and it has a value of N

but when i check it on DI.. i cant fint a CANCELLED after typing the oSO.

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Likes

Hi Weynard,

Yes... All fields are not exposed in DIAPI. This is the limitations.

Also Cancelled field is updated automatically, once you will Cancel a document.

SAPbobsCOM.Documents oSO = (SAPbobsCOM.Documents)SBO_Company.GetBusinessObject(BoObjectTypes.oOrders);

oSO.GetByKey(3619);   // 3619 is the DocEntry of a Sales Order.

oSO.Cancel();

the above sample will update the CANCELLED field automatically.

Hope it helps.

Thanks & Regards

Ankit Chauhan

Former Member
0 Likes

So you mean that it is okay to add the data eventhough i dont have a value to be added in CANCELLED column and also to other columns that are not in DI? is it okay?

edy_simon
Active Contributor
0 Likes

Hi Weynard,

There are only a few mandatory fields in creating SO.

Namely :

oSO.DocDate

oSO.DocDueDate

oSO.CardCode

oSO.Lines.ItemCode

oSO.Lines.Quantity

You can create an SO with above minimum information.

Regards
Edy

Former Member
0 Likes

Hi Edy Simon

Really? i thought i should insert a value in all fields. demn. do you know all the mandatory fields in table ORDR and RDR1? it will be a great help to me.

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Likes

Hi Weynard,

Mandatory fields cannot be mentioned in one time. It also depends on your company settings.

But normally the main fields are which Edy Simon has explained.

For more test, you can check by opening SAP B1. The fields that give you the error when you use SAP directly, also need to filled while using DIAPI.

Hope it helps.

Thanks & Regards

Ankit Chauhan

Former Member
0 Likes

Hi Ankit,One last thing, I added a UDF in sap b1.. for example is U_DiscRate1... so how am i goint to insert a value in U_Discrate1 field? i cant fin it on DI API,

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Likes

Hi Waynard,

Use it as follows:

oSO.Lines.UserFields.Fields.Item("U_Discrate1").Value = Value;   




Hope it helps.



Thanks & Regards


Ankit Chauhan

Former Member
0 Likes

Thanks Ankit. great help.

Best Regards,
Weyn

patrice_vigier
Participant
0 Likes
How do we insert shipping cost?

Answers (2)

Answers (2)

Former Member
0 Likes

Hello,

I'm using this code

oSO.Lines.DiscountPercent = 0;


but when my app send the order to SAP, this field discountpercent has another different value, I don't from where


What am I missing ?


thanks.

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Likes

Hi Weynard,

Also check here:

C:\Program Files\SAP\SAP Business One SDK\Samples\COM DI\VB.NET\05.OrderAndInvoice

Hope it helps.

Thanks & Regards

Ankit Chauhan