Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

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>

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.

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)

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.

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.

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

Export parameters

None

Changing parameters

None

Tables

None

Exceptions

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.

21 Comments