当前位置:网站首页>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.
边栏推荐
猜你喜欢

基于OpenGL的冰川与火鸟(光照计算模型、视景体、粒子系统)

Redis cluster configuration

MySQL安装配置教程(超级详细)

geoserver+mysql+openlayers问题点

MOSN 反向通道详解

You want the metagenomics - microbiome knowledge in all the (2022.8)

2022-07-27

Caldera(一)配置完成的虚拟机镜像及admin身份简单使用

快速掌握jmeter(一)——实现自动登录与动态变量

Parse the commonly used methods in the List interface that are overridden by subclasses
随机推荐
一些不错的博主
你想要的宏基因组-微生物组知识全在这(2022.8)
汇编实例解析--利用tcb,tss,全局tss,ldt管理任务实现任务切换
VMware虚拟机无法上网
Electron User Guide Beginning Experience
牛客题目——滑动窗口的最大值、矩阵最长递增路径、顺时针旋转矩阵、接雨水问题
golang刷leetcode 经典(10) tire树与ac自动机
Nature Microbiology综述:聚焦藻际--浮游植物和细菌互作的生态界面
MySQL安装配置教程(超级详细)
image could not be accessed on a registry to record its digest
golang刷leetcode 经典(11) 朋友圈
Mysql安装流程 【压缩版】
NC | 土壤微生物组的结构和功能揭示全球湿地N2O释放
动态规划常见实例详解
ABAP语法小复习
如何ES源码中添加一个自己的API 流程梳理
JWT学习
Translate My Wonderful | July Moli Translation Program Winners Announced
J9数字论:互联网跨链桥有什么作用呢?
E. Add Modulo 10(规律)