ABAP ALV使用经验Word下载.docx

上传人:b****2 文档编号:831930 上传时间:2023-04-29 格式:DOCX 页数:32 大小:151.89KB
下载 相关 举报
ABAP ALV使用经验Word下载.docx_第1页
第1页 / 共32页
ABAP ALV使用经验Word下载.docx_第2页
第2页 / 共32页
ABAP ALV使用经验Word下载.docx_第3页
第3页 / 共32页
ABAP ALV使用经验Word下载.docx_第4页
第4页 / 共32页
ABAP ALV使用经验Word下载.docx_第5页
第5页 / 共32页
ABAP ALV使用经验Word下载.docx_第6页
第6页 / 共32页
ABAP ALV使用经验Word下载.docx_第7页
第7页 / 共32页
ABAP ALV使用经验Word下载.docx_第8页
第8页 / 共32页
ABAP ALV使用经验Word下载.docx_第9页
第9页 / 共32页
ABAP ALV使用经验Word下载.docx_第10页
第10页 / 共32页
ABAP ALV使用经验Word下载.docx_第11页
第11页 / 共32页
ABAP ALV使用经验Word下载.docx_第12页
第12页 / 共32页
ABAP ALV使用经验Word下载.docx_第13页
第13页 / 共32页
ABAP ALV使用经验Word下载.docx_第14页
第14页 / 共32页
ABAP ALV使用经验Word下载.docx_第15页
第15页 / 共32页
ABAP ALV使用经验Word下载.docx_第16页
第16页 / 共32页
ABAP ALV使用经验Word下载.docx_第17页
第17页 / 共32页
ABAP ALV使用经验Word下载.docx_第18页
第18页 / 共32页
ABAP ALV使用经验Word下载.docx_第19页
第19页 / 共32页
ABAP ALV使用经验Word下载.docx_第20页
第20页 / 共32页
亲,该文档总共32页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

ABAP ALV使用经验Word下载.docx

《ABAP ALV使用经验Word下载.docx》由会员分享,可在线阅读,更多相关《ABAP ALV使用经验Word下载.docx(32页珍藏版)》请在冰点文库上搜索。

ABAP ALV使用经验Word下载.docx

本地文件,将当前表单存储到本地机器上,有几种供选择的存储格式。

邮件收件人,给系统内用户发邮件

图形,点击它可以根据表单情况绘制相关图表。

更改布局,点击它可以对表单中的列项目排列次序的互换,删减等。

选择布局,从已经保存的布局中选择自己满意的布局。

保存布局,对于自己满意的布局,可以通过点击它来将布局保存起来。

2.表单标题区

这个区域主要是用来显示一些抬头信息(总揽信息),类似于WORD中的页眉。

我们在使用的时候根据需要来进行相关填写。

3.表单显示区

这个区域主要是用来显示我们通过代码筛选出来的数据,相关的操作在下面的程序编写部分详细介绍。

三、程序的编写

1.在我们写ALV程序的时候,有一个类型组是肯定要用到的:

TYPE-POOLS:

SLIS。

在这个类型组中有很多ALV的自定义数据类型以及结构化数据类型(通过TYPE来定义的),我们在写ALV表单的时候需要调用的。

我们常用的几个有(蓝色部分):

I.对一个最简单的ALV表单(无标题区和页脚区),我们只需要定义下面几个

data:

i_fieldcat_alvtypeslis_t_fieldcat_alvwithheaderline,

i_layouttypeslis_layout_alv,"

alv的格式

i_fieldcattypeslis_fieldcat_alv,

w_repidlikesy-repid.

它对应的start-of-selection中定义子函数如下:

start-of-selection.

performgetdata.“从数据库中取数据到相应内表中

performlayout_build.“用于定义ALV表单的相关格式、属性

performfields.“用来定义表单中的各个列的相关信息,比如列名等

performdisplay_data.“用来显示ALV表单

子函数定义如下:

formlayout_build.

i_layout-zebra='

X'

.

i_layout-detail_popup='

.“是否弹出详细信息窗口

w_repid=sy-repid.“程序为当前程序

i_layout-f2code='

&

ETA'

.“设置触发弹出详细信息窗口的功能码,这里是双击

i_layout-no_vline='

.“这个用来设置列间隔线

i_layout-colwidth_optimize='

.“优化列宽选项是否设置

i_layout-detail_initial_lines='

i_layout-detail_titlebar='

详细内容'

.“设置弹出窗口的标题栏

endform.

formfields.

refreshi_fieldcat_alv.

pos=1.

cleari_fieldcat.

i_fieldcat-col_pos=pos.“第几列

i_fieldcat-fieldname='

NUM'

i_fieldcat-seltext_l='

序号'

.“列名

appendi_fieldcattoi_fieldcat_alv.

pos=pos+1.

i_fieldcat-col_pos=pos.

AUFNR'

生产订单'

…………

Endform.

formdisplay_data.

callfunction'

REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program=w_repid“当前程序

i_save='

'

is_layout=i_layout“子函数layout_build填充的格式定义

it_fieldcat=i_fieldcat_alv[]“子函数fields填充的各列

tables

t_outtab=head1.“假设数据都在head1内表中

II.对一个稍微复杂一点的ALV表单(有标题区和页脚区),我们需要定义下面几个

i_fieldcat_alvtypeslis_t_fieldcat_alv,

“用来存储我们将要在表单显示区域显示出来的表单的列名,每个列名对应的字段名以及列表头其他相关属性信息的数据类型

i_fieldcattypeslis_fieldcat_alv,

i_layouttypeslis_layout_alv.“ALV的格式

i_eventstypeslis_t_event,

i_event_exittypeslis_t_event_exit,

i_list_commentstypeslis_t_listheader,“用来填充表单标题区域的数据类型

i_excludingtypeslis_t_extab.

w_variantlikedisvariant,"

显示变式结构

wx_variantlikedisvariant,

w_variant_save

(1)typec,

w_exit

(1)typec,

w_user_specific

(1)typec,

w_callback_ucommtypeslis_formname,"

字符型

w_printtypeslis_print_alv,"

类型组

w_layouttypeslis_layout_alv,"

w_html_top_of_pagetypeslis_formname,"

w_fieldcat_alvlikelineofi_fieldcat_alv,

w_excludinglikelineofi_excluding,

w_eventslikelineofi_events,

w_event_exitlikelineofi_event_exit,

w_list_commentslikelineofi_list_comments.

*===========================================================================*

initialization.

performinit_variant.“这个子函数很重要,没有它会出错

*-----------------------------------------*

它对应的start-of-selection中定义子函数如下:

start-of-selection.

performevent_build.

(这里只定义前面文档没有提到的子函数,其他同名的请参考前面)

forminit_variant.

clear:

w_variant.

w_repid=sy-repid.“当前程序

w_variant-report=w_repid.

w_variant-username=sy-uname.

w_variant_save='

A'

."

Alltypes

formevent_build.

REUSE_ALV_EVENTS_GET'

i_list_type=0

importing

et_events=i_events.

readtablei_events

withkeyname=slis_ev_top_of_page

intow_events.

ifsy-subrc=0.

move'

ALV_TOP_OF_PAGE'

tow_events-form.“将标题区数据赋值给W_EVENTS

modifyi_eventsfromw_eventsindexsy-tabix.

endif.

withkeyname=slis_ev_end_of_list

ALV_END_OF_LIST'

tow_events-form.“将页尾数据赋值给W_EVENTS

withkeyname=slis_ev_end_of_page

ALV_END_OF_PAGE'

tow_events-form.“将页脚区数据赋值给W_EVENTS

formevent_build子函数中黑体字部分对应的几个子函数,我们需要定义如下:

formalv_top_of_page.

i_list_comments[].

w_list_comments-typ='

H'

H=Header,S=Selection,A=Action供选择

w_list_comments-key='

w_list_comments-info='

XX汽车有限公司变速箱废品率报表'

appendw_list_commentstoi_list_comments.

S'

H=Header,S=Selection,A=Action

concatenate'

库位:

werks-lowintowerks_t.

w_list_comments-info=werks_t.

REUSE_ALV_COMMENTARY_WRITE'

i_logo='

ENJOYSAP_LOGO'

it_list_commentary=i_list_comments.

formalv_end_of_list.

H=Header,S=Selection,A=Action

页脚显示'

it_list_commentary=i_list_comments

i_end_of_list_grid='

formalv_end_of_page.

它的定义类似上面两个子函数的内容,这里不再赘述

formdisplay_data.

*i_background_id='

SIWB_WALLPAPER'

i_background_id='

i_callback_program=w_repid

i_callback_html_top_of_page=w_html_top_of_page

*i_structure_name='

TRDIR'

i_default='

is_variant=w_variant

is_layout=w_layout

*i_callback_user_command=w_callback_ucomm

it_fieldcat=i_fieldcat_alv

it_events=i_events

it_event_exit=i_event_exit

it_excluding=i_excluding

is_print=w_print

*i_screen_start_column=1

*i_screen_start_line=1

*i_screen_end_column=70

*i_screen_end_line=30

t_outtab=head1.

2.写一个ALV程序的基本流程(主要包括ALV相关的那部分,后面会附上一个ALV源程序的代码):

第一步:

定义将要用到的表,即TALBES定义部分,然后定义TYPE-POOLS:

SLIS.

第二步:

定义“1”中提到的这些数据类型或者内表的实体对象

第三步:

定义一些需要用到的变量

第四步:

定义自己的选择屏幕

第五步:

定义INITIALIZATION部分,在这个部分往往要指定w_repid的值,

w_repid=sy-repid。

第六步:

start-of-selection部分

用一个子函数完成对ALV表单标题区域的赋值(i_list_comments)。

用一个子函数完成自己所需要数据的抓取

用一个子函数完成要显示列表的列名行(第一行)的相关赋值(i_fieldcat_alv)以及设置

用一个子函数完成输出格式的设置(i_layout),比如双击一条记录是否弹出对话框啊?

是用哪个功能键触发等等

用一个子函数FORMDISPLAY_DATA来显示上面我们已经分别封装好的数据,需要调用两个常用的FUNCTIONMODULE:

FUNCTION'

“用来显示表单数据

“用来显示表单标题

附件:

示例程序源代码(注:

下面这个程序调用的ALV功能应该讲是比较完全的了,大家可以通过上面的学习之后,再看这个程序,应该会有所收获)

*----------------------------------------------------------------------

*Program:

ZZ_ALV_REPORT_STUB

*Author:

*Date:

*

*Purpose:

ReportusingALVfunction

*Notes:

*1)Logos&

wallpaperscanbefoundintableBDS_CONN05

*withclass=PICTURES

*2)TransactionOAERcanbeusedtocreatePICTURES.

*RuntransactionOAERwithclassname=PICTURES,Classtype=OT,

*andObjectkeywithwhatevernameyouwanttocreate.Inthe

*nextscreen,rightclickingonscreenandimport

*Revisions

*Name:

*Comments:

reportzflex004

nostandardpageheading

line-size200

line-count65

message-idzz.

*--------------------------------

*Tables

tables:

ekpo,

mara,

trdir.

*GlobalTypes

type-pools:

slis.

*GlobalInternalTables

i_list_commentstypeslis_t_listheader,

*Displaydata

beginofi_dataoccurs0,

matnrlikemara-matnr,

mtartlikemara-mtart,

endofi_data.

*GlobalVariables

w_repidlikesy-repid,"

abap程序,当前主程序

w_list_commentslikeline

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 党团工作 > 入党转正申请

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2