Characteristic Relationship - Derive week from 0CALWEEK

I need an exit for characteristic relationship, deriving week (to a custom characteristic ZWEEK) from 0CALWEEK. I.e. I should be filling ZWEEK with the week number 1-52 based on 0CALWEEK's YYYYWW. Anyone have something like this already in place and would perhaps be so generous as to share the code or experiences?
Regards,
Thomas

Hi Thomas,
here you are:
FUNCTION Z_DERIVE_ZWEEK.
*"*"Local interface:
*"       IMPORTING
*"             VALUE(I_AREA) TYPE  UPC_Y_AREA
*"             REFERENCE(ITO_CHA) TYPE  UPC_YTO_CHA
*"             REFERENCE(ITO_SOURCE) TYPE  UPC_YTO_CHA
*"             REFERENCE(ITO_TARGET) TYPE  UPC_YTO_CHA
*"       CHANGING
*"             REFERENCE(XS_CHAS) TYPE  ANY
*"       EXCEPTIONS
*"              FAILED
  FIELD-SYMBOLS: <calweek> TYPE ANY, <zweek> TYPE ANY.
  READ TABLE ito_source TRANSPORTING NO FIELDS WITH
    KEY CHANM = '0CALWEEK'.
  if sy-subrc = 0.
    ASSIGN COMPONENT '0CALWEEK' OF STRUCTURE xs_chas TO <calweek>.
    READ TABLE ito_target TRANSPORTING NO FIELDS WITH
      KEY CHANM = 'ZWEEK'.
    if sy-subrc = 0.
      ASSIGN COMPONENT 'ZWEEK' OF STRUCTURE xs_chas TO <zweek>.
      <zweek> = <calweek>+4(2).
    endif.
  endif.
ENDFUNCTION.
Regards,
Marc
SAP NetWeaver RIG

Similar Messages

  • Characteristic relationships with derivation. I don't quite understand...

    Hi, experts!
    I'm trying to figure out all about using derivation in characteristic relationships and even though I seem to generally understand what it's for, some moments are still unclear.
    Let me describe the task: I have, for example, 10 item categories, all of them are in the real time info-cube. I have unique combinations for them, which are loaded into the DSO and I'm trying to create char. rel-ps based on that DSO.
    In the first aggregation level I'm using only the first 3 levels of item categories. The other 7 are not included.
    Let's assume I've planned my key figures for those 3 levels, and saved the plan. I need the system to distribute (disaggregate) the values among the remaining 7 category levels, so when I open another plan, based on an aggregation level that includes all 10 item categories, I would see all the data correctly and all the necessary combinations.
    As I understand, in that case I need to have characteristic relationships with derivation.
    But SAP demands that all the "target" characteristics should be held in the "Data Fields" section of DSO. And therefore they won't be key fields.
    I don't really get it - why should they be "data fields"? If I use them as "Data Fields" in the DSO, I won't be able to load all the possible combinations, because in some cases these 3 item categories that are the keys of the DSO, will match, only the remaining 7 will be different...
    How do I solve the described task?
    Thanks.
    Best regards,
    Andrey

    Hi Andrey,
    derivation is a function, given the source fields the derive functions fills the target fields. In other words, given a relation with two characteristics A, B with A source and B target the derive function F modeled in the relation 'calculates'  F(a) = b with a, b members of A,B, respecitvely. Since F is a function for a given a there are not two differen b1, b2 with F(a) = b1 and F(a) = b2.
    Using a derivation relation modeled in a data store the function F is defined by the active table of the data store. So A has to be the key and B has to be a an attribute (non-key). If this is not the case and A, B are key fields you can have the combinations
    A    B
    a    b1
    a    b2
    and this is by defintion not a derivation relation, but an n:m relation.
    On other words derivation fills redundant fields.
    It seems that you want to do just the opposite. It is a common problem to plan on a 'higher level' and to disaggregate from the higher level to lower levels, but of course only valid combinations should get values. You can use planning functions or the disaggregation feature in the query. Characteristic relationships are used to model the valid combinations.
    An example is as follows: We have Product -> Product Group -> Product line, the arrows indicate a derivation relation. The query uses all three characteristics in the aggregation level but has only Product Line and Product Group in the rows. Using disaggregation in the query changed key figure values will be disaggregated to Product (and maybe other characteristics used in the aggregation level). The system uses characteristic relationships that can be applied for the aggregation level to check the consistency of the records. Observe that a derivation relations can also be used to check the consistency of a combinations if both source and target fields are filled. Observe that for disaggregation of the above mentiond fields are filled and thus can and have to be checked using the derivation relations (and maybe other modeled relations).If 'access mode for result values' based on characteristic relationships is used in the query the relations can also be used to create all valid combinations needed for disaggregation.
    So you have to check whether the constraints you need are really of type n:m, then all fields have to be key in the data store or whether you have a derivation relation. By the way, derivations can be combined as in the Product -> Product Group (first relation) and Product Group -> Product Line (secdond relation) example.
    Regards,
    Gregor

  • IP Characteristic Relationship used via Filter for derivation in Query

    Hello Experts,
    hopefully you can help me with following issue:
    Currency is an Attribute from Company. I created a Characteristic Relationsship to derive Currency from Company
    Afterwards I created an Aggregation Level with fields
    Currency, Company, Material, Amount, Quantity, Unit.
    On this Aggregation Level I defined a Filter with Company which will be filled from a Variable (Replacement Path, Query, single value).
    I use this Filter in a Ready-Input Query and defined it like follows:
    Rows: Amount and Quantity (restricted to TO)
    Column: Material and Currency
    The field currency should be filled automatically with Currency from Company but it did't. Due to this the Query is not ready input.
    I know that it can be filled via User Exit but this is my last solution if nothing else is working. A Variable with Replacementh path and filled by Attribute of Company does not solve my issue.
    Thank you in advance for any help.
    Kind Regards
    Doris

    Hello,
    thank you all for your answers. I used Workpackages for my issue. I picked it upfrom the "How to Use workpackages to control Locking in BI Integrated Planning".
    With this solution I can fill the currency with Replacmenth Path from Attribute Company.
    This is the first time that I worked with Workpackages for Authorization and I can recomend it because you don't need an User Exit.
    Kind Regards
    Doris

  • Derive method of characteristic relationship with exit class BI IP

    Hi All,
    We have below four fileds in real time planning cube.
    Quantity
    Unit of measure
    Converted Quantity
    Converted UOM
    We have implemented characteristic relationship of type exit between UOM and converted UOM. We need to populate values of converted UOM using characteristic relationship.
    do we need to implement derive method to fulfil this requirement ?
    if yes, when derive method of exit class is getting called ?
    Awaiting for your reply.
    Regards,
    Mitesh.

    Hi Andrey,
    Thanks for your reply.
    I have tried approach suggested by you however break-point did not stop yet to derive method.
    I will give little more details on what i have implemented, probably it may help you.
    I implemented CREATE method and generated below combinations. No other method has been implemented yet.
    UOM            Converted UOM
    G                 KG
    KG              G
    clear ls_unit.
      ls_unit-unit = 'G'.
      ls_unit-unit1 = 'KG'.
      APPEND ls_unit to lt_unit.
      clear ls_unit.
      ls_unit-unit = 'KG'.
      ls_unit-unit1 = 'G'.
      APPEND ls_unit to lt_unit.
    E_TH_CHAS = lt_unit[] .
    Kindly suggest,
    1. any specific configuration at query level is required to call derive method
    2. what code should i need to write if i want to derive above combination using derive method
    Thanks,
    Mitesh.

  • Change first day of the week from Monday to Sunday(0CALWEEK)

    Hello!
    We have a report that display the data at a calendar week level. The start of the week currently show as Monday( retreived from FM - WEEK_GET_FIRST_DAY).
    Is there a global setting in source system to change the start day of the week from Monday to Sunday? I can always make this change in the transformation but would like to know if there is a global option to make this change so the rest of the reports display the same.
    Thanks
    Sirisha

    You can check this SAP Note 624627 - Sunday first day of the week also a working day (Collective)
    Might be helpful.
    Regards,
    AL

  • Fields missing in Characteristic Relationship

    Hi Experts,
    I want to derive Currency Key from Company code using Characteristic Relationship. I am using 'With Derivation' and master data attributes. But in the source fields I see only two fields Cost Center and Controlling Area. Not sure why I am missing rest of the fields from the Cube. Does this mean, I have to have Aggregation levels maintained before I look at Characteristic Relationships??
    Thanks,
    DV

    Hi,
    derivation is used to fill characteristic values from other characteristics in the InfoCube. So to derive 'Currency Key' from 'Company Code' means that both characteristics have to be inculded in your InfoCube. I think, Currency Key is an attribute of Company code, so you can create a derivation relation based on characteristic Company Code.
    If you don't need 'Currency Key' in the InfoCube, you also may use Currency Key as a navigation attribute. Then you need not characteristic relationship for this, the system automatically know about the link between Company Code and Currency Key.
    Regards,
    Gregor

  • Characteristic Relationship Error

    Hi
    I am deriving 0fiscper by concatenating 0fiscper3 and 0fiscyear. This works perfrectly in BPS. However, when I define the characteristic relationship in IP I get hte following error when checking:
    Characteristic relationships for InfoProvider ZSEM_C20 are inconsistent
    Relationship 01 is inconsistent
    Contains generic time derivation 0FISCYEAR,0FISCPER3 -> 0FISCPER
    Not permitted 
    The code for this is exacthly the same as for another derivation I did in BPS. How do I do this in IP?
    L.

    Hi,
    In IP, their are default characteristic relationships for time characteristics which are always active. This wont show in the properties of the real time infoprovider (char. rel. tab) but this will be active and cannot be overridden; this is different from BPS where no such automatic chal. rel.s were present.
    Therefore, you need not code them in an IP implementation.
    Hope this clears your issue.
    Edited by: Mayank Gupta on Feb 1, 2008 2:52 PM

  • IP - Characteristic Relationship with exit class URGENT

    Hi experts,
    I need to derive two infoobjects from other one. I know that I have to use a exit class and there implement the ABAP code for especify the derivation.
    I have copied the exit class CL_RSPLS_CR_EXIT_BASE. I suppose that the code of the derivation has to be implemented in the IF_RSPLS_CR_METHODS~DERIVE method. But, does anybody know the structure witch contain the source and target fields where is/are defined?
    Thanks in advanced.

    Hi,
    set a break-point in the factory method get_instance to check whether the class is called. In the planning modeler make sure that you  use an external break-point.
    Or use rsrt an change a cell value: Derivation is called in the delta buffer to derive from the fields contained in the aggregation level. So check also that the source fields are contained in the aggregation level or can be derived via a a chain of derivations.
    Also make sure that all source fields have to be non-initial. The system will not call derivation for initial source fields since in this case there is not unique target, cf. http://help.sap.com/saphelp_nw70/helpdata/en/43/1c3d0f31b70701e10000000a422035/frameset.htm
    Remark: The attached document of note 994853 is about the disaggregation feature but it also contains a section about the characteristic relationships. Observe also that the template exit classes are documented in SE24.
    Regards,
    Gregor

  • IP - characteristic relationship/ data slices

    Hi Guys,
    I am very new to IP and would like to have some help regarding the following with some simple example
    1) characteristic relationship
    2) data slices
    3) locking
    Some examples with the above is much appreciated.
    where can i get some good document explaining this ?
    Thanks in advance...

    Hi,
      Please find below the examples for characteristic relationship and data slice,
    1. Characteristic relationship:
                 Consider that you have characteristics called "Country" and "Continent" in your report (also in aggreagtion level).
    You cannot always expect the end user to enter the correct continent for a country. In this case, you can create a char rel
    based on the relastionship between these two characteristics (attribute, hierarchy or relationship data loaded to a DSO),where the source is "Country" and the target is "Continent". So when ever the user enters country and continent the char rel validates the entry based on the reference data (master data, hierrarchy or DSO data) and throws error if it s wrong. Apart from this by creating "With derivation" char rel, you can even derive continent value from country with out the user even entering the value in thye report.
    2. Data Slice:
              Consider that your planning requirement is you need to plan on a monthly basis which is like during current month you caa plan for the next month. In this case all other months except the next month should not be available for planning. In this case you can create a daat slice of type "Selection" where in you select '0CALMNONTH' and then filter it to the variable '0CMONTH' +1
    where in you "Exclude" this selection. So now all the other months except next month at any point of time will be disabled for planning.
    You can go through the following links for your reference,
    Char rel - [http://help.sap.com/SAPHELP_NW04s/helpdata/EN/43/1c3d0f31b70701e10000000a422035/frameset.htm]
    Data slice - [http://help.sap.com/SAPHELP_NW04s/helpdata/EN/43/1c3d0f31b70701e10000000a422035/frameset.htm]
    Hope this solves your doubt.
    Regards,
    Balajee

  • Characteristic relationship with Exit class is not applied correctly

    We are using a characteristic relationship (with derivation) type Exit class. For that we have created class ZCL_RSPLS_ARTICLE_FROM_PLMOD as a copy of the standard class CL_RSPLS_CR_EXIT_BASE.
    Target and source characteristics are members of the aggregation level.
    We want to generate a list of valid combinations of characteristics planning models and articles which should be planned in the planning query.
    For that we are using the method IF_RSPLS_CR_METHODS~CREATE:
    Source is characteristic Model ZMATMOD and we determine in the exit class all active articles ZMATART.
    We get a list of active (planning relevant) models and articles in our exit class (table e_th_chas).
    --> For instance 6 combinations
    Until here everything works fine.
    The problem is that in the query 8 combinations are displayed.
    We have no idea why more than the generated combinations are displayed.
    One reason could be that the characteristic article ZMATART is an attribute from characteristic model ZMATMOD.
    So from a master data point of view 8 combinations would be relevant.
    But we use the exit class in order to reduce the number of combinations to planning relevant items.
    If we use the method IF_RSPLS_CR_METHODS~CHECK we could flag the 2 combinations which are not planning relevant to not valid.
    But these are then displayed in the query. 6 combinations in change mode; 2 combinations in display mode. This would not help us.
    We would like to see only the planning relevant combinations  6 combinations
    Can anyone please help me urgently?
    Best regards
    Martin

    Hi,
    set a break-point in the factory method get_instance to check whether the class is called. In the planning modeler make sure that you  use an external break-point.
    Or use rsrt an change a cell value: Derivation is called in the delta buffer to derive from the fields contained in the aggregation level. So check also that the source fields are contained in the aggregation level or can be derived via a a chain of derivations.
    Also make sure that all source fields have to be non-initial. The system will not call derivation for initial source fields since in this case there is not unique target, cf. http://help.sap.com/saphelp_nw70/helpdata/en/43/1c3d0f31b70701e10000000a422035/frameset.htm
    Remark: The attached document of note 994853 is about the disaggregation feature but it also contains a section about the characteristic relationships. Observe also that the template exit classes are documented in SE24.
    Regards,
    Gregor

  • Characteristic Relationship BI-IP

    Hi,
    I am trying to create the following characteristic relationship on real time planning cube.
    Within the realtime cube I have 0fiscper and 0fiscvarnt being populated.
    I also want to calculate 0calquarter and 0halfyear1.
    For this I have created a DSO which has 0fiscper and 0fiscvarnt as the key and 0calquarter and 0halfyear1 as the data fields. I am populating 0fiscper and 0fiscvarnt during the upload and calculating 0calquarter and 0halfyear1 via a routine.
    I am now trying to create the characteristic relationship, but when I enter the DSO technical name, I get the following error message:
    DataStore object '....' does not have a data field from the InfoProvider; this object is invalid here.
    Any ideas why this happening, all the fields in the DSO exist in the realtime cube.
    Thanks
    DJL

    Hi
    For time characteristics, there are standard characteristic relationships.. dont see why need to create them.
    if it is for fiscvarnt-fiscper combination: guess no need for other things.
    Also if u r specifying DSO name in planning modeler, I guess u can look up the DSO thru F4 help.
    rgds
    Deepak

  • Characteristic Relationship Challenges in IP

    All,
    I'm having a bit of a problem with characteristic relationships in IP.
    We have a simple planning cube with no data.  It has the characteristics 0CALMONTH, 0MATERIAL, 0SALESORG, 0SALES_GRP, 0SALES_OFFICE, and 0PAYER.  We want to build a query which allows us to plan on specifically designated valid combinations of 0SALESORG, 0SALES_GRP, 0SALES_OFFICE, and 0PAYER.  However, instead of displaying only the valid combinations we desire, things seem to be showing up as the Cartesian Product of the characteristics.
    We thought we could accomplish this through a characteristic relationship and we tried establishing one (first by creating a DSO and then by creating a hierarchy).  But all combinations seem to yield only one of the following results:
    *Only the first level of the hierarchy
    *The Cartesian product
    *The 2nd level of the hierarchy (and only the 2nd level) but unfortunately containing ALL options in master data
    Has anyone here ever managed to do in IP what I'm trying to do (display only certain valid combinations of characteristics)?  If so can you give me a step by step outline of how you did it?
    According to SAP hosting we have all of the latest Service Packs.

    All, the issue is partially corrected.  Instead of fighting with hierarchies, I stepped back and re-attacked this problem by creating a characteristic relationship based on a DSO.  (I had tried this initially but it failed for a reason I will explain below.)
    We do top-down planning and so I need these valid combinations at each level of granularity.  I created a DSO with the key 0SALESORG, 0SALES_GRP, 0SALES_OFFICE, 0PAYER, and populated it with the valid combinations.  However, when I tried to create the characteristic relationship it does not allow me to select 0PAYER as a "Source Characteristic".  This results the relationship being inconsistent.
    So then I created a DSO with the key 0SALESORG, 0SALES_GRP, 0SALES_OFFICE, and populated the valid combinations.  It worked perfectly for my query at that level of granularity but not for the higher level of simply 0SALESORG and 0SALES_GRP and so I found myself creating another DSO and characteristic relationship to handle that level.
    Now I have the valid combinations down to a certain level of granularity displaying properly, but not all the way to the 0PAYER level.  I'm not sure why it has a problem aside from perhaps the fact that 0PAYER is a reference char based on 0CUSTOMER.  Does anyone know why it has this problem with 0PAYER?
    Additionally I have found that I can no longer execute a simple copy function on my cube because it "cannot find reference data for characteristic combination" in an insistance when I planned on a characteristic with a blank value.

  • Creating characteristic Relationship in IP

    Hi all,
    How do I create characteristic relationship in IP?
    I want to derive Employees based on certain Cost Center.
    This works well in BPS.
    But in IP, when I go to Characteristic Relatioship tab, there is no option/button to create a new relation.
    How do I do this?
    All help is highly appreciated.
    Thanks.
    Anand

    Did you try selecting other real time infoproviders. Do remember char-relationships can be created only for real-time cubes not for multiproviders or actual cubes.
    Also check the real time cube that u selected is set to plan mode in RSA1.
    If the problem is not solved, ask the basis team to look into it. probably a refesh to J2EE engine might solve the problem at times.

  • Characteristic Relationship - displaying data

    Hi All,
    I implemented characteristic relationship (through ABAP class) and it is working fine except one thing.
    It displays the desired combinations, but also posted data in infoprovider in planning mode, that were suppose to be hidden (according to char. rel. logic).
    I set for all the relevant characteristics "characteristic relationship" in query designer....
    Any idea what I am doing wrong?
    Many Thanks!
    Pavel

    Hi Pavel,
    sorry, maybe your exist does not work in all cases (implementation of the check method).
    From your description it seems that you want to control access or maybe only make something not input ready. In the first case use authorization, in the latter use data slices.
    When you say 'measures' it is also not clear for me whether you mean 'key figures'. You can not control key figures with characteristics relations, except you are using a characteristic to model key figures (account model). But again, characteristic relationships are a means to control the valid combination in the cube (so to say they define the 'truth' in the cube or what are 'consistent' data records). Data slices are a concept to protect data from being changed (typical example: lock a planning version).
    Regards,
    Gregor

  • Characteristic Relationship

    I am using a characteristic relationship (without derivation) on Employee for Cost Center.
    I have a cube that contains Key figures for each period for each planned cost center (with employee = #). I am wanting to copy these key figures to the employees within each cost center.
    ex:
    CC   Plan Hrs
    1238  155
    2345  200
    3425  175
    I have employee 10134 (CC = 1238)
    I am wanting to use ONE copy function to copy all key figures changing Employee:
    Employee = # to Employee = 10134
    I was hoping setting the Characteristic relationship would only copy the plan hours according to Master Cost Center (155 hours to 10134, etc). Instead, it will fail stating
    "Combination '10134,DEL/2345' is invalid; Valid is '10134,DEL/1238': Characteristic 0EMPLOYEE'".
    How can I set this characteristic relationship to only allow the copy to employees within the cost center without having it fail? I do not want to allow this function to copy the KF for CC 3425 to employees within another cost center.
    Thanks!

    Hi,
    it seems that you have combinations employee = #, CC = DEL/2345 in your copy source, the system then tries to copy such combinations to  '10134,DEL/2345' and this combination is not valid. This will only happen in the special case that you have employee = # as copy source and 10134 as target and employee is the only field to be changed, i.e. source and target have only single value selections.
    You can work around this effect as follows: allow more more values in the target for employee or by adding CC to the fields to be changed (if this characteristic is not restricted to a single value in the filter used in the planning function).
    Another option is to decomment the following lines in class CL_RSPLFC_COPY, method IF_RSPLFA_SRVTYPE_IMP_EXEC_REF~EXECUTE
            ELSE.
            .... restriction to single values => check the combination (much faster)
              MOVE-CORRESPONDING <s_block_line> TO <s_chas>.
              LOOP AT l_s_rule-t_to_sel INTO l_s_sel.
                ASSIGN COMPONENT l_s_sel-chanm OF STRUCTURE <s_chas> TO <cha>.
              precondition:  l_s_sel-t_rng contains just one line with sign = 'I' and opt = 'Eq'
                LOOP AT l_s_sel-t_rng INTO l_s_rng.
                  <cha> = l_s_rng-low.
                  EXIT.
                ENDLOOP.
              ENDLOOP.
              cl_rsplfr_controller=>p_r_cr_controller->check( EXPORTING i_s_chas = <s_chas>
                                        IMPORTING e_t_mesg = l_t_contr_msg
                                                  e_is_valid = l_is_valid ).
              IF l_is_valid = abap_false.
                continue.                                                                                "<== insert
              create context without real message
               me->msg_with_context( EXPORTING i_r_msg_src = l_r_msg         "<== begin of change
                                               i_s_rule = l_s_rule
                                     CHANGING  c_r_msg_trgt = l_r_i_msg ).
               LOOP AT l_t_contr_msg INTO l_s_contr_msg.
                 MESSAGE ID l_s_contr_msg-msgid TYPE 'E' NUMBER l_s_contr_msg-msgno
                       WITH l_s_contr_msg-msgv1 l_s_contr_msg-msgv2
                            l_s_contr_msg-msgv3 l_s_contr_msg-msgv4
                       INTO l_dummy.
                 l_r_i_msg->add_msg( ).
               ENDLOOP.
               RETURN. " all messages are error. => planning function stops.     "<== end of change
              ENDIF.
    Regards,
    Gregor

Maybe you are looking for