Human Capital Management Blogs by SAP
Get insider info on SAP SuccessFactors HCM suite for core HR and payroll, time and attendance, talent management, employee experience management, and more in this SAP blog.
cancel
Showing results for 
Search instead for 
Did you mean: 
yogananda
Product and Topic Expert
Product and Topic Expert
3,168
Hello ,

The purpose of this article is to demonstrate and explain how Query functions for String, Value, Date and Boolean works.

This will help Comp Admins to achieve when there is a complex requirement, by trying to construct the Formula and assign in a rule for Pipeline calculation to generate results;

Comp Admin will create a custom SQL SELECT Statements in a efficient way that results to return within 5 seconds incase it will be a session run time out and results won't be appearing.

Admins to ensure that the uptime, performance are taken care.

SQL Statement will have parameter condition to set and to be inserted in Plug-in table (TCMP).
By running the pipeline job, rule gets processed and calls the custom SQL query during the stages so that you can get derived results out of it.

Context Variables: The following context variables can be used to reference values in the current processing context:




  • $pipelineRunSeq - current pipeline run's pipelineRunSeq

  • $pipelineRunDate - current pipeline run's startTime

  • $modelSeq - current pipeline run's modelSeq

  • $periodSeq - current pipeline run's periodSeq

  • $calendarSeq - current pipeline run's calendarSeq

  • $processingUnitSeq - current pipeline run's processingUnitSeq

  • $periodStartDate - current pipeline run period's startDate

  • $periodEndDate - current pipeline run period's endDate

  • $lastDateInPeriod - current pipeline run period's lastDate (i.e. endDate minus one second)

  • $tenantId - current tenantId

  • $positionSeq - current position in the processing

  • $positionName - name of the current position in the processing

  • $positionEffectiveStartDate - effectiveStartDate of the current position in the processing

  • $positionEffectiveEndDate - effectiveEndDate of the current position in the processing

  • $positionProcessingStartDate - processingStartDate of the current position in the processing

  • $positionProcessingEndDate - processingEndDate of the current position in the processing

  • $positionCreditStartDate - creditStartDate of the current position in the processing

  • $positionCreditEndDate - creditEndDate of the current position in the processing

  • $payeeSeq - current payee in the processing

  • $ruleSeq - current rule in the processing

  • $planSeq - current plan in the processing

  • $salesTransactionSeq - current sales transaction in the processing (only apply in Allocate stage)

  • $compensationDate - compensation date of the current sales transaction in the processing (only apply in Allocate stage)

  • $salesOrderSeq - current sales order in the processing (only apply in Allocate stage)

  • $creditSeq - current credit in the processing (only apply in Allocate stage)


Parameter Variables: The following parameter variables can be used as values in the input parameter of the query function:




  • $1 - value of the first String parameter in the Query function. (first String parameter)

  • $2 - value of the second String parameter in the Query function (second String parameter)

  • $3 - value of the first Value parameter in the Query function (first Value parameter)

  • $4 - value of the second Value parameter in the Query function (second Value parameter)

  • $5 - value of the first Boolean parameter in the Query function (first Boolean parameter)

  • $6 - value of the second Boolean parameter in the Query function (second Boolean parameter)

  • $7 - value of the first Date parameter in the Query function (first Date parameter)

  • $8 - value of the second Date parameter in the Query function (second Date parameter)


Let's go overview to understand more details about it.




Query for String




Assign the Formula to a Rule based on Rule usage


Insert the SQL Select Statement to CS_Pluginquery Table




Query for Boolean





Insert the SQL Select Statement to CS_Pluginquery Table




Query for Date





Insert the SQL Select Statement to CS_Pluginquery Table




Query for Value 












Using above use-cases, Pipeline results are generated for the functions ;


Query for String , Boolean , Date & Value








 

Note : If SQL Select Statements are not inserted, will receive pipeline errors as shown here below


 



Disclaimers



  • SELECT Statement results should return within 5 seconds else timeout(or it will be canceled)

  • Ensure you have SPACE after the parameter

  • Allowed ONLY SELECT Statements.

  • No UPDATE, INSERT & DELETE Statements allowed.

  • No Stored Procs or Packages to call

  • If the query returns multiple rows, only the first row's value will be considered.


23 Comments
Informative Yoga!!!
sureshmusham
Product and Topic Expert
Product and Topic Expert
This is interesting! We can get rid of building Stagehooks for any minor requirements. Good that you have stressed on the performance aspect when using Query functions.
yogananda
Product and Topic Expert
Product and Topic Expert
Suresh, your thinking on eliminating Stage-hook is highlight and added advantage for Comp admin and support team for risk free deployment and no ticketless
Saurabh_Katoch
Advisor
Advisor
yoganandamuthaiah - The 5 sec aspect is very important else the function will not work. Nice to see another wonderful article.
yogananda
Product and Topic Expert
Product and Topic Expert
you Nailed it !  That's cool Saurabh!
Saurabh_Katoch
Advisor
Advisor
yoganandamuthaiah - for getting the query function into the system you have to go through support to get the insert script executed.
yogananda
Product and Topic Expert
Product and Topic Expert
yes Agree for Production.
tejathogaru
Product and Topic Expert
Product and Topic Expert
Nice article Yoga 🙂
yogananda
Product and Topic Expert
Product and Topic Expert
0 Kudos
Thanks Teja(Mike)!!
rachapudi
Product and Topic Expert
Product and Topic Expert
Thanks much for great article. Read this long back and finally we got a use case to implement recently which was successful. Appreciate for sharing your knowledge.
yogananda
Product and Topic Expert
Product and Topic Expert
0 Kudos
Thank you
suhaskinnimulk
Advisor
Advisor
Great, was trying to explore this.
Keep penning more.
yogananda
Product and Topic Expert
Product and Topic Expert
0 Kudos
Thanks suhas.kinnimulki !
KameshwarNukala
Product and Topic Expert
Product and Topic Expert
Hi Guys,

We have 1.2 M positions and we have written a query to fetch a data point from position how to check the query runs in less than 5 sec during runtime.
yogananda
Product and Topic Expert
Product and Topic Expert
kameshwar.nukala you will test it in local webide before inserting into cs_pluginquery table.
former_member495
Employee
Employee
Hey Yoga, Thanks for sharing this. Referred to this article to setup a plugin and it was very helpful.  In fact the effort required to create a plug in is quite minimal compared to a stage hook and it does give the developer more flexibility.

Thanks again.
yogananda
Product and Topic Expert
Product and Topic Expert
0 Kudos
Thanks, krish19 for your valuable feedback..

Please do share this article with your SPM colleagues, customers, and partners who can make use of this functionality much more...
Good morning.

 

where can I see a log that gives me details, against the processing of some transactions, on the query?

 

Thank you in advance.

Regards,
Daniele
Simone_
Explorer
Hello Daniele,

just for interest, are you implementing SAP Commissions for Agent commission calculation in Italy ?

Thanks

Simone
yogananda
Product and Topic Expert
Product and Topic Expert
0 Kudos
thank youmeharunnisha




DK08
Discoverer
0 Kudos

Hi @yogananda , how to use this in secondary measurement rule generic attribute if I need to stamp the value from sales transaction's generic attribute.

yogananda
Product and Topic Expert
Product and Topic Expert
0 Kudos

@DK08: First thing, how can you find multiple Sales transactions with attributes to update it in each position in SMR rule ?? Its not possible.  If you have per credit or per-incentive rule... it can be updated from Sales transaction attributes to 1n1 for Plugin..

DK08
Discoverer
0 Kudos

Got it! Thanks @yogananda !