ITPub博客

首页 > 应用开发 > IT综合 > 抓取报表ALV GRID上的数据

抓取报表ALV GRID上的数据

IT综合 作者:woshimaojian 时间:2015-03-16 17:02:13 0 删除 编辑

在很多开发情况下,我们需要处理sap标准报表程序跑出的数据,很多人会想到内存的处理方法,但是得到的格式不如人意,在google了几天后终于找到了个例子,以下是本人实例中的相关部分。

types:begin of ty_mb5td,
matnr type ekpo-matnr, “Article
werks type ekpo-werks, “Site
mb5td_calc_trame type mb5td-mb5td_calc_trame,“Calculated Stock in Transit on Date
meins type mara-meins, “Base Unit of Measure
end of ty_mb5td.
data:t_mb5td type table of ty_mb5td,
gw_mb5td type ty_mb5td.

*内表定义的字段要跟ALV structure里的一致。

*&———————————————————————*
*& Form. GET_DATA
*&———————————————————————*
* text
*———————————————————————-*
* –> p1 text
* <– p2 text
*———————————————————————-*
form. get_data.

data:ls_data type ref to data.
field-symbols: type table,
type data.
cl_salv_bs_runtime_info=>set(
display = abap_false
metadata = abap_false
data = abap_true ).

submit rm07mtrb_date ”Tcode MB5TD
with bukrs in s_bukrs
with reswk eq p_werks
with pa_budat eq p_budat
with xtram eq ”
and return.

try.
cl_salv_bs_runtime_info=>get_data_ref(
importing r_data = ls_data ).
assign ls_data->* to .
catch cx_salv_bs_sc_runtime_info.
message ‘Unable to retrieve ALV data’ type ‘E’.
endtry.

cl_salv_bs_runtime_info=>clear_all( ).

loop at assigning .
move-corresponding to gw_mb5td.
append gw_mb5td to t_mb5td.
endloop.
sort t_mb5td.

endform. “ GET_DATA

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/25054673/viewspace-1461777/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2011-08-02

  • 博文量
    4
  • 访问量
    10457