+ -

Pages

Saturday, July 26, 2014

Simple example of how to make a dialog program

Checklist for simpe dialog program

Create the program

Create a new program in the repository browser (Transaction SE80) . Name standard for dialog programs is SAPMZ<name of program>


In the attributes window:

- Module pool = M
- Application = Z

Create the screen

Create a new screen.

Add a pushbutton to the screen

In the attributes screen for the pushbutton, enter a function code

in the FctCode field ( In this example: 0020 ).

When you create a screen, SAP automathic creates a field with the type OK. The function code of the psuhbutton will be placed here when you push the button. However you have to supply the name of the OK field ( In this example: OK_CODE ).


You must also create a global variable in the program, to store the value of the OK field ( See below ).

Create global variables

DATA: 
* Global variable to store OK code     

  ok_code(4),       
* Temporary store the value of the OK code
 save_ok_code(4).  

Create code for the screen


PROCESS BEFORE OUTPUT.         
 MODULE status_0001.           

                              
PROCESS AFTER INPUT.           
  MODULE user_command_0001.    


MODULE status_0001 OUTPUT. 
   SET PF-STATUS '0001'.   
   SET TITLEBAR '001'.     
                                                                  

* Example of how deactivate a field on the screen
* ZCOSTAFSTM-ZAFSTEMNR is the name of the screen field we want to
* deactivate. 
  LOOP AT SCREEN.                                                
     CHECK screen-name = 'ZCOSTAFSTM-ZAFSTEMNR'.
 screen-input = '0'.                                         
     MODIFY SCREEN.                                              
  ENDLOOP.                                                       
   
 ENDIF.                                                  

ENDMODULE.


MODULE user_command_0001 INPUT.                                        
* Here you can catch when user pushes a pushbutton


* Save the OK code in  save_ok_code and clear it
    save_ok_code = ok_code.                                            
    CLEAR ok_code.                                                     
                                                                      
                                                                       

    CASE save_ok_code.                                                 
       WHEN '0010'.                                                    
*         Afstemninger                                                 
           LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN 0.            
           PERFORM my_list.                               
       WHEN '0020'.                                                    
           CALL TRANSACTION 'ZCO1'.                                    

      WHEN 'RETU'.                          
          LEAVE TO SCREEN '0000'.           
   ENDCASE.                                 
ENDMODULE.


AT USER-COMMAND.
* Here you can catch when the user psuh a button on the menu bar or presses a function key

   CASE sy-ucomm.     
      WHEN 'OPRT'.    
           PERFORM something.
   ENDCASE.
5 ABAP Tips: Simple example of how to make a dialog program Checklist for simpe dialog program Create the program Create a new program in the repository browser (Transaction SE80) . Name standard f...

No comments:

Post a Comment

< >