Back and Exit button not enabling in screen program

Viewed 1425

I am trying to enable back and exit buttons on application tool bar. I created pf-status choosing dialog box. I am not able to figure out which function code should be assigned to back and exit button. I need to have option where the output can be displayed in either popup dialog box or normal screen. Can anyone please explain how to achieve this?

1 Answers

It doesn't really matter what function code you assign to those buttons, because you have to implement the PAI module which handles the reactions to those buttons yourself anyway. There doesn't seem to be a convention either: SAP standard programs all use different function codes for those buttons.

Here is an example for such a handler. In this case the GUI-Status assigns "BACK", "EXIT" and "CANCEL" to the green, yellow and red button respectively:

MODULE handle_navigation INPUT.
  CASE sy-ucomm.
    WHEN 'BACK'.  " Green button
      LEAVE TO SCREEN 100.
    WHEN 'EXIT'.  " Yellow button
      CALL FUNCTION 'POPUP_TO_CONFIRM'
        EXPORTING 
          text_question = 'Would you like to save before quitting?'
        IMPORTING
          answer = lv_answer.          
      IF lv_answer = '1'.  " Yes, save and then quit
         PERFORM write_data_to_db.
         LEAVE PROGRAM.
      ELSEIF lv_answer = '2'.  " No, quit without saving
         LEAVE PROGRAM.
      ELSE.
         " User canceled the popup - do nothing
      ENDIF.         
    WHEN 'CANCEL'. " Red button
      LEAVE PROGRAM.
  ENDCASE.
ENDMODULE.
Related