SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

User Exits In FI



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> FI
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Sun Nov 25, 2007 10:48 pm    Post subject: User Exits In FI Reply with quote

User Exits In FI

User Exits in FI are implemented again in a different manner to both standard user exits and user exits in SD. The user exits are available for Substitutions, Validations and Rules which are specified either in transaction OB28 (for rules), or OBBH (for substitutions).

There are 3 steps involved in setting up user exits in FI.

These are:

[list=]Creating the Module Pool and programming the user exit.
Specifying the Module Pool that will hold the user exits.
"Activating" the user exit.
[/list]

Creating The Module Pool.

SAP provide two programs that should be used to implement these user exits. These are RGGBS000 and RGGBR000 (for substitutions and rules respectively). The relevant program should be copied to a Z version of the program, ZRGGBR000 for example. The code in this module pool is like so:

Code:
PROGRAM RGGBR000 .
*---------------------------------------------------------------------*
*                                                                     *
*   Regeln: EXIT-Formpool for Uxxx-Exits                              *
*                                                                     *
*   This formpool is used by SAP for demonstration purposes only.     *
*                                                                     *
*   Note: If you define a new user exit, you have to enter your       *
*         user exit in the form routine GET_EXIT_TITLES.              *
*                                                                     *
*---------------------------------------------------------------------*
INCLUDE FGBBGD00.               "Data types


*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*
*    PLEASE INCLUDE THE FOLLOWING "TYPE-POOL"  AND "TABLES" COMMANDS  *
*        IF THE ACCOUNTING MODULE IS INSTALLED IN YOUR SYSTEM         *
*TYPE-POOLS: GB002. " TO BE INCLUDED IN
*TABLES: BKPF,      " ANY SYSTEM THAT
*        BSEG,      " HAS 'FI' INSTALLED
*        COBL,
*        GLU1.
*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*

*----------------------------------------------------------------------*
*       FORM GET_EXIT_TITLES                                           *
*----------------------------------------------------------------------*
*       returns name and title of all available standard-exits         *
*       every exit in this formpool has to be added to this form.      *
*       You have to specify a parameter type in order to enable the    *
*       code generation program to determine correctly how to          *
*       generate the user exit call, i.e. how many and what kind of    *
*       parameter(s) are used in the user exit.                        *
*       The following parameter types exist:                           *
*                                                                      *
*       TYPE                Description              Usage             *
*    ------------------------------------------------------------      *
*       C_EXIT_PARAM_NONE   Use no parameter         Subst. and Valid. *
*                           except B_RESULT                            *
*       C_EXIT_PARAM_CLASS  Use a type as parameter  Subst. and Valid  *
*----------------------------------------------------------------------*
*  -->  EXIT_TAB  table with exit-name and exit-titles                 *
*                 structure: NAME(5), PARAM(1), TITEL(60)
*----------------------------------------------------------------------*
FORM GET_EXIT_TITLES TABLES ETAB.

  DATA: BEGIN OF EXITS OCCURS 50,
          NAME(5)   TYPE C,
          PARAM     LIKE C_EXIT_PARAM_NONE,
          TITLE(60) TYPE C,
        END OF EXITS.
*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* PLEASE DELETE THE FIRST '*' FORM THE BEGINING OF THE FOLLOWING LINES *
*        IF THE ACCOUNTING MODULE IS INSTALLED IN YOUR SYSTEM:         *
   EXITS-NAME  = 'U101'.
   EXITS-PARAM = C_EXIT_PARAM_CLASS.
   EXITS-TITLE = TEXT-100.                 "Posting date check
   APPEND EXITS.

   EXITS-NAME  = 'U100'.
   EXITS-PARAM = C_EXIT_PARAM_NONE.        "Complete data used in exit.
   EXITS-TITLE = TEXT-101.                 "Posting date check
   APPEND EXITS.

* forms for SAP_EIS
   EXITS-NAME  = 'US001'.                  "single validation: only one
   EXITS-PARAM = C_EXIT_PARAM_NONE.        "data record used
   EXITS-TITLE = TEXT-102.                 "Example EIS
   APPEND EXITS.

   EXITS-NAME  = 'UM001'.                  "matrix validation:
   EXITS-PARAM = C_EXIT_PARAM_CLASS.       "complete data used in exit.
   EXITS-TITLE = TEXT-103.                 "Example EIS
   APPEND EXITS.

  REFRESH ETAB.
  LOOP AT EXITS.
    ETAB = EXITS.
    APPEND ETAB.
  ENDLOOP.

ENDFORM.

*eject
*----------------------------------------------------------------------*
*       FORM U100                                                      *
*----------------------------------------------------------------------*
*       Example of an exit for a boolean rule                          *
*       This exit can be used in FI for callup points 1,2 or 3.        *
*----------------------------------------------------------------------*
*  <--  B_RESULT    T = True  F = False                                *
*----------------------------------------------------------------------*
FORM U100  USING B_RESULT.
*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* PLEASE DELETE THE FIRST '*' FORM THE BEGINING OF THE FOLLOWING LINES *
*        IF THE ACCOUNTING MODULE IS INSTALLED IN YOUR SYSTEM:         *
*
*   IF SY-DATUM = BKPF-BUDAT.
*     B_RESULT  = B_TRUE.
*  ELSE.
*    B_RESULT  = B_FALSE.
*  ENDIF.

ENDFORM.

*eject
*----------------------------------------------------------------------*
*       FORM U101                                                      *
*----------------------------------------------------------------------*
*       Example of an exit using the complete data from one            *
*       multi-line rule.                                               *
*       This exit is intended for use from callup point 3, in FI.      *
*                                                                      *
*       If account 400000 is used, then account 399999 must be posted  *
*       to in another posting line.                                    *
*----------------------------------------------------------------------*
*  -->  BOOL_DATA   The complete posting data.                         *
*  <--  B_RESULT    T = True  F = False                                *
*----------------------------------------------------------------------*

*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* PLEASE DELETE THE FIRST '*' FORM THE BEGINING OF THE FOLLOWING LINES *
*        IF THE ACCOUNTING MODULE IS INSTALLED IN YOUR SYSTEM:         *
*FORM u101 USING    bool_data TYPE gb002_015
*          CHANGING B_RESULT.
*  DATA: B_ACC_400000_USED LIKE D_BOOL VALUE 'F'.
*
*  B_RESULT = B_TRUE.
** Has account 400000 has been used?
*  LOOP AT BOOL_DATA-BSEG INTO BSEG
*                 WHERE HKONT  = '0000400000'.
*     B_ACC_400000_USED = B_TRUE.
*     EXIT.
*  ENDLOOP.
*
** Check that account 400000 has been used.
*  CHECK B_ACC_400000_USED = B_TRUE.
*
*  B_RESULT = B_FALSE.
*  LOOP AT BOOL_DATA-BSEG INTO BSEG
*                 WHERE HKONT  = '0000399999'.
*     B_RESULT = B_TRUE.
*     EXIT.
* ENDLOOP.
*
*ENDFORM.

*eject
*----------------------------------------------------------------------*
*       FORM US001
*----------------------------------------------------------------------*
*       Example of an exit for a boolean rule in SAP-EIS
*       for aspect 001 (single validation).
*       one data record is transfered in structure CF<asspect>
*----------------------------------------------------------------------
*       Attention: for any FORM one has to make an entry in the
*       form GET_EXIT_TITLES at the beginning of this include
*----------------------------------------------------------------------*
*  <--  B_RESULT    T = True  F = False                                *
*----------------------------------------------------------------------*
FORM US001 USING B_RESULT.

*TABLES CF001.                                 "table name aspect 001
*
*  IF ( CF001-SPART = '00000001' OR
*       CF001-GEBIE = '00000001' ) AND
*       CF001-ERLOS >= '1000000'.
*
**   further checks ...
*
*    B_RESULT  = B_TRUE.
*  ELSE.
*
**   further checks ...
*
*    B_RESULT  = B_FALSE.
*  ENDIF.

ENDFORM.                                   "US001

*eject
*----------------------------------------------------------------------*
*       FORM UM001
*----------------------------------------------------------------------*
*       Example of an exit for a boolean rule in SAP-EIS
*       for aspect 001 (matrix validation).
*       Data is transfered in BOOL_DATA:
*       BOOL_DATA-CF<aspect> is intern table of structure CF<asspect>
*----------------------------------------------------------------------
*       Attention: for any FORM one has to make an entry in the
*       form GET_EXIT_TITLES at the beginning of this include
*----------------------------------------------------------------------*
*  <--  B_RESULT    T = True  F = False                                *
*----------------------------------------------------------------------*
FORM UM001 USING BOOL_DATA    "TYPE GB002_<boolean class of aspect 001>
           CHANGING B_RESULT.

*DATA: LC_CF001 LIKE CF001.
*DATA: LC_COUNT TYPE I.

*  B_RESULT = B_TRUE.
*  CLEAR LC_COUNT.
*  process data records in BOOL_DATA
*  LOOP AT BOOL_DATA-CF001 INTO LC_CF001.
*    IF LC_CF001-SPART = '00000001'.
*      ADD 1 TO LC_COUNT.
*      IF LC_COUNT >= 2.
**       division '00000001' may only occur once !
*        B_RESULT = B_FALSE.
*        EXIT.
*      ENDIF.
*    ENDIF.
*
**   further checks ....
*
*  ENDLOOP.
ENDFORM.                                      "UM001


The first thing to do is to insert code that notifies the calling programs of the availability of the user exits. This is achieved in the form GET_EXIT_TITLES.

Decide on the name for your user exit, which should start with 'U' (for a user defined user exit) and then a 3 digit unique number. Above the line 'REFRESH ETAB', make the following entries:

Code:
   EXITS-NAME  = 'U100'.
   EXITS-PARAM = C_EXIT_PARAM_NONE.        "Complete data used in exit.
   EXITS-TITLE = TEXT-101.                 "Posting date check
   APPEND EXITS.


The NAME field should contain the user exit name that you will be using.

The field PARAM defines the parameter type.

There are three values for this parameter, and are defined as constants:

C_EXIT_PARAM_NONE:

This constant means that no parameters are defined for this user exit. In truth, there is one parameter defined and that is a boolean flag that is used to specify whether there is an error in the data or not. A value of false for this parameter means that the data is valid(!) and a value of true means that there is an error.

This parameter is valid for rules, validations and substitutions.

C_EXIT_PARAM_FIELD:

This constant is valid for substitutions only and means that one parameter can be defined for the user exit which is the field to be sustituted.

C_EXIT_PARAM_CLASS

valid for Rules, Validations and Substitutions, this parameter signifies that all the data (BKPF and BSEG data) will be passed as one parameter to the user exit. You will be passed a table containing all the relevant information. Have a look at the routine U101 to see how to access this data.

The last thing to include before the append is a text sting which is used to display the title of the user exit in an upcoming transaction.

Creating your user exit

Once you've entered the above code into the right place in the form GET_EXIT_TITLES, it's time to write the user exit code itself. Base the form delcaration on the examples above, remembering to return b_true or b_false dependant on the result of your user exit. If you wish to display any messages in the user exit, make them informational ones. Any other types can cause problems with the correcting of fields otherwise. Don't forget to activate the changes.

Specifying the module pool that holds the user exits.

Having written the user exit code, you must now activate that code. This is not the same as activating a program. What you are doing here is telling SAP that there is code available and this is where it lives.

Start transaction GCX2. This will then display a screen similar to the one shown here:



Change the screen into change mode by clicking this pencil as normal, and then enter the module pool name that you created in the steps above into the Ex. Prog Field.

Save the changes and exit.

"Activating" the User Exit.

The next thing to do is to incorporate your user exit code into a validation rule. Start transaction OB28.



Select 'New Entries', and complete the input fields. (How to define the validation name is forth coming).

Select the rule that you wish the user exit to be activated for (Note that these activations are company dependant).



Your user exit will appear essentially as a boolean variable in the rule that you have selected (or created). In the relevant step enter the user exit name either as part of a condition statement or on it's own. In the example below the user exit is called U102.

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> FI All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.