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

Script logic problem

former_member269849
Participant
0 Likes
969

Hi folks,

Please i want to do a logic script who calculate the final stock ,  I have the member Stock_ initial at the dimension  Rubrique_stock and i have the member Ventes ,

the initial stock is  the stock of the the last mounth of last year , and for Ventes it's depending of a mount of the current year ,

here is the script i did but it does not work .

*XDIM_FILTER ARTICLE_SOCIETE = [ARTICLE_SOCIETE].PROPERTIES("TYPE_ARTICLE") ="ZPFN"

*XDIM_MEMBERSET TYPE_VALEUR = QTE

*WHEN RUBRIQUE_STOCK

*IS Stock_initial

//*REC(EXPRESSION = [RUBRIQUE_STOCK].[Stock_initial] + ([RUBRIQUE_STOCK].[Entrées],[TEMPS].[2015.IMP]) - ([RUBRIQUE_STOCK].[Ventes],[TEMPS].[2015.IMP]) - ([RUBRIQUE_STOCK].[Sorties],[TEMPS].[2015.IMP]), RUBRIQUE_STOCK = Stock)

*REC(EXPRESSION = ([RUBRIQUE_STOCK].[Stock_initial],[TEMPS].[2014.12]) - [RUBRIQUE_STOCK].[Sorties], RUBRIQUE_STOCK = Stock)

*ENDWHEN

*COMMIT

You will find attached a screen of the input forms

please what do you suggest ?

Accepted Solutions (1)

Accepted Solutions (1)

former_member186338
Active Contributor
0 Likes

Not clear!

Please provide something like:

RUBRIQUE_STOCK: Stock_initial

TEMPS: 2014.12

Minus

RUBRIQUE_STOCK: Sorties or Ventes???

TEMPS: 2015.IMP or ?? Not clear

Result:

RUBRIQUE_STOCK: Stock

TEMPS: 2015.02 Not clear??

Vadim

P.S. And it's a bad idea to provide code with commented lines - just lead to misunderstanding

former_member269849
Participant
0 Likes

the stock _initial  of last year , and i have Sorties not Ventes .

I have to calculate Ventes of every mounth at the current year

for exemple

Stock  of article 1 for month 2015.01= Ventes (2015.01)- Stock initial ( 2014.12)

Stock  of article 1 for month 2015.02= Ventes (2015.02)- Stock initial ( 2014.12)

former_member186338
Active Contributor
0 Likes

Ok, then:

*XDIM_FILTER ARTICLE_SOCIETE = [ARTICLE_SOCIETE].PROPERTIES("TYPE_ARTICLE") ="ZPFN"

*XDIM_MEMBERSET TYPE_VALEUR = QTE

*XDIM_MEMBERSET RUBRIQUE_STOCK = Stock_initial,Ventes

*XDIM_MEMBERSET TEMPS = 2014.12,2015.01,2015.02,2015.03,2015.04,2015.05,2015.06,2015.07,2015.08,2015.09,2015.10,2015.11,2015.12

*WHEN TEMPS

*IS 2014.12

*WHEN RUBRIQUE_STOCK

*IS Stock_initial

*FOR %M%=01,02,03,04,05,06,07,08,09,10,11,12

*REC(EXPRESSION=-%VALUE%,RUBRIQUE_STOCK=Stock,TEMPS=2015.%M%)

*NEXT

*ENDWHEN

*ELSE //months of current year

*WHEN RUBRIQUE_STOCK

*IS Ventes

*REC(EXPRESSION=%VALUE%,RUBRIQUE_STOCK=Stock)

*ENDWHEN

*ENDWHEN

Vadim

former_member269849
Participant
0 Likes

Thank you Mr Vadim , but it does nit work , i do not understand why.

former_member186338
Active Contributor
0 Likes

"Doesn't work" - what do you mean? No information...

former_member269849
Participant
0 Likes

when i'm testing at the input form , it does not diplay anything at  stock column .

former_member186338
Active Contributor
0 Likes

And how you execute the code? By DM package?

former_member186338
Active Contributor
0 Likes

P.S. Please read:

former_member269849
Participant
0 Likes

Okay , Thank you .

former_member186338
Active Contributor
0 Likes

Please answer my last question - how the code is executed?

And what dimensions do you have in the model - not clear from input form...

former_member269849
Participant
0 Likes

I put the code in DEFAULT.LGF,

and for dimensions of the model : TYPE_VALEUR , TIME,RUBRIQUE_STOCK, ARTICLE_SOCIETE,COST_CENTER

former_member269849
Participant
0 Likes

And i Have two report  the first one where i have Stock_initial and the second one is where i have VENTES

former_member186338
Active Contributor
0 Likes

Default.lgf - is absolutely different story

P.S. The code I have posted was for DM package!

former_member269849
Participant
0 Likes

Ah , i'm new into BPC , please what can i do so that work ?

former_member186338
Active Contributor
0 Likes

The script in Default.lgf below will work if you enter number of Ventes values in the SINGLE YEAR and save!

It will not work on changes of Stock_initial.

//%TEMPS_SET% contain initial scope of sent data for TEMPS dimension - for the same year

*SELECT(%YS%,[YEAR],TEMPS,[ID]=%TEMPS_SET%) //%TEMPS_SET% = ex.: 2015.02,2015.04,2015.05

//%YS% will have years: 2015,2015,2015

*SELECT(%M1%,[ID],TEMPS,[YEAR]=%YS% AND MONTHNUM=1) //%M1% - will contain January of this year 2015.01

*WHEN ARTICLE_SOCIETE.TYPE_ARTICLE

*IS ZPFN

*WHEN TYPE_VALEUR

*IS QTE

*WHEN RUBRIQUE_STOCK

*IS Ventes

*REC(EXPRESSION=%VALUE%-([RUBRIQUE_STOCK].[Stock_initial],[TEMPS].[TMVL(-1,%M1%)]),RUBRIQUE_STOCK=Stock) //TMVL(-1,%M1%)=2014.12

*ENDWHEN

*ENDWHEN

*ENDWHEN

Please read also my document about default.lgf:

Vadim

former_member186338
Active Contributor
0 Likes

P.S. If you want to update Stock_Initial - then you will need to run DM package with my previous code. The Default.lgf will generate error if you change data in different years simultaneously!

former_member269849
Participant
0 Likes

it puts at the Stock column the same value as Ventes

former_member186338
Active Contributor
0 Likes

Please check other dimension members for Stock_Initial:

TYPE_VALEUR?

ARTICLE_SOCIETE?

COST_CENTER?

In my code I assume the same as for Ventes!

And use single report instead of 2! Then you will see the difference in members...

What is M1, M2 on the report?

former_member269849
Participant
0 Likes

Just Descrption of Mounts it M1 is 2015.01 ...., all dimensions are the same .

former_member186338
Active Contributor
0 Likes

If all dimensions are the same then the script will work correctly!

Please show single report with all mentioned members visible!

former_member269849
Participant
0 Likes

Thank you Vadim , it's working now .

former_member186338
Active Contributor
0 Likes

The script can be adjusted to accept simultaneous multi year data entry in Ventes:

*SELECT(%YS%,[YEAR],TEMPS,[ID]=%TEMPS_SET%) //%TEMPS_SET% = ex.: 2015.02,2015.04,2016.05

//%YS% will have years: 2015,2015,2016

*SELECT(%M1S%,[ID],TEMPS,[YEAR]=%YS% AND MONTHNUM=1) //%M1S% - will contain January of two years 2015.01 an 2016.01

*FOR %M1%=%M1S% //Loop 2015.01,2016.01

*WHEN ARTICLE_SOCIETE.TYPE_ARTICLE

*IS ZPFN

*WHEN TYPE_VALEUR

*IS QTE

*WHEN RUBRIQUE_STOCK

*IS Ventes

*REC(EXPRESSION=%VALUE%-([RUBRIQUE_STOCK].[Stock_initial],[TEMPS].[TMVL(-1,%M1%)]),RUBRIQUE_STOCK=Stock) //TMVL(-1,%M1%)=2014.12

*ENDWHEN

*ENDWHEN

*ENDWHEN

*NEXT

But for changes in Stock_initial you will have to run DM package.

Vadim

Answers (0)