【问题标题】:How to retrieve a specific field from a list output?如何从列表输出中检索特定字段?
【发布时间】:2017-06-21 02:02:23
【问题描述】:

我在我的 SAP 系统中没有任何开发人员权限,但我找到了一种方法可以在里面的一个小“用户退出”框(我不知道你是不是这么称呼它)中编写一些 ABAP 代码一份报告。

我正在尝试提交一份 HR 报告并将其输出的 PERNR 再次插入同一份报告中。

有一个语法错误告诉我t_list 没有名称为PERNR 的组件。

我必须做什么才能让它工作?

DATA: t_list TYPE TABLE OF abaplist WITH HEADER LINE,
      seltab TYPE TABLE OF rsparams,
      selline LIKE LINE OF seltab.
*I found out that the name of the selection field in the Report-GUI is "PNPPERNR" and tested it
selline-selname = 'PNPPERNR'.
selline-sign    = 'I'.
selline-option  = 'EQ'.

SUBMIT Y5000112
USING SELECTION-SET 'V1_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.
  LOOP AT t_list.
*The Problem is here: how do I get the pnppernr out of t_list, it's the first column of the report output
    selline-low = t_list-pernr.
    append selline to seltab.
  ENDLOOP.

  SUBMIT Y5000112
  WITH SELECTION-TABLE seltab
  USING SELECTION-SET 'V2_TEST'
  AND RETURN.
ENDIF.

【问题讨论】:

    标签: abap


    【解决方案1】:

    使用功能模块LIST_TO_ASCI 将t_list 的内容解码为可读的内容。 This answer 包含一些示例代码,包括所需的数据类型。此时,您要查找的数据可能会出现在输出的同一列范围内。使用standard substring access methods - e。 G。 line+42(21)获取你需要的那部分线路。

    【讨论】:

      【解决方案2】:

      vwegert 的回答非常有用!
      my previous answer 我忘了提到 LIST_TO_ASCI FM :) 我唯一可以补充的是,结果行的解析没有通用的解决方案,很大程度上取决于它的结构。通常它是这样完成的:

      LOOP AT t_list.
       SPLIT t_list AT '|' INTO <required_structure>.
       selline-low = <required_structure>-pernr.
       APPEND selline TO seltab.
      ENDLOOP.
      

      其中 是您的 Y5000112 输出结构。但这可能不是那么简单,可能需要额外的操作。

      【讨论】:

        猜你喜欢
        • 2014-10-15
        • 1970-01-01
        • 2019-02-08
        • 2016-01-31
        • 1970-01-01
        • 2021-08-31
        • 1970-01-01
        • 2012-06-10
        • 1970-01-01
        相关资源
        最近更新 更多