*--------------------------------------------------------------------* * 类型定义 *--------------------------------------------------------------------* TYPES: BEGIN OF TY_T001W, WERKS TYPE WERKS_D, NAME1 TYPE NAME1, BWKEY TYPE BWKEY, END OF TY_T001W,
BEGIN OF TY_ZMM010, ZBSART TYPE ZBSART, ZBATXT TYPE ZBATXT, END OF TY_ZMM010,
BEGIN OF TY_ZMM012, ZALLOTNO TYPE ZALLOTNO, ZALLOT TYPE ZALLOT, END OF TY_ZMM012,
BEGIN OF TY_ZMM014_F4, ZDEPT_CODE TYPE ZDEPT_CODE, ZDEPT_NAME TYPE ZDEPT_NAME, END OF TY_ZMM014_F4,
BEGIN OF TY_ZMM015_F4, ZPLTYPE TYPE ZPLTYPE, ZPLTEXT TYPE ZPLTEXT, END OF TY_ZMM015_F4,
BEGIN OF TY_T001L_F4, LGORT TYPE LGORT_D, LGOBE TYPE LGOBE, END OF TY_T001L_F4,
BEGIN OF TY_ZMM016_F4, PERNR TYPE ZPERNR, ENAME TYPE EMNAM, END OF TY_ZMM016_F4,
BEGIN OF TY_T001L, WERKS TYPE WERKS_D, LGORT TYPE LGORT_D, LGOBE TYPE LGOBE, ADRNR TYPE ADRNR, END OF TY_T001L,
BEGIN OF TY_ADRC, ADDRNUMBER TYPE AD_ADDRNUM, NAME1 TYPE AD_NAME1, TEL_NUMBER TYPE AD_TLNMBR1, STREET TYPE AD_STREET, END OF TY_ADRC,
BEGIN OF TY_CSKT, KOSTL TYPE KOSTL, DATBI TYPE DATBI, KTEXT TYPE KTEXT, END OF TY_CSKT,
BEGIN OF TY_MARC, MATNR TYPE MATNR, WERKS TYPE WERKS_D, MEINS TYPE MEINS, MAKTX TYPE MAKTX, GROES TYPE GROES, VOLUM TYPE VOLUM_15, VOLEH TYPE VOLEH, END OF TY_MARC,
BEGIN OF TY_MBEW, MATNR TYPE MATNR, BWKEY TYPE BWKEY, STPRS TYPE STPRS, END OF TY_MBEW,
BEGIN OF TY_MARD, MATNR TYPE MATNR, WERKS TYPE WERKS_D, LGORT TYPE LGORT_D, LABST TYPE LABST, END OF TY_MARD,
BEGIN OF TY_VBEP, VBELN TYPE VBELN, POSNR TYPE POSNR_VA, ETENR TYPE ETENR, OCDQTY_BU TYPE OCDQTY, DLVQTY_BU TYPE DLVQTY, END OF TY_VBEP,
BEGIN OF TY_PREDOCNO, ZPREDOCNO TYPE ZPREDOCNO, END OF TY_PREDOCNO,
BEGIN OF TY_AFPO, AUFNR TYPE AUFNR, AUART TYPE AUART, RSNUM TYPE RSNUM, OBJNR TYPE AUFK-OBJNR, PLNBEZ TYPE MATNR, PSMNG TYPE AFPO-PSMNG, WEMNG TYPE AFPO-WEMNG, LGORT TYPE LGORT_D, DGLTP TYPE CO_GLTRP, END OF TY_AFPO,
BEGIN OF TY_RESB, MATNR TYPE MATNR, RSPOS TYPE RESB-RSPOS, BDMNG TYPE RESB-BDMNG, ENMNG TYPE RESB-ENMNG, AUFNR TYPE AUFNR, END OF TY_RESB,
BEGIN OF TY_MATDOC, MATNR TYPE MATNR, MENGE TYPE MENGE_D, END OF TY_MATDOC,
BEGIN OF TY_RSNUM, RSNUM TYPE RSNUM, END OF TY_RSNUM,
BEGIN OF TY_KNA1, KUNNR TYPE KUNNR, NAME1 TYPE NAME1, END OF TY_KNA1,
BEGIN OF TY_STOCK_CHECK, MATNR TYPE MATNR, MENGE TYPE MENGE_D, ITEMNO TYPE CHAR50, END OF TY_STOCK_CHECK. ********************************************************************** TYPES: BEGIN OF TY_ZDSTATUS, MATNR TYPE MATNR, MENGE TYPE MENGE_D, END OF TY_ZDSTATUS. ********************************************************************** *--------------------------------------------------------------------* * 全局变量定义 *--------------------------------------------------------------------* *---全局变量 - 常量 CONSTANTS: GC_1000 TYPE SYST_DYNNR VALUE '1000', GC_2000 TYPE SYST_DYNNR VALUE '2000', GC_2100 TYPE SYST_DYNNR VALUE '2100', GC_2101 TYPE SYST_DYNNR VALUE '2101', GC_2200 TYPE SYST_DYNNR VALUE '2200', GC_2300 TYPE SYST_DYNNR VALUE '2300', GC_NEW TYPE C VALUE 'N', GC_CHANGE TYPE C VALUE 'C', GC_DISPLAY TYPE C VALUE 'D', GC_DELETE TYPE C VALUE 'L', GC_DEFAULT_STATUS TYPE ZPOSTSTATUS VALUE '01', GC_STATUS_DELETE TYPE ZPOSTSTATUS VALUE '05',
BEGIN OF GC_ICON, LED_GREEN TYPE ICON_D VALUE '@5B@', LED_RED TYPE ICON_D VALUE '@5C@', END OF GC_ICON,
BEGIN OF GC_UCOMM, EXECUTE TYPE SY-UCOMM VALUE 'EXEC', NEW TYPE SY-UCOMM VALUE 'NEW', CHANGE TYPE SY-UCOMM VALUE 'CHANGE', QUERY TYPE SY-UCOMM VALUE 'QUERY', PARK TYPE SY-UCOMM VALUE 'PARK', SAVE TYPE SY-UCOMM VALUE 'SAVE', POST TYPE SY-UCOMM VALUE 'POST', DELETE TYPE SY-UCOMM VALUE 'DELETE', PRINT TYPE SY-UCOMM VALUE 'PRINT', PRINTA5 TYPE SY-UCOMM VALUE 'PRINTA5', WRITEOFF TYPE SY-UCOMM VALUE 'WRITEOFF', YES TYPE SY-UCOMM VALUE 'YES', NO TYPE SY-UCOMM VALUE 'NO', SELALL TYPE SY-UCOMM VALUE 'SELALL', DESEL TYPE SY-UCOMM VALUE 'DESEL', REFRESH TYPE SY-UCOMM VALUE 'REFRESH', DELEPL0 TYPE SY-UCOMM VALUE 'DELEPL0', DOUBLECLICK TYPE SY-UCOMM VALUE '&IC1', END OF GC_UCOMM.
*---全局变量 - 结构/内表 DATA: GT_ADRC TYPE TABLE OF TY_ADRC, GT_CSKT TYPE TABLE OF TY_CSKT, GS_T001W TYPE TY_T001W, GT_T001L TYPE TABLE OF TY_T001L, " 仓库信息 GT_MARA TYPE TABLE OF MARA, GT_MARC TYPE SORTED TABLE OF TY_MARC WITH UNIQUE KEY MATNR WERKS, " 物料描述 GT_MARD TYPE SORTED TABLE OF TY_MARD WITH UNIQUE KEY MATNR WERKS LGORT, " 物料库存 GT_MBEW TYPE SORTED TABLE OF TY_MBEW WITH UNIQUE KEY MATNR BWKEY, GS_ZMM010 TYPE ZMM010, " 单据类型 GT_ZMM012 TYPE TABLE OF TY_ZMM012, " 调拨类型 GT_ZMM015 TYPE TABLE OF ZMM015, " 领料类型 GT_ZMM014 TYPE TABLE OF TY_ZMM014_F4, " 制单部门 GT_ZMM016 TYPE TABLE OF TY_ZMM016_F4, " 申请人工号 GS_ZMM011H TYPE ZST_ZMM011H, " 单据抬头 GS_ZMM011H_OLD TYPE ZST_ZMM011H, " 单据抬头 GT_ZMM011I TYPE TABLE OF ZST_ZMM011I, " 单据行项目 GT_ZMM011I_OLD TYPE TABLE OF ZST_ZMM011I, " 单据行项目旧数据 GS_ZMM011I TYPE ZST_ZMM011I, GT_KNA1 TYPE TABLE OF TY_KNA1, GT_QUERY_RESULT TYPE TABLE OF ZST_PREDOC_QUERY, GT_CHANGEABLE TYPE RANGE OF ZPREDOCSTATUS.
DATA: G_TC_2000_LINES TYPE I, GV_WRITEOFF_DATE TYPE D, GV_CONFIRM TYPE C, GV_A5 TYPE C, GV_ORDER TYPE C VALUE ABAP_TRUE, G_EDIT TYPE C VALUE GC_DISPLAY. " N = new , C = Change, D = display *&SPWIZARD: DECLARATION OF TABLECONTROL 'TC_2000' ITSELF CONTROLS: TC_2000 TYPE TABLEVIEW USING SCREEN 2000. *----------------------------------------------------------------------* * 定义宏 *----------------------------------------------------------------------* DEFINE MC_ADD_FIELDCAT. CLEAR ls_fieldcat. ls_fieldcat-fieldname = &1. ls_fieldcat-coltext = &2.
CASE &1. WHEN 'SELECT'. ls_fieldcat-checkbox = abap_true. ls_fieldcat-edit = abap_true. WHEN 'MATNR' OR 'UMMAT' OR 'PLNBEZ'. ls_fieldcat-convexit = 'MATN1'. WHEN 'ZPREDOCSTATUS'. ls_fieldcat-convexit = 'Z0001'. WHEN 'ZPREITEMPOSTSTATUS'. ls_fieldcat-convexit = 'Z0002'. WHEN 'ICON'. ls_fieldcat-icon = abap_true. WHEN 'AUFNR' OR 'IBLNR' OR 'KUNNR'. ls_fieldcat-convexit = 'ALPHA'. WHEN 'ZTRANSFER_ODD'. ls_fieldcat-edit = abap_true. ENDCASE.
READ TABLE lr_struct->components INTO ls_components WITH KEY name = &1. IF sy-subrc = 0. ls_fieldcat-outputlen = ls_components-length. ENDIF.
APPEND ls_fieldcat TO pt_fieldcat. END-OF-DEFINITION.
*--------------------------------------------------------------------* * 选择界面 *--------------------------------------------------------------------* SELECTION-SCREEN BEGIN OF BLOCK b1 with FRAME. PARAMETERS: p_werks type werks_d, p_zbsart type zbsart NO-DISPLAY, p_predoc type zpredocno. SELECTION-SCREEN end of BLOCK b1. *--------------------------------------------------------------------* * 查询选择界面 *--------------------------------------------------------------------* SELECTION-SCREEN BEGIN OF SCREEN 2101 as SUBSCREEN. SELECT-OPTIONS: s_predoc for gs_zmm011h-zpredocno VISIBLE LENGTH 40, s_status for gs_zmm011h-zpredocstatus, s_erdat for gs_zmm011h-erdat. SELECTION-SCREEN end of SCREEN 2101.
*--------------------------------------------------------------------* * 工厂输入帮助处理 *--------------------------------------------------------------------* at SELECTION-SCREEN on VALUE-REQUEST FOR p_werks. * PERFORM f4_werks CHANGING p_werks. *--------------------------------------------------------------------* *--------------------------------------------------------------------* at SELECTION-SCREEN on VALUE-REQUEST FOR s_predoc-low. PERFORM f4_predoc USING space CHANGING s_predoc-low. **--------------------------------------------------------------------* **--------------------------------------------------------------------* at SELECTION-SCREEN on VALUE-REQUEST FOR s_predoc-high. PERFORM f4_predoc USING space CHANGING s_predoc-high. *--------------------------------------------------------------------* * 开始选择界面处理 *--------------------------------------------------------------------* START-OF-SELECTION.
PERFORM start_of_selection.
INCLUDE ZMM001_ZM07O01. *INCLUDE zmm001_zm01o01. " PBO module
INCLUDE ZMM001_ZM07I01. *INCLUDE zmm001_zm01i01. " PAI module
INCLUDE ZMM001_ZM07F01. *INCLUDE zmm001_zm01f01. " PAI的处理子过程
INCLUDE ZMM001_ZM07F02. *INCLUDE ZMM001_ZM01F02. " 子过程
*&---------------------------------------------------------------------* *& Include ZMM001_ZM01F02 *&---------------------------------------------------------------------* *&---------------------------------------------------------------------* *&变更记录: *&Date Developer ReqNo Descriptions *& ========== ================== ========== ========================* *& 2017-09-20 Aaron(Hand) ED1K900147 初始开发 *&---------------------------------------------------------------------* *&---------------------------------------------------------------------* *& Form START_OF_SELECTION *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM start_of_selection .
"取工厂名称 SELECT SINGLE werks name1 bwkey INTO CORRESPONDING FIELDS OF gs_t001w FROM t001w WHERE werks = p_werks. "取单据类型主数据 SELECT SINGLE * INTO gs_zmm010 FROM zmm010 WHERE zbsart = p_zbsart. "取领料类型主数据 SELECT * INTO TABLE gt_zmm015 FROM zmm015. "取库位主数据 SELECT t1~werks t1~lgort lgobe adrnr INTO CORRESPONDING FIELDS OF TABLE gt_t001l FROM t001l AS t1 LEFT OUTER JOIN twlad AS t2 ON t1~werks = t2~werks AND t1~lgort = t2~lgort AND t2~lfdnr = '01' WHERE t1~werks = p_werks.
SORT gt_t001l BY werks lgort. "取库位主数据 SELECT addrnumber name1 tel_number street INTO CORRESPONDING FIELDS OF TABLE gt_adrc FROM adrc. "取成本中心主数据 SELECT t1~kostl t1~datbi ktext INTO CORRESPONDING FIELDS OF TABLE gt_cskt FROM csks AS t1 INNER JOIN cskt AS t2 ON t1~kokrs = t2~kokrs AND t1~kostl = t2~kostl AND t1~datbi = t2~datbi WHERE t2~spras = sy-langu AND t1~kokrs = '1000' AND bukrs = gs_t001w-bwkey. "取物料基本数据 SELECT t1~matnr werks meins maktx groes INTO CORRESPONDING FIELDS OF TABLE gt_marc FROM marc AS t1 INNER JOIN mara AS t2 ON t1~matnr = t2~matnr LEFT OUTER JOIN makt AS t3 ON t2~matnr = t3~matnr AND t3~spras = sy-langu WHERE werks = p_werks. "取物料库存数据 SELECT matnr werks lgort labst INTO CORRESPONDING FIELDS OF TABLE gt_mard FROM mard WHERE werks = p_werks AND labst > 0.
"取申请人工号 SELECT pernr ename INTO TABLE gt_zmm016 FROM zmm016.
IF p_predoc IS NOT INITIAL. gs_zmm011h-zpredocno = p_predoc. PERFORM get_predoc_info USING gs_zmm011h-zpredocno. ENDIF.
CALL SCREEN gc_2000.
ENDFORM. *&---------------------------------------------------------------------* *& Form NEW *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM new . DATA: ls_zmm011i TYPE zst_zmm011i.
DO 260 TIMES. ls_zmm011i-zpredocitem = sy-index. ls_zmm011i-bwart = gs_zmm010-bwart. ls_zmm011i-werks = gs_t001w-werks. ls_zmm011i-zpreitempoststatus = gc_default_status. APPEND ls_zmm011i TO gt_zmm011i. ENDDO.
CLEAR: gs_zmm011h_old, gt_zmm011i_old. ENDFORM. *&---------------------------------------------------------------------* *& Form CHANGE *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM change . DATA: lv_max_predocno TYPE zpredocno.
CLEAR: gt_zmm011i,g_edit.
IF gs_zmm011h-zpredocno IS INITIAL. CLEAR gs_zmm011h. SELECT MAX( zpredocno ) INTO lv_max_predocno FROM zmm011h WHERE werks = p_werks AND zbsart = p_zbsart. ELSE. lv_max_predocno = gs_zmm011h-zpredocno. ENDIF.
IF lv_max_predocno = space. MESSAGE e003. ENDIF.
PERFORM get_predoc_info USING lv_max_predocno.
ENDFORM. *&---------------------------------------------------------------------* *& Form QUERY *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM query . CALL SCREEN gc_2100 STARTING AT 10 10. ENDFORM. *&---------------------------------------------------------------------* *& Form PARK *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM park . DATA: lv_error TYPE i, lv_tabix TYPE sy-tabix, ls_zmm011h_db TYPE zmm011h, lt_zmm011i_screen TYPE TABLE OF zst_zmm011i, ls_zmm011i_screen TYPE zst_zmm011i, ls_zmm011i_db TYPE zmm011i, lt_zmm011i_db TYPE TABLE OF zmm011i, lt_zmm011i_db_del TYPE TABLE OF zmm011i, lt_stock_check TYPE TABLE OF ty_stock_check, ls_stock_check TYPE ty_stock_check. ********************************************************************** DATA: lv_answer TYPE c, lv_textline1 TYPE string, lv_textline2 TYPE string, lt_matdoc TYPE TABLE OF ty_matdoc, ls_matdoc TYPE ty_matdoc, lv_err TYPE i, lv_posted_menge TYPE menge_d, lv_menge TYPE menge_d, ls_zdstatus TYPE ty_zdstatus, lt_zdstatus TYPE TABLE OF ty_zdstatus. ********************************************************************** " 检查抬头 lt_zmm011i_screen = gt_zmm011i. DELETE lt_zmm011i_screen WHERE matnr = space. DELETE lt_zmm011i_screen WHERE select = space.
IF gs_zmm011h-zpredocno = space AND g_edit = gc_change. MESSAGE e010. ENDIF.
IF gs_zmm011h-lgort IS INITIAL. MESSAGE e002. ENDIF.
IF gs_zmm011h-aufnr IS INITIAL. MESSAGE e000 WITH '请输入生产订单号!'.. ENDIF.
" 检查行项目 IF lines( lt_zmm011i_screen ) = 0. MESSAGE e000 WITH '请选择发料行'. ENDIF. ********************************************************************** CLEAR: lt_zdstatus. "累计已制单数量 SELECT t1~matnr SUM( t1~menge ) AS menge INTO CORRESPONDING FIELDS OF TABLE lt_zdstatus FROM zmm011h AS t INNER JOIN zmm011i AS t1 ON t~zpredocno = t1~zpredocno WHERE t~zpoststatus IN ( '01','04' ) AND t~zpredocstatus = '01' AND t~zbsart = 'ZM07' AND t~aufnr = gs_zmm011h-aufnr AND t~werks = gs_zmm011h-werks GROUP BY t1~matnr.
"累计已领料数量 SELECT matnr, SUM( CASE WHEN bwart = '261' THEN menge WHEN bwart = '262' THEN menge * -1 END ) AS menge INTO CORRESPONDING FIELDS OF TABLE @lt_matdoc FROM matdoc WHERE bwart IN ( '261', '262' ) AND aufnr = @gs_zmm011h-aufnr AND werks = @gs_zmm011h-werks GROUP BY matnr. **********************************************************************
LOOP AT gt_zmm011i INTO ls_zmm011i_screen WHERE matnr <> space AND select = abap_true. * AND menge = 0. IF ls_zmm011i_screen-menge = 0. lv_error = 1. EXIT. ELSE. CLEAR ls_stock_check. " 限额领用数量小于累计已领数量 IF ls_zmm011i_screen-bdmng < ls_zmm011i_screen-enmng. lv_error = 3. EXIT. ENDIF. " * IF ls_zmm011i_screen-bdmng < ls_zmm011i_screen-enmng + ls_zmm011i_screen-menge."原来的逻辑 * lv_error = 4. * EXIT. * ENDIF. ********************************************************************** CLEAR:lv_menge,lv_posted_menge. "累计已领数量 + 输入数量 - 已制单的数量 > 限额领料数量 IF ls_zmm011i_screen-bdmng < ls_zmm011i_screen-enmng + ls_zmm011i_screen-menge - ls_zmm011i_screen-flag_menge. lv_error = 4.
READ TABLE lt_zdstatus INTO ls_zdstatus WITH KEY matnr = ls_zmm011i_screen-matnr. IF sy-subrc = 0. "占单(未过账) 的数量(不包括输入的数量) lv_menge = ls_zdstatus-menge. READ TABLE lt_matdoc INTO ls_matdoc WITH KEY matnr = ls_zmm011i_screen-matnr. IF sy-subrc = 0. "实际已过帐数量 lv_posted_menge = ls_matdoc-menge. ENDIF. lv_err = 5. ENDIF.
READ TABLE lt_stock_check INTO ls_stock_check WITH KEY matnr = ls_zmm011i_screen-matnr. IF sy-subrc = 0. lv_tabix = sy-tabix. ls_zmm011i_screen-zpredocitem = |{ ls_zmm011i_screen-zpredocitem ALPHA = OUT }|. ls_stock_check-menge = ls_zmm011i_screen-menge + ls_stock_check-menge. * CONCATENATE ls_stock_check-itemno * ls_zmm011i_screen-zpredocitem * into ls_stock_check-itemno * SEPARATED BY ','.
ls_stock_check-itemno = ls_stock_check-itemno && '/' && |{ ls_zmm011i_screen-zpredocitem ALPHA = OUT }|. MODIFY lt_stock_check FROM ls_stock_check INDEX lv_tabix. ELSE. ls_stock_check-matnr = ls_zmm011i_screen-matnr. ls_stock_check-menge = ls_zmm011i_screen-menge. ls_stock_check-itemno = |{ ls_zmm011i_screen-zpredocitem ALPHA = OUT }|. APPEND ls_stock_check TO lt_stock_check. ENDIF. ENDIF.
ENDLOOP.
IF lv_error = 0. LOOP AT lt_stock_check INTO ls_stock_check.
READ TABLE lt_zmm011i_screen INTO ls_zmm011i_screen WITH KEY matnr = ls_stock_check-matnr. IF sy-subrc = 0. IF ls_zmm011i_screen-available < ls_stock_check-menge. lv_error = 2. EXIT. ENDIF. ENDIF. ENDLOOP. ENDIF.
CASE lv_error. WHEN 1. MESSAGE e029 WITH |{ ls_zmm011i_screen-zpredocitem ALPHA = OUT }|. WHEN 2. MESSAGE e032 WITH ls_stock_check-itemno. WHEN 3. MESSAGE e039 WITH |{ ls_zmm011i_screen-zpredocitem ALPHA = OUT }|. WHEN 4. ********************************************************************** SHIFT ls_zmm011i_screen-zpredocitem LEFT DELETING LEADING '0'. IF lv_err EQ 5. lv_textline1 = '第' && ls_zmm011i_screen-zpredocitem && '行领用数量与累计已领用数量之和不能超过限额领料数量!其中本生产订单占单量(未过账)有:'&& lv_menge. lv_textline2 = '实际累计已过帐的有:' && lv_posted_menge && '请核对相关生产订单的预制单(已制)和实际过账的数量!再考虑是否开超领单'. CALL FUNCTION 'POPUP_TO_CONFIRM_STEP' EXPORTING titel = '警告!!' textline1 = lv_textline1 textline2 = lv_textline2 cancel_display = space IMPORTING answer = lv_answer.
IF lv_answer <> '1'. RETURN. ENDIF.
* MESSAGE e046 WITH |{ ls_zmm011i_screen-zpredocitem ALPHA = OUT }| |{ lv_menge }| |{ lv_posted_menge }|. ELSE. MESSAGE e041 WITH |{ ls_zmm011i_screen-zpredocitem ALPHA = OUT }|. ENDIF. ********************************************************************** * MESSAGE e041 WITH |{ ls_zmm011i_screen-zpredocitem ALPHA = OUT }|."之前逻辑
READ TABLE gt_zmm011i WITH KEY zpredocno = ls_zmm011i_screen-zpredocno zpredocitem = ls_zmm011i_screen-zpredocitem TRANSPORTING NO FIELDS. IF sy-subrc <> 0. MOVE-CORRESPONDING ls_zmm011i_screen TO ls_zmm011i_db. APPEND ls_zmm011i_db TO lt_zmm011i_db_del. ENDIF. ENDLOOP.
LOOP AT gt_zmm011i INTO ls_zmm011i_screen WHERE matnr <> space AND select = abap_true AND menge <> 0. MOVE-CORRESPONDING ls_zmm011i_screen TO ls_zmm011i_db. ls_zmm011i_db-zpredocno = gs_zmm011h-zpredocno. ls_zmm011i_db-kostl = gs_zmm011h-kostl. APPEND ls_zmm011i_db TO lt_zmm011i_db. ********************************************************************** ls_zmm011i_screen-flag_menge = ls_zmm011i_screen-menge. ********************************************************************** ENDLOOP.
MODIFY zmm011h FROM ls_zmm011h_db.
DELETE zmm011i FROM TABLE lt_zmm011i_db_del.
MODIFY zmm011i FROM TABLE lt_zmm011i_db. IF sy-subrc = 0. gs_zmm011h_old = gs_zmm011h. gt_zmm011i_old = gt_zmm011i. g_edit = gc_change. PERFORM unlock_predoc USING gs_zmm011h-zpredocno. MESSAGE s005 WITH gs_zmm011h-zpredocno. ENDIF.
ENDFORM. *&---------------------------------------------------------------------* *& Form SAVE *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM save .
PERFORM park.
PERFORM post.
ENDFORM. *&---------------------------------------------------------------------* *& Form POST *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM post. DATA: lt_predoc_post TYPE TABLE OF zmm_predoc_log, ls_predoc_post TYPE zmm_predoc_log, ls_zmm011i TYPE zst_zmm011i.
IF gs_zmm011h <> gs_zmm011h_old OR gt_zmm011i <> gt_zmm011i_old. MESSAGE e000 WITH '未保存不允许预制过账'. ENDIF.
LOOP AT gt_zmm011i INTO ls_zmm011i. CLEAR ls_predoc_post.
MOVE-CORRESPONDING ls_zmm011i TO ls_predoc_post. IF ls_predoc_post-zpredocno IS INITIAL. ls_predoc_post-zpredocno = gs_zmm011h-zpredocno. ENDIF. ls_predoc_post-budat = sy-datum. ls_predoc_post-zreleaseind = '2'. APPEND ls_predoc_post TO lt_predoc_post.
ENDLOOP.
CALL FUNCTION 'ZZMM_PREDOC_POST' TABLES t_predoc_post = lt_predoc_post.
READ TABLE lt_predoc_post INTO ls_predoc_post WITH KEY status = 'E'. IF sy-subrc <> 0. READ TABLE lt_predoc_post INTO ls_predoc_post WITH KEY status = 'S'. gs_zmm011h-zpredocstatus = '03'.
g_edit = gc_display. MESSAGE s000 WITH ls_predoc_post-message. ELSE. MESSAGE e000 WITH ls_predoc_post-message. ENDIF.
ENDFORM. *&---------------------------------------------------------------------* *& Form DELETE *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM delete .
IF gs_zmm011h-zpredocno = space. MESSAGE e010. ENDIF.
IF gs_zmm011h-zpredocstatus NOT IN gt_changeable. MESSAGE e008 WITH gs_zmm011h-zpredocno. ENDIF.
UPDATE zmm011h SET zpredocstatus = gc_status_delete WHERE zpredocno = gs_zmm011h-zpredocno.
* DELETE FROM zmm011i WHERE zpredocno = gs_zmm011h-zpredocno.
IF sy-subrc = 0. g_edit = gc_delete. gs_zmm011h-zpredocstatus = gc_status_delete. MESSAGE s009 WITH gs_zmm011h-zpredocno. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form PRINT *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM print . DATA: lt_zmm011i TYPE TABLE OF zst_zmm011i, lv_fm_name TYPE rs38l_fnam, ls_output TYPE ssfcresop.
IF gs_zmm011h-zpredocno = space. MESSAGE e010. ENDIF.
IF gs_zmm010-ssfname = space. MESSAGE e011. ENDIF.
PERFORM get_user_fullname USING gs_zmm011h-ernam CHANGING gs_zmm011h-ernam_name_text.
lt_zmm011i = gt_zmm011i.
DELETE lt_zmm011i WHERE matnr = space. DELETE lt_zmm011i WHERE select = space.
CALL FUNCTION lv_fm_name EXPORTING * control_parameters = l_control * output_options = lw_output * g_biaoshi = g_biaoshi gs_header = gs_zmm011h IMPORTING job_output_options = ls_output TABLES gt_items = lt_zmm011i EXCEPTIONS formatting_error = 1 internal_error = 2 send_error = 3 user_canceled = 4 OTHERS = 5. IF sy-subrc = 0. IF ls_output-tdpreview = space. " 如果是打印,则记录打印次数 gs_zmm011h-zprint_count = gs_zmm011h-zprint_count + 1. UPDATE zmm011h SET zprint_count = gs_zmm011h-zprint_count WHERE zpredocno = gs_zmm011h-zpredocno. ENDIF. ENDIF. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form WRITEOFF *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM writeoff . DATA: lt_return TYPE bapiret2_t, ls_return TYPE bapiret2.
CLEAR: gv_confirm, gv_writeoff_date.
IF gs_zmm011h-zpoststatus = '03'. MESSAGE e012 WITH gs_zmm011h-zpredocno. ELSE. IF gs_zmm011h-zpoststatus <> '02'. MESSAGE e013 WITH gs_zmm011h-zpredocno. ENDIF. ENDIF.
gv_writeoff_date = sy-datum.
CALL SCREEN gc_2200 STARTING AT 10 5.
IF gv_confirm = abap_true. PERFORM writeoff_post CHANGING gs_zmm011h lt_return.
READ TABLE lt_return INTO ls_return INDEX 1.
MESSAGE ID ls_return-id TYPE ls_return-type NUMBER ls_return-number WITH ls_return-message_v1 ls_return-message_v2 ls_return-message_v3 ls_return-message_v4. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form GET_NEW_PREDOCNO *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* * <--P_NEW_PREDOCNO text *&---------------------------------------------------------------------* FORM get_new_predocno USING p_zbsart TYPE zbsart CHANGING p_new_predocno TYPE zpredocno. DATA: ls_zmm013 TYPE zmm013.
CALL FUNCTION 'ENQUEUE_EZ_ZMM013' EXPORTING zbsart = gs_zmm010-zbsart datum = sy-datum EXCEPTIONS foreign_lock = 1 system_failure = 2 OTHERS.
IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF.
SELECT SINGLE * INTO ls_zmm013 FROM zmm013 WHERE zbsart = gs_zmm010-zbsart AND datum = sy-datum.
ls_zmm013-zbsart = gs_zmm010-zbsart. ls_zmm013-datum = sy-datum. MODIFY zmm013 FROM ls_zmm013.
CALL FUNCTION 'DEQUEUE_EZ_ZMM013' EXPORTING zbsart = gs_zmm010-zbsart datum = sy-datum.
ENDFORM. *&---------------------------------------------------------------------* *& Form GET_PREDOC_INFO *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* * -->P_PREDOCNO text *&---------------------------------------------------------------------* FORM get_predoc_info USING p_predocno TYPE zpredocno. DATA: ls_t001l TYPE t001l, ls_cskt TYPE ty_cskt, ls_zmm015 TYPE zmm015.
FIELD-SYMBOLS: TYPE zst_zmm011i.
SELECT SINGLE * INTO CORRESPONDING FIELDS OF gs_zmm011h FROM zmm011h WHERE zpredocno = p_predocno AND zbsart = gs_zmm010-zbsart. IF sy-subrc <> 0. MESSAGE e006 WITH p_predocno. ENDIF.
ENDFORM. *&---------------------------------------------------------------------* *& Form WRITEOFF_POST *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM writeoff_post CHANGING p_zmm011h TYPE zst_zmm011h pt_return TYPE bapiret2_t. DATA: ls_goodsmvt_headret TYPE bapi2017_gm_head_ret, lt_return TYPE TABLE OF bapiret2, ls_return TYPE bapiret2, lv_mblnr TYPE mblnr.
IF ls_goodsmvt_headret-mat_doc IS INITIAL. CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
READ TABLE lt_return INTO ls_return WITH KEY type = 'E'. IF sy-subrc <> 0. READ TABLE lt_return INTO ls_return WITH KEY type = 'A'. ENDIF.
IF sy-subrc = 0. MESSAGE e000 WITH ls_return-message. ELSE. MESSAGE e019. ENDIF. ELSE. READ TABLE lt_return INTO ls_return WITH KEY type = 'E'. IF sy-subrc <> 0. READ TABLE lt_return INTO ls_return WITH KEY type = 'A'. ENDIF.
IF sy-subrc = 0. CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. APPEND ls_return TO pt_return. ELSE. "返回了凭证号,同时未返回任何错误消息,则判断未成功 "提交事务 CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X'.
DO 50 TIMES. SELECT SINGLE mblnr "物料凭证号 INTO lv_mblnr FROM mkpf WHERE mblnr = ls_goodsmvt_headret-mat_doc AND mjahr = ls_goodsmvt_headret-doc_year. IF sy-subrc = 0. EXIT. ELSE. WAIT UP TO '0.1' SECONDS. ENDIF. ENDDO.
IF lv_mblnr IS INITIAL.
CALL FUNCTION 'BALW_BAPIRETURN_GET2' EXPORTING type = 'E' cl = 'ZMM_PREDOC' number = '018' IMPORTING return = ls_return EXCEPTIONS OTHERS = 0. APPEND ls_return TO pt_return.
UPDATE zmm011i SET zpreitempoststatus = p_zmm011h-zpoststatus WHERE zpredocno = p_zmm011h-zpredocno.
ls_return-message_v1 = p_zmm011h-zpredocno. ls_return-message_v2 = p_zmm011h-zlastwriteoffmblnr. CALL FUNCTION 'BALW_BAPIRETURN_GET2' EXPORTING type = 'S' cl = 'ZMM_PREDOC' number = '017' par1 = ls_return-message_v1 par2 = ls_return-message_v2 IMPORTING return = ls_return EXCEPTIONS OTHERS = 0. APPEND ls_return TO pt_return.
* MESSAGE s017 WITH p_zmm011h-zpredocno p_zmm011h-zlastwriteoffmblnr. ENDIF. ENDIF.
ENDIF.
ENDFORM. *&---------------------------------------------------------------------* *& Form SHOW_QUERY_GRID *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM show_query_grid . DATA: ls_layout_lvc TYPE lvc_s_layo, lt_fieldcat TYPE lvc_t_fcat, ls_grid_settings TYPE lvc_s_glay.
ENDFORM. *&---------------------------------------------------------------------* *& Form FILL_FIELDCAT *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* * <--PT_FIELDCAT text *&---------------------------------------------------------------------* FORM grid_status_set USING pt_extab TYPE slis_t_extab.
SET PF-STATUS 'GRID_STATUS' EXCLUDING pt_extab.
ENDFORM. *&---------------------------------------------------------------------* *& Form FILL_FIELDCAT *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* * <--PT_FIELDCAT text *&---------------------------------------------------------------------* FORM grid_user_command USING pr_ucomm LIKE sy-ucomm p_selfield TYPE slis_selfield. DATA: lr_grid TYPE REF TO cl_gui_alv_grid.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR' IMPORTING e_grid = lr_grid.
CASE pr_ucomm. WHEN gc_ucomm-writeoff. PERFORM grid_writeoff. WHEN gc_ucomm-print. PERFORM grid_print. WHEN gc_ucomm-post. PERFORM grid_post. WHEN gc_ucomm-refresh. PERFORM get_query_data. WHEN gc_ucomm-selall. PERFORM select_or_deselect USING lr_grid abap_true. WHEN gc_ucomm-desel. PERFORM select_or_deselect USING lr_grid space. WHEN gc_ucomm-doubleclick. PERFORM doubleclick USING p_selfield. ENDCASE.
ENDFORM. *&---------------------------------------------------------------------* *& Form GET_LGORT_LGOBE *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* * -->P_WERKS text * -->P_LGORT text * <--P_LGORT_LGOBE text *&---------------------------------------------------------------------* FORM get_lgort_lgobe USING p_werks TYPE werks_d p_lgort TYPE lgort_d CHANGING p_lgort_lgobe. DATA: ls_t001l TYPE ty_t001l.
READ TABLE gt_t001l INTO ls_t001l WITH KEY werks = p_werks lgort = p_lgort. IF sy-subrc = 0. p_lgort_lgobe = ls_t001l-lgobe. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form GET_COSTCENTER_TEXT *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* * -->P_KOSTL text * <--P_KTEXT text *&---------------------------------------------------------------------* FORM get_costcenter_text USING p_kostl TYPE kostl CHANGING p_ktext TYPE ktext. DATA: ls_cskt TYPE ty_cskt.
READ TABLE gt_cskt INTO ls_cskt WITH KEY kostl = p_kostl. IF sy-subrc = 0. p_ktext = ls_cskt-ktext. ELSE. MESSAGE e014 WITH p_kostl. ENDIF.
ENDFORM. *&---------------------------------------------------------------------* *& Form GET_ITEM_ADDITIONAL_INFO *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* * <--P_ZMM011I text *&---------------------------------------------------------------------* FORM get_item_additional_info CHANGING p_zmm011i TYPE zst_zmm011i. DATA: ls_zmm015 TYPE zmm015, ls_marc TYPE ty_marc, ls_mard TYPE ty_mard, ls_t001l TYPE ty_t001l.
IF p_zmm011i-werks IS INITIAL. p_zmm011i-werks = gs_t001w-werks. ENDIF.
IF p_zmm011i-lgort IS INITIAL. p_zmm011i-lgort = gs_zmm011h-lgort. p_zmm011i-lgort_lgobe = gs_zmm011h-lgort_lgobe. ENDIF.
IF p_zmm011i-kostl IS INITIAL. p_zmm011i-kostl = gs_zmm011h-kostl. ENDIF.
IF p_zmm011i-bwart IS INITIAL. p_zmm011i-bwart = gs_zmm010-bwart. ENDIF.
IF p_zmm011i-zpreitempoststatus IS INITIAL. p_zmm011i-zpreitempoststatus = gc_default_status. ENDIF.
READ TABLE gt_marc INTO ls_marc WITH KEY matnr = p_zmm011i-matnr werks = p_zmm011i-werks. IF sy-subrc = 0. p_zmm011i-matnr_maktx = ls_marc-maktx. p_zmm011i-meins = ls_marc-meins. TRY. p_zmm011i-groes = ls_marc-groes. CATCH cx_sy_conversion_no_number.
ENDFORM. *&---------------------------------------------------------------------* *& Form SHOW_QUERY *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM show_query .
PERFORM get_query_data. IF lines( gt_query_result ) > 0. PERFORM show_query_grid. ELSE. MESSAGE e000 WITH '没有找到相关数据'. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form GET_QUERY_DATA *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM get_query_data . DATA: ls_zmm015 TYPE zmm015, ls_marc TYPE ty_marc, ls_t001l TYPE ty_t001l, ls_adrc TYPE ty_adrc, ls_cskt TYPE ty_cskt.
FIELD-SYMBOLS: TYPE zst_predoc_query.
SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_query_result FROM zmm011h AS t1 INNER JOIN zmm011i AS t2 ON t1~zpredocno = t2~zpredocno WHERE t1~zpredocno IN s_predoc AND t1~zpredocstatus IN s_status AND erdat IN s_erdat AND t2~werks = gs_t001w-werks AND zbsart = gs_zmm010-zbsart.
READ TABLE gt_marc INTO ls_marc WITH KEY matnr = -ummat werks = -werks. IF sy-subrc = 0. -ummat_maktx = ls_marc-maktx. ENDIF.
SELECT SINGLE matnr INTO -plnbez FROM afpo WHERE aufnr = -aufnr.
READ TABLE gt_marc INTO ls_marc WITH KEY matnr = -plnbez werks = -werks. IF sy-subrc = 0. -plnbez_maktx = ls_marc-maktx. ENDIF.
PERFORM get_lgort_lgobe USING -werks -lgort CHANGING -lgort_lgobe.
READ TABLE gt_t001l INTO ls_t001l WITH KEY werks = -werks lgort = -umlgo. IF sy-subrc = 0. -umlgo_lgobe = ls_t001l-lgobe. READ TABLE gt_adrc INTO ls_adrc WITH KEY addrnumber = ls_t001l-adrnr. IF sy-subrc = 0. -umlgo_name1 = ls_adrc-name1. -umlgo_tel_number = ls_adrc-tel_number. -umlgo_street = ls_adrc-street. ENDIF. ENDIF.
PERFORM get_material_doc_creator USING -zlastpostmblnr -zlastpostmjahr CHANGING -zlastpostbudat -zlastpostcputm -zlastpostusnam.
PERFORM get_material_doc_creator USING -zlastwriteoffmblnr -zlastwriteoffmjahr CHANGING -zlastwriteoffbudat -zlastwriteoffcputm -zlastwriteoffusnam. IF NOT -kostl IS INITIAL. PERFORM get_costcenter_text USING -kostl CHANGING -ktext. ENDIF. "设置已取消过账的行为红色 IF -zpreitempoststatus = '03'. -rowcolor = 'C600'. ENDIF. ENDLOOP.
SORT gt_query_result BY zpredocno zpredocitem.
ENDFORM. *&---------------------------------------------------------------------* *& Form GRID_WRITEOFF *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM grid_writeoff . DATA: ls_zmm011h TYPE zst_zmm011h, lt_zmm011h TYPE TABLE OF zst_zmm011h, lt_return TYPE bapiret2_t, ls_return TYPE bapiret2.
FIELD-SYMBOLS: TYPE zst_predoc_query. READ TABLE gt_query_result WITH KEY select = abap_true TRANSPORTING NO FIELDS. IF sy-subrc <> 0. MESSAGE e020. ENDIF.
gv_writeoff_date = sy-datum. CALL SCREEN gc_2200 STARTING AT 10 10.
IF gv_confirm = abap_true. LOOP AT gt_query_result ASSIGNING WHERE select = abap_true. CLEAR ls_zmm011h.
IF -zlastpostmblnr IS INITIAL. -icon = gc_icon-led_red. -msg = '单据未过账'. CONTINUE. ENDIF.
IF NOT -zlastwriteoffmjahr IS INITIAL. -icon = gc_icon-led_red. -msg = '单据已冲销过账'. CONTINUE. ENDIF.
READ TABLE lt_zmm011h WITH KEY zpredocno = -zpredocno TRANSPORTING NO FIELDS. IF sy-subrc <> 0. MOVE-CORRESPONDING TO ls_zmm011h. APPEND ls_zmm011h TO lt_zmm011h.
READ TABLE lt_return INTO ls_return INDEX 1. IF sy-subrc = 0. CASE ls_return-type. WHEN 'S'. -icon = gc_icon-led_green. -msg = ls_return-message. -zlastwriteoffmblnr = ls_return-message_v2. -zlastwriteoffmjahr = sy-datum(4). -zlastwriteoffbudat = gv_writeoff_date. -zlastwriteoffcputm = sy-uzeit. -zlastwriteoffusnam = sy-uname. WHEN OTHERS. -icon = gc_icon-led_red. -msg = ls_return-message. ENDCASE. ENDIF. ENDIF. ENDLOOP. ENDIF.
ENDFORM. *&---------------------------------------------------------------------* *& Form GRID_POST *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM grid_post . DATA: lt_predoc_post TYPE TABLE OF zmm_predoc_log, ls_predoc_post TYPE zmm_predoc_log, lt_predocno TYPE TABLE OF ty_predocno, ls_predocno TYPE ty_predocno, ls_query_result TYPE zst_predoc_query.
READ TABLE gt_query_result WITH KEY select = abap_true TRANSPORTING NO FIELDS. IF sy-subrc <> 0. MESSAGE e020. ENDIF.
gv_writeoff_date = sy-datum. CALL SCREEN gc_2200 STARTING AT 10 10.
CHECK gv_confirm = abap_true.
LOOP AT gt_query_result INTO ls_query_result WHERE select = abap_true AND zpredocstatus <> gc_status_delete.
CLEAR ls_predocno. ls_predocno-zpredocno = ls_query_result-zpredocno. COLLECT ls_predocno INTO lt_predocno. ENDLOOP.
LOOP AT lt_predocno INTO ls_predocno.
LOOP AT gt_query_result INTO ls_query_result WHERE zpredocno = ls_predocno-zpredocno. CLEAR ls_predoc_post. MOVE-CORRESPONDING ls_query_result TO ls_predoc_post. ls_predoc_post-zreleaseind = '2'. ls_predoc_post-budat = gv_writeoff_date. APPEND ls_predoc_post TO lt_predoc_post. ENDLOOP.
CALL FUNCTION 'ZZMM_PREDOC_POST' TABLES t_predoc_post = lt_predoc_post.
CLEAR ls_predoc_post. READ TABLE lt_predoc_post INTO ls_predoc_post INDEX 1. CASE ls_predoc_post-status. WHEN 'E'. ls_query_result-icon = gc_icon-led_red. WHEN 'S'. ls_query_result-icon = gc_icon-led_green. ENDCASE.
ls_query_result-msg = ls_predoc_post-message. MODIFY gt_query_result FROM ls_query_result TRANSPORTING icon msg WHERE zpredocno = ls_predocno-zpredocno. ENDLOOP.
ENDFORM. *&---------------------------------------------------------------------* *& Form SELECT_OR_DESELECT *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* * -->P_ABAP_TRUE text *&---------------------------------------------------------------------* FORM select_or_deselect USING p_grid TYPE REF TO cl_gui_alv_grid p_select TYPE char01. DATA: it_filtered_entries TYPE lvc_t_fidx. FIELD-SYMBOLS: TYPE zst_predoc_query.
LOOP AT gt_query_result ASSIGNING . READ TABLE it_filtered_entries FROM sy-tabix TRANSPORTING NO FIELDS. IF sy-subrc NE 0. -select = p_select. ENDIF. ENDLOOP.
ENDFORM. *&---------------------------------------------------------------------* *& Form GET_USER_FULLNAME *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* * -->P_ERNAM text * <--P_NAME_TEXT text *&---------------------------------------------------------------------* FORM get_user_fullname USING p_ernam TYPE uname CHANGING p_name_text TYPE ad_namtext. DATA: ls_address TYPE bapiaddr3, lt_return TYPE bapiret2_t.
ENDFORM. *&---------------------------------------------------------------------* *& Form GRID_PRINT *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM grid_print . DATA: lt_zmm011h TYPE TABLE OF zst_zmm011h, ls_zmm011h TYPE zst_zmm011h, lt_zmm011i TYPE TABLE OF zst_zmm011i, ls_zmm011i TYPE zst_zmm011i, ls_query_result TYPE zst_predoc_query, lt_zmm011i_print TYPE TABLE OF zst_zmm011i. DATA: lv_fm_name TYPE rs38l_fnam, ls_output_options TYPE ssfcompop, ls_control_parameters TYPE ssfctrlop, ls_job_output_options TYPE ssfcresop, ls_job_output_info TYPE ssfcrescl.
READ TABLE gt_query_result WITH KEY select = abap_true TRANSPORTING NO FIELDS. IF sy-subrc <> 0. MESSAGE e020. ENDIF.
LOOP AT gt_query_result INTO ls_query_result.
IF ls_query_result-select = abap_true. READ TABLE lt_zmm011h WITH KEY zpredocno = ls_query_result-zpredocno TRANSPORTING NO FIELDS. IF sy-subrc <> 0. CLEAR ls_zmm011h. MOVE-CORRESPONDING ls_query_result TO ls_zmm011h. APPEND ls_zmm011h TO lt_zmm011h. ENDIF. ENDIF.
CLEAR ls_zmm011i. MOVE-CORRESPONDING ls_query_result TO ls_zmm011i. APPEND ls_zmm011i TO lt_zmm011i. ENDLOOP.
CALL FUNCTION 'SSF_CLOSE' IMPORTING job_output_info = ls_job_output_info EXCEPTIONS formatting_error = 1 internal_error = 2 send_error = 3 error_message = 4 OTHERS = 5. IF sy-subrc = 0. IF ls_job_output_info-outputdone = abap_true. "如果打印成功,更新打印次数 LOOP AT lt_zmm011h INTO ls_zmm011h. ls_query_result-zprint_count = ls_zmm011h-zprint_count = ls_zmm011h-zprint_count + 1. UPDATE zmm011h SET zprint_count = ls_zmm011h-zprint_count WHERE zpredocno = ls_zmm011h-zpredocno.
"更新内表打印次数 MODIFY gt_query_result FROM ls_query_result TRANSPORTING zprint_count WHERE zpredocno = ls_zmm011h-zpredocno. ENDLOOP. ENDIF. ENDIF. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form GET_MATERIAL_DOC_CREATOR *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* * -->P_MBLNR text * -->P_MJAHR text * <--P_BUDAT text * <--P_CPUTM text * <--P_USNAM text *&---------------------------------------------------------------------* FORM get_material_doc_creator USING p_mblnr TYPE mblnr p_mjahr TYPE mjahr CHANGING p_budat TYPE d p_cputm TYPE t p_usnam TYPE usnam.
IF NOT p_mblnr IS INITIAL. SELECT SINGLE budat cputm usnam INTO (p_budat,p_cputm,p_usnam) FROM mkpf WHERE mblnr = p_mblnr AND mjahr = p_mjahr. ENDIF.
ENDFORM. *&---------------------------------------------------------------------* *& Form DOUBLECLICK *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* * -->P_P_SELFIELD text *&---------------------------------------------------------------------* FORM doubleclick USING p_selfield TYPE slis_selfield.
CASE p_selfield-fieldname. WHEN 'ZPREDOCNO'. gs_zmm011h-zpredocno = p_selfield-value. PERFORM get_predoc_info USING gs_zmm011h-zpredocno. CALL SCREEN gc_2000. ENDCASE.
ENDFORM. *&---------------------------------------------------------------------* *& Form DELETE_STOCK_QTY_0 *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM delete_stock_qty_0 . DATA: ls_zmm011i TYPE zst_zmm011i.
IF gs_zmm011h-lgort IS NOT INITIAL. DELETE gt_zmm011i WHERE current_inventory = 0.
LOOP AT gt_zmm011i INTO ls_zmm011i. ls_zmm011i-zpredocitem = sy-tabix. MODIFY gt_zmm011i FROM ls_zmm011i TRANSPORTING zpredocitem. ENDLOOP.
REFRESH CONTROL 'TC_2000' FROM SCREEN sy-dynnr. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form LOCK_PREDOC *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* * -->P_ZPREDOCNO text *&---------------------------------------------------------------------* FORM lock_predoc USING p_zpredocno TYPE zpredocno.
IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE 'W' NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. g_edit = gc_display. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form UNLOCK_PREDOC *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* * -->P_GS_ZMM011H_ZPREDOCNO text *&---------------------------------------------------------------------* FORM unlock_predoc USING p_zpredocno TYPE zpredocno.
IF p_zpredocno IS NOT INITIAL. CALL FUNCTION 'DEQUEUE_EZ_ZMM011H' EXPORTING zpredocno = p_zpredocno EXCEPTIONS error_message = 1 OTHERS = 2. ENDIF.
ENDFORM. *&---------------------------------------------------------------------* *& Form GET_QTY_IN_PROCESS *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* * <--P_P_ZMM011I text *&---------------------------------------------------------------------* FORM get_qty_in_process CHANGING p_zmm011i TYPE zst_zmm011i. DATA: lv_zzqty_in_process TYPE menge_d, lt_vbep TYPE TABLE OF ty_vbep, ls_vbep TYPE ty_vbep, lt_lips TYPE TABLE OF ty_vbep, lv_order_qty TYPE ordqty, lv_zplquantity TYPE zplquantity. ********************************************************************** * 更改说明 :skgljc 20180611 * 1、加入条件 :按需求 取在制生产订单处理中的领料数量 将取值赋给字段 p_zmm011i-in_process * 2、将不加在制单生产订单查询的 所有生产订单 处理中的数量 将取值赋给新定义的字段 : p_zmm011i-all_in_process * ps:也就是说以前 字段 p_zmm011i-in_process 存的值是 所有处理中的领料数量(因为没有加在制生产订单作查询条件)现在改为字段:p_zmm011i-all_in_process * 而 现在 这个字段 p_zmm011i-in_process 存的值是 加入在制生产订单 查出订单的 处理中的领料数量 "新增 查询预制订单中 在制的生产订单 的未处理中的数量 SELECT SUM( menge ) INTO p_zmm011i-in_process FROM zmm011h AS t1 INNER JOIN zmm011i AS t2 ON t1~zpredocno = t2~zpredocno WHERE t1~zpredocno <> p_zmm011i-zpredocno AND ( ( zbsart <> 'ZM02' AND zbsart <> 'ZM05' AND zpreitempoststatus <> '02' AND zpredocstatus = '02' ) OR ( ( zbsart = 'ZM07' OR zbsart = 'ZM09' ) AND zpredocstatus = '01' ) ) AND aufnr = gs_zmm011h-aufnr AND matnr = p_zmm011i-matnr AND t2~werks = p_zmm011i-werks AND t2~lgort = p_zmm011i-lgort.
SELECT SUM( menge ) * INTO p_zmm011i-in_process "更改前 skgljc by 20180611 INTO p_zmm011i-all_in_process "更改后的 FROM zmm011h AS t1 INNER JOIN zmm011i AS t2 ON t1~zpredocno = t2~zpredocno WHERE t1~zpredocno <> p_zmm011i-zpredocno AND ( ( zbsart <> 'ZM02' AND zbsart <> 'ZM05' AND zpreitempoststatus <> '02' AND zpredocstatus = '02' ) OR ( ( zbsart = 'ZM07' OR zbsart = 'ZM09' ) AND zpredocstatus = '01' ) ) AND matnr = p_zmm011i-matnr AND t2~werks = p_zmm011i-werks AND t2~lgort = p_zmm011i-lgort.
SELECT SUM( zplquantity ) INTO lv_zplquantity FROM zmm011h AS t1 INNER JOIN zmm011i AS t2 ON t1~zpredocno = t2~zpredocno WHERE t1~zpredocno <> p_zmm011i-zpredocno AND ( ( zbsart = 'ZM05' AND zpreitempoststatus <> '02' AND zpredocstatus = '02' ) ) AND matnr = p_zmm011i-matnr AND t2~werks = p_zmm011i-werks AND t2~lgort = p_zmm011i-lgort AND zplquantity < 0.
IF p_zmm011i-werks = '1000'. SELECT t1~vbeln t2~posnr etenr ocdqty_bu dlvqty_bu INTO CORRESPONDING FIELDS OF TABLE lt_vbep FROM vbak AS t1 INNER JOIN vbap AS t2 ON t1~vbeln = t2~vbeln INNER JOIN vbep AS t3 ON t2~vbeln = t3~vbeln AND t2~posnr = t3~posnr WHERE auart NOT IN ( 'ZRE1','ZRE2','ZRE3','ZRE4' ) AND t3~lifsp = space AND t2~abgru = space AND t2~matnr = p_zmm011i-matnr AND t2~werks = p_zmm011i-werks AND t2~lgort = p_zmm011i-lgort.
IF lines( lt_vbep ) > 0. SELECT vbeln posnr lfimg AS ocdqty_bu INTO CORRESPONDING FIELDS OF TABLE lt_lips FROM lips FOR ALL ENTRIES IN lt_vbep WHERE vgbel = lt_vbep-vbeln AND vgpos = lt_vbep-posnr AND wbsta = 'C'. ENDIF.
CLEAR lv_order_qty. LOOP AT lt_vbep INTO ls_vbep. lv_order_qty = lv_order_qty + ls_vbep-ocdqty_bu + ls_vbep-dlvqty_bu. ENDLOOP.
LOOP AT lt_lips INTO ls_vbep. lv_order_qty = lv_order_qty - ls_vbep-ocdqty_bu. ENDLOOP.
ENDFORM. *&---------------------------------------------------------------------* *& Form USER_COMMAND_2000 *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM user_command_2000 . DATA: lv_ucomm TYPE sy-ucomm.
lv_ucomm = sy-ucomm. CLEAR sy-ucomm.
CASE lv_ucomm. WHEN gc_ucomm-new. "新建 PERFORM new. WHEN gc_ucomm-change. "修改 PERFORM change. WHEN gc_ucomm-query. "查询 PERFORM query. WHEN gc_ucomm-park. "仅保存 PERFORM park. * WHEN gc_ucomm-save. "保存并提交审批 * PERFORM save. WHEN gc_ucomm-post. "预制过账 PERFORM post. WHEN gc_ucomm-delete. "删除预制 PERFORM delete. WHEN gc_ucomm-print. "打印 PERFORM print. WHEN gc_ucomm-writeoff. "冲销过账 PERFORM writeoff. WHEN gc_ucomm-delepl0. "删除库存数量为零行 PERFORM delete_stock_qty_0. WHEN OTHERS. PERFORM user_ok_tc USING 'TC_2000' 'GT_ZMM011I' 'SELECT' CHANGING lv_ucomm. ENDCASE.
ENDFORM. *----------------------------------------------------------------------* * INCLUDE TABLECONTROL_FORMS * *----------------------------------------------------------------------*
*&---------------------------------------------------------------------* *& Form USER_OK_TC * *&---------------------------------------------------------------------* FORM user_ok_tc USING p_tc_name TYPE dynfnam p_table_name p_mark_name CHANGING p_ok LIKE sy-ucomm.
*&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------* DATA: l_ok TYPE sy-ucomm, l_offset TYPE i. *&SPWIZARD: END OF LOCAL DATA------------------------------------------*
*&SPWIZARD: Table control specific operations * *&SPWIZARD: evaluate TC name and operations * SEARCH p_ok FOR p_tc_name. IF sy-subrc <> 0. EXIT. ENDIF. l_offset = strlen( p_tc_name ) + 1. l_ok = p_ok+l_offset. *&SPWIZARD: execute general and TC specific operations * CASE l_ok. WHEN 'INSR'. "insert row PERFORM fcode_insert_row USING p_tc_name p_table_name. CLEAR p_ok.
WHEN 'DELE'. "delete row PERFORM fcode_delete_row USING p_tc_name p_table_name p_mark_name. CLEAR p_ok.
WHEN 'P--' OR "top of list 'P-' OR "previous page 'P+' OR "next page 'P++'. "bottom of list PERFORM compute_scrolling_in_tc USING p_tc_name l_ok. CLEAR p_ok. * WHEN 'L--'. "total left * PERFORM FCODE_TOTAL_LEFT USING P_TC_NAME. * * WHEN 'L-'. "column left * PERFORM FCODE_COLUMN_LEFT USING P_TC_NAME. * * WHEN 'R+'. "column right * PERFORM FCODE_COLUMN_RIGHT USING P_TC_NAME. * * WHEN 'R++'. "total right * PERFORM FCODE_TOTAL_RIGHT USING P_TC_NAME. * WHEN 'MARK'. "mark all filled lines PERFORM fcode_tc_mark_lines USING p_tc_name p_table_name p_mark_name . CLEAR p_ok.
WHEN 'DMRK'. "demark all filled lines PERFORM fcode_tc_demark_lines USING p_tc_name p_table_name p_mark_name . CLEAR p_ok.
* WHEN 'SASCEND' OR * 'SDESCEND'. "sort column * PERFORM FCODE_SORT_TC USING P_TC_NAME * l_ok.
ENDCASE.
ENDFORM. " USER_OK_TC
*&---------------------------------------------------------------------* *& Form FCODE_INSERT_ROW * *&---------------------------------------------------------------------* FORM fcode_insert_row USING p_tc_name TYPE dynfnam p_table_name .
*&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------* DATA l_lines_name LIKE feld-name. DATA l_selline LIKE sy-stepl. DATA l_lastline TYPE i. DATA l_line TYPE i. DATA l_table_name LIKE feld-name. DATA ls_zmm015 TYPE zmm015.
FIELD-SYMBOLS: , TYPE cxtab_control,
TYPE STANDARD TABLE, TYPE i, , , , , , . *&SPWIZARD: END OF LOCAL DATA------------------------------------------*
ASSIGN (p_tc_name) TO .
*&SPWIZARD: get the table, which belongs to the tc * CONCATENATE p_table_name '[]' INTO l_table_name. "table body ASSIGN (l_table_name) TO
. "not headerline
*&SPWIZARD: get looplines of TableControl * CONCATENATE 'G_' p_tc_name '_LINES' INTO l_lines_name. ASSIGN (l_lines_name) TO .
*&SPWIZARD: get current line * GET CURSOR LINE l_selline. IF sy-subrc <> 0. " append line to table l_selline = -lines + 1. *&SPWIZARD: set top line * IF l_selline > . -top_line = l_selline - + 1 . ELSE. -top_line = 1. ENDIF. ELSE. " insert line into table l_selline = -top_line + l_selline - 1. l_lastline = -top_line + - 1. ENDIF. *&SPWIZARD: set new cursor line * l_line = l_selline - -top_line + 1.
*&SPWIZARD: insert initial line * INSERT INITIAL LINE INTO
INDEX l_selline.
READ TABLE gt_zmm015 INTO ls_zmm015 WITH KEY zpltype = gs_zmm011h-zpltype.
LOOP AT
ASSIGNING . ASSIGN COMPONENT 'ZPREDOCITEM' OF STRUCTURE TO . IF IS ASSIGNED. = sy-tabix. ENDIF.
ASSIGN COMPONENT 'WERKS' OF STRUCTURE TO . IF IS ASSIGNED. = gs_zmm011h-werks. ENDIF.
ASSIGN COMPONENT 'LGORT' OF STRUCTURE TO . IF IS ASSIGNED. = gs_zmm011h-lgort. ENDIF.
ASSIGN COMPONENT 'LGORT_LGOBE' OF STRUCTURE TO . IF IS ASSIGNED. = gs_zmm011h-lgort_lgobe. ENDIF.
ASSIGN COMPONENT 'KOSTL' OF STRUCTURE TO . IF IS ASSIGNED. = gs_zmm011h-kostl. ENDIF.
ASSIGN COMPONENT 'BWART' OF STRUCTURE TO . IF IS ASSIGNED. = ls_zmm015-bwart1. ENDIF. ENDLOOP.
-lines = -lines + 1. *&SPWIZARD: set cursor * SET CURSOR LINE l_line.
ENDFORM. " FCODE_INSERT_ROW
*&---------------------------------------------------------------------* *& Form FCODE_DELETE_ROW * *&---------------------------------------------------------------------* FORM fcode_delete_row USING p_tc_name TYPE dynfnam p_table_name p_mark_name .
*&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------* DATA l_table_name LIKE feld-name.
FIELD-SYMBOLS TYPE cxtab_control. FIELD-SYMBOLS
TYPE STANDARD TABLE. FIELD-SYMBOLS . FIELD-SYMBOLS . FIELD-SYMBOLS . *&SPWIZARD: END OF LOCAL DATA------------------------------------------*
ASSIGN (p_tc_name) TO .
*&SPWIZARD: get the table, which belongs to the tc * CONCATENATE p_table_name '[]' INTO l_table_name. "table body ASSIGN (l_table_name) TO
. "not headerline
*&SPWIZARD: delete marked lines * DESCRIBE TABLE
LINES -lines.
LOOP AT
ASSIGNING .
*&SPWIZARD: access to the component 'FLAG' of the table header * ASSIGN COMPONENT p_mark_name OF STRUCTURE TO .
IF = abap_true. DELETE
INDEX syst-tabix. IF sy-subrc = 0. -lines = -lines - 1. ENDIF. ENDIF. ENDLOOP.
LOOP AT
ASSIGNING . ASSIGN COMPONENT 'ZPREDOCITEM' OF STRUCTURE TO . IF IS ASSIGNED. = sy-tabix. ENDIF. ENDLOOP.
REFRESH CONTROL p_tc_name FROM SCREEN sy-dynnr.
ENDFORM. " FCODE_DELETE_ROW
*&---------------------------------------------------------------------* *& Form COMPUTE_SCROLLING_IN_TC *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_TC_NAME name of tablecontrol * -->P_OK ok code *----------------------------------------------------------------------* FORM compute_scrolling_in_tc USING p_tc_name p_ok. *&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------* DATA l_tc_new_top_line TYPE i. DATA l_tc_name LIKE feld-name. DATA l_tc_lines_name LIKE feld-name. DATA l_tc_field_name LIKE feld-name.
FIELD-SYMBOLS TYPE cxtab_control. FIELD-SYMBOLS TYPE i. *&SPWIZARD: END OF LOCAL DATA------------------------------------------*
ASSIGN (p_tc_name) TO . *&SPWIZARD: get looplines of TableControl * CONCATENATE 'G_' p_tc_name '_LINES' INTO l_tc_lines_name. ASSIGN (l_tc_lines_name) TO .
*&SPWIZARD: get actual tc and column * GET CURSOR FIELD l_tc_field_name AREA l_tc_name.
IF syst-subrc = 0. IF l_tc_name = p_tc_name. *&SPWIZARD: et actual column * SET CURSOR FIELD l_tc_field_name LINE 1. ENDIF. ENDIF.
*&SPWIZARD: set the new top line * -top_line = l_tc_new_top_line.
ENDFORM. " COMPUTE_SCROLLING_IN_TC
*&---------------------------------------------------------------------* *& Form FCODE_TC_MARK_LINES *&---------------------------------------------------------------------* * marks all TableControl lines *----------------------------------------------------------------------* * -->P_TC_NAME name of tablecontrol *----------------------------------------------------------------------* FORM fcode_tc_mark_lines USING p_tc_name p_table_name p_mark_name. *&SPWIZARD: EGIN OF LOCAL DATA-----------------------------------------* DATA l_table_name LIKE feld-name.
FIELD-SYMBOLS TYPE cxtab_control. FIELD-SYMBOLS
TYPE STANDARD TABLE. FIELD-SYMBOLS . FIELD-SYMBOLS . *&SPWIZARD: END OF LOCAL DATA------------------------------------------*
ASSIGN (p_tc_name) TO .
*&SPWIZARD: get the table, which belongs to the tc * CONCATENATE p_table_name '[]' INTO l_table_name. "table body ASSIGN (l_table_name) TO
. "not headerline
*&SPWIZARD: mark all filled lines * LOOP AT
ASSIGNING .
*&SPWIZARD: access to the component 'FLAG' of the table header * ASSIGN COMPONENT p_mark_name OF STRUCTURE TO .
= 'X'. ENDLOOP. ENDFORM. "fcode_tc_mark_lines
*&---------------------------------------------------------------------* *& Form FCODE_TC_DEMARK_LINES *&---------------------------------------------------------------------* * demarks all TableControl lines *----------------------------------------------------------------------* * -->P_TC_NAME name of tablecontrol *----------------------------------------------------------------------* FORM fcode_tc_demark_lines USING p_tc_name p_table_name p_mark_name . *&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------* DATA l_table_name LIKE feld-name.
FIELD-SYMBOLS TYPE cxtab_control. FIELD-SYMBOLS
TYPE STANDARD TABLE. FIELD-SYMBOLS . FIELD-SYMBOLS . *&SPWIZARD: END OF LOCAL DATA------------------------------------------*
ASSIGN (p_tc_name) TO .
*&SPWIZARD: get the table, which belongs to the tc * CONCATENATE p_table_name '[]' INTO l_table_name. "table body ASSIGN (l_table_name) TO
. "not headerline
*&SPWIZARD: demark all filled lines * LOOP AT
ASSIGNING .
*&SPWIZARD: access to the component 'FLAG' of the table header * ASSIGN COMPONENT p_mark_name OF STRUCTURE TO .
= space. ENDLOOP. ENDFORM. "fcode_tc_mark_lines *&---------------------------------------------------------------------* *& Form CHANGE_FIELD_ATTR *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM change_field_attr . DATA: lv_input TYPE char01.
LOOP AT SCREEN.
IF g_edit <> gc_display AND g_edit <> gc_delete. lv_input = '1'. ELSE. lv_input = '0'. ENDIF.
IF screen-group1 = 'CHG'. screen-input = lv_input. MODIFY SCREEN. ENDIF.
IF g_edit <> gc_new. IF screen-name = 'GS_ZMM011H-ZPREDOCNO'. screen-input = '1'. MODIFY SCREEN. ENDIF. ENDIF.
ENDLOOP.
ENDFORM. *&---------------------------------------------------------------------* *& Form F4_KOSTL *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* * <--P_KOSTL text *&---------------------------------------------------------------------* FORM f4_kostl CHANGING p_kostl TYPE kostl. DATA: lt_return_tab TYPE TABLE OF ddshretval, ls_return_tab TYPE ddshretval, lv_display TYPE ddbool_d.
IF sy-subrc = 0. READ TABLE lt_return_tab INTO ls_return_tab INDEX 1. IF sy-subrc = 0. p_kostl = ls_return_tab-fieldval. ENDIF.
CALL FUNCTION 'SAPGUI_SET_FUNCTIONCODE' EXPORTING functioncode = '/00' EXCEPTIONS function_not_supported = 1 OTHERS = 2. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form F4_LGORT *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* * <--P_LGORT text *&---------------------------------------------------------------------* FORM f4_lgort CHANGING p_lgort TYPE lgort_d. DATA: lt_t001l_f4 TYPE TABLE OF ty_t001l_f4, ls_t001l TYPE ty_t001l, ls_t001l_f4 TYPE ty_t001l_f4, lt_return_tab TYPE TABLE OF ddshretval, ls_return_tab TYPE ddshretval, lv_display TYPE ddbool_d.
PERFORM check_field_editable CHANGING lv_display.
LOOP AT gt_t001l INTO ls_t001l. MOVE-CORRESPONDING ls_t001l TO ls_t001l_f4. APPEND ls_t001l_f4 TO lt_t001l_f4. ENDLOOP.
ENDFORM. *&---------------------------------------------------------------------* *& Form CHANGE_SCREEN_DATA *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM change_screen_data . DATA: ls_t001l TYPE ty_t001l, ls_cskt TYPE ty_cskt, ls_zmm011i TYPE zst_zmm011i, lv_tabix TYPE sy-tabix.
IF NOT gs_zmm011h-pernr IS INITIAL. READ TABLE gt_zmm016 WITH KEY pernr = gs_zmm011h-pernr TRANSPORTING NO FIELDS. IF sy-subrc <> 0. MESSAGE e000 WITH '申请人员工号不存在!'. ENDIF. ENDIF.
IF gs_zmm011h-aufnr IS NOT INITIAL. IF gs_zmm011h-zissueqty > gs_zmm011h-wemng. MESSAGE e000 WITH '发出套数不允许大于未结量!'. ENDIF. ENDIF.
IF NOT gs_zmm011h-lgort IS INITIAL. READ TABLE gt_t001l INTO ls_t001l WITH KEY werks = gs_zmm011h-werks lgort = gs_zmm011h-lgort. IF sy-subrc = 0. gs_zmm011h-lgort_lgobe = ls_t001l-lgobe.
ls_zmm011i-lgort = gs_zmm011h-lgort. ls_zmm011i-lgort_lgobe = ls_t001l-lgobe. MODIFY gt_zmm011i FROM ls_zmm011i TRANSPORTING lgort lgort_lgobe WHERE lgort <> gs_zmm011h-lgort.
LOOP AT gt_zmm011i INTO ls_zmm011i WHERE matnr <> space. lv_tabix = sy-tabix. PERFORM get_item_additional_info CHANGING ls_zmm011i. IF gs_zmm011h-auart <> 'SK03' AND gs_zmm011h-auart <> 'SK04'. ls_zmm011i-menge = gs_zmm011h-zissueqty * ls_zmm011i-bom_ratio. ENDIF. MODIFY gt_zmm011i FROM ls_zmm011i INDEX lv_tabix. ENDLOOP.
ELSE. MESSAGE e015 WITH gs_zmm011h-lgort. ENDIF. ENDIF.
IF NOT gs_zmm011h-zissueqty IS INITIAL.
LOOP AT gt_zmm011i INTO ls_zmm011i. lv_tabix = sy-tabix. IF gs_zmm011h-auart <> 'SK03' AND gs_zmm011h-auart <> 'SK04'. ls_zmm011i-menge = gs_zmm011h-zissueqty * ls_zmm011i-bom_ratio. ENDIF. * IF ls_zmm011i-menge > ls_zmm011i-available AND ls_zmm011i-select = abap_true. * MESSAGE e028 WITH sy-tabix. * ENDIF. MODIFY gt_zmm011i FROM ls_zmm011i INDEX lv_tabix. ENDLOOP.
ENDIF.
ENDFORM. *&---------------------------------------------------------------------* *& Form F4_PREDOC *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* * <--P_PREDOC text *&---------------------------------------------------------------------* FORM f4_predoc USING p_enter TYPE char01 CHANGING p_predoc TYPE zpredocno. DATA: lt_predocno TYPE TABLE OF ty_predocno, lt_return_tab TYPE TABLE OF ddshretval, ls_return_tab TYPE ddshretval, lv_display TYPE ddbool_d.
PERFORM check_field_editable CHANGING lv_display.
SELECT zpredocno INTO TABLE lt_predocno FROM zmm011h WHERE zbsart = p_zbsart AND werks = p_werks.
IF sy-subrc = 0. READ TABLE lt_return_tab INTO ls_return_tab INDEX 1. IF sy-subrc = 0. p_predoc = ls_return_tab-fieldval.
IF p_enter = abap_true. CALL FUNCTION 'SAPGUI_SET_FUNCTIONCODE' EXPORTING functioncode = '/00' EXCEPTIONS function_not_supported = 1 OTHERS = 2. ENDIF. ENDIF.
ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form USER_COMMAND_2100 *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM user_command_2100 . DATA: lv_ucomm TYPE sy-ucomm.
lv_ucomm = sy-ucomm. CLEAR sy-ucomm.
CASE lv_ucomm. WHEN gc_ucomm-yes. PERFORM show_query. SET SCREEN 0. WHEN gc_ucomm-no. SET SCREEN 0. ENDCASE.
ENDFORM. *&---------------------------------------------------------------------* *& Form TC_2000_MODIFY *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM tc_2000_modify .
* IF gs_zmm011i-menge > gs_zmm011i-available. * MESSAGE e016. * ENDIF.
MODIFY gt_zmm011i FROM gs_zmm011i INDEX tc_2000-current_line.
ENDFORM. *&---------------------------------------------------------------------* *& Form TC_2000_MARK *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM tc_2000_mark . DATA: ls_zmm011i LIKE LINE OF gt_zmm011i.
IF tc_2000-line_sel_mode = 1 AND gs_zmm011i-select = abap_true. LOOP AT gt_zmm011i INTO ls_zmm011i WHERE select = abap_true. ls_zmm011i-select = space. MODIFY gt_zmm011i FROM ls_zmm011i TRANSPORTING select. ENDLOOP. ENDIF.
MODIFY gt_zmm011i FROM gs_zmm011i INDEX tc_2000-current_line TRANSPORTING select.
ENDFORM. *&---------------------------------------------------------------------* *& Form USER_COMMAND_3000 *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM user_command_2200 . DATA: lv_ucomm TYPE sy-ucomm.
lv_ucomm = sy-ucomm. CLEAR sy-ucomm.
CASE lv_ucomm. WHEN gc_ucomm-yes. gv_confirm = abap_true. SET SCREEN 0. WHEN gc_ucomm-no. gv_confirm = space. SET SCREEN 0. ENDCASE.
ENDFORM. *&---------------------------------------------------------------------* *& Form F4_ZPLTYPE *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* * <--P_ZPLTYPE text *&---------------------------------------------------------------------* FORM f4_zpltype CHANGING p_zpltype TYPE zpltype. DATA: lt_zmm015_f4 TYPE TABLE OF ty_zmm015_f4, ls_zmm015_f4 TYPE ty_zmm015_f4, ls_zmm015 TYPE zmm015, lv_display TYPE ddbool_d.
PERFORM check_field_editable CHANGING lv_display.
LOOP AT gt_zmm015 INTO ls_zmm015. MOVE-CORRESPONDING ls_zmm015 TO ls_zmm015_f4. APPEND ls_zmm015_f4 TO lt_zmm015_f4. ENDLOOP.
ENDFORM. *&---------------------------------------------------------------------* *& Form CHECK_MATERIAL_DUPLICATES *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM check_material_duplicates . DATA: ls_zmm011i TYPE zst_zmm011i.
LOOP AT gt_zmm011i INTO ls_zmm011i WHERE zpredocitem <> gs_zmm011i-zpredocitem AND matnr = gs_zmm011i-matnr. ENDLOOP. IF sy-subrc = 0. MESSAGE e000 WITH '物料号不允许出现重复'. ENDIF.
ENDFORM. *&---------------------------------------------------------------------* *& Form STATUS_2000 *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM status_2000 . DATA: lt_excluding TYPE TABLE OF fcode.
CASE g_edit. WHEN gc_display. APPEND: gc_ucomm-park TO lt_excluding, gc_ucomm-post TO lt_excluding, gc_ucomm-delete TO lt_excluding. WHEN gc_new. APPEND: gc_ucomm-post TO lt_excluding, gc_ucomm-delete TO lt_excluding, gc_ucomm-print TO lt_excluding, gc_ucomm-writeoff TO lt_excluding. WHEN gc_change. WHEN gc_delete. APPEND: gc_ucomm-post TO lt_excluding, gc_ucomm-park TO lt_excluding, gc_ucomm-delete TO lt_excluding, gc_ucomm-writeoff TO lt_excluding. ENDCASE.
SET PF-STATUS gc_2000 EXCLUDING lt_excluding.
SET TITLEBAR gc_2000 WITH gs_zmm010-zbatxt.
ENDFORM. *&---------------------------------------------------------------------* *& Form F4_PERNR *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* * <--P_GS_ZMM011H_PERNR text *&---------------------------------------------------------------------* FORM f4_pernr CHANGING p_pernr TYPE zpernr. DATA: lt_zmm016 TYPE TABLE OF ty_zmm016_f4, lt_return_tab TYPE TABLE OF ddshretval, ls_return_tab TYPE ddshretval, lv_display TYPE ddbool_d.
IF sy-subrc = 0. READ TABLE lt_return_tab INTO ls_return_tab INDEX 1. IF sy-subrc = 0. p_pernr = ls_return_tab-fieldval. ENDIF.
ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form GET_PRODUCT_ORDER *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM get_product_order USING p_getrseb TYPE char01 p_aufnr TYPE aufnr. DATA: ls_marc TYPE ty_marc, ls_afpo TYPE ty_afpo, lt_resb TYPE TABLE OF ty_resb, lt_matdoc TYPE TABLE OF ty_matdoc, ls_matdoc TYPE ty_matdoc, ls_resb TYPE ty_resb, ls_zmm011i TYPE zst_zmm011i, lt_status TYPE TABLE OF jstat. **********************************************************************
DATA: ls_zdstatus TYPE ty_zdstatus, lt_zdstatus TYPE TABLE OF ty_zdstatus. ********************************************************************** SELECT SINGLE t1~aufnr auart rsnum objnr matnr AS plnbez psmng wemng INTO CORRESPONDING FIELDS OF ls_afpo FROM afko AS t1 INNER JOIN afpo AS t2 ON t1~aufnr = t2~aufnr INNER JOIN aufk AS t3 ON t1~aufnr = t3~aufnr WHERE t1~aufnr = p_aufnr AND auart LIKE 'SK%' AND werks = gs_zmm011h-werks.
IF sy-subrc <> 0. MESSAGE e000 WITH '生产订单号不存在!'. ENDIF.
IF p_getrseb = abap_true. CALL FUNCTION 'STATUS_READ' EXPORTING objnr = ls_afpo-objnr only_active = 'X' TABLES status = lt_status EXCEPTIONS object_not_found = 1 OTHERS = 2.
IF sy-subrc = 0. READ TABLE lt_status WITH KEY stat = 'I0076' TRANSPORTING NO FIELDS. IF sy-subrc = 0. MESSAGE e000 WITH '该生产订单已删除'. ELSE. READ TABLE lt_status WITH KEY stat = 'I0045' TRANSPORTING NO FIELDS. IF sy-subrc = 0. MESSAGE e000 WITH '该生产订单已关闭'. ELSE. READ TABLE lt_status WITH KEY stat = 'I0001' TRANSPORTING NO FIELDS. IF sy-subrc = 0. MESSAGE e000 WITH '该生产订单还未下达'. ENDIF. ENDIF. ENDIF. ENDIF. ENDIF.
********************************************************************** "累计已制单数量 SELECT t1~matnr SUM( t1~menge ) AS menge INTO CORRESPONDING FIELDS OF TABLE lt_zdstatus FROM zmm011h AS t INNER JOIN zmm011i AS t1 ON t~zpredocno = t1~zpredocno WHERE t~zpoststatus IN ( '01','04' ) AND t~zpredocstatus = '01' AND t~zbsart = 'ZM07' AND t~aufnr = gs_zmm011h-aufnr AND t~werks = gs_zmm011h-werks GROUP BY t1~matnr. **********************************************************************
"累计已领料数量 SELECT matnr, SUM( CASE WHEN bwart = '261' THEN menge WHEN bwart = '262' THEN menge * -1 END ) AS menge INTO CORRESPONDING FIELDS OF TABLE @lt_matdoc FROM matdoc WHERE bwart IN ( '261', '262' ) AND aufnr = @gs_zmm011h-aufnr AND werks = @gs_zmm011h-werks GROUP BY matnr.
SORT lt_matdoc BY matnr. "组件预留明细 SELECT matnr rspos bdmng enmng INTO TABLE lt_resb FROM resb WHERE rsnum = ls_afpo-rsnum AND ( dumps <> abap_true AND schgt <> abap_true AND rgekz <> abap_true AND xloek <> abap_true ) AND bwart <> '531'.
READ TABLE lt_matdoc INTO ls_matdoc WITH KEY matnr = ls_resb-matnr BINARY SEARCH. IF sy-subrc = 0. ls_zmm011i-enmng = ls_matdoc-menge. ENDIF.
IF gs_zmm011h-auart = 'SK03' OR gs_zmm011h-auart = 'SK04'. ls_zmm011i-menge = ls_resb-bdmng. ELSE. ls_zmm011i-menge = gs_zmm011h-zissueqty * ls_zmm011i-bom_ratio. ENDIF.
PERFORM get_item_additional_info CHANGING ls_zmm011i. APPEND ls_zmm011i TO gt_zmm011i. ENDLOOP.
ELSE.
LOOP AT gt_zmm011i INTO ls_zmm011i. READ TABLE lt_resb INTO ls_resb WITH KEY matnr = ls_zmm011i-matnr. IF sy-subrc = 0. ls_zmm011i-bdmng = ls_resb-bdmng.
READ TABLE lt_matdoc INTO ls_matdoc WITH KEY matnr = ls_resb-matnr BINARY SEARCH. IF sy-subrc = 0. ls_zmm011i-enmng = ls_matdoc-menge. ENDIF. IF ls_afpo-psmng <> 0. ls_zmm011i-bom_ratio = ls_resb-bdmng / ls_afpo-psmng. ENDIF. ENDIF.
MODIFY gt_zmm011i FROM ls_zmm011i TRANSPORTING bdmng enmng bom_ratio. ENDLOOP. ENDIF.
"by skgljc add start LOOP AT gt_zmm011i ASSIGNING FIELD-SYMBOL().
READ TABLE lt_zdstatus INTO ls_zdstatus WITH KEY matnr = -matnr. IF sy-subrc = 0. "累计领料数量 = 实际的领料数量(已过账) + 已制单的数量(未过账) -enmng = -enmng + ls_zdstatus-menge.
ENDIF.
ENDLOOP.
ENDFORM. *&---------------------------------------------------------------------* *& Form CHECK_FIELD_EDITABLE *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* * <--P_LV_DISPLAY text *&---------------------------------------------------------------------* FORM check_field_editable CHANGING p_display TYPE ddbool_d. DATA: lt_dynpread TYPE TABLE OF dynpread, ls_dynpread TYPE dynpread.
GET CURSOR FIELD ls_dynpread-fieldname. APPEND ls_dynpread TO lt_dynpread.
IF sy-subrc = 0. READ TABLE lt_dynpread INTO ls_dynpread INDEX 1. IF sy-subrc = 0. IF ls_dynpread-fieldinp <> abap_true. p_display = abap_true. ENDIF. ENDIF. ENDIF.
ENDFORM.
*&---------------------------------------------------------------------* *& Include ZMM001_ZM01F02 *&---------------------------------------------------------------------* *&---------------------------------------------------------------------* *&变更记录: *&Date Developer ReqNo Descriptions *& ========== ================== ========== ========================* *& 2017-09-20 Aaron(Hand) ED1K900147 初始开发 *&---------------------------------------------------------------------* *&---------------------------------------------------------------------* *& Form START_OF_SELECTION *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM start_of_selection .
"取工厂名称 SELECT SINGLE werks name1 bwkey INTO CORRESPONDING FIELDS OF gs_t001w FROM t001w WHERE werks = p_werks. "取单据类型主数据 SELECT SINGLE * INTO gs_zmm010 FROM zmm010 WHERE zbsart = p_zbsart. "取领料类型主数据 SELECT * INTO TABLE gt_zmm015 FROM zmm015. "取库位主数据 SELECT t1~werks t1~lgort lgobe adrnr INTO CORRESPONDING FIELDS OF TABLE gt_t001l FROM t001l AS t1 LEFT OUTER JOIN twlad AS t2 ON t1~werks = t2~werks AND t1~lgort = t2~lgort AND t2~lfdnr = '01' WHERE t1~werks = p_werks.
SORT gt_t001l BY werks lgort. "取库位主数据 SELECT addrnumber name1 tel_number street INTO CORRESPONDING FIELDS OF TABLE gt_adrc FROM adrc. "取成本中心主数据 SELECT t1~kostl t1~datbi ktext INTO CORRESPONDING FIELDS OF TABLE gt_cskt FROM csks AS t1 INNER JOIN cskt AS t2 ON t1~kokrs = t2~kokrs AND t1~kostl = t2~kostl AND t1~datbi = t2~datbi WHERE t2~spras = sy-langu AND t1~kokrs = '1000' AND bukrs = gs_t001w-bwkey. "取物料基本数据 SELECT t1~matnr werks meins maktx groes INTO CORRESPONDING FIELDS OF TABLE gt_marc FROM marc AS t1 INNER JOIN mara AS t2 ON t1~matnr = t2~matnr LEFT OUTER JOIN makt AS t3 ON t2~matnr = t3~matnr AND t3~spras = sy-langu WHERE werks = p_werks. "取物料库存数据 SELECT matnr werks lgort labst INTO CORRESPONDING FIELDS OF TABLE gt_mard FROM mard WHERE werks = p_werks AND labst > 0.
"取申请人工号 SELECT pernr ename INTO TABLE gt_zmm016 FROM zmm016.
IF p_predoc IS NOT INITIAL. gs_zmm011h-zpredocno = p_predoc. PERFORM get_predoc_info USING gs_zmm011h-zpredocno. ENDIF.
CALL SCREEN gc_2000.
ENDFORM. *&---------------------------------------------------------------------* *& Form NEW *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM new . DATA: ls_zmm011i TYPE zst_zmm011i.
DO 260 TIMES. ls_zmm011i-zpredocitem = sy-index. ls_zmm011i-bwart = gs_zmm010-bwart. ls_zmm011i-werks = gs_t001w-werks. ls_zmm011i-zpreitempoststatus = gc_default_status. APPEND ls_zmm011i TO gt_zmm011i. ENDDO.
CLEAR: gs_zmm011h_old, gt_zmm011i_old. ENDFORM. *&---------------------------------------------------------------------* *& Form CHANGE *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM change . DATA: lv_max_predocno TYPE zpredocno.
CLEAR: gt_zmm011i,g_edit.
IF gs_zmm011h-zpredocno IS INITIAL. CLEAR gs_zmm011h. SELECT MAX( zpredocno ) INTO lv_max_predocno FROM zmm011h WHERE werks = p_werks AND zbsart = p_zbsart. ELSE. lv_max_predocno = gs_zmm011h-zpredocno. ENDIF.
IF lv_max_predocno = space. MESSAGE e003. ENDIF.
PERFORM get_predoc_info USING lv_max_predocno.
ENDFORM. *&---------------------------------------------------------------------* *& Form QUERY *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM query . CALL SCREEN gc_2100 STARTING AT 10 10. ENDFORM. *&---------------------------------------------------------------------* *& Form PARK *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM park . DATA: lv_error TYPE i, lv_tabix TYPE sy-tabix, ls_zmm011h_db TYPE zmm011h, lt_zmm011i_screen TYPE TABLE OF zst_zmm011i, ls_zmm011i_screen TYPE zst_zmm011i, ls_zmm011i_db TYPE zmm011i, lt_zmm011i_db TYPE TABLE OF zmm011i, lt_zmm011i_db_del TYPE TABLE OF zmm011i, lt_stock_check TYPE TABLE OF ty_stock_check, ls_stock_check TYPE ty_stock_check. ********************************************************************** DATA: lv_answer TYPE c, lv_textline1 TYPE string, lv_textline2 TYPE string, lt_matdoc TYPE TABLE OF ty_matdoc, ls_matdoc TYPE ty_matdoc, lv_err TYPE i, lv_posted_menge TYPE menge_d, lv_menge TYPE menge_d, ls_zdstatus TYPE ty_zdstatus, lt_zdstatus TYPE TABLE OF ty_zdstatus. ********************************************************************** " 检查抬头 lt_zmm011i_screen = gt_zmm011i. DELETE lt_zmm011i_screen WHERE matnr = space. DELETE lt_zmm011i_screen WHERE select = space.
IF gs_zmm011h-zpredocno = space AND g_edit = gc_change. MESSAGE e010. ENDIF.
IF gs_zmm011h-lgort IS INITIAL. MESSAGE e002. ENDIF.
IF gs_zmm011h-aufnr IS INITIAL. MESSAGE e000 WITH '请输入生产订单号!'.. ENDIF.
" 检查行项目 IF lines( lt_zmm011i_screen ) = 0. MESSAGE e000 WITH '请选择发料行'. ENDIF. ********************************************************************** CLEAR: lt_zdstatus. "累计已制单数量 SELECT t1~matnr SUM( t1~menge ) AS menge INTO CORRESPONDING FIELDS OF TABLE lt_zdstatus FROM zmm011h AS t INNER JOIN zmm011i AS t1 ON t~zpredocno = t1~zpredocno WHERE t~zpoststatus IN ( '01','04' ) AND t~zpredocstatus = '01' AND t~zbsart = 'ZM07' AND t~aufnr = gs_zmm011h-aufnr AND t~werks = gs_zmm011h-werks GROUP BY t1~matnr.
"累计已领料数量 SELECT matnr, SUM( CASE WHEN bwart = '261' THEN menge WHEN bwart = '262' THEN menge * -1 END ) AS menge INTO CORRESPONDING FIELDS OF TABLE @lt_matdoc FROM matdoc WHERE bwart IN ( '261', '262' ) AND aufnr = @gs_zmm011h-aufnr AND werks = @gs_zmm011h-werks GROUP BY matnr. **********************************************************************
LOOP AT gt_zmm011i INTO ls_zmm011i_screen WHERE matnr <> space AND select = abap_true. * AND menge = 0. IF ls_zmm011i_screen-menge = 0. lv_error = 1. EXIT. ELSE. CLEAR ls_stock_check. " 限额领用数量小于累计已领数量 IF ls_zmm011i_screen-bdmng < ls_zmm011i_screen-enmng. lv_error = 3. EXIT. ENDIF. " * IF ls_zmm011i_screen-bdmng < ls_zmm011i_screen-enmng + ls_zmm011i_screen-menge."原来的逻辑 * lv_error = 4. * EXIT. * ENDIF. ********************************************************************** CLEAR:lv_menge,lv_posted_menge. "累计已领数量 + 输入数量 - 已制单的数量 > 限额领料数量 IF ls_zmm011i_screen-bdmng < ls_zmm011i_screen-enmng + ls_zmm011i_screen-menge - ls_zmm011i_screen-flag_menge. lv_error = 4.
READ TABLE lt_zdstatus INTO ls_zdstatus WITH KEY matnr = ls_zmm011i_screen-matnr. IF sy-subrc = 0. "占单(未过账) 的数量(不包括输入的数量) lv_menge = ls_zdstatus-menge. READ TABLE lt_matdoc INTO ls_matdoc WITH KEY matnr = ls_zmm011i_screen-matnr. IF sy-subrc = 0. "实际已过帐数量 lv_posted_menge = ls_matdoc-menge. ENDIF. lv_err = 5. ENDIF.
READ TABLE lt_stock_check INTO ls_stock_check WITH KEY matnr = ls_zmm011i_screen-matnr. IF sy-subrc = 0. lv_tabix = sy-tabix. ls_zmm011i_screen-zpredocitem = |{ ls_zmm011i_screen-zpredocitem ALPHA = OUT }|. ls_stock_check-menge = ls_zmm011i_screen-menge + ls_stock_check-menge. * CONCATENATE ls_stock_check-itemno * ls_zmm011i_screen-zpredocitem * into ls_stock_check-itemno * SEPARATED BY ','.
ls_stock_check-itemno = ls_stock_check-itemno && '/' && |{ ls_zmm011i_screen-zpredocitem ALPHA = OUT }|. MODIFY lt_stock_check FROM ls_stock_check INDEX lv_tabix. ELSE. ls_stock_check-matnr = ls_zmm011i_screen-matnr. ls_stock_check-menge = ls_zmm011i_screen-menge. ls_stock_check-itemno = |{ ls_zmm011i_screen-zpredocitem ALPHA = OUT }|. APPEND ls_stock_check TO lt_stock_check. ENDIF. ENDIF.
ENDLOOP.
IF lv_error = 0. LOOP AT lt_stock_check INTO ls_stock_check.
READ TABLE lt_zmm011i_screen INTO ls_zmm011i_screen WITH KEY matnr = ls_stock_check-matnr. IF sy-subrc = 0. IF ls_zmm011i_screen-available < ls_stock_check-menge. lv_error = 2. EXIT. ENDIF. ENDIF. ENDLOOP. ENDIF.
CASE lv_error. WHEN 1. MESSAGE e029 WITH |{ ls_zmm011i_screen-zpredocitem ALPHA = OUT }|. WHEN 2. MESSAGE e032 WITH ls_stock_check-itemno. WHEN 3. MESSAGE e039 WITH |{ ls_zmm011i_screen-zpredocitem ALPHA = OUT }|. WHEN 4. ********************************************************************** SHIFT ls_zmm011i_screen-zpredocitem LEFT DELETING LEADING '0'. IF lv_err EQ 5. lv_textline1 = '第' && ls_zmm011i_screen-zpredocitem && '行领用数量与累计已领用数量之和不能超过限额领料数量!其中本生产订单占单量(未过账)有:'&& lv_menge. lv_textline2 = '实际累计已过帐的有:' && lv_posted_menge && '请核对相关生产订单的预制单(已制)和实际过账的数量!再考虑是否开超领单'. CALL FUNCTION 'POPUP_TO_CONFIRM_STEP' EXPORTING titel = '警告!!' textline1 = lv_textline1 textline2 = lv_textline2 cancel_display = space IMPORTING answer = lv_answer.
IF lv_answer <> '1'. RETURN. ENDIF.
* MESSAGE e046 WITH |{ ls_zmm011i_screen-zpredocitem ALPHA = OUT }| |{ lv_menge }| |{ lv_posted_menge }|. ELSE. MESSAGE e041 WITH |{ ls_zmm011i_screen-zpredocitem ALPHA = OUT }|. ENDIF. ********************************************************************** * MESSAGE e041 WITH |{ ls_zmm011i_screen-zpredocitem ALPHA = OUT }|."之前逻辑
READ TABLE gt_zmm011i WITH KEY zpredocno = ls_zmm011i_screen-zpredocno zpredocitem = ls_zmm011i_screen-zpredocitem TRANSPORTING NO FIELDS. IF sy-subrc <> 0. MOVE-CORRESPONDING ls_zmm011i_screen TO ls_zmm011i_db. APPEND ls_zmm011i_db TO lt_zmm011i_db_del. ENDIF. ENDLOOP.
LOOP AT gt_zmm011i INTO ls_zmm011i_screen WHERE matnr <> space AND select = abap_true AND menge <> 0. MOVE-CORRESPONDING ls_zmm011i_screen TO ls_zmm011i_db. ls_zmm011i_db-zpredocno = gs_zmm011h-zpredocno. ls_zmm011i_db-kostl = gs_zmm011h-kostl. APPEND ls_zmm011i_db TO lt_zmm011i_db. ********************************************************************** ls_zmm011i_screen-flag_menge = ls_zmm011i_screen-menge. ********************************************************************** ENDLOOP.
MODIFY zmm011h FROM ls_zmm011h_db.
DELETE zmm011i FROM TABLE lt_zmm011i_db_del.
MODIFY zmm011i FROM TABLE lt_zmm011i_db. IF sy-subrc = 0. gs_zmm011h_old = gs_zmm011h. gt_zmm011i_old = gt_zmm011i. g_edit = gc_change. PERFORM unlock_predoc USING gs_zmm011h-zpredocno. MESSAGE s005 WITH gs_zmm011h-zpredocno. ENDIF.
ENDFORM. *&---------------------------------------------------------------------* *& Form SAVE *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM save .
PERFORM park.
PERFORM post.
ENDFORM. *&---------------------------------------------------------------------* *& Form POST *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM post. DATA: lt_predoc_post TYPE TABLE OF zmm_predoc_log, ls_predoc_post TYPE zmm_predoc_log, ls_zmm011i TYPE zst_zmm011i.
IF gs_zmm011h <> gs_zmm011h_old OR gt_zmm011i <> gt_zmm011i_old. MESSAGE e000 WITH '未保存不允许预制过账'. ENDIF.
LOOP AT gt_zmm011i INTO ls_zmm011i. CLEAR ls_predoc_post.
MOVE-CORRESPONDING ls_zmm011i TO ls_predoc_post. IF ls_predoc_post-zpredocno IS INITIAL. ls_predoc_post-zpredocno = gs_zmm011h-zpredocno. ENDIF. ls_predoc_post-budat = sy-datum. ls_predoc_post-zreleaseind = '2'. APPEND ls_predoc_post TO lt_predoc_post.
ENDLOOP.
CALL FUNCTION 'ZZMM_PREDOC_POST' TABLES t_predoc_post = lt_predoc_post.
READ TABLE lt_predoc_post INTO ls_predoc_post WITH KEY status = 'E'. IF sy-subrc <> 0. READ TABLE lt_predoc_post INTO ls_predoc_post WITH KEY status = 'S'. gs_zmm011h-zpredocstatus = '03'.
g_edit = gc_display. MESSAGE s000 WITH ls_predoc_post-message. ELSE. MESSAGE e000 WITH ls_predoc_post-message. ENDIF.
ENDFORM. *&---------------------------------------------------------------------* *& Form DELETE *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM delete .
IF gs_zmm011h-zpredocno = space. MESSAGE e010. ENDIF.
IF gs_zmm011h-zpredocstatus NOT IN gt_changeable. MESSAGE e008 WITH gs_zmm011h-zpredocno. ENDIF.
UPDATE zmm011h SET zpredocstatus = gc_status_delete WHERE zpredocno = gs_zmm011h-zpredocno.
* DELETE FROM zmm011i WHERE zpredocno = gs_zmm011h-zpredocno.
IF sy-subrc = 0. g_edit = gc_delete. gs_zmm011h-zpredocstatus = gc_status_delete. MESSAGE s009 WITH gs_zmm011h-zpredocno. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form PRINT *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM print . DATA: lt_zmm011i TYPE TABLE OF zst_zmm011i, lv_fm_name TYPE rs38l_fnam, ls_output TYPE ssfcresop.
IF gs_zmm011h-zpredocno = space. MESSAGE e010. ENDIF.
IF gs_zmm010-ssfname = space. MESSAGE e011. ENDIF.
PERFORM get_user_fullname USING gs_zmm011h-ernam CHANGING gs_zmm011h-ernam_name_text.
lt_zmm011i = gt_zmm011i.
DELETE lt_zmm011i WHERE matnr = space. DELETE lt_zmm011i WHERE select = space.
CALL FUNCTION lv_fm_name EXPORTING * control_parameters = l_control * output_options = lw_output * g_biaoshi = g_biaoshi gs_header = gs_zmm011h IMPORTING job_output_options = ls_output TABLES gt_items = lt_zmm011i EXCEPTIONS formatting_error = 1 internal_error = 2 send_error = 3 user_canceled = 4 OTHERS = 5. IF sy-subrc = 0. IF ls_output-tdpreview = space. " 如果是打印,则记录打印次数 gs_zmm011h-zprint_count = gs_zmm011h-zprint_count + 1. UPDATE zmm011h SET zprint_count = gs_zmm011h-zprint_count WHERE zpredocno = gs_zmm011h-zpredocno. ENDIF. ENDIF. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form WRITEOFF *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM writeoff . DATA: lt_return TYPE bapiret2_t, ls_return TYPE bapiret2.
CLEAR: gv_confirm, gv_writeoff_date.
IF gs_zmm011h-zpoststatus = '03'. MESSAGE e012 WITH gs_zmm011h-zpredocno. ELSE. IF gs_zmm011h-zpoststatus <> '02'. MESSAGE e013 WITH gs_zmm011h-zpredocno. ENDIF. ENDIF.
gv_writeoff_date = sy-datum.
CALL SCREEN gc_2200 STARTING AT 10 5.
IF gv_confirm = abap_true. PERFORM writeoff_post CHANGING gs_zmm011h lt_return.
READ TABLE lt_return INTO ls_return INDEX 1.
MESSAGE ID ls_return-id TYPE ls_return-type NUMBER ls_return-number WITH ls_return-message_v1 ls_return-message_v2 ls_return-message_v3 ls_return-message_v4. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form GET_NEW_PREDOCNO *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* * <--P_NEW_PREDOCNO text *&---------------------------------------------------------------------* FORM get_new_predocno USING p_zbsart TYPE zbsart CHANGING p_new_predocno TYPE zpredocno. DATA: ls_zmm013 TYPE zmm013.
CALL FUNCTION 'ENQUEUE_EZ_ZMM013' EXPORTING zbsart = gs_zmm010-zbsart datum = sy-datum EXCEPTIONS foreign_lock = 1 system_failure = 2 OTHERS.
IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF.
SELECT SINGLE * INTO ls_zmm013 FROM zmm013 WHERE zbsart = gs_zmm010-zbsart AND datum = sy-datum.
ls_zmm013-zbsart = gs_zmm010-zbsart. ls_zmm013-datum = sy-datum. MODIFY zmm013 FROM ls_zmm013.
CALL FUNCTION 'DEQUEUE_EZ_ZMM013' EXPORTING zbsart = gs_zmm010-zbsart datum = sy-datum.
ENDFORM. *&---------------------------------------------------------------------* *& Form GET_PREDOC_INFO *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* * -->P_PREDOCNO text *&---------------------------------------------------------------------* FORM get_predoc_info USING p_predocno TYPE zpredocno. DATA: ls_t001l TYPE t001l, ls_cskt TYPE ty_cskt, ls_zmm015 TYPE zmm015.
FIELD-SYMBOLS: TYPE zst_zmm011i.
SELECT SINGLE * INTO CORRESPONDING FIELDS OF gs_zmm011h FROM zmm011h WHERE zpredocno = p_predocno AND zbsart = gs_zmm010-zbsart. IF sy-subrc <> 0. MESSAGE e006 WITH p_predocno. ENDIF.
ENDFORM. *&---------------------------------------------------------------------* *& Form WRITEOFF_POST *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM writeoff_post CHANGING p_zmm011h TYPE zst_zmm011h pt_return TYPE bapiret2_t. DATA: ls_goodsmvt_headret TYPE bapi2017_gm_head_ret, lt_return TYPE TABLE OF bapiret2, ls_return TYPE bapiret2, lv_mblnr TYPE mblnr.
IF ls_goodsmvt_headret-mat_doc IS INITIAL. CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
READ TABLE lt_return INTO ls_return WITH KEY type = 'E'. IF sy-subrc <> 0. READ TABLE lt_return INTO ls_return WITH KEY type = 'A'. ENDIF.
IF sy-subrc = 0. MESSAGE e000 WITH ls_return-message. ELSE. MESSAGE e019. ENDIF. ELSE. READ TABLE lt_return INTO ls_return WITH KEY type = 'E'. IF sy-subrc <> 0. READ TABLE lt_return INTO ls_return WITH KEY type = 'A'. ENDIF.
IF sy-subrc = 0. CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. APPEND ls_return TO pt_return. ELSE. "返回了凭证号,同时未返回任何错误消息,则判断未成功 "提交事务 CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X'.
DO 50 TIMES. SELECT SINGLE mblnr "物料凭证号 INTO lv_mblnr FROM mkpf WHERE mblnr = ls_goodsmvt_headret-mat_doc AND mjahr = ls_goodsmvt_headret-doc_year. IF sy-subrc = 0. EXIT. ELSE. WAIT UP TO '0.1' SECONDS. ENDIF. ENDDO.
IF lv_mblnr IS INITIAL.
CALL FUNCTION 'BALW_BAPIRETURN_GET2' EXPORTING type = 'E' cl = 'ZMM_PREDOC' number = '018' IMPORTING return = ls_return EXCEPTIONS OTHERS = 0. APPEND ls_return TO pt_return.
UPDATE zmm011i SET zpreitempoststatus = p_zmm011h-zpoststatus WHERE zpredocno = p_zmm011h-zpredocno.
ls_return-message_v1 = p_zmm011h-zpredocno. ls_return-message_v2 = p_zmm011h-zlastwriteoffmblnr. CALL FUNCTION 'BALW_BAPIRETURN_GET2' EXPORTING type = 'S' cl = 'ZMM_PREDOC' number = '017' par1 = ls_return-message_v1 par2 = ls_return-message_v2 IMPORTING return = ls_return EXCEPTIONS OTHERS = 0. APPEND ls_return TO pt_return.
* MESSAGE s017 WITH p_zmm011h-zpredocno p_zmm011h-zlastwriteoffmblnr. ENDIF. ENDIF.
ENDIF.
ENDFORM. *&---------------------------------------------------------------------* *& Form SHOW_QUERY_GRID *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM show_query_grid . DATA: ls_layout_lvc TYPE lvc_s_layo, lt_fieldcat TYPE lvc_t_fcat, ls_grid_settings TYPE lvc_s_glay.
ENDFORM. *&---------------------------------------------------------------------* *& Form FILL_FIELDCAT *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* * <--PT_FIELDCAT text *&---------------------------------------------------------------------* FORM grid_status_set USING pt_extab TYPE slis_t_extab.
SET PF-STATUS 'GRID_STATUS' EXCLUDING pt_extab.
ENDFORM. *&---------------------------------------------------------------------* *& Form FILL_FIELDCAT *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* * <--PT_FIELDCAT text *&---------------------------------------------------------------------* FORM grid_user_command USING pr_ucomm LIKE sy-ucomm p_selfield TYPE slis_selfield. DATA: lr_grid TYPE REF TO cl_gui_alv_grid.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR' IMPORTING e_grid = lr_grid.
CASE pr_ucomm. WHEN gc_ucomm-writeoff. PERFORM grid_writeoff. WHEN gc_ucomm-print. PERFORM grid_print. WHEN gc_ucomm-post. PERFORM grid_post. WHEN gc_ucomm-refresh. PERFORM get_query_data. WHEN gc_ucomm-selall. PERFORM select_or_deselect USING lr_grid abap_true. WHEN gc_ucomm-desel. PERFORM select_or_deselect USING lr_grid space. WHEN gc_ucomm-doubleclick. PERFORM doubleclick USING p_selfield. ENDCASE.
ENDFORM. *&---------------------------------------------------------------------* *& Form GET_LGORT_LGOBE *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* * -->P_WERKS text * -->P_LGORT text * <--P_LGORT_LGOBE text *&---------------------------------------------------------------------* FORM get_lgort_lgobe USING p_werks TYPE werks_d p_lgort TYPE lgort_d CHANGING p_lgort_lgobe. DATA: ls_t001l TYPE ty_t001l.
READ TABLE gt_t001l INTO ls_t001l WITH KEY werks = p_werks lgort = p_lgort. IF sy-subrc = 0. p_lgort_lgobe = ls_t001l-lgobe. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form GET_COSTCENTER_TEXT *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* * -->P_KOSTL text * <--P_KTEXT text *&---------------------------------------------------------------------* FORM get_costcenter_text USING p_kostl TYPE kostl CHANGING p_ktext TYPE ktext. DATA: ls_cskt TYPE ty_cskt.
READ TABLE gt_cskt INTO ls_cskt WITH KEY kostl = p_kostl. IF sy-subrc = 0. p_ktext = ls_cskt-ktext. ELSE. MESSAGE e014 WITH p_kostl. ENDIF.
ENDFORM. *&---------------------------------------------------------------------* *& Form GET_ITEM_ADDITIONAL_INFO *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* * <--P_ZMM011I text *&---------------------------------------------------------------------* FORM get_item_additional_info CHANGING p_zmm011i TYPE zst_zmm011i. DATA: ls_zmm015 TYPE zmm015, ls_marc TYPE ty_marc, ls_mard TYPE ty_mard, ls_t001l TYPE ty_t001l.
IF p_zmm011i-werks IS INITIAL. p_zmm011i-werks = gs_t001w-werks. ENDIF.
IF p_zmm011i-lgort IS INITIAL. p_zmm011i-lgort = gs_zmm011h-lgort. p_zmm011i-lgort_lgobe = gs_zmm011h-lgort_lgobe. ENDIF.
IF p_zmm011i-kostl IS INITIAL. p_zmm011i-kostl = gs_zmm011h-kostl. ENDIF.
IF p_zmm011i-bwart IS INITIAL. p_zmm011i-bwart = gs_zmm010-bwart. ENDIF.
IF p_zmm011i-zpreitempoststatus IS INITIAL. p_zmm011i-zpreitempoststatus = gc_default_status. ENDIF.
READ TABLE gt_marc INTO ls_marc WITH KEY matnr = p_zmm011i-matnr werks = p_zmm011i-werks. IF sy-subrc = 0. p_zmm011i-matnr_maktx = ls_marc-maktx. p_zmm011i-meins = ls_marc-meins. TRY. p_zmm011i-groes = ls_marc-groes. CATCH cx_sy_conversion_no_number.
ENDFORM. *&---------------------------------------------------------------------* *& Form SHOW_QUERY *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM show_query .
PERFORM get_query_data. IF lines( gt_query_result ) > 0. PERFORM show_query_grid. ELSE. MESSAGE e000 WITH '没有找到相关数据'. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form GET_QUERY_DATA *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM get_query_data . DATA: ls_zmm015 TYPE zmm015, ls_marc TYPE ty_marc, ls_t001l TYPE ty_t001l, ls_adrc TYPE ty_adrc, ls_cskt TYPE ty_cskt.
FIELD-SYMBOLS: TYPE zst_predoc_query.
SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_query_result FROM zmm011h AS t1 INNER JOIN zmm011i AS t2 ON t1~zpredocno = t2~zpredocno WHERE t1~zpredocno IN s_predoc AND t1~zpredocstatus IN s_status AND erdat IN s_erdat AND t2~werks = gs_t001w-werks AND zbsart = gs_zmm010-zbsart.
READ TABLE gt_marc INTO ls_marc WITH KEY matnr = -ummat werks = -werks. IF sy-subrc = 0. -ummat_maktx = ls_marc-maktx. ENDIF.
SELECT SINGLE matnr INTO -plnbez FROM afpo WHERE aufnr = -aufnr.
READ TABLE gt_marc INTO ls_marc WITH KEY matnr = -plnbez werks = -werks. IF sy-subrc = 0. -plnbez_maktx = ls_marc-maktx. ENDIF.
PERFORM get_lgort_lgobe USING -werks -lgort CHANGING -lgort_lgobe.
READ TABLE gt_t001l INTO ls_t001l WITH KEY werks = -werks lgort = -umlgo. IF sy-subrc = 0. -umlgo_lgobe = ls_t001l-lgobe. READ TABLE gt_adrc INTO ls_adrc WITH KEY addrnumber = ls_t001l-adrnr. IF sy-subrc = 0. -umlgo_name1 = ls_adrc-name1. -umlgo_tel_number = ls_adrc-tel_number. -umlgo_street = ls_adrc-street. ENDIF. ENDIF.
PERFORM get_material_doc_creator USING -zlastpostmblnr -zlastpostmjahr CHANGING -zlastpostbudat -zlastpostcputm -zlastpostusnam.
PERFORM get_material_doc_creator USING -zlastwriteoffmblnr -zlastwriteoffmjahr CHANGING -zlastwriteoffbudat -zlastwriteoffcputm -zlastwriteoffusnam. IF NOT -kostl IS INITIAL. PERFORM get_costcenter_text USING -kostl CHANGING -ktext. ENDIF. "设置已取消过账的行为红色 IF -zpreitempoststatus = '03'. -rowcolor = 'C600'. ENDIF. ENDLOOP.
SORT gt_query_result BY zpredocno zpredocitem.
ENDFORM. *&---------------------------------------------------------------------* *& Form GRID_WRITEOFF *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM grid_writeoff . DATA: ls_zmm011h TYPE zst_zmm011h, lt_zmm011h TYPE TABLE OF zst_zmm011h, lt_return TYPE bapiret2_t, ls_return TYPE bapiret2.
FIELD-SYMBOLS: TYPE zst_predoc_query. READ TABLE gt_query_result WITH KEY select = abap_true TRANSPORTING NO FIELDS. IF sy-subrc <> 0. MESSAGE e020. ENDIF.
gv_writeoff_date = sy-datum. CALL SCREEN gc_2200 STARTING AT 10 10.
IF gv_confirm = abap_true. LOOP AT gt_query_result ASSIGNING WHERE select = abap_true. CLEAR ls_zmm011h.
IF -zlastpostmblnr IS INITIAL. -icon = gc_icon-led_red. -msg = '单据未过账'. CONTINUE. ENDIF.
IF NOT -zlastwriteoffmjahr IS INITIAL. -icon = gc_icon-led_red. -msg = '单据已冲销过账'. CONTINUE. ENDIF.
READ TABLE lt_zmm011h WITH KEY zpredocno = -zpredocno TRANSPORTING NO FIELDS. IF sy-subrc <> 0. MOVE-CORRESPONDING TO ls_zmm011h. APPEND ls_zmm011h TO lt_zmm011h.
READ TABLE lt_return INTO ls_return INDEX 1. IF sy-subrc = 0. CASE ls_return-type. WHEN 'S'. -icon = gc_icon-led_green. -msg = ls_return-message. -zlastwriteoffmblnr = ls_return-message_v2. -zlastwriteoffmjahr = sy-datum(4). -zlastwriteoffbudat = gv_writeoff_date. -zlastwriteoffcputm = sy-uzeit. -zlastwriteoffusnam = sy-uname. WHEN OTHERS. -icon = gc_icon-led_red. -msg = ls_return-message. ENDCASE. ENDIF. ENDIF. ENDLOOP. ENDIF.
ENDFORM. *&---------------------------------------------------------------------* *& Form GRID_POST *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM grid_post . DATA: lt_predoc_post TYPE TABLE OF zmm_predoc_log, ls_predoc_post TYPE zmm_predoc_log, lt_predocno TYPE TABLE OF ty_predocno, ls_predocno TYPE ty_predocno, ls_query_result TYPE zst_predoc_query.
READ TABLE gt_query_result WITH KEY select = abap_true TRANSPORTING NO FIELDS. IF sy-subrc <> 0. MESSAGE e020. ENDIF.
gv_writeoff_date = sy-datum. CALL SCREEN gc_2200 STARTING AT 10 10.
CHECK gv_confirm = abap_true.
LOOP AT gt_query_result INTO ls_query_result WHERE select = abap_true AND zpredocstatus <> gc_status_delete.
CLEAR ls_predocno. ls_predocno-zpredocno = ls_query_result-zpredocno. COLLECT ls_predocno INTO lt_predocno. ENDLOOP.
LOOP AT lt_predocno INTO ls_predocno.
LOOP AT gt_query_result INTO ls_query_result WHERE zpredocno = ls_predocno-zpredocno. CLEAR ls_predoc_post. MOVE-CORRESPONDING ls_query_result TO ls_predoc_post. ls_predoc_post-zreleaseind = '2'. ls_predoc_post-budat = gv_writeoff_date. APPEND ls_predoc_post TO lt_predoc_post. ENDLOOP.
CALL FUNCTION 'ZZMM_PREDOC_POST' TABLES t_predoc_post = lt_predoc_post.
CLEAR ls_predoc_post. READ TABLE lt_predoc_post INTO ls_predoc_post INDEX 1. CASE ls_predoc_post-status. WHEN 'E'. ls_query_result-icon = gc_icon-led_red. WHEN 'S'. ls_query_result-icon = gc_icon-led_green. ENDCASE.
ls_query_result-msg = ls_predoc_post-message. MODIFY gt_query_result FROM ls_query_result TRANSPORTING icon msg WHERE zpredocno = ls_predocno-zpredocno. ENDLOOP.
ENDFORM. *&---------------------------------------------------------------------* *& Form SELECT_OR_DESELECT *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* * -->P_ABAP_TRUE text *&---------------------------------------------------------------------* FORM select_or_deselect USING p_grid TYPE REF TO cl_gui_alv_grid p_select TYPE char01. DATA: it_filtered_entries TYPE lvc_t_fidx. FIELD-SYMBOLS: TYPE zst_predoc_query.
LOOP AT gt_query_result ASSIGNING . READ TABLE it_filtered_entries FROM sy-tabix TRANSPORTING NO FIELDS. IF sy-subrc NE 0. -select = p_select. ENDIF. ENDLOOP.
ENDFORM. *&---------------------------------------------------------------------* *& Form GET_USER_FULLNAME *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* * -->P_ERNAM text * <--P_NAME_TEXT text *&---------------------------------------------------------------------* FORM get_user_fullname USING p_ernam TYPE uname CHANGING p_name_text TYPE ad_namtext. DATA: ls_address TYPE bapiaddr3, lt_return TYPE bapiret2_t.
ENDFORM. *&---------------------------------------------------------------------* *& Form GRID_PRINT *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM grid_print . DATA: lt_zmm011h TYPE TABLE OF zst_zmm011h, ls_zmm011h TYPE zst_zmm011h, lt_zmm011i TYPE TABLE OF zst_zmm011i, ls_zmm011i TYPE zst_zmm011i, ls_query_result TYPE zst_predoc_query, lt_zmm011i_print TYPE TABLE OF zst_zmm011i. DATA: lv_fm_name TYPE rs38l_fnam, ls_output_options TYPE ssfcompop, ls_control_parameters TYPE ssfctrlop, ls_job_output_options TYPE ssfcresop, ls_job_output_info TYPE ssfcrescl.
READ TABLE gt_query_result WITH KEY select = abap_true TRANSPORTING NO FIELDS. IF sy-subrc <> 0. MESSAGE e020. ENDIF.
LOOP AT gt_query_result INTO ls_query_result.
IF ls_query_result-select = abap_true. READ TABLE lt_zmm011h WITH KEY zpredocno = ls_query_result-zpredocno TRANSPORTING NO FIELDS. IF sy-subrc <> 0. CLEAR ls_zmm011h. MOVE-CORRESPONDING ls_query_result TO ls_zmm011h. APPEND ls_zmm011h TO lt_zmm011h. ENDIF. ENDIF.
CLEAR ls_zmm011i. MOVE-CORRESPONDING ls_query_result TO ls_zmm011i. APPEND ls_zmm011i TO lt_zmm011i. ENDLOOP.
CALL FUNCTION 'SSF_CLOSE' IMPORTING job_output_info = ls_job_output_info EXCEPTIONS formatting_error = 1 internal_error = 2 send_error = 3 error_message = 4 OTHERS = 5. IF sy-subrc = 0. IF ls_job_output_info-outputdone = abap_true. "如果打印成功,更新打印次数 LOOP AT lt_zmm011h INTO ls_zmm011h. ls_query_result-zprint_count = ls_zmm011h-zprint_count = ls_zmm011h-zprint_count + 1. UPDATE zmm011h SET zprint_count = ls_zmm011h-zprint_count WHERE zpredocno = ls_zmm011h-zpredocno.
"更新内表打印次数 MODIFY gt_query_result FROM ls_query_result TRANSPORTING zprint_count WHERE zpredocno = ls_zmm011h-zpredocno. ENDLOOP. ENDIF. ENDIF. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form GET_MATERIAL_DOC_CREATOR *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* * -->P_MBLNR text * -->P_MJAHR text * <--P_BUDAT text * <--P_CPUTM text * <--P_USNAM text *&---------------------------------------------------------------------* FORM get_material_doc_creator USING p_mblnr TYPE mblnr p_mjahr TYPE mjahr CHANGING p_budat TYPE d p_cputm TYPE t p_usnam TYPE usnam.
IF NOT p_mblnr IS INITIAL. SELECT SINGLE budat cputm usnam INTO (p_budat,p_cputm,p_usnam) FROM mkpf WHERE mblnr = p_mblnr AND mjahr = p_mjahr. ENDIF.
ENDFORM. *&---------------------------------------------------------------------* *& Form DOUBLECLICK *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* * -->P_P_SELFIELD text *&---------------------------------------------------------------------* FORM doubleclick USING p_selfield TYPE slis_selfield.
CASE p_selfield-fieldname. WHEN 'ZPREDOCNO'. gs_zmm011h-zpredocno = p_selfield-value. PERFORM get_predoc_info USING gs_zmm011h-zpredocno. CALL SCREEN gc_2000. ENDCASE.
ENDFORM. *&---------------------------------------------------------------------* *& Form DELETE_STOCK_QTY_0 *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM delete_stock_qty_0 . DATA: ls_zmm011i TYPE zst_zmm011i.
IF gs_zmm011h-lgort IS NOT INITIAL. DELETE gt_zmm011i WHERE current_inventory = 0.
LOOP AT gt_zmm011i INTO ls_zmm011i. ls_zmm011i-zpredocitem = sy-tabix. MODIFY gt_zmm011i FROM ls_zmm011i TRANSPORTING zpredocitem. ENDLOOP.
REFRESH CONTROL 'TC_2000' FROM SCREEN sy-dynnr. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form LOCK_PREDOC *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* * -->P_ZPREDOCNO text *&---------------------------------------------------------------------* FORM lock_predoc USING p_zpredocno TYPE zpredocno.
IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE 'W' NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. g_edit = gc_display. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form UNLOCK_PREDOC *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* * -->P_GS_ZMM011H_ZPREDOCNO text *&---------------------------------------------------------------------* FORM unlock_predoc USING p_zpredocno TYPE zpredocno.
IF p_zpredocno IS NOT INITIAL. CALL FUNCTION 'DEQUEUE_EZ_ZMM011H' EXPORTING zpredocno = p_zpredocno EXCEPTIONS error_message = 1 OTHERS = 2. ENDIF.
ENDFORM. *&---------------------------------------------------------------------* *& Form GET_QTY_IN_PROCESS *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* * <--P_P_ZMM011I text *&---------------------------------------------------------------------* FORM get_qty_in_process CHANGING p_zmm011i TYPE zst_zmm011i. DATA: lv_zzqty_in_process TYPE menge_d, lt_vbep TYPE TABLE OF ty_vbep, ls_vbep TYPE ty_vbep, lt_lips TYPE TABLE OF ty_vbep, lv_order_qty TYPE ordqty, lv_zplquantity TYPE zplquantity. ********************************************************************** * 更改说明 :skgljc 20180611 * 1、加入条件 :按需求 取在制生产订单处理中的领料数量 将取值赋给字段 p_zmm011i-in_process * 2、将不加在制单生产订单查询的 所有生产订单 处理中的数量 将取值赋给新定义的字段 : p_zmm011i-all_in_process * ps:也就是说以前 字段 p_zmm011i-in_process 存的值是 所有处理中的领料数量(因为没有加在制生产订单作查询条件)现在改为字段:p_zmm011i-all_in_process * 而 现在 这个字段 p_zmm011i-in_process 存的值是 加入在制生产订单 查出订单的 处理中的领料数量 "新增 查询预制订单中 在制的生产订单 的未处理中的数量 SELECT SUM( menge ) INTO p_zmm011i-in_process FROM zmm011h AS t1 INNER JOIN zmm011i AS t2 ON t1~zpredocno = t2~zpredocno WHERE t1~zpredocno <> p_zmm011i-zpredocno AND ( ( zbsart <> 'ZM02' AND zbsart <> 'ZM05' AND zpreitempoststatus <> '02' AND zpredocstatus = '02' ) OR ( ( zbsart = 'ZM07' OR zbsart = 'ZM09' ) AND zpredocstatus = '01' ) ) AND aufnr = gs_zmm011h-aufnr AND matnr = p_zmm011i-matnr AND t2~werks = p_zmm011i-werks AND t2~lgort = p_zmm011i-lgort.
SELECT SUM( menge ) * INTO p_zmm011i-in_process "更改前 skgljc by 20180611 INTO p_zmm011i-all_in_process "更改后的 FROM zmm011h AS t1 INNER JOIN zmm011i AS t2 ON t1~zpredocno = t2~zpredocno WHERE t1~zpredocno <> p_zmm011i-zpredocno AND ( ( zbsart <> 'ZM02' AND zbsart <> 'ZM05' AND zpreitempoststatus <> '02' AND zpredocstatus = '02' ) OR ( ( zbsart = 'ZM07' OR zbsart = 'ZM09' ) AND zpredocstatus = '01' ) ) AND matnr = p_zmm011i-matnr AND t2~werks = p_zmm011i-werks AND t2~lgort = p_zmm011i-lgort.
SELECT SUM( zplquantity ) INTO lv_zplquantity FROM zmm011h AS t1 INNER JOIN zmm011i AS t2 ON t1~zpredocno = t2~zpredocno WHERE t1~zpredocno <> p_zmm011i-zpredocno AND ( ( zbsart = 'ZM05' AND zpreitempoststatus <> '02' AND zpredocstatus = '02' ) ) AND matnr = p_zmm011i-matnr AND t2~werks = p_zmm011i-werks AND t2~lgort = p_zmm011i-lgort AND zplquantity < 0.
IF p_zmm011i-werks = '1000'. SELECT t1~vbeln t2~posnr etenr ocdqty_bu dlvqty_bu INTO CORRESPONDING FIELDS OF TABLE lt_vbep FROM vbak AS t1 INNER JOIN vbap AS t2 ON t1~vbeln = t2~vbeln INNER JOIN vbep AS t3 ON t2~vbeln = t3~vbeln AND t2~posnr = t3~posnr WHERE auart NOT IN ( 'ZRE1','ZRE2','ZRE3','ZRE4' ) AND t3~lifsp = space AND t2~abgru = space AND t2~matnr = p_zmm011i-matnr AND t2~werks = p_zmm011i-werks AND t2~lgort = p_zmm011i-lgort.
IF lines( lt_vbep ) > 0. SELECT vbeln posnr lfimg AS ocdqty_bu INTO CORRESPONDING FIELDS OF TABLE lt_lips FROM lips FOR ALL ENTRIES IN lt_vbep WHERE vgbel = lt_vbep-vbeln AND vgpos = lt_vbep-posnr AND wbsta = 'C'. ENDIF.
CLEAR lv_order_qty. LOOP AT lt_vbep INTO ls_vbep. lv_order_qty = lv_order_qty + ls_vbep-ocdqty_bu + ls_vbep-dlvqty_bu. ENDLOOP.
LOOP AT lt_lips INTO ls_vbep. lv_order_qty = lv_order_qty - ls_vbep-ocdqty_bu. ENDLOOP.
PROCESS BEFORE OUTPUT. MODULE status_2000. *&SPWIZARD: PBO FLOW LOGIC FOR TABLECONTROL 'TC_2000' MODULE tc_2000_change_tc_attr. *&SPWIZARD: MODULE TC_2000_CHANGE_COL_ATTR. LOOP AT gt_zmm011i INTO gs_zmm011i WITH CONTROL tc_2000 CURSOR tc_2000-current_line. MODULE tc_2000_get_lines. * MODULE TC_2000_CHANGE_FIELD_ATTR. ENDLOOP.
MODULE change_field_attr.
PROCESS AFTER INPUT.
CHAIN. FIELD gs_zmm011h-zpredocno MODULE get_predoc_info ON CHAIN-REQUEST. ENDCHAIN.
CHAIN. FIELD gs_zmm011h-aufnr MODULE get_product_order ON CHAIN-REQUEST. ENDCHAIN.
CHAIN. FIELD gs_zmm011h-lgort. FIELD gs_zmm011h-pernr. FIELD gs_zmm011h-zissueqty. MODULE change_screen_data ON CHAIN-REQUEST. ENDCHAIN. *&SPWIZARD: PAI FLOW LOGIC FOR TABLECONTROL 'TC_2000'
LOOP AT gt_zmm011i. CHAIN. FIELD gs_zmm011i-zpredocitem. FIELD gs_zmm011i-matnr." MODULE check_material_duplicates ON "INPUT. FIELD gs_zmm011i-menge. FIELD gs_zmm011i-ziremark. MODULE tc_2000_modify ON CHAIN-REQUEST. ENDCHAIN. FIELD gs_zmm011i-select MODULE tc_2000_mark ON REQUEST. ENDLOOP.
*&SPWIZARD: MODULE TC_2000_CHANGE_TC_ATTR. *&SPWIZARD: MODULE TC_2000_CHANGE_COL_ATTR. MODULE exit_2000 AT EXIT-COMMAND.
MODULE user_command_2000.
PROCESS ON VALUE-REQUEST. FIELD gs_zmm011h-zpredocno MODULE f4_zpredocno. FIELD gs_zmm011h-lgort MODULE f4_lgort. FIELD gs_zmm011h-pernr MODULE f4_pernr.
在客户端访问subversion版本库时出现这个错误:
svnserve.conf:12: Option expected
为什么会出现这个错误呢,就是因为subversion读取配置文件svnserve.conf时,无法识别有前置空格的配置文件,如### This file controls the configuration of the svnserve daemon, if you##
什么是Akka
Message-Driven Runtime is the Foundation to Reactive Applications
In Akka, your business logic is driven through message-based communication patterns that are independent of physical locatio
zabbix_api网上比较多的写法是python或curl。上次我用java--http://bossr.iteye.com/blog/2195679,这次用perl。for example: #!/usr/bin/perl
use 5.010 ;
use strict ;
use warnings ;
use JSON :: RPC :: Client ;
use
package com.test;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
public class TestMap {
public static v
MySQL server has gone away 问题解决方法,需要的朋友可以参考下。
应用程序(比如PHP)长时间的执行批量的MYSQL语句。执行一个SQL,但SQL语句过大或者语句中含有BLOB或者longblob字段。比如,图片数据的处理。都容易引起MySQL server has gone away。 今天遇到类似的情景,MySQL只是冷冷的说:MySQL server h
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml&