Display an internal table?

匆匆过客 提交于 2021-01-07 06:26:28

问题


I have to read some data from a table and display it. The program starts but I don't know how to display any of the data I've selected. I want to put it out as a table.

I honestly don't even know if the following code is correct.

REPORT ZT_THIEMANN_TEST.

types : begin of ts_output,
          object_id  type CRMD_ORDERADM_H-object_id,
          created_by type CRMD_ORDERADM_H-created_by,
        end of ts_output,
        tt_output type table of ts_output.

PARAMETERS Mel_Nr TYPE CRMD_ORDERADM_H-Object_ID obligatory.

data gt_output type tt_output.

START-OF-SELECTION.

SELECT cm~object_id cm~created_by
from CRMD_ORDERADM_H as cm
into corresponding fields of table gt_output
where cm~object_id like Mel_Nr.

回答1:


As Sandra said, you can check if your code/the select works by using the debugger.

You can output data different ways, but the easiest is using the class CL_SALV_TABLE. Without adding any additional features (such as a title, toolbar buttons, sorting, hotspots, etc.), the below code is how you can display your data using the oo alv grid.

...

DATA: go_alv       TYPE REF TO  cl_salv_table,
      gx_salv_msg  TYPE REF TO  cx_salv_msg.

...

  TRY.
      cl_salv_table=>factory(
      IMPORTING
        r_salv_table = go_alv
      CHANGING
        t_table = gt_output ).
    CATCH cx_salv_msg INTO gx_salv_msg.
      MESSAGE 'error' TYPE 'E'.
  ENDTRY.

  go_alv->display( ).



回答2:


If you need a real one-liner, just use ABAP demo output standard class cl_demo_output that can handle any type including internal tables:

SELECT *
   FROM scarr
   INTO TABLE @DATA(carriers).

cl_demo_output=>display( carriers ).


来源:https://stackoverflow.com/questions/57724477/display-an-internal-table

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!