cancel
Showing results for 
Search instead for 
Did you mean: 

BW-IP: Delete Plan Buffer from an Aggregation Level

0 Kudos

Hi All,

Please suggest a way of deleting the data from plan buffer. I'm writing a custom planning function which works as expected. I am triggering this planning function using planning sequence.

But I see that SAP is reading data from plan buffer and deciding to something completely different with it and gives wrong results in my planning function.

Thanks.

Regards,

Sagar

Accepted Solutions (1)

Accepted Solutions (1)

cornelia_lezoch
Active Contributor
0 Kudos

Hello Sagar,

you issue seems to me the standard issue that I encounter with every ABAP programmer when they first work with planning functions.

In planning functions we always calculate the end result of the key figure.

The buffer and the data base then make sure, that delta records to the key figure value are written into the provider.

So in your case, when you say, that you calculate payrise and it creates a data record for salary with -1000, this means, that your function code sets the salary key figure to 0.

Just make sure, that your function code does not change / delete the salary key figure and everything will work fine.

regards

Cornelia

0 Kudos

Hi Cornelia,

"you issue seems to me the standard issue that I encounter with every ABAP programmer"

Well that's a relief. I was starting to believe I was lacking some brain cells 🙂

Although to defend myself and my fellow ABAPers, SAP hasn't done a mighty good job in documenting this stuff. Have they?

Nonetheless, thank you so much for your response and thanks to Sheldon for sticking with me.

"Just make sure, that your function code does not change / delete the salary key figure and everything will work fine."

Actually that is the requirement. Isn't it? To modify the salary key figure. Allow me to explain ( BTW, I've managed to solve the issue. So, below is just for academic purposes )

___________________________________________________________________________________________________________

Both Salary and Pay Rise are to be calculated from a same base key figure (0AMOUNT) in same ADSO (cube like ADSO).

Lets say:

Salary is 0AMOUNT / 12

Pay Rise is ( 0AMOUNT * 2.5% ) / 100

After the above calculations, I'm changing 0AMOUNT in C_TH_DATA for final output.

Wheres the problem then?

  • Something goes on in standard method - GET_REF_DATA_SEL. This is what caused bulk of issues. Upon debugging, I found that SAP is going into buffer. Finding records it shouldn't and doing things it shouldn't. All before my custom code.
  • And yes, along the lines of what you said - I did delete something - not a just a key figure. A whole line from C_TH_DATA. Every time I got a Salary line during Pay Rise function, I deleted the salary line. This caused SAP to think that record needs to be deleted in target. (On this I have a question that I'll ask separately.)

How I managed to get things working? (I'll be concise here. Will give details of my aches and solution in a blog.)

  • Hit & Trials
  • Workarounds
  • Folks from Answers.sap helping around

I'm planning on to write a blog on all the nuances and different moving parts. But before that I hope I could make sense of things SAP has done behind the scenes.

Regards

Sagar

Answers (5)

Answers (5)

0 Kudos

Hi Sagar,

just some final remarks from my side:

1 Most people overlook the fact that the interfaces used in the exit planning functions are documented in SE24, cf. IF_RSPLFA_SRVTYPE_IMP_EXEC_REF, IF_RSPLFA_SRVTYPE_IMP_CHECK (interface and method documentation); for interface IF_RSPLFA_SRVTYPE_TREX_EXEC_R read the how to paper: https://archive.sap.com/documents/docs/DOC-53800

2 I think your approach to copy a SAP implementation was not the right approach to learn the concepts: the COPY function is not a simple planning function! This is why you got features needed for COPY semantics that you maybe don't need in your exit function implementation. You said e.g.:

...Something goes on in standard method - GET_REF_DATA_SEL. This is what caused bulk of issues. Upon debugging, I found that SAP is going into buffer. Finding records it shouldn't and doing things it shouldn't. All before my custom code.

Believe me, everything we do in the COPY function is really needed; but maybe it is not needed in your use case.

Regards,

Gregor

0 Kudos

Hi Gregor,

You somehow seem to bring the best of links/documents out there. This is another great document that's going to be some days for me to read. And I actually, I did come across it earlier too but did not consider reading as it said SQL Script. In my current assignment, I'm supposed to use ABAP layer and not worry about code to data paradigm yet. Although I'll definitely give it a read for understanding the concepts.

"Most people overlook the fact that the interfaces used in the exit planning functions are documented in SE24"

I did as well. Sorry. I'll definitely check that out.

"I think your approach to copy a SAP implementation was not the right approach to learn the concepts"

You couldn't be more right and I totally concur. But the problem is - I never did this to learn the concepts. I've worked as BW ABAP consultant for 4 years, never touched IP and just joined a new job, a month back. Here I was given this massive custom planning function requirement which is tricky in terms of normal ABAP as well, let alone mixing it up standard IP frameworks.. You see, I was (still am, to an extent) basically running in wild, shooting in dark in all the directions.

Although, I'm glad I got this opportunity as I'm finding IP to be far more interesting than core BW. Hope I could crack it sometime soon. Thank you all from SAP though, for all your help so far. Keep up the good work.

Regards,

Sagar

PS: The good thing is, I somehow managed to get it all working finally.

0 Kudos

Hi Sagar,

I recommend that you first read the documentation of the copy function:

https://help.sap.com/viewer/69ec98e0c0e54128a61c32f3255fa438/11.0.7/en-US/4cad7e44d5943b9de10000000a...

If you copy the standard implementation to your implementation it is essential to understand what the standard function does since you might not need the full logic of the standard function. I think there is no issue with the buffer here. The standard copy function always clears the target to have a pure copy semantic (you get in the target what you have in the source). In other words if you have a record in the target that would not be created by the copy function the record is deleted. I think this is the effect you observe.

I recommend also to read how planning functions work in general, cf.

https://help.sap.com/viewer/69ec98e0c0e54128a61c32f3255fa438/11.0.7/en-US/4ca2095cbebd6642e10000000a...

Regards,

Gregor

0 Kudos

Hi Gregor

"I recommend that you first read the documentation of the copy function:"

I'm sure I need to do. My knowledge on all this has been around a month old (at the very best). But having said, should we not have an official and deep technical documentation (like this)? What each standard method (and a slew of objects used in them) does? To enable an amateur to understand what parts to use and what not to? Quite something like RSA3 and RSAX framework for generic extractors.

"The standard copy function always clears the target to have a pure copy semantic"

Yes. This! But what if I have a requirement to do different calculations to the key figures and create 10 record lines for every single line in source and if data is already there in target, then do something else. And if already present data meets a certain specific requirement, do something entirely different.

I'm genuinely disappointed that I couldn't find anything for complex requirements. Every document I found was either just too semantic in nature, explaining what a planning function is, what a block is OR - or told me to multiply 0AMOUNT by 1.5 and call that custom and have a good night.

So I ask. Do you know of such a document? Maybe a Note or KBA? For extreme requirements. (I humbly admit I'm lacking deep technical understanding of IP; I'm giving it a shot though.)

Thanks.

Regards,

Sagar

sheldon_piao
Advisor
Advisor
0 Kudos

Hi Sagar,

I am not quite sure whether the issue can be seen by standard planning function type copy or not. If it is, then it will be easier to guess what happens in the system though it is still not easy to 'replay' what happens in my mind.

If you execute the PS1 only and save data, I assume the target should be:

123 2019001 SALARY 1000

123 2019002 SALARY 1000

123 2019003 SALARY 1000

If above is what I assume, we can confirm that the PS2 is the cause of the negative lines.
Can you confirm above first?

Once again, if we can replicate the issue in standard copy function, the analysis will be easier.

Best Regards,

Sheldon

0 Kudos

Hi Sheldon,

Yes, you are quite correct. PS1 gives the correct data. PS2 will also give correct data if ran independently.

What I mean is - if you run PS1 and then run PS2, negative lines show up. Same is the case with PS2 running first and then PS1. Negative lines show up even then.

Point is - everything runs fine only for the first time. As soon as the data gets written to the target, negative lines start showing up.

Regarding replicating this issue in standard COPY function. I'm not sure we'll get this issue over there. Because here, I'm actually adding extra lines to C_TH_DATA. Although I'll try to replicate it there as well.

Thanks

Sagar

sheldon_piao
Advisor
Advisor
0 Kudos

Dear Sagar,

Do you mean two planning function used in two planning sequences?

Can you execute it one by one with save action between them? Then list the corresponding result after each one to see whether the single execution result is correct or not?

By the way, is it a HANA optimized system? What's version and support package is.

Best Regards,

Sheldon

0 Kudos

Yes Sheldon. Two planning sequences containing two different planning functions. Allow me to give some details.

This is how the design is

Planning Sequence 1 (PS1) -> Contains Planning Function 1 (PF1) - It calculates Salary.

Planning Sequence 2 (PS2) -> Contains Planning Function 2 (PF2) - It calculates Pay Rise.

This is how the execution takes place:

Execute PS1 -> SAVE DATA -> Execute PS2

Key Points:

  • Please note that both of my f=planning functions are a copy of standard COPY function. I'm getting reference data.
  • I have copied code from class of standard copy function for all the methods. Only in the execute method, I'm making changes to do my calculations and saving back to C_TH_DATA
  • Importantly, I'm creating new lines in C_TH_DATA. For every Fiscyear, I'll create 12 new records (for every month) to be added target.
  • One thing I found is - This gets solved (partially) if I comment the code in GET_REF_DATA_SEL method. Only line that I've now left uncommented in this method is => "e_t_ref_charsel = i_t_data_charsel". I'm not getting negative lines if I do this. This has caused another issue for me (that I know how to correct)

I desperately want to understand why is SAP creating negative lines.

System Details:

SAP_BW7500012SAPK-75012INSAPBWSAP Business Warehouse

Database System HDB Release 1.00.122.16.1520

Regards,

Sagar

sheldon_piao
Advisor
Advisor
0 Kudos

Hi Sagar,

What you need might be a correction to fix the issue regarding plan buffer. To narrow down and confirm it is related to plan buffer, can you first disable plan buffer query's cache? If the infoprovider used to build the aggregation level is INFOPROV, the plan buffer query is INFOPROV/!!1INFOPROV. Set the cache to be inactive in transaction code RSRT -> Properties. Then to see whether the planning function's result is correct or not.

Best Regards,
Sheldon

0 Kudos

Hi Sheldon,

Thanks for your answer but I did not find any such option in RSRT. Although it can be parked for now as the issue seems to be with delta handling.

Here is my problem:

I'm calculating two different KPIs - Salary and Pay Rise. Same Aggregation Level, two separate planning functions and two respective planning sequences.

This is how the record should be in target

EMPLOYEE FISCPER DATATYPE AMOUNT

123 2019001 SALARY 1000

123 2019002 SALARY 1000

123 2019003 SALARY 1000

123 2019001 PAYRISE 200

123 2019002 PAYRISE 200

123 2019003 PAYRISE 200

But whenever I calculate payrise after salary - a negative record is created for already existing salary record. Why is that? Below is the data I end up getting.

123 2019001 SALARY 1000

123 2019001 SALARY 1000-

123 2019002 SALARY 1000

123 2019002 SALARY 1000-

123 2019003 SALARY 1000

123 2019003 SALARY 1000-

123 2019001 PAYRISE 200

123 2019002 PAYRISE 200

123 2019003 PAYRISE 200

Can you please help me with this negative line? How is it getting created? I was presuming it was buffer playing a part.

Thanks

Sagar