当前位置:网站首页>ABAP ALV LVC模板
ABAP ALV LVC模板
2022-07-07 22:22:00 【Seele_1018】
模板包含选择屏幕、ALV、菜单栏事件、打印程序内容
********************************************************************
* 事务代码: *
* 程序名称:ZDEMO_SEELE01 *
* 使用变式: *
* 设 计 人:SEELE *
* 设计时间: *
* 程序类型: REPORT *
* 应用类型: MM *
* 描 述: *
*(修改日志)--------------------------------------------------------*
* *
* 日志号 修改人 修改时间 修改说明 *
* ---- ------ ------ ----------- *
* 001 SEELE 创建报表 *
********************************************************************
REPORT zdemo_seele01.
*------------------------------------------------------------------------*
* 声明选择屏幕、图标等用到的表和类型池
*------------------------------------------------------------------------*
TYPE-POOLS: slis.
TABLES: ekko,sscrfields.
*-----------------------------------------------------------------------*
* 声明自定义的数据类型
*-----------------------------------------------------------------------*
TYPES: BEGIN OF ty_alv,
ebeln TYPE ekko~ebeln,
bukrs TYPE ekko~bukrs,
butxt TYPE t001~butxt,
bstyp TYPE ekko~bstyp,
sel TYPE c,
END OF ty_alv.
*------------------------------------------------------------------------*
* 声明ALV显示过程中用到的数据对象
*------------------------------------------------------------------------*
DATA: gt_fieldcat TYPE lvc_t_fcat,
gs_fieldcat TYPE lvc_s_fcat,
gs_layout TYPE lvc_s_layo.
*ALV回调函数
CONSTANTS: gc_callback_satus TYPE slis_formname VALUE 'FRM_USER_STATUS', " 设置自定义菜单栏常量
gc_callback_user_command TYPE slis_formname VALUE 'FRM_USER_COMMAND'. " 设置自定义菜单按钮事件
* ALV报表
DATA: gs_alv TYPE ty_alv,
gt_alv TYPE TABLE OF ty_alv.
* Smartforms
DATA: tmp_control_parameters TYPE ssfctrlop,
fm_name TYPE rs38l_fnam.
*-----------------------------------------------------------------------*
* INITIALIZATION
*-----------------------------------------------------------------------*
INITIALIZATION.
* 选择屏幕
SELECTION-SCREEN BEGIN OF BLOCK blk WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS s_matnr FOR zqmt_qylist-matnr.
SELECTION-SCREEN END OF BLOCK blk.
* ALV格式初始化
PERFORM layout_init.
PERFORM fieldcat_init_all.
*-----------------------------------------------------------------------*
* START-OF-SELECTION
*-----------------------------------------------------------------------*
START-OF-SELECTION.
*获取数据
PERFORM frm_get_data.
*-----------------------------------------------------------------------*
* END-OF-SELECTION
*-----------------------------------------------------------------------*
END-OF-SELECTION.
* 展示ALV
PERFORM frm_display_alv.
*-----------------------------------------------------------------------*
* FORM子例程区
*-----------------------------------------------------------------------*
* 获取数据
FORM frm_get_data.
ENDFORM.
* 设置layout
FORM frm_set_layout. "SET LAYOUT
gs_layout-cwidth_opt = 'X'. "设置为最适合的布局
gs_layout-zebra = 'X'. "斑马线
gs_layout-sel_mode = 'A'. "选择模式
gs_layout-box_fname = 'SEL'. "选择字段
ENDFORM.
* 设置field
FORM frm_field. "USE FIELD
REFRESH: gt_fieldcat.
CLEAR: gs_fieldcat.
PERFORM frm_set_field USING 0 'XUHAO' TEXT-a01 '' 'X' '' 'C' '' '' '' '' '' ''.
PERFORM frm_set_field USING 1 'EQUNR' TEXT-a02 '' 'X' '' 'C' '' '' '' 'EQUNR' 'EQUI' ''.
PERFORM frm_set_field USING 2 'EQKTX' TEXT-a03 '' '' '' 'C' '' '' '' 'EQKTX' 'EQKT' ''.
PERFORM frm_set_field USING 3 'EQTYP' TEXT-a04 '' '' '' 'C' '' '' '' 'EQTYP' 'EQUI' ''.
PERFORM frm_set_field USING 4 'SWERK' TEXT-a06 '' '' '' 'C' '' '' '' 'SWERK' 'ILOA' ''.
PERFORM frm_set_field USING 5 'TYPBZ' TEXT-a07 '' '' '' 'C' '' '' '' 'TYPBZ' 'EQUI' ''.
PERFORM frm_set_field USING 6 'TXT30' TEXT-a08 '' '' '' 'C' '' '' '' 'TXT30' 'TJ30T' ''.
ENDFORM.
FORM frm_set_field USING i_col_pos TYPE any "SET FIELD
i_fieldname TYPE any
i_coltext TYPE any
i_qfieldname TYPE any
i_key TYPE any
i_checkbox TYPE any
i_just TYPE any
i_emphasize TYPE any
i_datatype TYPE any
i_inttype TYPE any
i_ref_field TYPE any
i_ref_table TYPE any
i_edit TYPE any.
gs_fieldcat-col_pos = i_col_pos.
gs_fieldcat-fieldname = i_fieldname.
gs_fieldcat-coltext = i_coltext.
gs_fieldcat-qfieldname = i_qfieldname.
gs_fieldcat-key = i_key.
gs_fieldcat-checkbox = i_checkbox.
gs_fieldcat-just = i_just.
gs_fieldcat-emphasize = i_emphasize.
gs_fieldcat-datatype = i_datatype.
gs_fieldcat-inttype = i_inttype.
gs_fieldcat-ref_field = i_ref_field.
gs_fieldcat-ref_table = i_ref_table.
gs_fieldcat-edit = i_edit.
APPEND gs_fieldcat TO gt_fieldcat.
CLEAR gs_fieldcat.
ENDFORM.
FORM frm_display_alv.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = sy-repid
i_callback_pf_status_set = 'FRM_USER_STATUS'
i_callback_user_command = 'FRM_USER_COMMAND'
* it_events = gv_events
is_layout_lvc = gs_layout
it_fieldcat_lvc = gt_fieldcat
i_save = 'A'
TABLES
t_outtab = gt_data
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM.
FORM frm_user_status USING pt_extab TYPE slis_t_extab. "GUI
SET PF-STATUS 'STATUS_1000' EXCLUDING pt_extab.
ENDFORM.
FORM frm_user_command USING i_ucomm LIKE sy-ucomm "user_command
i_selfield TYPE slis_selfield.
DATA: lo_grid TYPE REF TO cl_gui_alv_grid.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = lo_grid.
CALL METHOD lo_grid->check_changed_data. "将更新后的数据传到alv所对应的内表
i_selfield-refresh = 'X'. "刷新数据
CASE i_ucomm.
WHEN 'PRINT'.
READ TABLE gt_data INTO gs_data WITH KEY sel = 'X'. "CHECK SEL
IF sy-subrc NE 0.
MESSAGE s003(zpm01) DISPLAY LIKE 'E'.
RETURN.
ELSE.
CLEAR:gs_tab,gt_tab.
LOOP AT gt_data INTO gs_data WHERE sel = 'X'.
MOVE-CORRESPONDING gs_data TO gs_tab.
APPEND gs_tab TO gt_tab.
ENDLOOP.
PERFORM frm_print.
ENDIF.
ENDCASE.
ENDFORM.
FORM frm_print.
DATA: ls_control_parameters TYPE ssfctrlop,
ls_output_options TYPE ssfcompop,
ls_outopt TYPE ssfcresop,
ls_output_info TYPE ssfcrescl.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'ZPMF_WORKORDER01'
IMPORTING
fm_name = lv_name01
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL FUNCTION 'SSF_OPEN'
EXPORTING
control_parameters = ls_control_parameters
output_options = ls_output_options
IMPORTING
job_output_options = ls_outopt
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
RETURN.
ENDIF.
ls_control_parameters-no_open = 'X'.
ls_control_parameters-no_close = 'X'.
LOOP AT gt_sel INTO gw_alv.
CALL FUNCTION ls_pm-sfname
EXPORTING
control_parameters = ls_control_parameters
output_options = ls_output_options
gs_head = ls_pm
IMPORTING
job_output_info = ls_output_info
TABLES
gt_item = lt_pmi
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDLOOP.
CALL FUNCTION 'SSF_CLOSE'
IMPORTING
job_output_info = ls_output_info
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM.
边栏推荐
- Reptile practice (VIII): reptile expression pack
- 3年经验,面试测试岗20K都拿不到了吗?这么坑?
- redis你到底懂不懂之list
- Daily question brushing record (16)
- 【编程题】【Scratch二级】2019.09 制作蝙蝠冲关游戏
- Su embedded training - Day3
- LinkedBlockingQueue源码分析-新增和删除
- Tencent security released the white paper on BOT Management | interpreting BOT attacks and exploring ways to protect
- Introduction to programming hardware
- 单机高并发模型设计
猜你喜欢
全自动化处理每月缺卡数据,输出缺卡人员信息
paddle一个由三个卷积层组成的网络完成cifar10数据集的图像分类任务
What if the testing process is not perfect and the development is not active?
[研发人员必备]paddle 如何制作自己的数据集,并显示。
Introduction to programming hardware
An error is reported during the process of setting up ADG. Rman-03009 ora-03113
RPA云电脑,让RPA开箱即用算力无限?
【测试面试题】页面很卡的原因分析及解决方案
【推荐系统基础】正负样本采样和构造
The standby database has been delayed. Check that the MRP is wait_ for_ Log, apply after restarting MRP_ Log but wait again later_ for_ log
随机推荐
80%的人答错,苹果logo上的叶子到底朝左还是朝右?
STM32F1與STM32CubeIDE編程實例-旋轉編碼器驅動
从Starfish OS持续对SFO的通缩消耗,长远看SFO的价值
攻防世界Web进阶区unserialize3题解
Binder核心API
Is Zhou Hongyi, 52, still young?
什么是负载均衡?DNS如何实现负载均衡?
Daily question brushing record (16)
【转载】解决conda安装pytorch过慢的问题
[programming questions] [scratch Level 2] March 2019 garbage classification
Robomaster visual tutorial (11) summary
Database query - what is the highest data?
STM32F1与STM32CubeIDE编程实例-旋转编码器驱动
如果在构造函数中抛出异常,最好的做法是防止内存泄漏?
redis你到底懂不懂之list
Opengl3.3 mouse picking up objects
Installation and configuration of sublime Text3
Use filters to count URL request time
【编程题】【Scratch二级】2019.12 绘制十个正方形
华泰证券官方网站开户安全吗?