声明:原创作品,转载时请注明文章来自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课程---Android Studio的一些小技巧

    APK瘦身 在Android Studio中我们可以开启混淆,和自动删除没有Resources文件,来达到给APP瘦身的目的,这对于一些维护很久的老项目比较有用,里面有很多无效的Resource, 删 ...

  2. Unity学习疑问记录之layer问题

    在Sprite Render中有个Sorting Layer,这里可以建层,而Inspector窗口中也有个layer,也可以新建层,这2者有什么不一样呢? layer主要通过光线投射来选择性地忽略碰 ...

  3. Cocos2d-x环境搭建

    资源列表 官网上下载最新的cocos2d-x-3.3. 安装JDK,Eclipse,CDT插件,ADT插件. 下载Android SDK,更新.因为国内经常访问不了google,用vpn速度也有点慢. ...

  4. linux 解压xz包

    1.下载xz包 http://tukaani.org/xz/xz-4.999.9beta.tar.bz2   2.解压安装包 $tar -jxvf xz-4.999.9beta.tar.bz2   3 ...

  5. class-dump + DumpFrameworks.pl

    目的:实现生成 private framework 的 .h,以便倒入项目使用私有 api. 一.class-dump 下载地址: http://stevenygard.com/download/ 安 ...

  6. ios编程之网络请求

    网络请求有GET请求和POST请求,get和post实现的时候可以选择同步或者异步实现.看一个请求是GET还是POST就看网址后面有没有携带请求体. GET与POST 区别  1.get请求 请求的网 ...

  7. mysql qps tps计算

    Information from web QPS (Query per second) (每秒查询量)TPS(Transaction per second) (每秒事务量,如果是InnoDB会显示,没 ...

  8. Python基础、文件处理

    一.概述 Python中操作文件是通过file对象来处理的,步骤: 指定文件的路径.操作的模式 对文件进行操作,读或写操作 关闭文件对象 f = open( '文件路径','访问模式') # 打开文件 ...

  9. PowerShell 常用命令

    下载文件 http://powershell.com/cs/blogs/tips/archive/2012/10/11/downloading-files-from-internet.aspx Pow ...

  10. WebViewClient shouldOverrideUrlLoading 常见错误用法

    需求描述 在使用 WebView 的项目中,一个常见的需求是将页面内的链接跳转限制在 WebView 内,而不是使用外部浏览器打开,但 WebView 的默认行为是将链接点击事件作为 Intent 发 ...