Designing SAP Transactions
Content
Introduction
SAP Dynpros
Screen Elements, Fields and Layouts
Flow Logic
Example Transaction Code
Example - Define Screens
Example - Write Flow Logic
Example - PBO
Example - PAI
Example - Forms
Example - Validating Fields
Example - Variable Declarations
Assigning Transaction Codes
  Designing SAP Transactions
-Example - Forms-
 
Page 10 Of 13
 

Code the Forms

Double click on the form to create the object in the subprogram MZTRYF01. This subprogram will contain all the forms that we are coding for the transaction, to make the program modular.

Now we are in a position to code the respective forms to give a final shape to our transaction. 

MZTRYF01 

Form check_emp_exist.

  Clear v_empno.

  Move ztryemp-empno to v_empno.

  Clear ztryemp.

  Select single * from ztryemp where empno = v_empno.

  If sy-subrc ne 0.

     Clear v_emp_exist.

  Else.

     Clear ztrytxn.

     Select * up to 1 rows from ztrytxn where empno = v_empno.

     Endselect.

     Move : ztrytxn-valfr to v_date,

                C_x to v_emp_exist.

  Endif.

Endform.

 

Form move_values.

  Clear : t_ztryermp, t_ztrytxn.

  Move-corresponding ztryemp to t_ztryemp.

  Move-corresponding ztrytxn to t_ztrytxn.

  Move-corresponding ztryemp to t_ztrytxn.

  Move v_date to t_ztrytxn-valfr.

Endform.

 

Form lock_table.

  Call function ‘ENQUEUE_EZTRYEMP’

      Exporting

         Mode_ztryemp = ‘X’

         Empno = ztryemp-empno

         X_empno = ‘  ‘

         _scope = ‘2’

         _wait = ‘  ‘

         collect = ‘  ‘

      exception

        foreign_lock = 1

        system_failure = 2

        others = 3.

  If sy-subrc eq 0.

      Call function ‘ENQUEUE_EZTRYTXN’

      Exporting

         Mode_ztrytxn = ‘X’

         Empno = ztryemp-empno

         Valfr = v_date

         X_valfr = ‘  ‘

         _scope = ‘2’

         _wait = ‘  ‘

         collect = ‘  ‘

      exception

        foreign_lock = 1

        system_failure = 2

        others = 3.

     If sy-subrc ne 0.

        Message id sy-msgid type sy-msgty number sy-msgno with sy-msgv1 sy-   

       msgv2 sy-msgv3 sy-msgv4.

    Endif.

 Else.

       Message id sy-msgid type sy-msgty number sy-msgno with sy-msgv1 sy-   

       msgv2 sy-msgv3 sy-msgv4.

 Endif.

Endform.

 

Form change_dbase.

  Modify ztryemp from t_ztryemp.

  Modify ztrytxn from t_ztrytxn.

  Commit work.

Endform.

 

Form insert_dbase.

  Insert into ztryemp values t_ztryemp.

  Insert into ztrytxn values t_ztrytxn.

  Commit work.

Endform.

 

Form delete_dbase.

  Delete ztryemp from t_ztryemp.

  Delete ztrytxn from t_ztrytxn.

  Commit work.

Endform.

 

Form unlock_table.

  Call function ‘DEQUEUE_EZTRYEMP’

      Exporting

         Mode_ztryemp = ‘X’

         Empno = ztryemp-empno

         X_empno = ‘  ‘

         _scope = ‘3’

         _synchron = ‘  ‘

         collect = ‘  ‘.

 

  Call function ‘DEQUEUE_EZTRYTXN’

      Exporting

         Mode_ztrytxn = ‘X’

         Empno = ztryemp-empno

         Valfr = v_date

         X_empno = ‘  ‘

         X_valfr = ‘  ‘

         _scope = ‘3’

         _synchron = ‘  ‘

         collect = ‘  ‘.

Endform.

 

Now we will write the code for validating each field of the screen 200.

 
Stats Box
Vendor Listings (9)
Jobs (3)
Resumes (3)
Tutorials (18)
Articles (22)
Code Snippets (1)
CBTs (17)
Books (4)
Online Training (15)
Latest 5 Tutorial
SAPscript
SAP Mobile Engine
Integrating XML into SAP Business Connector
Lotus Notes Integration
SAP Data Archiving
 
Copyright © 2007 SapDox.com. All rights Reserved.