复制物料(参考的MMCC想法)

MMCC这个事务码没用过,也是才听到的,都是业务搞起来的。。。然后感觉这个东西有点意思,就搞搞咯

网上找的一篇文章,自己修改的。改了默认收货工厂为创建时的工厂,因为这边一直报收货工厂必输。。。不管是不是配置问题,反正可以解决。

*&---------------------------------------------------------------------*
*& Report  ZLYTEST_MATERIAL
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT ZLYTEST_MATERIAL.

SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME.
PARAMETERS: P_WERKS0 LIKE MARC-WERKS DEFAULT ‘2001‘,
P_VKORG0 LIKE MVKE-VKORG DEFAULT ‘2001‘,
P_DISNSO LIKE MVKE-VTWEG DEFAULT ‘00‘,
P_MBRSH LIKE MARA-MBRSH DEFAULT ‘C‘.
SELECTION-SCREEN: END OF BLOCK B1.
SELECTION-SCREEN: BEGIN OF BLOCK B2 WITH FRAME.
PARAMETERS: P_MATNR LIKE MARA-MATNR DEFAULT ‘4000888‘.
PARAMETERS: P_BUKRS LIKE T001-BUKRS.
PARAMETERS: P_BWKEY LIKE T001K-BWKEY.
PARAMETERS: P_MATCFG LIKE MARA-MATNR DEFAULT ‘4000020‘.
SELECTION-SCREEN: END OF BLOCK B2.

START-OF-SELECTION.
  DATA: GT_MARC TYPE TABLE OF MARC.
  DATA: GT_MARA TYPE TABLE OF MARA.
  DATA : STR_CLIENTDATA          LIKE          BAPI_MARA_GA,
         STR_PLANTDATA           LIKE          BAPI_MARC_GA,
         STR_FORECASTPARAMETERS  LIKE          BAPI_MPOP_GA,
         STR_PLANNINGDATA        LIKE          BAPI_MPGD_GA,
         STR_STORAGELOCATIONDATA LIKE          BAPI_MARD_GA,
         STR_VALUATIONDATA       LIKE          BAPI_MBEW_GA,
         STR_SALESDATA           LIKE          BAPI_MVKE_GA,
         STR_WAREHOUSENUMBERDATA LIKE          BAPI_MLGN_GA,
         STR_STORAGETYPEDATA     LIKE          BAPI_MLGT_GA,
         STR_PRTDATA             LIKE          BAPI_MFHM_GA,
         STR_LIFOVALUATIONDATA   LIKE          BAPI_MYMS_GA,
         TAB_GET_ALL_R           TYPE TABLE OF BAPIRETURN.
  DATA:TAB_MATERIALDESCRIPTION  TYPE TABLE OF BAPI_MAKT_GA WITH HEADER LINE,
       TAB_UNITSOFMEASURE       TYPE TABLE OF BAPI_MARM_GA,
       TAB_INTERNATIONALARTNOS  TYPE TABLE OF BAPI_MEAN_GA,
       TAB_MATERIALLONGTEXT     TYPE TABLE OF BAPI_MLTX_GA,
       TAB_TAXCLASSIFICATIONS   TYPE TABLE OF BAPI_MLAN_GA,
       TAB_MATERIALDESCRIPTION1 TYPE TABLE OF BAPI_MAKT WITH HEADER LINE.
  DATA: BEGIN OF TAB_HEAD.
          INCLUDE STRUCTURE BAPIMATHEAD.
  DATA: END OF TAB_HEAD.
  DATA: BEGIN OF TAB_PLANTDATA.
          INCLUDE STRUCTURE BAPI_MARC.
  DATA: END OF TAB_PLANTDATA.
  DATA: BEGIN OF TAB_PLANTDATAX.
          INCLUDE STRUCTURE BAPI_MARCX.
  DATA: END OF TAB_PLANTDATAX.
  DATA: BEGIN OF TAB_CLIENT.
          INCLUDE STRUCTURE BAPI_MARA.
  DATA: END OF TAB_CLIENT.
  DATA: BEGIN OF TAB_CLIENTX.
          INCLUDE STRUCTURE BAPI_MARAX.
  DATA: END OF TAB_CLIENTX.
  DATA: BEGIN OF TAB_SALESDATA.
          INCLUDE STRUCTURE BAPI_MVKE.
  DATA: END OF TAB_SALESDATA.
  DATA: BEGIN OF TAB_SALESDATAX.
          INCLUDE STRUCTURE BAPI_MVKEX.
  DATA: END OF TAB_SALESDATAX.
  DATA : BEGIN OF TAB_RETURN.
          INCLUDE STRUCTURE BAPIRET2 .
  DATA : END OF TAB_RETURN.
  DATA : TAB_RETURN_MSGS TYPE TABLE OF BAPI_MATRETURN2 .
  DATA: TAB_FORECAST   LIKE BAPI_MPOP,
        TAB_FORECASTX  LIKE BAPI_MPOPX,
        TAB_PLANGDATA  LIKE BAPI_MPGD,
        TAB_PLANGDATAX LIKE BAPI_MPGDX,
        TAB_STLOCDATA  LIKE BAPI_MARD,
        TAB_STLOCDATAX LIKE BAPI_MARDX,
        TAB_VALDATA    LIKE BAPI_MBEW,
        TAB_VALDATAX   LIKE BAPI_MBEWX,
        TAB_WAREHOUSE  LIKE BAPI_MLGN,
        TAB_WAREHOUSEX LIKE BAPI_MLGNX,
        TAB_STORTYPED  LIKE BAPI_MLGT,
        TAB_STORTYPEDX LIKE BAPI_MLGTX.
  DATA GT_MAKT TYPE TABLE OF BAPI_MAKT.
  DATA: GV_LEN      TYPE I,
        VIEW,
        COUNTER     TYPE SY-INDEX,
        GV_I        TYPE I,
        GV_MSG(200).
  FIELD-SYMBOLS:
    <FS_MARC>  TYPE BAPI_MARA_GA,"MARC,
    <F1>       TYPE ANY,
    <F2>       TYPE ANY,
    <FMS>      TYPE BAPI_MATRETURN2,
    <FSTRUCT>  TYPE ANY,
    <FSTRUCTX> TYPE ANY.
  CALL FUNCTION ‘BAPI_MATERIAL_GET_ALL‘
    EXPORTING
      MATERIAL            = P_MATCFG
      COMP_CODE           = P_BUKRS
      VAL_AREA            = P_BWKEY
*     VAL_TYPE            =
      PLANT               = P_WERKS0
*     STGE_LOC            =
      SALESORG            = P_VKORG0
      DISTR_CHAN          = P_DISNSO
*     WHSENUMBER          =
*     STGE_TYPE           =
*     LIFO_VALUATION_LEVEL =
    IMPORTING
      CLIENTDATA          = STR_CLIENTDATA
      PLANTDATA           = STR_PLANTDATA
      FORECASTPARAMETERS  = STR_FORECASTPARAMETERS
      PLANNINGDATA        = STR_PLANNINGDATA
      STORAGELOCATIONDATA = STR_STORAGELOCATIONDATA
      VALUATIONDATA       = STR_VALUATIONDATA
      WAREHOUSENUMBERDATA = STR_WAREHOUSENUMBERDATA
      SALESDATA           = STR_SALESDATA
      STORAGETYPEDATA     = STR_STORAGETYPEDATA
      PRTDATA             = STR_PRTDATA
      LIFOVALUATIONDATA   = STR_LIFOVALUATIONDATA
    TABLES
      MATERIALDESCRIPTION = TAB_MATERIALDESCRIPTION
      UNITSOFMEASURE      = TAB_UNITSOFMEASURE
      INTERNATIONALARTNOS = TAB_INTERNATIONALARTNOS
      MATERIALLONGTEXT    = TAB_MATERIALLONGTEXT
      TAXCLASSIFICATIONS  = TAB_TAXCLASSIFICATIONS
*     EXTENSIONOUT        =
      RETURN              = TAB_GET_ALL_R.

* Material views update ---

*  SELECT * FROM MARC INTO TABLE GT_MARC
*  WHERE MATNR = P_MATCFG
*  AND WERKS = P_WERKS0.
*  IF SY-SUBRC = 0.
*    READ TABLE GT_MARC ASSIGNING <FS_MARC> INDEX 1.
*    IF SY-SUBRC = 0.
  ASSIGN STR_CLIENTDATA TO <FS_MARC>.
"关于视图这块是本人修改的,原来是读的MARC用的PSTAT,可是我发现,还是用读出来的MAINT_STAT准确点
  COUNTER = 0. CLEAR VIEW.
  GV_I = STRLEN( <FS_MARC>-MAINT_STAT ).
  DO GV_I TIMES.
    VIEW = <FS_MARC>-MAINT_STAT+COUNTER(1).
    IF VIEW IS INITIAL. EXIT. ENDIF.
    COUNTER = COUNTER + 1.
    CASE VIEW.
      WHEN ‘K‘.
        TAB_HEAD-BASIC_VIEW = VIEW.
      WHEN ‘V‘.
        TAB_HEAD-SALES_VIEW = VIEW.
      WHEN ‘E‘.
        TAB_HEAD-PURCHASE_VIEW = VIEW.
      WHEN ‘D‘ .
        TAB_HEAD-MRP_VIEW = VIEW.
      WHEN ‘P‘.
        TAB_HEAD-FORECAST_VIEW = VIEW.
      WHEN ‘A‘.
        TAB_HEAD-WORK_SCHED_VIEW = VIEW.
      WHEN ‘F‘.
        TAB_HEAD-PRT_VIEW = VIEW.
      WHEN ‘L‘.
        TAB_HEAD-STORAGE_VIEW = VIEW.
      WHEN ‘S‘.
        TAB_HEAD-WAREHOUSE_VIEW = VIEW.
      WHEN ‘Q‘.
        TAB_HEAD-QUALITY_VIEW = VIEW.
      WHEN ‘B‘.
        TAB_HEAD-ACCOUNT_VIEW = VIEW.
      WHEN ‘G‘.
        TAB_HEAD-COST_VIEW = VIEW.
      WHEN OTHERS.
    ENDCASE.
  ENDDO.
*    ENDIF.
*  ENDIF.
  TAB_HEAD-MATERIAL = P_MATNR.
  TAB_HEAD-IND_SECTOR = STR_CLIENTDATA-IND_SECTOR.
  TAB_HEAD-MATL_TYPE = STR_CLIENTDATA-MATL_TYPE.
  MOVE-CORRESPONDING STR_CLIENTDATA TO TAB_CLIENT.
  MOVE-CORRESPONDING STR_PLANTDATA TO TAB_PLANTDATA.
  MOVE-CORRESPONDING STR_FORECASTPARAMETERS TO TAB_FORECAST.
  MOVE-CORRESPONDING STR_PLANNINGDATA TO TAB_PLANGDATA.
  MOVE-CORRESPONDING STR_STORAGELOCATIONDATA TO TAB_STLOCDATA.
  MOVE-CORRESPONDING STR_VALUATIONDATA TO TAB_VALDATA.
  MOVE-CORRESPONDING STR_WAREHOUSENUMBERDATA TO TAB_WAREHOUSE.
  MOVE-CORRESPONDING STR_SALESDATA TO TAB_SALESDATA.
  TAB_SALESDATA-DELYG_PLNT = P_WERKS0."默认的工厂
  MOVE-CORRESPONDING STR_STORAGETYPEDATA TO TAB_STORTYPED.

* Fill the update struktur

  DO .
    CASE SY-INDEX.
      WHEN 1.
        ASSIGN TAB_CLIENT TO <F1>.
        ASSIGN TAB_CLIENTX TO <F2>.
        PERFORM FILL_UPDATE_STRUCT USING <F1> <F2>.
      WHEN 2.
        ASSIGN TAB_PLANTDATA TO <F1>.
        ASSIGN TAB_PLANTDATAX TO <F2>.
        PERFORM FILL_UPDATE_STRUCT USING <F1> <F2>.
      WHEN 3.
        ASSIGN TAB_FORECAST TO <F1>.
        ASSIGN TAB_FORECASTX TO <F2>.
        PERFORM FILL_UPDATE_STRUCT USING <F1> <F2>.
      WHEN 4.
        ASSIGN TAB_PLANGDATA TO <F1>.
        ASSIGN TAB_PLANGDATAX TO <F2>.
        PERFORM FILL_UPDATE_STRUCT USING <F1> <F2>.
      WHEN 5.
        ASSIGN TAB_STLOCDATA TO <F1>.
        ASSIGN TAB_STLOCDATAX TO <F2>.
        PERFORM FILL_UPDATE_STRUCT USING <F1> <F2>.
      WHEN 6.
        ASSIGN TAB_VALDATA TO <F1>.
        ASSIGN TAB_VALDATAX TO <F2>.
        PERFORM FILL_UPDATE_STRUCT USING <F1> <F2>.
      WHEN 7.
        ASSIGN TAB_WAREHOUSE TO <F1>.
        ASSIGN TAB_WAREHOUSEX TO <F2>.
        PERFORM FILL_UPDATE_STRUCT USING <F1> <F2>.
      WHEN 8.
        ASSIGN TAB_SALESDATA TO <F1>.
        ASSIGN TAB_SALESDATAX TO <F2>.
        PERFORM FILL_UPDATE_STRUCT USING <F1> <F2>.
      WHEN 9.
        ASSIGN TAB_STORTYPED TO <F1>.
        ASSIGN TAB_STORTYPEDX TO <F2>.
        PERFORM FILL_UPDATE_STRUCT USING <F1> <F2>.
      WHEN OTHERS.
        EXIT.
    ENDCASE.
  ENDDO.

  LOOP AT TAB_MATERIALDESCRIPTION.
    MOVE-CORRESPONDING TAB_MATERIALDESCRIPTION TO TAB_MATERIALDESCRIPTION1.
    APPEND TAB_MATERIALDESCRIPTION1.
  ENDLOOP.

  TAB_SALESDATA-SALES_ORG = P_VKORG0.
  TAB_SALESDATA-DISTR_CHAN = P_DISNSO.
  CLEAR: TAB_SALESDATAX-SALES_ORG,
  TAB_SALESDATAX-DISTR_CHAN.
  TAB_SALESDATAX-SALES_ORG = TAB_SALESDATA-SALES_ORG.
  TAB_SALESDATAX-DISTR_CHAN = TAB_SALESDATA-DISTR_CHAN.
  CLEAR TAB_PLANTDATAX-PLANT.
  TAB_PLANTDATAX-PLANT = TAB_PLANTDATA-PLANT.
  CLEAR TAB_VALDATAX-VAL_AREA.
  TAB_VALDATAX-VAL_AREA = TAB_VALDATA-VAL_AREA.
  CALL FUNCTION ‘BAPI_MATERIAL_SAVEDATA‘
    EXPORTING
      HEADDATA             = TAB_HEAD
      CLIENTDATA           = TAB_CLIENT
      CLIENTDATAX          = TAB_CLIENTX
      PLANTDATA            = TAB_PLANTDATA
      PLANTDATAX           = TAB_PLANTDATAX
      FORECASTPARAMETERS   = TAB_FORECAST
      FORECASTPARAMETERSX  = TAB_FORECASTX
      PLANNINGDATA         = TAB_PLANGDATA
      PLANNINGDATAX        = TAB_PLANGDATAX
      STORAGELOCATIONDATA  = TAB_STLOCDATA
      STORAGELOCATIONDATAX = TAB_STLOCDATAX
      VALUATIONDATA        = TAB_VALDATA
      VALUATIONDATAX       = TAB_VALDATAX
      WAREHOUSENUMBERDATA  = TAB_WAREHOUSE
      WAREHOUSENUMBERDATAX = TAB_WAREHOUSEX
      SALESDATA            = TAB_SALESDATA
      SALESDATAX           = TAB_SALESDATAX
      STORAGETYPEDATA      = TAB_STORTYPED
      STORAGETYPEDATAX     = TAB_STORTYPEDX
*     FLAG_ONLINE          = ‘ ‘
*     FLAG_CAD_CALL        = ‘ ‘
*     NO_DEQUEUE           = ‘ ‘
    IMPORTING
      RETURN               = TAB_RETURN
    TABLES
      MATERIALDESCRIPTION  = TAB_MATERIALDESCRIPTION1
*     UNITSOFMEASURE       =
*     UNITSOFMEASUREX      =
*     INTERNATIONALARTNOS  =
*     MATERIALLONGTEXT     =
*     TAXCLASSIFICATIONS   =
      RETURNMESSAGES       = TAB_RETURN_MSGS.

  IF TAB_RETURN-TYPE = ‘S‘.
    CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT‘
      EXPORTING
        WAIT = ‘X‘.
  ELSE.
    CALL FUNCTION ‘BAPI_TRANSACTION_ROLLBACK‘.
  ENDIF.
  LOOP AT TAB_RETURN_MSGS ASSIGNING <FMS>.
    GV_MSG = <FMS>.
    WRITE:/ GV_MSG.
  ENDLOOP.

*&---------------------------------------------------------------------*
*& Form fill_update_struct
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_<F1> text
* -->P_<F2> text
*----------------------------------------------------------------------*

FORM FILL_UPDATE_STRUCT USING P_F1 TYPE ANY
P_F2 TYPE ANY.
  DO.
    ASSIGN COMPONENT SY-INDEX OF STRUCTURE P_F1 TO <FSTRUCT>.
    IF SY-SUBRC <> 0. EXIT. ENDIF.
    IF <FSTRUCT> IS NOT INITIAL.
      ASSIGN COMPONENT SY-INDEX OF STRUCTURE P_F2 TO <FSTRUCTX>.
      IF SY-SUBRC = 0.
        <FSTRUCTX> = ‘X‘.
      ENDIF.
    ENDIF.
  ENDDO.
ENDFORM. " fill_update_struct

代码应该都能看懂,就不废话了。。。

时间: 2024-10-09 22:24:18

复制物料(参考的MMCC想法)的相关文章

Postgresql流复制+pgpool实现高可用

pgpool 概述 pgpool-II 是一个位于 PostgreSQL 服务器和 PostgreSQL 数据库客户端之间的中间件,它提供以下功能:连接池.复制.负载均衡.限制超过限度的连接以及并行查询.文档在此. 四种模式 O 意味着“可用”, X 意味着“不可用(1) 并行查询模式需要同时打开复制和负载均衡,但是复制和负载均衡无法用于并行查询模式中的分布式表.(2) 在线恢复可以和流复制同时使用.(*3) 客户端仅仅是通过 pgpool-II 连接到 PostgreSQL服务器.这种模式仅仅

MySQL 5.6 Replication 复制 FAQ

原文请参照MySQL官方文档Reference Manual,版本5.6.10. 复制功能使得数据可以从一个MySQL数据库(master主库)复制到另一个或多个MySQL数据库(slave从库).缺省情况下,复制是异步的,slave无需保持持久的连接来从master获得更新.这意味着更新能工作在远程连接,甚至是临时间断性的连接上,比如拨号连接服务.根据不同的配置,你能复制master上所有的数据库,或指定的数据库,甚至某一数据库中指定的数据表. 下面是关于复制功能,新手经常问到的问题. 1.

InnoSQL/MySQL并行复制的实现与配置

InnoSQL/MySQL并行复制的实现与配置 http://www.innomysql.net/article/6276.html 并行复制之前的解决方案 InnoSQL在5.5.30-v4版本中支持了从机并行复制的功能.总所周知,MySQL数据库slave服务器延迟的现象是非常普遍的,这导致了虽然对比Oracle.Microsoft SQL Server,MySQL复制允许从机进行SELECT操作,但是在实际线上环境下,由于从机延迟的关系,很难将读取操作转向到从机.这就导致了有了以下一些潜规

CentOS6.5源码安装多个MySQL实例及复制搭建

多实例安装本节是在CentOS6.5源码安装MySQL5.6.35的基础上,在同一台机器增加一个MySQL实例.参考Centos中安装多个mysql数据的配置实例,安装目录为/usr/local/mysql3307/ 6.目录创建(-p父目录不存在则创建此目录) [[email protected] ~]# cd mysql-5.6.35 [[email protected] mysql-5.6.35]# mkdir -p /usr/local/mysql3307/data 7.编译安装 [[e

TimesTen 数据库复制学习:11. ASP带缓存组复制的几种固定架构模式

概述 对于带缓存组的复制,推荐的复制策略是 Active-Standby (A/S) pair.因为其复制整个库,并且复制和恢复都比较简单和直接,而且错误切换和恢复都是自动的. 带AWT缓存组的ASP复制 - 单站点 此种复制不支持灾备 注意数据的流向 带只读缓存组的ASP复制 注意数据的流向 带AWT缓存组的ASP复制 - 多站点 此种复制支持灾备 从standby到subscriber的克隆使用特殊的ttRepadmin复制选项 参考 HOWTO : Understand Combining

mha配置参考

1.ssh互信配置:ssh-keygen -t rsassh-copy-id -i .ssh/id_rsa.pub [email protected] 2.mysql复制配置参考:http://blog.51cto.com/1937519/2283779 3.创建监控用户:[email protected] 15:28: [(none)]>create user [email protected]'%' identified by "monitor123";Query OK, 0

MySQL 复制 - 性能与扩展性的基石 1:概述及其原理

原文:MySQL 复制 - 性能与扩展性的基石 1:概述及其原理 1. 复制概述 MySQL 内置的复制功能是构建基于 MySQL 的大规模.高性能应用的基础,复制解决的基本问题是让一台服务器的数据与其他服务器保持同步. 接下来,我们将从复制概述及原理.复制的配置.常见的问题及解决方法来学习 MySQL 的复制功能. 1.1 复制解决的问题 下面是复制常见的用途: 数据分布.Mysql 复制通常不会对带宽造成很大压力,但在 5.1 版本中引入的基于行的复制会比传统的基于语句的复制模式产生更大的带

SAP 常用T-CODE

Plant Maintenance (PM) IW32 - Change Plant Maintenance Order IW33 - Display Plant Maintenance Order IW34 - Create Notification Order IW51 - Create Service Notification IW52 - Change Service Notification IW53 - Display Service Notification IW54 - Crea

javascript代码复用(四)-混入、借用方法和绑定

这篇继续说js的现代复用模式:混入.借用方法和绑定. 混入 可以针对前面提到的通过属性复制实现代码复用的想法进行一个扩展,就是混入(mix-in).混入并不是复制一个完整的对象,而是从多个对象中复制出任意的成员并将这些成员组合成一个新的对象. 混入的实现并不难,只需要遍历每个参数,并且复制出传递给这个函数的每个对象中的每个属性. function mix(){ var arg,prop,child={}; for(arg=0:arg<arguments.length;arg++){ for(ar