0
votes

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.
2
Hi @Teaman, please google "ALV Grid". As far as I know it's the easiest option to display internal tables. - konstantin
@konstantin Please convert your comment into an answer, I don't think you need to add a lot of extra information, just a snippet (for example with CL_SALV_TABLE). - Sandra Rossi
Simply use the debugger (add a break point and run the program). PS: in your case, you want a break point after the last line of code (SELECT), so you may find it easier to add a dummy statement right after that line. - Sandra Rossi

2 Answers

4
votes

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
votes

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 ).