Skip to Content
avatar image
Former Member

Need to add Business Partner using XML (DI Server)

Hello Experts,

I am stuck at a place and need your guidance.

I need to add a business partner into SBO using XML(DI Server).

have a look at the code given below.

Plz let me know what is the issue, or where i am wrong.

Any inputs will be helpful.

private void ADDBP_Click(object sender, EventArgs e)

        {

            this.CreateSession();

            try

            {

                string sCmd = @"<?xml version=""1.0"" encoding=""UTF-16""?>";

                sCmd += @"<Envelopes>";

                sCmd += @"<env:Envelope xmlns:env=""http://schemas.xmlsoap.org/soap/envelope/"">";

                sCmd += @"<env:Header><SessionID>" + this.sessionId + "</SessionID></env:Header>";

                sCmd += @"<env:Body>";

                sCmd += @"<dis:AddObject xmlns:dis=""http://www.sap.com/SBO/DIS"" CommandID=""Add BP"">";

                sCmd += @"<BOM>";

                sCmd += @"<BO>";

                sCmd += @"<AdmInfo>";

                sCmd += @"<Object>oBusinessPartners</Object>";

                sCmd += @"</AdmInfo>";

                sCmd += @"<BusinessPartners>";

                sCmd += @"<row>";

                sCmd += @"<CardCode>" + bpcode.Text + "</CardCode>";

                sCmd += @"</row>";

                sCmd += @"<row>";

                sCmd += @"<CardName>" + bpname.Text + "</CardName>";

                sCmd += @"</row>";

                sCmd += @"<row>";

                sCmd += @"<CardType>" + bptype.Text + "</CardType>";

                sCmd += @"</row>";

                sCmd += @"</BusinessPartners>";

                sCmd += @"<Document_Lines>";

                sCmd += @"<row>";

                sCmd += @"<TaxLiable>" + "tNO" + "</TaxLiable>";   

                sCmd += @"</row>";

                sCmd += @"<row>";

                sCmd += @"<WTLiable>" + "tNO" + "</WTLiable>";

                sCmd += @"</row>";

                sCmd += @"</Document_Lines>";

                sCmd += @"</BO>";

                sCmd += @"</BOM>";

                sCmd += @"</dis:AddObject>";

                sCmd += @"</env:Body></env:Envelope>";

                sCmd += @"</Envelopes>";

                //MessageBox.Show(sCmd);

                string itemData = node.BatchInteract(sCmd);

                MessageBox.Show(itemData);

                MessageBox.Show("Businees partner Susscesfully Add In SAP Business One");

                this.DisconnectSession();

            }

       

            catch (Exception ex)

            {

                MessageBox.Show(ex.Message);

            }

        }

i attach snap which give me error...

Thanks

Nikunj

a2.jpg (281.2 kB)
a1.jpg (213.9 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Jan 08, 2015 at 10:36 AM

    Hi Nikunj,

    What Pedro Told You should Follow it once.

    Also if you want to use it in the same code then you need to use the below code.

                    sCmd += @"<BusinessPartners>";

                    sCmd += @"<row>";

                    sCmd += @"<CardCode>" + bpcode.Text + "</CardCode>";

                    sCmd += @"<CardName>" + bpname.Text + "</CardName>";

                    sCmd += @"<CardType>" + bptype.Text + "</CardType>";

                    sCmd += @"<SubjectToWithholdingTax>" + "N" + "</SubjectToWithholdingTax>";

                    sCmd += @"</row>";

                    sCmd += @"</BusinessPartners>";

    I am sure this will work for you.

    Thanks,

    Amit.

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 07, 2015 at 02:20 PM

    Hi Nikunj,

    instead of using "AddObject" of DIS use BusinessPartnerService :

    <?xml version="1.0" ?>
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <soap:Header>
            <MsgHeader xmlns="http://www.sap.com/SBO/DIS">
                <SessionID>71484CA7-877C-4A50-8F7F-54D68A2A7322</SessionID>
                <ServiceName>BusinessPartnersService</ServiceName>
            </MsgHeader>
        </soap:Header>
        <soap:Body>
            <Add xmlns="BusinessPartnersService">
                <BusinessPartner xmlns="http://www.sap.com/SBO/DIS">
                    <CardCode>test001</CardCode>
                    <CardName>mytest001</CardName>
                </BusinessPartner>
            </Add>
        </soap:Body>
    </soap:Envelope>
    

    regards,

    Maik

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Nikunj,

      since it is an indian localization requirement I can't test, but i my understanding you just have to add this child element to BusinessPartner tagĀ  :

      <SubjectToWithholdingTax>tNO</SubjectToWithholdingTax>

      And I see that this is what Pedro suggested aswell, only that now its the BusinessPartnerService.

      good luck,

      Maik

  • Jan 06, 2015 at 01:29 PM

    Hi Nikunj,

    The message is requesting the PAN number. Could this be something specific to the localization of Business One you are using?


    Best regards,

    Pedro Magueija


    View Pedro Magueija's profile on LinkedIn

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Pedro Magueija

      Hi Pedro,

      i have also changed session id but it will generate error as shown above image.

      i can't solve my problem.

      I have attach one txt file which cover full code.

      Kindly help with it.  where is, i am wrong?


      qqqq.txt.zip (1.4 kB)