工艺路线当日创建或修改自动分配物料组件

*&---------------------------------------------------------------------*
*& Report  Z_CA01_BACKGROUND
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

工艺路线当日如果有新建或修改,将会重新分配物料.

程序定义成了后台作业.

前提是BOM中每个物都维护的排序字符串,排序字符串和工序的简称相同.作为自动分配组件的原则

report  z_ca01_background.

*AEDAT          2010.11.24
*AEUZEIT        15:10:11
*今日创建修改的工艺路线(PLKZ)
data: begin of i_matnr occurs 0,
      werks like mapl-werks,
      matnr like mapl-matnr,
      end of i_matnr.

 data subrc type sy-subrc.
data messtab like  bdcmsgcoll occurs 0.

data: matnr_001 type bdcdata-fval.
data: werks_002 type bdcdata-fval.
data: p_model type c.
data: w_msg(200) type c.

parameters  p_model1 type c radiobutton group r1.
parameters  p_model2 type c radiobutton group r1.
parameters  p_tag type c as checkbox.

 

if p_model1 eq 'X'.
  p_model = 'N'.
else.
  p_model = 'A'.

endif.

select distinct werks matnr
into corresponding fields of table i_matnr
from mapl
inner join plkz  on  mapl~plnnr = plkz~plnnr
where plkz~aedat eq sy-datum and loekz eq space and mapl~plnty = 'N'.

 

  loop at i_matnr.

 

  matnr_001 = i_matnr-matnr.

  werks_002 = i_matnr-werks.

 

  call function 'ZCA02'
   exporting
*   CTU                 = 'X'
   mode                = p_model
*   UPDATE              = 'L'
*   GROUP               = GROUP
*   USER                = USER
*   KEEP                = KEEP
*   HOLDDATE            = HOLDDATE
*   NODATA              = '/'
     matnr_001           = matnr_001
     werks_002           = werks_002
*   PLNNR_003           = '10008203'
*   STTAG_004           = '2010.11.08'
*   PLNAL_005           = ''
*   ENTRY_ACT_006       = '1'
*   SORTF_007           = 'X'
*   SORTF_008           = 'ai'
*   VORNR_009           = '0010'
*   PLNFL_010           = '0'
*   SORTF_011           = 'X'
*   SORTF_012           = 'dip'
*   VORNR_013           = '0020'
*   PLNFL_014           = '0'
   p_tag = p_tag
   importing
     subrc               = subrc
 tables
   messtab             = messtab
            .

endloop.

function zca02.
*"----------------------------------------------------------------------
*"*"Local interface:
*"  IMPORTING
*"     VALUE(CTU) LIKE  APQI-PUTACTIVE DEFAULT 'X'
*"     VALUE(MODE) LIKE  APQI-PUTACTIVE DEFAULT 'N'
*"     VALUE(UPDATE) LIKE  APQI-PUTACTIVE DEFAULT 'L'
*"     VALUE(GROUP) LIKE  APQI-GROUPID OPTIONAL
*"     VALUE(USER) LIKE  APQI-USERID OPTIONAL
*"     VALUE(KEEP) LIKE  APQI-QERASE OPTIONAL
*"     VALUE(HOLDDATE) LIKE  APQI-STARTDATE OPTIONAL
*"     VALUE(NODATA) LIKE  APQI-PUTACTIVE DEFAULT '/'
*"     VALUE(MATNR_001) LIKE  BDCDATA-FVAL DEFAULT '120201355'
*"     VALUE(WERKS_002) LIKE  BDCDATA-FVAL DEFAULT '1000'
*"     VALUE(PLNNR_003) LIKE  BDCDATA-FVAL DEFAULT '10008203'
*"     VALUE(STTAG_004) LIKE  BDCDATA-FVAL DEFAULT '2010.11.08'
*"     VALUE(PLNAL_005) LIKE  BDCDATA-FVAL DEFAULT ''
*"     VALUE(ENTRY_ACT_006) LIKE  BDCDATA-FVAL DEFAULT '1'
*"     VALUE(SORTF_007) LIKE  BDCDATA-FVAL DEFAULT 'X'
*"     VALUE(SORTF_008) LIKE  BDCDATA-FVAL DEFAULT 'ai'
*"     VALUE(VORNR_009) LIKE  BDCDATA-FVAL DEFAULT '0010'
*"     VALUE(PLNFL_010) LIKE  BDCDATA-FVAL DEFAULT '0'
*"     VALUE(SORTF_011) LIKE  BDCDATA-FVAL DEFAULT 'X'
*"     VALUE(SORTF_012) LIKE  BDCDATA-FVAL DEFAULT 'dip'
*"     VALUE(VORNR_013) LIKE  BDCDATA-FVAL DEFAULT '0020'
*"     VALUE(PLNFL_014) LIKE  BDCDATA-FVAL DEFAULT '0'
*"     VALUE(P_TAG) TYPE  C1 OPTIONAL
*"  EXPORTING
*"     VALUE(SUBRC) LIKE  SYST-SUBRC
*"  TABLES
*"      MESSTAB STRUCTURE  BDCMSGCOLL OPTIONAL
*"----------------------------------------------------------------------

  data wa_messatab like bdcmsgcoll.
  data i_capp_com like table of capp_com with header line.
 data: begin of i_stb occurs 0.
         include structure stpox.
 data: end of i_stb.
 data: l_werks like marc-werks.
 data: wa_zca02_log like zca02_log.

  data: w_msg(200) type c.

 

*定义工序信息,
  data i_opr like table of capp_opr with header line.
  data i_opr_bom like table of capp_opr with header line.

  tables  mapl.
  data: wa_matnr like mara-matnr.

    data: l_matnr like mara-matnr.

 

*查找物料的工序信息放入内标。

  select single * from mapl
  where matnr = matnr_001 and werks = werks_002 and loekz = space.

  call function 'CONVERSION_EXIT_ALPHA_OUTPUT'
    exporting
      input  = mapl-matnr
    importing
      utput = wa_matnr.

  l_werks = werks_002.

  call function 'CONVERSION_EXIT_ALPHA_INPUT'
    exporting
      input  = wa_matnr
    importing
      utput = l_matnr.

 

  call function 'CARO_ROUTING_READ'
    exporting
*   DATE_FROM                  = '19000101'
*   DATE_TO                    = '99991231'
      plnty                      = mapl-plnty
      plnnr                      = mapl-plnnr
      plnal                      = mapl-plnal
     matnr                      = l_matnr
*   BUFFER_DEL_FLG             = 'X'
*   DELETE_ALL_CAL_FLG         = 'X'
*   ADAPT_FLG                  = 'X'
*   IV_CREATE_ADD_CHANGE       = ' '
   tables
*   TSK_TAB                    = TSK_TAB
*   SEQ_TAB                    = SEQ_TAB
     opr_tab                    = i_opr
*   PHASE_TAB                  = PHASE_TAB
*   SUBOPR_TAB                 = SUBOPR_TAB
*   REL_TAB                    = REL_TAB
*   com_tab                    = i_capp_com
*   REFERR_TAB                 = REFERR_TAB
*   REFMIS_TAB                 = REFMIS_TAB
   exceptions
     not_found                  = 1
     ref_not_exp                = 2
     not_valid                  = 3
            .
*需要先关联到BOM表取排序字符串

*    IF LINES( i_capp_com ) *      CLEAR w_msg.
*      CONCATENATE  '物料:'  matnr_001+9(9) '工厂:'   werks_002 '没有组件' INTO w_msg.
*      WRITE :/ w_msg COLOR COL_NEGATIVE.
*      EXIT.
*    ENDIF.

*通过展BOM来获取排序字符串
    call function 'CS_BOM_EXPL_MAT_V2'
     exporting
          capid  = 'PP01'
          datuv  = sy-datum          "BOM用效日期.
          ehndl  = '1'
          emeng  = 1
          mtnrv  = l_matnr
          mehrs  = 'X'             "多层BOM展开标记.
          mmory  = '1'
*          stlal  = '1'              "代用BOM.
*          stlan  = w_stlan "s_stlan-low           "BOM用途.
          stpst  = '99'
          werks  = l_werks           "P_WERKS.
*       importing
*            topmat = selpool
*            dstst  = dstst_flg
     tables
          stb    = i_stb              "存放BOM项目.
*          matcat = matcat
      exceptions
         alt_not_found         =  4
         call_invalid          =  8
         material_not_foun     = 12
*         OBJECT_NOT_FOUND      = 12
         missing_authorization = 16
         no_bom_found          = 20
         no_plant_data         = 24
         no_suitable_bom_found = 28
         conversion_error      = 32.

sort i_stb by sortf.
delete adjacent duplicates from i_stb comparing sortf.

loop at i_stb.
  if i_stb-sortf ne space.
    i_opr_bom-ktsch =  i_stb-sortf.
    append i_opr_bom.
  endif.
endloop.

*  SELECT sortf AS ktsch
*    FROM stpo
*   INTO CORRESPONDING FIELDS OF TABLE i_opr_bom
*    FOR ALL ENTRIES IN i_capp_com
*    WHERE stlnr = i_capp_com-stlnr AND stlkn =  i_capp_com-stlkn.
*比较工序中文本和BOM中文本,如果BOM中文本和工序中不同,则退出不做。
  loop at i_opr_bom.

    read table i_opr with key ktsch =  i_opr_bom-ktsch.
    if sy-subrc ne 0.
      clear w_msg.
      concatenate  '物料:'  matnr_001+9(9) '工厂:'   werks_002 'BOM排序字符串:'  i_opr_bom-ktsch '在工序中不存在' INTO w_msg.
      WRITE :/ w_msg COLOR COL_NEGATIVE.
      CLEAR WA_ZCA02_LOG.
      WA_ZCA02_LOG-DATUM = SY-DATUM.
      WA_ZCA02_LOG-UZEIT = SY-UZEIT.
      WA_ZCA02_LOG-MATNR = matnr_001.
      WA_ZCA02_LOG-WERKS = WERKS_002.
      WA_ZCA02_LOG-MSG = W_MSG.
       WA_ZCA02_LOG-SUCC_TAG = '失败'.

      INSERT ZCA02_LOG FROM WA_ZCA02_LOG.
      REJECT.
    ENDIF.

  ENDLOOP.

 

 

 

  subrc = 0.
  IF LINES( i_opr ) > 0.

    PERFORM. bdc_nodata      USING nodata.

    PERFORM. open_group      USING group user keep holddate ctu.

    PERFORM. bdc_dynpro      USING 'saplcpdi' '1010'.
    PERFORM. bdc_field       USING 'bdc_cursor'
                                  'rc27m-werks'.
    PERFORM. bdc_field       USING 'bdc_okcode'
                                  '/00'.
    PERFORM. bdc_field       USING 'rc27m-matnr'
                                  matnr_001+9(9).
    PERFORM. bdc_field       USING 'rc27m-werks'
                                  werks_002.
    PERFORM. bdc_field       USING 'rc271-plnnr'
                                  mapl-plnnr.
    PERFORM. bdc_field       USING 'rc271-sttag'
                                  sy-datum.                 "sttag_004.
    PERFORM. bdc_field       USING 'rc271-plnal'
                                  plnal_005.
    PERFORM. bdc_dynpro      USING 'saplcpdi' '1400'.
    PERFORM. bdc_field       USING 'bdc_cursor'
                                  'rc27x-entry_act'.
    PERFORM. bdc_field       USING 'bdc_okcode'
                                  '=mata'.
    PERFORM. bdc_field       USING 'rc27x-entry_act'
                                  entry_act_006.
    PERFORM. bdc_dynpro      USING 'saplcmdi' '1000'.
    PERFORM. bdc_field       USING 'bdc_cursor'
                                  'rcm01-matnr'.
    PERFORM. bdc_field       USING 'bdc_okcode'
                                  '=mara'.
    PERFORM. bdc_dynpro      USING 'saplcmdi' '1000'.
    PERFORM. bdc_field       USING 'bdc_cursor'
                                  'rcm01-matnr'.
    PERFORM. bdc_field       USING 'bdc_okcode'
                                  '=del'.
    PERFORM. bdc_dynpro      USING 'saplspo1' '0100'.
    PERFORM. bdc_field       USING 'bdc_okcode'
                                  '=yes'.
    PERFORM. bdc_dynpro      USING 'saplcmdi' '1000'.
    PERFORM. bdc_field       USING 'bdc_cursor'
                                  'rcm01-matnr'.

    LOOP AT i_opr.

*排序字符串过滤条件
      PERFORM. bdc_field       USING 'bdc_okcode'
                                    '=filt'.
      PERFORM. bdc_dynpro      USING 'saplcm01' '1070'.
      PERFORM. bdc_field       USING 'bdc_cursor'
                                    'd1070-sortf'.
      PERFORM. bdc_field       USING 'bdc_okcode'
                                    '=pick'.
      PERFORM. bdc_field       USING 'd1070-sortf'
                                    sortf_007.
      PERFORM. bdc_dynpro      USING 'saplcm01' '1080'.
      PERFORM. bdc_field       USING 'bdc_cursor'
                                    'stpo-sortf'.
      PERFORM. bdc_field       USING 'bdc_okcode'
                                    '/00'.
      PERFORM. bdc_field       USING 'stpo-sortf'
                                    i_opr-ktsch.
      PERFORM. bdc_dynpro      USING 'saplcmdi' '1000'.
      PERFORM. bdc_field       USING 'bdc_cursor'
                                    'rcm01-matnr'.
      PERFORM. bdc_field       USING 'bdc_okcode'
                                    '=mara'.
      PERFORM. bdc_dynpro      USING 'saplcmdi' '1000'.
      PERFORM. bdc_field       USING 'bdc_cursor'
                                    'rcm01-matnr'.
      PERFORM. bdc_field       USING 'bdc_okcode'
                                    '=new'.
      PERFORM. bdc_dynpro      USING 'saplcm01' '1090'.
      PERFORM. bdc_field       USING 'bdc_cursor'
                                    'rcm01-vornr'.
      PERFORM. bdc_field       USING 'bdc_okcode'
                                    '=goon'.
      PERFORM. bdc_field       USING 'rcm01-vornr'
                                    i_opr-vornr.
      PERFORM. bdc_field       USING 'rcm01-plnfl'
                                    plnfl_010.
      PERFORM. bdc_dynpro      USING 'saplcmdi' '1000'.
      PERFORM. bdc_field       USING 'bdc_cursor'
                                    'rcm01-matnr'.

*perform. bdc_field       using 'BDC_OKCODE'
*                              '=FILT'.
*perform. bdc_dynpro      using 'SAPLCM01' '1070'.
*perform. bdc_field       using 'BDC_CURSOR'
*                              'D1070-SORTF'.
*perform. bdc_field       using 'BDC_OKCODE'
*                              '=PICK'.
*perform. bdc_field       using 'D1070-SORTF'
*                              SORTF_011.
*perform. bdc_dynpro      using 'SAPLCM01' '1080'.
*perform. bdc_field       using 'BDC_CURSOR'
*                              'STPO-SORTF'.
*perform. bdc_field       using 'BDC_OKCODE'
*                              '/00'.
*perform. bdc_field       using 'STPO-SORTF'
*                              SORTF_012.
*perform. bdc_dynpro      using 'SAPLCMDI' '1000'.
*perform. bdc_field       using 'BDC_CURSOR'
*                              'RCM01-MATNR'.
*perform. bdc_field       using 'BDC_OKCODE'
*                              '=MARA'.
*perform. bdc_dynpro      using 'SAPLCMDI' '1000'.
*perform. bdc_field       using 'BDC_CURSOR'
*                              'RCM01-MATNR'.
*perform. bdc_field       using 'BDC_OKCODE'
*                              '=NEW'.
*perform. bdc_dynpro      using 'SAPLCM01' '1090'.
*perform. bdc_field       using 'BDC_CURSOR'
*                              'RCM01-VORNR'.
*perform. bdc_field       using 'BDC_OKCODE'
*                              '=GOON'.
*perform. bdc_field       using 'RCM01-VORNR'
*                              VORNR_013.
*perform. bdc_field       using 'RCM01-PLNFL'
*                              PLNFL_014.
*perform. bdc_dynpro      using 'SAPLCMDI' '1000'.
*perform. bdc_field       using 'BDC_CURSOR'
*                              'RCM01-MATNR'.

    ENDLOOP.

    PERFORM. bdc_field       USING 'bdc_okcode'
                                 '=bu'.

 

*提交
    PERFORM. bdc_transaction TABLES messtab
    USING                         'ca02'
                                  ctu
                                  mode
                                  update.
    IF sy-subrc 0.
      subrc = sy-subrc.
*      EXIT.
    ENDIF.

 

  ENDIF.
  IF subrc NE 0.
    LOOP AT messtab INTO wa_messatab ."WHERE  msgtyp NE 's'.
      CLEAR w_msg.
      CONCATENATE  '物料:'  matnr_001+9(9) '工厂:'   werks_002 '分配组件失败  '  wa_messatab-msgv1   wa_messatab-msgv2  wa_messatab-msgv3   wa_messatab-msgv4 INTO w_msg.
      WRITE :/ w_msg COLOR COL_NEGATIVE.
       CLEAR WA_ZCA02_LOG.
      WA_ZCA02_LOG-DATUM = SY-DATUM.
      WA_ZCA02_LOG-UZEIT = SY-UZEIT.
      WA_ZCA02_LOG-MATNR = matnr_001.
      WA_ZCA02_LOG-WERKS = WERKS_002.
      WA_ZCA02_LOG-MSG = W_MSG.
       WA_ZCA02_LOG-SUCC_TAG = '失败'.

      INSERT ZCA02_LOG FROM WA_ZCA02_LOG.

    ENDLOOP.

  ELSE.
    IF p_tag EQ space.
      CLEAR w_msg.
      CONCATENATE :  '物料:'  matnr_001+9(9) '工厂:' werks_002 '分配组件成功' INTO w_msg .

      WRITE :/  w_msg COLOR COL_POSITIVE.
      CLEAR WA_ZCA02_LOG.
      WA_ZCA02_LOG-DATUM = SY-DATUM.
      WA_ZCA02_LOG-UZEIT = SY-UZEIT.
      WA_ZCA02_LOG-MATNR = matnr_001.
      WA_ZCA02_LOG-WERKS = WERKS_002.
      WA_ZCA02_LOG-MSG = W_MSG.
       WA_ZCA02_LOG-SUCC_TAG = '成功'.
      INSERT ZCA02_LOG FROM WA_ZCA02_LOG.

    ENDIF.
  ENDIF.
  ULINE.

  PERFORM. close_group USING     ctu.

ENDFUNCTION.
INCLUDE bdcrecxy .

 

 

时间: 2024-11-10 00:28:37

工艺路线当日创建或修改自动分配物料组件的相关文章

前台工艺路线组件自动分配

*&---------------------------------------------------------------------**& Report  ZPP_CA02*&*&---------------------------------------------------------------------**&*&*&--------------------------------------------------------

批量创建定额工艺路线的函数cp_cc_s_import_data

问题描述 cp_cc_s_import_data创建定额工艺路线提示:序列号无效,或者根本没有消息返回.然后进ca21查看的时候,发现该物料,和工厂的数据头已存在,就是具体的工艺细节为空.希望能够帮我找找原因

跟我学SQL:(五)创建和修改表格

创建 再次欢迎您来到SQL(结构化查询语言)基础系列教程.本文将介绍数据库定义语言(DDL)用于创建数据库和表格以及修改表格结果的指令.    当你使用这些指令时一定要小心--它很容易删去你的数据库中的主要结构令您丢失数据.所以,在您开始修改数据库之前,您需要知道数据库是什么. -------------------------------------------------------------------------------- 数据库之间的差异 本文中的样品查询系统遵循SQL92 IS

工艺路线相关配置

工艺路线相关配置..................................................................................................... 1 1 控制数据 Control Data.................................................................................................. 1 2 通用数据 General Dat

Javascript实例教程:DOM方法创建和修改表格

文章简介:Javascript实例教程:DOM方法创建和修改表格. <table>元素是HTML中最复杂的结构之一.要想创建表格,一般都必须涉及表示表格行.单元格.表头等方面的标签.由于涉及的标签多,因而使用核心DOM方法创建和修改表格往往都免不了要编写大量的代码.假设我们要使用DOM来创建下面的HTML表格: <table border="1" width="100%"> <tbody> <tr> <td>

自动分配IP地址

网络通信离不开TCP/IP协议,在TCP/IP网络中,每台计算机要想进行通信,存取网络上的资源,都必须进行必要的网络配置,一些主要参数诸如IP地址.子网掩码.默认网关.DNS服务器等必不可少.配置这些参数有两种方法:静态手工配置和自动分配. 手工配置TCP/IP参数是一些网络管理员习惯使用的方法.通常,管理员需要创建一张详细的配置清单,并将其他带在身上或存放在计算机上,以便于随时查阅并配置IP地址.子网掩码以及网关和DNS服务器的IP地址.这种方法看似简单可行,但却相当费时且容易出错.以网络中有

使用DHCP服务器自动分配工作站地址

在大型网络中,需要将各种地址(IP地址.子网掩码.网关.DNS地址.WINS服务器地址等)及其相关参 数分配给各个工作站.这项工作十分繁重,并且容易出现错误.使用DHCP服务器可以为网络中工作站自动 分配. 一.DHCP服务器概述 DHCP(Dynamic Host Configure Protocol,动态主机配置协议 )是一个简化主机IP地址分配管理的ICP/IP标准协议.网络管理员可以利用DHCP服务器动态地为客户端分 配IP地址及其他相关的环境配置工作. 1.DHCP服务的优点 TCP/

为ROS创建的资源自动挂载数据盘

为ROS创建的资源自动挂载数据盘 通过ROS可以方便创建,管理资源.例如自动挂载数据盘,如果是通过阿里云的官方镜像,使用ROS创建ECS资源,UserData可以很容易的帮你完成这一步,详细内容可以参考这篇文章:但是如果你使用自己制作的镜像,而且自己制作的镜像不支持UserData功能怎么办呢,这篇文章帮你解决你的问题. 要完成自有镜像自动挂载数据盘,只需要三步: 1.制作镜像前,把下面的这个脚本拷贝到你将要制作镜像的ECS机器上,例如:/usr/local/bin/mount_disks下面.

SharePoint 2013 入门教程之创建及修改母版页

原文:SharePoint 2013 入门教程之创建及修改母版页 在SharePoint 2013中,微软提供了根据HTML页面转换Master页的方法,并支持单项同步,但是这样的更新,并不完善,会使一些功能造成丢失,所以,了解Master结构的人,尽量直接去修改Master比较方便. 当然,如果需要使用母版页,必须开启SharePoint 2013的发布功能,也就是去网站集功能和网站功能,打开激活发布的Feature. 1.激活发布功能 2.打开SharePoint Designer 2013