Vous êtes sur la page 1sur 4

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_TG_1,
* Field: SID.
SID TYPE RSSID,
* Field: DATAPAKID.
DATAPAKID TYPE RSDATAPID,
* Field: RECORD.
RECORD TYPE RSARECORD,
* InfoObject: P_OBJECT Object.
/BIC/P_OBJECT TYPE /BIC/OIP_OBJECT,
* InfoObject: P_IN_CHAR Internal char..
/BIC/P_IN_CHAR TYPE /BIC/OIP_IN_CHAR,
* InfoObject: P_COUNTER Counter.
/BIC/P_COUNTER TYPE /BIC/OIP_COUNTER,
* InfoObject: P_OBJ_CLS Object/Class.
/BIC/P_OBJ_CLS TYPE /BIC/OIP_OBJ_CLS,
* InfoObject: 0CLASS_TYPE Class type.
CLASS_TYPE TYPE /BI0/OICLASS_TYPE,
* InfoObject: P_INT_CTR Int. counter.
/BIC/P_INT_CTR TYPE /BIC/OIP_INT_CTR,
* InfoObject: 0RECORDMODE BW Delta Process: Update Mode.
RECORDMODE TYPE RODMUPDMOD,
* InfoObject: P_CH_VAL Char. Value.
/BIC/P_CH_VAL TYPE /BIC/OIP_CH_VAL,
* InfoObject: PMCOO Multiple Country of Origin.
/BIC/PMCOO TYPE /BIC/OIPMCOO,
* InfoObject: 0MATERIAL Material.
MATERIAL TYPE /BI0/OIMATERIAL,
* InfoObject: 0PLANT Plant.
PLANT TYPE /BI0/OIPLANT,
* InfoObject: PMCOO_CV MCOO Characteristic Value Description.
/BIC/PMCOO_CV TYPE /BIC/OIPMCOO_CV,
* InfoObject: 0AC_DOCTEXT Document Text.
AC_DOCTEXT TYPE /BI0/OIAC_DOCTEXT,
END OF _ty_s_TG_1.
TYPES:
_ty_t_TG_1 TYPE STANDARD TABLE OF _ty_s_TG_1
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
new_record__end_routine
IMPORTING
source_segid type rstran_segid
source_record type sytabix
EXPORTING
record_new type sytabix.
METHODS
end_routine
IMPORTING
request type rsrequest
datapackid type rsdatapid
segid type rsbk_segid
EXPORTING
monitor type rstr_ty_t_monitors
CHANGING
RESULT_PACKAGE type _ty_t_TG_1
RAISING
cx_rsrout_abort
cx_rsbk_errorcount.
METHODS
inverse_end_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 end_routine
*----------------------------------------------------------------------*
* Calculation of result package via end routine.
* Note: Update of target fields depends on rule assignment in
* transformation editor. Only fields that have a rule assigned,
* are updated to the data target.
*----------------------------------------------------------------------*
* <-> result package
*----------------------------------------------------------------------*
METHOD end_routine.
*=== Segments ===
FIELD-SYMBOLS:
<RESULT_FIELDS> TYPE _ty_s_TG_1.
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.
TYPES: BEGIN OF st_mcoo,
MATERIAL TYPE /BI0/OIMATERIAL,
PLANT TYPE /BI0/OIPLANT,
MCOO TYPE /BIC/OIPMCOO,
PMCOO_CV TYPE /BIC/OIPMCOO_CV,
END OF st_mcoo.
DATA: wa_Data TYPE _ty_s_tg_1,
wa_mcoo TYPE st_mcoo,
it_mcoo TYPE TABLE OF st_mcoo,
mcoo TYPE char30,
material TYPE /BI0/OIMATERIAL,
flag TYPE c.
Data : l-tabix type sy-tabix
SORT RESULT_PACKAGE by material.
Refresh : it_mcoo.
SELECT MATERIAL
PLANT
/BIC/PMCOO
/BIC/PMCOO_CV
FROM /BIC/APPU_O0600
INTO TABLE it_mcoo for all entries in RESULT_PACKAGE
WHERE material = wa_data-material.
clear : l_tabix
LOOP AT RESULT_PACKAGE INTO wa_Data.
l_tabix = sy-tabix.
Read table it_mcoo into wa_mcoo with key material = wa_Data-material plant = wa_
data-plant
*****LOOP AT it_mcoo INTO wa_mcoo.
IF l_tabix = 1.
mcoo = wa_mcoo-mcoo.
ELSE.
CONCATENATE mcoo wa_mcoo-mcoo INTO mcoo SEPARATED BY ','.
ENDIF.
CLEAR: wa_mcoo.
*****ENDLOOP.
*IF wa_data-/BIC/GMULTICOO IS INITIAL.
CONDENSE mcoo NO-GAPS.
wa_data-/BIC/GMULTICOO = mcoo.
*ENDIF.
MODIFY RESULT_PACKAGE FROM wa_data index l-tabix.
CLEAR: wa_data.
ENDLOOP.
*$*$ end of routine - insert your code only before this line *-*
ENDMETHOD. "end_routine
*----------------------------------------------------------------------*
* Inverse method inverse_end_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_end_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_end_routine
METHOD new_record__end_routine.
***** IMPLEMENTATION is only visible in generated program *****
ENDMETHOD.
ENDCLASS. "routine IMPLEMENTATION