cancel
Showing results for 
Search instead for 
Did you mean: 

how to optimize the code by performance tool tips ?

former_member187312
Participant
0 Kudos

Hello, Experts.

When I checked the performance tips on the above code it shows

so I've modified as below,

Still, I'm getting performance suggestions as below

How to optimize the code without any suggestion leaving by performance tips tool.

Horst Schaude

Br

Senz

Accepted Solutions (0)

Answers (1)

Answers (1)

HorstSchaude
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Senz,

By simply doing what the Performance Tips suggest:
use

if (this.ToParent.CC:IsSet())

instead of

if (parent.CC.Count() > 0 )

HTH,
. Horst

former_member187312
Participant
0 Kudos

Hello Horst,

but this.IsSet() is not available in the auto completion.

Any Idea,

Regards

Senz.

HorstSchaude
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Senz,

I see we need to enhance the performance tips 🙂

First: if you use constructs like "this.<association>" more than twice, it is better to assign it to a variable

var myParent = this.ToParent;

Then you can check it.
Checking means

  • Association => IsSet()
  • Element => IsInitial()

Second: You don't need to check if the "this" is set.

Maybe you share the BO definition so we can see how "CC" is defined.

Bye,
. Horst

former_member187312
Participant
0 Kudos

Thanks Horst

Here is my BO

import AP.Common.GDT as apCommonGDT;

[DeploymentUnit(Financials)] businessobject ApprovalSetup raises GeneralInfo
{
message ServiceIDEmpty text "Service ID cannot be empty,save fails";
message GeneralInfo text "&1":LANGUAGEINDEPENDENT_EXTENDED_Text;
message SourceBOExists text "Entered source business object already exists,save fails";

[AlternativeKey]element ID:BusinessTransactionDocumentID;
element SysAdminData:SystemAdministrativeData;
element CreatedBy:Name;
element ChangedBy:Name;
element Status :ActivationStatusCode;
element SourceBusinessObject:BusinessObjectTypeCode;
element CompanyID : PartyID;
element CompanyName:Name;
element BackupEmployee:EmployeeID;
action Delete;
node DefaultTargetGroups [0,n] raises GeneralInfo,SourceBOExists
{
element ID:BusinessTransactionDocumentItemID;
element Level:NumberValue;
element ActualLevel : NumberValue;
element TargetOption:TARGETOPTIONCode;// 1 = target group, 2= individual, 3= ops manager
element TargetGroupID:BusinessTransactionDocumentID; //  if targetOption =  1
element TargetGroupName:Name;
element AllRelevant:Indicator;
element RelevanceFormula:REL_FORMULACode;
element CommonEmployee : EmployeeID;
element CommonEmployeeName : Name;
action AddCC; 
element WithRFQ:Indicator;
node CC [0,n] raises CCInfo
{
message CCInfo text "&1":LANGUAGEINDEPENDENT_EXTENDED_Text;
element CCEmployee : EmployeeID;
element CCEmployeeName : Name;
}
}
}

and I wrote the code on Root ->Node DefaultTargetGroups->Node CC -> Event AfterModify script.

Regards

Senz.

HorstSchaude
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Senz,

So in short: You want to prevent that another instance of the CC node with the same Employee ID is created?

I would code like this;

var allCCs = this.ToParent.CC;

if (allCCs.IsSet()) {

<check via the Where if the EmployeeID is already existing>

...

}

HTH,
. Horst

former_member187312
Participant
0 Kudos

Hello Horst,

Yes, I want to prevent that another instance of the CC node with the same Employee ID is created and also leaving no suggestion from performance tips because it would be pointed out in the health check of SAP.

Again I'm getting the same problem, no IsSet() is found.

Sorry,

Senz

HorstSchaude
Product and Topic Expert
Product and Topic Expert

Hello Senz,

I've checked the Performance Tips coding for that situation.
I will do some enhancements there. 🙂
For the time being you can ignore those messages for this situation.

Sorry,
. Horst

former_member187312
Participant
0 Kudos

Thanks a lot !!

Regards,

Senz