End Routine D6D
End Routine D6D
*---------------------------------------------------------------------*
* 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.
*$*$ 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
cx_dynamic_check
cx_rs_failed.
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
*--------------Constants Declaration-----------*
CONSTANTS: lc_a TYPE c LENGTH 1 VALUE 'A',
lc_rg TYPE /bic/oizpar_fun VALUE 'RG',
lc_zpos_up TYPE tvarvc-name VALUE 'ZPOS_UP'.
*--------Types Declaration---------------------*
TYPES: BEGIN OF ty_plant,
plant TYPE /bi0/oiplant,
rt_custpl TYPE /bi0/oirt_custpl,
END OF ty_plant.
* EAN Code 13
TYPES: BEGIN OF ty_matnr,
zeanupc TYPE /bic/oizeanupc,
END OF ty_matnr.
* EAN Code 14
TYPES: BEGIN OF ty_skupa,
zean14 TYPE /bic/oizzean14,
END OF ty_skupa.
* Promotion
TYPES: BEGIN OF ty_promo_sel,
rt_promo TYPE /bi0/oirt_promo,
rt_mat_prm TYPE /bi0/oirt_mat_prm,
END OF ty_promo_sel.
* Promotion, Material
TYPES: BEGIN OF ty_promo,
rt_promo TYPE /bi0/oirt_promo,
rt_mat_prm TYPE /bi0/oimaterial,
rt_promoth TYPE /bi0/oirt_promoth,
END OF ty_promo.
* Promotion
TYPES: BEGIN OF ty_promo_nat,
material TYPE /bi0/oimaterial,
/bic/zzsitegrp TYPE /bic/oizzsitegrp,
/bic/zpromovdb TYPE /bic/oizpromovdb,
/bic/zpromovdi TYPE /bic/oizpromovdi,
rt_promo TYPE /bi0/oirt_promo,
/bic/zsite TYPE /bic/oizsite,
END OF ty_promo_nat.
* Material Information
TYPES: BEGIN OF ty_pmaterial,
material TYPE /bi0/oimaterial,
CREATEDON TYPE /BI0/OICREATEDON,
" RFC 2000621 changes
MATL_GROUP TYPE /BI0/OIMATL_GROUP,
rt_confmat TYPE /bi0/oirt_confmat,
vendor TYPE /bi0/oivendor,
/bic/zeanupc TYPE /bi0/pmaterial-/bic/zeanupc,
/bic/zmerc_c1 TYPE /bic/oizmerc_c1,
/bic/zmerc_c2 TYPE /bic/oizmerc_c2,
/bic/zmerc_c3 TYPE /bic/oizmerc_c3,
/bic/zmerc_c4 TYPE /bic/oizmerc_c4,
/BIC/ZZBRAND TYPE /BIC/OIZZBRAND,
/bic/zmean_ean TYPE /bic/oizmean_ean,
/bic/zme TYPE /bic/oizme,
* gross_wt TYPE /bi0/pmaterial-gross_wt,
* unit_of_wt TYPE /bi0/pmaterial-unit_of_wt,
* volume TYPE /bi0/pmaterial-volume,
* volumeunit TYPE /bi0/pmaterial-volumeunit,
base_uom TYPE /bi0/pmaterial-base_uom,
del_flag TYPE /bi0/pmaterial-del_flag,
objvers TYPE /bi0/pmaterial-objvers,
matl_cat TYPE /bi0/pmaterial-matl_cat,
END OF ty_pmaterial.
* Vendor MAterial
TYPES: BEGIN OF ty_vendmate,
/bic/zzean2 TYPE /bic/oizzean2,
vendor TYPE /bi0/oivendor,
END OF ty_vendmate.
* Customer
TYPES: BEGIN OF ty_pcustomer,
customer TYPE /bi0/oicustomer,
/bic/zlayvr TYPE /bic/oizlayvr,
END OF ty_pcustomer.
* Site Information
TYPES: BEGIN OF ty_zsite,
/bic/zsite TYPE /bic/oizsite,
distr_chan TYPE /bi0/oidistr_chan,
region TYPE /bi0/oiregion,
rt_custpl TYPE /bi0/oirt_custpl,
sales_dist TYPE /bi0/oisales_dist,
/bic/zzprova TYPE /bic/oizzprova,
/bic/zztotar TYPE /bic/oizztotar,
/bic/zztotsar TYPE /bic/oizztotsar,
/bic/zzsort2 TYPE /bic/oizzsort2,
/bic/zzsitegrp TYPE /bic/oizzsitegrp,
END OF ty_zsite.
* Payer
TYPES: BEGIN OF ty_payer,
customer TYPE /bi0/oicustomer,
END OF ty_payer.
* Material Group
TYPES: BEGIN OF ty_mc_sel,
matl_group TYPE /bi0/oimatl_group,
END OF ty_mc_sel.
* Material Hierarchy
TYPES: BEGIN OF ty_mc_hier,
matl_group TYPE /bi0/oimatl_group,
/bic/zmerc_c1 TYPE /bi0/pmatl_group-/bic/zmerc_c1,
/bic/zmerc_c2 TYPE /bi0/pmatl_group-/bic/zmerc_c2,
/bic/zmerc_c3 TYPE /bi0/pmatl_group-/bic/zmerc_c3,
/bic/zmerc_c4 TYPE /bi0/pmatl_group-/bic/zmerc_c4,
objvers TYPE /bi0/pmaterial-objvers,
END OF ty_mc_hier.
* Control File
TYPES: BEGIN OF ty_ctrl_file,
counter(6) TYPE n,
sep01(2) TYPE c,
cnt_pack(6) TYPE n,
sep02(2) TYPE c,
cnt_vk(6) TYPE n,
sep08(2) TYPE c,
request TYPE rsrequnr,
sep03(2) TYPE c,
zsite TYPE _ty_s_tg_1-/bic/zsite,
sep04(2) TYPE c,
calday TYPE _ty_s_tg_1-calday,
sep05(2) TYPE c,
eancount(6) TYPE n,
sep06(2) TYPE c,
date LIKE sy-datum,
sep07(2) TYPE c,
time LIKE sy-uzeit,
END OF ty_ctrl_file.
*--------WorkArea Declaration-------------------*
DATA: lwa_plant TYPE ty_plant,
lwa_matnr TYPE ty_matnr,
lwa_pmaterial TYPE ty_pmaterial,
lwa_pmaterial1 TYPE ty_pmaterial,
lwa_kupa TYPE ty_skupa,
lwa_pkupa TYPE ty_pkupa,
lwa_pcustomer TYPE ty_pcustomer,
lwa_zsite TYPE ty_zsite,
lwa_promo_sel TYPE ty_promo_sel,
lwa_promo TYPE ty_promo,
lwa_payer TYPE ty_payer,
lwa_promo_nat TYPE ty_promo_nat,
lwa_mc_sel TYPE ty_mc_sel,
lwa_mc_hier TYPE ty_mc_hier,
lwa_ctrl_file TYPE ty_ctrl_file,
lwa_payer_new TYPE ty_payer_new,
lwa_customer_new TYPE ty_customer_new,
* lwa_zasor_pc TYPE ty_zasor_pc, *** not in scope in Blu
lwa_count TYPE ty_ctrl_nr,
lwa_vendmate TYPE ty_vendmate,
lwa_count_ean TYPE ty_ctrl_nr,
lwa_tvarvc TYPE tvarvc,
lwa_sitegrp TYPE ty_sitegrp.
*---------Variable Declaration--------------------*
IF <result_fields>-/bic/zeanupc EQ space.
* Do Nothing
ELSE.
* Convert the Format
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = <result_fields>-/bic/zeanupc
IMPORTING
output = <result_fields>-/bic/zeanupc.
* Clear WorkArea
CLEAR: lwa_matnr,
lwa_kupa.
ENDLOOP.
SORT: lt_matnr,
lt_kupa.
IF sy-subrc EQ 0.
SORT lt_pmaterial BY /bic/zeanupc createdon.
ENDIF.
ENDIF.
* Select data from the material master for the material group
SELECT material createdon matl_group rt_confmat vendor
/bic/zeanupc
/bic/zmerc_c1 /bic/zmerc_c2 /bic/zmerc_c3 /bic/zmerc_c4
/bic/zzbrand /bic/zmean_ean objvers matl_cat base_uom
"GBD-419 base_uom added
FROM /bi0/pmaterial
INTO CORRESPONDING FIELDS OF TABLE lt_pmaterial1
FOR ALL ENTRIES IN lt_mc_sel
WHERE objvers = 'A' "Active version
AND matl_cat = '30'
AND matl_group EQ lt_mc_sel-matl_group.
IF sy-subrc EQ 0.
* SORT lt_pmaterial BY /bic/zzean2.
SORT lt_pmaterial1 BY matl_group.
ENDIF.
* ENDIF.
IF lv_lines_kupa GT 0.
SELECT material CREATEDON MATL_GROUP rt_confmat vendor
/bic/zeanupc /bic/zmerc_c1 /bic/zmerc_c2 /bic/zmerc_c3
/bic/zmerc_c4 /bic/ZZBRAND /bic/zzean14 /bic/zmean_ean
/bic/zme DEL_FLAG
base_uom
FROM /bi0/pmaterial
INTO CORRESPONDING FIELDS OF TABLE lt_pkupa
FOR ALL ENTRIES IN lt_kupa
WHERE objvers = 'A' "Active version
AND /bic/zzean14 EQ lt_kupa-zean14
AND /bic/zmean_ean = 'X'
"Added this condition as earlier we used to load data from ZZEAN2/3
AND del_flag <> 'X'.
IF sy-subrc EQ 0.
* SORT lt_pkupa BY /bic/zzean3.
SORT lt_pkupa DESCENDING BY /bic/zzean14 CREATEDON.
ENDIF.
ENDIF.
BREAK XKSHIRVI.
* No known EAN code and KUPA code-> Fill the material field with materia
* all 9's at the end
CONCATENATE <result_fields>-/bic/ZPIK_TR
'99999999999999'
INTO <result_fields>-material.
<result_fields>-rt_confmat = <result_fields>-material.
lwa_count-zsite = <result_fields>-/bic/zsite.
lwa_count-calday = <result_fields>-calday.
lwa_count-number = 1.
COLLECT lwa_count INTO lt_count_ean.
lv_count_ean = lv_count_ean + 1.
ENDIF.
ENDIF.
ENDIF.
ELSEIF sy-subrc NE 0.
lwa_count-number = 1.
COLLECT lwa_count INTO lt_count_ean.
lv_count_ean = lv_count_ean + 1.
ENDIF.
ELSE.
CONCATENATE <result_fields>-/bic/ZPIK_TR '99999999999999'
INTO <result_fields>-material.
<result_fields>-rt_confmat = <result_fields>-material.
IF sy-subrc EQ 0.
<result_fields>-/bic/zmerc_c1 = lwa_mc_hier-/bic/zmerc_c1.
<result_fields>-/bic/zmerc_c2 = lwa_mc_hier-/bic/zmerc_c2.
<result_fields>-/bic/zmerc_c3 = lwa_mc_hier-/bic/zmerc_c3.
<result_fields>-/bic/zmerc_c4 = lwa_mc_hier-/bic/zmerc_c4.
ENDIF.
ENDIF.
ENDIF.
CLEAR lv_zme.
CLEAR lwa_material.
ENDLOOP.
BREAK xkshirvi.
IF lv_rpa_tix NE <result_fields>-rpa_tix.
CLEAR lv_cnt.
lv_rpa_tix = <result_fields>-rpa_tix.
ELSE.
CLEAR lv_rpa_tix.
lv_rpa_tix = <result_fields>-rpa_tix.
ENDIF.
lv_cnt = lv_cnt + 1.
<result_fields>-/bic/zpos_cust = lv_cnt.
ENDLOOP.
*=====================End Of GBD-407===================================
*$*$ 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.
ENDMETHOD.
ENDCLASS. "routine IMPLEMENTATION