Any coding or configuration examples provided in this document are only examples and are NOT intended for use in a productive system. The example is only done to better explain and visualize the topic.

The objective of this blog is to explain how can we create Custom PDF summary for Tickets & It’s Sub Tickets with extension fields.

Below is the detailed scope of this Blog: –

  • Create a Custom BO to retrieve Tickets & It’s Sub Tickets.
  • Create PDF Form for this custom BO
  • Include the PDF generation option to standard Ticket UI.

Implementation Details: –

  1. Create a solution in PDI.
  2. Add extension Fields to Ticket UI through PDI (C4C SDK).
  3. Create Custom BO.
  4. Populate data for the new Custom BO.
  5. Create Print Form.
  6. Create a Embedded Component for Custom BO.
  7. Include “Preview Summary” Button to newly added EC for generating PDF.

Below will be our targeted Sub ticket facet in Ticket TI with “Preview Summary” button to generate PDF summary.

23 2 9581907

1. Create a solution in PDI

Provide required information for the creation of Solution.

2 15 8990572

2. Add extension Fields to Ticket UI through PDI (C4C SDK).

We will add an extension field called “Ext_SpecialNote” to Ticket Header, using PDI logic.

import AP.Common.GDT; import AP.CRM.Global; [Extension] businessobject AP.CRM.Global:ServiceRequest { [Label ("Special Note")] element Ext_SpecialNote:LANGUAGEINDEPENDENT_EXTENDED_Text; node Item { } node ServiceReferenceObject { } }

Add this Extension field to the targeted Ticket TI – /BYD_COD/ServiceOnDemand/AgentWorkspace/COD_SEOD_Agent_Workspace_TI.TI.uicomponent

3. Create Custom BO.

Create a custom BO to retrieve Tickets and Sub Tickets and it’s associated Extension fields.

The custom BO should have the same set of elements at Root & Sub Node level, which needed in the PDF template. For this add transient elements to the custom BO(To hold the standard information).

import AP.Common.GDT as apCommonGDT; import AP.CRM.Global; businessobject Custom_Ticket { [Transient] element TicketID : BusinessTransactionDocumentID; [Transient] element TicketDesc : LANGUAGEINDEPENDENT_LONG_Description; [Transient] element Ext_SpecialNote : LANGUAGEINDEPENDENT_EXTENDED_Text; node SubTickets [0,n] { [Transient] element Sub_TicketID : BusinessTransactionDocumentID; [Transient] element Sub_TicketDesc : LANGUAGEINDEPENDENT_LONG_Description; [Transient] element Sub_TicketExt_SpecialNote : LANGUAGEINDEPENDENT_EXTENDED_Text; } }

4. Populate data for the new Custom BO.

Now we have the Custom BO and elements ready, we need to fill data into it. For this we need to implement After Modify Event at root level.

Below will be the code you can add to retrieve Tickets and It’s associated Sub tickets.

import ABSL; import AP.CRM.Global; import AP.Common.GDT; if ( !this.GetFirst().TicketID.content.IsInitial()) { var requiredTicket = ServiceRequest.Retrieve(this.GetFirst().TicketID); this.GetFirst().TicketDesc = requiredTicket.Name.content; this.GetFirst().Ext_SpecialNote = requiredTicket.Ext_SpecialNote; var SubItems = requiredTicket.BusinessTransactionDocumentReference; this.GetFirst().SubTickets.Delete(); foreach(var current in SubItems) { if(current.BusinessTransactionDocumentReference.TypeCode == "118" && current.BusinessTransactionDocumentRelationshipRoleCode == "14") { var subTicket = ServiceRequest.Retrieve(current.BusinessTransactionDocumentReference.UUID); if(subTicket.IsSet()) { var extSubNode = this.GetFirst().SubTickets.Create(); extSubNode.Sub_TicketID = subTicket.ID; extSubNode.Sub_TicketDesc = subTicket.Name.content; extSubNode.Sub_TicketExt_SpecialNote = subTicket.Ext_SpecialNote; } } } }

5. Create Print Form.

Navigate to Custom BO and click on “Create Print Form“. This first step to create the PDF template and it’s data source.

7 10 8857560

The Form Template Group Header is generated (with a Unique ID) along with the “*.xdp” file.

If you open “*.ftgd” file you can find the unique form group code.

9 11 3700511

The Form Interface structure includes all the fields from the BO including the Sub-Nodes. You can select fields from the Form Interface for Form Template Creation.

Open “*.xdp” file (which will launch the form in adobe livecycle designer) – One can copy the content of an existing form template (“*.xdp” file) to reduce the effort in designing the template again.

Use Adobe LIVECYCLE Designer to create a Adobe Form Template and to bind the field.

12 9 5703197Data View – This view show the hierarchy of information being exposed/available to the form template.

Hierarchy – This will give the details of PDF template’s fields and tables.

Use below window to bind the fields:-

13 10 4943859

Once form is designed, Save and Activate the form. Click on Check-In against the “*.xdp” file in C4C SDK to merge the changes back into Studio – You also need deploy the business configuration.

6. Create a Embedded Component for Custom BO.

Create an Embedded Component with an Inport, with Ticket ID as the incoming parameter. Configure an event to be fired after the trigger of inport.

15 9 2760870

Configure “EV_Initialize” to read the data for passed Ticket ID and it’s associated Sub tickets.

Configure the below operations to set the context.

  • First operation should be ‘BO Read’, which initially checks if the data has already been buffered in Custom BO? If yes, then it avoids re-reading the data back into BO.
  • Second operation should be ‘Condition’, which checks if the attribute ‘ROOT/TICKETID’ gets a result from READ Operation, if NO (blank) then it create an instance.
    • If the Condition is met, i.e. /ROOT/TICKETID= “ “, then :- Do a Data Operation where assign incoming InportData/TicketID to ROOT/TicketID and do a exclusive SyncContainer operation.

17 6 9537969

7. Include Preview Summary Button to newly added EC for generating PDF.

  • Create a button in the same Embedded Component to launch the custom preview form for Ticket & Sub Tickets.
  • Create an Outport to pass the FORM Group Code and the parameter to force front-end preview as-is below

19 5 5122126

  • Create the Event Handler to trigger outport and assign this Event Handler to “ON CLICK” properties of the Button – Add FireOutport operation of previously added Outport.
  • Add the PREVIEW Modal Dialog (from the reuse SAP BYD Application UI folder – /SAP_BYD_APPLICATION_UI/Reuse/OutputManagement/Preview.MD.uicomponent)

Also do a NodeReferenceBinding on ROOT

21 3 2007352

Next add the Embedded Component using a Stable Anchor in the Ticekt TI – /BYD_COD/ServiceOnDemand/AgentWorkspace/COD_SEOD_Agent_Workspace_TI.TI.uicomponent

And do the Outport-Inport Binding.

With above enhancement:- Ticket->Sub ticket will look as shown below.

23 3 5658910

If you click on the button “Preview Summary” It will generate the below PDF.

You can find more details on this concept from this link -:- https://archive.sap.com/documents/docs/DOC-69441