0

Currently my program writes out the results but I was hoping I can output into an ALV List. Am I able to use the function reuse_alv_list_display?

Below is my code so far:

REPORT  Z_TRANSFORMER_TOOL_BATCH.

TABLES zfit_map_account.

TYPES: BEGIN OF t_account,
        saknr TYPE saknr,
        txt20 TYPE txt20,
        zznew TYPE new_saknr,
        ntx20 TYPE zntx20,
       END OF t_account.

DATA: gwa_account TYPE t_account.
DATA: gt_account TYPE TABLE OF t_account.

SELECT saknr txt20 zznew ntx20
FROM zfit_map_account
INTO gwa_account
WHERE zznew = '1010101998'.
APPEND gwa_account TO gt_account.
ENDSELECT.

Loop at gt_account INTO gwa_account.
  Write :/ gwa_account-saknr, gwa_account-txt20, gwa_account-zznew, gwa_account-ntx20.
ENDLOOP.
Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Michael
  • 37
  • 2
  • 7
  • Possible duplicate of [In ABAP Workbench, how do I make the program return multiple table fields in a table when a button is clicked?](http://stackoverflow.com/questions/38553767/in-abap-workbench-how-do-i-make-the-program-return-multiple-table-fields-in-a-t) – gkubed Aug 10 '16 at 13:11
  • Why? What have you tried so far? Are you expecting standard selection screen functions (variants, ...) to work? – vwegert Aug 10 '16 at 13:23
  • @vwegert I have edited my response with the code I have so far. I want to put it into a ALV list since it's easier to view. – Michael Aug 10 '16 at 14:02
  • 3
    Your question with the code is a bit confusing. Your code does not have a selection screen. Investigate the classes in the packages of package SALV, it's the modern way of handling ALV. A good start would be example program SALV_DEMO_TABLE_SIMPLE. – Gert Beukema Aug 10 '16 at 16:00

1 Answers1

1

An easy way can be using the cl_salv_table class. You can just do something like this as a replacement of your entire loop section

DATA alv TYPE REF TO cl_salv_table.

TRY.
      cl_salv_table=>factory(
        IMPORTING
          r_salv_table = alv
        CHANGING
          t_table      = gt_account ).
    CATCH cx_salv_msg INTO message.
      " handle error
  ENDTRY.


alv->display( ).
Reginaldo Costa
  • 766
  • 7
  • 17