声明:原创作品,转载时请注明文章来自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. IOS第四天(1:图片的方法和缩小,遮罩层)

    @interface HMViewController () @property (nonatomic, strong) UIButton *cover; //阴影 @end @implementat ...

  2. 求解PDE的多重网格法(MG)

    多重网格法相对于普通的Jacobi迭代或者G-S迭代等能够得到和未知数的个数成线性的高效运行时间的主要原因在于:迭代初值的一步步接近真值和G_S方法的前面几步的快速收敛性. 先看一张图[1]: 这张图 ...

  3. php--数组函数array

    1.array_combine array_combine是一种函数,通过合并两个数组来创建一个新数组,其中的一个数组是键名,另一个数组的值为键值.如果其中一个数组为空,或者两个数组的元素个数不同,则 ...

  4. dom4j微信接口开发

    新建一个web项目,我用的是eclipse和tomcat7.0 ,外网环境用的nat123 先建立一个实体bean:TextMessage /** * xml基本对象 * @author xiaohu ...

  5. webservice的简单示例的实现步骤

    前段时间在webservice的问题上纠结了很长时间,本来想写在thinkphp的框架里面,可是怎么也实现不了,目前为止也仅仅是学会的没有框架的接口的开发. 在此资源共享一下步骤: 首先我创建的文件有 ...

  6. JQuery html API支持解析执行Javascript脚本功能实现-代码分析

    JQuery html用法(功能类似innerHTML) 开发中需要使用Ajax技术来更新页面局部区域, 使用的方法是ajax获取html代码段(字符串),然后将这个html代码段作为参数,传入目标D ...

  7. Tomcat启动时报错,Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext

    05-Dec-2016 11:23:44.321 SEVERE [localhost-startStop-1] org.apache.catalina.core.ContainerBase.addCh ...

  8. Java基础之在窗口中绘图——移动曲线的控制点(CurveApplet 3 moving the control points)

    Applet程序. import javax.swing.*; import java.awt.*; import java.awt.geom.*; import javax.swing.event. ...

  9. Hadoop:搭建hadoop集群

    操作系统环境准备: 准备几台服务器(我这里是三台虚拟机): linux ubuntu 14.04 server x64(下载地址:http://releases.ubuntu.com/14.04.2/ ...

  10. linux挂载移动硬盘

    1. 安装ntfs-3g2. mkdir /mnt/disk3. mount -t ntfs-3g /dev/sdb /mnt/disk4.卸载 umount /dev/sdb