cancel
Showing results for 
Search instead for 
Did you mean: 

Calculations before parameter mapping in ABAP CDS

shyam_uthaman
Participant
0 Kudos

Hi All,

I have a fiscal period parameter (Ex. 03) and a fiscal year (Ex. 2018) parameter flowing in from a layer of views below. So the select statement now is:

select from <view>

(P_FiscalPeriod: $parameters.P_FiscalPeriod ,P_FiscalYear: $parameters.P_FiscalYear).


Now the user wants to enter a single parameter 03.2018.

To accomodate this change, I would want to separate out the fiscal period and year from this string before the parameter mapping is done - maybe use one of the substring functions.

The problem is that I can't do this within the parameter mapping code. I cant write P_FiscalPeriod: LEFT($parameters.P_FiscalPeriod,2) . It starts giving syntax errors.

I can't figure out the right syntax or other ways to do this. Am not able to find an example either.

Any help would be greatly appreciated.

Regards,

Shyam

Accepted Solutions (1)

Accepted Solutions (1)

D039507
Advisor
Advisor
0 Kudos

But as a workaround you can do something like this:

View 1:

View 2:

shyam_uthaman
Participant
0 Kudos

I did it in a slightly different way. Created the same view as you did to calculate the substring.

Then used a parameter in this view with a @consumption.derivation from this view to read these values form the first view.

Answers (3)

Answers (3)

D039507
Advisor
Advisor
0 Kudos

Hi Shyam,

I have tried to do that in a test system, but this doesn't work.

Sorry, you can't do it in that way....

best Regards

Thorsten

D039507
Advisor
Advisor
0 Kudos

Hi,

I think normally this should work. I do it in a similar way:

as select from ZI_SalesOrderItem ( P_Date_from: $parameters.P_Date_from,

P_Date_to: $parameters.P_Date_to )

as SOI

This is working for me.

Best regards

Thorsten

shyam_uthaman
Participant
0 Kudos

Hi Thorsten,

I am sorry if I am miscommunicating. I want the function to work inside that parameter mapping.

as select from ZI_SalesOrderItem ( P_Date_from: left( $parameters.P_Date_from,6),

P_Date_to: $parameters.P_Date_to )

Regards,

Shyam

D039507
Advisor
Advisor
0 Kudos

Hi,

i did it that way, perhaps that helps you:

with parameters 
@Environment.systemField: #SYSTEM_DATE
p_today: abap.dats


left($parameters.p_today,6) as ExtractPeriod,

Best regards

Thorsten

shyam_uthaman
Participant
0 Kudos

Hi Thorsten,

I was referring to writing that function in the parameter mapping area which does not work.

select from <view>

(P_FiscalPeriod: $parameters.P_FiscalPeriod ,P_FiscalYear: $parameters.P_FiscalYear)

{

field1,

field 2...

}