Download Android App of sapabap-vamsi

sapabap-vamsi : Download Android App for Mobiles

Thursday, May 10, 2012

Convert internal table data into HTML format without using Function Modules


The output of this Tutorial is same as previous one but in this we are not using any function modules to convert internal table data to HTML table.
*&----------------------------------------------------------------*
*& Report  YTEST_TABLE_HTML1
*&
*&----------------------------------------------------------------*
REPORT  ytest_table_html1.
*----------------------------------------------------------------*
*        D A T A   D E C L A R A T I O N
*----------------------------------------------------------------*
*-HTML Table
DATA:
  t_html TYPE STANDARD TABLE OF w3html WITH HEADER LINE,
                                       " Html Table
*- Declare Internal table and Fieldcatalog
  it_flight TYPE STANDARD TABLE OF sflight WITH HEADER LINE,
                                       " Flights Details
  it_fcat TYPE lvc_t_fcat WITH HEADER LINE.
                                       " Fieldcatalog
*-Variables
DATA:
  v_lines TYPE i,
  v_field(40).
*-Fieldsymbols
FIELD-SYMBOLS: <fs> TYPE ANY.
*----------------------------------------------------------------*
*        S T A R T - O F - S E L E C T I O N
*----------------------------------------------------------------*
START-OF-SELECTION.
  SELECT *
    FROM sflight
    INTO TABLE it_flight
    UP TO 20 ROWS.
*----------------------------------------------------------------*
*        E N D - O F - S E L E C T I O N
*----------------------------------------------------------------*
END-OF-SELECTION.
*-Fill the Column headings and Properties
* Field catalog is used to populate the Headings and Values of 
* The table cells dynamically 
  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
    EXPORTING
      i_structure_name       = 'SFLIGHT'
    CHANGING
      ct_fieldcat            = it_fcat[]
    EXCEPTIONS
      inconsistent_interface = 1
      program_error          = 2.
  DELETE it_fcat WHERE fieldname = 'MANDT'.
  t_html-line = '<html>'.
  APPEND t_html.
  CLEAR t_html.
  t_html-line = '<thead>'.
  APPEND t_html.
  CLEAR t_html.
  t_html-line = '<tr>'.
  APPEND t_html.
  CLEAR t_html.
  t_html-line = '<td><h1>Flights Details</h1></td>'.
  APPEND t_html.
  CLEAR t_html.
  t_html-line = '</tr>'.
  APPEND t_html.
  CLEAR t_html.
  t_html-line = '</thead>'.
  APPEND t_html.
  CLEAR t_html.
  t_html-line = '<table border = "1">'.
  APPEND t_html.
  CLEAR t_html.
  t_html-line = '<tr>'.
  APPEND t_html.
  CLEAR t_html.
*-Populate HTML columns from Filedcatalog
  LOOP AT it_fcat.
    CONCATENATE '<th bgcolor = "green" fgcolor = "black">'
        it_fcat-scrtext_l
        '</th>' INTO t_html-line.
    APPEND t_html.
    CLEAR t_html.
  ENDLOOP.
  t_html-line = '</tr>'.
  APPEND t_html.
  CLEAR t_html.
  DESCRIBE TABLE it_fcat LINES v_lines.
*-Populate HTML table from Internal table data
  LOOP AT it_flight.
    t_html-line = '<tr>'.
    APPEND t_html.
    CLEAR t_html.
*-Populate entire row of HTML table Dynamically
*-With the Help of Fieldcatalog.
    DO v_lines TIMES.
      READ TABLE it_fcat INDEX sy-index.
      CONCATENATE 'IT_FLIGHT-' it_fcat-fieldname INTO v_field.
      ASSIGN (v_field) TO <fs>.
      t_html-line = '<td>'.
      APPEND t_html.
      CLEAR t_html.
      t_html-line = <fs>.
      APPEND t_html.
      CLEAR t_html.
      t_html-line = '</td>'.
      APPEND t_html.
      CLEAR t_html.
      CLEAR v_field.
      UNASSIGN <fs>.
    ENDDO.
    t_html-line = '</tr>'.
    APPEND t_html.
    CLEAR t_html.
  ENDLOOP.
  t_html-line = '</table>'.
  APPEND t_html.
  CLEAR t_html.
*-Download  the HTML into frontend
  CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      filename                = 'C:\Flights.htm'
    TABLES
      data_tab                = t_html
    EXCEPTIONS
      file_write_error        = 1
      no_batch                = 2
      gui_refuse_filetransfer = 3
      invalid_type            = 4
      no_authority            = 5
      unknown_error           = 6
      header_not_allowed      = 7
      separator_not_allowed   = 8
      filesize_not_allowed    = 9
      header_too_long         = 10
      dp_error_create         = 11
      dp_error_send           = 12
      dp_error_write          = 13
      unknown_dp_error        = 14
      access_denied           = 15
      dp_out_of_memory        = 16
      disk_full               = 17
      dp_timeout              = 18
      file_not_found          = 19
      dataprovider_exception  = 20
      control_flush_error     = 21
      OTHERS                  = 22.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
*-Display the HTML file
  CALL METHOD cl_gui_frontend_services=>execute
    EXPORTING
      document               = 'C:\Flights.htm'
      operation              = 'OPEN'
    EXCEPTIONS
      cntl_error             = 1
      error_no_gui           = 2
      bad_parameter          = 3
      file_not_found         = 4
      path_not_found         = 5
      file_extension_unknown = 6
      error_execute_failed   = 7
      synchronous_failed     = 8
      not_supported_by_gui   = 9
      OTHERS                 = 10.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
Result:   


Monday, May 7, 2012

ABAP Performance Standards


Following are the performance standards need to be following in writing ABAP programs:
1.      Unused/Dead code
Avoid leaving unused code in the program. Either comment out or delete the unused situation. Use program --> check --> extended program to check for the variables, which are not used statically. 
2.      Subroutine Usage
For good modularization, the decision of whether or not to execute a subroutine should be made before the subroutine is called. For example:  
This is better:
IF f1 NE 0.
  PERFORM sub1.
ENDIF. 
FORM sub1.
  ...
ENDFORM.  
Than this:
PERFORM sub1.
FORM sub1.
  IF f1 NE 0.
    ...
  ENDIF.
ENDFORM. 
3.      Usage of IF statements
When coding IF tests, nest the testing conditions so that the outer conditions are those which are most likely to fail. For logical expressions with AND , place the mostly likely false first and for the OR, place the mostly likely true first. 
Example - nested IF's:
  IF (least likely to be true).
    IF (less likely to be true).
     IF (most likely to be true).
     ENDIF.
    ENDIF.
   ENDIF. 
Example - IF...ELSEIF...ENDIF :
  IF (most likely to be true).
  ELSEIF (less likely to be true).
  ELSEIF (least likely to be true).
  ENDIF. 
Example - AND:
   IF (least likely to be true) AND
      (most likely to be true).
   ENDIF.
Example - OR:
        IF (most likely to be true) OR
      (least likely to be true). 
4.      CASE vs. nested Ifs
When testing fields "equal to" something, one can use either the nested IF or the CASE statement. The CASE is better for two reasons. It is easier to read and after about five nested IFs the performance of the CASE is more efficient. 
5.      MOVE statements
When records a and b have the exact same structure, it is more efficient to MOVE a TO b than to  MOVE-CORRESPONDING a TO b.
 MOVE BSEG TO *BSEG.
is better than
 MOVE-CORRESPONDING BSEG TO *BSEG. 
6.      SELECT and SELECT SINGLE
When using the SELECT statement, study the key and always provide as much of the left-most part of the key as possible. If the entire key can be qualified, code a SELECT SINGLE not just a SELECT.   If you are only interested in the first row or there is only one row to be returned, using SELECT SINGLE can increase performance by up to three times. 
7.      Small internal tables vs. complete internal tables

In general it is better to minimize the number of fields declared in an internal table.  While it may be convenient to declare an internal table using the LIKE command, in most cases, programs will not use all fields in the SAP standard table. 
For example:
Instead of this:
data:  t_mara like mara occurs 0 with header line.
Use this:
data: begin of t_mara occurs 0,
        matnr like mara-matnr,
        ...
        end of t_mara. 
8.      Row-level processing and SELECT SINGLE
Similar to the processing of a SELECT-ENDSELECT loop, when calling multiple SELECT-SINGLE commands on a non-buffered table (check Data Dictionary -> Technical Info), you should do the following to improve performance: 
o       Use the SELECT into <itab> to buffer the necessary rows in an internal table, then
o       sort the rows by the key fields, then 
o       use a READ TABLE WITH KEY ... BINARY SEARCH in place of the SELECT SINGLE command. Note that this only make sense when the table you are buffering is not too large (this decision must be made on a case by case basis).
9.      READing single records of internal tables
When reading a single record in an internal table, the READ TABLE WITH KEY is not a direct READ.  This means that if the data is not sorted according to the key, the system must sequentially read the table.   Therefore, you should:
o       SORT the table
o       use READ TABLE WITH KEY BINARY SEARCH for better performance. 
10.  SORTing internal tables
When SORTing internal tables, specify the fields to SORTed.
SORT ITAB BY FLD1 FLD2.
 is more efficient than
SORT ITAB.  
11.  Number of entries in an internal table
To find out how many entries are in an internal table use DESCRIBE.
DESCRIBE TABLE ITAB LINES CNTLNS.
 is more efficient than
LOOP AT ITAB.
  CNTLNS = CNTLNS + 1.
ENDLOOP. 
12.  Performance diagnosis
To diagnose performance problems, it is recommended to use the SAP transaction SE30, ABAP/4 Runtime Analysis. The utility allows statistical analysis of transactions and programs. 
13.  Nested SELECTs versus table views
Since releASE 4.0, OPEN SQL allows both inner and outer table joins.  A nested SELECT loop may be used to accomplish the same concept.  However, the performance of nested SELECT loops is very poor in comparison to a join.  Hence, to improve performance by a factor of 25x and reduce network load, you should either create a view in the data dictionary then use this view to select data, or code the select using a join. 
14.  If nested SELECTs must be used
As mentioned previously, performance can be dramatically improved by using views instead of nested SELECTs, however, if this is not possible, then the following example of using an internal table in a nested SELECT can also improve performance by a factor of 5x:
Use this:
form select_good.
  data: t_vbak like vbak occurs 0 with header line.
  data: t_vbap like vbap occurs 0 with header line.
  select * from vbak into table t_vbak up to 200 rows.
  select * from vbap
          for all entries in t_vbak
          where vbeln = t_vbak-vbeln.
    ...
  endselect.
endform.
Instead of this:
form select_bad.
 select * from vbak up to 200 rows.
  select * from vbap where vbeln = vbak-vbeln.
      ...
  endselect.
 endselect.
endform.
Although using "SELECT...FOR ALL ENTRIES IN..." is generally very fast, you should be aware of the three pitfalls of using it:
Firstly, SAP automatically removes any duplicates from the rest of the retrieved records.  Therefore, if you wish to ensure that no qualifying records are discarded, the field list of the inner SELECT must be designed to ensure the retrieved records will contain no duplicates (normally, this would mean including in the list of retrieved fields all of those fields that comprise that table's primary key).
Secondly,  if you were able to code "SELECT ... FROM <database table> FOR ALL ENTRIES IN TABLE <itab>" and the internal table <itab> is empty, then all rows from <database table> will be retrieved.
Thirdly, if the internal table supplying the selection criteria (i.e. internal table <itab> in the example "...FOR ALL ENTRIES IN TABLE <itab> ") contains a large number of entries, performance degradation may occur. 
15.  SELECT * versus SELECTing individual fields
In general, use a SELECT statement specifying a list of fields instead of a SELECT * to reduce network traffic and improve performance.  For tables with only a few fields the improvements may be minor, but many SAP tables contain more than 50 fields when the program needs only a few.  In the latter case, the performace gains can be substantial.  For example:
Use:
select vbeln auart vbtyp from table vbak
  into (vbak-vbeln, vbak-auart, vbak-vbtyp)
  where ...
Instead of using:
select * from vbak where ... 
16.  Avoid unnecessary statements
There are a few cases where one command is better than two.  For example:
Use:
append <tab_wa> to <tab>.
Instead of:
<tab> = <tab_wa>.
append <tab> (modify <tab>).
And also, use:
if not <tab>[] is initial.
Instead of:
describe table <tab> lines <line_counter>.
if <line_counter> > 0. 
17.  Copying or appending internal tables
Use this: 
<tab2>[] = <tab1>[].  (if <tab2> is empty)
Instead of this:
loop at <tab1>.
  append <tab1> to <tab2>.
endloop.
However, if <tab2> is not empty and should not be overwritten, then use:
append lines of <tab1> [from index1] [to index2] to <tab2>.

Wednesday, May 2, 2012

MESSAGE xxxx RAISING xxxx


In general, exceptions in a function module are handled by means of RAISE EXCEPTION. This sets a return code which is passed back to the calling program. 
For eg., let us consider an example of a function module SXXXX, which would create a purchase order with reference to a Purchase Requisition. The import parameter for this function module is Purchase Requisition number and the export parameter is the Purchase Order number created here. Assume that after a PR is created, a material is moved from one plant to another. Now during the PO creation, because of this mismatch the PO would not be created.  
In a normal case, if there is any mismatch, we generally use RAISE EXCEPTION XXXX. This would stop the function module from further processing and returns to the calling program with just the return code. But the calling program would never know the material number that caused this error.  
Now, instead of raising the exception using RAISE EXCEPTION, we would use the following statement:  
MESSAGE E309(06) with ‘xxx’ Raising XXXX.  
Using the above statement is similar to the usage of RAISE EXCEPTION, except for:
  • If the call to the function module does not handle EXCEPTIONS, then the message is issued (in this case the error message is issued)
  • If the calling program handles the exception, then no message is issued. The calling program would have the message details in the standard message variables SY-MSGID, SY-MSGV1 and others. So in our case, the calling program would have the information about the material and plant combination that triggered the exception.

Sunday, April 22, 2012

Demo on using Table Control

*&---------------------------------------------------------------------*
*& Report  Z_DB_TABLECONTROL                                           *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*
REPORT  Z_DB_TABLECONTROL.
TABLES: MARA.
CONTROLS MATERIAL TYPE TABLEVIEW USING SCREEN 130.
TYPES: BEGIN OF ST_MARA,
       MATNR TYPE MARA-MATNR,
       ERSDA TYPE MARA-ERSDA,
       ERNAM TYPE MARA-ERNAM,
       LAEDA TYPE MARA-LAEDA,
       END OF ST_MARA.
DATA: IT_ST TYPE TABLE OF ST_MARA,
      WA_ST TYPE ST_MARA,
      IT_MARA TYPE MARA,
      WA_MARA TYPE MARA,
      OK_CODE LIKE SY-UCOMM.
CALL SCREEN 130.
*&---------------------------------------------------------------------*
*&      Module  V1  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE V1 INPUT.
CASE OK_CODE.
WHEN 'SAVE'.
WA_ST-MATNR = MARA-MATNR.
WA_ST-ERSDA = MARA-ERSDA.
WA_ST-ERNAM = MARA-ERNAM.
WA_ST-LAEDA = MARA-LAEDA.
MOVE-CORRESPONDING WA_ST TO WA_MARA.
INSERT INTO MARA VALUES WA_MARA.
WHEN 'DELETE'.
WA_ST-MATNR = MARA-MATNR.
WA_ST-ERSDA = MARA-ERSDA.
WA_ST-ERNAM = MARA-ERNAM.
WA_ST-LAEDA = MARA-LAEDA.
MOVE-CORRESPONDING  WA_ST TO WA_MARA.
DELETE MARA FROM WA_MARA.
WHEN 'MODIFY'.
WA_ST-MATNR = MARA-MATNR.
WA_ST-ERSDA = MARA-ERSDA.
WA_ST-ERNAM = MARA-ERNAM.
WA_ST-LAEDA = MARA-LAEDA.
MOVE-CORRESPONDING  WA_ST TO WA_MARA.
MODIFY MARA FROM WA_MARA.
ENDCASE.
ENDMODULE.                 " V1  INPUT
*&---------------------------------------------------------------------*
*&      Module  EXIT  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE EXIT INPUT.
IF OK_CODE = 'EXIT'.
LEAVE PROGRAM.
ENDIF.
ENDMODULE.                 " EXIT  INPUT
Create a screen by number 130 and provide the following attributes: 
 
LAYOUT:
 
ELEMENT LIST:
 
FLOW LOGIC.
 
EXECUTE: 

Wednesday, April 18, 2012

Wizard creation in SAP


Pre-requisites:
The readers must have the knowledge on basic ABAP programming.  
Purpose of this tutorial:
This tutorial demonstrates how to create a wizard to do a step by step job in SAP.
Introduction:
Wizard is a tool that guides a user to do a certain task in SAP step by step. The real time example of a wizard is the one, which guides us while installing any software in our systems. The following function modules play vital role in wizard customization.  
ü  SWF_WIZARD_CALL
ü  SWF_WIZARD_DIALOG_DATA_GET
ü  SWF_WIZARD_DIALOG_DATA_SET
ü  SWF_WIZARD_DIALOG_MODIFY
ü  SWF_WIZARD_DIALOG_OKCODE_GET
ü  SWF_WIZARD_DIALOG_OKCODE_SET
ü  SWF_WIZARD_DIALOG_REFRESH
ü  SWF_WIZARD_PROCESS
ü  SWF_WIZARD_PROCESS_INTERNAL
ü  SWF_WIZARD_PROCESS_MODIFY
ü  SWF_WIZARD_PROCESS_READ  
Have a look the following flow chart, for which we are going to build in wizard.
  
Step 1 : Create a program with three screens:  
  
First screen to get two numbers as input with two radio buttons of arithmetic operations(Add/Subtract).
  
Second screen to show the addition result.
  
Third screen to show the subtraction result.
  
All these screens should be “subscreens”. So that they can be placed in wizard.  
Step 2 : Wizard title and description creation:  
To have wizard title and description in every screen of wizard, we need to create document text object. Go to transaction SE61 and create a dialog text object.
  
Create the title with a brief description, save and activate.  


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
Sample output:  
Execute the example program. The wizard is started.
  
Input two numbers and select one of arithmetic operations.
  
Result screen appears according to the arithmetic input.
  
The wizard is ended.
  
Summary:
As a result of this tutorial, the reader will be able to create SAP wizard with dynamic screens.