cancel
Showing results for 
Search instead for 
Did you mean: 

DIAPI - Using JCO to link Activities and Service Calls

Former Member
0 Kudos
684

I am attempting to use the SAP B1 API to create and attach Activities to Service Calls.  I am using the Java connector (sapjco.jar).  There is virtually no help available online, other than the API documentation, and I can't locate the sample code that apparently comes as part of the install.

I can use the API to successfully create and update both Activities (IContacts) and Service Calls (IServiceCalls), but I don't know how to link them together. It would make sense if it was done like this

activity.setParentobjectId(call_id)

except this function does not exist.

I guess that maybe I need to use IRelationship, but the API doc says only this:

getRelationships(ICompany aCompany, java.lang.Integer lID)

          get Relationships object with specified ID, BoObjectTypes_oRelationships


Is this correct?  What should BoObjectTypes_oRelationships be?  Is anyone able to give me some guidance please, or at least a useful sample?

Thanks,

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I've now found this article which has helped: 

Here is a working example in Java:

IContacts a;

try {

  a = SBOCOMUtil.newContacts(company.getICompany());

  a.setCardCode(activity.getCardCode());

  a.setDetails("API TEST!");

  a.setNotes("Test");

  a.add();

  int clgCode = Integer.valueOf(company.getICompany().getNewObjectKey());

  System.out.println("NEW CLG CODE: " + clgCode);

  IServiceCalls sc = SBOCOMUtil.getServiceCalls(company.getICompany(), activity.getParentId());

  IServiceCallActivities sca = sc.getActivities();

  sca.add();

  sca.setActivityCode(clgCode);

  System.out.println("SERVICE CALL UPDATE : " + sc.update());

} catch (SBOCOMException e) {

  e.printStackTrace();

}

I've also recreated this code in C# too:

            SAPbobsCOM.Contacts act = sapCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oContacts);

            act.CardCode="C00694";

            act.Details = "API TEST FROM C#";

            act.Notes = "Test from C#";

            act.Add();


            String clgCode = sapCompany.GetNewObjectKey();

          

            SAPbobsCOM.ServiceCalls sc = sapCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oServiceCalls);

            sc.GetByKey(338104);

            sc.Activities.Add();

            sc.Activities.ActivityCode = Convert.ToInt32(clgCode);

            MessageBox.Show("UPDATE RESULT: " + sc.Update());

I hope that this helps others.

Answers (0)