当前位置:网站首页>ALV report learning summary
ALV report learning summary
2022-08-02 22:39:00 【Desolate Moon】
*------------------------初始定义
report zalvtest022
type-pools:slis.
tables: ekko,ekpo,eket,mara. "此处的tablesDefines options used in selection screens
*-----------------------Statement of fixed relevant variables
data: lt_fieldcat type slis_t_fieldcat_alv, "存储fieldcat的内表
wa_fieldcat type slis_fieldcat_alv, "定义工作区
gs_layout type slis_layout_alv, "alv格式控制的结构体:layout
*----------------------定义内表结构
types:begin of ty_alvshow, "We define the structure of the custom inner table asTY_alvshow
vbeln type ekkn-vbeln, "销售订单号
erfmg type mseg-erfmg, "入库数量
budat type mkpf-budat, "入库日期
eindt type eket-eindt, "采购交期
ebeln type ekko-ebeln, "采购订单号
ebelp type ekpo-ebelp, "行项目号
matnr type mara-matnr, "零件号
txz01 type ekpo-txz01, "零件描述
meins type ekpo-meins, "订单单位
bukrs type ekko-bukrs, "公司
werks type ekpo-werks, "工厂
ekorg type ekko-ekorg, "采购组织
ekgrp type ekko-ekgrp, "采购组
submi type ekko-submi, "汇总号
matkl type ekpo-matkl, "物料组
bedat type ekko-bedat, "下单日期
vbeln1 type ekkn-vbeln, "Sales order number line item
bstnk type vbak-bstnk, "客户参考号
kunnr type vbak-kunnr, "客户代号
kvgr2 type vbak-kvgr2, "品牌
edatu type vbep-edatu, "销售订单评审交期
bsart type ekko-bsart, "凭证类型
lifnr type ekko-lifnr, "供应商代码
vbelp type ekkn-vbelp, "Sales order number remarks
jyrq type qave-vdatum, “Although this data we do not need to show,But in the query process use,So write it in
qinspst type mseg-qinspst, “同上
vdatum type qave-vdatum, “同上
end of ty_alvshow.
*-------------定义内表和工作区
data:
gt_ty_alvshow type table of ty_alvshow,
gs_ty_alvshow type ty_alvshow.
*------------定义ALV格式控制-选择界面(也可以称为laout参数控制),Used to define the filter interface before entering the form------
select-options:
s_werks for ekpo-werks obligatory, "工厂 obligatory Defined as non-nullable
s_matkl for ekpo-matkl, “物料组
s_labor for mara_labor, "实验室
s_lifnr for ekko-lifnr, "供应商
s_eindt for eket-eindt obligatory. "Purchase order delivery date
start-of-selection. "data form data selection
perform get_data. "获取数据 "将封装好的get_data在这里调用
end-of-selection.
perform call_alv. "展示 "将封装好的call_alv在这里调用
&---------------------------------------------------------------------
*& Form F_SET_FIELDCAT
&---------------------------------------------------------------------
*& 创建一个名为F_SET_FIELDCAT的子例程
&---------------------------------------------------------------------
*& --> p1 text
*& <-- p2 text
&---------------------------------------------------------------------
form f_set_fieldcat.
clear wa_fieldcat. "Clear the workspace(可去掉,The purpose is to prevent the not clear the contents of the interference)
refresh lt_fieldcat. "Refresh the contents of the inner table
define alv_append_field. "宏定义
wa_fieldcat-fieldname = &1 . "定义wa_fieldcat(工作区)的fieldname属性,放在第一个位置
wa_fieldcat-seltext_l = &2. "定义wa_fieldcat(工作区)的seltext_l(备注)属性,放在第二个位置
APPEND wa_fieldcat TO lt_fieldcat " Move these external displays from the workspace into the internal table
CLEAR wa_fieldcat.
end-of-definition.
alv_append_field: "in the already definedalv_append_fieldIn writing within the content of the table
‘VBELN’ ‘销售订单号’, "由于我们将fieldname放在第一个位置,Notes are placed in the second position,so write
‘ERFMG’ ‘入库数量’,
‘BUDAT’ ‘入库日期’,
‘EINDT’ ‘采购交期’,
‘EBELN’ ‘采购订单号’,
‘EBELP’ ‘行项目号’,
‘MATNR’ ‘零件号’,
‘TXZ01’ ‘零件描述’,
‘MEINS’ ‘订单单位’,
‘BUKRS’ ‘公司’,
‘WERKS’ ‘工厂’,
‘EKORG’ ‘采购组织’,
‘EKGRP’ ‘采购组’,
‘SUBMI’ ‘汇总号’,
‘BEDAT’ ‘物料组’,
‘MATKL’ ‘下单日期’,
‘BSTNK’ ‘客户参考号’,
‘KUNNR’ ‘客户代号’,
‘KVGR2’ ‘品牌’,
‘EDATU’ ‘销售订单评审交期’,
‘BSTNK’ ‘凭证类型’,
‘LIFNR’ ‘供应商代码’,
‘VBELP’ ‘Sales order number remarks’,
‘JYRQ’ ‘检验日期’.
endform.
&---------------------------------------------------------------------
*& Form GET_DATA
&---------------------------------------------------------------------
*& 定义了GET_DATAThis subroutine
&---------------------------------------------------------------------
*& --> p1 text
*& <-- p2 text
&---------------------------------------------------------------------
from get_data.
‘’编写sqlstatement to get data
"步骤,先编写from语句,Abbreviation of various tables that need to be used,Then each time a table is abbreviated, the attributes in this table are added,Then various tables are concatenated through the association relationship,即可完成,(At the same time, pay attention to the use of inner joinsor左连接,For example, when we left table joins right table,The attributes on the right may be absent if possible,应该使用左连接)
from mseg as a
inner join mkpf as b on a~mblnr = b~mblnr and a~mjahr = b~mjahr
inner join ekpo as c on c~ebeln = a~ebeln and c~ebelp = a~ebelp
inner join eket as d on d~ebeln = c~ebeln and d~ebelp = c~ebelp and d~etenr = '0001'
inner join ekko as e on e~ebeln = c~ebeln
left join ekkn as f on f~ebeln = c~ebeln and f~ebelp = c~ebelp
left join vbap as g on f~vbeln = g~vbeln and f~vbelp = g~posnr
left join vbak as h on h~vbeln = g~vbeln
left join vbep as i on i~vbeln = g~vbeln and i~posnr = g~posnr and i~etenr = '0001'
left join qals as j on a~mblnr = j~mblnr and a~mjahr = j~mjahr and a~zeile = j~zeile
inner join mara as l on a~matnr = l~matnr
left join qave as k on j~prueflos = k~prueflos
where c~werks in @s_werks and c~matkl in @s_matkl *whereAttention should be paid to writing is to choose the interface part,Is the table before into the interface
and l~labor in @s_labor and e~lifnr in @s_lifnr
and d~eindt in @s_eindt and a~qinspst in ('','4','1') "并且whereConditional filtering is also possible
into corresponding fields of table @gt_ty_alvshow. "取出所有的字段对应放入内表中的字段
loop at gt_ty_alvshow into gs_ty_alvshow. ‘’Loop on the condition that the contents of the inner table enter the work area each time
IF gs_ty_alvshow-qinspst = ‘’ OR gs_ty_alvshow-qinspst = ‘4’ . " 如果gs_ty_alvshow中的qinspstAttribute is equal to or empty4
gs_ty_alvshow-JYRQ = gs_ty_alvshow-budat.
gs_ty_alvshow-JYRQ = gs_ty_alvshow-budat.
ELSEIF gs_ty_alvshow-qinspst = ‘1’.
gs_ty_alvshow-JYRQ = gs_ty_alvshow-vdatum.
ENDIF.
MODIFY gt_ty_alvshow FROM gs_ty_alvshow.
ENDLOOP.
endform.
&---------------------------------------------------------------------
*& Form F_CALL_ALV
&---------------------------------------------------------------------
*& 创建了一个名为F_CALL_ALV的子例程
&---------------------------------------------------------------------
*& --> p1 text
*& <-- p2 text
&---------------------------------------------------------------------
form f_call_alv .
call function ‘REUSE_ALV_GRID_DISPLAY’
exporting
i_callback_program = sy-repid "当前程序名
i_callback_pf_status_set = 'PF_STATUS_SET' "触发事件调用子程序
tablesi_callback_user_command = 'USER_COMMAND' "鼠标事件操作子程序 is_layout = gs_layout "输出样式 it_fieldcat = lt_fieldcat "字段定义描述表 i_default = 'X' i_save = 'A' "i_save有4个可选值,其中A代表(缺省默认和特定用户都可以)
t_outtab = gt_ty_alvshow "inner table used
exceptions
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.
边栏推荐
- Geoserver+mysql+openlayers2
- 分享一个 web 应用版本监测 (更新) 的工具库
- 脑机接口003 | 马斯克称已实现与云端的虚拟自己对话,相关概念股份大涨
- ALV报表学习总结
- Electron User Guide Beginning Experience
- Introduction of uncommon interfaces of openlayers
- 【软件工程导论】软件工程导论笔记
- golang刷leetcode动态规划(11)不同路径
- Parse the commonly used methods in the List interface that are overridden by subclasses
- Geoserver+mysql+openlayers
猜你喜欢
TPAMI2022 | TransCL: based on the study the compression of the Transformer, more flexible and more powerful
ECCV 2022 | 通往数据高效的Transformer目标检测器
扫码预约 | 观看Apache Linkis数据处理实践以及计算治理能力
2022-07-27
A Review of Nature Microbiology: Focusing on the Algae--Ecological Interface of Phytoplankton-Bacteria Interactions
如何ES源码中添加一个自己的API 流程梳理
ShapeableImageView 的使用,告别shape、三方库
openlayers版本更新差别
Redis集群配置
溜不溜是个问题
随机推荐
健康报告-设计与实现
遇上Mysql亿级优化,怎么办
元宇宙001 | 情绪无法自控?元宇宙助你一臂之力
Silver circ: letter with material life insurance products should be by the insurance company is responsible for the management
openlayers version update difference
Fetch 请求不转换BLOB正常显示GBK编码的数据
【软件工程导论】软件工程导论笔记
姑姑:给小学生出点口算题
【Psychology · Characters】Issue 1
Office2021 安装MathType
实战:10 种实现延迟任务的方法,附代码!
入职对接-hm项目
Geoserver+mysql+openlayers2
Electron使用指南之初体验
分享一个 web 应用版本监测 (更新) 的工具库
Metaverse 001 | Can't control your emotions?The Metaverse is here to help you
我用这一招让团队的开发效率提升了 100%!
AI Scientist: Automatically discover hidden state variables of physical systems
J9 digital theory: the Internet across chain bridge has what effect?
Shell: conditional statements