cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Is it possible to read user id dynamically in DM script and pass it on logic script?

Former Member
0 Likes
727

Hi Experts,

Is it some way possible to read the user id of the user executing a data manager package then concatenate it with a char string and pass that concatenated value to a logic script?

For example, currently i have the below script (partial declaration part only), where $INPVERSION$ is a DM Input variable, which is reading input from the user say, "USER123456". Here "123456" is the user id of the user executing the package and "USER" is just a text string appended before. "USER123456" is a member ID of the version dimension.

Script :

*SELECT(%STEAVERS%,"[STEAVERS]",VERSION,"[ID]= $INPVERSION$") *SELECT(%SBCVERS%,"[SBCVERS]",VERSION,"[ID]= $INPVERSION$") *SELECT(%FFYEAR%,"[FFYEAR]",VERSION,"[ID]= $INPVERSION$") *SELECT(%LFYEAR%,"[LFYEAR]",VERSION,"[ID]= $INPVERSION$") *SELECT(%FYEARALL%,"[ID]",TIME,"[ID]>=%FFYEAR% AND ID<=%LFYEAR%") *SELECT(%LAYEAR%,"[LAYEAR]",VERSION,"[ID]= $INPVERSION$") *SELECT(%FYEARLAG%,"[ID]",TIME,"[ID]>=%LAYEAR% AND ID<=%LFYEAR%") *SELECT(%FYEARNXT%,"[ID]",TIME,"[ID]>%FFYEAR% AND ID<=%LFYEAR%")

The above is working fine with DM input variable as explained but the objective is to avoid the DM input and make it dynamic through combination of DM script and Logic script.

I hope i have been able to explain.

Any ideas?

Accepted Solutions (1)

Accepted Solutions (1)

former_member186338
Active Contributor
0 Likes

Try to add:

INFO(%EQU%,=)
INFO(%TAB%,;)
TASK(/CPMB/DEFAULT_FORMULAS_LOGIC,TAB,%TAB%)
TASK(/CPMB/DEFAULT_FORMULAS_LOGIC,EQU,%EQU%)
TASK(/CPMB/DEFAULT_FORMULAS_LOGIC,REPLACEPARAM,USER%EQU%%USER%)

In the script use $USER$

Former Member
0 Likes

Hi Vadim,

How do i concatenate string "USER" and $USER$ in the logic script and pass it to the *SELECT Statements?

Thanks and Regards,

Swakshar

former_member186338
Active Contributor
0 Likes

First - please remove incorrect tag!

Former Member
0 Likes

Primary tag is OK right? Have removed the secondary one.

former_member186338
Active Contributor
0 Likes

Yes, primary is OK, because you are working with BPC NW.

Read my second answer about concatenation. Please accept the correct answer.

former_member186338
Active Contributor
0 Likes

P.S. And it's a bad idea in general to repeat a question without closing the previous one! Next time I will not help you.

Answers (1)

Answers (1)

former_member186338
Active Contributor
0 Likes

In the script you can concatenate text without issues:

*SELECT(%STEAVERS%,[STEAVERS],VERSION,[ID]=USER$USER$)

Former Member
0 Likes

I followed your suggestion and the script looked as below but it seems the TIME dimension values are not getting identified. Though the FFYEAR, LFYEAR and LAYEAR are properly maintained for the VERSION member id

****************************************************************************************************************************

*SELECT(%STEAVERS%,[STEAVERS],VERSION,[ID]=USER$USER$)
*SELECT(%SBCVERS%,[SBCVERS],VERSION,[ID]=USER$USER$)
*SELECT(%FFYEAR%,[FFYEAR],VERSION,[ID]=USER$USER$)
*SELECT(%LFYEAR%,[LFYEAR],VERSION,[ID]=USER$USER$)
*SELECT(%FYEARALL%,[ID],TIME,[ID]>=%FFYEAR% AND [ID]<=%LFYEAR%)
*SELECT(%LAYEAR%,[LAYEAR],VERSION,[ID]=USER$USER$)
*SELECT(%FYEARLAG%,[ID],TIME,[ID]>=%LAYEAR% AND [ID]<=%LFYEAR%)
*SELECT(%FYEARNXT%,[ID],TIME,[ID]>%FFYEAR% AND [ID]<=%LFYEAR%)

****************************************************************************************************************************

Error after running DM package: RUN_LOGIC:No value assigned to dimension "TIME"

For you reference DM script i have updated as:

****************************************************************************************************************************

TASK(/CPMB/DEFAULT_FORMULAS_LOGIC,SUSER,%USER%) 
TASK(/CPMB/DEFAULT_FORMULAS_LOGIC,SAPPSET,%APPSET%) 
TASK(/CPMB/DEFAULT_FORMULAS_LOGIC,SAPP,%APP%) 
INFO(%EQU%,=)
INFO(%TAB%,;)
TASK(/CPMB/DEFAULT_FORMULAS_LOGIC,EQU,%EQU%) 
TASK(/CPMB/DEFAULT_FORMULAS_LOGIC,TAB,%TAB%) 
TASK(/CPMB/DEFAULT_FORMULAS_LOGIC,REPLACEPARAM,USER%EQU%%USER%) 
TASK(/CPMB/DEFAULT_FORMULAS_LOGIC,LOGICFILENAME,XYZ.LGF)

****************************************************************************************************************************

I am not sure whether the SELECT statement is reading the $USER$ variable from the DM script or not.

Regards,

Swakshar

Former Member
0 Likes

Incase you want the full script:

*SELECT(%STEAVERS%,[STEAVERS],VERSION,[ID]=USER$USER$)
*SELECT(%SBCVERS%,[SBCVERS],VERSION,[ID]=USER$USER$)
*SELECT(%FFYEAR%,[FFYEAR],VERSION,[ID]=USER$USER$)
*SELECT(%LFYEAR%,[LFYEAR],VERSION,[ID]=USER$USER$)
*SELECT(%FYEARALL%,[ID],TIME,[ID]>=%FFYEAR% AND [ID]<=%LFYEAR%)
*SELECT(%LAYEAR%,[LAYEAR],VERSION,[ID]=USER$USER$)
*SELECT(%FYEARLAG%,[ID],TIME,[ID]>=%LAYEAR% AND [ID]<=%LFYEAR%)
*SELECT(%FYEARNXT%,[ID],TIME,[ID]>%FFYEAR% AND [ID]<=%LFYEAR%)

*START_BADI UPDATE_CALC_VERS
VERSION = USER%USER%
QUERY = OFF
WRITE = OFF
*END_BADI
//----------------------------------------------------------------------------------------------------------------------------
*XDIM_MEMBERSET VERSION = USER%USER%
*XDIM_MEMBERSET ACCOUNT = INT003

*WHEN ACCOUNT
*IS *
*REC(EXPRESSION = 0)
*ENDWHEN

*XDIM_MEMBERSET INPFACTOR = NO_FACTOR
*XDIM_MEMBERSET GLOBPARAM = NO_GLOBPARAM
*XDIM_MEMBERSET INPUTCURRENCY = USD
*XDIM_MEMBERSET VERSION = USER%USER%,%STEAVERS% 
*XDIM_MEMBERSET DATASOURCE = STEA
*XDIM_MEMBERSET KFTYPE = QUANTITY
*XDIM_MEMBERSET ACCOUNT = 305100
*XDIM_MEMBERSET TIME = %FYEARALL%

*WHEN ACCOUNT
*IS 305100
//Oil equity boepd
*REC(EXPRESSION = -(%VALUE%*1000000)/365,ACCOUNT = INT003,DATASOURCE = CALC,VERSION = USER%USER%)
*ENDWHEN

//----------------------------------------------------------------------------------------------------------------------------
*XDIM_MEMBERSET ACCOUNT = 110580,INT201,CF_055
*XDIM_MEMBERSET VERSION = USER%USER%,%%STEAVERS%,%SBCVERS%
*XDIM_MEMBERSET DATASOURCE = STEA,CALC
*XDIM_MEMBERSET INPFACTOR = NO_FACTOR
*XDIM_MEMBERSET GLOBPARAM = NO_GLOBPARAM
*XDIM_MEMBERSET INPUTCURRENCY = USD
*XDIM_MEMBERSET KFTYPE = AMOUNT
*XDIM_MEMBERSET TIME = %FYEARALL%

//Copy investment to liability
*FOR %FYR% = %FYEARALL%
*WHEN TIME
*IS %FYR%
*WHEN ACCOUNT
*IS 110580
*BEGIN
*REC(EXPRESSION = -%VALUE%,DATASOURCE = CALC, TIME = %FYR%, ACCOUNT = INT201,VERSION = USER%USER%)
*END
*ENDWHEN
*ENDWHEN
*NEXT

*FOR %FYR% = %FYEARALL%
*WHEN TIME
*IS %FYR%
*WHEN ACCOUNT
*IS 110580
*BEGIN
*REC(EXPRESSION = %VALUE%,DATASOURCE = CALC, TIME = %FYR%, ACCOUNT = CF_055,VERSION = USER%USER%)
*END
*ENDWHEN
*ENDWHEN
*NEXT
//------------------------------------------------------------------------------------------------------------------------
former_member186338
Active Contributor
0 Likes

First - you are not looking on your post results!

There are no line breaks in the advanced DM script! I have to copy it to notepad and insert line breaks myself - makes me very unhappy. Looks like you disrespect people answering your questions.

Second - the following lines from my answer are missing in your advanced script:

INFO(%EQU%,=)
INFO(%TAB%,;)

Do you think I posted the mentioned lines just for fun?

As a result $USER$ variable is empty.

former_member186338
Active Contributor
0 Likes

P.S. Just tested correct script in my system!

Everything is working properly.

The correct user id is passed to the variable $USER$ and correct CATEGORY ID is selected after concatenation: USER$USER$

Former Member
0 Likes

Hi Vadim,

Its highly appreciated that you are helping me out. If i am making mistakes there is a polite and professional way to point it out. Making kind of comments that you are making like above are not at all welcome.

If you fail keep patience because i am responding with mistakes you can choose to stop helping me.

I believe this is a professional forum and i am not here to offend or make fun of people's efforts.

Regards,

Swakshar

former_member186338
Active Contributor
0 Likes

Yes, we are using a professional forum. And professionals are always checking the results of posts. Unfortunately I can see a lot of users posting text without correct line breaks (making text unreadable), using "Insert File" instead of correct "Insert Image", posting code as attached screenshot (impossible to copy and edit), posting low resolution images etc... I don't think it's a professional behavior!

P.S. By the way, I am writing about the mentioned issues each week, looks like users asking questions are not reading forum (only asking own questions).

Former Member
0 Likes

Hi Vadim,

Thank you for helping, the issue is resolved. If i was careful enough yesterday, it would have been solved yesterday itself.

Regarding rules of the forum and not following them, i believe there is a way to point out and make people aware who are violating them (Note: they might not be violating DELIBERATELY). Choice of words is something i feel should be checked upon as this is a professional forum not someones personal blog space.

Anyway.

Regards,

Swakshar

former_member186338
Active Contributor
0 Likes

In this particular case I am not talking about violation of forum rules. I am talking about common sense things related to question/comment posting.

P.S. Actually your current question was answered here: https://answers.sap.com/questions/444321/help-with-select-statement-in-script-logic-sap-bpc.html

There is no special variable %USER%!
You have to pass user name from advanced script using REPLACEPARAM

In the current question the full code was provided.