Skip to Content

I have seen many blogs to add a buttton in EC and then Embed the EC on TI.

In general that solution is great but sometimes few customers just dont like to click on somehwhere which is not a proper place., Like Standard button group.

Like Below,

The use case : Create a custom button to print PDF ( custom PDF form with linkage to multiple BOs)

How normally it is achieved.,

How they want it to be.

Now without further ado lets see how to do it.

  1. Create an EC in my case this EC is responsible to FireOutport to a Preview reuse component, i.e : Generating PDF

How I made that EC : https://archive.sap.com/documents/docs/DOC-69441

This is very nice document from 

Which is very helpful. However below are the steps.

Creation of Inport:

Creation of InportHandler Event handler :

 

2.So dont delete button from the EC from timebeing and test the button thoroughly before moving to next steps.

 

3. Create a Custom field on a standard BO whereever your EC is linked , in my case it was opportunity.

create a Transient field :

[Transient] element PDFTriggeredAt : DateTime;

 

 

4. declare an action in xBO.

action ShowPDFGeneration;

Code in ABSL File :

import ABSL;
this.PDFTriggeredAt = Context.GetCurrentSystemDateTime().ConvertToGlobalDateTime();

 

So basically we have timestamp for the button pressed ( a transientfield )

5. Now I hope that your EC which is based on somecustom BO has been tested perfectly.

if yes then check if your customBO has the association with StnardBO or not. Like below.

[Transient]element RFQPDFTriggeredAt : DateTime;
[Transient]element OpportunityID:BusinessTransactionDocumentID;
[Transient]element AccountName:LANGUAGEINDEPENDENT_EXTENDED_Text;
node Item[0,n] {

[Label(“Product Category (Opp)”)] element ProductCategoryInternalID : ProductCategoryInternalID;
[Label(“Product Category Description (Opp)”)] element ProductCategoryDescription : LANGUAGEINDEPENDENT_EXTENDED_Text;

}
association ToOpport[0,1] to Opportunity; 
action updateTriggeredAt;

6. Now add the field which you created in point 3 in the DataModel of your EC.

 

6. Add a piece of code in Aftermodify method of Custom BO to fill the associated Opportunity in customBO.

import ABSL;
import AP.Common.Global;
import AP.CRM.Global;

var current = this;
var currentCommon = this.GetFirst();

if(!this.GetFirst().OpportunityID.IsInitial())
{
var OpptQuery = Opportunity.QueryByElements;
var OpptSel = OpptQuery.CreateSelectionParams();
OpptSel.Add(OpptQuery.ID.content,”I”,”EQ”,this.GetFirst().OpportunityID.content);
var OpptRes = OpptQuery.Execute(OpptSel);
var opportBO = Opportunity.Retrieve(this.GetFirst().OpportunityID.AddLeadingZeros());
this.GetFirst().ToOpport = opportBO;
}

7. PreviewHandler has nothing but an FireOutport to Preview Modelbox.

7. Add a custom button on standard TI via extensility explorer.

8. Call your action which you created in Point4.

 

This is just a use case for this kind of work you can do much more with this approch of keeping the EC invisible and playing around with the timestamp transient field.

Another use caase for you to practise : Show a confirmation dialogue box ( Are sure you want to blah blah ) after clicking on a custombutton in standard TI on Standard toolbaar.

I hope this will help fellow patrons.

Regards,

Dhruvin

 

 

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply