TXT

ZCH_CRM_SPRATE

By Elaine Ramos,2014-04-11 11:57
20 views 0
ZCH_CRM_SPRATE

REPORT zch_crm_sprate.

    TYPE-POOLS: slis.

    TYPES:

    BEGIN OF line_partner_order_bjmx,

     service_org TYPE zchcrm1010-service_org, "?Ö??Ë??úÂë

     service_org_name TYPE hrp1000-stext, "?Ö??Ë?Ãû?Æ

     service_org_rep TYPE zchcrm1010-service_org_rep, "?ìÊÂ??

     service_org_rep_name TYPE hrp1000-stext, "?ìÊÂ??Ãû?Æ

     sales_org TYPE zchcrm1010-sales_org, "ÏúÊÛ×éÖ?

     sales_org_name TYPE hrp1000-stext,"ÏúÊÛ×éÖ?Ãû?Æ

     season_shipqty TYPE i,"ÔÂ?È???þ???õ??µ?Êý

     current_shipqty TYPE i,"24Ð?Ê????þ???õ??µ?Êý

     apply TYPE zchcrm1011-idate_01,"ÉêÇëÈÕÆÚ

     shipment TYPE zchcrm1011-idate_03,"???õÈÕÆÚ

     rate(15) TYPE c,"???þÉêÇë24Ð?Ê???Ó?ÂÊ

     color(4),

    END OF line_partner_order_bjmx.

    DATA :lt_season TYPE TABLE OF line_partner_order_bjmx WITH HEADER LINE,

     lt_current TYPE TABLE OF line_partner_order_bjmx WITH HEADER LINE,

     wa_alv_field TYPE slis_fieldcat_alv,

     wa_alv_fieldcat TYPE slis_t_fieldcat_alv,

     wa_layout TYPE slis_layout_alv.

DATA: tzone LIKE ttzz-tzone,tim TYPE t,first_dt TYPE

    zchcrm1011-idate_01,last_dt TYPE zchcrm1011-idate_03.

PARAMETERS: cft_dt TYPE dats OBLIGATORY,

     clast_dt TYPE dats OBLIGATORY.

START-OF-SELECTION.

     tim = '000000'.

     CALL FUNCTION 'TZ_SYSTEM_GET_TZONE'

     IMPORTING

     tzone_system = tzone.

     CONVERT DATE cft_dt TIME tim INTO TIME STAMP first_dt TIME ZONE tzone.

     tim = '235959'.

     CONVERT DATE clast_dt TIME tim INTO TIME STAMP last_dt TIME ZONE tzone. *&------------Ñ?È?ÒÑ??ËÍÓëÒÑÈ?ÈÏÊÕ?õ???þÊýÁ?-------------------------

     SELECT

     t10~service_org

     thr1~stext AS service_org_name

     t10~service_org_rep

     thr2~stext AS service_org_rep_name

     t10~sales_org

     thr3~stext AS sales_org_name

     t11~idate_01 AS apply

     t11~idate_03 AS shipment

     INTO CORRESPONDING FIELDS OF TABLE lt_season

     FROM zchcrm1010 AS t10

     LEFT JOIN hrp1000 AS thr1 ON t10~service_org = thr1~otjid AND thr1~endda = '99991231'

     LEFT JOIN hrp1000 AS thr2 ON t10~service_org_rep = thr2~otjid AND thr2~endda = '99991231'

     LEFT JOIN hrp1000 AS thr3 ON t10~sales_org = thr3~otjid AND thr3~endda = '99991231'

     JOIN zchcrm1011 AS t11 ON t10~guid = t11~header

     WHERE t11~itm_type IN ('ZRV1','ZRV2')

     AND

     ( ( t11~istat_user = 'HS70' AND t11~idate_04 BETWEEN first_dt AND last_dt )

     OR

     ( t11~istat_user = 'HS60' AND t11~idate_03 BETWEEN first_dt AND last_dt ) )

ORDER BY

    thr1~stext

    thr2~stext

    thr3~stext.

     DATA :count1 TYPE i,count2 TYPE i,count3 TYPE i,count4 TYPE i,count5 TYPE i,count6 TYPE i,count7 TYPE i,count8 TYPE i,

     st LIKE tzonref-tstamps,et LIKE tzonref-tstamps,

     h LIKE sretgstruc-hour1,h1 TYPE f,r TYPE p DECIMALS 2.

     LOOP AT lt_season.

     st = lt_season-shipment.

     et = lt_season-apply.

     count1 = count1 + 1.

     count3 = count3 + 1.

     count5 = count5 + 1.

     count7 = count7 + 1.

     IF st IS NOT INITIAL AND et IS NOT INITIAL AND st > et.

     CALL FUNCTION 'SRET_TIME_DIFF_GET'

     EXPORTING

     utc_start = et

     utc_end = st

     IMPORTING

     hours = h.

     h1 = h.

     IF h1 <= 24.

     count2 = count2 + 1.

     count4 = count4 + 1.

     count6 = count6 + 1.

     count8 = count8 + 1.

     ENDIF.

     ENDIF.

     AT END OF sales_org_name.

     lt_current-sales_org_name = lt_season-sales_org_name.

     lt_current-service_org_rep_name = lt_season-service_org_rep_name.

     lt_current-service_org_name = lt_season-service_org_name.

     lt_current-season_shipqty = count1.

     lt_current-current_shipqty = count2.

     r = count2 / count1 * 100.

     lt_current-rate = r.

     CONCATENATE lt_current-rate '%' INTO lt_current-rate.

     lt_current-color =''.

     APPEND lt_current.

     CLEAR count1.

     CLEAR count2.

     ENDAT.

     AT END OF service_org_rep_name.

     lt_current-sales_org_name = 'Ð??Ç'.

     lt_current-service_org_rep_name = lt_season-service_org_rep_name.

     lt_current-service_org_name = lt_season-service_org_name.

     lt_current-season_shipqty = count3.

     lt_current-current_shipqty = count4.

     r = count4 / count3 * 100.

     lt_current-rate = r.

     CONCATENATE lt_current-rate '%' INTO lt_current-rate.

     lt_current-color ='C211'.

     APPEND lt_current.

     CLEAR count3.

     CLEAR count4.

     ENDAT.

     AT END OF service_org_name.

     lt_current-service_org_name = lt_season-service_org_name.

     lt_current-sales_org_name = ''.

     lt_current-service_org_rep_name = 'Ð??Ç'.

     lt_current-season_shipqty = count5.

     lt_current-current_shipqty = count6.

     r = count6 / count5 * 100.

     lt_current-rate = r.

     CONCATENATE lt_current-rate '%' INTO lt_current-rate.

     lt_current-color ='C110'.

     APPEND lt_current.

     CLEAR count5.

     CLEAR count6.

     ENDAT.

     AT LAST.

     lt_current-service_org_name = '×Ü?Æ'.

     lt_current-sales_org_name = ''.

     lt_current-service_org_rep_name = ''.

     lt_current-season_shipqty = count7.

     lt_current-current_shipqty = count8.

     r = count8 / count7 * 100.

     lt_current-rate = r.

     CONCATENATE lt_current-rate '%' INTO lt_current-rate.

     lt_current-color ='C310'.

     APPEND lt_current.

     ENDAT.

     ENDLOOP.

*&------------------------?ñÊ???------------------------

     wa_alv_field-col_pos = 1.

     wa_alv_field-fieldname = 'SERVICE_ORG_NAME'."

     wa_alv_field-seltext_m = '?Ö??Ë?'.

     APPEND wa_alv_field TO wa_alv_fieldcat.

     wa_alv_field-col_pos = 2.

     wa_alv_field-fieldname = 'SERVICE_ORG_REP_NAME'.

     wa_alv_field-seltext_m = '?ìÊÂ??'.

     APPEND wa_alv_field TO wa_alv_fieldcat.

     wa_alv_field-col_pos = 3.

     wa_alv_field-fieldname = 'SALES_ORG_NAME'.

     wa_alv_field-seltext_m = 'ÏúÊÛ×éÖ?'.

     APPEND wa_alv_field TO wa_alv_fieldcat.

     wa_alv_field-col_pos = 4.

     wa_alv_field-fieldname = 'SEASON_SHIPQTY '.

     wa_alv_field-seltext_m = 'ÔÂ?È???þ???õ??µ?Êý'.

     APPEND wa_alv_field TO wa_alv_fieldcat.

     wa_alv_field-col_pos = 5.

     wa_alv_field-fieldname = 'CURRENT_SHIPQTY'.

     wa_alv_field-seltext_m = '??ÆÚ24Ð?Ê????þ???õ??µ?Êý'.

     APPEND wa_alv_field TO wa_alv_fieldcat.

     wa_alv_field-col_pos = 6.

     wa_alv_field-fieldname = 'RATE'.

     wa_alv_field-seltext_m = '??ÆÚ???þÉêÇë24Ð?Ê???Ó?ÂÊ'.

     APPEND wa_alv_field TO wa_alv_fieldcat.

     wa_layout-info_fieldname = 'COLOR'.

     wa_layout-colwidth_optimize = 'X'.

     CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

     EXPORTING

     it_fieldcat = wa_alv_fieldcat

     is_layout = wa_layout

     TABLES

     t_outtab = lt_current.

Report this document

For any questions or suggestions please email
cust-service@docsford.com