Skip to Content
1

How to create a Document flow ( ActivityTask ) for a Service Ticket On Save using ABSL script.

Mar 14, 2017 at 07:09 AM

378

avatar image
Former Member

Hi Experts,

My scenario is on save of a service ticket I need to create ActivityTask as follow up document with some default values and it should be visible in Document flow tab of the service ticket.

I used below code in the Event-BeforeSave.absl of the ServiceRequest.XBO

import ABSL;

import AP.FO.Activity.Global;

import AP.Common.Global;

import AP.PC.ActivityManagement.Global;

var ServiceTicketKey : BusinessTransactionDocumentKey;

//ActivityTask: Root node

var elTaskRoot : elementsof ActivityTask;

var instTask;

// ActivityTask: define party node

var elTaskParty : elementsof ActivityTask.Party;

var instParty;

// ActivityTask: define service order text collection

var TXT_TYPE_BODY_TEXT = "10002";

var elTaskTxtCollTxt: elementsof ActivityTask.TextCollection.Text;

var elTaskTxtCollTxtCntnt: elementsof ActivityTask.TextCollection.Text.TextContent;

var instTaskTxtColl;

var instTaskTxtCollTxt;

var elPeriod: elementsof ActivityTask.Period;

// ActivityTask: maintain description - mandatory

elTaskRoot.Name.content = "Service Ticket " + this.ID.content.RemoveLeadingZeros();

// ActivityTask: create new instance

instTask = ActivityTask.Create(elTaskRoot);

// Task: Call Particpant

if (! instTask.ProcessorParty.IsSet()) {

elTaskParty.PartyKey.PartyID.content = this.ProcessorParty.PartyKey.PartyID.content;

instTask.ProcessorParty.Create(elTaskParty);

}

else

{

elTaskParty.PartyKey.PartyID.content = this.ProcessorParty.PartyKey.PartyID.content;

instTask.ProcessorParty.Create(elTaskParty);

}

// Task: Set Employee Responsible mandatory

if (! instTask.EmployeeResponsibleParty.IsSet()) {

elTaskParty.PartyKey.PartyID.content = this.ProcessorParty.PartyKey.PartyID.content; // Set Employee ID

instTask.EmployeeResponsibleParty.Create(elTaskParty);

}

else

{

elTaskParty.PartyKey.PartyID.content = this.ProcessorParty.PartyKey.PartyID.content; // Set Employee ID

instTask.EmployeeResponsibleParty.Create(elTaskParty);

}

// Create a text of type "Body Text"

instTaskTxtColl = instTask.TextCollection.Create();

elTaskTxtCollTxt.TypeCode.content = TXT_TYPE_BODY_TEXT;

instTaskTxtCollTxt = instTaskTxtColl.Text.Create(elTaskTxtCollTxt);

elTaskTxtCollTxtCntnt.Text.content = "Body text of the Task activity";

instTaskTxtCollTxt.TextContent.Create(elTaskTxtCollTxtCntnt);

// trying to add service ticket as Reference to the ActivityTask

ServiceTicketKey.BusinessTransactionDocumentID = this.ID; //Service Ticket ID

ServiceTicketKey.BusinessTransactionDocumentTypeCode = this.ProcessingTypeCode; // “Type Code = “SRRE”

instTask.AddReferenceWithDataProvision(ServiceTicketKey);

but no effect. I can see a new task created but it is not attached to the Service ticket as Follow-up or reference document.

Any clues.

I even tried

ActivityTask.CreateWithReference( )

But unable to set default values on the Task.

Regards,

Chella.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Saurabh Kabra
Mar 15, 2017 at 07:02 AM
1

Hi,

You are not passing any thing to 'BusinessTransactionDocumentReference' node to create a document flow entry. This is mandatory to link the document with Predecessor or Successor status. Please refer the attached code through which I am able to attach the activity with Service Request via ABSL.

import ABSL;
import AP.CRM.Global;
var t1 : elementsof ServiceRequest.BusinessTransactionDocumentReference;
t1.BusinessTransactionDocumentReference.ID.content = "46433"; // Activity task ID to be attached 
t1.BusinessTransactionDocumentReference.TypeCode = "542";   // Type code for Activity Task ( Refer Data Type BusinessTransactionDocumentReference for Allowed values )
t1.BusinessTransactionDocumentRelationshipRoleCode = "1"; // Mention if it is Predecessor or Successor ( Refer Data Type BusinessTransactionDocumentRelationshipRoleCode for Allowed values)
this.BusinessTransactionDocumentReference.Create(t1);

Please let know in case you have any issues.

Thanks

Saurabh

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Mar 15, 2017 at 07:26 AM
0

Hi Saurabh,

Thanks for your reply.

It worked using ActivityTask.CreateWithReference(this);

this points to the ServiceRequest BO

import ABSL;
import AP.FO.Activity.Global;
import AP.Common.Global;
import AP.PC.ActivityManagement.Global;

//ActivityTask: Root node
var elTaskRoot : elementsof ActivityTask;

var  instTask = ActivityTask.CreateWithReference(this);

// ActivityTask: define party node
var elTaskParty : elementsof ActivityTask.Party;
var instParty;

instTask.Name.content = "Subject Ticket " + this.ID.content.RemoveLeadingZeros();

if (! instTask.ProcessorParty.IsSet()) {
		elTaskParty.PartyKey.PartyID.content = this.ProcessorParty.PartyKey.PartyID.content;
		instTask.ProcessorParty.Create(elTaskParty);
	}
	else
	{
		instTask.ProcessorParty.Delete();
		elTaskParty.PartyKey.PartyID.content = this.ProcessorParty.PartyKey.PartyID.content; 
		instTask.ProcessorParty.Create(elTaskParty);
	}
	


Thanks,

Chella.

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi B.Chella,

I have a similar problem, I want to create a sub ticket for a ticket as following document, I try the similar code like you provide.But it dump, I don't know why,please help me,thank you.The following link is the question.

https://answers.sap.com/questions/298641/how-to-create-follow-up-documentalso-service-reque.html

Jack.Hua

Best Regard

0