当前位置:网站首页>ALV program collection
ALV program collection
2022-07-26 05:11:00 【Lunar Yin shortage】
*&---------------------------------------------------------------------*
*& Report ZALVTEST002
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZALVTEST002.
TYPE-POOLs:slis.
tables:vbak.
TYPES: BEGIN OF gty_alv,
vkorg TYPE vbak-vkorg , " Sales organization
vtweg TYPE vbak-vtweg , " Distribution channels
vkgrp TYPE vbak-vkgrp , " Sales group
auart TYPE vbak-auart , " Order type
erdat TYPE vbak-erdat , " Order date
vbeln TYPE vbak-vbeln , " The order number
END OF gty_alv.
data gt_vbak type table of gty_alv.
data gs_vbak type gty_alv.
DATA gt_fieldcat TYPE slis_t_fieldcat_alv.
DATA gs_fieldcat TYPE slis_fieldcat_alv.
DATA gs_layout TYPE slis_layout_alv.
* Macro definition
DEFINE %%append_fieldcat.
CLEAR gs_fieldcat.
gs_fieldcat-fieldname = &1.
gs_fieldcat-seltext_m = &2.
APPEND gs_fieldcat TO gt_fieldcat.
END-OF-DEFINITION.
SELECTION-SCREEN : BEGIN OF BLOCK vie WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS s_vbeln FOR vbak-vbeln.
* The radio
PARAMETERS: p_1 RADIOBUTTON GROUP grp1 DEFAULT 'X' .
PARAMETERS: p_2 RADIOBUTTON GROUP grp1 .
SELECTION-SCREEN:END OF BLOCK vie.
start-of-selection.
perform get_data. " Count
IF gt_vbak IS NOT INITIAL.
PERFORM show_data. " Display the data
ELSE.
MESSAGE s000 WITH ' No data '.
FORM get_data . " Count
IF p_1 = 'X'.
SELECT
vkorg " Sales organization
vtweg " Distribution channels
vkgrp " Sales group
auart " Order type
erdat " Order date
vbeln " The order number
FROM vbak
INTO CORRESPONDING FIELDS OF TABLE gt_vbak
WHERE vbeln IN s_vbeln.
ELSE.
MESSAGE s000 WITH ' no '.
ENDIF.
ENDFORM.
FORM show_data . " Display the data
PERFORM bulid_fieldcat. " Field shows
PERFORM build_alv. "alv Show
PERFORM bulid_layout. "layout Show
ENDFORM.
FORM build_alv .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = sy-repid
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
* I_GRID_TITLE =
* I_GRID_SETTINGS =
is_layout = gs_layout
it_fieldcat = gt_fieldcat
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* I_HTML_HEIGHT_TOP = 0
* I_HTML_HEIGHT_END = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* IR_SALV_FULLSCREEN_ADAPTER =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = gt_vbak
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDFORM.
FORM bulid_fieldcat .
%%append_fieldcat:
'vkorg' ' Sales organization ',
'vtweg' ' Distribution channels ',
'vkgrp' ' Sales group ',
'auart' ' Order type ',
'erdat' ' Order date ',
'vbeln' ' The order number '.
ENDFORM.
FORM bulid_layout .
gs_layout-colwidth_optimize = 'X'.
gs_layout-zebra = 'X'.
ENDFORM.
*&---------------------------------------------------------------------*
*& Report ZALVTEST003
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZALVTEST003." The reporter declares
TYPE-POOLS:slis." Call the type pool existing in the system
* Calling ALV Before , You need to define Layout and Fieldcat, They belong to slis Type pool
DATA:fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
layout TYPE slis_layout_alv,
w_repid TYPE sy-repid." Record the current program name of the system
TABLES:bkpf.
DATA:lbkpf LIKE STANDARD TABLE OF bkpf WITH HEADER LINE." Internal table in standard table format lbkpf
SELECTION-SCREEN BEGIN OF BLOCK blk WITH FRAME TITLE t0." Define the screen
SELECT-OPTIONS:s_bukrs FOR bkpf-bukrs OBLIGATORY," Condition input box , One for Corresponding to one
s_belnr FOR bkpf-belnr,"for The front is the name of the field , You can modify , But be careful not to exceed 8 Characters , Otherwise, an error will be reported
s_gjahr FOR bkpf-gjahr.
SELECTION-SCREEN END OF BLOCK blk.
START-OF-SELECTION.
* Call subroutine
PERFORM getdata.
PERFORM catalog.
PERFORM alvshow.
* Define subroutine
FORM getdata." Query statement
SELECT *
FROM bkpf INTO CORRESPONDING FIELDS OF TABLE lbkpf
WHERE bukrs IN s_bukrs
AND belnr IN s_belnr
AND gjahr IN s_gjahr.
ENDFORM.
FORM catalog." Header
w_repid = sy-repid.
CLEAR fieldcat.
DEFINE fieldcatset." Macro definition
fieldcat-just = 'C'." The field is centered
fieldcat-outputlen = 10." Length of custom field
fieldcat-ref_tabname = 'BKPF'." Call the data structure of the transparent table
fieldcat-fieldname = &1." Transparent table field name
fieldcat-seltext_l = &2."ALV Name
fieldcat-col_pos = &3." Column position
APPEND fieldcat.
END-OF-DEFINITION.
fieldcatset 'BUKRS' ' Company code ' sy-tabix.
fieldcatset 'gjahr' ' Fiscal year ' sy-tabix.
fieldcatset 'BUKRS' ' Accounting period ' sy-tabix.
fieldcatset 'BELNR' ' Voucher No ' sy-tabix.
fieldcatset 'BLART' ' Voucher type ' sy-tabix.
fieldcatset 'BLDAT' ' Certificate date ' sy-tabix.
fieldcatset 'BUDAT' ' Posting date ' sy-tabix.
fieldcatset 'XSTOV' ' Reversal mark ' sy-tabix.
fieldcatset 'STBLG' ' Reversal voucher ' sy-tabix.
fieldcatset 'PPNAM' ' Prepared by ' sy-tabix.
fieldcatset 'USNAM' ' Posted by ' sy-tabix.
READ TABLE fieldcat INDEX 3." Read the third column of the report
fieldcat-hotspot = 'X'." Mouse Hotspot Events
fieldcat-key = 'X'." Defined as primary key ( color changing )
MODIFY fieldcat INDEX 3." Modify the style
READ TABLE fieldcat INDEX 4.
fieldcat-HOTSPOT = 'X'.
fieldcat-emphasize = 'C500'.
MODIFY fieldcat INDEX 4.
READ TABLE fieldcat INDEX 1.
fieldcat-emphasize = 'C600'.
MODIFY fieldcat INDEX 1.
READ TABLE fieldcat INDEX 2.
fieldcat-emphasize = 'C300'.
MODIFY fieldcat INDEX 2.
READ TABLE fieldcat INDEX 5.
fieldcat-emphasize = 'C600'.
MODIFY fieldcat INDEX 5.
READ TABLE fieldcat INDEX 6.
fieldcat-emphasize = 'C600'.
MODIFY fieldcat INDEX 6.
READ TABLE fieldcat INDEX 7.
fieldcat-emphasize = 'C100'.
MODIFY fieldcat INDEX 7.
READ TABLE fieldcat INDEX 8.
fieldcat-emphasize = 'C200'.
MODIFY fieldcat INDEX 8.
READ TABLE fieldcat index 9.
fieldcat-checkbox = 'X'.
MODIFY fieldcat index 9.
*layout-colwidth_optimize = 'X'.
layout-zebra = 'X'." The style of zebra crossing
ENDFORM.
* Subroutine responding to mouse click time
FORM ALV_USER_COMMAND USING R_UCOMM LIKE SY-ucomm
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE R_UCOMM.
WHEN '&IC1'." The default value is this , It is said that you can modify the information on the Internet ~
READ TABLE lbkpf INDEX RS_SELFIELD-tabindex.
SET PARAMETER ID 'BLN' FIELD lbkpf-belnr.
CALL TRANSACTION 'FB03' AND SKIP FIRST SCREEN.
ENDCASE.
ENDFORM.
FORM FRM_SET_PF_STATUS USING PT_EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'ZHKALV1'.
ENDFORM.
FORM alvshow.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
i_callback_program = w_repid" Program name
I_CALLBACK_PF_STATUS_SET = 'FRM_SET_PF_STATUS'
I_CALLBACK_USER_COMMAND = 'ALV_USER_COMMAND'" Yes ALV Trigger the defined subroutine when operating
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
i_grid_title = ' Accounting voucher '" Title name
* I_GRID_SETTINGS =
is_layout = layout" Defined by the program layout name
it_fieldcat = fieldcat[]" Definition fieldcat data
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* I_HTML_HEIGHT_TOP = 0
* I_HTML_HEIGHT_END = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* IR_SALV_FULLSCREEN_ADAPTER =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = lbkpf
EXCEPTIONS" The following are the default
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM.

边栏推荐
- BigDecimal 的 4 个坑,你踩过几个?
- Meta analysis [whole process, uncertainty analysis] method based on R language and meta machine learning
- DOM事件流 事件冒泡-事件捕获-事件委托
- 安装NCCL\mpirun\horovod\nvidia-tensorflow(3090Ti)
- Redis过期删除策略和内存淘汰策略
- Redis solves the problem of oversold inventory
- JVM Lecture 6: how to solve the frequent FGC in online environment?
- 阿里三面:MQ 消息丢失、重复、积压问题,如何解决?
- Full analysis of domain name resolution process means better text understanding
- The importance of supporting horizontal expansion of time series database
猜你喜欢

测试必备工具之Fiddler,你真的了解吗?
![[pytorch] install torch 1.8.1 and check whether torch version and GPU are available](/img/97/078c72729a29675939a84895b5ab86.png)
[pytorch] install torch 1.8.1 and check whether torch version and GPU are available

Security permission management details

C语言函数

Google Emoji guessing game helps parents guide their children to surf the Internet safely

Nacos introduction and deployment

5个chrome简单实用的日常开发功能详解,赶快解锁让你提升更多效率!

Excel VBA:按日期汇总计算输出结果(sumif)

第二讲 初识SLAM

【ACWing】2983. 玩具
随机推荐
JVM第二讲:类加载机制
Excel VBA: realize automatic drop-down filling formula to the last line
SAP报表开发步骤
List转换为tree-项目真实使用
webassembly 01基本资料
DOM事件流 事件冒泡-事件捕获-事件委托
Excel VBA:按日期汇总计算输出结果(sumif)
Nacos 介绍和部署
Common solutions for distributed ID - take one
Test of countlaunch demo
Meta analysis [whole process, uncertainty analysis] method based on R language and meta machine learning
Map making of environmental impact assessment based on remote sensing interpretation and GIS technology
When AQS wakes up the thread, I understand why it traverses from the back to the front
AXI协议(5):AXI协议的burst机制
Go-Excelize API源码阅读(六)—— DeleteSheet(sheet string)
Redis solves the problem of oversold inventory
List converted to tree real use of the project
Date and time function of MySQL function summary
测试必备工具之Fiddler,你真的了解吗?
一次线上事故,我顿悟了异步的精髓