SAP_ABAP_MM_安全库存_设计方案+实现代码(MARD_MBEW )_ALV_行列控制动态编辑

SAP ABAP 顾问(开发工程师)能力模型-CSDN博客文章浏览阅读959次。目标:基于对SAP abap 顾问能力模型的梳理,给一年左右经验的abaper 快速成长为三年经验提供超级燃料!https://blog.csdn.net/java_zhong1990/article/details/132469977


目标:从工厂、库存地点、物料层面,设置库存的范围,在范围内的库存表示正常,在范围外的库存表示异常.

需要考虑的是如何定义正常的库存范围,

一、背景说明

1.1 实现效果

 

1.2 业务说明

设计步骤:

1 计划员,批量维护物料的安全库存

2 计划主管,可以更改安全库存范围

3 输出安全库存报表

1.3 代码实现
*&---------------------------------------------------------------------*
*& Report ZMM028
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zmm031.INCLUDE zmm031_top.
INCLUDE zmm031_sel.
INCLUDE zmm031_frm.
INCLUDE zmm031_pbo.
INCLUDE zmm031_pai.SELECTION-SCREEN FUNCTION KEY: 1 .INITIALIZATION.PERFORM init.AT SELECTION-SCREEN OUTPUT.AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_file.PERFORM get_excel.AT SELECTION-SCREEN.CASE sscrfields-ucomm .WHEN 'FC01'.PERFORM download_template USING '批导模版.xlsx' 'ZMM031'.WHEN OTHERS.ENDCASE.START-OF-SELECTION.IF p_inp = 'X'.*    SELECT * INTO TABLE @DATA(ls_ztmm031) FROM ztmm031 WHERE ztmm031~c1 = @sy-uname.
*    IF sy-subrc = 0.
*    ELSE.
*      MESSAGE '没有权限,请联系系统管理员!' TYPE 'S' DISPLAY LIKE 'E'.
*      LEAVE TO LIST-PROCESSING.
*      EXIT.
*
*    ENDIF.PERFORM get_data_for_excel.PERFORM check_data_for_excel.PERFORM set_catalog.PERFORM display_alv.ELSEIF p_sel = 'X'.PERFORM get_data_for_ztmm030.PERFORM set_catalog1.PERFORM display_alv_ztmm030.ELSE.PERFORM get_data_for_mard.PERFORM set_catalog2.PERFORM display_alv2.ENDIF.
*&---------------------------------------------------------------------*
*& Form get_data_for_mard
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM get_data_for_mard .DATA:lv_lfgja TYPE mard-lfgja.DATA:lv_lfmon TYPE mard-lfmon.lv_lfgja = sy-datum+0(4).lv_lfmon = sy-datum+4(2).*  lv_lfgja = '2022'.
*  lv_lfmon = '05'.SELECTmard~lfgja,mard~lfmon,mard~werks,mard~lgort,mard~matnr,mard~labst,t001l~lgobe,mara~zwlcms,mara~meins,mbew~verpr,mbew~peinh,ztmm030~l1,ztmm030~l2,ztmm030~createby,ztmm030~createdate,ztmm030~createtimeINTO CORRESPONDING FIELDS OF TABLE @gt_data2FROM mardLEFT JOIN ztmm030 ON ztmm030~werks = mard~werks AND ztmm030~lgort = mard~lgort AND ztmm030~matnr = mard~matnrINNER JOIN t001l   ON t001l~werks   = mard~werks AND mard~lgort = t001l~lgortINNER JOIN mara    ON mara~matnr    = mard~matnrINNER JOIN mbew    ON mbew~matnr    = mard~matnr AND mbew~bwkey    = mard~werks AND mbew~vprsv = 'V'WHERE mard~lfgja = @lv_lfgja  AND mard~lfmon = @lv_lfmonAND mard~werks IN @so_werksAND mard~lgort IN @so_lgortAND mard~matnr IN @so_matnrAND mard~labst <> '0'."verprLOOP AT gt_data2 ASSIGNING FIELD-SYMBOL(<fs1>).<fs1>-je = <fs1>-verpr / <fs1>-peinh * <fs1>-labst.IF <fs1>-l1 IS NOT INITIAL AND <fs1>-l2 IS NOT INITIAL.IF <fs1>-labst < <fs1>-l1 .<fs1>-text = '库存过低'.ELSEIF  <fs1>-labst > <fs1>-l2.<fs1>-text = '超上限'.ELSE.<fs1>-text = '库存正常'.ENDIF.ENDIF.*    <fs1>-labst2 = <fs1>-labst.<fs1>-l1_ = <fs1>-l1.<fs1>-l2_ = <fs1>-l2.IF <fs1>-l1 IS INITIAL AND <fs1>-l2 IS INITIAL.<fs1>-f1 = 'X'.ELSE.SELECT * INTO TABLE @DATA(ls_ztmm031) FROM ztmm031 WHERE ztmm031~c1 = @sy-uname.IF sy-subrc = 0.<fs1>-f1 = 'X'.ELSE."<fs>-message = '无权限修改'.<fs>-status  = 'E'. CONTINUE.ENDIF.ENDIF.ENDLOOP.DATA:gwa_edit TYPE lvc_s_styl,git_edit TYPE lvc_t_styl.LOOP AT gt_data2 INTO gs_data2.IF  gs_data2-f1 = 'X'.CLEAR: gwa_edit.gwa_edit-fieldname = 'L1'.gwa_edit-style = cl_gui_alv_grid=>mc_style_enabled."设置为可编辑APPEND  gwa_edit TO gs_data2-celtab .CLEAR: gwa_edit.gwa_edit-fieldname = 'L2'.gwa_edit-style = cl_gui_alv_grid=>mc_style_enabled."设置为可编辑APPEND  gwa_edit TO gs_data2-celtab .ELSE.CLEAR: gwa_edit.gwa_edit-fieldname = 'L1'.gwa_edit-style = cl_gui_alv_grid=>mc_style_disabled."设置为不可编辑APPEND  gwa_edit TO gs_data2-celtab .CLEAR: gwa_edit.gwa_edit-fieldname = 'L2'.gwa_edit-style = cl_gui_alv_grid=>mc_style_disabled."设置为不可编辑APPEND  gwa_edit TO gs_data2-celtab .ENDIF.MODIFY gt_data2  FROM  gs_data2 .ENDLOOP.ENDFORM.
*&---------------------------------------------------------------------*
*& 包含               ZMM028_FRM
*&---------------------------------------------------------------------*FORM get_excel.DATA : l_filetab TYPE filetable,l_waftab  LIKE LINE OF l_filetab,l_rc      TYPE i.CALL METHOD cl_gui_frontend_services=>file_open_dialogEXPORTINGwindow_title            = '打开文件'initial_directory       = 'C:/'CHANGINGfile_table              = l_filetabrc                      = l_rcEXCEPTIONSfile_open_dialog_failed = 1cntl_error              = 2error_no_gui            = 3not_supported_by_gui    = 4OTHERS                  = 5.IF sy-subrc <> 0.MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgnoWITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.EXIT.ELSE.READ TABLE l_filetab INTO l_waftab INDEX 1.pa_file = l_waftab-filename.CLEAR: l_filetab,l_waftab.ENDIF.ENDFORM.FORM init.DATA: ls_dyntxt TYPE smp_dyntxt .ls_dyntxt-icon_id   = icon_export.ls_dyntxt-quickinfo = '模板下载'.ls_dyntxt-icon_text = '模板下载'.sscrfields-functxt_01 = ls_dyntxt.
ENDFORM.FORM init_output.ENDFORM.FORM get_data_for_excel.TYPES: BEGIN OF ly_excel_data,werks TYPE ztmm030-werks, "工厂lgort TYPE ztmm030-lgort, "存储地点matnr TYPE ztmm030-matnr, "物料编号l1    TYPE ztmm030-l1,    "库存下限(未来)l2    TYPE ztmm030-l2,    "库存上限(未来)
*           createby   TYPE ztmm030-createby,  "最近更新人
*           createdate TYPE ztmm030-createdate, "最近更新日期
*           createtime TYPE ztmm030-createtime, "最近更新时间END OF ly_excel_data.DATA: lt_excel      TYPE TABLE OF alsmex_tabline WITH HEADER LINE,ls_excel_data TYPE ly_excel_data,l_index       LIKE sy-tabix.DATA: lv_lines TYPE i.FIELD-SYMBOLS: <fs>.IF pa_file IS NOT INITIAL.CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'EXPORTINGfilename                = pa_filei_begin_col             = '1'i_begin_row             = '2'i_end_col               = '10'i_end_row               = '50000'TABLESintern                  = lt_excelEXCEPTIONSinconsistent_parameters = 1upload_ole              = 2OTHERS                  = 3.IF sy-subrc = 0.
*&& 将EXCEL格式中的数据导入到内表TAB_LOAD中LOOP AT lt_excel.ASSIGN COMPONENT lt_excel-col OF STRUCTURE ls_excel_data TO <fs>.<fs> = lt_excel-value.AT END OF row.MOVE-CORRESPONDING ls_excel_data TO gs_data."跟Excel的列一一对应的内表APPEND gs_data TO gt_data.CLEAR: ls_excel_data,gs_data.ENDAT.ENDLOOP.lv_lines = lines( gt_data ).IF lv_lines > 8000.MESSAGE  '本次导入数据超过5000,请拆分数据文件!' TYPE 'S'DISPLAY LIKE 'E'.STOP.ENDIF.ENDIF.ELSE.MESSAGE  '请输入文件路径!' TYPE 'S'DISPLAY LIKE 'E'.STOP.ENDIF.ENDFORM.FORM check_data_for_excel.LOOP AT gt_data ASSIGNING FIELD-SYMBOL(<fs>).CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'EXPORTINGinput  = <fs>-matnrIMPORTINGoutput = <fs>-matnr
*     EXCEPTIONS
*       LENGTH_ERROR       = 1
*       OTHERS = 2.IF sy-subrc <> 0.ENDIF.SELECT SINGLE matnr INTO @DATA(ls1) FROM mara WHERE mara~matnr = @<fs>-matnr.IF sy-subrc = 0.ELSE.<fs>-message = '物料号不存在'.<fs>-status  = 'E'.CONTINUE.ENDIF.SELECT SINGLE t001l~werks INTO @DATA(ls2) FROM t001l WHERE t001l~werks = @<fs>-werks.IF sy-subrc = 0.ELSE.<fs>-message = '工厂不存在'.<fs>-status  = 'E'.CONTINUE.ENDIF.SELECT SINGLE t001l~werks INTO @DATA(ls3) FROM t001l WHERE t001l~lgort = @<fs>-lgort.IF sy-subrc = 0.ELSE.<fs>-message = '库位不存在'.<fs>-status  = 'E'.CONTINUE.ENDIF.SELECT SINGLE * INTO  @DATA(ls_ztmm030)FROM ztmm030 WHERE ztmm030~werks = @<fs>-werks  AND ztmm030~lgort = @<fs>-lgort  AND ztmm030~matnr = @<fs>-matnr.IF sy-subrc = 0.<fs>-l1_old = ls_ztmm030-l1.<fs>-l2_old = ls_ztmm030-l2.<fs>-createby   = ls_ztmm030-createby.<fs>-createdate = ls_ztmm030-createdate.<fs>-createtime = ls_ztmm030-createtime.SELECT * INTO TABLE @DATA(ls_ztmm031) FROM ztmm031 WHERE ztmm031~c1 = @sy-uname.IF sy-subrc = 0.ELSE.<fs>-message = '无权限修改'.<fs>-status  = 'E'. CONTINUE.ENDIF.ELSE.<fs>-createby   = sy-uname.<fs>-createdate = sy-datum.<fs>-createtime = sy-uzeit.ENDIF.ENDLOOP.ENDFORM.FORM download_template USING pu_filename pu_objid.
*& 下载模版DATA: ls_objdata LIKE wwwdatatab.DATA: lv_filename TYPE string,lv_fullpath TYPE string  VALUE 'C:\',lv_path     TYPE  string VALUE 'C:\'.DATA: lv_errtxt TYPE string.DATA: lv_destination LIKE rlgrap-filename.DATA: lv_rc LIKE sy-subrc.DATA: lv_fileup LIKE rlgrap-filename.lv_filename = pu_filename .
*& 调用保存对话框CALL METHOD cl_gui_frontend_services=>file_save_dialogEXPORTINGdefault_extension    = 'xlsx'default_file_name    = lv_filenameinitial_directory    = 'C:\'CHANGINGfilename             = lv_filenamepath                 = lv_pathfullpath             = lv_fullpathEXCEPTIONScntl_error           = 1error_no_gui         = 2not_supported_by_gui = 3OTHERS               = 4.IF sy-subrc NE 0.MESSAGE '不能打开EXCEL' TYPE 'E'.ENDIF.CHECK lv_fullpath IS NOT INITIAL .lv_fileup = lv_fullpath.ls_objdata-relid = 'MI' .ls_objdata-objid = pu_objid .lv_destination = lv_fullpath .CALL FUNCTION 'DOWNLOAD_WEB_OBJECT'EXPORTINGkey         = ls_objdatadestination = lv_destinationIMPORTINGrc          = lv_rc.IF lv_rc NE 0.CONCATENATE '模板文件:' ls_objdata-objid '下载失败' INTO lv_errtxt.MESSAGE lv_errtxt TYPE 'E'.ELSE.MESSAGE '模版下载成功' TYPE 'S'.ENDIF.ENDFORM.                    " DOWNLOAD_TEMPLATEFORM set_catalog.DATA:lv_position TYPE i VALUE 1.CLEAR: lv_position.lv_position = lv_position + 1.
* 预定义一个输出模式DEFINE df_fieldcat.CLEAR gs_fieldcat_lvc.gs_fieldcat_lvc-col_pos     = lv_position."ALV 控制: 输出列gs_fieldcat_lvc-scrtext_m   = &1."中字段标签gs_fieldcat_lvc-fieldname   = &2."ALV 控制: 内部表字段的字段名称gs_fieldcat_lvc-no_zero     = &3."ALV 控制: 为输出隐藏零gs_fieldcat_lvc-checkbox    = &4."ALV 控制: 作为复选框输出gs_fieldcat_lvc-edit        = &5."设置可编辑模式gs_fieldcat_lvc-outputlen   = &6."输出长度gs_fieldcat_lvc-ref_table   = &7.gs_fieldcat_lvc-ref_field   = &8.gs_fieldcat_lvc-datatype    = &9.APPEND gs_fieldcat_lvc TO gt_fieldcat_lvc.ADD 1 TO lv_position.END-OF-DEFINITION.df_fieldcat:'状态' 'STATUS' 'X' '' '' '' '' '' '',
'消息' 'MESSAGE' 'X' '' '' '' '' '' '',
'工厂' 'WERKS' 'X' '' '' '' '' '' '',
'存储地点' 'LGORT' 'X' '' '' '' '' '' '',
'物料编号' 'MATNR' 'X' '' '' '' '' '' '',
'库存下限(当前)' 'L1_OLD' 'X' '' '' '' '' '' '',
'库存上限(当前)' 'L2_OLD' 'X' '' '' '' '' '' '',
'最近更新人' 'CREATEBY' 'X' '' '' '' '' '' '',
'最近更新日期' 'CREATEDATE' 'X' '' '' '' '' '' '',
'最近更新时间' 'CREATETIME' 'X' '' '' '' '' '' '',
'库存下限(未来)' 'L1' 'X' '' '' '' '' '' '',
'库存上限(未来)' 'L2' 'X' '' '' '' '' '' ''
.ENDFORM.FORM set_catalog1.DATA:lv_position TYPE i VALUE 1.CLEAR: lv_position.lv_position = lv_position + 1.
* 预定义一个输出模式DEFINE df_fieldcat.CLEAR gs_fieldcat_lvc.gs_fieldcat_lvc-col_pos     = lv_position."ALV 控制: 输出列gs_fieldcat_lvc-scrtext_m   = &1."中字段标签gs_fieldcat_lvc-fieldname   = &2."ALV 控制: 内部表字段的字段名称gs_fieldcat_lvc-no_zero     = &3."ALV 控制: 为输出隐藏零gs_fieldcat_lvc-checkbox    = &4."ALV 控制: 作为复选框输出gs_fieldcat_lvc-edit        = &5."设置可编辑模式gs_fieldcat_lvc-outputlen   = &6."输出长度gs_fieldcat_lvc-ref_table   = &7.gs_fieldcat_lvc-ref_field   = &8.gs_fieldcat_lvc-datatype    = &9.APPEND gs_fieldcat_lvc TO gt_fieldcat_lvc.ADD 1 TO lv_position.END-OF-DEFINITION.df_fieldcat:'工厂' 'WERKS' 'X' '' '' '' '' '' '','存储地点' 'LGORT' 'X' '' '' '' '' '' '','物料编号' 'MATNR' 'X' '' '' '' '' '' '','库存下限' 'L1' 'X' '' '' '' '' '' '','库存上限' 'L2' 'X' '' '' '' '' '' '','最近更新人' 'CREATEBY' 'X' '' '' '' '' '' '','最近更新日期' 'CREATEDATE' 'X' '' '' '' '' '' '','最近更新时间' 'CREATETIME' 'X' '' '' '' '' '' ''.ENDFORM.FORM set_catalog2.DATA:lv_position TYPE i VALUE 1.CLEAR: lv_position.lv_position = lv_position + 1.
* 预定义一个输出模式DEFINE df_fieldcat.CLEAR gs_fieldcat_lvc.gs_fieldcat_lvc-col_pos     = lv_position."ALV 控制: 输出列gs_fieldcat_lvc-scrtext_m   = &1."中字段标签gs_fieldcat_lvc-fieldname   = &2."ALV 控制: 内部表字段的字段名称gs_fieldcat_lvc-no_zero     = &3."ALV 控制: 为输出隐藏零gs_fieldcat_lvc-checkbox    = &4."ALV 控制: 作为复选框输出gs_fieldcat_lvc-edit        = &5."设置可编辑模式gs_fieldcat_lvc-outputlen   = &6."输出长度gs_fieldcat_lvc-ref_table   = &7.gs_fieldcat_lvc-ref_field   = &8.gs_fieldcat_lvc-datatype    = &9.APPEND gs_fieldcat_lvc TO gt_fieldcat_lvc.ADD 1 TO lv_position.END-OF-DEFINITION.df_fieldcat:'年度' 'LFGJA' 'X' '' '' '' '' '' '',
'月份' 'LFMON' 'X' '' '' '' '' '' '',
'工厂' 'WERKS' 'X' '' '' '' '' '' '',
'库存地点' 'LGORT' 'X' '' '' '' '' '' '',
'仓储地点描述' 'LGOBE' 'X' '' '' '' '' '' '',
'物料' 'MATNR' 'X' '' '' '' '' '' '',
'物料描述' 'ZWLCMS' 'X' '' '' '' '' '' '',
'单位' 'MEINS' 'X' '' '' '' '' '' '',
'库存数量' 'LABST' 'X' '' '' '' '' '' '',
'库存下限' 'L1' 'X' '' 'X' '' '' '' '',
'库存上限' 'L2' 'X' '' 'X' '' '' '' '',
'金额' 'JE' 'X' '' '' '' '' '' '',
'库存状态' 'TEXT' 'X' '' '' '' '' '' '',
'最近更新人' 'CREATEBY' 'X' '' '' '' '' '' '',
'最近更新日期' 'CREATEDATE' 'X' '' '' '' '' '' '',
'最近更新时间' 'CREATETIME' 'X' '' '' '' '' '' ''.ENDFORM.FORM display_alv_ztmm030.DATA: ls_layout TYPE lvc_s_layo.IF gt_data IS NOT INITIAL.ls_layout-zebra      = 'X'.ls_layout-cwidth_opt = 'X'.
* 调用ALV functionCALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'EXPORTINGi_callback_program       = sy-repid "这里是调用这个ALV的程序名i_callback_pf_status_set = 'PF_STATUS' "设置ALV状态栏的函数i_callback_user_command  = 'USER_COMMAND' "获取用户事件的函数is_layout_lvc            = ls_layout "显示的布局it_fieldcat_lvc          = gt_fieldcat_lvc "设置显示的字段以及字段的功能i_save                   = 'A'TABLESt_outtab                 = gt_dataEXCEPTIONSprogram_error            = 1.IF sy-subrc <> 0.MESSAGE '报表生成异常,请联系系统管理员!' TYPE 'S' DISPLAY LIKE 'E'.ENDIF.ELSE.
* 这个消息用来显示我们是不是获取到了数据,自己用的时候把这个硬代码换成你需要的TEXT-XXX.MESSAGE '没有获取到数据,请重新检索!' TYPE 'S' DISPLAY LIKE 'E'.LEAVE TO LIST-PROCESSING.EXIT.ENDIF.
ENDFORM.FORM display_alv.DATA: ls_layout TYPE lvc_s_layo.IF gt_data IS NOT INITIAL.ls_layout-zebra      = 'X'.ls_layout-cwidth_opt = 'X'.
* 调用ALV functionCALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'EXPORTINGi_callback_program       = sy-repid "这里是调用这个ALV的程序名i_callback_pf_status_set = 'PF_STATUS' "设置ALV状态栏的函数i_callback_user_command  = 'USER_COMMAND' "获取用户事件的函数is_layout_lvc            = ls_layout "显示的布局it_fieldcat_lvc          = gt_fieldcat_lvc "设置显示的字段以及字段的功能i_save                   = 'A'TABLESt_outtab                 = gt_dataEXCEPTIONSprogram_error            = 1.IF sy-subrc <> 0.MESSAGE '报表生成异常,请联系系统管理员!' TYPE 'S' DISPLAY LIKE 'E'.ENDIF.ELSE.
* 这个消息用来显示我们是不是获取到了数据,自己用的时候把这个硬代码换成你需要的TEXT-XXX.MESSAGE '没有获取到数据,请重新检索!' TYPE 'S' DISPLAY LIKE 'E'.LEAVE TO LIST-PROCESSING.EXIT.ENDIF.
ENDFORM.FORM display_alv2.DATA: ls_layout TYPE lvc_s_layo.IF gt_data2 IS NOT INITIAL.ls_layout-zebra      = 'X'.ls_layout-cwidth_opt = 'X'.ls_layout-stylefname   = 'CELTAB'.
* 调用ALV functionCALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'EXPORTINGi_callback_program       = sy-repid "这里是调用这个ALV的程序名i_callback_pf_status_set = 'PF_STATUS' "设置ALV状态栏的函数i_callback_user_command  = 'USER_COMMAND' "获取用户事件的函数is_layout_lvc            = ls_layout "显示的布局it_fieldcat_lvc          = gt_fieldcat_lvc "设置显示的字段以及字段的功能i_save                   = 'A'TABLESt_outtab                 = gt_data2EXCEPTIONSprogram_error            = 1.IF sy-subrc <> 0.MESSAGE '报表生成异常,请联系系统管理员!' TYPE 'S' DISPLAY LIKE 'E'.ENDIF.ELSE.
* 这个消息用来显示我们是不是获取到了数据,自己用的时候把这个硬代码换成你需要的TEXT-XXX.MESSAGE '没有获取到数据,请重新检索!' TYPE 'S' DISPLAY LIKE 'E'.LEAVE TO LIST-PROCESSING.EXIT.ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form get_data_for_ztmm030
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM get_data_for_ztmm030 .SELECT * INTO CORRESPONDING FIELDS OF TABLE @gt_data FROM ztmm030WHERE ztmm030~matnr IN @so_matnrAND ztmm030~werks IN @so_werksAND ztmm030~lgort IN @so_lgort.ENDFORM.
*&---------------------------------------------------------------------*
*& 包含               ZMM028_PAI
*&---------------------------------------------------------------------**&---------------------------------------------------------------------*
*&  包含                ZFI068_PAI
*&---------------------------------------------------------------------*FORM user_command USING i_ucomm TYPE sy-ucommi_wa_selfield TYPE slis_selfield.DATA:gwa_edit TYPE lvc_s_styl,git_edit TYPE lvc_t_styl.DATA lv_length TYPE num10.DATA lr_grid TYPE REF TO cl_gui_alv_grid.CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'IMPORTINGe_grid = lr_grid.CALL METHOD lr_grid->check_changed_data.CALL METHOD lr_grid->refresh_table_display.i_wa_selfield-refresh = 'X'.CASE i_ucomm.WHEN  'ZSAVE'.DATA(lt_check) = gt_data.DELETE lt_check WHERE status <> 'E'.IF lines( lt_check ) <> 0.MESSAGE '检查未通过' TYPE 'E'.ENDIF.*      "权限检查
*      DATA:lv_auth TYPE char.
*      lv_auth = ''.*      SELECT * INTO TABLE @DATA(ls_ztmm031) FROM ztmm031 WHERE ztmm031~c1 = @sy-uname.
*      IF sy-subrc = 0.
*        lv_auth = 'X'.
*      ELSE.**        MESSAGE '没有权限,请联系系统管理员!' TYPE 'S' DISPLAY LIKE 'E'.
**        LEAVE TO LIST-PROCESSING.
**        EXIT.
*      ENDIF.
*
*      IF lv_auth  = 'X'.DATA:lt_ TYPE TABLE OF ztmm030.MOVE-CORRESPONDING gt_data TO lt_.MODIFY ztmm030 FROM TABLE lt_.MESSAGE '保存成功' TYPE 'S'.*      ENDIF.WHEN  'ZSAVE1'.DATA:lt_ztmm030 TYPE TABLE OF ztmm030.DATA:ls_ztmm030 TYPE  ztmm030.LOOP AT gt_data2 INTO gs_data2.IF gs_data2-l1 = gs_data2-l1_ AND gs_data2-l2 = gs_data2-l2_.ELSE.MOVE-CORRESPONDING gs_data2 TO ls_ztmm030.ls_ztmm030-createby   = sy-uname.ls_ztmm030-createdate = sy-datum.ls_ztmm030-createtime = sy-uzeit.APPEND ls_ztmm030           TO lt_ztmm030.ENDIF.ENDLOOP.IF lt_ztmm030 IS NOT INITIAL.MODIFY ztmm030 FROM TABLE lt_ztmm030.MESSAGE '保存成功' TYPE 'S'.ENDIF.WHEN  'ZSAVE2'.WHEN 'ZSAL'.WHEN 'ZALL'.WHEN OTHERS.ENDCASE.ENDFORM.
*&---------------------------------------------------------------------*
*& 包含               ZMM028_PBO
*&---------------------------------------------------------------------*FORM pf_status USING lt_extab TYPE slis_t_extab.REFRESH:lt_extab[]. CLEAR:lt_extab.IF p_inp = 'X'.SET TITLEBAR 'ZSTATUS_TITLE'."说明:需要显示的按钮进行注释
*    APPEND 'ZSAVE'  TO lt_extab.APPEND 'ZSAVE1'  TO lt_extab.SET PF-STATUS 'ZSTATUS_001' EXCLUDING lt_extab.ELSEIF p_sel = 'X'.SET TITLEBAR 'ZSTATUS_TITLE'."说明:需要显示的按钮进行注释APPEND 'ZSAVE'  TO lt_extab.APPEND 'ZSAVE1'  TO lt_extab.SET PF-STATUS 'ZSTATUS_001' EXCLUDING lt_extab.ELSE.SET TITLEBAR 'ZSTATUS_TITLE'."说明:需要显示的按钮进行注释APPEND 'ZSAVE'  TO lt_extab.SET PF-STATUS 'ZSTATUS_001' EXCLUDING lt_extab.ENDIF.ENDFORM.
*&---------------------------------------------------------------------*
*& 包含               ZMM028_SEL
*&---------------------------------------------------------------------*TABLES:lips,ztmm030,mard.SELECTION-SCREEN:BEGIN OF BLOCK b0 WITH FRAME TITLE TEXT-001.PARAMETERS:p_inp RADIOBUTTON GROUP g1 USER-COMMAND u1 DEFAULT 'X'.PARAMETERS:p_sel RADIOBUTTON GROUP g1 .PARAMETERS:p_sel2 RADIOBUTTON GROUP g1 .PARAMETERS: pa_file TYPE rlgrap-filename ."文件夹上传SELECTION-SCREEN SKIP 1.*
*  SELECT-OPTIONS: so_lfgja FOR mard-lfgja.
*  SELECT-OPTIONS: so_lfmon FOR mard-lfmon.SELECT-OPTIONS: so_werks FOR ztmm030-werks.SELECT-OPTIONS: so_lgort FOR ztmm030-lgort.SELECT-OPTIONS: so_matnr FOR ztmm030-matnr.SELECTION-SCREEN:END OF BLOCK b0.
*&---------------------------------------------------------------------*
*& 包含               ZMM028_TOP
*&---------------------------------------------------------------------**&---------------------------------------------------------------------*
*&  包含                ZFI068_TOP
*&---------------------------------------------------------------------*
TABLES: sscrfields,vbak,bsis.
TYPE-POOLS: esp1,slis ,icon.TYPES: BEGIN OF gy_data,*         checked    TYPE char1,       "勾选框
*         status_inc TYPE char10,      "状态灯status     TYPE char2,       "状态message    TYPE char255,     "消息文本zindex     TYPE i,            "序号werks      TYPE ztmm030-werks, "工厂lgort      TYPE ztmm030-lgort, "存储地点matnr      TYPE ztmm030-matnr, "物料编号l1_old     TYPE ztmm030-l1,   "库存下限(当前)l2_old     TYPE ztmm030-l2,   "库存上限(当前)createby   TYPE ztmm030-createby,  "最后更新人createdate TYPE ztmm030-createdate, "最后更新日期createtime TYPE ztmm030-createtime, "最后更新时间l1         TYPE ztmm030-l1,    "库存下限(未来)l2         TYPE ztmm030-l2,    "库存上限(未来)END OF gy_data.DATA: gs_data TYPE gy_data,gt_data TYPE TABLE OF gy_data.
FIELD-SYMBOLS: <fs_data>  TYPE gy_data.TYPES: BEGIN OF gy_data2,lfgja      TYPE   mard-lfgja,  "年度lfmon      TYPE   mard-lfmon,  "月份werks      TYPE   mard-werks,  "工厂lgort      TYPE   mard-lgort,  "库存地点lgobe      TYPE   t001l-lgobe, "仓储地点描述matnr      TYPE   mard-matnr,  "物料zwlcms     TYPE   mara-zwlcms, "物料描述meins      TYPE   mara-meins,  "单位labst      TYPE   mard-labst,  "库存数量l1         TYPE ztmm030-l1,    "库存下限l2         TYPE ztmm030-l2,    "库存上限"je         TYPE  mbew-verpr,   "金额je         TYPE  acdoca-tsl,   "金额text       TYPE char10,        "库存状态verpr      TYPE mbew-verpr,peinh      TYPE mbew-peinh,
*         sobkz  TYPE   mspr-sobkz,  "特殊库存
*         pspnr  TYPE   mspr-pspnr,  "特殊库存编号
*         prlab  TYPE   mspr-prlab,  "库存数量createby   TYPE ztmm030-createby,   "最后更新人createdate TYPE ztmm030-createdate, "最后更新日期createtime TYPE ztmm030-createtime, "最后更新时间f1         TYPE char1,l1_        TYPE ztmm030-l1,    "库存下限l2_        TYPE ztmm030-l2,    "库存上限celtab     TYPE  lvc_t_styl,  "控制字段可编辑的参数END OF gy_data2.DATA: gs_data2 TYPE gy_data2,gt_data2 TYPE TABLE OF gy_data2.
FIELD-SYMBOLS: <fs_data2>  TYPE gy_data2.DATA: gt_fieldcat_lvc TYPE lvc_t_fcat, "ALV:定义一个先显示字段的表gs_fieldcat_lvc LIKE LINE OF gt_fieldcat_lvc. "ALV

二、设计逻辑

表名-字段名

字段描述

说明

MARD-LFGJA

MARD-LFMON

备注:

1.以当前年月为查询条件

MARD-LFGJA    = 当前年

MARD-LFMON  = 当前月份

2.通用库存MARD,库存数量不为0的数据

3.只查询V价物料

MBEW-MATNR =MSPR/MARD-MATNR

MBEW-BWKEY=MSPR/MARD-WERKS

MBEW-VPRSV=V的数据

MARD-WERKS

工厂

MARD-LGORT

仓库

T001L-LGOBE

仓储地点描述

MARD-WERKS=T001L-WERKS

MARD-LGORT=T001L-LGORT

取T001L-LGOBE

MARD-MATNR

物料编码

MARA-ZWLCMS

物料长描述

MARD-MATNR=MARA-MATNR

取MARA-ZWLCMS

MSPR-SOBKZ

特殊库存

MSPR-PSPNR

特殊库存编号

MARA-MEINS

单位

MSPR-PRLAB

MARD-LABST

库存数量

MSPR-PRLAB≠0

MARD-LABST≠0

用户输入

库存下限

  1. 用户可批导
  2. 用户编辑修改  只能编辑修改一次   可参考ZMM018变更计划交期字段 

用户输入

库存上限

  1. 用户可批导
  2. 用户编辑修改  只能编辑修改一次   可参考ZMM018变更计划交期字段 

库存金额

MBEW-MATNR =MARD-MATNR

MBEW-BWKEY=MARD-WERKS

取到MBEW-VERPR ÷MBEW-PEINH的单价

再用单价*所对应的库存数量

文本显示

库存状态

状态有四种(超上限、库存过低、库存正常、空)

当前库存数量与库存上下限对比,无上下限对比则为空

高于上限值=“超上限”

介于上下限值中间=“库存正常”

低于下限值=“库存过低”

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/571605.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

短期通过PMP考试该如何备考?

不得不提到&#xff0c;新版本的考纲确实有些挑战性。我想和大家分享一下我的考试感受。个人认为新考纲的难度相对较高&#xff0c;至少比之前的冲刺模拟试题难度要大。新考纲的难点主要体现在两个方面&#xff1a;一是灵活变通的题目&#xff0c;二是混合题目数量比预期多得多…

Netty教程之NIO基础

NIO 介绍 NIO 全称java non-blocking IO&#xff08;非阻塞 I/O&#xff09;&#xff0c;后续提供了一系列改进的输入/输出的新特性&#xff0c;被统称为 NIO(即 New IO)&#xff0c;是同步非阻塞的。 阻塞和非阻塞是进程在访问数据的时候&#xff0c;数据是否准备就绪的一种…

Springboot:Actuator监控

提示&#xff1a;文章写完后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 目录 一、Actuator介绍 二、集成步骤 三、重要端点介绍 1、/actuator 2、/actuator/env 3、/actuator/heapdump 4、/actuator/metrics 5、/actuator/shutdown 6、/l…

HWM豪迈电子听漏仪维修相关仪XMIC-lite DXmic-lite

漏水检测系列仪器维修Leakage ManagemHWM豪迈电子听漏仪维修XMIC-lite DXmic-liteent检测仪器包括&#xff1a;Xmic电子听漏仪维修、Xmic-lite电子听漏仪&#xff1b;DXmic&#xff1b;DXmic-lite等系列。也叫电子地面麦克风,用来放大水从带有压力的自来水管道中泄漏出来产生的…

Go——结构体

Go语言中没有类的概念&#xff0c;也不支持类的继承等面向对象的概念。Go语言中通过结构体的内嵌再配合接口比面向对象具有更高的扩展性和灵活性。 一. 类型别名和自定义类型 1.1 自定义类型 在Go语言中有一些基本的数据类型&#xff0c;如string&#xff0c;整型&#xff0c;…

【随笔】Git -- 常用命令(四)

&#x1f48c; 所属专栏&#xff1a;【Git】 &#x1f600; 作  者&#xff1a;我是夜阑的狗&#x1f436; &#x1f680; 个人简介&#xff1a;一个正在努力学技术的CV工程师&#xff0c;专注基础和实战分享 &#xff0c;欢迎咨询&#xff01; &#x1f496; 欢迎大…

Element

1、Element 基本使用 1.1、Element介绍 Element&#xff1a;网站快速成型工具。是饿了么公司前端开发团队提供的一套基于Vue的网站组件库。 使用Element前提必须要有Vue。 组件&#xff1a;组成网页的部件&#xff0c;例如超链接、按钮、图片、表格等等~ Element官网&#…

python实现图片压缩

首先 pip install Pillow compression_level参数&#xff0c;该参数的范围从0到100&#xff0c;其中0表示最小尺寸&#xff08;最高压缩&#xff09;&#xff0c;100表示最大质量&#xff08;最小压缩&#xff09;。这个脚本将尝试在保持图片可识别性的同时&#xff0c;尽可能…

Java_16 移动零

移动零 给定一个数组 nums&#xff0c;编写一个函数将所有 0 移动到数组的末尾&#xff0c;同时保持非零元素的相对顺序。 请注意 &#xff0c;必须在不复制数组的情况下原地对数组进行操作。 示例 1: 输入: nums [0,1,0,3,12] 输出: [1,3,12,0,0] 示例 2: 输入: nums [0]…

uniapp对接极光推送(国内版以及海外版)

勾选push&#xff0c;但不要勾选unipush 国内版 网址&#xff1a;极光推送-快速集成消息推送功能,提升APP运营效率 (jiguang.cn) 进入后台&#xff0c;并选择对应应用开始配置 配置安卓包名 以及ios推送证书&#xff0c;是否将生产证书用于开发环境选择是 ios推送证书…

如何将python项目转变成deb安装包

先将python项目转变成可执行文件 1. 首先确保你的python项目可以正常执行 2.安装pyinstaller模块&#xff0c;pip install pyinstaller -i Simple Index 3.确定好你的项目的文件入口&#xff0c;也就是运行的文件.py 4. 开始打包成单文件&#xff0c;pyinstaller -F <第…

Maya 2024 for Mac/Win:重塑三维创意世界的利器

在数字化浪潮汹涌的当下&#xff0c;三维图形软件早已成为创意产业不可或缺的重要工具。而在这其中&#xff0c;Maya 2024以其卓越的性能和丰富的功能&#xff0c;赢得了无数设计师的青睐。无论是Mac还是Win平台&#xff0c;Maya 2024都能为您的三维创作提供强大的支持。 Maya…