WORKING WITH TABLE CONTROL

WORKING WITH TABLE CONTROL:

Table control is used to display the multiple records in a tabular format.

Syntax of declaring the table control in ABAP editor: - 
Controls <Table control name> type table view using screen <screen no> .

Syntax of transferring the data from internal table to table control in the flow logic editor: -
Loop at <it> into <wa>  with control <tbc name> cursor <tbc name>- current_line.

endloop.

Note: - Whenever we are working with loop & endloop in any one of the event then we must declare                a dummy loop & endloop in another event

PROGRAM:


*&---------------------------------------------------------------------*
*& Module Pool       ZM_TABLE_CONTROL
*&
*&---------------------------------------------------------------------*
PROGRAM ZM_TABLE_CONTROL.
DATA : TYPE EKKO-EBELN.
CONTROLS TC TYPE TABLEVIEW USING SCREEN 2222.
TYPES : BEGIN OF TY_EKPO,
        EBELN 
TYPE EKPO-EBELN,
        EBELP 
TYPE EKPO-EBELP,
        MENGE 
TYPE EKPO-MENGE,
        MEINS 
TYPE EKPO-MEINS,
        NETPR 
TYPE EKPO-NETPR,
        
END OF TY_EKPO.
DATA : WA_EKPO TYPE TY_EKPO,
       IT_EKPO 
TYPE TABLE OF TY_EKPO.
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_2222  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_2222 INPUT.

  
IF SY-UCOMM 'BACK'.
    
LEAVE TO SCREEN 0.
    
ENDIF.
ENDMODULE.                 " USER_COMMAND_2222  INPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_1111  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_1111 INPUT.

  
IF SY-UCOMM 'DIS'.
  
SELECT EBELN
         EBELP
         MENGE
         MEINS
         NETPR
    
FROM EKPO
    
INTO TABLE IT_EKPO
    
WHERE EBELN A.
    
CALL SCREEN 2222.
   
ELSEIF SY-UCOMM 'BACK'.
     
LEAVE PROGRAM.
     
ENDIF.
ENDMODULE.                 " USER_COMMAND_1111  INPUT
*&---------------------------------------------------------------------*
*&      Module  STATUS_2222  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_2222 OUTPUT.
  
SET PF-STATUS 'ST'.
*  SET TITLEBAR 'xxx'.
ENDMODULE.                 " STATUS_2222  OUTPUT

SCREEN 1111.
PROCESS BEFORE OUTPUT.
* MODULE STATUS_1111.
*
PROCESS AFTER 
INPUT.
 
MODULE USER_COMMAND_1111.
SCREEN 2222.
PROCESS BEFORE OUTPUT.
 
MODULE STATUS_2222.
LOOP AT IT_EKPO INTO WA_EKPO
        
WITH CONTROL TC CURSOR
        TC
-CURRENT_LINE.
  
ENDLOOP.

PROCESS AFTER INPUT.
LOOP.
  
ENDLOOP.
 
MODULE USER_COMMAND_2222.

OUTPUT:
SCREEN 1
SCREEN 2