cancel
Showing results for 
Search instead for 
Did you mean: 

Start Routine for 0COSTELMNT_0102_HIER

Former Member
0 Kudos

Hi everyone,

i load the Cost element Hierarchy into BW and i got an Error: The "from" value is larger than the "to" value for the interval node with ID XX and XY and node name.

On SCN Forum, i understand the Reason for the Problem : 'Intervals in IDOC format: The interval segment in IDoc format is not compatible with the interval segment of the target structure.Therefore you need to create a start routine that writes the From value of the interval to the node structure segment. The corresponding function call is created by default as a comment in a new start routine. You simply have to remove the comments and enter the correct source field of the hierarchy basis characteristic. In the interval segment you assign the LEAFTO field to the corresponding target InfoObjects.

Creating a Transformation for a Hierarchy - Modeling - SAP Library

i found that there is a difference betwen the interval of Field 'Leafto' and interval of target '0COSTELMNT' and '0CO_AREA' so i write this Code on Start routine :

CALL METHOD cl_rstran_gen_step_hier_split=>reset_interval_nodes
EXPORTING
i_iobjnm      = ('0COSTELMNT','0CO_AREA')
i_t_intervals = SOURCE_PACKAGE_5
CHANGING
c_t_nodes     = SOURCE_PACKAGE_3.


But this Code doesn't work. Can you please help me how to fix this Code?.

Thanks



Accepted Solutions (0)

Answers (1)

Answers (1)

RafkeMagic
Active Contributor
0 Kudos

No clue where you got the above code and how you think that will solve your issue, but your issue is due to the fact that 0COSTELMNT is compounded with 0CO_AREA and your SOURCE_FIELDS_3-NODENAME contains both (concatenated)... so you cannot use a 1-1 mapping.

I suggest you get together with a developer and debug a small load to see how & when you should "split" up this concatenated field.

Former Member
anindya_bose
Active Contributor
0 Kudos

Hi Pha

Did you try with just cost element ?

Like 

i_iobjnm      = '0COSTELMNT'

@Raf, this code seems to be a part of OSS note which is not available outside SAP. 

Regards

Anindya

Former Member
0 Kudos

i tried it but it not work

Former Member
0 Kudos

hi Anindya,

i think the code i wrote wrong.

i_iobjnm      = ('0COSTELMNT','0CO_AREA')

anindya_bose
Active Contributor
0 Kudos

I feel the same.  It would take only one InfoObject I guess.

After this start routine , put a break point and run the DTP in Debug Mode in dialog.

Once the DTP stops at break point, check the content of the table SOURCE_PACKAGE_3 .

You would get an idea whether it could change the dates ( to and from )

Regards

Anindya

Former Member
0 Kudos

Hi Anindya,

Do you know how to assign 2 Value for the parameter: i_iobjnm ?

This Code i_iobjnm      = ('0COSTELMNT','0CO_AREA') is not correct because i write it as SQL Code therefore its wrong.


anindya_bose
Active Contributor
0 Kudos

I am not sure if this method would take two InfoObjects.

Below note might help you .

http://service.sap.com/sap/support/notes/2024513

Instead of the Class/Method I tried a custom ABAP to interchange DATEFROM and DATETO .  Can you try to comment the class/method portion and use this custom code ?

Here is the code :

DATA TEMP_DATE TYPE SY-DATUM.

LOOP AT SOURCE_PACKAGE_3 ASSIGNING <SOURCE_FIELDS_3>  .

  IF <SOURCE_FIELDS_3>-DATEFROM GT   <SOURCE_FIELDS_3>-DATETO .

    TEMP_DATE = <SOURCE_FIELDS_3>-DATETO .

   <SOURCE_FIELDS_3>-DATETO = <SOURCE_FIELDS_3>-DATEFROM .

   <SOURCE_FIELDS_3>-DATEFROM = TEMP_DATE .

   CLEAR TEMP_DATE .

  ENDIF .

ENDLOOP.

Regards

Anindya

Former Member
0 Kudos

Hi Anindya,

Thanks for your valuable help. i applied your code but it still show me the same Error

anindya_bose
Active Contributor
0 Kudos

If you go to PSA, for Hierarchy DataSource you would see different segment.  Can you check which segment data has From Date greater than To Date ?

I can see Source_Package_2,3,5 has DATETO DATEFROM Fileld .  What is the setting of your Hierarchy ?  Is it a Time Dependent one ? Please check the setting once under hierarchy tab and provide a screenshot .

Regards

Anindya

Former Member
0 Kudos

Thanks Anindya,

Can you please tell me how to check " which segment data has From Date greater than To Date ?"

and the setting of Hierarchy?

anindya_bose
Active Contributor
0 Kudos

To check different Segment, Right Click on DataSource------> Manage----->Select Request----->PSA Maintenance ----> choose different segment ( Hierarchy Node, Node Text etc ) to see data

To Check  Hierarchy Setting ,  RSD1 ---->0COSTELEMT ---> Hierarchy Tab

May be you do not need a "time depended hierarchy" but this setting is checked for some reasons.

Additionally if it is your development system, you can try the same routine for SOURCE_PACKAGE_2 and SOURCE_PACKAGE_5

Regards

Anindya

Former Member
0 Kudos

thanks Anindya,

i have check all segments in PSA. there is no Fields "Date from" and "date to" , there is only field "valid from" and "valid to" and in these Fields there are no data (blank).

Regarding the Error: Interval node with ID 314: The "from" value is larger than the "to" value , when i click on the technical info, i got the Message: by swaping the from and to values we can have valid hierarchy structure


i have enter RSD1 ---->0COSTELEMT . But i can't find the Hierarchy Tab, where can i find the Tab?

what do you mean by :you can try the same routine for SOURCE_PACKAGE_2 and SOURCE_PACKAGE_5. i don't understand what to do, can you please say in more detail.


Please help me Anindya,

Former Member
0 Kudos

Hi Anindya,

i have check the Hierarchy Setting.the hierarchy is not time independency

How can you check Source_Package_2,3,5, that has DATETO DATEFROM Fields?

anindya_bose
Active Contributor
0 Kudos

Hi Pha

my hierarchy is not time dependent., please check the attached screenshot. What is the setting for 0COSTELMNT in your system ?

Valid To and Valid From are the description of the field DATEFROM and DATETO.

As per the error message, you are getting problems because your "Valid From" Date is greater than "Valid To" Date .  So, if we can swap where Datefrom > DateTO, we should be fine.

Now, the code I provided would do the same for SOURCE_PACKAGE_3 .

What I want is to repeat the same for SOURCE_PACKEGE_2 and 5. 

Copy the code from LOOP AT ....ENDLOOP  and replace SOURCE_PACKAGE_3 with SOURCE_PACKGE_2 .

Ultimately you would have 3 loops.  One for package 2, one for 3 and one for 5.

Regards

Anindya

Former Member
0 Kudos

Hi Anindya,

you mean the code like this:

DATA TEMP_DATE TYPE SY-DATUM.

LOOP AT SOURCE_PACKAGE_3 ASSIGNING <SOURCE_FIELDS_3>  .

  IF <SOURCE_FIELDS_3>-DATEFROM GT   <SOURCE_FIELDS_3>-DATETO .

    TEMP_DATE = <SOURCE_FIELDS_3>-DATETO .

   <SOURCE_FIELDS_3>-DATETO = <SOURCE_FIELDS_3>-DATEFROM .

   <SOURCE_FIELDS_3>-DATEFROM = TEMP_DATE .

   CLEAR TEMP_DATE .

  ENDIF .

ENDLOOP.


DATA TEMP_DATE TYPE SY-DATUM.

LOOP AT SOURCE_PACKAGE_2 ASSIGNING <SOURCE_FIELDS_2>  .

  IF <SOURCE_FIELDS_2>-DATEFROM GT   <SOURCE_FIELDS_2>-DATETO .

    TEMP_DATE = <SOURCE_FIELDS_2>-DATETO .

   <SOURCE_FIELDS_2>-DATETO = <SOURCE_FIELDS_2>-DATEFROM .

   <SOURCE_FIELDS_2>-DATEFROM = TEMP_DATE .

   CLEAR TEMP_DATE .

  ENDIF .

ENDLOOP.

DATA TEMP_DATE TYPE SY-DATUM.

LOOP AT SOURCE_PACKAGE_5 ASSIGNING <SOURCE_FIELDS_5>  .

  IF <SOURCE_FIELDS_5>-DATEFROM GT   <SOURCE_FIELDS_5>-DATETO .

    TEMP_DATE = <SOURCE_FIELDS_5>-DATETO .

   <SOURCE_FIELDS_5>-DATETO = <SOURCE_FIELDS_5>-DATEFROM .

   <SOURCE_FIELDS_5>-DATEFROM = TEMP_DATE .

   CLEAR TEMP_DATE .

  ENDIF .

ENDLOOP.

i have copy this Code in pase it in the Start rout tine right?

Thankyou so much!

anindya_bose
Active Contributor
0 Kudos

Your Hierarchy is Time Dependent or Independent ?  Can you put the screenshot of setting?

You can double click on Source_Package_3 , it will take you to type definition like below

SOURCE_PACKAGE_3              type _ty_t_SC_3

double click on _ty_t_SC_3  , it will take to structure _ty_s_SC_3  .

Right click on _ty_s_SC_3  would show you the structure.

Regards

Anindya

anindya_bose
Active Contributor
0 Kudos

Hi

You just dont need the below statement 3 times.  This is definition of field, so one time is enough.

DATA TEMP_DATE TYPE SY-DATUM.



Reards

Anindya

Former Member
0 Kudos

Hi Anindya,

i have check, the setting for Hierarchy is the same as your picture, no time independen.

how can i find Source_Package_3?

i cant provide the screenshot now because my Computer is cotrolled by IT service which will not allow any data to be uploaded in internet

Thanks

Former Member
0 Kudos

Hi Anindya,

here is the setting of my start routine: PROGRAM trans_routine.


*---------------------------------------------------------------------*
*       CLASS routine DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_transform DEFINITION.
   PUBLIC SECTION.

*  Attributs
     DATA:
       p_check_master_data_exist
             TYPE RSODSOCHECKONLY READ-ONLY,
*-    Instance for getting request runtime attributs;
*     Available information: Refer to methods of
*     interface 'if_rsbk_request_admintab_view'
       p_r_request
             TYPE REF TO if_rsbk_request_admintab_view READ-ONLY.

   PRIVATE SECTION.

     TYPE-POOLS: rsd, rstr.

*   Rule specific types
     TYPES:
       BEGIN OF _ty_s_SC_1,
*      Field: HIENM Hierarchy name.
         HIENM           TYPE C LENGTH 30,
*      Field: VERSION Hierarchy version.
         VERSION           TYPE C LENGTH 3,
*      Field: DATEFROM Valid from.
         DATEFROM           TYPE D,
*      Field: DATETO To.
         DATETO           TYPE D,
*      Field: OBJECTID Object ID.
         OBJECTID           TYPE I,
*      Field: RECORD Record Number.
         RECORD           TYPE RSARECORD,
       END   OF _ty_s_SC_1.
     TYPES:
       _ty_t_SC_1        TYPE STANDARD TABLE OF _ty_s_SC_1
                         WITH NON-UNIQUE DEFAULT KEY.
     TYPES:
       BEGIN OF _ty_s_SC_2,
*      Field: LANGU Language.
         LANGU           TYPE C LENGTH 1,
*      Field: TXTSH Short description.
         TXTSH           TYPE C LENGTH 20,
*      Field: TXTMD Medium description.
         TXTMD           TYPE C LENGTH 40,
*      Field: TXTLG Long description.
         TXTLG           TYPE C LENGTH 60,
*      Field: OBJECTID Object ID.
         OBJECTID           TYPE I,
*      Field: RECORD Record Number.
         RECORD           TYPE RSARECORD,
       END   OF _ty_s_SC_2.
     TYPES:
       _ty_t_SC_2        TYPE STANDARD TABLE OF _ty_s_SC_2
                         WITH NON-UNIQUE DEFAULT KEY.
     TYPES:
       BEGIN OF _ty_s_SC_3,
*      Field: NODEID HierNode ID.
         NODEID           TYPE N LENGTH 8,
*      Field: IOBJNM InfoObject.
         IOBJNM           TYPE C LENGTH 30,
*      Field: NODENAME Node name.
         NODENAME           TYPE C LENGTH 32,
*      Field: TLEVEL Node level.
         TLEVEL           TYPE N LENGTH 2,
*      Field: LINK Link ID.
         LINK           TYPE C LENGTH 1,
*      Field: PARENTID ID superior node.
         PARENTID           TYPE N LENGTH 8,
*      Field: CHILDID ID sub. node.
         CHILDID           TYPE N LENGTH 8,
*      Field: NEXTID ID of the next node.
         NEXTID           TYPE N LENGTH 8,
*      Field: DATEFROM Valid from.
         DATEFROM           TYPE D,
*      Field: DATETO To.
         DATETO           TYPE D,
*      Field: INTERVL Indicator.
         INTERVL           TYPE C LENGTH 1,
*      Field: FIELDNM Field.
         FIELDNM           TYPE C LENGTH 30,
*      Field: KOKRS CO Area.
         KOKRS           TYPE C LENGTH 4,
*      Field: KSTAR Cost Element.
         KSTAR           TYPE C LENGTH 10,
*      Field: OBJECTID Object ID.
         OBJECTID           TYPE I,
*      Field: RECORD Record Number.
         RECORD           TYPE RSARECORD,
       END   OF _ty_s_SC_3.
     TYPES:
       _ty_t_SC_3        TYPE STANDARD TABLE OF _ty_s_SC_3
                         WITH NON-UNIQUE DEFAULT KEY.
     TYPES:
       BEGIN OF _ty_s_SC_4,
*      Field: LANGU Language.
         LANGU           TYPE C LENGTH 1,
*      Field: IOBJNM InfoObject.
         IOBJNM           TYPE C LENGTH 30,
*      Field: NODENAME Node name.
         NODENAME           TYPE C LENGTH 32,
*      Field: TXTSH Short description.
         TXTSH           TYPE C LENGTH 20,
*      Field: TXTMD Medium description.
         TXTMD           TYPE C LENGTH 40,
*      Field: TXTLG Long description.
         TXTLG           TYPE C LENGTH 60,
*      Field: OBJECTID Object ID.
         OBJECTID           TYPE I,
*      Field: RECORD Record Number.
         RECORD           TYPE RSARECORD,
       END   OF _ty_s_SC_4.
     TYPES:
       _ty_t_SC_4        TYPE STANDARD TABLE OF _ty_s_SC_4
                         WITH NON-UNIQUE DEFAULT KEY.
     TYPES:
       BEGIN OF _ty_s_SC_5,
*      Field: NODEID HierNode ID.
         NODEID           TYPE N LENGTH 8,
*      Field: LEAFFROM Page from.
         LEAFFROM           TYPE C LENGTH 32,
*      Field: LEAFTO Page to.
         LEAFTO           TYPE C LENGTH 32,
*      Field: KSTAR Cost Element.
         KSTAR           TYPE C LENGTH 10,
*      Field: OBJECTID Object ID.
         OBJECTID           TYPE I,
*      Field: RECORD Record Number.
         RECORD           TYPE RSARECORD,
       END   OF _ty_s_SC_5.
     TYPES:
       _ty_t_SC_5        TYPE STANDARD TABLE OF _ty_s_SC_5
                         WITH NON-UNIQUE DEFAULT KEY.

*$*$ begin of global - insert your declaration only below this line  *-*
... "insert your code here
*$*$ end of global - insert your declaration only before this line   *-*

     METHODS
       start_routine
         IMPORTING
           request                  type rsrequest
           datapackid               type rsdatapid
           segid                    type rsbk_segid
         EXPORTING
           monitor                  type rstr_ty_t_monitors
         CHANGING
           SOURCE_PACKAGE_1              type _ty_t_SC_1
           SOURCE_PACKAGE_2              type _ty_t_SC_2
           SOURCE_PACKAGE_3              type _ty_t_SC_3
           SOURCE_PACKAGE_4              type _ty_t_SC_4
           SOURCE_PACKAGE_5              type _ty_t_SC_5
         RAISING
           cx_rsrout_abort
           cx_rsbk_errorcount.
     METHODS
       inverse_start_routine
         IMPORTING
           i_th_fields_outbound         TYPE rstran_t_field_inv
           I_R_SELSET_OUTBOUND          TYPE REF TO CL_RSMDS_SET
           i_is_main_selection          TYPE rs_bool
           i_r_selset_outbound_complete TYPE REF TO cl_rsmds_set
           i_r_universe_inbound         TYPE REF TO CL_RSMDS_UNIVERSE
         CHANGING
           c_th_fields_inbound          TYPE rstran_t_field_inv
           c_r_selset_inbound           TYPE REF TO CL_RSMDS_SET
           c_exact                      TYPE rs_bool.
ENDCLASS.                    "routine DEFINITION

*$*$ begin of 2nd part global - insert your code only below this line  *
... "insert your code here
*$*$ end of 2nd part global - insert your code only before this line   *

*---------------------------------------------------------------------*
*       CLASS routine IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_transform IMPLEMENTATION.

*----------------------------------------------------------------------*
*       Method start_routine
*----------------------------------------------------------------------*
*       Calculation of source package via start routine
*----------------------------------------------------------------------*
*   <-> source package
*----------------------------------------------------------------------*
   METHOD start_routine.
*=== Segments ===

     FIELD-SYMBOLS:
       <SOURCE_FIELDS_1>    TYPE _ty_s_SC_1,
       <SOURCE_FIELDS_2>    TYPE _ty_s_SC_2,
       <SOURCE_FIELDS_3>    TYPE _ty_s_SC_3,
       <SOURCE_FIELDS_4>    TYPE _ty_s_SC_4,
       <SOURCE_FIELDS_5>    TYPE _ty_s_SC_5.

     DATA:
       MONITOR_REC     TYPE rstmonitor.

*$*$ begin of routine - insert your code only below this line        *-*
... "insert your code here
*--  fill table "MONITOR" with values of structure "MONITOR_REC"
*-   to make monitor entries
... "to cancel the update process
*    raise exception type CX_RSROUT_ABORT.



*$*$ end of routine - insert your code only before this line         *-*
   ENDMETHOD.                    "start_routine
*----------------------------------------------------------------------*
*       Inverse method inverse_start_routine
*----------------------------------------------------------------------*
*       This subroutine needs to be implemented only for direct access
*       (for better performance) and for the Report/Report Interface
*       (drill through).
*       The inverse routine should transform a projection and
*       a selection for the target to a projection and a selection
*       for the source, respectively.
*       If the implementation remains empty all fields are filled and
*       all values are selected.
*----------------------------------------------------------------------*
*       Customer comment:
*----------------------------------------------------------------------*
   METHOD inverse_start_routine.

*   IMPORTING
*     i_r_selset_outbound          TYPE REF TO cl_rsmds_set
*     i_th_fields_outbound         TYPE HASHED TABLE
*     i_r_selset_outbound_complete TYPE REF TO cl_rsmds_set
*     i_r_universe_inbound         TYPE REF TO cl_rsmds_universe
*   CHANGING
*     c_r_selset_inbound           TYPE REF TO cl_rsmds_set
*     c_th_fields_inbound          TYPE HASHED TABLE
*     c_exact                      TYPE rs_bool

*$*$ begin of inverse routine - insert your code only below this line*-*
... "insert your code here
*$*$ end of inverse routine - insert your code only before this line *-*

   ENDMETHOD.                    "inverse_start_routine

anindya_bose
Active Contributor
0 Kudos

My mistake, only SOURCE_PACKAGE_1 and 3 have DATEFROM and DATETO.

Can you just put the routine for package 1 and 3.  ( 3 is already there ) .

Regards

Anindya

Former Member
0 Kudos

Hi Anindya,

i applied this Code but it still doesn't work and give me the same Error. Can you please help to look at my code:

DATA TEMP_DATE TYPE SY-DATUM.
LOOP AT SOURCE_PACKAGE_3 ASSIGNING <SOURCE_FIELDS_3>  .
   IF <SOURCE_FIELDS_3>-DATEFROM GT   <SOURCE_FIELDS_3>-DATETO .
     TEMP_DATE = <SOURCE_FIELDS_3>-DATETO .
    <SOURCE_FIELDS_3>-DATETO = <SOURCE_FIELDS_3>-DATEFROM .
    <SOURCE_FIELDS_3>-DATEFROM = TEMP_DATE .
    CLEAR TEMP_DATE .
   ENDIF .
ENDLOOP.
LOOP AT SOURCE_PACKAGE_1 ASSIGNING <SOURCE_FIELDS_1>  .
   IF <SOURCE_FIELDS_1>-DATEFROM GT   <SOURCE_FIELDS_1>-DATETO .
     TEMP_DATE = <SOURCE_FIELDS_1>-DATETO .
    <SOURCE_FIELDS_1>-DATETO = <SOURCE_FIELDS_1>-DATEFROM .
    <SOURCE_FIELDS_1>-DATEFROM = TEMP_DATE .
    CLEAR TEMP_DATE .
   ENDIF .
ENDLOOP.

Former Member
0 Kudos

When i click on Start routine, there is a window like this, do i need to select any source fields for Start routine?

anindya_bose
Active Contributor
0 Kudos

The problem is , I am not able to reproduce your scenario .

I have no other suggestion apart from what the error message is suggesting.

Delete all other routines I provided, keep only SAP standard one ( Uncomment that )

Open the Transformation ---> Source Segments---->Intervals  --Check if the mapping is matching with the screenshot.  If this does not solve , please raise a message with SAP.

Regards

Anindya

Former Member
0 Kudos

Thanks Anindya,

I have the same mapping as yours in my transformation. The problem is how to know which "from" and "to" value i have to swap with the start routine. I dont know whether its datefrom and dateto  or leaffrom and leafto. Do you know how to check it?

Another question: do we need to select anysource fields for start routine as the picture i attacked?

And it would be very nice if you please load the same datasouce in your system and you may have the same problem as i have. If you can do that i will thanks alot

Last thingthat i want to say is that, i will assign point to you even i still looking for correct code. I want to thank you many time for help

anindya_bose
Active Contributor
0 Kudos

After the start routine put a statement

" BREAK-POINT . "

Run  the DTP in Dialog Mode for Debugging ( Execute Tab )  .  It will stop at the break point .  Double click on any of the source package , like source_package_5.  You would see the content .

As per your error message, Node Number 314 has problem.  Please check the same in PSA or Debugging .

You can also modify the routine I provided to be used for SOURCE_PACKAGE_5 . Something like below


DATA TEMP  TYPE C LENGTH 52.

LOOP AT SOURCE_PACKAGE_5 ASSIGNING <SOURCE_FIELDS_5>  .

  IF <SOURCE_FIELDS_5>-LEAFFROM GT   <SOURCE_FIELDS_5>-LEAFTO .

    TEMP = <SOURCE_FIELDS_5>-LEAFTO .

   <SOURCE_FIELDS_5>-LEAFTO = <SOURCE_FIELDS_5>-LEAFFROM .

   <SOURCE_FIELDS_5>-LEAFFROM = TEMP .

   CLEAR TEMP .

  ENDIF .

ENDLOOP..

If we can see what is causing problem, it would be easier to provide a solution, but in this case, I cannot see which record is creating problem.

Regards

Anindya