End 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_TG_1,
*      Field: RECORD.
        RECORD           TYPE RSARECORD,
*      InfoObject: 0BILL_NUM Billing document.
        BILL_NUM           TYPE /BI0/OIBILL_NUM,
*      InfoObject: 0BILL_ITEM Billing item.
        BILL_ITEM           TYPE /BI0/OIBILL_ITEM,
*      InfoObject: 0RECORDMODE BW Delta Process: Update Mode.
        RECORDMODE           TYPE RODMUPDMOD,
*      InfoObject: 0BILL_TYPE Billing Type.
        BILL_TYPE           TYPE /BI0/OIBILL_TYPE,
*      InfoObject: 0BILL_DATE Date for invoice/billing index and printou
*t.

        BILL_DATE           TYPE /BI0/OIBILL_DATE,
*      InfoObject: ZJBUKRS 公司.
        /BIC/ZJBUKRS           TYPE /BIC/OIZJBUKRS,
*      InfoObject: ZJKUNNR 客户.
        /BIC/ZJKUNNR           TYPE /BIC/OIZJKUNNR,
*      InfoObject: 0SOLD_TO Sold-to party.
        SOLD_TO           TYPE /BI0/OISOLD_TO,
*      InfoObject: 0SHIP_TO Ship-To Party.
        SHIP_TO           TYPE /BI0/OISHIP_TO,
*      InfoObject: 0PAYER Payer.
        PAYER           TYPE /BI0/OIPAYER,
*      InfoObject: 0BILLTOPRTY Bill-to party.
        BILLTOPRTY           TYPE /BI0/OIBILLTOPRTY,
*      InfoObject: 0BILL_CAT Billing category.
        BILL_CAT           TYPE /BI0/OIBILL_CAT,
*      InfoObject: 0SALES_OFF Sales Office.
        SALES_OFF           TYPE /BI0/OISALES_OFF,
*      InfoObject: 0SALES_GRP Sales group.
        SALES_GRP           TYPE /BI0/OISALES_GRP,
*      InfoObject: 0SALESORG Sales Organization.
        SALESORG           TYPE /BI0/OISALESORG,
*      InfoObject: 0DISTR_CHAN Distribution Channel.
        DISTR_CHAN           TYPE /BI0/OIDISTR_CHAN,
*      InfoObject: 0INV_QTY Billing Quantity in Sales Units.
        INV_QTY           TYPE /BI0/OIINV_QTY,
*      InfoObject: 0MATL_GROUP Material group.
        MATL_GROUP           TYPE /BI0/OIMATL_GROUP,
*      InfoObject: ZJMATNR 物料.
        /BIC/ZJMATNR           TYPE /BIC/OIZJMATNR,
*      InfoObject: 0NETVAL_INV Net Value of Billing Item in Document Cur
*rency.

        NETVAL_INV           TYPE /BI0/OINETVAL_INV,
*      InfoObject: 0SALES_UNIT Sales unit.
        SALES_UNIT           TYPE /BI0/OISALES_UNIT,
*      InfoObject: 0DOC_CURRCY Document currency.
        DOC_CURRCY           TYPE /BI0/OIDOC_CURRCY,
*      InfoObject: 0ITEM_CATEG Sales document item category.
        ITEM_CATEG           TYPE /BI0/OIITEM_CATEG,
*      InfoObject: ZJWERKS 工厂.
        /BIC/ZJWERKS           TYPE /BIC/OIZJWERKS,
*      InfoObject: 0DOC_NUMBER Sales document.
        DOC_NUMBER           TYPE /BI0/OIDOC_NUMBER,
*      InfoObject: 0S_ORD_ITEM Sales document item.
        S_ORD_ITEM           TYPE /BI0/OIS_ORD_ITEM,
*      InfoObject: 0DOC_TYPE Sales document type.
        DOC_TYPE           TYPE /BI0/OIDOC_TYPE,
*      InfoObject: 0DOC_CATEG Sales Document Category.
        DOC_CATEG           TYPE /BI0/OIDOC_CATEG,
*      InfoObject: 0FISCVARNT Fiscal year variant.
        FISCVARNT           TYPE /BI0/OIFISCVARNT,
*      InfoObject: 0CALDAY Calendar Day.
        CALDAY           TYPE /BI0/OICALDAY,
*      InfoObject: 0CALWEEK Calendar Year/Week.
        CALWEEK           TYPE /BI0/OICALWEEK,
*      InfoObject: 0CALMONTH Calendar Year/Month.
        CALMONTH           TYPE /BI0/OICALMONTH,
*      InfoObject: 0CALMONTH2 Calendar month.
        CALMONTH2           TYPE /BI0/OICALMONTH2,
*      InfoObject: 0CALQUARTER Calendar year/quarter.
        CALQUARTER           TYPE /BI0/OICALQUARTER,
*      InfoObject: 0CALQUART1 Quarter.
        CALQUART1           TYPE /BI0/OICALQUART1,
*      InfoObject: 0CALYEAR Calendar Year.
        CALYEAR           TYPE /BI0/OICALYEAR,
*      InfoObject: 0FISCPER Fiscal year / period.
        FISCPER           TYPE /BI0/OIFISCPER,
*      InfoObject: 0FISCPER3 Posting period.
        FISCPER3           TYPE /BI0/OIFISCPER3,
*      InfoObject: 0FISCYEAR Fiscal year.
        FISCYEAR           TYPE /BI0/OIFISCYEAR,
      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
        EXPORTING
          monitor                  type rstr_ty_t_monitors
        CHANGING
          RESULT_PACKAGE              type _ty_t_TG_1
        RAISING
          cx_rsrout_abort.
    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.

DATA:t_docinfo TYPE TABLE OF _ty_s_TG_1.
DATA:wa_docinfo TYPE  _ty_s_TG_1.

**=======调试使用
Data: t_zjzjtest TYPE TABLE OF zjzjtest .
DATA wa_zjzjtest type zjzjtest.
**=======end

SELECT DOC_NUMBER s_ord_item doc_type doc_categ
  INTO CORRESPONDING FIELDS OF TABLE
t_docinfo
**这里最好从PSA 物理表里读取数据,如果是要从DSO 激活表里读取,还得要注意先激活后再读取
  FROM /bic/azjsd_d2100 FOR ALL ENTRIES IN RESULT_PACKAGE
  WHERE doc_number = RESULT_PACKAGE-doc_number and s_ord_item =
  RESULT_PACKAGE-s_ord_item.

sort t_docinfo by DOC_NUMBER s_ord_item ASCENDING.

LOOP AT RESULT_PACKAGE ASSIGNING <RESULT_FIELDS> .
READ TABLE t_docinfo WITH key DOC_NUMBER = <RESULT_FIELDS>-DOC_NUMBER
     s_ord_item = <RESULT_FIELDS>-S_ORD_ITEM BINARY SEARCH INTO
     wa_docinfo.
<RESULT_FIELDS>-doc_type = wa_docinfo-doc_type.
<RESULT_FIELDS>-doc_categ = wa_docinfo-doc_categ.
**=======调试使用
CONCATENATE wa_docinfo-DOC_NUMBER wa_docinfo-s_ord_item
    wa_docinfo-doc_type wa_docinfo-doc_categ
    INTO wa_zjzjtest-f1 SEPARATED BY ` `.
APPEND wa_zjzjtest to  t_zjzjtest.
**=======end
ENDLOOP.

**=======调试使用
DELETE FROM zjzjtest.
MODIFY zjzjtest from TABLE t_zjzjtest.
**=======end

*$*$ end of routine - insert your code only before this line         *-*

  ENDMETHOD.                   
"end_routine
*----------------------------------------------------------------------*
*       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.
*
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*

  METHOD inverse_end_routine.

*$*$ 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
posted @ 2015-02-16 09:43  江正军  阅读(1713)  评论(0编辑  收藏  举报