当前位置:网站首页>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.
边栏推荐
- 日志框架学习
- 【Psychology · Characters】Issue 1
- Flutter with internationalized adapter automatically generated
- 汇编实例解析--利用tcb,tss,全局tss,ldt管理任务实现任务切换
- 线程池原理与实践|从入门到放弃,深度解析
- 治疗 | 如何识别和处理消极想法
- 一款好用的FAQ搭建工具
- Parse the commonly used methods in the List interface that are overridden by subclasses
- [AnXun cup 2019] easy_web
- The so-called fighting skill again gao also afraid of the chopper - partition, depots, table, and the merits of the distributed
猜你喜欢
LeetCode:622. 设计循环队列【模拟循环队列】
What is a Field Service Management System (FSM)?what is the benefit?
4 kmiles join YiSheng group, with more strong ability of digital business, accelerate China's cross-border electricity full domain full growth
Leetcode刷题——字符串相加相关题目(415. 字符串相加、面试题 02.05. 链表求和、2. 两数相加)
【软件工程导论】软件工程导论笔记
动态规划常见实例详解
Detailed explanation of common examples of dynamic programming
openlayers不常用接口介绍
PG's SQL execution plan
Mysql安装流程 【压缩版】
随机推荐
Kali命令ifconfig报错command not found
MaxCompute 近期发布上线的版本的 SQL 引擎新功能参数化视图有什么优势?
Compose主题切换——让你的APP也能一键换肤
J9数字货币论:识别Web3新的稀缺性:开源开发者
遇上Mysql亿级优化,怎么办
Parse common methods in the Collection interface that are overridden by subclasses
什么是现场服务管理系统(FSM)?有什么好处?
Three.js入门
服务器Centos7 静默安装Oracle Database 12.2
MaxCompute 的SQL 引擎参数化视图具体有哪些增强功能?
MOSN 反向通道详解
软件测试分类
LeetCode - 105. 从前序与中序遍历序列构造二叉树;023.合并K个升序链表
SQL Server数据类型转换函数cast()和convert()详解
竞赛:糖尿病遗传风险检测挑战赛(科大讯飞)
ALV概念讲解
SQL Server安装教程
golang刷leetcode动态规划(11)不同路径
Cannot find declaration to go to
Brain-computer interface 003 | Musk said that he has realized a virtual self-dialogue with the cloud, and related concept shares have risen sharply