cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Planning Function - where to update the values?

Former Member
0 Kudos

Dear all,

I have used a copy function that uses 0CALWEEK as the changeable object and works perfectly on my InfoCube when the aggregation level contains 0CALWEEK.  However, the InfoCube also contains 0CALDAY, 0CALMONTH & 0CALYEAR that must be updated.  The problem with the standard copy function is that when the value for 0CALWEEK is changed from EG - 03.3016 > 10.2016 the values for the other calendar objects would not be correct for 10.2016 as they are just copied, so the copy function generates 0 records, which is to be expected.

So I require a custom planning function to correctly set the values for 0CALDAY, 0CALMONTH & 0CALYEAR.  I copied the class CL_RSPLFC_COPY to my own version and set up my custom planning function to use this new class.  The custom planning function works when using an aggregation level with just 0CALWEEK.  So I've set about amending the code, IF_RSPLFA_SRVTYPE_IMP_EXEC_REF~EXECUTE, to update the values for 0CALDAY, 0CALMONTH & 0CALYEAR using an aggregation level that includes these characteristics.

However, I am struggling to determine where I can write my code to correctly set the values.  I am fine with the actual code; I just can't work out where to write it and which table/work area to work off.

I am assuming that once the values for 0CALDAY, 0CALMONTH & 0CALYEAR are correctly set the custom planning function continues as expected.

Does anyone have any suggestions?

Cheers

Martyn

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Thanks to all who have replied so far.

I have used Cornelia's suggestion of using character relationships as it's a solution specific for my requirement.

I have set my CRs up using CALWEEK as the source and CALDAY etc. as the targets.  I selected the Exit type and created my own class using CL_RSPLS_CR_EXIT_BASE.  I amended the DERIVE method with my code and successfully fill <l_s_buf> when I debug my code using RSPLAN.  So all good so far.

However, the values are not being passed back to the calling method IF_RSPLS_CR_MAPPER~DERIVE_ALL.  The values are contained in <l_s_out> but are not copied to c_s_chas.  When the update is complete my CRs are not being filled as expected.  No errors occur.  My DERIVE statement below.

Any thoughts?  Should I start a new thread?

Cheers

Martyn

Former Member
0 Kudos

When I tried my code today the cube is populating the calendar fields correctly.  Not sure why.  It's now working perfectly.

Thanks to all.

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Martyn,

i would do the following:

  1. Define your own Function Type with corresponding Class.
  2. Create Paramter to hold from(0CALWEEK) and to(0CALWEEK) values
  3. Implement interface IF_RSPLFA_SRVTYPE_IMP_EXEC_REF
  4. In GET_REF_DATA_SEL_METHOD restrict ref data to from records
  5. In EXCECUTE-Method: Create hashed table that hold all records of agg level except 0calday
  6. LOOP at i_th_ref_data and insert each record into this internal hash table (To get rid of caldays)
  7. LOOP at this hashed table and replace component 0CALWEEK by TO-value of parameter
  8. Determine first day of this target week with function module WEEK_GET_FIRST_DAY
  9. then do 7 times increment calday. From this day you derive 0calyear and 0calmonth
  10. insert this new record from 7. into c_th_data (7 records per week)

Thus you consider overlapping months and years with respect to weeks.

That's it.

Regards

Jonas

sheldon_piao
Advisor
Advisor
0 Kudos

Hi Martyn,

The issue is aggregation level itself.

Let's take one example for you:

The planning cube1 contains following record:

0CALMONTH 0CALYEAR 0CALWEEK  KF1

01.2016, 2016, 03.2016   10

If you want to get the following records via standard copy function:

0CALMONTH 0CALYEAR 0CALWEEK  KF1

03.2016, 2016, 10.2016   10

You should not contain 0CALMONTH into the relevant aggregation level.

Then the generic time characterisitic relationship will help you find the relevant month value.

If you add 0CALMONTH into the aggergation level, the system will check the following combination is invalid:

0CALMONTH 0CALYEAR 0CALWEEK  KF1

01.2016, 2016, 10.2016   10


If you involve 0CALDAY, the issue will be more complex because the system cannot know how to get the 0CALDAY value based on 0CALWEEK.

Best Regards,
Sheldon.

cornelia_lezoch
Active Contributor
0 Kudos

Hi Martyn,

what you want to do is better realised with a small copy function on an aggr leven without the char that are dependent and to fill those other time char with char relationships.

Have a look here about the standard time char relationships

http://help.sap.com/saphelp_nw70/helpdata/en/44/be8b631c743959e10000000a1553f6/content.htm?frameset=...

end here about char relationships in general

Characteristic Relationships - Business Intelligence - SAP Library

regards

Cornelia

cornelia_lezoch
Active Contributor
0 Kudos

and by the way - if you still want to do it in a planning function ask google about

"sap help ip planning function"

and you will end up here:

Planning Functions - Business Intelligence - SAP Library

and if you follwo the link to implementing planning function type you get what you need about how to create you own function type ...

regards

Cornelia