Register Login

Insert multiple record into database table using table control

Updated May 18, 2018

TABLES: ZBC2_DVG_GR4.
END-OF-SELECTION.
CALL SCREEN 9800.
CONTROLS: TC TYPE TABLEVIEW USING SCREEN 9800.
DATA: OKCODE TYPE SY-UCOMM,
      MBLNR1 TYPE MBLNR.

  DATA: IT_FINAL TYPE STANDARD TABLE OF ZBC2_DVG_GR4,
        WA_FINAL TYPE ZBC2_DVG_GR4,
       

*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9800  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9800 INPUT.
******* INSERT INTO TABLE
  CASE OKCODE.


      WHEN 'EXIT'.
         LEAVE PROGRAM.
      WHEN 'CREATE'.
SELECT MAX( MBLNR ) FROM ZBC2_DVG_GR3 INTO MBLNR1.
        MBLNR1 = MBLNR1 + 1.
        ZBC2_DVG_GR3-MBLNR = MBLNR1.

         
          INSERT ZBC2_DVG_GR4 FROM TABLE IT_FINAL.
         

          CLEAR IT_FINAL[].


          MESSAGE 'SUCCESSFUL INSERTION OF DATA' TYPE 'S' .

       WHEN 'DISPLAY'.
         

          SELECT * FROM ZBC2_DVG_GR4 INTO TABLE IT_FINAL WHERE MBLNR = ZBC2_DVG_GR4-MBLNR.

      WHEN 'DELETE'.

         
          DELETE FROM ZBC2_DVG_GR4 WHERE MBLNR = ZBC2_DVG_GR4-MBLNR.
         
          MESSAGE 'VALUES DELETED FROM DB' TYPE 'S'.


     WHEN 'CHANGE'.

         UPDATE ZBC2_DVG_GR4 FROM TABLE IT_FINAL.

         
  ENDCASE.
endmodule.


MODULE APPEND INPUT.
  WA_FINAL-ZEILE = TC-CURRENT_LINE.
 
  APPEND WA_FINAL TO IT_FINAL.

  ENDMODULE. 




In flow Logic


PROCESS BEFORE OUTPUT.

    LOOP AT IT_FINAL INTO WA_FINAL WITH CONTROL TC
           CURSOR TC-CURRENT_LINE.
      MODULE STATUS_9800.
     ENDLOOP.

PROCESS AFTER INPUT.

 LOOP AT IT_FINAL.
    MODULE APPEND.
     ENDLOOP.
     MODULE USER_COMMAND_9800.            


×