I am writing an application to load service contract data into SBO from a CSV file.
I am having a problem using the DI to add lines to a service contract.
The 'Add' method on the SAPbobsCOM.ServiceContract_Lines object does not add a record to the CTR1 table in the database.
The add method on the SAPbobsCOM.ServiceContract_Lines object is unique amongst similar add methods in that is a void function. It does not return a Boolean indicating it's success or failure, as all of the other Add methods seem to do.
I though perhaps there would be an error code waiting, but calling SAPbobsCOM.Company.GetLastErrorCode returns no error code.
It seems that I am going to have to use a RecordSet object to manually perform an insert into this table in order to do my data load.
Has anybody handled this condition before?
Here is the I am using code, for reference.
With Contract.Lines
.ItemCode = EquipCard.ItemCode
.StartDate = Data.StartDate.Value
.EndDate = Data.ExpiryDate.Value
.ManufacturerSerialNum = EquipCard.ManufacturerSerialNum
.InternalSerialNum = EquipCard.InternalSerialNum
.UserFields.Fields.Item("U_UDF1").Value = Data.CUSTOM_FIELD1.Value
' More UDF's are here, but have been removed for brevity
Call .Add '<> 0 Then ' this is a Sub, not a Function like the others
' check to see if maybe an error condition is waiting
Call mCompany.GetLastError(ErrorCode, ErrorMessage)
Debug.Print ErrorCode & " - " & ErrorMessage
Call MsgBox(ErrorCode & " - " & ErrorMessage)
End With
Hi,
The structure of the Business Object is:
Business Object
-->Header properties
-->Lines - a collection
-
>Line - an object
-
>Line properties
-->UserFields - a collection
-->ContactEmployees - a collection
-->etc'
This means that the object to use is the main Business
Object and not the SubObject.
Now we get to the tricky part:
1. Add() method of a collection will only add an <b>empty row</b>(line) to the collection - it will <u><b>not</b></u> add anything to the DB
2. <b>Add() method of the main business object is the only add() function that adds data to the company DB</b>
<u>Bottom line:</u>
1. Use the Contract.Lines.Add() to add empty line in lines collection
2. Use the Contract.Add() to add the object to company DB
Best regards,
Yaniv Gamliel
SDK Consultant
SAP Manage Israel
Thanks for the reply.
With the DI, is it possible to load an existing service contract, then add lines to it, then save those lines to the database?
I tried using the Update method on the contract object after adding line items to the lines collection, and it didn't seem to work.
Thanks,
Demetree
Add a comment