与LIST_TO_ASCI类似,支持JSON / XML

时间:2018-08-02 06:32:08

标签: sap abap

我知道我可以使用LIST_TO_ASCI将报告转换为ASCII。

但是我想拥有更高级的数据格式,例如json,XML,CSV。

有没有办法得到比ASCII更容易处理的东西?

这是报表在SAP中的样子:

enter image description here

转换必须在ABAP中执行,其结果是这样的:

SUBMIT <REPORT_NAME> ... EXPORTING LIST TO MEMORY AND RETURN.

2 个答案:

答案 0 :(得分:1)

您可以像这样访问内存中的“提交”列表:

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.

问题的解决方案的最后一步(将结果表转换为JSON)was already answered to you

答案 1 :(得分:0)

我在这里找到了解决方案:http://zevolving.com/2015/07/salv-table-22-get-data-directly-after-submit/

这是代码:

DATA: lt_outtab TYPE STANDARD TABLE OF alv_t_t2.
FIELD-SYMBOLS: <lt_outtab> like lt_outtab.
DATA lo_data TYPE REF TO data.

" Let know the model
 cl_salv_bs_runtime_info=>set(
  EXPORTING
    display  = abap_false
    metadata = abap_false
    data     = abap_true
).


SUBMIT salv_demo_table_simple
  AND RETURN.

TRY.
    " get data from SALV model
    cl_salv_bs_runtime_info=>get_data_ref(
          IMPORTING
            r_data = lo_data
    ).
    ASSIGN lo_data->* to <lt_outtab>.
    BREAK-POINT.    

  CATCH cx_salv_bs_sc_runtime_info.
ENDTRY.

非常感谢Sandra Rossi,她给了我cx_salv_bs_sc_runtime_info的提示。

相关答案:https://stackoverflow.com/a/52834118/633961