cancel
Showing results for 
Search instead for 
Did you mean: 

Deleting an item line in ServiceContract, not possible?

former_member244307
Participant
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

former_member201110
Active Contributor
0 Kudos

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

former_member244307
Participant
0 Kudos

Hi Owen,

Thanks for your help and code testing for my issue and I will try your solution, it is good to know that we can use a temp XML file to do SAP object update. Hope SAP can fix the bug or provide the delete method in the future release.

Thanks again.

Lan

Answers (0)