SAP库龄计算报表(源码)

news2024/12/26 20:55:24

一个简单的库龄计算报表,根据移动类型来判断最后移动日期,包含批次和非批次库存。

*&---------------------------------------------------------------------*
*& Report ZMMR_016
*&---------------------------------------------------------------------*
*& Created by         : 
*& Created on         : 2024.07.19
*& Requested by       :
*& Description        :
*& Description        : 根据物料的最后一次移动记录计算库存的时间。排除311,312位置移动的规则
*&
*& Authority Object   :
*& Transport Request  :
*&---------------------------------------------------------------------*
REPORT zmmr_016.

TABLES:vggt2.
INCLUDE zmmr_016_top.

INCLUDE zmmr_016_s01.

INCLUDE zmmr_016_form.


INITIALIZATION.

START-OF-SELECTION.

  PERFORM get_data.

  IF so_charg IS INITIAL.
    PERFORM get_data2.
  ENDIF.

  PERFORM build_data.

*--------- END-OF-SELECTION ----------
END-OF-SELECTION.
  IF gt_data IS INITIAL.
    MESSAGE '没有找到相关的数据!' TYPE 'S' DISPLAY LIKE 'E'.  " 没有找到相关的数据!
  ELSE.
*   显示alv界面
    PERFORM frm_display_alv.
  ENDIF.

*&---------------------------------------------------------------------*
*& Include          ZMMR_016_TOP
*&---------------------------------------------------------------------*
TYPE-POOLS slis.
INCLUDE <icon>.
INCLUDE <symbol>.
TABLES: mara,marc,mard,mch1,mchb,t001l,ekpo,vbrk.

TYPES :BEGIN OF gy_data,
         werks        TYPE mchb-werks,
         matnr        TYPE mchb-matnr,
         maktx        TYPE makt-maktx,
         mfrnr        TYPE mara-mfrnr, "生产商
         mftxt        TYPE text80, "生产商名称
         bu_sort1     TYPE bu_sort1, "业务伙伴的搜索词 1
         mfrpn        TYPE mara-mfrpn, "生产商货号
         groes        TYPE mara-groes, "大小/量纲
         charg        TYPE mchb-charg,
         licha        TYPE mch1-licha, "供应商批次
         lgort        TYPE mchb-lgort,
         lgobe        TYPE t001l-lgobe,
         zzfi01       TYPE ekpo-zzfi01,
         zzfi02       TYPE ekpo-zzfi02,
         zzfi03       TYPE ekpo-zzfi03,
         zzfi04       TYPE ekpo-zzfi04,
         vfdat        TYPE mcha-vfdat,
         meins        TYPE mara-meins,
         cuobj_bm     TYPE mcha-cuobj_bm, "内部对象号
         cspem        TYPE mchb-cspem,
         clabs        TYPE mchb-clabs,
         cinsm        TYPE mchb-cinsm,
         ceinm        TYPE mchb-ceinm,
         msbookpartno TYPE mara-msbookpartno,
         bu_sort2     TYPE but000-bu_sort1, 
         ktext        TYPE aufk-ktext, 
         ktext2       TYPE cskt-ktext, 
         text         TYPE char255, 
         ZEINR        TYPE mara-zeinr,   "  成品出库短描述 20210512 addby XXX
         hsdat        TYPE mch1-hsdat,   "  生产日期     addby  XXX 20240318
         budat        TYPE mkpf-budat,    " 最后移动的日期
         zzkts        TYPE i,   " 在库天数
       END OF gy_data.

DATA :gt_data TYPE TABLE OF gy_data,
      gs_data TYPE gy_data.
DATA :gt_data2 TYPE TABLE OF gy_data,
      gs_data2 TYPE gy_data.

DATA :gt_but000 TYPE TABLE OF but000,
      gs_but000 TYPE but000.

TYPES :BEGIN OF gy_objek ,
         objek TYPE cuobn,
       END OF gy_objek.
DATA:gt_objek TYPE TABLE OF gy_objek,
     gs_objek TYPE gy_objek.

DATA:gt_ausp_1 TYPE TABLE OF ausp,
     gs_ausp_1 TYPE ausp.
DATA:gt_ausp_2 TYPE TABLE OF ausp,
     gs_ausp_2 TYPE ausp.
DATA:gt_ausp_3 TYPE TABLE OF ausp,
     gs_ausp_3 TYPE ausp.
DATA:gt_ausp_4 TYPE TABLE OF ausp,
     gs_ausp_4 TYPE ausp.

DATA:gt_t001l TYPE TABLE OF t001l,
     gs_t001l TYPE t001l.

TYPES:BEGIN OF gy_mara,
        matnr        TYPE mara-matnr,
        mfrnr        TYPE mara-mfrnr,
        mfrpn        TYPE mara-mfrpn,
        meins        TYPE mara-meins,
        msbookpartno TYPE dimp_drm_msbookpart,
        groes        TYPE mara-groes,
        ZEINR        TYPE mara-zeinr,   "  成品出库短描述 20210512 addby XXX
      END OF gy_mara.
DATA:gt_mara TYPE TABLE OF gy_mara,
     gs_mara TYPE gy_mara.

DATA:gt_makt TYPE TABLE OF makt,
     gs_makt TYPE makt.

DATA:gt_mch1 TYPE TABLE OF mch1,  "  增加生产日期  by  XXX  20240218
     gs_mch1 TYPE mch1.

TYPES:BEGIN OF gy_mkpf,     "   XXX 20240717
     matnr    TYPE mara-matnr,
     charg    TYPE  mseg-charg,
     mblnr    TYPE  mkpf-mblnr,
     mjahr    type  mkpf-mjahr,
      budat    type  mkpf-budat,
  END OF gy_mkpf.
DATA:gt_mkpf TYPE TABLE OF gy_mkpf,
     gs_mkpf TYPE gy_mkpf.

DATA gv_pur_glag(1).
****Defination for FM geting classification
DATA gv_objkey TYPE bapi1003_key-object.
DATA:gt_num_v  TYPE TABLE OF bapi1003_alloc_values_num,
     gs_num_v  TYPE bapi1003_alloc_values_num,
     gt_char_v TYPE TABLE OF bapi1003_alloc_values_char,
     gs_char_v TYPE bapi1003_alloc_values_char,
     gt_curr_v TYPE TABLE OF bapi1003_alloc_values_curr,
     gs_curr_v TYPE bapi1003_alloc_values_curr,
     gt_return TYPE TABLE OF bapiret2.

DATA:gt_characteristic TYPE TABLE OF bapi1003_object_keys,
     gs_characteristic TYPE bapi1003_object_keys,
     gt_message        TYPE TABLE OF bapiret2.


DATA: gs_layout     TYPE slis_layout_alv,
      gs_layout_lvc TYPE lvc_s_layo.
DATA: gs_grid TYPE lvc_s_glay.
DATA: gs_fieldcat      TYPE slis_fieldcat_alv,
      gt_fieldcat      TYPE TABLE OF slis_fieldcat_alv,
      gt_fieldca1      TYPE TABLE OF slis_fieldcat_alv,
      gt_fieldca2      TYPE TABLE OF slis_fieldcat_alv,
      gt_fieldcat_item TYPE TABLE OF slis_fieldcat_alv,
      gt_fieldcat_msg  TYPE TABLE OF slis_fieldcat_alv.
DATA: gs_fieldcat_lvc TYPE lvc_s_fcat,
      gt_fieldcat_lvc TYPE lvc_t_fcat.

DATA: gs_sortinfo_alv TYPE slis_sortinfo_alv,
      gt_sortinfo_alv TYPE slis_t_sortinfo_alv.
DATA: gs_sortinfo_lvc TYPE lvc_s_sort,
      gt_sortinfo_lvc TYPE lvc_t_sort.

DATA: gt_list_top_of_page TYPE slis_t_listheader.
DATA: gs_print_alv TYPE slis_print_alv.
DATA: gs_event TYPE slis_alv_event,
      gt_event TYPE slis_t_event.
DATA: col_pos          TYPE i,
      g_fieldcat_value TYPE text10.
DATA: galv_grid  TYPE REF TO cl_gui_alv_grid.

DATA:
  cal_intime TYPE i.

DATA res_intime TYPE p DECIMALS 2.

* ------ macro defination
CLEAR:   gt_fieldcat.
REFRESH: gt_fieldcat.
DEFINE fieldcat_macro.
  CLEAR gs_fieldcat.
  col_pos = col_pos + 1.
  gs_fieldcat-tabname   = 'GT_DATA'.
  gs_fieldcat-fieldname = '&1'.
  gs_fieldcat-seltext_l = &2.
  gs_fieldcat-key       = &3.
  gs_fieldcat-decimals_out = &4.
*   gs_fieldcat-emphasize = &5.
*   gs_fieldcat-edit      = &5.
  gs_fieldcat-no_out      = &5.
*   gs_fieldcat-hotspot   = &6.
  gs_fieldcat-checkbox  = &6.
  gs_fieldcat-outputlen  = &7.
  gs_fieldcat-no_zero   = &8.
  gs_fieldcat-just      = &9.
  gs_fieldcat-col_pos   = col_pos.
  APPEND gs_fieldcat TO gt_fieldcat.
END-OF-DEFINITION.

*&---------------------------------------------------------------------*
*& Include          ZMMR_016_S01
*&---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK 0 WITH FRAME TITLE TEXT-001.
  SELECT-OPTIONS: so_matnr FOR mch1-matnr .
  SELECT-OPTIONS: so_werks FOR mchb-werks OBLIGATORY DEFAULT '1000'.
  SELECT-OPTIONS: so_lgort FOR mchb-lgort.
  SELECT-OPTIONS: so_charg FOR mchb-charg.
SELECTION-SCREEN END OF BLOCK 0.

*&---------------------------------------------------------------------*
*& Include          ZMMR_016_FORM
*&---------------------------------------------------------------------*
*逻辑:通过客制化字段(项目、部门、申请人、任务)查询物料库存物资。
*&---------------------------------------------------------------------*
*&      Form  GET_DATA
*       获取数据
*----------------------------------------------------------------------*
FORM get_data .
*****  抓取符合前4个条件的批次
  FREE gt_data.
  SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_data
    FROM mchb INNER JOIN mch1
     ON mch1~matnr = mchb~matnr AND mch1~charg = mchb~charg
    WHERE mchb~matnr IN so_matnr
    AND mchb~werks IN so_werks
    AND mchb~lgort IN so_lgort
    AND mchb~charg IN so_charg
    AND ( clabs NE '' OR cinsm NE '' OR ceinm NE '' OR cspem NE '' ). "无库存不显示在报表中

****  以下转换仅用来适应 FOR ALL ENTRIES IN 关键字
  FREE gt_objek .
  LOOP AT gt_data INTO gs_data.
    CLEAR gs_objek.
    gs_objek-objek = gs_data-cuobj_bm.
    APPEND gs_objek TO gt_objek.
  ENDLOOP.

  IF gt_data IS NOT INITIAL.
    FREE gt_mara.
    SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_mara
      FROM mara
      FOR ALL ENTRIES IN gt_data
      WHERE matnr = gt_data-matnr.

    FREE gt_makt.
    SELECT * FROM makt INTO TABLE gt_makt
      FOR ALL ENTRIES IN gt_data
      WHERE matnr = gt_data-matnr
          AND spras = sy-langu.

    FREE gt_mch1.     "   addby   XXX  20240318
    SELECT * FROM mch1 INTO TABLE gt_mch1
      FOR ALL ENTRIES IN gt_data
      WHERE matnr = gt_data-matnr
          AND charg = gt_data-charg.


    IF gt_mara IS NOT INITIAL.
      FREE gt_but000.
      SELECT * FROM but000 INTO TABLE gt_but000
        FOR ALL ENTRIES IN gt_mara
        WHERE partner = gt_mara-mfrnr.
    ENDIF.

    FREE gt_t001l.
    SELECT * FROM t001l INTO TABLE gt_t001l
      FOR ALL ENTRIES IN gt_data
      WHERE werks = gt_data-werks
      AND lgort = gt_data-lgort.

    FREE gt_mkpf.    "  XXX 20240717
     SELECT mkpf~budat mseg~charg mkpf~mblnr  mkpf~mjahr
     from mkpf INNER JOIN mseg ON mkpf~mblnr = mseg~mblnr and mkpf~mjahr = mseg~mjahr
     INTO CORRESPONDING FIELDS OF TABLE gt_mkpf
      FOR ALL ENTRIES IN gt_data
          WHERE mseg~charg = gt_data-charg
       AND BWART NOT IN ('311','312','321','322').
     SORT gt_mkpf DESCENDING by charg budat.
     DELETE ADJACENT DUPLICATES FROM gt_mkpf COMPARING charg..


  ENDIF.

  LOOP AT gt_data INTO gs_data.


****  生产商  生产商货号  单位  规格型号 成品出库短描述
    CLEAR gs_mara .
    READ TABLE gt_mara INTO gs_mara WITH KEY matnr = gs_data-matnr.
    IF sy-subrc = 0.
      gs_data-mfrnr = gs_mara-mfrnr.
      gs_data-mfrpn = gs_mara-mfrpn.
      gs_data-meins = gs_mara-meins.
      gs_data-msbookpartno = gs_mara-msbookpartno.
      gs_data-groes = gs_mara-groes.
      gs_data-zeinr = gs_mara-zeinr.
      CLEAR gs_but000.
      READ TABLE gt_but000 INTO gs_but000 WITH KEY partner = gs_mara-mfrnr.
      IF sy-subrc = 0.
*        gs_data-bu_sort1  = gs_but000-bu_sort1 .
        CONCATENATE gs_but000-name_org1 gs_but000-name_org2
                    gs_but000-name_org3 gs_but000-name_org4 INTO gs_data-mftxt.
      ENDIF.
    ENDIF.

****   物料描述
    CLEAR gs_makt.
    READ TABLE gt_makt INTO gs_makt WITH KEY matnr = gs_data-matnr.
    IF sy-subrc = 0.
      gs_data-maktx = gs_makt-maktx.
    ENDIF.

****   生产日期    addby XXX  20240318
    CLEAR gs_mch1.
    READ TABLE gt_mch1 INTO gs_mch1 WITH KEY matnr = gs_data-matnr charg = gs_data-charg.
    IF sy-subrc = 0.
      gs_data-hsdat = gs_mch1-hsdat.
    ENDIF.

    CLEAR gs_mkpf.  "  XXX  20240717
    READ TABLE gt_mkpf  INTO gs_mkpf WITH KEY charg = gs_data-charg.
    IF sy-subrc = 0.
      gs_data-budat = gs_mkpf-budat.
    ENDIF.

    gs_data-zzkts = sy-datum - gs_data-budat.

****   仓库描述
    CLEAR gs_t001l .
    READ TABLE gt_t001l INTO gs_t001l WITH KEY werks = gs_data-werks lgort = gs_data-lgort.
    IF sy-subrc = 0.
      gs_data-lgobe = gs_t001l-lgobe.
    ENDIF.

*    CALL FUNCTION 'CONVERSION_EXIT_CUNIT_OUTPUT'
*      EXPORTING
*        input     = gs_data-meins
*      IMPORTING
*        long_text = gs_data-meins.

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        input  = gs_data-zzfi03
      IMPORTING
        output = gs_data-zzfi03.

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        input  = gs_data-zzfi04
      IMPORTING
        output = gs_data-zzfi04.

    PERFORM frm_get_text USING gs_data-matnr gs_data-charg CHANGING gs_data-text."批次长文本,包装批次

    MODIFY gt_data FROM gs_data.
  ENDLOOP.
ENDFORM.                    " GET_DATA

FORM get_data2.
  SELECT mard~matnr mard~werks mard~lgort meins mfrnr mfrpn msbookpartno
     labst AS clabs insme AS cinsm einme AS ceinm speme AS cspem
     FROM mard INNER JOIN mara ON mard~matnr = mara~matnr
    INTO CORRESPONDING FIELDS OF TABLE gt_data2
      WHERE mard~matnr IN so_matnr
        AND mard~werks IN so_werks
        AND mard~lgort IN so_lgort
        AND mara~xchpf NE 'X'
        AND ( labst NE '' OR insme NE '' OR einme NE '' OR speme NE '' ). "无库存不显示在报表中

  FREE:gt_t001l, gt_makt ,gt_but000.

  IF gt_data2 IS NOT INITIAL.

    SELECT * FROM makt INTO CORRESPONDING FIELDS OF TABLE gt_makt
      FOR ALL ENTRIES IN gt_data2
      WHERE matnr = gt_data2-matnr
      AND spras = sy-langu.

    SELECT * FROM t001l INTO CORRESPONDING FIELDS OF TABLE gt_t001l
      FOR ALL ENTRIES IN gt_data2
      WHERE werks = gt_data2-werks
        AND lgort = gt_data2-lgort.

    SELECT * FROM but000 INTO TABLE gt_but000
      FOR ALL ENTRIES IN gt_data2
      WHERE partner = gt_data2-mfrnr.

FREE gt_mkpf.    "  XXX 20240717
         SELECT mkpf~budat mseg~matnr mkpf~mblnr  mkpf~mjahr
     from mkpf INNER JOIN mseg ON mkpf~mblnr = mseg~mblnr and mkpf~mjahr = mseg~mjahr
     INTO CORRESPONDING FIELDS OF TABLE gt_mkpf
      FOR ALL ENTRIES IN gt_data2
          WHERE mseg~matnr = gt_data2-matnr
      AND  BWART NOT IN ('311','312','321','322').
     SORT gt_mkpf DESCENDING by matnr budat.
     DELETE ADJACENT DUPLICATES FROM gt_mkpf COMPARING matnr.

  ENDIF.

  LOOP AT gt_data2 INTO gs_data2.
****   物料描述
    CLEAR gs_makt.
    READ TABLE gt_makt INTO gs_makt WITH KEY matnr = gs_data2-matnr.
    IF sy-subrc = 0.
      gs_data2-maktx = gs_makt-maktx.
    ENDIF.

    CLEAR gs_but000.
    READ TABLE gt_but000 INTO gs_but000 WITH KEY partner = gs_data2-mfrnr.
    IF sy-subrc = 0.
      gs_data2-bu_sort1  = gs_but000-bu_sort1 .
    ENDIF.

****   仓库描述
    CLEAR gs_t001l .
    READ TABLE gt_t001l INTO gs_t001l WITH KEY werks = gs_data2-werks lgort = gs_data2-lgort.
    IF sy-subrc = 0.
      gs_data2-lgobe = gs_t001l-lgobe.
    ENDIF.

    CLEAR gs_mkpf.  "  XXX  20240717
    READ TABLE gt_mkpf  INTO gs_mkpf WITH KEY matnr = gs_data2-matnr.
    IF sy-subrc = 0.
      gs_data2-budat = gs_mkpf-budat.
    ENDIF.

    gs_data2-zzkts = sy-datum - gs_data2-budat.
*    CALL FUNCTION 'CONVERSION_EXIT_CUNIT_OUTPUT'
*      EXPORTING
*        input     = gs_data2-meins
*      IMPORTING
*        long_text = gs_data2-meins.

    PERFORM frm_get_text USING gs_data2-matnr gs_data2-charg CHANGING gs_data2-text.

    MODIFY gt_data2 FROM gs_data2.

  ENDLOOP.
  APPEND LINES OF gt_data2 TO gt_data.
  SORT gt_data BY matnr.
ENDFORM.
*&---------------------------------------------------------------------*
*&      Form  BUILD_DATA
*&---------------------------------------------------------------------*
*       整理数据
*----------------------------------------------------------------------*
FORM build_data .

  TYPES:BEGIN OF gy_setheadert,
          setclass TYPE setclass,
          subclass TYPE setsubcls,
          setname  TYPE setnamenew,
          langu    TYPE spras,
          descript TYPE settext,
          kostl    TYPE kostl,
        END OF gy_setheadert.

  DATA :gt_but000     TYPE TABLE OF but000,
        gs_but000     TYPE but000,
        gt_but000_2   TYPE TABLE OF but000,
        gs_but000_2   TYPE but000,
        gt_ztask      TYPE TABLE OF ztask,
        gs_ztask      TYPE ztask,
        gt_aufk       TYPE TABLE OF aufk,
        gs_aufk       TYPE aufk,
        gt_cskt       TYPE TABLE OF cskt,
        gs_cskt       TYPE cskt,
        gt_setheadert TYPE TABLE OF gy_setheadert,
        gs_setheadert TYPE gy_setheadert.
  
ENDFORM.                    " BUILD_DATA

*&---------------------------------------------------------------------*
*&      Form  FRM_DISPLAY_ALV
*&---------------------------------------------------------------------*
*       显示alv界面
*----------------------------------------------------------------------*
FORM frm_display_alv .

* 设定报表输出样式
  PERFORM set_layout.
* 设定报表列标题格式
  PERFORM set_fieldcat.
* 输出ALV报表
  PERFORM alv_grid_display.

ENDFORM.                    " FRM_DISPLAY_ALV

*&---------------------------------------------------------------------*
*&      Form  SET_LAYOUT
*&---------------------------------------------------------------------*
*       设定报表输出样式。
*----------------------------------------------------------------------*
FORM set_layout .

* 设置Grid的字段列宽度自动适应
  gs_layout-colwidth_optimize = 'X'.
* 设置Grid的行颜色变换显示
  gs_layout-zebra  = 'X'.
* 置弹出窗口的标题栏
  gs_layout-detail_titlebar = TEXT-t16.
* 设置Grid的多行选择列,其中BOX必须为内表的一列,为一个字符长度
*  gs_layout-box_fieldname = 'SEL'.
* 设置Grid是否显示行分割线
*  gs_layout-no_vline = 'X'.
* 设置Grid是否显示列分隔线
*  gs_layout-no_hline = 'X'.
* 设置Grid的没有标题
*  gs_layout-no_colhead = ' '.
* 设置Grid不显示弹出明细显示窗口
* gs_layout-detail_popup = 'X'.
* 行颜色字段设置
*  gs_layout-info_fieldname = 'ROWCOLOR'.

ENDFORM.                    " SET_LAYOUT

*&---------------------------------------------------------------------*
*&      Form  SET_FIELDCAT
*&---------------------------------------------------------------------*
*       设定报表列标题格式
*----------------------------------------------------------------------*
FORM set_fieldcat .
* 列标题设定
  col_pos = 0.
  fieldcat_macro matnr    '物料号'                      '' '' '' '' '10'  'X' 'L'.
  fieldcat_macro maktx    '物料描述'                    '' '' '' '' '6'   'X' 'L'.
*  fieldcat_macro mfrnr    '生产商'                     '' '' '' '' '12'  'X' 'L'.
*  fieldcat_macro bu_sort1    '生产商名称'                     '' '' '' '' '12'  'X' 'L'.
  fieldcat_macro mftxt    '生产商名称'                     '' '' '' '' '12'  'X' 'L'.
  fieldcat_macro mfrpn    '生产商货号'                    '' '' '' '' '10'   '' 'L'.
  fieldcat_macro groes     '规格'                     '' '' '' '' '12'  'X' 'L'.
*  fieldcat_macro zeinr     '成品出库短描述'                     '' '' '' '' '12'  'X' 'L'.
*  fieldcat_macro msbookpartno     '包装规格'                     '' '' '' '' '12'  'X' 'L'.
  fieldcat_macro charg    '批次号'                        '' '' '' '' '15'  ''  'L'.
  fieldcat_macro licha    '供应商批次'                      '' '' '' '' '20'  ''  'L'.
  fieldcat_macro lgort    '库存地点'                      '' '' '' '' '15'  ''  'L'.
  fieldcat_macro lgobe    '库存地点描述'                      '' '' '' '' '15'  ''  'L'.
  fieldcat_macro hsdat    '生产日期'                       '' '' '' '' '10'  ''  'L'.
  fieldcat_macro vfdat    '有效至'                       '' '' '' '' '10'  ''  'L'.
  fieldcat_macro meins    '单位'                      '' '' '' '' '10'  ''  'L'.
  fieldcat_macro cspem    '冻结库存'                     '' '' '' '' '10'  ''  'L'.
  fieldcat_macro clabs    '非限制库存'                     '' '' '' '' '10'  ''  'L'.
  fieldcat_macro cinsm '质检库存'                 '' '' '' '' '10'  ''  'L'.
  fieldcat_macro ceinm   '限制库存'                        '' '' '' '' '10'   ''  'L'.
  fieldcat_macro budat    '最后移动日期'                       '' '' '' '' '10'  ''  'L'.
  fieldcat_macro zzkts    '天数'                       '' '' '' '' '10'  ''  'L'.


ENDFORM.                    " SET_FIELDCAT

*&---------------------------------------------------------------------*
*&      Form  ALV_GRID_DISPLAY
*&---------------------------------------------------------------------*  ,
*       输出ALV报表
*----------------------------------------------------------------------*
FORM alv_grid_display .

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program       = sy-repid
      i_callback_pf_status_set = 'SET_PF_STATUS'
      i_callback_user_command  = 'USER_COMMAND'
*      add by CUDK905767
*     i_callback_html_end_of_list = 'HTML_END_OF_LIST'
*     i_background_id          = 'ALV_BACKGROUND'
*      end by CUDK905767
      is_layout                = gs_layout  "设定报表输出样式
      it_fieldcat              = gt_fieldcat[]
      i_default                = 'X'
      i_save                   = 'A'  "设定是否可以保存报表布局
    TABLES
      t_outtab                 = gt_data
    EXCEPTIONS
      program_error            = 1
      OTHERS                   = 2.

ENDFORM.                    " ALV_GRID_DISPLAY

*&---------------------------------------------------------------------*
*&      Form  SET_PF_STATUS
*&---------------------------------------------------------------------*
*       定义用户自定义的屏幕菜单。
*----------------------------------------------------------------------*
FORM set_pf_status USING im_extab TYPE slis_t_extab.

  DATA: l_count TYPE char5.
  DATA: l_fcode TYPE TABLE OF sy-ucomm.

  DESCRIBE TABLE gt_data LINES l_count.
*  SET TITLEBAR 'TITLE' WITH l_count.

  SET PF-STATUS 'SET_PF_STATUS'.

ENDFORM.                    "SET_PF_STATUS

*&---------------------------------------------------------------------*
*&      Form  USER_COMMAND
*&---------------------------------------------------------------------*
*       响应菜单项及相应事件。
*----------------------------------------------------------------------*
FORM user_command USING   im_ucomm TYPE sy-ucomm
                        im_filecat TYPE slis_selfield.

  PERFORM alv_check_value.

  CASE im_ucomm .
    WHEN  '&F03' OR  'EXIT'.
      LEAVE TO SCREEN 0.
    WHEN 'CANCEL'.
    WHEN OTHERS.
  ENDCASE.

ENDFORM.                    "user_command

FORM html_end_of_list USING document TYPE REF TO cl_dd_document.
  DATA: text TYPE sdydo_text_element.

  CLEAR res_intime.

  CALL METHOD document->add_gap
    EXPORTING
      width = 0.     " 空格.

  CLEAR text.
  text = '机器完成总数: '.
  CALL METHOD document->add_text
    EXPORTING
      text         = text
      sap_emphasis = 'Strong'
    .   " Style: HEADING;KEY;

  CALL METHOD document->new_line. "换行


ENDFORM.                    "html_end_of_list
*&---------------------------------------------------------------------*
*&      Form  ALV_CHECK_VALUE
*&---------------------------------------------------------------------*
*       获取改变后的值
*----------------------------------------------------------------------*
FORM alv_check_value.

  IF galv_grid IS INITIAL.
    CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
      IMPORTING
        e_grid = galv_grid.
  ENDIF.

  IF NOT galv_grid IS INITIAL.
    CALL METHOD galv_grid->check_changed_data.
  ENDIF.

ENDFORM.                    " ALV_CHECK_VALUE

*&---------------------------------------------------------------------*
*&      Form  ALV_REJUST_LAYOUT_WIDTH
*&---------------------------------------------------------------------*
*       重新调整列宽
*----------------------------------------------------------------------*
FORM alv_rejust_layout_width.
  DATA: lv_layout TYPE lvc_s_layo.
  IF galv_grid IS INITIAL.
    CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
      IMPORTING
        e_grid = galv_grid.
  ENDIF.
  IF NOT galv_grid IS INITIAL.
    CALL METHOD galv_grid->get_frontend_layout
      IMPORTING
        es_layout = lv_layout.
    lv_layout-cwidth_opt = 'X'. " 设置Grid的字段列宽度自动适应
    CALL METHOD galv_grid->set_frontend_layout
      EXPORTING
        is_layout = lv_layout.
  ENDIF.
ENDFORM.                    " ALV_REJUST_LAYOUT_WIDTH
*&---------------------------------------------------------------------*
*& Form frm_get_text
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*&      --> GS_DATA_MATNR
*&      --> GS_DATA_CHARG
*&      <-- GS_DATA_TEXT
*&---------------------------------------------------------------------*
FORM frm_get_text  USING    p_matnr
                            p_charg
                   CHANGING p_text.
  DATA: lv_name TYPE thead-tdname,
        lt_line TYPE TABLE OF tline WITH HEADER LINE.
  FREE :lt_line[] .
  CLEAR lv_name.

  lv_name+0(18) = p_matnr.
  lv_name+044(10) = p_charg.

  CALL FUNCTION 'READ_TEXT'
    EXPORTING
      id                      = 'VERM'
      language                = sy-langu
      name                    = lv_name
      object                  = 'CHARGE'
    TABLES
      lines                   = lt_line[]
    EXCEPTIONS
      id                      = 1
      language                = 2
      name                    = 3
      not_found               = 4
      object                  = 5
      reference_check         = 6
      wrong_access_to_archive = 7
      OTHERS                  = 8.

  LOOP AT lt_line.
    p_text = | { p_text } { lt_line-tdline } |.
  ENDLOOP.
  SHIFT p_text LEFT DELETING LEADING ' '.
ENDFORM.

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

数据代理实践

1&#xff0c;什么事数据代理机制&#xff1f; 通过访问 代理对象的属性 来向该访问 目标对象的属性 数据代理机制的视线需要依靠&#xff0c;Object.defineProperty()方法 2&#xff0c; ES6新特性&#xff1a; 在对象中的函数/方法 &#xff1a;function是可以省略的 &l…

P2-AI产品经理-九五小庞

项目要怎么做 需求&#xff0c;技术&#xff0c;构建流程&#xff0c;算法 要懂&#xff0c;懂什么&#xff1f; 懂产品方案&#xff0c;包含&#xff1a; 不懂&#xff0c;会遇到哪些问题&#xff1f; 跟算法供应商沟通的专业度不足&#xff0c;容易被边缘化&#xff0c;…

手写数字识别(机器学习)

一&#xff1a;一对多分类方法(one-vs-all) 这里先上的代码&#xff0c;想看原理可以到代码下面。 在数据集中&#xff0c;y的取值为1~10&#xff0c;y10表示当前数字为0 首先读取数据,并对数据进行切分。 import pandas as pd import numpy as np import matplotlibmatplo…

美摄科技企业级视频拍摄与编辑SDK解决方案

在数字化浪潮汹涌的今天&#xff0c;视频已成为企业传递信息、塑造品牌、连接用户不可或缺的强大媒介。为了帮助企业轻松驾驭这一视觉盛宴的制作过程&#xff0c;美摄科技凭借其在影视级非编技术领域的深厚积累&#xff0c;推出了面向企业的专业视频拍摄与编辑SDK解决方案&…

Linux磁盘扩容lvm

目录 Linux磁盘管理基础知识介绍 1.确认分区类型 2.添加新硬盘 3.给新硬盘添加分区 &#xff08;2&#xff09;指定分区类型 4.创建物理卷 5.创建卷组 6.扩展逻辑卷 7.刷新文件系统 &#xff08;1&#xff09;查看文件系统 xfs文件系统使用&#xff08;centos&#…

RocketMQ集群搭建,看完这篇文章你就懂了(基于2m-2s-async模式)

前言 上一篇初步认识了RocketMQ&#xff0c;这一篇文章我们简单来搭建一个RocketMQ集群。RocketMQ支持多种集群部署模式&#xff0c;其中最常用的是多主多从的异步复制模式&#xff08;2m代表两个master&#xff0c;2s代表两个slave&#xff0c;async代表异步刷盘的机制&#…

数据结构 - AVL树

文章目录 一、AVL树的介绍二、AVL树的实现1、基本框架2、查找3、插入4、删除5、测试6、总代码 三、AVL树的性能 一、AVL树的介绍 1、概念 AVL树&#xff08;Adelson-Velsky and Landis Tree&#xff09;是一种自平衡的二叉搜索树。它得名于其发明者G. M. Adelson-Velsky和E. M…

广东工程职业技术学院财经学院领导一行莅临泰迪智能科技参观交流

7月19日&#xff0c;广东工程职业技术学院财经学院市场调查与统计分析专业主任苏志鹏、专业老师余乐莅临广东泰迪智能科技股份有限公司产教融合实训基地参观交流。泰迪智能科技董事长张良均、副总经理施兴、高校业务部经理孙学镂、校企合作经理吴桂锋进行接待。 仪式伊始&#…

保持形态真实性的大脑生成建模| 文献速递-基于人工智能(AI base)的医学影像研究与疾病诊断

Title 题目 Realistic morphology-preserving generative modelling of the brain 保持形态真实性的大脑生成建模 01 文献速递介绍 医学影像研究通常受到数据稀缺和可用性的限制。治理、隐私问题和获取成本都限制了医学影像数据的访问&#xff0c;加上深度学习算法对数据的…

苍穹外卖(一)之环境搭建篇

Ngnix启动一闪而退 启动之前需要确保ngnix.exe的目录中没有中文字体&#xff0c;在conf目录下的nginx.conf文件查看ngnix的端口号&#xff0c;一般默认为80&#xff0c;若80端口被占用就会出现闪退现象。我们可以通过logs/error.log查看错误信息&#xff0c;错误信息如下&…

k8s+containerd(kvm版)

k8s&#xff08;Kubernetes&#xff09;是由Gogle开源的容器编排引擎&#xff0c;可以用来管理容器化的应用程序和服务&#xff0c;k 高可用&#xff1a;系统在长时间内持续正常地运行&#xff0c;并不会因为某一个组件或者服务的故障而导致整个系统不可用可扩展性&#xff1a…

freesql简单使用操作mysql数据库

参考&#xff1a;freesql中文官网指南 | FreeSql 官方文档 这两天准备做一个测试程序&#xff0c;往一个系统的数据表插入一批模拟设备数据&#xff0c;然后还要模拟设备终端发送数据包&#xff0c;看看系统的承压能力。 因为系统使用的第三方框架中用到了freesql&#xff0c…

【数据结构】包装类、初识泛型

&#x1f387;&#x1f389;&#x1f389;&#x1f389;点进来你就是我的人了 博主主页&#xff1a;&#x1f648;&#x1f648;&#x1f648;戳一戳&#xff0c;欢迎大佬指点&#xff01; 人生格言: 当你的才华撑不起你的野心的时候,你就应该静下心来学习! 欢迎志同道合的朋友…

在windows上使用Docker部署一个简易的web程序

使用Docker部署一个python的web服务&#x1f680; 由于是从事算法相关工作&#xff0c;之前在项目中&#xff0c;需要将写完的代码服务&#xff0c;部署在docker上&#xff0c;以此是开始接触了Docker这个工具&#xff0c;由于之前也没系统学习过&#xff0c;之后应该可能还会用…

[240724] Meta 发布全新大语言模型 Llama 3.1 | Apple 开源全新 AI 模型,打造高效 AI 生态

目录 Meta 发布全新发语言模型 Llama 3.1Apple 开源全新 AI 模型&#xff0c;挑战 Meta&#xff0c;打造高效 AI 生态 Meta 发布全新发语言模型 Llama 3.1 Llama 3.1 提供 8B、70B 和 405B 三种参数规模&#xff0c;其中 405B 版本在通用知识、可控性、数学、工具使用和多语 言…

Python鲁汶意外莱顿复杂图拓扑分解算法

&#x1f3af;要点 &#x1f3af;算法池化和最佳分区搜索&#xff1a;&#x1f58a;网格搜索 | &#x1f58a;发现算法池 | &#x1f58a;返回指定图的最佳划分 | &#x1f58a;返回指定图的最佳分区 | &#x1f3af;适应度和聚类比较功能&#xff1a;&#x1f58a;图的划分 |…

django电商用户消费数据分析系统-计算机毕业设计源码20891

摘 要 随着电子商务的快速发展&#xff0c;电商平台积累了大量的用户消费数据。为了更好地理解用户行为、优化商品结构和提升用户体验&#xff0c;本文设计并实现了一个基于Django框架的电商用户消费数据分析系统。 该系统包含后台首页、系统用户&#xff08;管理员&#xf…

探索 GPT-4o mini:成本效益与创新的双重驱动

&#x1f49d;&#x1f49d;&#x1f49d;欢迎来到我的博客&#xff0c;很高兴能够在这里和您见面&#xff01;希望您在这里可以感受到一份轻松愉快的氛围&#xff0c;不仅可以获得有趣的内容和知识&#xff0c;也可以畅所欲言、分享您的想法和见解。 推荐:kwan 的首页,持续学…

elk日志索引被锁blocks,日志无法写入

现象&#xff1a; kafka积压&#xff0c;logstash无法将日志写入到es logstash报错&#xff1a; [logstash.outputs.elasticsearch][main][] Retrying failed action {:status>403 :error>{“type”>“cluster_block_exception”, “reason”>“index [] blocked …

“微软蓝屏”全球宕机,敲响基础软件自主可控警钟

上周五&#xff0c;“微软蓝屏”“感谢微软 喜提假期”等词条冲上热搜&#xff0c;全球百万打工人受此影响&#xff0c;共同见证这一历史性事件。据微软方面发布消息称&#xff0c;旗下Microsoft 365系列服务出现访问中断。随后在全球范围内&#xff0c;包括企业、政府、个人在…