当前位置:网站首页>The first ABAP ALV reporter construction process
The first ABAP ALV reporter construction process
2022-07-26 18:37:00 【Lunar Yin shortage】
REPORT ZALVTEST006.
First step : Statement ALV Related variables
They are definitions ALV The type pool to be used :TYPE-POOLS:SLIS
in the light of ALV Control information data (Layout&Fieldcat)
TYPE-POOLS:slis.
DATA: lt_fieldcat TYPE slis_t_fieldcat_alv, " Storage fieldcat Inner table of
wa_fieldcat TYPE slis_fieldcat_alv, " Define workspace
ls_layout TYPE slis_layout_alv. "ALV Structure of format control :layout
Generally, it is named xx_fieldcat Such a variable to reference slis_t_fieldcat, As control information data for storing internal tables
Similarly, it will be named xx_fieldcat Such a variable to reference slis_fieldcat, As the control information data used to define the workspace
Below xx_layout So it is with
The second step : Define the inner table
When there is such a table in our dictionary VBAK( Sales voucher : Header data sheet , yes SAP My watch )
After we check this table , It is found that such data
namely
VBELN Sales voucher
ERDAT Record creation date
ERNAM Name of orderer
KUNNER Seller
They all belong to VBAK This table
And the same thing VBAP This table ( Sales voucher : Project data , For the same SAP Bring their own )
ZMENG Target number of sales units
ZIEME Target quantity UOM
So we define inner table like this
TYPE:BEGIN OF TY_ALVSHOW ‘’ALVSHOW Is the name of the structure of the inner table defined by ourselves
VBELN TYPE VBAK-VBELN,
ERDAT TYPE VBAK-ERDAT,
ERNAM TYPE VBAK-ERNAM,
KUNNR TYPE VBAK-KUNNR,
POSNR TYPE VBAP-POSNR,
MATNR TYPE VBAP-POSNR,
MATKL TYPE VBAP-MATKL,
ZMENG TYPE VBAP-ZMENG,
ZIEME TYPE VBAP-ZIEME,
WERKS TYPE VBAP-WERKS,
LGORT TYPE VBAP-LGORT.
END OF TY_ALVSHOW.
DATA: LT_ALVSHOW TYPE TABLE OF TY_ALVSHOW. “ Define the name of the related inner table as LT_ALVSHOW, Its structure refers to the structure defined above ”
WA_ALVSHOW TYPE TY_ALVSHOW. " Define workspace WA_ALVSHOW
The third step : Reading data
Because you need to read two tables , We need to connect to read , And generally we read through inner connection .
SELECT
VBELN ERDAT ERNAM KUNNR POSNRMATNR
MATKL ZMENG ZIEME WERKS LGORT
FROM VBAK as a INNER as b
on a~vbeln = b~vbeln
into TABLE LT_ALVSHOW
UP TO 100 ROWS.
Step four : ALV Format control ( In fact, that is layout Parameter control )
* The name of the format control information we named is ls_layout
ls_layout-zebra = ‘X’. “ stay ABAP Many times in the X Express ‘ yes ‘ It means
ls_layout-detail-popup = ‘X’. " Whether to pop up the detailed information serial port
layout
ETA Represents the function code of double clicking , Is constant
SE11
Then input VBAK, Click to display , You can find this table .
&---------------------------------------------------------------------
*& Report ZALVTEST006
&---------------------------------------------------------------------
*&
&---------------------------------------------------------------------
REPORT ZALVTEST006.
First step : Statement ALV Related variables
TYPE-POOLS:slis.
DATA: lt_fieldcat TYPE slis_t_fieldcat_alv, " Storage fieldcat Inner table of
wa_fieldcat TYPE slis_fieldcat_alv, " Define workspace
ls_layout TYPE slis_layout_alv. "ALV Structure of format control :layout
The second step : Define the inner table
TYPES: BEGIN OF TY_ALVSHOW,
VBELN TYPE VBAK-VBELN,
ERDAT TYPE VBAK-ERDAT,
ERNAM TYPE VBAK-ERNAM,
KUNNR TYPE VBAK-KUNNR,
POSNR TYPE VBAP-POSNR,
MATHR TYPE VBAP-MATNR,
MATKL TYPE VBAP-MATKL,
ZMENG TYPE VBAP-ZMENG,
ZIEME TYPE VBAP-ZIEME,
WERKS TYPE VBAP-WERKS,
LGORT TYPE VBAP-LGORT,
END OF TY_ALVSHOW.
Define the name of the related inner table as LT_ALVSHOW, Its structure refers to the structure at the beginning of our uninstallDATA: lt_alvshow TYPE TABLE OF TY_ALVSHOW,
LS_alvshow TYPE TY_ALVSHOW.Define workspace wa_alvshowThe third step : Reading data
SELECT
VBELN ERDAT ERNAME KUNNR POSNRMATNR
MATKL ZMENG ZIEME WERKS LGORT
FROM VBAK as a INNER JOIN vbap as b
on a~vbeln = b~vbeln
into TABLE LT_ALVSHOW
UP TO 100 ROWS.
Step four :ALV Format control
ls_layout-zebra = ‘X’.
ls_layout-detail_popup = ‘X’.
ls_layout-detail_titlebar = ‘X’.
ls_layout-f2code = ‘X’.
ls_layout-colwidth_optimize = ‘X’.
"fieldcat
* Sales voucher
lv_colpos = 1.
ls_fieldcat-fieldname = ‘VBELN’.
ls_fieldcat-col_pos = lv_colpos.
ls_fieldcat-key = ‘X’.
ls_fieldcat-datatype = ‘CHAR’.
ls_fieldcat-outputlen = ‘10’.
ls_fieldcat-seltext_m = ‘ Sales voucher ’.
APPEND ls_fieldcat TO lt_fieldcat.
* Certificate date
lv_colpos = lv_colpos + 1 .
ls_fieldcat-fieldname = ‘ERDAT’.
ls_fieldcat-col_pos = lv_colpos.
ls_fieldcat-key = ‘X’.
ls_fieldcat-datatype = ‘CHAR’.
ls_fieldcat-outputlen = ‘10’.
ls_fieldcat-seltext_m = ‘ Sales date ’.
APPEND ls_fieldcat TO lt_fieldcat.
* Creation time
lv_colpos = lv_colpos + 1 .
ls_fieldcat-fieldname = ‘ERNAME’.
ls_fieldcat-col_pos = lv_colpos.
ls_fieldcat-key = ‘X’.
ls_fieldcat-datatype = ‘CHAR’.
ls_fieldcat-outputlen = ‘10’.
ls_fieldcat-seltext_m = ‘ Creation time ’.
APPEND ls_fieldcat TO lt_fieldcat.
* founder
lv_colpos = lv_colpos + 1 .
ls_fieldcat-fieldname = ‘ERNAM’.
ls_fieldcat-col_pos = lv_colpos.
ls_fieldcat-key = ‘X’.
ls_fieldcat-datatype = ‘CHAR’.
ls_fieldcat-outputlen = ‘12’.
ls_fieldcat-seltext_m = ‘ Salesman ’.
APPEND ls_fieldcat TO lt_fieldcat.
* Seller
lv_colpos = lv_colpos + 1 .
ls_fieldcat-fieldname = ‘kunnr’.
ls_fieldcat-col_pos = lv_colpos.
ls_fieldcat-key = ‘X’.
ls_fieldcat-datatype = ‘CHAR’.
ls_fieldcat-outputlen = ‘10’.
ls_fieldcat-seltext_m = ‘ Seller ’.
APPEND ls_fieldcat TO lt_fieldcat.
* Project code
lv_colpos = lv_colpos + 1 .
ls_fieldcat-fieldname = ‘POSNR’.
ls_fieldcat-col_pos = lv_colpos.
ls_fieldcat-key = ‘X’.
ls_fieldcat-datatype = ‘NUMC’.
ls_fieldcat-outputlen = ‘6’.
ls_fieldcat-seltext_m = ‘ Project code ’.
APPEND ls_fieldcat TO lt_fieldcat.
* materiel
lv_colpos = lv_colpos + 1 .
ls_fieldcat-fieldname = ‘MATNR’.
ls_fieldcat-col_pos = lv_colpos.
ls_fieldcat-key = ‘X’.
ls_fieldcat-datatype = ‘CHAR’.
ls_fieldcat-outputlen = ‘18’.
ls_fieldcat-seltext_m = ‘ materiel ’.
APPEND ls_fieldcat TO lt_fieldcat.
* Item group
lv_colpos = lv_colpos + 1 .
ls_fieldcat-fieldname = ‘MATKL’.
ls_fieldcat-col_pos = lv_colpos.
ls_fieldcat-key = ‘X’.
ls_fieldcat-datatype = ‘CHAR’.
ls_fieldcat-outputlen = ‘9’.
ls_fieldcat-seltext_m = ‘ Item group ’.
APPEND ls_fieldcat TO lt_fieldcat.
* Number
lv_colpos = lv_colpos + 1 .
ls_fieldcat-fieldname = ‘ZMENG’.
ls_fieldcat-col_pos = lv_colpos.
ls_fieldcat-key = ‘X’.
ls_fieldcat-datatype = ‘QUAN’.
ls_fieldcat-outputlen = ‘13’.
ls_fieldcat-seltext_m = ‘ Number ’.
APPEND ls_fieldcat TO lt_fieldcat.
* Company
lv_colpos = lv_colpos + 1 .
ls_fieldcat-fieldname = ‘ZIEME’.
ls_fieldcat-col_pos = lv_colpos.
ls_fieldcat-key = ‘X’.
ls_fieldcat-datatype = ‘CUNIT’.
ls_fieldcat-outputlen = ‘3’.
ls_fieldcat-seltext_m = ‘ Company ’.
APPEND ls_fieldcat TO lt_fieldcat.
* factory
lv_colpos = lv_colpos + 1 .
ls_fieldcat-fieldname = ‘werks’.
ls_fieldcat-col_pos = lv_colpos.
ls_fieldcat-ref_tabname = ‘VBAP’.
APPEND ls_fieldcat TO lt_fieldcat.
* stock
lv_colpos = lv_colpos + 1 .
ls_fieldcat-fieldname = ‘LOGORT’.
ls_fieldcat-col_pos = lv_colpos.
ls_fieldcat-ref_tabname = ‘VBAP’.
APPEND ls_fieldcat TO lt_fieldcat.
Step five : Defining events ( Omit )
Step six : Show ALV
CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
EXPORTINGI_INTERFACE_CHECK = ’ ’
I_BYPASSING_BUFFER = ’ ’
I_BUFFER_ACTIVE = ’ ’
I_CALLBACK_PROGRAM = ’ ’
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 = LS_LAYOUT
IT_FIELDCAT = LT_FIELDCATIT_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 = LT_ALVSHOW
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.Implement suitable error handling here
ENDIF.
边栏推荐
- [kitex source code interpretation] service discovery
- Linked list - reverse linked list
- The first day of Oracle (review and sort out the common knowledge points of development)
- 钉钉第三方服务商应用ISV应用开发及上架教程
- 任正非首度揭秘:华为差点100亿美元“卖身”摩托罗拉背后的故事!
- 链表-合并两个排序的列表
- PS_ 1_ Know the main interface_ New document (resolution)_ Open save (sequence animation)
- Maximum sum of continuous subarray of sword finger offer (2)
- Ten year structure five year life-06 impulse to leave
- 更安全、更健康、无续航焦虑,魏牌拿铁DHT-PHEV来了
猜你喜欢

Vector CANape - How to Send Receive CAN Message in CANape

MySQL 遇到过死锁问题吗,你是如何解决的?

剑指offer 连续子数组的最大和(二)

Redis master-slave replication, read-write separation, sentinel mode

数据仓库:详解维度建模之事实表

Are you suitable for automated testing?

成为测试/开发程序员,小张:现实就来了个下马威......

NFT数字藏品系统开发:上线即售罄,网民“秒杀”数字藏品

更安全、更健康、无续航焦虑,魏牌拿铁DHT-PHEV来了

复现gallerycms字符长度限制短域名绕过
随机推荐
Privacy computing basic component series - confusion circuit
同步时现实密码不匹配
Leetcode 50 day question brushing plan (day 2 - the longest substring without repeated characters 10.00-12.00)
[a little knowledge] thread pool
隐私计算基础组件系列-混淆电路
MPLS实验
LeetCode_ 1005_ Maximized array sum after K negations
14. Gradient detection, random initialization, neural network Summary
剑指offer 跳台阶扩展问题
If the recommendation effect is not satisfactory, it's better to try to learn the propeller chart
Become a test / development programmer, Xiao Zhang: reality is coming
第一个ABAP ALV报表程序构建流程
PS_2_图层
Are you suitable for automated testing?
NFT数字藏品开发:数字藏品助力企业发展
更安全、更健康、无续航焦虑,魏牌拿铁DHT-PHEV来了
Nailing third-party service provider application ISV application development and listing tutorial
mpc5744p的pit报错, RTOS无法启动, 时钟源问题
Netease game R & D Engineer Intern (client side)
Continue to work hard on your skills, and the more you learn, the more you will learn