ABAP retrieving data from database to a screen table control

5.6k Views Asked by At

I need help if possible because i am stuck on a place where there is no syntax errors . I am using abap to retrieve data from my database table to the table control i have in screen 0300 . And whenever i press direct processing in screen 0300 i have no information on my table control . Thats the flow logic of screen 0300 :

PROCESS BEFORE OUTPUT.

 MODULE STATUS_0300.

 LOOP at it_customers  into WA_customerS WITH CONTROL tc300.
   MODULE fill_ctable_control .

 ENDLOOP.



PROCESS AFTER INPUT.

  LOOP at it_CUSTOMERs .
module read_ctable_control .

 ENDLOOP.


MODULE USER_COMMAND_0300.

And that is the PBO / PAI code :

module FILL_CTABLE_CONTROL output.

IF it_CUSTOMERS is initIAl.
SELECT * FROM  zy2014_42_CUSTOM

    INTO CORRESPONDING FIELDS OF TABLE it_CUSTOMERS.
ENDIF.

endmodule.                 " FILL_CTABLE_CONTROL  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  READ_CTABLE_CONTROL  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module READ_CTABLE_CONTROL intput.
 IF sy-stepl = 1.

      tc300-lines = tc300-top_line + sy-loopc - 1.

    ENDIF.



*   move fields from work area to scrren fields

    MOVE-CORRESPONDING wa_CUSTOMERs TO zy2014_42_TCCUSTOMERS.
endmodule.

module USER_COMMAND_0300 input.
case ok_code .
when 'BACK'.
LEAVE TO SCREEN 100.
ENDCASE.
  SELECT *  FROM  zy2014_42_CUSTOM

    INTO CORRESPONDING FIELDS OF TABLE it_CUSTOMERS.

CLEAR OK_CODE.
endmodule. 

Taking in consideration that i am using dynpro program

Thanks all in advance

1

There are 1 best solutions below

1
On BEST ANSWER

The purpose of the MODULE fill_ctable_control seems to be to read the whole database table into your it_customers. It would make sense to execute it once per PBO. However, you've put the call into the LOOP at it_customers which means it is executed once for each entry in that internal table. When the internal table hasn't got any entries yet, it isn't executed at all, so the table stays as empty as it is.

I would recommend you to move the module-call out of the loop.