Skip to Content
0

FOX Formula with "Only Read Changed Data"

Jun 14, 2017 at 09:58 AM

276

avatar image

Hi All,

I must admit FOX is a new thing to me and I am trying to learn it. As always the best way to do that is by recreating something that I have done in the past with BPC Standard Script Logic or Custom Logic BADI.

In this case I am trying to enter something in the Analysis which then creates another one or more entries with FOX. It works fine with "Only Read Changed Data", but what I am struggling with is how I can delete the generated records if I enter "0" (clear the input).

The Example:

1. Entering 1000 Spending, Generating with FOX -1000 Cash

2. Entering 0 Spending, but FOX doesn't read/write 0 to Cash

The option I tired is to run Delete function for the "Cash" before the FOX in my sequence. It works if I untick "Only Read Changed Data", but if it is enabled the data is not cleared.

I am trying to avoid running the sequence from button and trying to do something similar to the so called running in "Default" from BPC Classic/Standard.

Thank you for any suggestions!

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

6 Answers

Best Answer
Emiliyan Tanev Jun 15, 2017 at 03:31 PM
0

In addition to very helpful answer from Gregor I found after some search a SAP Note. By default, In-memory doesn't work with empty or zero records.

https://launchpad.support.sap.com/#/notes/0002135884

Share
10 |10000 characters needed characters left characters exceeded
Vadim Kalinin Jun 14, 2017 at 10:51 AM
1

Interesting! I am not an expert in FOX, but can you provide more info about: "Entering 0 Spending, but FOX doesn't read/write 0 to Cash"

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Vadim,

After doing some debugging, I found out that the subset of data before the *FOREACH statement doesn't contain zero values, hence the reason I can't write 0 in the destination.

The destination that needs to be cleared. May 2017 is the one where the source value is zero.

Below is my code.

DATA FLOW TYPE ZSFLOW.
DATA ACCOUNT TYPE ZSACCOUNT.
DATA DEST_ACC TYPE ZSACCOUNT.
DATA DEST_FL TYPE ZSFLOW.
DATA PERIOD TYPE 0FISCPER.

****

BREAK-POINT.
*****Clear Additions
FOREACH PERIOD, ACCOUNT, FLOW.
  IF FLOW = 'CP005' AND ACCOUNT CP 'CL*'.
    DEST_ACC = ATRV( 'ZDEST_ACC', ACCOUNT ).
    DEST_FL = ATRV( 'ZDEST_FL', ACCOUNT ).
    { 0AMOUNT, PERIOD, DEST_ACC, DEST_FL } = 0.
  ENDIF.
ENDFOR.
            <br>
screenshot.png (39.5 kB)
0
Gregor Dieckmann
Jun 14, 2017 at 02:53 PM
1

Hi Emiliyan,

from the documentation ...

Working with Empty Records

Almost all planning function types do not read empty records and do not write empty delta records to the buffer. Copy and Generate are exceptions: both read null records and write null delta records.

...

In transaction RSPLF1 you can check the flag 'Process Empty Records' set in a planning function type and read the F1 documentation there.

In your case you can create a exit planning function type with the flag 'Process Empty Records' set.

Regards,

Gregor

Show 2 Share
10 |10000 characters needed characters left characters exceeded

That was very helpful!!!

0
0
Emiliyan Tanev Jun 14, 2017 at 12:59 PM
0

OK, so my problem is that I used the default option in FOREACH without specifying "IN SELECTION". The "IN SELECTION" option widens the scope of the loop and the data we are working on. By default, from the debugging I get that the system use REFDATA which doesn't pick the zeroes. This at least according to my findings. Any other suggestions are welcome as "IN SELECTION" is not as good as REFDATA.

https://help.sap.com/viewer/0ecf5244825c4742a7b062a89d11c2ac/7.5.7/en-US/4cae4a55dd6e3b9ee10000000a42189b.html

Further variants of the FOREACH loop:

  • FOREACH <Variable> IN REFDATA uses all characteristic values in the reference data for iteration
  • FOREACH <Variable> IN SELECTION uses all characteristic values in the active planning filter for iteration.
  • FOREACH <Variable> IN VARIABLE Var uses all characteristic values in a global variable (Var) for iteration.
Share
10 |10000 characters needed characters left characters exceeded
Cornelia Lezoch Jun 14, 2017 at 02:32 PM
0

what exactly is the fox coding you have written?

Show 1 Share
10 |10000 characters needed characters left characters exceeded

You can check it in the comment next to answer from Vadim above.

0
Emiliyan Tanev Jun 15, 2017 at 08:47 AM
0

Hi Gregor,

So I see that when I enable Process Empty Records, it works fine if I run it as a seprate step. However, it still doesn't write or read if I use only "Read only changed data".

I guess this is what you meant about creating exit planning function?

Regards,

Emiliyan

Share
10 |10000 characters needed characters left characters exceeded