cancel
Showing results for 
Search instead for 
Did you mean: 

Looping or updating calculated value in hana graphical view

0 Kudos
382

Hi All,

I have one requirement to replicate the MB5B in HANA Studio. I am using MARDH and MATDOC to bring the data

Currently I got in below use case

Opening_Stock(mardh) Stock_Qty(matdoc) date Closing_Stock

100 5 01.02.2019 105

100 -2 02.02.2019 98

100 3 03.02.2019 103

The output I want to bring is as follows:

Opening_Stock(mardh) Stock_Qty(matdoc) date Closing_Stock

100 5 01.02.2019 105

105 -2 02.02.2019 103

103 3 03.02.2019 106

Where Opening_Stock and Closing stock are calculated column.

Can anybody suggest how to loop the model to achieve the above requirement.

Thanks in Advance

Regards,

Juned

Accepted Solutions (0)

Answers (1)

Answers (1)

pfefferf
Active Contributor

When I understand you correct, you want to reach that the opening stock of a specific date is the closing stock of the day before, right?

Instead of thinking about using a loop you have to think how you can join the data. In that case based on your original result you need to projections and one of that projections needs a calculated column which calculates the "day before" (date minus 1 day). With that information you can join both projections and prepare your result like you want to have it, because you have all the necessary data in "one row".

Depending on your amount of data and performance requirements the usage of calculated columns can be probably a problem. Maybe in that case you have to think about using a Table Function which prepares the data (if necessary with imperative logic like loops and index based cells access).