注意:
如果测试发现无法自动过账,则需要去事务代码SPRO检查"选定集"的设定,质量管理->质量检验->检验批完成->编辑使用决策的选定集
使用决策的过账:UD决策时,自动过账
后台:此标识对前台操作生效(QA11、QVM2)。
代码:
************************************************************************ * 程 序 名:ZQMR0007 * 程序描述:检验批自动UD和过账 * 事务代码:ZQM007 ************************************************************************ * 修改日志 ************************************************************************ * 日期 版本 修改人 描述 * -------- ---- ------------ ------------------------------------------- * 20230104 1.0 Amell 创建程序 * ************************************************************************ REPORT zqmr0007. ************************************************************************ * Type Pools Definitions 定义类型池 ************************************************************************ TYPE-POOLS slis. ************************************************************************ * Tables Definitions ************************************************************************ TABLES: qals, qamr. ************************************************************************ * Data Definitions 定义数据 ************************************************************************ TYPES: BEGIN OF ty_data. INCLUDE TYPE qals_d01. TYPES: sel TYPE c, END OF ty_data. DATA: gt_data TYPE TABLE OF ty_data. DATA: gs_layout TYPE slis_layout_alv, "布局 gt_fieldcat TYPE slis_t_fieldcat_alv. "字段 ************************************************************************ * Includes Module 包含模块 ************************************************************************ ************************************************************************ * Selection Screen 选择屏幕 ************************************************************************ SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-b01. PARAMETERS: p_werks LIKE marc-werks DEFAULT '2000' OBLIGATORY, p_art LIKE qals-art OBLIGATORY, p_skip TYPE q_display_skip AS CHECKBOX DEFAULT 'X', p_all TYPE q_display_all AS CHECKBOX. SELECTION-SCREEN END OF BLOCK b1. SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE TEXT-b02. PARAMETERS: p_qv1 LIKE qave-vauswahlmg, p_qv2 LIKE qave-vwerks, p_qv3 LIKE qave-vcodegrp, p_qv4 LIKE qave-vcode. SELECTION-SCREEN END OF BLOCK b2. ************************************************************************ * Initialization 初始化事件 ************************************************************************ INITIALIZATION. ************************************************************************ * At Selection Screen PAI事件 ************************************************************************ *---------------------------------------------------------------------* AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_qv1. PERFORM code_auswahl_l. *------------ AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_qv2. PERFORM code_auswahl_l. *------------ AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_qv3. PERFORM code_auswahl_l. *------------ AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_qv4. PERFORM code_auswahl_l. *------------ AT SELECTION-SCREEN ON BLOCK b2. PERFORM code_auswahl_l. ************************************************************************ * At Selection Screen Output PBO事件 ************************************************************************ AT SELECTION-SCREEN OUTPUT. ************************************************************************ * Report Format 报表格式 ************************************************************************ TOP-OF-PAGE. END-OF-PAGE. ************************************************************************ * Main Process 主要逻辑 ************************************************************************ START-OF-SELECTION. "获取数据 PERFORM frm_get_data. "处理数据 PERFORM frm_process_lot. "显示数据 PERFORM frm_display_data. END-OF-SELECTION. *&---------------------------------------------------------------------* *& Form CODE_AUSWAHL_L *&---------------------------------------------------------------------* * Auswahlen und Prüfen VE-Code * *----------------------------------------------------------------------* FORM code_auswahl_l. DATA: c_stern VALUE '*', l_qpk1ac LIKE qpk1ac. IF p_qv1 IS INITIAL. MOVE c_stern TO p_qv1. ENDIF. IF p_qv2 IS INITIAL. MOVE c_stern TO p_qv2. ENDIF. IF p_qv3 IS INITIAL. MOVE c_stern TO p_qv3. ENDIF. IF p_qv4 IS INITIAL. MOVE c_stern TO p_qv4. ENDIF. CALL FUNCTION 'QPK1_UD_CODE_PICKUP_LEAN' EXPORTING i_werks = p_qv2 i_auswahlmge = p_qv1 i_codegruppe = p_qv3 i_code = p_qv4 i_no_usageindication = 'X' IMPORTING e_qpk1ac = l_qpk1ac EXCEPTIONS OTHERS = 1. IF NOT sy-subrc IS INITIAL. MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. EXIT. ENDIF. * MOVE l_qpk1ac-werks TO p_qv2. MOVE l_qpk1ac-auswahlmge TO p_qv1. MOVE l_qpk1ac-codegruppe TO p_qv3. MOVE l_qpk1ac-code TO p_qv4. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_GET_DATA *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM frm_get_data . SELECT * FROM qals WHERE werk = @p_werks AND ( kzskiplot = 'X' OR EXISTS ( SELECT * FROM jest WHERE stat = 'I0213' "已结果确认 RREC I0213 AND inact = '' AND jest~objnr = qals~objnr ) ) AND stat35 NE 'X' "未UD判定 AND art = @p_art AND NOT EXISTS ( SELECT * FROM jest WHERE stat = 'I0224' "已取消 LTCA I0224 AND inact = '' AND jest~objnr = qals~objnr ) INTO CORRESPONDING FIELDS OF TABLE @gt_data. SORT: gt_data BY prueflos. IF p_skip EQ space. "删除不为跳检检验批 DELETE gt_data WHERE kzskiplot = 'X'. ENDIF. IF p_all EQ space. "删除已结果确认检验批 DELETE gt_data WHERE kzskiplot NE 'X'. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_PROCESS_LOT *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM frm_process_lot . DATA: ls_data TYPE ty_data, ls_ud TYPE bapi2045ud, ls_return TYPE bapireturn1. ls_ud-ud_selected_set = p_qv1. ls_ud-ud_plant = p_qv2. ls_ud-ud_code_group = p_qv3. ls_ud-ud_code = p_qv4. ls_ud-ud_stock_posting = 'X'. LOOP AT gt_data INTO ls_data WHERE prueflos = '010000560031'. "验货类型 UPDATE qals SET zchecktype = '10' WHERE prueflos = ls_data-prueflos. "UD决策和库存过账 ls_ud-insplot = ls_data-prueflos. CALL FUNCTION 'BAPI_INSPLOT_SETUSAGEDECISION' EXPORTING number = ls_data-prueflos ud_data = ls_ud IMPORTING return = ls_return. IF ls_return-type NE 'E'. COMMIT WORK. ELSE. ROLLBACK WORK. ENDIF. ENDLOOP. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_DISPLAY_DATA *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM frm_display_data . "栏位最适宽度 gs_layout-colwidth_optimize = 'X'. "ALV条纹 gs_layout-zebra = 'X'. "选择框 gs_layout-box_fieldname = 'SEL'. "ALV的栏位 CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE' EXPORTING i_program_name = sy-repid "i_internal_tabname = 'GT_DATA' i_structure_name = 'QALS_D01' i_inclname = sy-cprog CHANGING ct_fieldcat = gt_fieldcat EXCEPTIONS inconsistent_interface = 1 program_error = 2 OTHERS = 3. "ALV显示 CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING i_callback_program = sy-repid "当前程序名 is_layout = gs_layout "Layout it_fieldcat = gt_fieldcat[] "Fieldcat i_save = 'A' TABLES t_outtab = gt_data EXCEPTIONS program_error = 1 OTHERS = 2. ENDFORM.
标签:BAPI,SELECTION,PERFORM,SCREEN,MOVE,INSPLOT,过账,code,TYPE From: https://www.cnblogs.com/StephenAmell/p/17027135.html