工藝路線當日建立或修改自動分配物料元件
*&---------------------------------------------------------------------*
*& 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 ) < 1.
* 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 .
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29829936/viewspace-1595532/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 前臺工藝路線元件自動分配元件
- 讀取工藝路線的函式函式
- PDM工藝路線在ERP系統中的應用
- 工藝品的網路營銷策略
- JVM的藝術-物件建立與記憶體分配機制深度剖析JVM物件記憶體
- vue 動態建立元件(執行時建立元件)Vue元件
- [軟體工藝]
- CRM系統如何自動分配線索
- 物件的建立和分配物件
- 軟體工藝運動的目標是什麼?
- PCBA貼片加工無鉛工藝與有鉛工藝的區別?
- 相當於delphi的日曆控制元件 (轉)控制元件
- Angular動態建立元件之PortalsAngular元件
- win7系統開啟或關閉自動連線無線網路Win7
- 基於工業物聯網的物料包裝生產線監控系統
- 修改自動生成get/set方法模板程式碼
- 從業務元件庫看前端物料生態元件前端
- SAP RETAIL 基於分配表建立採購訂單的時候按工廠拆分?AI
- 蘋果iPhone 6S或將採用14nm工藝A9處理器蘋果iPhone
- 安集科技參加積體電路超級工藝技術Workshop
- mongoDB當機修復MongoDB
- [譯] 單元素元件模式簡介:使用 React 或其它元件庫建立可靠元件的規則和實踐元件模式React
- 控制物料無成本不允許入庫或發料
- 元件能否支援動態建立庫及表元件
- BCB中實現動態建立元件 (轉)元件
- monitor_dg_當機或日誌沒正常應用就報警
- 三維智慧工藝,效益資料見真章 華耀電子三維智慧工藝案例分享
- 2020年裂解(裂化)工藝報名考試及裂解(裂化)工藝考試APPAPP
- Dependabot:自動建立GitHub PR修復潛在漏洞Github
- win7 或 win8 建立無線區域網Win7
- 批次管理(一):批次建立&批次物料的初始入庫
- 物件的建立與記憶體分配物件記憶體
- 手動開發一個日曆元件元件
- 娛樂工場:2016年中國網路綜藝投資報告
- 建立一個連線資料庫的VB元件 (轉)資料庫元件
- SAP RETAIL 沒有分配Assortment的物料,也可以正常下達採購訂單AI
- BZOJ2882: 工藝(字尾陣列)陣列
- [筆記]軟體工藝1-4筆記