声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将追究法律责任!原文链接:http://www.cnblogs.com/jiangzhengjun/p/4293704.html
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

End Routine的更多相关文章

  1. What is the difference between routine , method , procedure , function ? please explain it with example?

    a method is named and attached to an object. so, for example, a method is like a function but is con ...

  2. Routine Problem(数学)

     Routine Problem time limit per test 1 second memory limit per test 256 megabytes input standard inp ...

  3. ABAP中Conversion Routine示例

          在SAP的Domain定义中,Output Length下面有个Convers. routine的标识,这是SAP用来进行输入输出转换的.我们知道,屏幕上的I/O字段都是字符串形式的,而数 ...

  4. 用完成例程(Completion Routine)实现的重叠I/O模型

    /// 用完成例程(Completion Routine)实现的重叠I/O模型 /// 异步IO模型 /// 用完成例程来实现重叠I/O比用事件通知简单得多.在这个模型中,主线程只用不停的接受连接 / ...

  5. mysql存储过程出现OUT or INOUT argument 10 for routine

    OUT or INOUT argument 10 for routine * is not a variable or NEW pseudo-variable 我查网上很多出现在call的时候没有添加 ...

  6. mysql存储过程 OUT or INOUT argument 3 for routine

    mysql存储过程出现: OUT or INOUT argument 3 for routine gotask.UserLogin is not a variable or NEW pseudo-va ...

  7. 十字链表 Codeforces Round #367 E Working routine

    // 十字链表 Codeforces Round #367 E Working routine // 题意:给你一个矩阵,q次询问,每次交换两个子矩阵,问最后的矩阵 // 思路:暴力肯定不行.我们可以 ...

  8. SAP BW 例程(Routine)【开始例程、关键值或特性的例程、结束例程】

    定义 可以使用例程定义关键值或特性的复杂的转换规则. 例程是本地 ABAP 类,它们包括预定义的定义和实施范围.进站和出站参数的 TYPES及方法签名都存储在定义范围中.实际例程创建于实施范围中.使用 ...

  9. mysql create routine 权限的一些说明

    1.如果用户有create routine 权限那么他就可以创建procedure | function . 2.如果用户创建了procedure | function 那么mysql 会自动赋予它对 ...

随机推荐

  1. Android SDK路径不能含有空格

    错误, android sdk location shoud not contain whitespace,as this can cause problems with thte ndk tools

  2. Nginx配置proxy_pass转发的/路径问题

    Nginx配置proxy_pass转发的/路径问题 在nginx中配置proxy_pass时,如果是按照^~匹配路径时,要注意proxy_pass后的url最后的/,当加上了/,相当于是绝对根路径,则 ...

  3. c语言中的指针问题

    “*”符号的作用在C语言中有两种: 1.声明该变量是指针,例如:int * p;//表示声明一个int类型的指针,变量名为p 2.在指针运算时,表示取这个地址上的内容,例如  temp = *p;// ...

  4. 基于swoole的网页一对一实时聊天

    需求分析 网站上实现一对一即时沟通,能查看聊天记录以及离线留言,新消息提醒. 核心技术 html5的websocket,php的swoole扩展http://wiki.swoole.com/ 数据表 ...

  5. XE系列资源文件的奇怪问题

    这是一个关于资源文件的故事.......-_- 今天写一个功能测试Demo, 为了省事直接在工程文件里Resources And Images里添加了几个图片, 类型都是默认的RCDATA 然后直接就 ...

  6. PHP 多维数组 Key Value的使用

    <?php $user["60"] = array("id" => "60", "num" => &q ...

  7. JMeter学习-020-JMeter 监听器之【聚合报告】错误率、吞吐量、传输速率实例计算

    上文 对聚合报告的结果字段进行了概要的讲述释义,同时对吞吐量.传输速率.分位数等进行了详细的阐述,此文针对上文中描述的吞吐量及传输速率的计算进行详细的实例计算演示. 多不闲述,直入主题! 实际操作步骤 ...

  8. php的spl_autoload_register函数的一点个人见解

    这是一篇对spl_autoload_register()函数的个人简单介绍,有需要的同学可以参考,主要是讨论spl_autoload_register()函数所注册的函数的参数的个人一点迷惑. 废话不 ...

  9. iOS:给Git仓库上传代码时,超过100M会被拒绝(例如github和oschina)

    处理GitHub不允许上传大于100M文件问题?本人也遇到这个坑... 来自转载,原文链接:http://www.cnblogs.com/qmmq/p/4604862.html 1.报错: 自己的项目 ...

  10. SQL Nexus

    在前面的SQLdiag系列中有提到SQLNexus,当时我们用SQLNexus查看了Perfmon Summary(性能计数器).ReadTrace Reports(跟踪文件)两项报表.SQLNexu ...