cancel
Showing results for 
Search instead for 
Did you mean: 

Script Logic with Multiple For Statments

Former Member
0 Kudos

Hi BPC Team,

I need you advice in logic script for below scenario:

I have 3 Positions with 18 employees.

4 employees are in Position A

8 employees are in Position B

6 employees are in Position C

I have created Position as Dimension, Employee as another dimension with Position as Property.

I have total 10 dimension for this Model and updated Salary level for each positions.

Position A Salary 100000

Position B Salary 125000

Position C Salary 80000

I want script logic to post Each employee with respective salary amount based on Position

4 employees are in Position A Salary of 100000 each

8 employees are in Position B Salary of 125000 each

6 employees are in Position C Salary of 80000 each

Here is the code I am using.

*XDIM_MEMBERSET CHANGE_LEDGER = CL_159

*XDIM_MEMBERSET COSTCENTRE = CC_NONE

*XDIM_MEMBERSET LOCATION = LO_NONE

*XDIM_MEMBERSET PROJECT = PJ_NONE

*XDIM_MEMBERSET RPTCURRENCY = LC

*XDIM_MEMBERSET TIME = 2016.INPUT

*XDIM_MEMBERSET VERSION = VE_ACTUAL

//*SELECT(%PERS%,[ID],TIME,"[YEAR] = '%YEAR%' AND LEVEL = 'MONTH'")

*SELECT(%FIN2%,[ID],GRADE,"[ID] =A','B',’C’")

*FOR %FIN2% = %FIN2%

*XDIM_MEMBERSET GRADE = %FIN2%

*XDIM_MEMBERSET ACCOUNTHR = 10000000

//*XDIM_MEMBERSET EMPLOYEE = NO_EMP

*XDIM_FILTER EMPLOYEE = [EMPLOYEE].properties("GRADENO") = "%FIN2%"

//*XDIM_ADDMEMBERSET EMPLOYEE = NO_EMP

*SELECT(%EMP%,[ID],EMPLOYEE,"[GRADENO] = '%FIN2%'")

*FOR %EMP% = %EMP%

*WHEN ACCOUNTHR

*IS *

*BEGIN

*REC(FACTOR = 1,EMPLOYEE =%EMP%, GRADE =%FIN2%)

*END

*ENDWHEN

*NEXT

*NEXT

*COMMIT

Result of this program is logic is posting:

18 employees are in Position A Salary of 100000 each

18 employees are in Position B Salary of 125000 each

18 employees are in Position C Salary of 80000 each

Could you please let me know where I am making mistake.

Regards,

Tej

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi All,

Solution is to use Run Alloacation.

Regards,

Tej

Answers (1)

Answers (1)

former_member186498
Active Contributor
0 Kudos

Hi Tej,

try this

*SELECT(%FIN2%,[ID],GRADE,"[ID] =A','B',’C’")

*XDIM_MEMBERSET GRADE = %FIN2%

*XDIM_MEMBERSET ACCOUNTHR = 10000000

//*XDIM_MEMBERSET EMPLOYEE = NO_EMP

*XDIM_FILTER EMPLOYEE = [EMPLOYEE].properties("GRADENO") = "%FIN2%"

//*XDIM_ADDMEMBERSET EMPLOYEE = NO_EMP

*SELECT(%EMP1%,[ID],EMPLOYEE,"[GRADENO] = '%FIN2%'")

*WHEN ACCOUNTHR

*IS *

     *FOR %FIN% = %FIN2%

          *FOR %EMP% = %EMP1%

               *WHEN GRADE

               *IS %FIN%

                    *WHEN EMPLOYEE

                    *IS %EMP%

                         *BEGIN

                              *REC(FACTOR = 1,EMPLOYEE =%EMP%, GRADE =%FIN%)

                         *END

                    *ENDWHEN

               *ENDWHEN

          *NEXT

     *NEXT

*ENDWHEN

not sure if you need this statement *XDIM_FILTER EMPLOYEE = [EMPLOYEE].properties("GRADENO") = "%FIN2%" because you build a select on it, try also without it.

Regards

     Roberto

Former Member
0 Kudos

Hi Roberto,

Thanks for the code, will try on Monday and let you know the results.

Thanks.

Tej

Former Member
0 Kudos

Hi Roberto,

This logic is not working.

In my HR cube, i have updated Positionwise salary with Employee as NO_EMP.

Now i want script to read that record and post employeewise salary based on employee dimension property Gradeno(which is Position ID).

The logic you mentioned will give no results, becuase in

*WHEN EMPLOYEE

*IS %EMP%

Cube value exist only for NO_EMP.

So i have tested with

*SELECT(%FIN2%,[ID],GRADE,"[ID] =586','588',’589’")

*XDIM_MEMBERSET GRADE = %FIN2%

*XDIM_MEMBERSET ACCOUNTHR = 10000000

*XDIM_MEMBERSET EMPLOYEE = NO_EM

*SELECT(%EMP1%,[ID],EMPLOYEE,"[GRADENO] = '%FIN2%'")

*WHEN ACCOUNTHR

*IS *

    *FOR %FIN% = %FIN2%

          *FOR %EMP% = %EMP1%

              *WHEN GRADE

              *IS %FIN%

                    *WHEN EMPLOYEE

                    *IS NO_EMP

                        *BEGIN

                              *REC(FACTOR = 1,EMPLOYEE =%EMP%, GRADE =%FIN%)

                        *END

                    *ENDWHEN

              *ENDWHEN

          *NEXT

    *NEXT

*ENDWHEN

System is creating each position for all emplolyees of Select Statment.

Problem is with *REC(FACTOR = 1,EMPLOYEE =%EMP%, GRADE =%FIN%)

Record Statment destination employee has to be only employees which belong to respective Position.

Could you please help me out with this. Sending the screenshot of Logic results