*&---------------------------------------------------------------------* *& Report ZMMF013 *& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* REPORT zmmf013. TABLES:ikpf,iseg,mara,makt. TYPES:BEGIN OF ty_show, sel(1), iblnr TYPE iseg-iblnr, gjahr TYPE iseg-gjahr, zeili TYPE iseg-zeili, matnr TYPE iseg-matnr, maktx TYPE makt-maktx, wrkst TYPE mara-wrkst, werks TYPE iseg-werks, lgort TYPE iseg-lgort, lgobe TYPE t001l-lgobe, charg TYPE iseg-charg, bldat TYPE ikpf-bldat, budat TYPE iseg-budat, xloek TYPE iseg-xloek, menge TYPE iseg-menge, buchm TYPE iseg-buchm, zcysl TYPE iseg-menge, meins TYPE iseg-meins, usnam TYPE ikpf-usnam, END OF ty_show. DATA:gt_show TYPE TABLE OF ty_show, gw_show LIKE LINE OF gt_show. DATA:gt_fieldcat TYPE lvc_t_fcat. DATA gs_fieldcat LIKE LINE OF gt_fieldcat. DATA ls_layout TYPE lvc_s_layo. DATA:GT_T001w TYPE STANDARD TABLE OF T001w, GS_T001w TYPE T001w. "define DEFINE append_fieldcat . CLEAR GS_FIELDCAT. GS_FIELDCAT-FIELDNAME = &1. GS_FIELDCAT-SCRTEXT_L = &2. GS_FIELDCAT-OUTPUTLEN = &3. GS_FIELDCAT-NO_ZERO = &4. IF &1 = 'MEINS'. gs_fieldcat-CONVEXIT = 'ZCONV'. ENDIF. APPEND GS_FIELDCAT TO gt_fieldcat. END-OF-DEFINITION. "宏定义 DEFINE rt_tab. CLEAR:&1. &1-LOW = &2. &1-HIGH = &3. &1-OPTION = &4. &1-SIGN = &5. APPEND &1. END-OF-DEFINITION. SELECTION-SCREEN:BEGIN OF BLOCK blk01 WITH FRAME TITLE text-001. SELECT-OPTIONS:s_iblnr FOR ikpf-iblnr. PARAMETERS:p_gjahr TYPE ikpf-gjahr DEFAULT sy-datum+0(4). SELECT-OPTIONS:s_werks FOR ikpf-werks DEFAULT '1010'. SELECT-OPTIONS:s_lgort FOR ikpf-lgort. SELECT-OPTIONS:s_bldat FOR ikpf-bldat. SELECT-OPTIONS:s_budat FOR ikpf-budat. SELECT-OPTIONS:s_usnam FOR ikpf-usnam. SELECTION-SCREEN END OF BLOCK blk01. *************屏幕控制*********** AT SELECTION-SCREEN. "屏幕执行声明 IF sy-ucomm = 'ONLI'. SELECT * INTO CORRESPONDING FIELDS OF TABLE GT_T001w FROM T001w WHERE werks IN S_WERKS AND SPRAS = 1. LOOP AT GT_T001w INTO GS_T001w. AUTHORITY-CHECK OBJECT 'M_MATE_WRK' * ID 'ACTVT' FIELD '*' ID 'WERKS' FIELD GS_T001w-WERKS. IF SY-SUBRC <> 0. MESSAGE '您没有分配工厂代码' && GS_T001w-WERKS && '权限,请检查' TYPE 'E'. ENDIF. ENDLOOP. ENDIF. START-OF-SELECTION. PERFORM prm_get_data. PERFORM prm_proce_data. PERFORM prm_set_field. PERFORM prm_show. *&---------------------------------------------------------------------* *& Form PRM_GET_DATA *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM prm_get_data . SELECT ikpf~iblnr" TYPE iseg-iblnr, ikpf~gjahr" TYPE iseg-gjahr, iseg~zeili" TYPE iseg-zeili, iseg~matnr" TYPE iseg-matnr, makt~maktx" TYPE makt-maktx, mara~wrkst" TYPE mara-wrkst, ikpf~werks" TYPE iseg-werks, ikpf~lgort" TYPE iseg-lgort, t001l~lgobe" TYPE t001l-lgobe, iseg~charg" TYPE iseg-charg, ikpf~budat" TYPE iseg-budat, ikpf~bldat" TYPE iseg-budat, iseg~xloek" TYPE iseg-xloek, iseg~menge" TYPE iseg-menge, iseg~buchm" TYPE iseg-buchm, "zcysl TYPE iseg-menge, iseg~meins" TYPE iseg-meins, ikpf~usnam" TYPE iseg-meins, INTO CORRESPONDING FIELDS OF TABLE gt_show FROM ikpf INNER JOIN iseg ON ikpf~iblnr = iseg~iblnr AND ikpf~gjahr = iseg~gjahr INNER JOIN t001l ON t001l~werks = iseg~werks AND t001l~lgort = iseg~lgort INNER JOIN mara ON iseg~matnr = mara~matnr INNER JOIN makt ON iseg~matnr = makt~matnr AND makt~spras = '1' WHERE ikpf~iblnr IN s_iblnr AND ikpf~gjahr = p_gjahr AND ikpf~werks IN s_werks AND ikpf~lgort IN s_lgort AND ikpf~bldat IN s_bldat AND ikpf~budat IN s_budat AND ikpf~lstat = '' AND ikpf~usnam IN s_usnam AND iseg~xloek = ''. IF gt_show[] IS INITIAL. MESSAGE '无选择条件的结果!' TYPE 'S' DISPLAY LIKE 'E'. LEAVE LIST-PROCESSING. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form PRM_PROCE_DATA *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM prm_proce_data . LOOP AT gt_show INTO gw_show. gw_show-zcysl = gw_show-menge - gw_show-buchm. MODIFY gt_show FROM gw_show. ENDLOOP. ENDFORM. *&---------------------------------------------------------------------* *& Form PRM_SET_FIELD *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM prm_set_field . ls_layout-cwidth_opt = 'X'. "优化列宽选项是否设置 ls_layout-zebra = 'X'. ls_layout-box_fname = 'SEL'. append_fieldcat: 'IBLNR' '盘点凭证' 10 'X', 'GJAHR' '会计年度' 4 '', 'ZEILI' '行号' 3 '', 'MATNR' '物料号' 18 '', 'MAKTX' '物料描述' 40 '', 'WRKST' '补充描述' 48 '', 'WERKS' '工厂' 4 '', 'LGORT' '库位' 4 '', 'LGOBE' '仓储地点的描述' 16 '', 'CHARG' '批号' 10 '', 'BUDAT' '过帐日期' 10 '', 'BLDAT' '凭证日期' 10 '', 'MENGE' '实盘数量' 16 '', 'BUCHM' '帐面数量' 16 '', 'ZCYSL' '盘亏/盘盈数量' 16 '', 'MEINS' '单位' 3 ''. ENDFORM. *&---------------------------------------------------------------------* *& Form PRM_SHOW *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM prm_show . CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC' EXPORTING i_callback_program = sy-repid i_callback_pf_status_set = 'PRM_SET_STATUS' i_callback_user_command = 'PRM_USER_COMMAND' is_layout_lvc = ls_layout it_fieldcat_lvc = gt_fieldcat[] i_default = 'X' i_save = 'A' TABLES t_outtab = gt_show[] EXCEPTIONS program_error = 1 OTHERS = 2. IF sy-subrc <> 0. ENDIF. ENDFORM. FORM prm_set_status USING rt_extab TYPE slis_t_extab. SET PF-STATUS 'ZSTAT'." EXCLUDING lt_code. ENDFORM. FORM prm_user_command USING p_ucomm LIKE sy-ucomm p_selfield TYPE slis_selfield. DATA:lt_select TYPE TABLE OF ty_show. DATA:gt_head TYPE TABLE OF zmmf013h, gw_head TYPE zmmf013h, gt_item TYPE TABLE OF zmmf013i, gw_item TYPE zmmf013i. DATA:lv_flag TYPE c. DATA:ls_control TYPE ssfctrlop. DATA:lv_con TYPE ssfcrescl. DATA:lv_sfname TYPE tdsfname VALUE 'ZMMF013'. DATA:lv_fname TYPE rs38l_fnam. CHECK p_ucomm = 'PRNT'. APPEND LINES OF gt_show TO lt_select. DELETE lt_select[] WHERE sel = ''. "打印控制参数 ls_control-no_open = 'X'. ls_control-no_close = 'X'. "获取打印函数 CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME' EXPORTING formname = lv_sfname IMPORTING fm_name = lv_fname EXCEPTIONS no_form = 1 no_function_module = 2 OTHERS = 3. IF sy-subrc <> 0. ENDIF. CALL FUNCTION 'SSF_OPEN'. SORT lt_select[] BY gjahr iblnr zeili ASCENDING. LOOP AT lt_select INTO gw_show. AT NEW iblnr. lv_flag = 'X'. ENDAT. IF lv_flag = 'X'. gw_head-iblnr = gw_show-iblnr. gw_head-gjahr = gw_show-gjahr. gw_head-werks = gw_show-werks. gw_head-lgort = gw_show-lgort. gw_head-lgobe = gw_show-lgobe. gw_head-usnam = gw_show-usnam. gw_head-bldat = gw_show-bldat. gw_head-budat = gw_show-budat. SELECT SINGLE name_text INTO gw_head-usnam FROM adrp INNER JOIN usr21 ON adrp~persnumber = usr21~persnumber WHERE usr21~bname = gw_show-usnam. * APPEND gw_head TO gt_head. * CLEAR:gw_head,lv_flag. ENDIF. gw_item-iblnr = gw_show-iblnr. gw_item-gjahr = gw_show-gjahr. gw_item-zeili = gw_show-zeili. gw_item-matnr = gw_show-matnr. gw_item-maktx = gw_show-maktx && gw_show-wrkst. gw_item-menge = gw_show-menge. gw_item-buchm = gw_show-buchm. gw_item-zcysl = gw_show-zcysl. gw_item-meins = gw_show-meins. SELECT SINGLE msehl INTO gw_item-msehl FROM t006a WHERE spras = '1' AND msehi = gw_show-meins. APPEND gw_item TO gt_item. CLEAR:gw_item. AT END OF iblnr. lv_flag = 'E'. ENDAT. IF lv_flag = 'E'. CALL FUNCTION lv_fname EXPORTING control_parameters = ls_control gw_head = gw_head TABLES gt_item = gt_item[] EXCEPTIONS formatting_error = 1 internal_error = 2 send_error = 3 user_canceled = 4. CLEAR:gt_item[],gw_head. ENDIF. ENDLOOP. CALL FUNCTION 'SSF_CLOSE'. ENDFORM.
原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/18602.html