*&---------------------------------------------------------------------*
*& Report ZRMM007
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zmm220.
TYPE-POOLS: slis.
TABLES:afko,afpo,ztbzps,zrmm220t1,resb,mard,sscrfields.
INCLUDE zrmm220_zcd. "轉(zhuǎn)儲單數(shù)據(jù)
*一、數(shù)據(jù)聲明
DATA: BEGIN OF item OCCURS 0,
werks LIKE resb-werks, "工廠
zdydh LIKE zrmm220t1-zdydh, "配送單號
aufnr LIKE afko-aufnr, "生產(chǎn)訂單
lgort LIKE afpo-lgort, "車間庫---接收庫存地
lgobe LIKE t001l-lgobe,
rsnum LIKE resb-rsnum, "預留號
rspos LIKE resb-rspos,
matnr LIKE resb-matnr, "物料
maktx LIKE makt-maktx, "物料描述
bdmng LIKE resb-bdmng, "需求數(shù)量
menge LIKE zrmm220t1-menge, "實收數(shù)量
meins LIKE resb-meins, "單位
sortf LIKE resb-sortf, "排序字符串
zbanz(10), "班組
zgwei(10), "工位
lgfsb LIKE marc-lgfsb, "二級庫----原來:外部采購倉儲地點 = 發(fā)出庫存地
lgfse LIKE t001l-lgobe,
lgpbe LIKE mard-lgpbe, "存儲倉位/庫管員
zbzmg LIKE ztbzps-zbzmg, "標準配送量
zrept(10),
wempf LIKE resb-wempf, "備注
zbez(40),
zzzt(4),
rtp04 LIKE afpo-rtp04, "合并標示
xloek LIKE resb-xloek,"刪除標示
beskz LIKE marc-beskz,
ablad LIKE resb-ablad,
dispo LIKE afko-dispo, "MRP控制者
umlgo LIKE marc-lgfsb, "寄售庫
lifnr LIKE lfa1-lifnr, "
sortl LIKE lfa1-sortl,
name1 LIKE lfa1-name1,
aufn2 LIKE zrmm220t1-aufn2,
chck,
END OF item.
DATA: gd_repid LIKE sy-repid.
DATA: i_grid_settings TYPE lvc_s_glay .
DATA: zt_h LIKE TABLE OF item WITH HEADER LINE.
*DATA: lt_wempf LIKE TABLE OF item WITH HEADER LINE.
DATA: itab LIKE TABLE OF item WITH HEADER LINE.
DATA: lt_et LIKE TABLE OF item WITH HEADER LINE.
DATA: wa_h LIKE item.
DATA: itac LIKE TABLE OF item WITH HEADER LINE.
DATA: l_aufnr LIKE afko-aufnr, "第一個工單
l_i(2)."如果輸入范圍差值
DATA: BEGIN OF it_header OCCURS 0,
zbanz LIKE zrmm220t1-zbanz,
umlgo LIKE zrmm220t1-umlgo,
lgpbe LIKE zrmm220t1-lgpbe,
lgort LIKE zrmm220t1-lgort,
END OF it_header.
DATA:gt_dynfields LIKE TABLE OF dynpread WITH HEADER LINE.
DATA:t_line LIKE TABLE OF tline WITH HEADER LINE,
p_tdname LIKE stxl-tdname.
DATA: afield TYPE slis_fieldcat_alv.
DATA: fieldcat TYPE TABLE OF slis_fieldcat_alv WITH HEADER LINE.
DATA: layout TYPE slis_layout_alv,
i_grid_title TYPE lvc_title.
DATA: l_pos TYPE i VALUE 1,p_i TYPE i.
DATA: gv_filename TYPE rlgrap-filename.
DATA: l_zbzmg LIKE ztbzps-zbzmg,l_num TYPE i,p_num TYPE i,l_con(30),z_num TYPE numc4,l_zdydh LIKE zrmm220t1-zdydh,o_num TYPE numc3.
DATA: g_cmd LIKE sy-ucomm.
DATA: s_i(40) TYPE c.
DATA: l_gd10 TYPE i."工單超過10個報錯
DATA: zzxrq LIKE sy-datum.
DATA: zzxsj LIKE sy-uzeit.
DATA: l_line LIKE bsvx-sttxt.
DATA: l_objnr LIKE aufk-objnr.
DATA: l_data LIKE sy-datum.
*宏的定義
DEFINE fill.
afield-col_pos = l_pos.
afield-fieldname = &1.
afield-seltext_l = &2.
afield-no_zero = &3.
afield-key = &4.
afield-edit = &5.
append afield to fieldcat.
clear afield.
l_pos = l_pos + 1.
END-OF-DEFINITION.
*二、聲明查詢屏幕
SELECTION-SCREEN FUNCTION KEY 1 .
SELECTION-SCREEN BEGIN OF BLOCK radio WITH FRAME TITLE text-001.
PARAMETERS: p1 RADIOBUTTON GROUP rad1 USER-COMMAND sele DEFAULT 'X' ,
p2 RADIOBUTTON GROUP rad1 .
SELECTION-SCREEN END OF BLOCK radio.
SELECTION-SCREEN BEGIN OF BLOCK blc WITH FRAME TITLE text-002.
PARAMETERS: r1 RADIOBUTTON GROUP rad2 DEFAULT 'X' MODIF ID m1 ,
r2 RADIOBUTTON GROUP rad2 MODIF ID m1 .
SELECTION-SCREEN SKIP.
PARAMETER: p_werks LIKE resb-werks DEFAULT '6000' .
SELECT-OPTIONS : s_zdydh FOR zrmm220t1-zdydh MODIF ID m2.
SELECT-OPTIONS : s_aufnr FOR afko-aufnr MODIF ID m1,
s_dispo FOR afko-dispo NO-EXTENSION NO INTERVALS MODIF ID m1,
s_umlgo FOR resb-lgort NO-EXTENSION NO INTERVALS MODIF ID m1,
s_lgpbe FOR mard-lgpbe MODIF ID m1,
s_zbanz FOR zrmm220t1-zbanz MODIF ID m1, "班組
s_matnr FOR resb-matnr MODIF ID m1,
s_sortf FOR resb-sortf MODIF ID m1.
SELECTION-SCREEN END OF BLOCK blc.
SELECTION-SCREEN BEGIN OF SCREEN 1001 AS WINDOW .
PARAMETER p_aufnr LIKE afko-aufnr.
SELECTION-SCREEN END OF SCREEN 1001.
INITIALIZATION.
sscrfields-functxt_01 = '查詢工單組合'.
AT SELECTION-SCREEN .
CASE sscrfields-ucomm . "
WHEN 'FC01'.
PERFORM searchaufnr.
ENDCASE.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
CASE screen-group1.
WHEN 'M1'.
IF p1 = 'X'.
screen-active = '1'.
ELSE.
screen-active = '0'.
ENDIF.
WHEN 'M2'.
IF p1 = 'X'.
screen-active = '0'.
ELSE.
screen-active = '1'.
ENDIF.
ENDCASE.
MODIFY SCREEN.
ENDLOOP.
START-OF-SELECTION.
IF p1 = 'X'.
IF p_werks IS INITIAL OR s_aufnr IS INITIAL OR s_dispo IS INITIAL OR s_umlgo IS INITIAL.
MESSAGE s001(00) WITH '工廠竟闪、生產(chǎn)訂單隙赁、MRP控制者、發(fā)出庫存地需要輸入' DISPLAY LIKE 'E'.
EXIT.
ENDIF.
SELECT * FROM afko WHERE dispo <> s_dispo-low AND aufnr IN s_aufnr.
IF sy-subrc = 0.
MESSAGE s001(00) WITH '生產(chǎn)訂單中存在不同的MRP控制者披蕉,不允許打印' DISPLAY LIKE 'E'.
RETURN.
ENDIF.
ENDSELECT.
ENDIF.
IF p2 = 'X'.
IF p_werks IS INITIAL OR s_zdydh IS INITIAL.
MESSAGE s001(00) WITH '工廠颈畸、單據(jù)號需要輸入' DISPLAY LIKE 'E'.
EXIT.
ENDIF.
ENDIF.
IF p1 = 'X'.
PERFORM frm_get_data1. "獲取數(shù)據(jù)
IF l_gd10 > 20.
MESSAGE s001(00) WITH '已經(jīng)超出20個生產(chǎn)訂單,請重新合并生產(chǎn)訂單' DISPLAY LIKE 'E'.
RETURN.
ENDIF.
LOOP AT item.
"檢查預留庫存地點
IF item-lgort = ''.
MESSAGE s001(00) WITH '生產(chǎn)訂單中物料:' item-matnr '没讲,沒有接收庫存地點眯娱,請聯(lián)系生產(chǎn)物控部維護!' DISPLAY LIKE 'E'.
RETURN.
ENDIF.
ENDLOOP.
IF lt_et[] IS NOT INITIAL.
PERFORM frm_show_data.
ENDIF.
ELSE.
PERFORM frm_get_data2. "獲取數(shù)據(jù)
ENDIF.
IF ( item[] IS NOT INITIAL OR it_save[] IS NOT INITIAL ) AND lt_et[] IS INITIAL.
IF p1 = 'X'.
PERFORM frm_get_jskc. "獲取寄售可用庫存
PERFORM frm_process_data.
PERFORM frm_show_mx. "顯示分配供應商寄售庫存的明細數(shù)據(jù)
ELSE.
PERFORM printdata USING 'ZMM220'. "調(diào)用sf
ENDIF.
ELSE.
MESSAGE s001(00) WITH '沒有查詢到數(shù)據(jù)'.
ENDIF.
*&---------------------------------------------------------------------*
*& Form FRM_GET_DATA1
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_get_data1 .
SELECT afko~aufnr afpo~pwerk AS werks resb~lgort "afpo~rtp04
resb~rsnum resb~rspos resb~matnr resb~bdmng resb~meins resb~sortf resb~wempf resb~xloek
marc~lgfsb marc~beskz resb~ablad afko~dispo
INTO CORRESPONDING FIELDS OF TABLE item
FROM afko
INNER JOIN afpo ON ( afko~aufnr = afpo~aufnr AND afpo~posnr = '0001' )
INNER JOIN resb ON ( afko~rsnum = resb~rsnum AND resb~werks = afpo~pwerk )"AND resb~xloek = '' )
INNER JOIN marc ON ( marc~matnr = resb~matnr AND marc~werks = afpo~pwerk )
WHERE afpo~pwerk = p_werks AND afko~aufnr IN s_aufnr
AND resb~matnr IN s_matnr
AND marc~beskz IN ('F','X')
AND afko~dispo IN s_dispo
AND marc~loggr <> 'A1'
"AND resb~WEMPF = ''
AND resb~sortf IN s_sortf.
SORT item BY werks aufnr matnr.
DELETE item WHERE beskz = 'X' AND ablad <> '外購' OR wempf IS NOT INITIAL.
SELECT * FROM afko
WHERE aufnr IN s_aufnr.
l_gd10 = l_gd10 + 1.
ENDSELECT.
SORT s_aufnr BY low.
READ TABLE s_aufnr INDEX 1.
l_aufnr = s_aufnr-low."第一個工單(最小工單)作為合并后唯一識別的工單
CLEAR:itac,itac[].
LOOP AT item.
IF item-aufnr IS NOT INITIAL.
SELECT SINGLE aufk~objnr INTO l_objnr FROM aufk WHERE aufnr = item-aufnr.
CHECK sy-subrc EQ 0.
CALL FUNCTION 'STATUS_TEXT_EDIT'
EXPORTING
objnr = l_objnr
spras = sy-langu
IMPORTING
line = l_line
EXCEPTIONS
object_not_found = 01.
SEARCH l_line FOR 'TECO'.
IF sy-subrc = 0.
l_line = l_line+sy-fdpos(4).
item-zzzt = l_line.
ENDIF.
ENDIF.
MODIFY item.
ENDLOOP.
DELETE item WHERE zzzt = '' AND xloek = 'X'.
LOOP AT item.
itac-aufn2 = l_aufnr.
itac-werks = item-werks.
itac-lgort = item-lgort .
itac-matnr = item-matnr .
itac-maktx = item-maktx .
itac-bdmng = item-bdmng .
itac-meins = item-meins .
itac-sortf = item-sortf .
itac-zgwei = item-zgwei .
CASE item-lgort.
WHEN '2001'.
itac-lgfsb = '2005'.
WHEN '2002'.
itac-lgfsb = '2006'.
WHEN '2003'.
itac-lgfsb = '2007'.
WHEN '2004'.
itac-lgfsb = '2008'.
WHEN '2009'.
itac-lgfsb = '2010'.
ENDCASE.
COLLECT itac.
CLEAR itac. """"""""""""""""""""""""""
ENDLOOP.
CLEAR:item,item[].
APPEND LINES OF itac TO item.
""""""""""""""""""""""""""""""""""""""""""""""""""""""
LOOP AT item.
*獲取其他字段
SELECT SINGLE * FROM ztbzps
WHERE werks = item-werks AND matnr = item-matnr.
IF r1 = 'X'.
IF sy-subrc = 0.
DELETE item.
CONTINUE.
ENDIF.
ELSE.
IF sy-subrc <> 0.
DELETE item.
CONTINUE.
ENDIF.
ENDIF.
*物料描述
SELECT SINGLE maktx INTO item-maktx
FROM makt WHERE matnr = item-matnr AND spras = '1'.
*班組/工位
* SPLIT item-sortf AT '/' INTO item-zbanz item-zgwei.
*工位
item-zgwei = item-sortf.
*班組
SELECT SINGLE zbanz INTO item-zbanz
FROM ztbzgw WHERE werks = item-werks AND lgort = item-lgort
AND zgwei = item-zgwei.
*倉管員
item-umlgo = s_umlgo-low.
SELECT SINGLE lgpbe INTO item-lgpbe
FROM mard WHERE matnr = item-matnr AND werks = item-werks
AND lgort = item-umlgo.
MODIFY item.
MOVE-CORRESPONDING item TO zt_h.
CLEAR:zt_h-rspos,zt_h-wempf.
COLLECT zt_h.
* lt_wempf-aufnr = item-aufnr.
* lt_wempf-zgwei = item-sortf.
* lt_wempf-matnr = item-matnr.
* lt_wempf-wempf = item-wempf.
* COLLECT lt_wempf.
*錯誤數(shù)據(jù)
lt_et-matnr = item-matnr.
lt_et-maktx = item-maktx.
lt_et-sortf = item-sortf.
lt_et-lgfsb = item-umlgo.
lt_et-lgpbe = item-lgpbe.
IF lt_et-sortf IS INITIAL OR lt_et-lgpbe IS INITIAL.
COLLECT lt_et.
ELSE.
ENDIF.
CLEAR:lt_et,zt_h.
ENDLOOP.
IF s_lgpbe IS NOT INITIAL.
DELETE zt_h WHERE lgpbe NOT IN s_lgpbe.
DELETE item WHERE lgpbe NOT IN s_lgpbe.
ENDIF.
IF s_zbanz IS NOT INITIAL.
DELETE zt_h WHERE zbanz NOT IN s_zbanz.
DELETE item WHERE zbanz NOT IN s_zbanz.
ENDIF.
ENDFORM. " FRM_GET_DATA1
*&---------------------------------------------------------------------*
*& Form FRM_SHOW_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_show_data .
i_grid_settings-edt_cll_cb = 'X' . "顯示界面可編輯字段上修改了數(shù)據(jù)爬凑,回車后就會立即將內(nèi)表的數(shù)據(jù)也修改
layout-colwidth_optimize = 'X'. "設置字段列寬自適應
layout-zebra = 'X'.
i_grid_title = '物料錯誤信息'.
CLEAR afield.
REFRESH fieldcat.
fill 'MATNR' '物料編碼' 'X' 'X' ''.
fill 'MAKTX' '物料描述' '' '' ''.
fill 'SORTF' '排序字符串' '' '' ''.
fill 'LGFSB' '發(fā)出庫存地' 'X' '' ''.
fill 'LGPBE' '倉管員' '' '' ''.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_grid_settings = i_grid_settings "顯示界面可編輯字段上修改了數(shù)據(jù)徙缴,回車后就會立即將內(nèi)表的數(shù)據(jù)也修改
i_callback_program = sy-cprog "sy-repid "標記當前程序
it_fieldcat = fieldcat[]
is_layout = layout
i_grid_title = i_grid_title
* i_callback_user_command = 'USER_COMMAND'
TABLES
t_outtab = lt_et.
ENDFORM. " FRM_SHOW_DATA
*&---------------------------------------------------------------------*
*& Form FRM_GET_DATA2
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_get_data2 .
SELECT * INTO CORRESPONDING FIELDS OF TABLE it_save
FROM zrmm220t1
WHERE werks = p_werks AND zdydh IN s_zdydh.
"AND mblnr = ''
"AND xloek = ''.
LOOP AT it_save.
SELECT SINGLE maktx INTO it_save-makts
FROM makt WHERE matnr = it_save-matnr AND spras = '1'.
SELECT SINGLE sortl INTO it_save-sortl
FROM lfa1 WHERE lifnr = it_save-lifnr.
MODIFY it_save TRANSPORTING makts sortl.
ENDLOOP.
ENDFORM. " FRM_GET_DATA2
*&---------------------------------------------------------------------*
*& Form FRM_PROCESS_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_process_data .
IF p1 = 'X'.
CLEAR:zt_save,zt_save[].
LOOP AT zt_h.
SELECT * FROM zrmm220t1
WHERE aufn2 = zt_h-aufn2 AND matnr = zt_h-matnr
AND zbanz = zt_h-zbanz
AND lgort = zt_h-lgort
AND zgwei = zt_h-zgwei
AND xloek = ''.
IF zrmm220t1-psgz IS INITIAL.
IF zrmm220t1-zcdhgz IS INITIAL. "轉(zhuǎn)儲未過帳
zt_h-bdmng = zt_h-bdmng - zrmm220t1-bdmng.
ELSE.
zt_h-bdmng = zt_h-bdmng - zrmm220t1-menge.
ENDIF.
ELSE.
zt_h-bdmng = zt_h-bdmng - zrmm220t1-menge.
ENDIF.
ENDSELECT.
IF zt_h-bdmng <= 0.
DELETE zt_h.
CONTINUE.
ENDIF.
ENDLOOP.
LOOP AT it_save.
MOVE-CORRESPONDING it_save TO zt_save.
LOOP AT zt_h WHERE matnr = it_save-matnr.
IF zt_h-bdmng > it_save-bdmng.
zt_save-zbanz = zt_h-zbanz.
zt_save-zgwei = zt_h-zgwei.
zt_save-makts = zt_h-maktx.
zt_save-lgfsb = zt_h-lgfsb.
zt_save-lgort = zt_h-lgort.
zt_save-bdmng = it_save-bdmng.
SELECT SINGLE name1 sortl INTO (zt_save-name1,zt_save-sortl)
FROM lfa1 WHERE lifnr = it_save-lifnr.
APPEND zt_save.
DELETE it_save.
zt_h-bdmng = zt_h-bdmng - it_save-bdmng.
MODIFY zt_h TRANSPORTING bdmng.
EXIT.
ELSE.
zt_save-zbanz = zt_h-zbanz.
zt_save-zgwei = zt_h-zgwei.
zt_save-makts = zt_h-maktx.
zt_save-name1 = zt_h-sortl.
zt_save-lgfsb = zt_h-lgfsb.
zt_save-lgort = zt_h-lgort.
zt_save-bdmng = zt_h-bdmng.
SELECT SINGLE name1 sortl INTO (zt_save-name1,zt_save-sortl)
FROM lfa1 WHERE lifnr = it_save-lifnr.
APPEND zt_save.
DELETE zt_h.
it_save-bdmng = it_save-bdmng - zt_h-bdmng.
IF it_save-bdmng = 0.
EXIT.
ENDIF.
ENDIF.
ENDLOOP.
ENDLOOP.
CLEAR:it_save[].
it_save[] = zt_save[].
ENDIF.
ENDFORM. " FRM_PROCESS_DATA
*&---------------------------------------------------------------------*
*& Form SEARCHAUFNR
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM searchaufnr .
DATA: lt_fldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE.
CALL SELECTION-SCREEN 1001 STARTING AT 40 5 .
CHECK sy-subrc = 0 .
SELECT DISTINCT zjsdh INTO TABLE it_zjsdh FROM zrmm220t2
WHERE zrmm220t2~aufnr = p_aufnr.
IF it_zjsdh[] IS NOT INITIAL.
SELECT DISTINCT aufnr INTO TABLE yt_aufnr FROM zrmm220t2
FOR ALL ENTRIES IN it_zjsdh
WHERE zjsdh = it_zjsdh-zjsdh.
SORT yt_aufnr.
lt_fldcat-fieldname = 'AUFNR'.
lt_fldcat-seltext_l = '生產(chǎn)訂單'.
APPEND lt_fldcat.
CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
EXPORTING
i_title = '合并打印的生產(chǎn)訂單'
i_tabname = ''
i_selection = ''
it_fieldcat = lt_fldcat[]
i_screen_start_column = 40
i_screen_start_line = 5
TABLES
t_outtab = yt_aufnr
EXCEPTIONS
program_error = 1
OTHERS = 2.
ELSE.
MESSAGE s000(oo) WITH '沒有找到'.
ENDIF.
ENDFORM. " SEARCHAUFNR
INCLUDE zmm220_frm_get_jskcf01.
*&---------------------------------------------------------------------*
*& Form FRM_SHOW_MX
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_show_mx .
slayt-colwidth_optimize = 'X'.
slayt-zebra = 'X'.
slayt-info_fieldname = 'COLOR'.
repid = sy-repid.
varnt-report = sy-repid.
varnt-handle = 1.
SET TITLEBAR 'T100' WITH '寄售轉(zhuǎn)儲單打印程序'.
PERFORM catlg_set USING: 'AUFNR' '訂單號',
'RSNUM' '預留編號',
'RSPOS' '項目',
'MATNR' '物料號',
'WERKS' '工廠',
'LGFSB' '二級庫',
'LGORT' '車間庫',
'BDMNG' '需求量',
'MEINS' '單位',
'XLOEK' '已刪除項目',
'STAT ' '對象狀態(tài)',
'ABLAD' '是否外購',
'DISPO' 'MRP控制者',
'BESKZ' '采購類型',
'LGPBE' '倉管員',
'QUNUM' '配額編號'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = repid
it_fieldcat = it_fldcat[]
i_save = 'A'
is_variant = varnt
is_layout = slayt
i_callback_user_command = 'USER_COMMAND1'
i_callback_pf_status_set = 'SET_STATUS1'
TABLES
t_outtab = it_resb[].
ENDFORM. " FRM_SHOW_MX
*---------------------------------------------------------------------*
* FORM frm_catlg_set *
*---------------------------------------------------------------------*
FORM catlg_set USING p_field
p_text.
DATA: ls_fieldcat TYPE slis_fieldcat_alv.
ls_fieldcat-fieldname = p_field.
ls_fieldcat-seltext_l = p_text.
IF ls_fieldcat-fieldname = 'MENGE' OR
ls_fieldcat-fieldname = 'BDMNG'.
ls_fieldcat-qfieldname = 'MEINS'.
ELSEIF ls_fieldcat-fieldname = 'TBTWR'.
ls_fieldcat-cfieldname = 'WAERS'.
ELSEIF ls_fieldcat-fieldname = 'AUFNR' OR
ls_fieldcat-fieldname = 'LIFNR' .
ls_fieldcat-edit_mask = '==ALPHA'.
ELSEIF ls_fieldcat-fieldname = 'MATNR'.
ls_fieldcat-edit_mask = '==MATN1'.
ELSEIF ls_fieldcat-fieldname = 'MEINS' .
ls_fieldcat-edit_mask = '==CUNIT'.
ENDIF.
APPEND ls_fieldcat TO it_fldcat .
CLEAR ls_fieldcat .
ENDFORM. "frm_catlg_set
*&--------------------------------------------------------------------*
*& Form user_command1
*&--------------------------------------------------------------------*
FORM user_command1 USING r_ucomm LIKE sy-ucomm
rs_selfld TYPE slis_selfield.
READ TABLE it_resb INDEX rs_selfld-tabindex.
CASE r_ucomm.
WHEN '&IC1'. "雙擊
CASE rs_selfld-fieldname.
WHEN 'QUNUM'.
SET PARAMETER ID 'WRK' FIELD it_resb-werks.
SET PARAMETER ID 'MAT' FIELD it_resb-matnr.
CALL TRANSACTION 'MEQ3' AND SKIP FIRST SCREEN.
WHEN 'AUFNR'.
SET PARAMETER ID 'ANR' FIELD it_resb-aufnr.
CALL TRANSACTION 'CO03' AND SKIP FIRST SCREEN .
ENDCASE.
WHEN 'HEBING'.
PERFORM hebing.
WHEN 'EXIT'.
LEAVE PROGRAM.
ENDCASE.
ENDFORM. "user_com
*&--------------------------------------------------------------------*
*& Form set_status
*&--------------------------------------------------------------------*
FORM set_status1 USING rt_extab TYPE slis_t_extab.
IF disable = 'X'.
APPEND 'HEBING' TO rt_extab .
ENDIF.
SET PF-STATUS 'STANDARD' EXCLUDING rt_extab .
ENDFORM. "set_status1
*&---------------------------------------------------------------------*
*& Form HEBING
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM hebing .
PERFORM frm_get_xc.
* slayt-colwidth_optimize = 'X'.
* slayt-zebra = 'X'.
* slayt-info_fieldname = 'COLOR'.
* repid = sy-repid.
* varnt-report = sy-repid.
* varnt-handle = 2.
* SET TITLEBAR 'T100' WITH '寄售轉(zhuǎn)儲單合并'.
*
* CLEAR it_fldcat[].
* PERFORM catlg_set USING: 'CHCK' '選擇',
* 'LIFNR' '供應商',
* 'NAME1' '供應商名稱',
* 'WERKS' '工廠',
* 'UMLGO' '發(fā)出庫',
* 'LGFSB' '二級庫',
* 'LGORT' '車間庫',
* 'LGPBE' '倉管員',
* 'ZBANZ' '班組',
* 'ZGWEI' '工位',
* 'MATNR' '物料號 ',
* 'MAKTS' '物料描述',
* 'AUFN2' '訂單號 ',
* 'BDMNG' '需求量',
* 'MEINS' '單位'.
*
* LOOP AT it_fldcat.
* IF it_fldcat-fieldname = 'CHCK'.
* it_fldcat-edit = 'X'.
* it_fldcat-checkbox = 'X'.
* ENDIF.
* MODIFY it_fldcat.
* ENDLOOP.
* CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
* EXPORTING
* i_callback_program = repid
* it_fieldcat = it_fldcat[]
* i_save = 'A'
* is_variant = varnt
* is_layout = slayt
* i_callback_user_command = 'USER_COMMAND2'
* i_callback_pf_status_set = 'SET_STATUS2'
* TABLES
* t_outtab = it_save_et.
CLEAR it_fieldcat[].
i_grid_settings-edt_cll_cb = 'X' .
gd_layout-stylefname = 'FIELD_STYLE'.
gd_layout-cwidth_opt = 'X'.
gd_layout-zebra = 'X'.
wa_fieldcat-fieldname = 'CHCK'.
wa_fieldcat-scrtext_m = '選擇'.
wa_fieldcat-edit = 'X'.
wa_fieldcat-checkbox = 'X'.
wa_fieldcat-col_pos = 0.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'LIFNR'.
wa_fieldcat-scrtext_m ='供應商'.
wa_fieldcat-col_pos = 1.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname ='NAME1'.
wa_fieldcat-scrtext_m = '供應商名稱'.
wa_fieldcat-col_pos = 2.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'WERKS'.
wa_fieldcat-scrtext_m = '工廠'.
wa_fieldcat-col_pos = 3.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'UMLGO'.
wa_fieldcat-scrtext_m = '發(fā)出庫'.
wa_fieldcat-col_pos = 4.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'LGFSB'.
wa_fieldcat-scrtext_m = '二級庫'.
wa_fieldcat-col_pos = 5.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'LGORT'.
wa_fieldcat-scrtext_m = '車間庫'.
wa_fieldcat-col_pos = 6.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'LGPBE'.
wa_fieldcat-scrtext_m = '倉管員'.
wa_fieldcat-col_pos = 7.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'ZBANZ'.
wa_fieldcat-scrtext_m = '班組'.
wa_fieldcat-col_pos = 8.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'ZGWEI'.
wa_fieldcat-scrtext_m = '工位'.
wa_fieldcat-col_pos = 9.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-scrtext_m = '物料號 '.
wa_fieldcat-col_pos = 10.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MAKTS'.
wa_fieldcat-scrtext_m = '物料描述'.
wa_fieldcat-col_pos = 11.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'AUFN2'.
wa_fieldcat-scrtext_m = '訂單號 '.
wa_fieldcat-col_pos = 12.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'BDMNG'.
wa_fieldcat-scrtext_m = '需求量'.
wa_fieldcat-no_zero = 'X'.
wa_fieldcat-qfieldname = 'MEINS'.
wa_fieldcat-inttype = 'X'.
wa_fieldcat-col_pos = 13.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MEINS'.
wa_fieldcat-scrtext_m = '單位'.
wa_fieldcat-col_pos = 14.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_grid_settings = i_grid_settings
i_callback_program = sy-cprog
is_layout_lvc = gd_layout
it_fieldcat_lvc = it_fieldcat
i_save = 'X'
i_callback_pf_status_set = 'SET_STATUS2'
i_callback_user_command = 'USER_COMMAND2'
"it_events = gt_events "注冊回車事件
TABLES
t_outtab = it_save_et
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM.
*&--------------------------------------------------------------------*
*& Form user_command
*&--------------------------------------------------------------------*
FORM user_command2 USING r_ucomm LIKE sy-ucomm
rs_selfld TYPE slis_selfield.
rs_selfld-refresh = 'X'.""""""""""""""""""""""""""""""""
DATA: lr_grid TYPE REF TO cl_gui_alv_grid.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = lr_grid.
CALL METHOD lr_grid->check_changed_data.
READ TABLE it_resb INDEX rs_selfld-tabindex.
CASE r_ucomm.
WHEN '&IC1'. "雙擊
CASE rs_selfld-fieldname.
WHEN ''.
ENDCASE.
WHEN 'SAVEPRINT'.
READ TABLE it_save_et WITH KEY chck = 'X'.
IF sy-subrc <> 0.
MESSAGE s000(oo) WITH '至少選擇一行'.
EXIT.
ENDIF.
CLEAR: it_save,it_save[].
LOOP AT it_save_et.
MOVE-CORRESPONDING it_save_et to it_save.
APPEND it_save.
CLEAR: it_save_et,it_save.
ENDLOOP.
PERFORM savedata.
PERFORM printdata USING 'ZMM220'.
LEAVE PROGRAM.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN '&ZALL'.
LOOP AT it_save_et WHERE chck IS INITIAL.
it_save_et-chck = 'X'.
MODIFY it_save_et TRANSPORTING chck.
ENDLOOP.
WHEN '&ZSAL'.
LOOP AT it_save_et WHERE chck IS NOT INITIAL.
it_save_et-chck = ''.
MODIFY it_save_et TRANSPORTING chck.
ENDLOOP.
ENDCASE.
ENDFORM. "user_com
*&--------------------------------------------------------------------*
*& Form set_status
*&--------------------------------------------------------------------*
FORM set_status2 USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'STANDARD2' EXCLUDING rt_extab .
ENDFORM. "set_status
*&---------------------------------------------------------------------*
*& Form SAVEDATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM savedata .
DATA: numc(4) TYPE n.
DELETE it_save WHERE chck = ''.
SORT it_save .
CLEAR:it_header[],zt_save[],zt_save.
LOOP AT it_save.
it_header-zbanz = it_save-zbanz.
it_header-umlgo = it_save-umlgo.
it_header-lgpbe = it_save-lgpbe.
it_header-lgort = it_save-lgort.
COLLECT it_header.
ENDLOOP.
LOOP AT it_header.
IF r1 = 'X'.
CALL FUNCTION 'ZNUMC4_GET_NEXT'
EXPORTING
subobject = '02'
IMPORTING
number = numc
EXCEPTIONS
OTHERS = 9.
l_zdydh = 'ZP' && sy-datum+2(6) && numc.
LOOP AT it_save WHERE zbanz = it_header-zbanz AND lgort = it_header-lgort AND lgpbe = it_header-lgpbe. "
MOVE-CORRESPONDING it_save TO zt_save.
zt_save-zdydh = l_zdydh.
APPEND zt_save.
CLEAR zt_save.
ENDLOOP.
ELSE.
CLEAR:p_num,mt_save,mt_save[].
LOOP AT it_save WHERE zbanz = it_header-zbanz AND lgort = it_header-lgort AND lgpbe = it_header-lgpbe. "每個分組下最大的重復次數(shù)
CLEAR l_zbzmg.
SELECT SINGLE zbzmg INTO l_zbzmg
FROM ztbzps WHERE werks = it_save-werks AND matnr = it_save-matnr.
IF l_zbzmg > 0.
l_num = ceil( it_save-bdmng / l_zbzmg ).
DO l_num TIMES.
MOVE-CORRESPONDING it_save TO mt_save.
mt_save-bdmng = l_zbzmg.
IF l_num = sy-index.
mt_save-bdmng = it_save-bdmng MOD l_zbzmg.
IF mt_save-bdmng = 0. "整除的情況
mt_save-bdmng = l_zbzmg.
ENDIF.
ENDIF.
mt_save-znumc = sy-index.
APPEND mt_save.
CLEAR mt_save.
ENDDO.
ELSE.
l_num = 1.
MOVE-CORRESPONDING it_save TO mt_save.
mt_save-znumc = 1.
APPEND mt_save.
CLEAR mt_save.
ENDIF.
IF l_num > p_num.
p_num = l_num.
ENDIF.
ENDLOOP.
DO p_num TIMES.
CALL FUNCTION 'ZNUMC4_GET_NEXT'
EXPORTING
subobject = '02'
IMPORTING
number = numc
EXCEPTIONS
OTHERS = 9.
l_zdydh = 'ZP' && sy-datum+2(6) && numc.
o_num = sy-index.
LOOP AT mt_save WHERE znumc = o_num.
mt_save-zdydh = l_zdydh.
MODIFY mt_save TRANSPORTING zdydh.
ENDLOOP.
ENDDO.
APPEND LINES OF mt_save TO zt_save.
ENDIF.
ENDLOOP.
SORT zt_save BY werks zdydh zbanz lgpbe zgwei matnr.
CLEAR:it_save,it_save[],it_header,it_header[].
it_save[] = zt_save[].
CALL FUNCTION 'ZNUMC4_GET_NEXT'
EXPORTING
subobject = '02'
IMPORTING
number = numc
EXCEPTIONS
OTHERS = 9.
it_resb-zjsdh = zjsdh = it_save-zjsdh = sy-datum && numc.
MODIFY it_resb TRANSPORTING zjsdh WHERE zjsdh = ''.
MODIFY it_save TRANSPORTING zjsdh WHERE zjsdh = ''.
LOOP AT it_save.
it_save-zjsdi = sy-tabix.
it_save-erdat = sy-datum.
it_save-erzet = sy-uzeit.
it_save-ernam = sy-uname.
MODIFY it_save.
ENDLOOP.
INSERT zrmm220t1 FROM TABLE it_save.
INSERT zrmm220t2 FROM TABLE it_resb.
COMMIT WORK.
ENDFORM. " SAVEDATA
*&---------------------------------------------------------------------*
*& Form PRINTDATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM printdata USING p_formname.
DATA: lf_fm_name TYPE rs38l_fnam.
DATA: ls_control_param TYPE ssfctrlop.
DATA: ls_composer_param TYPE ssfcompop.
DATA: lf_formname TYPE tdsfname.
DATA: jobinfo TYPE ssfcrescl.
DATA job_output_info TYPE ssfcrescl.
DATA job_output_options TYPE ssfcresop.
DATA: gt_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE.
lf_formname = p_formname.
**打印參數(shù)定義
* ls_control_param-langu = sy-langu.
* ls_control_param-getotf = 'X'. "
* ls_control_param-no_open = 'X'.
* ls_control_param-no_close = 'X'.
* ls_control_param-no_dialog = 'X'.
* ls_composer_param-tdnoprev = 'X'.
* ls_composer_param-tdimmed = 'X'.
* ls_composer_param-tddelete = 'X'.
ls_control_param-langu = sy-langu. "調(diào)用smartforms
ls_control_param-no_open = 'X'.
ls_control_param-no_close = 'X'.
ls_composer_param-tdimmed = 'X'.
ls_composer_param-tddelete = 'X'.
ls_composer_param-tdiexit = 'X'.
CALL FUNCTION 'SSF_OPEN'
EXPORTING
control_parameters = ls_control_param
output_options = ls_composer_param
user_settings = ' '
IMPORTING
job_output_options = job_output_options
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
EXIT.
ENDIF.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = lf_formname
IMPORTING
fm_name = lf_fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CLEAR:lt_h,lt_h[].
LOOP AT it_save.
lt_h-werks = it_save-werks.
lt_h-aufn2 = it_save-aufn2.
lt_h-zdydh = it_save-zdydh.
lt_h-zbanz = it_save-zbanz.
lt_h-lgpbe = it_save-lgpbe. "寄售庫倉管員
lt_h-lgort = it_save-lgort. "車間庫
lt_h-lgfsb = it_save-lgfsb. "二級庫
lt_h-umlgo = it_save-umlgo. "發(fā)出庫--寄售庫
IF p2 = 'X'.
SELECT SINGLE * FROM zrmm220t1
WHERE zdydh = it_save-zdydh AND druck = 'X'.
IF sy-subrc = 0.
lt_h-zrept = '重復打印'.
ENDIF.
ENDIF.
COLLECT lt_h.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = it_save-matnr
IMPORTING
output = it_save-matnr.
MODIFY it_save.
ENDLOOP.
LOOP AT lt_h.
CLEAR:lft_h[],lft_h,lft_i[],lft_i,p_i.
LOOP AT it_save WHERE zdydh = lt_h-zdydh AND zbanz = lt_h-zbanz AND lgpbe = lt_h-lgpbe AND lgort = lt_h-lgort.
MOVE-CORRESPONDING it_save TO lft_i.
p_i = p_i + 1.
APPEND lft_i.
ENDLOOP.
SORT lft_i BY zgwei lifnr matnr.
MOVE-CORRESPONDING lt_h TO lft_h.
APPEND lft_h.
CALL FUNCTION lf_fm_name
EXPORTING
control_parameters = ls_control_param
output_options = ls_composer_param
user_settings = 'X'
* IMPORTING
* job_output_info = job_output_info
* job_output_options = job_output_options
* TABLES
* gt_h = lft_h
* gt_i = lft_i
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDLOOP.
CALL FUNCTION 'SSF_CLOSE'
IMPORTING
job_output_info = jobinfo
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
EXIT.
ELSE.
*記錄打印日志
IF jobinfo-outputdone = 'X'.
LOOP AT it_save.
UPDATE zrmm220t1 SET druck = 'X'
WHERE zdydh = it_save-zdydh.
ENDLOOP.
COMMIT WORK.
ENDIF.
ENDIF.
ENDFORM. " PRINTDATA
FORM frm_get_xc.
DATA ls_stylerow TYPE lvc_s_styl.
DATA lt_styletab TYPE lvc_t_styl.
DATA l_matnr LIKE zrmm002t1-matnr.
CLEAR: it_save_et,it_save_et[].
LOOP AT it_save.
MOVE-CORRESPONDING it_save TO it_save_et.
APPEND it_save_et.
ENDLOOP.
LOOP AT it_save_et INTO wa_save_et.
CLEAR l_matnr.
SELECT SINGLE matnr INTO l_matnr FROM zrmm002t1 WHERE matnr = wa_save_et-matnr.
IF sy-subrc = 0 AND l_matnr IS NOT INITIAL.
ls_stylerow-fieldname = 'LIFNR'.
ls_stylerow-style = cl_gui_alv_grid=>mc_style_enabled.
INSERT ls_stylerow INTO TABLE wa_save_et-field_style.
ls_stylerow-fieldname = 'BDMNG'.
ls_stylerow-style = cl_gui_alv_grid=>mc_style_enabled.
INSERT ls_stylerow INTO TABLE wa_save_et-field_style.
MODIFY it_save_et FROM wa_save_et.
CLEAR wa_save_et.
ENDIF.
ENDLOOP.
ENDFORM.
ALV特定列可編輯
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
- 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來单寂,“玉大人贬芥,你說我怎么就攤上這事⌒觯” “怎么了蘸劈?”我有些...
- 文/不壞的土叔 我叫張陵,是天一觀的道長疲扎。 經(jīng)常有香客問我昵时,道長捷雕,這世上最難降的妖魔是什么? 我笑而不...
- 正文 為了忘掉前任壹甥,我火速辦了婚禮救巷,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘句柠。我一直安慰自己浦译,他們只是感情好,可當我...
- 文/花漫 我一把揭開白布溯职。 她就那樣靜靜地躺著精盅,像睡著了一般。 火紅的嫁衣襯著肌膚如雪谜酒。 梳的紋絲不亂的頭發(fā)上叹俏,一...
- 文/蒼蘭香墨 我猛地睜開眼度秘,長吁一口氣:“原來是場噩夢啊……” “哼顶伞!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起剑梳,我...
- 正文 年R本政府宣布,位于F島的核電站,受9級特大地震影響睬关,放射性物質(zhì)發(fā)生泄漏诱担。R本人自食惡果不足惜,卻給世界環(huán)境...
- 文/蒙蒙 一电爹、第九天 我趴在偏房一處隱蔽的房頂上張望蔫仙。 院中可真熱鬧,春花似錦丐箩、人聲如沸摇邦。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽施籍。三九已至,卻和暖如春概漱,著一層夾襖步出監(jiān)牢的瞬間丑慎,已是汗流浹背。 一陣腳步聲響...
推薦閱讀更多精彩內(nèi)容
- @所有文友 建安聯(lián)誼會作品集,請跟帖[抱拳] 日 子 文/林峰 日頭翻過的黑白 幻化成一幅幅歲月的片段 掛在心畔 ...
- 參考 http://stackoverflow.com/questions/5234117/how-to-drop...
- 腧穴釋義 列缺:列吏垮,分解障涯,裂開;缺膳汪,缺口唯蝶。此穴為手太陰肺經(jīng)之絡穴,自此分支別走手陽明大腸經(jīng)遗嗽,位于橈骨莖突上方粘我,當肱...
- 漂亮多肉植物系列 烏木系 大部分肉友都喜歡紅尖 漂亮多肉植物系列 烏木系 大部分肉友都喜歡紅尖 漂亮多肉植物系列 ...
- 1、怎么想起寫成長日記的痹换? 我的發(fā)小,大學修的是學前教育斧抱。我結(jié)婚以后他送給我一本書《早期教育與天才》仙蚜。他希望我能夠...