Wizard creation in SAP

...Previous

Function module SWF_WIZARD_PROCESS:  

This is the first and important function module to be called to define the wizard. The important input parameter to this function module is “Definition”, to which one internal table of program name, wizard link texts and subroutines of the wizard screen definitions is populated. Example program will have further details on this.  

Function module SWF_WIZARD_CALL:  

This function module is mainly used to call the wizard screen in a defined workflow. The important input parameter, what we have to supply to this function module, is “Wizard_Data. Pass the document text object and screen type in the structure. The screen types in wizard are…  

ü  Starting screen

ü  Ending screen

ü  Input screen

ü  Normal screen

ü  Report screen

ü  Text screen  

These types of screens have been defined in “<wizard>” include. This must be included in your program to create wizard.  

Function module SWF_WIZARD_PROCESS_MODIFY:  

This is the one, which diverts the wizard flow according to the user input dynamically. The important input parameter that the user has to supply are “Step_program”, “Step_form” and “Command”. First two parameters say in which program, which wizard definition subroutine should be executed. Commands are three values. ‘A’, ‘D’ and ‘J’.  

ü  A -  Activate a screen in wizard definition

ü  D -  Deactivate a screen in wizard definition.

ü  J -  Jump to a screen in the wizard flow.  

The example program of above flow chart will give you clear picture how to create the wizard.  

*&---------------------------------------------------------------------*
*& Report  ZRUN_WIZARD                                                 *
*& Wizard creation demo.                                         
*&---------------------------------------------------------------------*

REPORT  zrun_wizard.

* This include is mandatory to make use of wizard macro definition.
INCLUDE<wizard>.

DATA it_wizdef TYPE TABLE OF swf_wizdef,
       wa_wizdef 
TYPE swf_wizdef,
       wa_wizard 
TYPE swf_wizard. 

* Creation of wizard definition.
PERFORM wizard_append_def USING :
      
'ZRUN_WIZARD' 'Start' 'START_WIZARD',
      
'ZRUN_WIZARD' 'User Input' 'SHOW_SCREEN_0500',
      
'ZRUN_WIZARD' 'Addition result' 'SHOW_SCREEN_0501',
      
'ZRUN_WIZARD' 'Subtraction result' 'SHOW_SCREEN_0502',
      
'ZRUN_WIZARD' 'Complete' 'END_WIZARD'.
* Starting the wizard.
CALL FUNCTION 'SWF_WIZARD_PROCESS'
  
EXPORTING
    container_compensation      
'X'
  
TABLES
    
definition                  it_wizdef
  
EXCEPTIONS
    operation_cancelled_by_user 
1
    process_in_error            
2
    
OTHERS                      3.

*&---------------------------------------------------------------------*
*&      Form  wizard_append_def
*&---------------------------------------------------------------------*
*  This subroutine is used to create wizard definition.
*  It defines the subrountines that are to be executed in a program
*  and the wizard link texts.
*----------------------------------------------------------------------*
FORM wizard_append_def USING lv_program TYPE c
                             lv_text 
TYPE c
                             lv_subroutine 
TYPE c.
  
CLEAR wa_wizdef.
  wa_wizdef
-program lv_program.
  wa_wizdef
-text    lv_text.
  wa_wizdef
-form    lv_subroutine.
  
APPEND wa_wizdef TO it_wizdef.
ENDFORM.                    "append_definition

*&---------------------------------------------------------------------*
*&      Form  start_wizard
*&---------------------------------------------------------------------*
*  This subroutines starts the wizard.
*----------------------------------------------------------------------*
FORM start_wizard TABLES container USING command.
  
CLEAR wa_wizard.
  wa_wizard
-descobject 'WIZARD_DEMO_TEXT'.
  wa_wizard
-screen_typ wizard_screen_start.
  
CALL FUNCTION 'SWF_WIZARD_CALL'
    
EXPORTING
      wizard_data                 
wa_wizard
      start_column                
2
      start_row                   
2
    
EXCEPTIONS
      operation_cancelled_by_user 
1
      
back                        2
      
OTHERS                      3.
  swf_evaluate command
.

ENDFORM.                    "start_wizard
*&---------------------------------------------------------------------*
*&      Form  show_screen_0500
*&---------------------------------------------------------------------*
*  This subroutine shows the initial input screen of two number
*  in the wizard.
*----------------------------------------------------------------------*
FORM show_screen_0500 TABLES container USING command.
  wa_wizard
-docuobject 'WIZARD_DEMO_TEXT'.
  wa_wizard
-screen_typ wizard_screen_normal.
  wa_wizard
-subscpool1 'ZWIZARD_DEMO'.
  wa_wizard
-subscreen1 '0500'.

  
CALL FUNCTION 'SWF_WIZARD_CALL'
    
EXPORTING
      wizard_data                 
wa_wizard
      start_column                
2
      start_row                   
2
    
EXCEPTIONS
      operation_cancelled_by_user 
1
      
back                        2
      
OTHERS                      3.
  swf_evaluate command
.
ENDFORM.                    "show_screen_0500  
*&---------------------------------------------------------------------*
*&      Form  show_screen_0501
*&---------------------------------------------------------------------*
*  This subroutine is used to show the addition result screen
*  in the wizard.
*----------------------------------------------------------------------*
FORM show_screen_0501 TABLES container USING command.
  wa_wizard
-docuobject 'WIZARD_DEMO_TEXT'.
  wa_wizard
-screen_typ wizard_screen_normal.
  wa_wizard
-subscpool1 'ZWIZARD_DEMO'.
  wa_wizard
-subscreen1 '0501'.

  
CALL FUNCTION 'SWF_WIZARD_CALL'
    
EXPORTING
      wizard_data                 
wa_wizard
      start_column                
2
      start_row                   
2
    
EXCEPTIONS
      operation_cancelled_by_user 
1
      
back                        2
      
OTHERS                      3.
  swf_evaluate command
.

  
CALL FUNCTION 'SWF_WIZARD_PROCESS_MODIFY'
    
EXPORTING
      step_form           
'END_WIZARD'
      step_program        
'ZRUN_WIZARD'
      command             
'J'
    
EXCEPTIONS
      modification_failed 
1
      
OTHERS              2.
ENDFORM.                    "show_screen_0501  


*&---------------------------------------------------------------------*
*&      Form  show_screen_0502
*&---------------------------------------------------------------------*
*  This subroutine is used to show the subtraction result screen
*  in the wizard.
*----------------------------------------------------------------------*
FORM show_screen_0502 TABLES container USING command.
  wa_wizard
-docuobject 'WIZARD_DEMO_TEXT'.
  wa_wizard
-screen_typ wizard_screen_normal.
  wa_wizard
-subscpool1 'ZWIZARD_DEMO'.
  wa_wizard
-subscreen1 '0502'.

  
CALL FUNCTION 'SWF_WIZARD_CALL'
    
EXPORTING
      wizard_data                 
wa_wizard
      start_column                
2
      start_row                   
2
    
EXCEPTIONS
      operation_cancelled_by_user 
1
      
back                        2
      
OTHERS                      3.
  swf_evaluate command
.

  
CALL FUNCTION 'SWF_WIZARD_PROCESS_MODIFY'
    
EXPORTING
      step_form           
'END_WIZARD'
      step_program        
'ZRUN_WIZARD'
      command             
'J'
    
EXCEPTIONS
      modification_failed 
1
      
OTHERS              2.
ENDFORM.                    "show_screen_0502

*&---------------------------------------------------------------------*
*&      Form  end_wizard
*&---------------------------------------------------------------------*
*  This subroutine is used to end the wizard.
*----------------------------------------------------------------------*
FORM end_wizard TABLES container USING command.
  wa_wizard
-descobject 'WIZARD_DEMO_TEXT'.
  wa_wizard
-screen_typ wizard_screen_end.

  
CALL FUNCTION 'SWF_WIZARD_CALL'
    
EXPORTING
      wizard_data                 
wa_wizard
      start_column                
2
      start_row                   
2
    
EXCEPTIONS
      operation_cancelled_by_user 
1
      
back                        2
      
OTHERS                      3.
  swf_evaluate command
.
ENDFORM.                    "end_wizard

Click here to continue...

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image