Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Wrong values in FOR/NEXT Loop

I have written following script  sales distribution planning model here i am trying to LOOKUP SALES QUANTITY from the Sales Planning model Region and Product wise, then i LOOKUP the Capacity of container from the SALES DISTRIBUTION DRIVER model and after performing the calculation trying to write in the SALES DISTRIBUTION MODEL WAREHOUSE AND PRODUCT WISE (WAREHOUSE = REGION)

My script is as follows

*XDIM_MEMBERSET ENTITY = %ENTITY_SET%

*XDIM_MEMBERSET VERSION =%VERSION_SET%

*XDIM_MEMBERSET TIME = %TIME_SET%

*XDIM_MEMBERSET DISTRIBUTORS = "NO_DIST"

*XDIM_MEMBERSET COST_CENTER = "1010101001"

*XDIM_MEMBERSET DIST_METHOD = "DEDICATED"

*XDIM_MEMBERSET ACC_SALESDIST = "NO_TRIP"

*LOOKUP SALES//the real name of model 1

*FOR %REG% = 1003, 1002

*FOR %PROD% = 0100100101

*DIM VERSION = "Plan"   

*DIM ENTITY = "1000"

*DIM REGION = %REG%

*DIM PRODUCT = %PROD%

*DIM TIME = %TIME_SET%

*DIM Q%REG%%PROD%: ACC_SAL_M ="QTY"

*NEXT

*NEXT

*ENDLOOKUP

*LOOKUP SALES_DIST_DRIVER//the real name of model 2

*DIM VERSION = "Plan"

*DIM ENTITY = %ENTITY_SET%

*DIM TIME = %TIME_SET%

*DIM VEHICLE = "50FT"

*DIM DISTRIBUTORS = "NO_DIST"

*DIM WAREHOUSE = "NOWH"

*DIM CAPACITY: ACC_SDIST_DRIVER ="CAPACITY"

*ENDLOOKUP

*WHEN_REF_DATA = MASTER_DATA

*FOR %REG% = 1003, 1002

*FOR %PROD% = 0100100101

*WHEN ACC_SALESDIST

*IS "NO_TRIP"

*WHEN DIST_METHOD

*IS "DEDICATED"

*WHEN DISTRIBUTORS

*IS "NO_DIST"

*WHEN COST_CENTER

*IS "1010101001"

*WHEN PRODUCT

*IS %PROD%

*WHEN WAREHOUSE

*IS %REG%

*REC(EXPRESSION = LOOKUP(Q%REG%%PROD%) / LOOKUP(CAPACITY))

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*COMMIT

*NEXT

*NEXT

I am getting following results, system is only picking the values of WAREHOUSE (WAREHOUSE = REGION) 1003 only(i.e. the first value pickup from lookup variable) and writing in both WAREHOUSE 1003 AND 1002. My concern is that it should write REGION AND PRODUCT wise date in respective region and product rather repeating the same data in the other.

LGX:

*XDIM_MEMBERSET ENTITY = 1000

*XDIM_MEMBERSET VERSION =Plan

*XDIM_MEMBERSET TIME = 2016.01

*XDIM_MEMBERSET DISTRIBUTORS = "NO_DIST"

*XDIM_MEMBERSET COST_CENTER = "1010101001"

*XDIM_MEMBERSET DIST_METHOD = "DEDICATED"

*XDIM_MEMBERSET ACC_SALESDIST = "NO_TRIP"

*LOOKUP SALES

*DIM VERSION = "Plan"

*DIM ENTITY = "1000"

*DIM REGION = 1003

*DIM PRODUCT = 0100100101

*DIM TIME = 2016.01

*DIM Q10030100100101: ACC_SAL_M ="QTY"

*DIM VERSION = "Plan"

*DIM ENTITY = "1000"

*DIM REGION = 1002

*DIM PRODUCT = 0100100101

*DIM TIME = 2016.01

*DIM Q10020100100101: ACC_SAL_M ="QTY"

*ENDLOOKUP

*LOOKUP SALES_DIST_DRIVER

*DIM VERSION = "Plan"

*DIM ENTITY = 1000

*DIM TIME = 2016.01

*DIM VEHICLE = "50FT"

*DIM DISTRIBUTORS = "NO_DIST"

*DIM WAREHOUSE = "NOWH"

*DIM CAPACITY: ACC_SDIST_DRIVER ="CAPACITY"

*ENDLOOKUP

*WHEN_REF_DATA = MASTER_DATA

*WHEN ACC_SALESDIST

*IS NO_TRIP

*WHEN DIST_METHOD

*IS DEDICATED

*WHEN DISTRIBUTORS

*IS NO_DIST

*WHEN COST_CENTER

*IS 1010101001

*WHEN PRODUCT

*IS 0100100101

*WHEN WAREHOUSE

*IS 1003

*REC(EXPRESSION = LOOKUP(Q10030100100101) / LOOKUP(CAPACITY))

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*COMMIT

*WHEN ACC_SALESDIST

*IS NO_TRIP

*WHEN DIST_METHOD

*IS DEDICATED

*WHEN DISTRIBUTORS

*IS NO_DIST

*WHEN COST_CENTER

*IS 1010101001

*WHEN PRODUCT

*IS 0100100101

*WHEN WAREHOUSE

*IS 1002

*REC(EXPRESSION = LOOKUP(Q10020100100101) / LOOKUP(CAPACITY))

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*COMMIT

-------------------------------------------------------------------------------------------------------------------------------------

LOG:

LOG BEGIN TIME:2015-11-03 06:09:06

FILE:\ROOT\WEBFOLDERS\PLANNING \ADMINAPP\SALES_DISTRIBUTION\TEST.LGF

USER:ABC

APPSET:PLANNING

APPLICATION:SALES_DISTRIBUTION

[INFO] GET_DIM_LIST(): I_APPL_ID="SALES_DISTRIBUTION", #dimensions=10

ACC_SALESDIST,COST_CENTER,DISTRIBUTORS,DIST_METHOD,ENTITY,MEASURES,PRODUCT,TIME,VERSION,WAREHOUSE

#dim_memberset=7

ENTITY:1000,1 in total.

VERSION:Plan,1 in total.

TIME:2016.01,1 in total.

DISTRIBUTORS:NO_DIST,1 in total.

COST_CENTER:1010101001,1 in total.

DIST_METHOD:DEDICATED,1 in total.

ACC_SALESDIST:NO_TRIP,1 in total.

REC :LOOKUP(Q10030100100101) / LOOKUP(CAPACITY)

CALCULATION BEGIN:

QUERY PROCESSING DATA

QUERY TIME : 0.00 ms. 1  RECORDS QUERIED OUT.

QUERY REFERENCE DATA

QUERY LOOKUP DATA FROM APPLICATION: SALES

QUERY TIME : 0.00 ms. 2  RECORDS QUERIED OUT.

QUERY LOOKUP DATA FROM APPLICATION: SALES_DIST_DRIVER

QUERY TIME : 0.00 ms. 1  RECORDS QUERIED OUT.

CALCULATION TIME IN TOTAL :0.00 ms.

1  RECORDS ARE GENERATED.

CALCULATION END.

ENDWHEN ACCUMULATION: 1  RECORDS ARE GENERATED.

DATA TO WRITE BACK:

ACC_SALESDIST COST_CENTER DISTRIBUTORS DIST_METHOD ENTITY PRODUCT TIME VERSION WAREHOUSE SIGNEDDATA

NO_TRIP 1010101001 NO_DIST DEDICATED 1000 0100100101 2016.01 Plan 1003 - 3.33

Result should write 16.7 value in WAREHOUSE 1002 and PRODUCT 01

I am working on SAP BPC 10.1 Patch 7.0

Please suggest solution

Regards

replied

Script:

//Script in SALES!

*LOOKUP SALES_DIST_DRIVER

*DIM VEHICLE = "50FT"

*DIM DISTRIBUTORS = "NO_DIST"

*DIM WAREHOUSE = "NOWH"

*DIM CAPACITY: ACC_SDIST_DRIVER ="CAPACITY"

//TIME,ENTITY,VERSION will be taken from the current record in WHEN/ENDWHEN

*ENDLOOKUP

*XDIM_MEMBERSET ENTITY=%ENTITY_SET% //or 1000 for test

*XDIM_MEMBERSET VERSION=Plan

*XDIM_MEMBERSET TIME=%TIME_SET% //or 2016.01 for test

*XDIM_MEMBERSET ACCOUNT=ACC_SAL_M

*XDIM_MEMBERSET REGION=1003,1002

*XDIM_MEMBERSET PRODUCT=0100100101 //Can be a list of products...

*DESTINATION_APP SALES_DISTRIBUTION_MAIN

*SKIP_DIM = ACCOUNT

*RENAME_DIM REGION=WAREHOUSE

*ADD_DIM DIST_METHOD=DEDICATED, ACC_SALESDIST=NO_TRIP, DISTRIBUTORS=NO_DIST, COST_CENTER=1010101001

*WHEN TIME

*IS *

*REC(EXPRESSION = %VALUE%/LOOKUP(CAPACITY))

*ENDWHEN

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question