Skip to Content

I had some difficulty in transforming my documentation into HTML especially with the pictures hopefully not to much got lost.

“Not state of the art but useful”.

A wizard is a program that takes the user by the hand to execute a task using a step by step interface. Wizard builder helps you to create wizards (transaction SBPT_WB) see picture below. On the SAP website you can download the “SAP Wizard Style Guide” which gives you guidelines about designing a wizard, link: http://www1.sapdesignguild.org/resources/wizard_html/wizard_styleguide.pdf .</p>

image

The Wizard Builders generates a fully working program based on the Wizard Framework.

See also this blog by Puru Govind on how to change the Wizard at run-time.

The source code generated by the Wizard Builder is two-fold:

1. Main program

2. Wizard steps

1. Main program

The generated program is actually a function module with the name WZ_[Wizard name]_START containing three subroutines A, B and C.

image

A. Define wizard steps

Initialization of the wizard steps into global function module variable l_wizard_steps  (structure SWF_WIZDEF).

B. Initialize wizard data

This is the place to initialize global data for the wizard.

C. Process wizard steps

Here the actual wizard process starts by calling the function SWF_WIZARD_PROCESS which in turn dynamically calls the subroutine FORM CB_PROCESS_STEP_START.

Relevant include(s):

L[wizard name]DAT – declaration global variables

2. Wizard steps (screen process)

image

You can also do field checks using command MODULE … ON … (with field assignment) in the PAI event of the screen (this is not part of the Wizard Framework).

Step texts can be changed using transaction SE61 with the following parameters:

Document class = Text in dialog

Name text element = Can be found in the subroutine FORM CB_PROCESS_STEP_[screen number or START or FINISH] in variable L_WIZARD-DESCOBJECT = http://scn.sap.com/name text element.

Example see picture blow.

image

image

Wizard Macros

SWF_EXCLUDE

This macro can be used to exclude a screen from the wizard process. Example in picture below shows how you can skip a wizard process step based on the outcome of the current step.

image

You can achieve the same using macro swf_goto (same parameters as for swf_exclude).

Wizard Framework background information

Template source code is stored in include SBPT_WIZARD_PATTERN.

Wizard title is stored in text symbol TTL.

Wizard additions

Add step to existing wizard

There is no functionality to add new steps (screens) to an existing wizard this is why I created function Z_ZDB001_WZ_ADD_SCREENS.

Be aware that this function updates an existing module therefor use with great care.

This function will allow you to add an extra step to an existing wizard. The step will be added at the end just before the Finish step.

Text object will not be active when the function has finished. Start transaction SE61 and enter [function group]_[screen number] in the dialog text field press the <Change button> then  press <Activate> button to activate the step text and from now on the text can be changed from within the wizard (transaction SBPT_WB).

See also this blog by Puru Govind on how to change the Wizard at run-time.

Source code

Add step to a wizard created with the wizard framework (transaction SBPT_WB).

Import parameters

image

Export parameters

None

Changing parameters

None

Tables

None

Exceptions

image

Source code: Function Module


FUNCTION z_zdb001_wz_add_screens.

*”———————————————————————-

*”*”Local interface:

*”  IMPORTING

*”     VALUE(I_FUNC_GROUP) TYPE  AREA

*”     VALUE(I_SCREEN_NO) TYPE  SCRADNUM

*”     VALUE(I_STEP_TEXT) TYPE  SWF_WIZTXT

*”  EXCEPTIONS

*”      ERR_FUNC_GROUP_MISSING

*”      ERR_SCREEN_NR

*”———————————————————————-

*———————————————————————–

* text object will not be active when function has finished start

* transaction SE61 and enter [function group]_[screen number] in the

* dialog text field press the <Change button> then activate press

* <Activate> button to activate the dialog text from now on the text

* can be changed from within the wizard (transaction SBPT_WB)

*———————————————————————–

* declarations

  DATA:

    l_include_name   TYPE rglif-include,

    l_program        TYPE rglif-include,

    l_symbol_name    TYPE pt_symbol_name,

    t_tab            TYPE textpool OCCURS 50 WITH HEADER LINE,

    tb_source        TYPE STANDARD TABLE OF rssource,

    wa_source        TYPE rssource,

    l_index          TYPE sytabix,

    l_scr_nr(4)      TYPE n,

    l_text_nr(3)     TYPE n.            “number text element

* check input

  MOVE i_screen_no TO l_scr_nr.

  IF l_scr_nr < 20.

    MESSAGE ID ‘001’ TYPE ‘E’ NUMBER ‘000’

    WITH ‘Screen nr must be higher than 20’ RAISING err_screen_nr.

  ENDIF.

*———————————————————-   

* initialize

*———————————————————-   

* get namespace and function group

  IF i_func_group IS INITIAL.

*   top include missing

    RAISE err_func_group_missing.

  ELSE.

*   copy top include name

    p_wz_wizard_data-function_group = i_func_group.

  ENDIF.

* set function name   WZ_ZZDB002_TESTMM_START

  CONCATENATE ‘WZ_’ p_wz_wizard_data-function_group ‘_START’

         INTO p_wz_wizard_data-function.

* get function group data

  CALL FUNCTION ‘FUNCTION_INCLUDE_CONCATENATE’

       IMPORTING

            top                      = p_wz_wizard_data-top_include

       CHANGING

            group                    = p_wz_wizard_data-function_group

            namespace                = p_wz_wizard_data-namespace

            complete_area            = p_wz_wizard_data-complete_group

       EXCEPTIONS

            not_enough_input         = 1

            no_function_pool         = 2

            delimiter_wrong_position = 3

            OTHERS                   = 4.

  IF sy-subrc <> 0.

    p_subrc = sy-subrc.

    EXIT.

  ENDIF.

* set wizard title

  CONCATENATE p_wz_wizard_data-namespace ‘SAPL’

              p_wz_wizard_data-function_group

         INTO l_program.

* get existing text pool

  p_wz_wizard_data-title = ‘TEXT-TTL’.

*———————————————————————–

* set symbol replace indicators where the source code is to be added

* in the includes

*———————————————————————–

* include USR

  REFRESH: tb_source. CLEAR: wa_source.

* set include for usr subroutines

  CONCATENATE p_wz_wizard_data-namespace ‘L’

              p_wz_wizard_data-function_group ‘USR’

         INTO l_include_name.

* initialize source include L[function group name]USR

  READ REPORT l_include_name INTO tb_source.

* add line that will ensure that the new code is added

  wa_source-line = ‘*&WZ_PATTERN_USR_SCREEN_DATA&’.

  APPEND wa_source TO tb_source.

* update report

  INSERT REPORT l_include_name FROM tb_source.

* include FWZ

  REFRESH: tb_source. CLEAR: wa_source.

* set include for usr subroutines

  CONCATENATE p_wz_wizard_data-namespace ‘L’

              p_wz_wizard_data-function_group ‘FWZ’

         INTO l_include_name.

* initialize source include L[function group name]USR

  READ REPORT l_include_name INTO tb_source.

* delete indicators

  l_symbol_name = ‘*&WZ_PATTERN_WIZARD_STEPS_START&’.

  READ TABLE tb_source TRANSPORTING NO FIELDS

                      WITH KEY line = l_symbol_name.

  IF sy-subrc = 0.

*   entry was found get index for insert

    l_index = sy-tabix.

*   delete entry

    DELETE tb_source INDEX l_index.

  ENDIF.

  l_symbol_name = ‘*&WZ_PATTERN_WIZARD_STEPS_END&’.

  READ TABLE tb_source TRANSPORTING NO FIELDS

                      WITH KEY line = l_symbol_name.

 

IF sy-subrc = 0.

*   entry was found get index for insert

    l_index = sy-tabix.

*   delete entry

    DELETE tb_source INDEX l_index.

  ENDIF.

* add indicators

  l_symbol_name = ‘CB_PROCESS_STEP_FINISH’.

  LOOP AT tb_source INTO wa_source.

    IF wa_source-line CS l_symbol_name.

*     found it!

      l_index = sy-tabix.

    ENDIF.

  ENDLOOP.

  IF sy-subrc = 0.

*   get index

    l_index = l_index + 1.

*   get text element nr final step

    CLEAR: wa_source.

    READ TABLE tb_source INTO wa_source INDEX l_index.

    SHIFT wa_source-line UP TO ‘TEXT-‘.

    l_text_nr = wa_source-line+5(3).

*   set index for insert first indicator

    l_index = l_index – 2.

*   add line that will ensure that the new code is added

    wa_source-line = ‘*&WZ_PATTERN_WIZARD_STEPS_START&’.

    INSERT wa_source INTO tb_source INDEX l_index.

    l_index = l_index + 1.

*   add line that will ensure that the new code is added

    CLEAR: wa_source.

    wa_source-line = ‘*&WZ_PATTERN_WIZARD_STEPS_END&’.

    INSERT wa_source INTO tb_source INDEX l_index.

  ENDIF.

* update report

  INSERT REPORT l_include_name FROM tb_source.

*———————————————————————–

* initialize step (screen) to be added

*———————————————————————–

* initialize steps (make sure there are no existing screens in

* the internal table p_wz_wizard_data-steps)   

* main prg name function group

  CONCATENATE ‘SAPL’ p_wz_wizard_data-function_group

    INTO wa_wizard_step-program.

  CONCATENATE ‘CB_PROCESS_STEP_’ i_screen_no INTO wa_wizard_step-form.

  wa_wizard_step-text        = i_step_text.

* text object name

  CONCATENATE p_wz_wizard_data-function_group ‘_’ i_screen_no

    INTO wa_wizard_step-descobject.

  CONCATENATE ‘D’ p_wz_wizard_data-function_group

    INTO wa_wizard_step-desckey.

* step text (html)

  CONCATENATE p_wz_wizard_data-function_group ‘_’ i_screen_no

    INTO wa_wizard_step-docuobject.

  wa_wizard_step-subscreen   = i_screen_no.

  wa_wizard_step-subscrpool  = wa_wizard_step-program.

*  wa_wizard_step-screen_typ

*  wa_wizard_step-inactive

*  wa_wizard_step-mark

  APPEND wa_wizard_step TO p_wz_wizard_data-steps.

  CLEAR: wa_wizard_step.

*wz_wizard_step

*———————————————————-   

* insert textelements

*———————————————————-   

  PERFORM ut_progress_indicator IN PROGRAM saplsbpt_wizard_definition

          USING

             ‘Textelemente erzeugen …'(p01)

             15.

  PERFORM gn_insert_textpool

             USING l_text_nr

             CHANGING

                p_wz_wizard_data

                l_subrc.

  IF l_subrc <> 0.

    p_error = ‘X’.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    EXIT.

  ENDIF.

*———————————————————-   

* generate step definition

*———————————————————-   

  PERFORM ut_progress_indicator IN PROGRAM saplsbpt_wizard_definition

          USING

             ‘Schritt-Definition erzeugen …'(p03)

             30.

  PERFORM gn_insert_step_definition

  IN PROGRAM saplsbpt_wizard_definition

             USING

                p_wz_wizard_data

             CHANGING

                l_subrc.

  IF l_subrc <> 0.

    p_error = ‘X’.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    EXIT.

  ENDIF.

* generate callbacks

  PERFORM ut_progress_indicator IN PROGRAM saplsbpt_wizard_definition

          USING

             ‘CallBacks erzeugen …'(p04)

             40.

  PERFORM gn_insert_callbacks IN PROGRAM saplsbpt_wizard_definition

             USING

                p_wz_wizard_data

             CHANGING

                l_subrc.

  IF l_subrc <> 0.

    p_error = ‘X’.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    EXIT.

  ENDIF.

* generate user exits

  PERFORM ut_progress_indicator IN PROGRAM saplsbpt_wizard_definition

          USING

             ‘User-Includes erzeugen …'(p05)

             50.

  PERFORM gn_insert_user_exits

             USING

                p_wz_wizard_data

             CHANGING

                l_subrc.

  IF l_subrc <> 0.

    p_error = ‘X’.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    EXIT.

  ENDIF.

* generate subscreens

  PERFORM ut_progress_indicator IN PROGRAM saplsbpt_wizard_definition

          USING

             ‘Subscreens erzeugen …'(p06)

             70.

  PERFORM gn_insert_subscreens IN PROGRAM saplsbpt_wizard_definition

             USING

                p_wz_wizard_data

             CHANGING

                l_subrc.

  IF l_subrc <> 0.

    p_error = ‘X’.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    EXIT.

  ENDIF.

* generate documentation

  PERFORM ut_progress_indicator IN PROGRAM saplsbpt_wizard_definition

          USING

             ‘Dokumentation erzeugen …'(p07)

             80.

  PERFORM gn_insert_documentation IN PROGRAM saplsbpt_wizard_definition

             USING

                p_wz_wizard_data

                l_corr

             CHANGING

                l_subrc.

  IF l_subrc <> 0.

    p_error = ‘X’.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    EXIT.

  ENDIF.

* actualize program index

  PERFORM ut_progress_indicator IN PROGRAM saplsbpt_wizard_definition

          USING

             ‘Programmindex aktualisieren…'(p08)

             90.

  CONCATENATE ‘SAPL’ p_wz_wizard_data-function_group INTO l_progname.

  CALL FUNCTION ‘RS_PROGRAM_INDEX_ACTUALIZE’

       EXPORTING

            program = l_progname.

* activate function group

  l_object-object   = ‘FUGR’.

  l_object-obj_name = p_wz_wizard_data-function_group.

  APPEND l_object TO l_objects.

  CALL FUNCTION ‘RS_WORKING_OBJECTS_ACTIVATE’

       TABLES

            objects = l_objects

       EXCEPTIONS

            OTHERS  = 1.

  IF sy-subrc <> 0.

    p_error = ‘X’.

    MESSAGE ID sy-msgid TYPE ‘S’ NUMBER sy-msgno

            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

  ENDIF.

ENDFUNCTION.

To report this post you need to login first.

21 Comments

You must be Logged on to comment or reply to a post.

  1. Puru Govind
    Hey,
    Nice blog. I created a small wizard using this. But am having a problem at end. Actually I am collecting some information from the user all through the wizard. When the user presses “complete”, I need to display a pop up or something shopwing that collected data. If not popup can i show it in final screen of wizard only?

    regards
    Puru

    (0) 
  2. Srinivas Patchipulusu
    I have one doubt in wizards.
    Please tell me how to display dynamic variables in Complete screen .
    Suppose, if i have fields in screen 100 – Name and screen 200 – Address.
    Then how to display the values of the above fields in complete screen(Last Screen)
    (0) 
  3. Srinivas Patchipulusu
    I have one doubt in wizards.
    Please tell me how to display dynamic variables in Complete screen .
    Suppose, if i have fields in screen 100 – Name and screen 200 – Address.
    Then how to display the values of the above fields in complete screen(Last Screen)
    (0) 
    1. Dennis van den Broek Post author
      Hi Srinivas Patchipulusu,

      Thank you.

      You can always created a summary of all the values entered in the previous screens on your last screen in the Wizard. The values you enter in the screens are held in global variables (global within the function module group) so there for during each step in the wizard you have access to all the fields and values of the previous steps. This will enable you to create a summary on the last step (screen) of your wizard. I hope this answers your question.

      Regards,
      Dennis

      (0) 
  4. Sushma Machana
    Hi dennis,
    the info was real good, but i was wondering if you had any idea how we can use this for customizing.
    I am using the table maintenance generator tool for a table view to generate code into the same function group generated by the wizard. I am also making sure i use the same screens as those specified in the wizard.
    I was wondering if you knew what changes in the code i need to do to sync the two generated codes.

    Thanks in advance,
    Sushma

    (0) 
  5. Ajai J Valiathan

    Hi,

    Using Abap wizard for customizing, what should be done to get the popup that asks for a transport request(like in classic abap) for saving customizing entries? Now the data gets saved automatically. Please provide your input.

    Thanks

    (0) 
    1. Dennis van den Broek Post author

      It is not quite clear to me what you are developing and how it relates to the wizard. Could you give me some more details of what you are trying to achieve?  

      (0) 
  6. Ajai J Valiathan

    Hi Dennis,

    Thanks for your reply.

    We have a  requirement to replace a standard IMG screen with an Abap Wizard where user can enter data and on clicking on Wizard “Continue” button, user expects the popup dialog box asking for saving to a customizing transport request like the classic abap IMG. Here, the popup is not happening and based on the program we wrote for saving, it saves to DB without asking the Transport Request. Is there any API or FM that has to be called to enable this feature? Please provide your inputs.

    Thanks a lot

    (0) 
    1. Dennis van den Broek Post author

      Am I correct in understanding that you haven’t found an “exit” where you can alter the process of assigning a development object to a transport request?

      If so look for Business Add-Ins (SE18) or Enhancements (SMOD) alternatively you could always create your own enhancement. I hope this helps you further.

      (0) 
  7. Ajai J Valiathan

    Thank you for providing the FM name for creating Request. We are close to the solution.

    The exact requirement here is:

    Assume we have a Customizing Transport Request already created in the system.

    Now, when we enter new values in customizing and click on “Save”, usually a pop up dialog box comes(in classic abap environment) asking which Transport Request you want to save right?

    How we can achieve this functionality(to display the popup dialogue box asking which TR to save) in abap wizard? By default it does not ask for that in abap wizard.

    Please provide your input on this.

    Thanks a lot for your help,

    Best Regards,
    Ajai

    (0) 
    1. Dennis van den Broek Post author

      I think I begin to understand what you are developing. Correct me if I’m wrong.

      You are using the wizard to change customizing settings in your own custom created table.

      Have a look at the functions in function group SVIM. With these function you can maintain customizing tables. If you created your own table make sure it is a customizing table.

      You can also have a look at function group STRD especially the functions TR_OBJECTS_CHECK and TR_OBJECTS_INSERT.

      Sorry for not going into more detail but I am a bit stressed for time at the moment. Hope this helps you further.

      (0) 
    2. Dennis van den Broek Post author

      FYI.

      If you created your own (customizing) table with SE11 than select “C” for delivery class and select “Display/Maintenace allowed” in the “Delivery and maintenance” tab.

      In table maintenance generator ensure that “recording routine” radio button is set to “Standard recording routine”. Now when making changes to the table with SM30 the system will automatically ask for a transport request.

      (0) 
  8. Petra Bolli

    Hi,

    we are looking for a possibility using the wizard framework with a bigger/flexible screen or even to display it with fullscreen. Are there any possibilities?

    Thanks in advance,

    Petra

    (0) 
    1. Dennis van den Broek Post author

      Haven’t looked at this in great detail but here is some info that might help you further. 

      I think it is not possible with the framework as provided by SAP however you could perhaps make a copy and change the size of the main screen and allow resizing. Have a look at the screens in function group SWF2 here you should find the main screen of the wizard. As mentioned in the beginning haven’t looked at this in great detail so excuse me if I made a mistake in my answer. I hope you keep me informed on how you get on because it would make a nice addition to the current wizard framework. Success.

      (0) 

Leave a Reply