on 04-28-2016 4:18 PM
Hi,
I am working on a DI application which needs to editing a service contract with serial numbers. I just realized that there is only Add method for the item lines. I can't find a method like SapServiceContractObj.Lines.Delete(). But SAP allow you to add or deleting in its client.
Any idea?
Thanks,
Lan
Hi Lan,
There are some cases where you can use the XML functions in the DI API to modify an object where there isn't a specific method in the object itself. I've just tested and I was able to remove a contract line by doing the following:
1) Use the GetByKey method of the Contracts object in the DI API to load up the contract I want to edit.
2) Use the SaveToFile or SaveAsXML methods to export this object to XML.
3) Call up the XML in a XML editor and remove the node(s) for any rows I want to remove from the contract.
4) Save the XML file.
5) Load the XML file in to the Contracts object by using the GetBusinessObjectFromXML method of the Company object.
6) Call Update on the contract.
This removed the line successfully. I did have a problem initially because of the way that the DI API exports the data to XML. For example, on the CTR1 table there is an ItemGroup field. This field had a null value in my database but the DI API exports this as 0. Therefore I had to change <ItemGroup>0</ItemGroup> to <ItemGroup nil="true"/> during step 3 (or I believe you can simply remove this element entirely). Likewise there are some header fields that had to be edited because the value was null in the database but the export to XML doesn't set this correctly. If you don't do this then you'll see a 'No matching records found' error message during the update.
Hope that helps.
Kind Regards,
Owen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
108 | |
12 | |
11 | |
6 | |
5 | |
4 | |
3 | |
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.