注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

XINBO'S SAP BLOG

你所浪费的今天,是昨天死去的人奢望的明天。你所厌恶的现在,是未来的你回不去的曾经

 
 
 

日志

 
 

ALV分类汇总一例  

2009-05-20 11:18:51|  分类: ALV |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

REPORT ztest1.

TABLES:mara,mbew.

TYPE-POOLS:slis.

TYPES:BEGIN OF t_itab,

matnr LIKE mara-matnr,

ersda LIKE mara-ersda,

matkl LIKE mara-matkl,

lbkum LIKE mbew-lbkum,

salk3 LIKE mbew-salk3,

END OF t_itab.

DATA:itab TYPE TABLE OF t_itab WITH HEADER LINE.

SELECTION-SCREEN BEGIN OF BLOCK blok WITH FRAME. TITLE txt1.

SELECT-OPTIONS:matnr FOR mara-matnr.

SELECTION-SCREEN END OF BLOCK blok.

INITIALIZATION.

txt1 = '请输入选择条件'.

START-OF-SELECTION.

END-OF-SELECTION.

PERFORM. getdata.

PERFORM. disalv.

*&---------------------------------------------------------------------*

*& Form. getdata

*&---------------------------------------------------------------------*

* text

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

* --> p1 text

* <-- p2 text

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

FORM. getdata .

SELECT

mara~matnr

mara~ersda

mara~matkl

mbew~lbkum

mbew~salk3

INTO TABLE itab

FROM mara

JOIN mbew ON ( mara~matnr = mbew~matnr AND mbew~bwkey = 'PU81')

WHERE mara~matnr IN matnr

ORDER BY mara~matnr

.

delete adjacent duplicates from itab.

ENDFORM. " getdata

*&---------------------------------------------------------------------*

*& Form. disalv

*&---------------------------------------------------------------------*

* text

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

* --> p1 text

* <-- p2 text

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

FORM. disalv .

DATA: it_fieldcat TYPE slis_t_fieldcat_alv,

is_variant LIKE disvariant,

it_events TYPE slis_t_event,

is_layout TYPE slis_layout_alv,"ALV的格式

i_list_comments TYPE slis_t_listheader,

i_callback_program TYPE sy-repid,

title TYPE lvc_title,

it_sort TYPE slis_t_sortinfo_alv

.

PERFORM. fieldcat_init USING it_fieldcat."输出列表控件表头

* PERFORM. layout_init USING is_layout.

* PERFORM. eventtab_build USING it_events.

PERFORM. e02_layout_sort_build CHANGING it_sort.

i_callback_program = sy-repid.

title = '测试'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = i_callback_program

i_grid_title = title

is_layout = is_layout

it_fieldcat = it_fieldcat

it_events = it_events

it_sort = it_sort[]

TABLES

t_outtab = itab

EXCEPTIONS

program_error = 1

OTHERS = 2.

IF sy-subrc <> 0.

ENDIF.

ENDFORM. " disalv

*&---------------------------------------------------------------------*

*& Form. fieldcat_init

*&---------------------------------------------------------------------*

* text

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

* -->P_IT_FIELDCAT text

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

FORM. fieldcat_init USING it_fieldcat TYPE slis_t_fieldcat_alv.

DATA: ls_fieldcat TYPE slis_fieldcat_alv.

ls_fieldcat-fieldname = 'MATNR'.

ls_fieldcat-reptext_ddic = '物料号'.

ls_fieldcat-no_zero = 'X'.

APPEND ls_fieldcat TO it_fieldcat.

CLEAR ls_fieldcat.

ls_fieldcat-fieldname = 'ERSDA'.

ls_fieldcat-reptext_ddic = '创建日期'.

APPEND ls_fieldcat TO it_fieldcat.

CLEAR ls_fieldcat.

ls_fieldcat-fieldname = 'MATKL'.

ls_fieldcat-reptext_ddic = '物料组'.

APPEND ls_fieldcat TO it_fieldcat.

CLEAR ls_fieldcat.

ls_fieldcat-fieldname = 'LBKUM'.

ls_fieldcat-reptext_ddic = '总评估的库存'.

ls_fieldcat-do_sum = 'X'.

APPEND ls_fieldcat TO it_fieldcat.

CLEAR ls_fieldcat.

ls_fieldcat-fieldname = 'SALK3'.

ls_fieldcat-reptext_ddic = '估价的总库存价值'.

ls_fieldcat-do_sum = 'X'.

APPEND ls_fieldcat TO it_fieldcat.

CLEAR ls_fieldcat.

ENDFORM. " fieldcat_init

*&---------------------------------------------------------------------*

*& Form. e02_layout_sort_build

*&---------------------------------------------------------------------*

* text

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

* <--P_IT_SORT text

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

FORM. e02_layout_sort_build CHANGING lt_sort TYPE slis_t_sortinfo_alv.

DATA ls_sort TYPE slis_sortinfo_alv.

*

CLEAR ls_sort.

ls_sort-fieldname = 'ERSDA'. "#EC *

ls_sort-spos = 1.

ls_sort-up = 'X'.

ls_sort-subtot = 'X'.

APPEND ls_sort TO lt_sort.

CLEAR ls_sort.

ls_sort-fieldname = 'MATKL'. "#EC *

ls_sort-spos = 1.

ls_sort-up = 'X'.

ls_sort-subtot = 'X'.

APPEND ls_sort TO lt_sort.

ENDFORM. " e02_layout_sort_build

  评论这张
 
阅读(435)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017