Skip to Content

1. Create a ModulePool program.

2. Create one Screen: 100

3. Create the required screen elements:

   1.JPG

Function code for the buttons:

2.JPG

3.JPG

4.JPG

Display : DISPLAY

Exit      : EXIT

4. Paste this code in your program


PROGRAM  zmtc01.

TABLES: sflight.                                        ” Table Name

TYPES: BEGIN OF ty_sflight,                     ” Structure
        carrid TYPE sflightcarrid,
        connid TYPE sflightconnid,
        fldate TYPE sflightfldate,
        price TYPE sflightprice,
        sel   TYPE c,
        END OF ty_sflight.
DATA: flag TYPE c.
DATA: flag1 TYPE c.
DATA: int TYPE i,
       id TYPE i.

DATA: it_sflight TYPE TABLE OF ty_sflight,
         wa_sflight TYPE ty_sflight.

DATA: carrid TYPE sflightcarrid.

DATA: ok_code TYPE syucomm.

CONTROLS: table_control TYPE TABLEVIEW USING SCREEN 100.
*&———————————————————————*
*&      Module  USER_COMMAND_0100  INPUT
*&———————————————————————*
*       text
*———————————————————————-*
MODULE user_command_0100 INPUT.

   CASE syucomm.
     WHEN ‘DIS’.
       SELECT carrid connid fldate price FROM sflight INTO CORRESPONDING FIELDS OF TABLE it_sflight WHERE carrid = sflightcarrid.
       flag = ‘X’.
       IF sysubrc = 0.
         MESSAGE ‘ALL THE VALUES ARE SUCCESSFULY DISPLAYED’ TYPE ‘S’.
       ELSE.
         MESSAGE ‘THERE IS NO VALUE AVAILABLE’ TYPE ‘E’.
       ENDIF.
     WHEN ‘EXIT’.
       LEAVE PROGRAM.
     WHEN ‘INS’.
*         if id is initial.
       CLEAR wa_sflight.
       INSERT wa_sflight INTO it_sflight INDEX 1.
*         else.
*            clear wa_sflight.
*           INSERT WA_SFLIGHT INTO IT_SFLIGHt index id.
*         endif.

       id = table_controlcurrent_line.
     WHEN ‘DEL’.
       LOOP AT it_sflight INTO wa_sflight.
         IF wa_sflightsel = ‘X’.
           DELETE it_sflight  WHERE sel = ‘X’.

         ENDIF.

       ENDLOOP.
     WHEN ‘EDIT’.
       flag1 = ‘X’.

   ENDCASE.

ENDMODULE.                 ” USER_COMMAND_0100  INPUT
*&———————————————————————*
*&      Module  STATUS_0100  OUTPUT
*&———————————————————————*
*       text
*———————————————————————-*
MODULE status_0100 OUTPUT.

   IF it_sflight IS INITIAL.
     SELECT carrid connid fldate price FROM sflight INTO CORRESPONDING FIELDS OF TABLE it_sflight.
   ENDIF.

ENDMODULE.                 ” STATUS_0100  OUTPUT
*&———————————————————————*
*&      Module  M1  INPUT
*&———————————————————————*
*       text
*———————————————————————-*
MODULE m1 INPUT.
   MODIFY it_sflight FROM wa_sflight INDEX table_controlcurrent_line.
* This code is for selecting the record by selecting the lead selection. for this in screen in pai we need to witr some code
   IF wa_sflightsel = ‘X’.
     id = table_controlcurrent_line.
   ENDIF.
* CLEAR WA_SFLIGHT.
* INSERT WA_SFLIGHT INTO IT_SFLIGHT INDEX 1.

*Int = TABLE_CONTROL-current_line.
ENDMODULE.                                                  “M1 INPUT
*&———————————————————————*
*&      Module  EDIT  OUTPUT
*&———————————————————————*
*       text
*———————————————————————-*
MODULE edit OUTPUT.

* This code is for making the new record editable.
   LOOP AT SCREEN.
     IF ( ok_code = ‘EDIT’ AND table_controlcurrent_line = id ) OR ( table_controlcurrent_line = 1 AND syucomm = ‘INS’).

       screeninput = 1.
       MODIFY SCREEN.

     ELSEIF wa_sflightsel = ‘X’.
       screeninput = 1.
       MODIFY SCREEN.
     ELSEIF ( wa_sflightcarrid IS INITIAL OR wa_sflightconnid IS INITIAL OR wa_sflightfldate IS INITIAL OR wa_sflightprice IS INITIAL ).
       screeninput = 1.
       MODIFY SCREEN.
     ENDIF.
   ENDLOOP.
ENDMODULE.                 ” EDIT  OUTPUT

5. In Flow Logic of screen 100, Paste this code:

PROCESS BEFORE OUTPUT.
  MODULE STATUS_0100.
    LOOP AT  IT_SFLIGHT INTO WA_SFLIGHT WITH  CONTROL TABLE_CONTROL.
    MODULE EDIT.
    ENDLOOP.
*
PROCESS AFTER INPUT.

     LOOP AT IT_SFLIGHT.
      FIELD: WA_SFLIGHTSEL MODULE M1.
    ENDLOOP.
     MODULE USER_COMMAND_0100.

6. Activate it, Create the Transaction.

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

Leave a Reply