cancel
Showing results for 
Search instead for 
Did you mean: 

BW-IP: Where to edit C_TH_DATA for Planning Function Type built on CL_RSPLFC_COPY

sagar_sheokand
Participant
0 Kudos

Hi,

I need to write a custom planning function type that would copy data from one ADSO to another. Both the ADSOs are cube type. I need reference data as well.

Now, before copying some calculations have to be done on one of the key figures.

I know, I need to change data in C_TH_DATA in IF_RSPLFA_SRVTYPE_IMP_EXEC_REF~EXECUTE method. I'm able to the calculations and change C_TH_DATA but am unsure where in code do I actually update this new data.

There are several places where C_TH_DATA is used by SAP. Where should I update this so that this new data is copied to my target ADSO?

A code snippet showing above or below which line I should do my editing would be very helpful.

Thanks

Sagar

Accepted Solutions (1)

Accepted Solutions (1)

sagar_sheokand
Participant
0 Kudos

Hi Gregor,

Thanks for the link. It does have a lot useful stuff in there. But I couldn't find my exact requirement over there. Maybe I didn't look close enough. In any case, I found the right place to edit C_TH_DATA myself.

So just in case anyone else needs and is running short on time.

There is a loop on I_TH_REF_DATA table and in that loop, at the very end there is a COLLECT statement. Custom code should go right before this COLLECT statement. I'm pasting the whole LOOP here; just scroll to the end to find the place to edit C_TH_DATA table.

Edit: Going to accept my own answer. Feel that relates directly to the question.

Thanks,

Sagar

  LOOP AT i_th_ref_data INTO <s_data_wa2>.
    MOVE-CORRESPONDING <s_data_wa2> TO <s_block_line>.
    LOOP AT p_ts_rule INTO l_s_rule WHERE rulepos = l_rulepos.
      <s_data_wa> = <s_data_wa2>.
      IF abap_true = cl_rsplfu_work_area=>check_conditions( i_ts_sel = l_s_rule-t_from_sel
                                                            i_s_data = <s_data_wa> ).


        l_s_rule-r_work_area->complement_clear( CHANGING c_s_data = <s_data_wa> ).


        IF l_s_rule-to_sel_is_single = abap_false.
*         .... no restriction to single values => create allowed combinations
          IF l_set_cr_controller = rs_c_false.
            l_set_cr_controller = rs_c_true.
            cl_rsplfr_controller=>p_r_cr_controller->set_sub_structure_x( i_x_source = p_x_source_create
                                                                          i_x_target = p_x_target_create ).
          ENDIF.




          p_r_object_creation->create( EXPORTING i_r_cr_controller = cl_rsplfr_controller=>p_r_cr_controller
                                                                      i_s_block_line = <s_block_line>
                                                                      i_tsx_seldr = l_s_rule-tsx_seldr_repr_of_to
                                                                      i_r_msg = l_r_msg
                                                            IMPORTING e_th_chas = <th_chas> ).
          IF abap_true = l_r_msg->contains_error( ).
* Gleiches Verhalten wie beim Fall mit nur einem Zielwert. Es wird nichts erzeugt
            CLEAR <th_chas>.
*            me->msg_with_context( EXPORTING i_r_msg_src = l_r_msg
*                                            i_s_rule = l_s_rule
*                                  CHANGING  c_r_msg_trgt = l_r_i_msg ).
*            RETURN.
          ENDIF.
          LOOP AT <th_chas> ASSIGNING <s_combi>.
            MOVE-CORRESPONDING <s_combi> TO <s_data_wa>.
            COLLECT <s_data_wa> INTO <th_data>.
          ENDLOOP.
        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_is_valid = l_is_valid ).
          IF l_is_valid = abap_true.
*         combination valid -> store kyfs to receiver.
            MOVE-CORRESPONDING <s_chas> TO <s_data_wa>.
* WRITE YOUR CUSTOM LOGIC HERE. Edit <s_data_wa> that gets COLLECTed in next line. Alternatively, you can comment the next line. Do your calculations and yourself write to C_TH_DATA table.
            COLLECT <s_data_wa> INTO c_th_data.
          ENDIF.
        ENDIF.
      ENDIF.
    ENDLOOP.
  ENDLOOP.

Answers (1)

Answers (1)

0 Kudos

Hi Sagar,

you can check the list of how-to papers for examples:

https://blogs.sap.com/2012/02/28/sap-how-to-guides-for-analysis-and-planning/

In addition you have the option to debug the standard implementation CL_RSPLFC_COPY and to learn how things can be done. Another option is to write a FOX that does the job.

Check the interface documentation

IF_RSPLFA_SRVTYPE_IMP_CHECK

IF_RSPLFA_SRVTYPE_IMP_EXEC_REF

IF_RSPLFA_SRVTYPE_TREX_EXEC_R

in transaction SE24. The logic has to be implemented in method IF_RSPLFA_SRVTYPE_IMP_EXEC_REF~EXECUTE as you mentioned already.

Regards,

Gregor