给定以前在 ABAP 中执行的报告的结果,如何执行报告 [英] How to execute Report given the results of a previously executed Report in ABAP

查看:18
本文介绍了给定以前在 ABAP 中执行的报告的结果,如何执行报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题如下:
我有一份名为 Y5000112 的报告.
我的同事总是用 selection screen variant V1 手动执行一次,然后用 variant V2 第二次执行它将第一次执行的结果添加到选择中.
在这种情况下,这些结果是 PERNR.

My problem is the following:
I have one report called Y5000112.
My colleagues always execute it manually once with selection screen variant V1 and then execute it a second time with variant V2 adding the results of the first execution to the selection.
Those results in this case are PERNR.

我的目标:
自动执行此操作 - 单击一次执行两次该查询,并使用第一次执行的 PERNR 结果自动填充第二次执行的 PERNR 选择.

My goal:
Automate this - execute that query twice with one click and automatically fill the PERNR selection of the second execution with the PERNR results of the first execution.

我发现了如何触发报告执行,然后是另一个,如何将它设置为某个变体并走到这一步 - 在第一个答案之后我得到了一些进一步的但我仍然不知道如何遍历我的结果并将它们放入下一个报告提交中:

I found out how to trigger a report execution and after that another one, how to set it to a certain variant and got this far - after the first answer I got a bit further but I still have no idea how to loop through my results and put them into the next Report submit:

DATA: t_list TYPE TABLE OF abaplist.
*      lt_seltab TYPE TABLE OF rsparams,
*      ls_selline LIKE LINE OF lt_seltab.

SUBMIT Y5000114
USING SELECTION-SET 'MA OPLAN TEST'
EXPORTING LIST TO MEMORY
AND RETURN.

CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
  listobject = t_list
EXCEPTIONS
  not_found = 1
  OTHERS = 2.
IF sy-subrc <> 0.
  WRITE 'Unable to get list from memory'.
ELSE.
* I want to fill ls_seltab here with all pernr (table pa0020) but I haven't got a clue how to do this
*  LOOP AT t_list.
*    WRITE /t_list.
*  ENDLOOP.

  SUBMIT Y5000114
*  WITH-SELECTION-TABLE ls_seltab
  USING SELECTION-SET 'MA OPLAN TEST2'
  AND RETURN.
ENDIF.

附言
我对 ABAP 不是很熟悉,所以如果我没有提供足够的信息,请在评论中告诉我,我会尝试找出您需要知道的任何信息来解决这个问题.

P.S.
I'm not very familiar with ABAP so if I didn't provide enough Information just let me know in the comments and I'll try to find out whatever you need to know in order to solve this.

这是我想象中的 JS 代码,可以非常概括地表达我想要完成的任务.

Here's my imaginary JS-Code that can express very generally what I'm trying to accomplish.

function submitAndReturnExport(Reportname,VariantName,OptionalPernrSelection)
{...return resultObject;}

var t_list = submitAndReturnExport("Y5000114","MA OPLAN TEST");
var pernrArr = [];
for (var i in t_list)
{
 pernrArr.push(t_list[i]["pernr"]);
}
submitAndReturnExport("Y5000114","MA OPLAN TEST2",pernrArr);

推荐答案

这并不像想象的那么容易,所以不会有任何单行代码段.
没有标准的方法来获取结果报告.尝试EXPORTING LIST TO MEMORY子句,但考虑报告可能需要调整:

It's not that easy as it supposed to, so there won't be any one-line snippet.
There is no standard way of getting results from report. Try EXPORTING LIST TO MEMORY clause, but consider that the report may need to be adapted:

提交 [report_name]
WITH SELECTION-TABLE [rspar_tab]
将列表导出到内存
然后返回.

SUBMIT [report_name]
WITH SELECTION-TABLE [rspar_tab]
EXPORTING LIST TO MEMORY
AND RETURN.

上述语句的结果应该从内存中读取并适应输出:

The result of the above statement should be read from memory and adapted for output:

call function 'LIST_FROM_MEMORY'
  TABLES
   listobject       = t_list
  EXCEPTIONS
   not_found        = 1
   others           = 2.

if sy-subrc <> 0.
  message 'Unable to get list from memory' type 'E'.
endif.

call function 'WRITE_LIST'
  TABLES
   listobject       = t_list
  EXCEPTIONS
   EMPTY_LIST       = 1
   OTHERS           = 2
        .
 if sy-subrc <> 0.
  message 'Unable to write list' type 'E'.
 endif.

另一种(更有效的方法,恕我直言)是通过类cl_salv_bs_runtime_info 访问生成的网格.请参阅此处的示例

Another (and more efficient approach, IMHO) is to gain access to resulting grid via class cl_salv_bs_runtime_info. See the example here

附言使用相互依赖的不同参数执行相同报告(第一次迭代的输出解析=第二次迭代的输入解析)绝对是糟糕的设计,这些操作应该是内部完成.
对我来说,最好重新考虑报告的整个架构.

P.S. Executing the same report with different parameters which are mutually-dependent (output pars of 1st iteration = input pars for the 2nd) is definitely a bad design, and those manipulations should be done internally.
As for me one'd better rethink the whole architecture of the report.

这篇关于给定以前在 ABAP 中执行的报告的结果,如何执行报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆