日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

工单更改历史记录(轉載)

發布時間:2023/12/20 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 工单更改历史记录(轉載) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

一、自定義表結構

二、生產工單出口增強

三、查詢報表

一、自定義表結構

表ZPCO02

MANDT?MANDT?CLNT?3?0?客戶端?
AUFNR?AUFNR?CHAR?12?0?訂單號?
MATNR?MATNR?CHAR?18?0?物料號?
FILED?FIELDNAME?CHAR?30?0?字段名?
AENAM?AENAM?CHAR?12?0?對象更改人員的名稱?
LAEDA?LAEDA?DATS?8?0?上次更改的日期?
TCODE?TCODE?CHAR?20?0?事務代碼
CHNID?CDCHNGIND?CHAR?1?0?修改類型 (U, I, E, D)
HOSTIP?CHAR20?CHAR?20?0?字符 20
HOST?MSHOST2?CHAR?32?0?Name of Application Server
VALUE_OLD?CHAR20?CHAR?20?0?字符 20
VALUE_NEW?CHAR20?CHAR?20?0?字符 20
TIMES?CDUZEIT?TIMS?6?0?時間已更改?
LOOPID?SYTABIX?INT4?10?0?????????????????????????????????????????????????????????????
ALPOS?ALPOS?CHAR?1?0?指示符:替代項目
STTXT?CO_STTXT?CHAR?40?0?系統狀態

BDMNG?BDMNG?QUAN?13?3?需求量

二、生產工單出口增強

PPCO0001

EXIT_SAPLCOBT_001

ZXCO1U01

check sy-tcode ne 'CO01'.

*&保存工單更改的歷史記錄
tables:caufv,resb.
data: begin of old_resb? occurs 0,? "更改后未保存之RESB.
???????? aufnr like resb-aufnr,
???????? posnr like resb-posnr,
???????? matnr like resb-matnr,
???????? rsnum like resb-rsnum,
???????? rspos like resb-rspos,
???????? xloek like resb-xloek,
???????? bdmng like resb-bdmng,
???????? objnr like resb-objnr,
???????? lgort like resb-lgort,
???????? end of old_resb.

data: begin of new_resb occurs 0.? "數據庫中的RESB.
??????? include structure old_resb.
data: end of new_resb.
data: begin of obj_resb occurs 0.? "插入的RESB
??????? include structure old_resb.
data: end of obj_resb.

data: i_zpco02 like zpco02 occurs 0 with header line.
data: i_temp?? like zpco02 occurs 0 with header line.

data: iporg like msxxlist-hostadr,
????? ipdec(16) type c,
????? host(18)? type c.
data: char1(20) type c,
????? char2(20) type c.


data: licl type c.

data: inst_flg type c value 'N',
????? chan_had type c value 'N'.
*????? teco_flg TYPE c VALUE 'N',
*????? read_flg TYPE c .
data: l_str type string.

data: i_msgty like sy-msgty.
data: tabix like sy-tabix.

*BREAK-POINT.

clear: i_temp, iporg, ipdec, host.
**? Get user IP,hostname
call function 'TH_USER_INFO'??? " Get user IP,hostname
? exporting
??? client?? = sy-mandt
??? user???? = sy-uname
? importing
??? hostaddr = iporg
??? terminal = host
? exceptions
??? others?? = 1.

**"Conv.IP addr to format 'xxx.xxx.xxx.xxx'
call function 'GWY_IPADR2STRING'? "Conv.IP addr
? exporting
??? ipadr?? = iporg
? importing
??? string? = ipdec.

***Common var.
move: sy-mandt to i_temp-mandt,
????? sy-uname to i_temp-aenam,
????? sy-datum to i_temp-laeda,
????? sy-uzeit to i_temp-times,
????? sy-tcode to i_temp-tcode,
???????? ipdec to i_temp-hostip,
????????? host to i_temp-host,
* { INCERT
????????? header_table-sttxt to i_temp-sttxt,? "工單狀態
* INCERT } DEVK905414 ADD:工單狀態取值
????????? header_table-aufnr to i_temp-aufnr.


***Check M/O header
select single gamng gltrp gstrp into (caufv-gamng, caufv-gltrp,caufv-gstrp)
???????? from caufv where aufnr eq header_table-aufnr.
**qty
if header_table-gamng ne caufv-gamng.
? move: caufv-gamng to char1, header_table-gamng to char2.
? move-corresponding i_temp to i_zpco02.
? move: '更改工單總數' to i_zpco02-filed,
??????? 'U'??????????? to i_zpco02-chnid,
??????? char1????????? to i_zpco02-value_old,
??????? char2????????? to i_zpco02-value_new.
? append i_zpco02.
? inst_flg = 'Y'.
? chan_had = 'Y'.
endif.
**增加開始日期修改記錄(MODIFY BY LU.X 2010.09.26)
if header_table-gstrp ne caufv-gstrp.
? move-corresponding i_temp to i_zpco02.
? move: '更改開始時間' to i_zpco02-filed,
??????? 'U'??????? to i_zpco02-chnid,
??????? caufv-gstrp??????? to i_zpco02-value_old,
??????? header_table-gstrp to i_zpco02-value_new.
? append i_zpco02.
? inst_flg = 'Y'.
endif.

if header_table-gltrp ne caufv-gltrp.
? move-corresponding i_temp to i_zpco02.
? move: '更改完成時間' to i_zpco02-filed,
??????? 'U'??????? to i_zpco02-chnid,
??????? caufv-gltrp??????? to i_zpco02-value_old,
??????? header_table-gltrp to i_zpco02-value_new.
? append i_zpco02.
? inst_flg = 'Y'.
endif.

?


if inst_flg = 'Y'.
? insert zpco02 from table i_zpco02 accepting duplicate keys.
? inst_flg = 'N'.
endif.

loop at component_table where vbkz eq 'U'
?????????????????????????? or vbkz eq 'I'
?????????????????????????? or vbkz eq 'D'.
? clear licl.
? case component_table-vbkz.
??? when 'I'.
????? move-corresponding i_temp to i_zpco02.
????? move: '新增組件' to i_zpco02-filed,
??????????? 'I'??????? to i_zpco02-chnid,
??????????? ''???????? to i_zpco02-value_old, "old_resb-matnr
??????????? component_table-matnr to i_zpco02-value_new,
??????????? '新增的組件'?? to i_zpco02-matnr,
*?????????? read_flg?????? TO i_zpco02-readf,
??????????? component_table-alpos to i_zpco02-alpos,
??????????? component_table-bdmng to i_zpco02-bdmng,
??????????? sy-tabix?????? to i_zpco02-loopid.
????? append i_zpco02.
????? inst_flg = 'Y'.

??? when 'D'.
????? move-corresponding i_temp to i_zpco02.
????? move: '刪除組件' to i_zpco02-filed,
??????????? 'D'??????? to i_zpco02-chnid,
??????????? resb-xloek to i_zpco02-value_old,
??????????? component_table-xloek to i_zpco02-value_new,
??????????? component_table-matnr to i_zpco02-matnr,
*??????????? read_flg?????? TO i_zpco02-readf,
??????????? component_table-alpos to i_zpco02-alpos,
??????????? sy-tabix?????? to i_zpco02-loopid.
????? append i_zpco02.
????? inst_flg = 'Y'.


??? when 'U'.
* { INCERT
????? if component_table-xloek is not initial.
* { INCERT
??????? search i_temp-sttxt for 'TECO'.
??????? case sy-subrc.
????????? when 4.
* } DEVK910121
??????????? move-corresponding i_temp to i_zpco02.
??????????? move: '刪除組件' to i_zpco02-filed,
????????????????? 'D'??????? to i_zpco02-chnid,
????????????????? resb-xloek to i_zpco02-value_old,
????????????????? component_table-xloek to i_zpco02-value_new,
????????????????? component_table-matnr to i_zpco02-matnr,
*??????????? read_flg?????? TO i_zpco02-readf,
????????????????? component_table-alpos to i_zpco02-alpos,
????????????????? sy-tabix?????? to i_zpco02-loopid.
??????????? append i_zpco02.
??????????? inst_flg = 'Y'.
* { INCERT
??????? endcase.
* } DEVK910121 忽略由工單關閉引起的組件刪除
????? else.
* INCERT } DEVK905414 FIX BUG:刪除組件無記錄
??????? select single matnr bdmng lgort into? (resb-matnr, resb-bdmng,resb-lgort)
???????????????? from resb? where aufnr eq component_table-aufnr
????????????????????????????? and posnr eq component_table-posnr
????????????????????????????? and matnr eq component_table-matnr
????????????????????????????? and rsnum eq component_table-rsnum
????????????????????????????? and rspos eq component_table-rspos.
??????? if component_table-matnr ne resb-matnr.
????????? move-corresponding i_temp to i_zpco02.
????????? move: '更改組件' to i_zpco02-filed,
??????????????? 'U'??????? to i_zpco02-chnid,
??????????????? resb-matnr to i_zpco02-value_old,
??????????????? component_table-matnr to i_zpco02-value_new,
??????????????? '更改的工單組件' to i_zpco02-matnr,
*???????????? read_flg?????? TO i_zpco02-readf,
??????????????? component_table-alpos to i_zpco02-alpos,
????????????????? sy-tabix?????? to i_zpco02-loopid.
????????? append i_zpco02.
????????? inst_flg = 'Y'.

??????? elseif component_table-bdmng ne resb-bdmng.
* { DELETE
*????????? CHECK chan_had NE 'Y'.
* DELETE } DEVK905414 FIX BUG:抬頭數量修改引起的組件數量修改無記錄
????????? move: component_table-bdmng to char1, resb-bdmng to char2.
????????? move-corresponding i_temp to i_zpco02.
????????? move: '需求數量' to i_zpco02-filed,
????????? 'U'?? to i_zpco02-chnid,
????????? char2 to i_zpco02-value_old,
????????? char1 to i_zpco02-value_new,
????????? component_table-matnr to i_zpco02-matnr,
*????? read_flg?????? TO i_zpco02-readf,
????????? component_table-alpos to i_zpco02-alpos,
????????? sy-tabix?????? to i_zpco02-loopid.
????????? append i_zpco02.
????????? inst_flg = 'Y'.
*????? wangkai 發料倉庫變更的記錄
??????? elseif component_table-lgort ne resb-lgort .
????????? move: component_table-lgort to char1, resb-lgort to char2.
????????? move-corresponding i_temp to i_zpco02.
????????? move: '發料倉庫' to i_zpco02-filed,
?????????? 'U'?? to i_zpco02-chnid,
?????????? char2 to i_zpco02-value_old,
?????????? char1 to i_zpco02-value_new,
?????????? component_table-matnr to i_zpco02-matnr,
*????? read_flg?????? TO i_zpco02-readf,
?????????? component_table-alpos to i_zpco02-alpos,
?????????? sy-tabix?????? to i_zpco02-loopid.
????????? append i_zpco02.
????????? inst_flg = 'Y'.
* { INCERT
??????? endif.
* INCERT } DEVK905414
????? endif.
? endcase.

endloop.

if inst_flg = 'Y'.
? insert zpco02 from table i_zpco02 accepting duplicate keys.
? if sy-subrc eq 0.
??? inst_flg = 'N'.
??? chan_had = 'N'.
??? free: i_zpco02.
??? clear: i_temp.
? endif.
endif.

三、查詢報表

REPORT? ZCOHS.
tables: zpco02, afko.
data: i_zpco02 like zpco02 occurs 0 with header line.
data: i_clear? like zpco02 occurs 0 with header line.
*data: i_aufnr
selection-screen begin of block block1 with frame. title text-001 .
select-options s_aufnr for? afko-aufnr."生產訂單
*SELECT-OPTIONS s_matnr FOR ZPCO02-MATNR.
select-options s_aenam for zpco02-aenam."更改者
select-options s_laeda for zpco02-laeda modif id gp2."修改日期
"PARAMETERS:??? p_clear AS CHECKBOX MODIF ID gp1.
selection-screen end of block block1 .

?

top-of-page.
? perform. write_header.

at selection-screen output.
? loop at screen.
??? if screen-group1 = 'GP1'.
????? screen-intensified = '1'.
????? modify screen.
????? continue.
??? endif.
? endloop.

*&---------------------------------------------------------------------*
*&?? Event START-OF-SELECTION
*&---------------------------------------------------------------------*
start-of-selection.

? perform. get_data.
*&---------------------------------------------------------------------*
*&?? Event END-OF-SELECTION
*&---------------------------------------------------------------------*
end-of-selection.
? perform. report_output.

?form. get_data .
? select zpco02~mandt zpco02~aufnr zpco02~matnr zpco02~filed zpco02~aenam zpco02~laeda zpco02~tcode
???????? zpco02~chnid zpco02~hostip zpco02~host zpco02~value_old zpco02~value_new zpco02~times zpco02~loopid
???????? zpco02~alpos zpco02~sttxt zpco02~bdmng
??? into corresponding fields of table i_zpco02
??? from zpco02
??? inner join afpo on zpco02~aufnr = afpo~aufnr
??? where? afpo~posnr = 1
????? and? afpo~elikz = ''
????? and? zpco02~aufnr in s_aufnr
????? and? zpco02~aenam in s_aenam
????? and? zpco02~laeda in s_laeda
????? .

? check i_zpco02[] is initial or sy-subrc eq 4.
? message id 'ZX' type 'S'
????????? number '000' with '沒有找到數據'.

endform.??????????????????? " get_data
*&---------------------------------------------------------------------*
*&????? Form? write_header
*&---------------------------------------------------------------------*
form. write_header .
? data: l_pos1 type i,
??????? l_pos2 type i,
??????? l_pos3 type i,
??????? l_title(33) type c value '工單更改歷史記錄'.
*?? CONCATENATE l_title v_bom_til INTO l_title.

? l_pos1 = sy-linsz / 2 - 15.
? l_pos2 = sy-linsz - 15.
? l_pos3 = l_pos2 + 6.
? skip 2.
? write /l_pos1 l_title.
? uline at /l_pos1(16).
? skip.
? write at: /(11) '生產訂單',
???????????? (16) '組件/表頭',
???????????? (16) '更改動作',
???????????? (20) '新字段值',
???????????? (20) '舊字段值',
???????????? (08) '替代',
???????????? (08) '需求數',
???????????? (08) '更改帳號',
???????????? (15) '更改者IP',
???????????? (10) '更改者PC',
???????????? (10) '更改日期',
???????????? (10) '更改時間',
* { INCERT
???????????? (35) '工單狀態'.
* INCERT } DEVK910078

? uline.
endform.??????????????????? " write_header
*&---------------------------------------------------------------------*
*&????? Form? report_output
*&---------------------------------------------------------------------*
*?????? text
*----------------------------------------------------------------------*
form. report_output .
* { REPLACE
*? SORT i_zpco02 BY aufnr aenam laeda.
? sort i_zpco02 by aufnr laeda times matnr.
* REPLACE } DEVK910078
? data qty(13) type c .
? loop at i_zpco02.
??? write at: /(11) i_zpco02-aufnr ,? " '生產訂單',
?????????????? (16) i_zpco02-matnr ,? "? '物料號碼',
?????????????? (16) i_zpco02-filed .? "? '更改動作',
* { INCERT
??? set left scroll-boundary.
* INCERT } DEVK910078
??? if i_zpco02-filed = '新增組件' .
????? qty = i_zpco02-bdmng .
??? else .
????? qty = ''.
?? endif .
????? write at:? (20) i_zpco02-value_new
????????????????????? color 2,? "? '新字段值',
???????????????? (20) i_zpco02-value_old
????????????????????? color 3,? "? '舊字段值',
???????????????? (08) i_zpco02-alpos
????????????????????? color 4,
???????????????? (08) qty
????????????????????? color 5,????????? "? '需求數'
???????????????? (08) i_zpco02-aenam ,? "? '更改帳號',
???????????????? (15) i_zpco02-hostip , "? '更改者IP',
???????????????? (10) i_zpco02-host ,?? "? '更改者PC',
???????????????? (10) i_zpco02-laeda ,? "? '更改日期',
???????????????? (10) i_zpco02-times ,? "? '更改時間'.
???????????????? (35) i_zpco02-sttxt.? "'工單狀態'.

??? endloop.

? endform.??????????????????? " report_output

轉載于:https://www.cnblogs.com/yanglikun/p/4078615.html

總結

以上是生活随笔為你收集整理的工单更改历史记录(轉載)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。