当前位置:网站首页>Simplest ALV template
Simplest ALV template
2022-06-12 20:39:00 【Square wood 2021】
*&---------------------------------------------------------------------*
*& Report ZMMU100
*&---------------------------------------------------------------------*
*& System : Program name
*& Module : MM
*& Program ID : ZMMU100
*& Author : john
*& Date : 20210616
*& Description : Program Introduction
*&---------------------------------------------------------------------*
*& Modify the record :
*& Edition date Modifier
*& NO** YYYY/MM/DD XXX
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
REPORT zmmu100.
TABLES:zmmt021.
TYPE-POOLS:slis.
DATA:mail_ret TYPE zsappo_ret_info.
DATA:gt_fieldcat TYPE STANDARD TABLE OF lvc_s_fcat.
DATA:gs_fieldcat LIKE LINE OF gt_fieldcat.
DATA:gt_events TYPE slis_t_event.
DATA:gt_repid TYPE sy-repid.
*DATA:GS_EVENTS LIKE LINE OF GT_EVENTS.
DATA:gs_layout TYPE lvc_s_layo.
*DATA:GS_LAYOUT LIKE LINE OF GT_LAYOUT.
DATA:chat_input TYPE zmsg01.
DATA:BEGIN OF gt_data OCCURS 0,
ebeln TYPE zmmt021-ebeln,
status TYPE zmmt021-status,
zdate TYPE zmmt021-zdate,
ztime TYPE zmmt021-ztime,
ernam TYPE ekko-ernam,
msg TYPE string,
END OF gt_data.
DATA:t_tab TYPE zmms005_t,
is_req TYPE zsappo_req_info,
is_input TYPE zmms006,
es_ret TYPE zsappo_ret_info,
chat_RET TYPE zsappo_ret_info.
SELECTION-SCREEN BEGIN OF BLOCK col WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: s_ebeln FOR zmmt021-ebeln .
SELECT-OPTIONS: s_STATUS FOR zmmt021-status DEFAULT 'N'.
SELECT-OPTIONS: s_ZDATE FOR zmmt021-zdate.
SELECT-OPTIONS: s_ZTIME FOR zmmt021-ztime.
SELECTION-SCREEN END OF BLOCK col.
DEFINE fill_field.
CLEAR gs_fieldcat.
gs_fieldcat-fieldname = &1. "ALV control : Field name of internal table field
gs_fieldcat-scrtext_l = &2. " Long field label
gs_fieldcat-no_zero = &3. "ALV control : Hide zero for output
gs_fieldcat-ref_table = &4. " Refer to table
gs_fieldcat-ref_field = &5. " Reference field
APPEND gs_fieldcat TO gt_fieldcat.
END-OF-DEFINITION.
START-OF-SELECTION. " The sequence in which the program occurs
PERFORM frm_get_data. " Count
PERFORM frm_process_data. " Processing data
PERFORM frm_set_layout. "LAYOUT Parameter setting
PERFORM frm_set_fieldcat. " Set up FIELDCAT Parameters
PERFORM frm_top_of_page. "TOP_OF_PAGE Parameter setting
END-OF-SELECTION.
*&---------------------------------------------------------------------*
*& Form frm_get_data
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM frm_get_data .
DATA:lt_return LIKE TABLE OF bapireturn WITH HEADER LINE.
CLEAR:lt_return[].
DATA ls_zmmt021 TYPE zmmt021.
SELECT DISTINCT a~ebeln,a~status,a~zdate,a~ztime,b~ernam
INTO TABLE @DATA(lt_ebeln)
FROM zmmt021 AS a
INNER JOIN ekko AS b ON b~ebeln = a~ebeln
AND b~frgke = 'Z'
AND b~ihrez <> 'X'
WHERE a~ebeln IN @s_ebeln
AND a~status IN @s_status
AND a~zdate IN @s_zdate
AND a~ztime IN @s_ztime.
LOOP AT lt_ebeln ASSIGNING FIELD-SYMBOL(<fs>).
MOVE-CORRESPONDING <fs> TO gt_data. " Field auto match
MOVE-CORRESPONDING <fs> TO ls_zmmt021. " Field auto match
APPEND gt_data.
ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form frm_process_data
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM frm_process_data .
ENDFORM.
*&---------------------------------------------------------------------*
*& Form frm_set_layout
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM frm_set_layout .
gs_layout-zebra = 'X'.
gs_layout-cwidth_opt = 'X'.
gs_layout-detailinit = 'X'.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form frm_set_fieldcat
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM frm_set_fieldcat .
REFRESH gt_fieldcat.
fill_field:'EBELN' ' Purchase order ' 'X' 'EKKO' 'EBELN',
'STATUS' ' state ' 'X' '' '',
'ZDATE' ' date ' 'X' '' '',
'ZTIME' ' Time ' 'X' '' '',
'ERNAM' ' Purchaser ' 'X' '' '',
'MSG' ' news ' 'X' '' ''.
gt_repid = sy-repid.
SORT gt_data BY ebeln.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = gt_repid
* i_callback_user_command = 'USER_COMMAND' " Double-click the event
i_callback_top_of_page = 'FRM_TOP_OF_PAGE' " Header
is_layout_lvc = gs_layout
it_fieldcat_lvc = gt_fieldcat[]
i_save = 'A'
it_events = gt_events
TABLES
t_outtab = gt_data[]
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form frm_top_of_page
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM frm_top_of_page .
DATA:gt_header TYPE slis_t_listheader,
wa_header TYPE slis_listheader,
t_line LIKE wa_header-info,
ld_lines TYPE i,
ld_linesc(10) TYPE c.
"TITLE title
wa_header-typ = 'H'. " The font of the title
wa_header-info = ' Manually push purchase orders to OA System records '.
APPEND wa_header TO gt_header.
CLEAR:wa_header.
"DATE Tabulated date
wa_header-typ = 'S'. " Font of tabulation date
wa_header-key = 'DATE:'. " Date title
CONCATENATE sy-datum(4)'.'
sy-datum+4(2)'.'" From 4 Character truncation 2 position
sy-datum+6(2)
INTO wa_header-info. "TODAY DATE
APPEND wa_header TO gt_header.
CLEAR:wa_header.
"TOTAL NO.OF RECORDS SELECTED
DESCRIBE TABLE gt_data LINES ld_lines.
ld_linesc = ld_lines.
CONCATENATE 'TOTAL NO.OF RECORDS SELECTED:' ld_linesc " Convert to text format
INTO t_line SEPARATED BY space.
wa_header-typ = 'A'. "A In italics
wa_header-info = t_line.
APPEND wa_header TO gt_header.
CLEAR:wa_header,
t_line.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE' " Control the output of header data
EXPORTING
it_list_commentary = gt_header. " Header parameters
ENDFORM.
边栏推荐
- Illustrator tutorial, how to recolor artwork in illustrator?
- Go -- monitor file changes
- [leetcode 7 solution] integer inversion
- 牛客網:三數之和
- SAP QM preliminary - cannot assign a sampling policy to an inspection characteristic when maintaining an inspection plan by executing transaction code qp02?
- Lightroom Ambassador series: capturing nostalgia with MEG loeks
- 初步了解认识正则表达式(Regex)
- 检测当前系统语言
- Troubleshooting of service port failure
- Wechat applet notes
猜你喜欢

A simple understanding of consistent hash

WordPress optimization tutorial makes WordPress open faster

Why my order by create_ Time ASC becomes order by ASC

A Zhu and Xu Baobao's high-rise game - difference

Installation of xv6 system

Typescript definition type: type 'timeout' cannot be assigned to type 'number';

Listener in JSP

Detailed explanation of search tree and hash table

Fcpx tutorial, how to export video graphics and text in Final Cut Pro?

同时做测试,别人已经年薪20w起,为什么你还在为达到月薪10k而努力?
随机推荐
Let Google browser fofa plug-in come alive
中小型机房动力环境综合监控解决方案
Algorinote_2_主定理与 Akra-Bazzi 定理
P5076 [deep base 16. Example 7] common binary tree (simplified version)
Proxy and reflection
Nexus3 build local warehouse
EDI 855 purchase order confirmation
The required books for software testers (with e-books) recommended by senior Ali have benefited me a lot
SAP WM preliminary transaction code lx29 - list of fixed storage bins
Generate API documents using swagger (go language example)
使用Swagger生成 API 文档(go语言示例)
How to determine the sample size of an inspection lot in SAP QM's initial sampling strategy?
Fcpx tutorial, how to export video graphics and text in Final Cut Pro?
P5076 【深基16.例7】普通二叉樹(簡化版)
2022年春招,测试工程师全套面试攻略,一篇吃透全部技术栈(全是干货)
标量、向量、数组和矩阵
Foreign brands become a thing of the past? What are the key words of the TV industry in 2022?
Maximize tensorflow* CPU performance (shell)
Halcon angle and radian interchange
WordPress optimization tutorial makes WordPress open faster