Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
manish_shankar
Participant

1. Create a ModulePool program.

2. Create one Screen: 100

3. Create the required screen elements:

  

Function code for the buttons:

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 sflight-carrid,
        connid TYPE sflight-connid,
        fldate TYPE sflight-fldate,
        price TYPE sflight-price,
        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 sflight-carrid.

DATA: ok_code TYPE sy-ucomm.

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

   CASE sy-ucomm.
     WHEN 'DIS'.
       SELECT carrid connid fldate price FROM sflight INTO CORRESPONDING FIELDS OF TABLE it_sflight WHERE carrid = sflight-carrid.
       flag = 'X'.
       IF sy-subrc = 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_control-current_line.
     WHEN 'DEL'.
       LOOP AT it_sflight INTO wa_sflight.
         IF wa_sflight-sel = '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_control-current_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_sflight-sel = 'X'.
     id = table_control-current_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_control-current_line = id ) OR ( table_control-current_line = 1 AND sy-ucomm = 'INS').

       screen-input = 1.
       MODIFY SCREEN.

     ELSEIF wa_sflight-sel = 'X'.
       screen-input = 1.
       MODIFY SCREEN.
     ELSEIF ( wa_sflight-carrid IS INITIAL OR wa_sflight-connid IS INITIAL OR wa_sflight-fldate IS INITIAL OR wa_sflight-price IS INITIAL ).
       screen-input = 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_SFLIGHT-SEL MODULE M1.
    ENDLOOP.
     MODULE USER_COMMAND_0100.

6. Activate it, Create the Transaction.

1 Comment
Labels in this area