Skip to Content
0

how to optimize the code by performance tool tips ?

Jul 11, 2017 at 05:15 AM

106

avatar image

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

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

1 Answer

Horst Schaude
Jul 12, 2017 at 12:25 PM
0

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

Show 7 Share
10 |10000 characters needed characters left characters exceeded

Hello Horst,

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

Any Idea,

Regards

Senz.

isset.png (14.9 kB)
0

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

0

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.

0

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

0

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

4.jpg (25.9 kB)
0

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

1
Show more comments