问题描述
我的问题如下:
我有一个名为 Y5000112
的报告。
我的同事总是手动执行一次使用选择屏幕变体 V1
,然后使用变体 V2第二次执行该操作code>将首次执行的结果添加到选择中。
在这种情况下,这些结果是 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.
PS
我对ABAP不太熟悉,所以如果不这样做, t提供足够的信息,只是在评论中让我知道,我将尝试找出您需要解决的所有问题。
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);
推荐答案
这并不像想象的那么容易,所以不会是任何一行代码段。
没有从报告中获取结果的标准方法。尝试使用将列表导出为内存
子句,但请考虑修改报告 :
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:
上述语句的结果应从内存中读取并调整为输出:
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.
另一种(更有效的方法,恕我直言)是通过类<$ c来访问生成的网格$ c> 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
PS使用具有相互依赖关系的不同参数执行同一报告(第一次迭代的输出参数=第二次迭代的输入参数)绝对是错误的设计,这些操作应内部完成。
对于我来说,最好重新考虑一下报告的整个架构。
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中先前执行的报告的结果,如何执行报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!