Chinaunix首页 | 论坛 | 博客
  • 博客访问: 126042
  • 博文数量: 60
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 0
  • 用 户 组: 普通用户
  • 注册时间: 2014-03-25 18:14
个人简介

ABAP 小店http://ymhtea.taobao.com

文章分类

全部博文(60)

分类: WINDOWS

2014-03-29 18:30:01

原文地址:ALV分类汇总一例 作者:连老

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. 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,"的格式
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

阅读(1006) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~