Saturday, 19 August 2017

AT EXIT-COMMAND



  • Scenario: Generally if a screen contains any obligatory(Required) input field & we execute the MP program, the screen appears & if we want to come out of the program it will not allow us. We have to fill the mandatory field on the screen and then we can come out of the program by clicking on the application toolbar buttons. To overcome this problem, generally, we use AT EXIT-COMMAND at PAI of the screen to force the exit from the screen that contains a required field without filling any value to it.
  • Here we have two screens 9000 and 9001. In the 9000 screens, we have a required i/p field & a single record is displayed on 9001 screens based on the i/p.


  • Screen 9000 looks like,
  • Screen 9001 looks like,


  • Flow logic for screen 9000.




  • Flow logic for screen 9001.
  • Top include looks like,
PROGRAM  ZEXIT_COMMAND.
TYPES : BEGIN OF T_MARA,
        MATNR  TYPE MARA-MATNR,
        ERSDA  TYPE MARA-ERSDA,
        ERNAM  TYPE MARA-ERNAM,
        MTART TYPE MARA-MTART,
        MATKL  TYPE MARA-MATKL,
        MEINS  TYPE  MARA-MEINS,
     END OF T_MARA.
DATA : P_MATNR TYPE MARA-MATNR,
       WA_MARA TYPE T_MARA.

  • Output include looks like,



module STATUS_9000 output.
  SET PF-STATUS 'STATUS'.
*  SET TITLEBAR 'xxx'.

endmodule.                 " STATUS_9000  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  STATUS_9001  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module STATUS_9001 output.
*  SET PF-STATUS 'xxxxxxxx'.
*  SET TITLEBAR 'xxx'.


 SELECT SINGLE MATNR ERSDA ERNAM MTART MATKL MEINS FROM MARA
         INTO WA_MARA
     WHERE MATNR = P_MATNR.
endmodule.                 " STATUS_9001  OUTPUT


Note : Double click on PF-STATUS of 9000 and add 'EXIT' and 'CANCEL' function code.



  • Double click on Cancel function code.
  • Pop-up will appear.
  • Select Function Type as E ( Exit-Command ).
  • Similarly to the Exit Function Code.



  • Input include looks like,

module USER_COMMAND_9000 input.

  CASE SY-UCOMM.
    WHEN 'DISP' .
      CALL SCREEN 9001.
   WHEN 'BACK'.
    LEAVE PROGRAM.
  ENDCASE.

endmodule.                 " USER_COMMAND_9000  INPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9001  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module USER_COMMAND_9001 input.

  CASE  SY-UCOMM.
    WHEN 'BACK'.
      LEAVE TO SCREEN 0.
  ENDCASE.

endmodule.                 " USER_COMMAND_9001  INPUT
 
  • Module AT EXIT COMMAND ( Create it in Input include ) looks like.

module FORCE_EXIT input.
  CASE SY-UCOMM.
    WHEN 'EXIT' OR 'CANCEL' .
      LEAVE PROGRAM.

  ENDCASE.

endmodule.                 " FORCE_EXIT  INPUT



No comments:

Post a Comment