on 01-06-2015 11:09 AM
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello
I am facing just one problem while adding business partner in sap using DI Server.
I need to provide the card code manually in api. but I want to generate it automatically. Like in the SAP portal when we want to add any business partner if we select the code : customer it generate the code automatically and if we select manual then we need to add code.
How I can achieve this using DI Server.
I want to generate card code automatically.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi maik,
after making the told changes.
I again came to my initial error that "Enter PAN No. for Business Partner."
Now to enter a BP record without PAN No. I need remove the withHolding tax TICK mark in the Accounting TAB.
Kindly suggest How I can do this.
I have to use this for Indian Localization.
Let me know if you need more information. Also I have added the error screen shot for your reference.
Thanks,
Nikunj
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Pedro,
Yes the system is in Indian Localization.
We need to enter the PAN details if the Withholding Tax is kept to Yes.
We need to keep Withholding tax to false or tNO. while entering a BP master record to avoid inputting PAN details. But I am not able to do it using the above code. It generates the msg "Enter PAN no. " even if I used the below code.
sCmd += @"<row>";
sCmd += @"<TaxLiable>" + "tNO" + "</TaxLiable>";
sCmd += @"</row>";
sCmd += @"<row>";
sCmd += @"<WTLiable>" + "tNO" + "</WTLiable>";
sCmd += @"</row>";
Let me know if this is the right way to disable the withholding tax details.
DO Let me know if you need more information. I hope you will get what I meant to say.
Thanks and regards,
Nikunj.
Hi Nikunj,
I had a look at an SOAP envelope and it should look like this:
<BOM>
<BO>
<AdmInfo>
<Object>oBusinessPartners</Object>
</AdmInfo>
<BusinessPartners>
<row>
<CardCode>C23900</CardCode>
<CardName>Efotech GmbH</CardName>
<CardType>cCustomer</CardType>
<SubjectToWithholdingTax>tNO</SubjectToWithholdingTax>
</row>
</BusinessPartners>
...
</BO>
</BOM>
The <SubjectToWithholdingTax> is the WTLiable you mentioned.
You can get the template for a given business object by using:
<?xml version="1.0" encoding="UTF-16"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header>
<SessionID>32D83BB6-F3AD-985F-D4BC-655B3D9ACBE2</SessionID>
</env:Header>
<env:Body>
<dis:GetBusinessObjectTemplate xmlns:dis="http://www.sap.com/SBO/DIS">
<Object>oBusinessPartners</Object>
</dis:GetBusinessObjectTemplate>
</env:Body>
</env:Envelope>
The server will return a template that you should use for that business object, that way you can know for sure what tags to use.
Best regards,
Pedro Magueija
Hi Nikunj,
The GetBusinessObjectTemplate soap structure above should be just like it's posted (just change the session id). From your screen shot seems that you are sending a different soap message.
Note that when you use GetBusinessObjectTemplate you get back the xml to use for your adding message. GetBusinessObjectTemplate will not add the business partner itself.
Use the xml returned by GetBusinessObjectTemplate to build another soap message with the tags shown by the returned xml.
Understand?
Best regards,
Pedro Magueija
User | Count |
---|---|
95 | |
11 | |
11 | |
6 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.