Charbel Sakr
Charbel Sakr

Reputation: 1

How to display data in Table Control?

I've got a screen '200' that has a table control with all rows from my database. The user enters the ID in the ID_FIELD and then press on SEARCH button so he gets all the columns of that specific row.

module SEARCH_COMMAND_0100 input.
  IF sy-ucomm = 'FCT_SEARCH'.
    SELECT SINGLE * FROM zch_empdata INTO wa_empdata WHERE id = zch_empdata-id.
  ENDIF.
endmodule.

Here I cannot CALL SCREEN '200' because I will get all the data in my database, so how can I solve it?

Upvotes: 0

Views: 132

Answers (1)

Kisbandi
Kisbandi

Reputation: 313

It is definitely a mistake that in this case the data is stored in a structure called wa_empdata. You won't be able to display this in ALV because you can only enter itab there. If you want to use the same table that is on the 200 screen anyway, you have to put the structure in the itab that set_table_for_first_display displays. After that you need to refresh the ALV with the refresh_table_display( ) method.

If the itab and the ALV GRID object are available in the same program as the modules, it is possible that it works.

module SEARCH_COMMAND_0100 input.
  IF sy-ucomm = 'FCT_SEARCH'.
    SELECT SINGLE * FROM zch_empdata INTO displayed_itab WHERE id = zch_empdata-id.
    grid_object->refresh_table_display( ).
  ENDIF.
endmodule.

Or create a new table display for it and use a simple condition check to decide which element you want to display.

I assume you built the screen 200 PBO part by setting up the itab there and calling the display. So if you just call that screen it will always display the basic itab. I suggest you don't organize these into modules, but rather into classes and methods to make it easier to manage and transparent. And there you can also manage the button presses.

Upvotes: 0

Related Questions