第 176 页 / 共 275 页
8 Validation and Substitution of Accounting Documents
navigate directly to the maintenance of messages via the pencil icon on the
right-hand side of the message class. Highlight a free message number, and
click Individual Maintenance.
8. Enter the text for the message, for example, “Please enter a sort key!” Save the
change, and navigate via Back ([F3]) again to the Check section. You can also
perform the message maintenance directly in Transaction SE91.
9. Enter the message number in the respective field of the validation. Leave the
message type as an error message. You can only display warning messages
when required. The additional transfer of message variables with additional
information is possible here.
10. Click again on your step in the left-hand bar, and save your changes. The step
should now appear as in Figure 8.3.
Figure 8.3 Example of a Validation
11. You must still activate the validation so that it will actually run. Switch back to
the initial screen of the validation (Transaction OB28). When you’ve created
the validation, the right-hand column Degree of Activation is still empty. In
this case, the validation is not executed. Change the degree of activation to 1
176
© 2013 by Galileo Press Inc., Boston (MA)
第 177 页 / 共 275 页
Validation of Accounting Documents 8.1
to fundamentally run the validation. With the degree of activation 2, the vali-
dation is activated but is bypassed for batch input.
12. As an example, if you now enter an incoming invoice with a purchase order
reference with Transaction MIRO, you must enter a text for each item starting
with OS; otherwise, you receive an error message.
8.1.4 Example with Exit Routine
For simple checks, the variant already mentioned in Section 8.1.3, Example with-
out Exit Routine, is sufficient. Let’s now assume that you want to enhance the
check from the previous example so that only classification keys can still be used
that have been defined in a custom table. This means that you must execute a
database query. This is only possible via an exit routine. To use exit routines, you
must first recall some basics.
Exit routines for validation or substitution are form routines that are stored in a
specific program. The program is maintained in the Customizing Table T80D (see
Figure 8.4). One program is stored here for each work area (type Module pool)
that includes exit routines. The work area is relevant for the validation GBLR. The
program RGGBR000 is stored here in the standard. If you want to store custom form
routines, you must copy the program RGGBR000, for example, to ZGGBR000, and
change the entry accordingly in Table T80D.
Figure 8.4 Assignment of the Programs for Work Areas
177
Personal Copy for Yang Meteor, user id a8103f58-81fe-4f49-acf6-cfb58959c618
第 178 页 / 共 275 页
8 Validation and Substitution of Accounting Documents
You implement the example by using an exit routine with the following steps:
1. If nothing has happened yet in your system, copy the program RGGBR000 to
your namespace, and change the entry for the work area GBLR in Table T80D.
2. Two steps are necessary to enhance the program with a new exit routine. First,
the new routine must be created. User routines should always start with U, and
use a three-digit number. The basic framework for such a routine is shown in
Listing 8.2.
*-------------------------------------------------------------
* Validation Exit
*------------------------------------------------------------*
* <-B_RESULT T = True F = False *
*------------------------------------------------------------*
FORM u900 USING b_result.
ENDFORM.
Listing 8.2 Standard Framework for Exit Routines in the Validation
3. Next, this exit routine must be announced to the validation. For this, there is a
predefined form called get_exit_titles. in the program ZGGBR000. This form
returns an internal Table ETAB with all defined form routines. This table is filled
from the uniform internal Table EXITS. You can fill these as follows:
exits-name = ‘U900’.
exits-param = c_exit_param_none.
exits-title = text-900.
APPEND exits.
You fill the field NAME with the name of the form routine; the field TITLE con-
tains a descriptive text. If you use a text element (TEXT-###) for this, this text
can be created in several languages. You ultimately fill the field PARAM with one
of the three possible variants of the interface for the form routine. You can
always work with the constant for the validation C_EXIT_PARAM_NONE (see Table
8.2).
4. Edit your previously defined program. Create a new, still empty form routine,
as described earlier. Enhance the form get_exit_titles to return the name of
your new form.
178
© 2013 by Galileo Press Inc., Boston (MA)
第 179 页 / 共 275 页
Validation of Accounting Documents 8.1
Parameter Type/Constant Description
C_EXIT_PARAM_NONE The form routine (besides B_RESULT) does not
contain any other parameters.
C_EXIT_PARAM_FIELD The form routine uses an additional field that
is to be changed (in substitution).
C_EXIT_PARAM_CLASS All data is handled as a parameter. This exit
type can only be used in matrix validations or
substitutions.
Table 8.2 Parameter Types for Exit Routines
5. The check is executed using a database table. For this, create a table in the ABAP
Dictionary (Transaction SE11). You can view a simple example of this in Figure
8.5. Next, maintain the table, and create some entries that start with OS.
Figure 8.5 Database Table ZORGSCHL for Validation
6. Now you can program the new exit routine. Check whether the content of
the entered item text (BSEG-SGTXT) in the previously defined table has been
entered. If this is the case, set B_RESULT to True (T); if not, set it to False (F). To
access BSEG, you need to announce this structure via a TABLES command. You
can find some commented lines on this at the beginning of the report, which
you can simply activate.
179
Personal Copy for Yang Meteor, user id a8103f58-81fe-4f49-acf6-cfb58959c618
| Parameter Type/Constant | Description |
|---|---|
| C_EXIT_PARAM_NONE | The form routine (besides B_RESULT) does not contain any other parameters. |
| C_EXIT_PARAM_FIELD | The form routine uses an additional field that is to be changed (in substitution). |
| C_EXIT_PARAM_CLASS | All data is handled as a parameter. This exit type can only be used in matrix validations or substitutions. |
第 180 页 / 共 275 页
8 Validation and Substitution of Accounting Documents
Although a document contains several items, you must view the exit BSEG as a
structure. The exit is called several times when the document is updated, once
for each item. BSEG contains the respective item in each case. In Listing 8.3, you
can find a complete program with the new exit routine taken from the
example.
PROGRAM zggbr000.
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 *
*------------------------------------------------------------*
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.
exits-name = ‘U900‘.
exits-param = c_exit_param_none.
exits-title = text-900.
APPEND exits.
REFRESH etab.
LOOP AT exits.
etab = exits.
APPEND etab.
180
© 2013 by Galileo Press Inc., Boston (MA)
第 181 页 / 共 275 页
Validation of Accounting Documents 8.1
ENDLOOP.
ENDFORM. “GET_EXIT_TITLES
*-------------------------------------------------------------
* Validation Exit
*------------------------------------------------------------*
* <-- B_RESULT T = True F = False *
*------------------------------------------------------------*
FORM u900 USING b_result.
DATA ls_zorgschl TYPE zorgschl.
SELECT SINGLE * FROM zorgschl INTO ls_zorgschl
WHERE orgschl = bseg-sgtxt.
IF sy-subrc = 0.
b_result = ‘T‘.
ELSE.
b_result = ‘F‘.
ENDIF.
ENDFORM.
Listing 8.3 Exit Form Pool for the Validation (Extract from the Program ZGGBR000)
7. Restart Transaction OB28 if applicable. Otherwise, the new exit routine is still
unknown. Switch to the validation and to the step that you created in Section
8.1.3, Example without Exit Routine. Then click Check to switch there.
8. Switch again to the expert mode, and delete the checks created in the previous
example. Now simply write the name of the exit routine, for example, U900, in
the formula editor. Alternatively, you can switch to the Exits tabstrip, and copy
the routine U900 by double-clicking.
9. Now test the entry of an incoming invoice again via Transaction MIRO. You
must now store a text in the items that is created in Table ZORGSCHL; otherwise,
you receive the defined error message.
Tip
You may use exit routines both in validation and in substitution as a prerequisite.
You therefore have a very flexible option to control the execution of a step. Here,
you work again with the return value B_RESULT that you fill either with T (True, the
prerequisite is fulfilled) or F (False, the prerequisite is not fulfilled).
181
Personal Copy for Yang Meteor, user id a8103f58-81fe-4f49-acf6-cfb58959c618
| Tip |
|---|
| You may use exit routines both in validation and in substitution as a prerequisite. You therefore have a very flexible option to control the execution of a step. Here, you work again with the return value B_RESULT that you fill either with T (True, the prerequisite is fulfilled) or F (False, the prerequisite is not fulfilled). |
第 182 页 / 共 275 页
8 Validation and Substitution of Accounting Documents
8.2 Substitution of Accounting Documents
Substitution allows the replacement of some fields of the accounting document
during its posting. Substitution is in many respects very similar to validation. For
this reason, you should definitely take a look at Section 8.1, Validation of Account-
ing Documents, because not all of the basics are repeated here. You should already
understand the concept of times and steps, in particular (see Section 8.1.1, Callup
Point, and 8.1.2, Steps).
You access the substitution via Transaction OBBH. With the validation, you can
create a substitution for each company code and callup point. Each substitution
is divided into steps that are processed in sequence. The steps themselves in turn
consist of a prerequisite and the substitution itself. You can no longer display error
messages here. Substitution doesn’t include a Messages section (see Figure 8.6).
Figure 8.6 Step Overview of a Substitution
Which Fields Are Available in Substitution?
The interchangeable fields can be controlled via Table GB01. All fields from the docu-
ment header and document item can be substituted; that is, they can be overwritten
with new values, which are assigned in Table GB01 of the Boolean class (refer to Table
8.1), and haven’t been explicitly excluded from this via the field BEXCLUDE.
You can display the content of the table with the following selection parameters:
182
© 2013 by Galileo Press Inc., Boston (MA)
| Which Fields Are Available in Substitution? |
|---|
| The interchangeable fields can be controlled via Table GB01. All fields from the docu- ment header and document item can be substituted; that is, they can be overwritten with new values, which are assigned in Table GB01 of the Boolean class (refer to Table 8.1), and haven’t been explicitly excluded from this via the field BEXCLUDE. You can display the content of the table with the following selection parameters: |
第 183 页 / 共 275 页
Substitution of Accounting Documents 8.2
EE BOOLCLASS
008 for document header (Callup point 1) or 009 for document item (Callup point 2).
Callup point 3 (Boolean class 015) no longer plays any role in substitution because no
fields are allowed here.
EE CLASSTYPE
S (Substitution).
EE BCLTAB
BKPF for document header or BSEG for document item.
All listed fields (the field name is in BCLFIELD) may be substituted, if the indicator BEX-
CLUDE is not set. Furthermore, for Callup point 2 it is allowed to release additional fields
by customizing Table GB01. The additional fields are listed here:
EE BSEG-FIPOS (financing item)
EE BSEG-HBKID (short key for a house bank)
EE BSEG-MSCHL (dunning key)
EE BSEG-MANSP (dunning block indicator)
EE BSEG-MADAT (date of the last reminder notice)
EE BSEG-MANST (dunning level)
EE BSEG-MABER (dunning area)
EE BSEG-RSTGR (reason code for payments)
EE BSEG-ZLSPR (key for payment blocking indicator)
After you’ve customized the table, you must start Report RGUGBR00 to regenerate the
programs for the substitution. Before you customize Table GB01, refer also to SAP Note
42615 for more detailed information on this.
You can execute the substitution itself via a simple formula assignment or a substi-
tution exit. The following subsection is a simple example again for both variants
that describes the principle of substitution.
8.2.1 Substitution without Exit Routine
Let’s assume that you want to replace the field BSEG-XREF1 (reference key) with a
new value. You have two options for this without replacing an exit routine: You
can either copy the field content from another field or overwrite the field content
with a constant value.
1. Start Transaction OBBH. Because the field BSEG-XREF1 belongs to the items of
the FI document, you must use a substitution for the Callup point 2. Create a
substitution for a company code on the Callup point 2 by providing any name
183
Personal Copy for Yang Meteor, user id a8103f58-81fe-4f49-acf6-cfb58959c618
第 184 页 / 共 275 页
8 Validation and Substitution of Accounting Documents
and double-clicking the substitution. Alternatively, navigate to an already-exist-
ing substitution by double-clicking.
2. In the tree structure on the left-hand side, the chosen substitution should now
be automatically selected. If not, click your substitution to highlight it. Click
Step to create a new step within the substitution.
3. A dialog window appears that maps all interchangeable fields at this point. You
can now select one or several of the fields. The field BSEG-XREF1 is adequate for
the example. Then confirm the dialog by pressing the [Enter] key.
4. Another dialog window now appears for each previously chosen field and offers
three selection options:
EE Constant Value
You can replace the field with a constant, that is, with any definable text.
EE Exit
You can choose an exit routine and replace the field with ABAP coding.
EE Field – Field Assignment
You can overwrite the content of the field with the content from another
field of the document.
Choose the Field – Field Assignment option, and confirm the dialog by press-
ing the [Enter] key.
5. Identify the step with a descriptive text, and go to the Prerequisite section.
Switch to the expert mode (Settings • Expert Mode), and enter the following
condition to only implement the substitution when the document originates
from Logistics Invoice Verification:
BKPF-TCODE = ‘MIRO’ OR BKPF-TCODE = ‘MIR7’
6. Edit the Substitution section. For each field that you have selected in the dia-
log window (that has appeared when you created a new step), you can now
specify the source of the substitution. The field Reference Key 1 (XREF1) will be
overwritten by the content of BSEG-SGTXT, which means you enter this field as
a source on the right-hand side (see Figure 8.7). You receive a warning message
that the field XREF1 is shorter than SGTXT and that may therefore be lost — only
the first 12 characters from SGTXT are copied.
184
© 2013 by Galileo Press Inc., Boston (MA)
第 185 页 / 共 275 页
Substitution of Accounting Documents 8.2
Figure 8.7 Field-Field Assignment in the Substitution
7. You must still activate the substitution so that it will run. To do this, switch
again to the initial screen of the substitution (Transaction OBBH). When you
have created the substitution, the right-hand column Degree of Activation is
still empty. In this case, the substitution is not executed. Change the degree of
activation to 1 to run the substitution. With the degree of activation 2, the sub-
stitution is activated but is bypassed with batch input.
8.2.2 Substitution with Exit Routine
Simple substitution without using ABAP coding quickly reaches its limits. How-
ever, just as with validation, it is possible to enhance a form routine pool with
custom routines and to run these in the substitution when required. You can find
some basics on using exit routines in the validation described in more detail in
Section 8.1.4, Example with Exit Routine.
The program containing the available form routines is maintained for substitution
in Table T80D (see Figure 8.4). The program on the work area GBLS must be main-
tained for substitution. Program RGGBS000 is stored here by default. To add custom
routines, you must copy the program into the custom namespace and change the
entry accordingly in T80D.
1. If this has not yet happened in your system, copy Program RGGBS000 into your
namespace, and change the entry for the work area GBLS in Table T80D.
2. You must also define form routines in substitution by including them in the
internal Table ETAB (via Table EXITS) in the form get_exit_titles. You define
the interface so that a field can be transferred as a parameter (the field that is
later substituted). For this, set the field PARAM to C_EXIT_PARAM_FIELD (refer to
Table 8.2):
exits-name = ‘U900’.
exits-param = c_exit_param_field.
185
Personal Copy for Yang Meteor, user id a8103f58-81fe-4f49-acf6-cfb58959c618
第 186 页 / 共 275 页
8 Validation and Substitution of Accounting Documents
exits-title = text-900.
APPEND exits.
It’s then specified that the form routine U900 contains a field in the parameter
interface. The field must not have a type and can also have any name in the
interface. You define which field with which type is actually transferred later in
Transaction OBBH. The field is then substituted by a simple assignment of a
value.
You must, however, make sure that you don’t cause any type conflict with
regard to the assignment that would then only show for the runtime. The stan-
dard framework for a substitution routine is given in Listing 8.4.
*-------------------------------------------------------------
* Substitution Exit
*------------------------------------------------------------*
FORM u900 USING ref_key.
* Substitution is carried out by assignment
* ref_key = ...
ENDFORM.
Listing 8.4 Standard Framework for Exit Routines in the Substitution
If, for example, the field reference key 2 (BSEG-XREF2) is filled with a combina-
tion of the reference activity and posting user, the complete example would
appear as in Listing 8.5. Here, you can also read data from custom tables to
implement more complex populations of the field.
3. Modify your previously changed program, and insert a custom routine to
substitute the field BSEG-XREF2. Register this routine in the form get_exit_
titles, and use the parameter C_EXIT_PARAM_FIELD. You can use Listing 8.5 as
a sample.
PROGRAM zggbs000.
INCLUDE fgbbgd00. “Standard 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,
186
© 2013 by Galileo Press Inc., Boston (MA)
第 187 页 / 共 275 页
Substitution of Accounting Documents 8.2
CSKS,
ANLZ,
GLU1.
*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*
*------------------------------------------------------------*
* FORM GET_EXIT_TITLES
*------------------------------------------------------------*
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.
* Register exit U900
exits-name = ‘U900’.
exits-param = c_exit_param_field.
exits-title = text-900.
APPEND exits.
REFRESH etab.
LOOP AT exits.
etab = exits.
APPEND etab.
ENDLOOP.
ENDFORM.
*------------------------------------------------------------*
* FORM U900
*------------------------------------------------------------*
FORM u900 USING ref_key.
DATA lv_xref2 TYPE bseg-xref2.
* XREF2 has only twelve characters, concatenate BKPF-AWTYP 5, BKPF-
USNAM 12
* suitably:
CONCATENATE bkpf-awtyp(4) bkpf-usnam(8) INTO lv_xref2.
* Substitution is carried out by assignment
ref_key = lv_xref2.
ENDFORM.
Listing 8.5 User Exit Form Pool for Substitution
187
Personal Copy for Yang Meteor, user id a8103f58-81fe-4f49-acf6-cfb58959c618
第 188 页 / 共 275 页
8 Validation and Substitution of Accounting Documents
4. Start Transaction OBBH, and select your already available substitution on Cal-
lup point 2. Generate a new Step, choose the field BSEG-XREF2 in the dialog
window, and confirm the dialog by pressing the [Enter] key.
5. In the next dialog window, select the EXIT option as the source for the substitu-
tion. Confirm this dialog also via the [Enter] key.
6. Then switch to the Prerequisite section. Here you can again use the following
condition:
BKPF-TCODE = ‘MIRO’ OR BKPF-TCODE = ‘MIR7’
7. In the Substitutions section, you can now assign the previously defined exit
(see Figure 8.8).
Figure 8.8 Substitution with Exit Routine
8. Save your changes, and check that your substitution is active in the initial
screen of Transaction OBBH. If you now post a logistics invoice, the content of
the field BSEG-XREF1 is overwritten according to the coding.
8.2.3 Read Access to Data of the Source Document
You usually only have access to fields of the FI document in substitution. You may
possibly want to format the fields from the original document, which has not been
copied into the FI document to therefore substitute another field in the FI docu-
ment. This could be particularly interesting if you use custom fields in the original
document, which you want to copy into a field of the FI document without too
much effort. You would, for example, have the option of creating a new input field
in Logistics Invoice Verification, the content of which is copied into the field XREF1
of the FI document. Normally, you can directly maintain only the item text (SGTXT)
in Logistics Invoice Verification.
Using a small trick, you can gain access to this data in individual cases: The posting
of the FI document and substitution is called from the original document. From
188
© 2013 by Galileo Press Inc., Boston (MA)
第 189 页 / 共 275 页
Substitution of Accounting Documents 8.2
the program point of view, other programs or function modules are called from
the original program. You can look at the exact call stack in the debugger when
you place a breakpoint in the substitutions exit, post a document, and then switch
to the respective view in the debugger. In Figure 8.9, you can see this view for a
logistics invoice (MIRO/MIR7) in the classic debugger.
Figure 8.9 Call List in the Debugger
As you can see from this view, the original program name (in which the form
BELEG_BUCHEN will run) is SAPLMR1M. By double-clicking the call stack, you can
navigate to the respective level and search for data objects in the codes that are
available there. Finding the appropriate data can sometimes be difficult. Moreover,
you must ensure that this data object is defined in the global area of the program
189
Personal Copy for Yang Meteor, user id a8103f58-81fe-4f49-acf6-cfb58959c618
第 190 页 / 共 275 页
8 Validation and Substitution of Accounting Documents
(you do not have any access to local variables). There are items in the internal table
YDRSEG for the logistics invoice.
You can check whether external access to a data object is possible by switching
again (with a double-click) to the top level of the call stack in the debugger and try-
ing to display the variable there. The entry is made in the sample (PROGRAMMNAME)
VARIABLE, for example, (SAPLMR1M)YDRSEG. Is the content displayed to you in the
debugger? Congratulations! You can now also access it in substitution.
1. You cannot directly access the variable (SAPLMR1M)YDRSEG. This is unknown in
the form pool of substitution, and you receive a syntax error. Instead, you
must first create a constant of the ABAP type C (Character), and then assign
the variable name. If it is an internal table as described in the example given,
you should explicitly refer to the content of the internal table (and not, for
instance, to the possibly available header line). You execute this by attaching
square brackets:
(SAPLMR1M)YDRSEG[].
2. Define a field symbol, and assign the content to the constant. Write the name of
the constant in brackets; otherwise, you would be able to see the constant itself
via the field symbol. The command for this is the following:
ASSIGN (c_constant) TO <fieldsymbol>.
The field symbol now displays for you the content of the internal table
YDRSEG.
3. Create an internal table identical to Table YDRSEG, and copy the content into your
custom table. Only work with your local copy, and do not touch the original.
Each unintentional change to the original data could have disastrous conse-
quences and result in inconsistencies. As long as you use the data only for read
access in the copy, then there is no danger.
4. If you haven’t already linked substitution as a result of the prerequisite to a spe-
cific transaction, you should integrate a check on sy-tcode by now, at the latest,
in the program. Bear in mind that the program variable(SAPLMR1M)YDRSEG is
only available when the original document is a logistics invoice.
Listing 8.6 shows a customized variant of the form U900. There is a custom field
named ZZ_FELD at the item level in the logistics invoice be copied to BSEG-XREF1.
*-------------------------------------------------------------
* Substitution Exit U900
*------------------------------------------------------------*
190
© 2013 by Galileo Press Inc., Boston (MA)
第 191 页 / 共 275 页
Substitution of Accounting Documents 8.2
FORM u900 USING ref_key.
* Define constant and field symbol
CONSTANTS c_drseg(18) TYPE c VALUE ‘(SAPLMR1M)YDRSEG[]’.
FIELD-SYMBOLS <ydrseg> TYPE ANY TABLE.
* Type-Pool MMCR contains the necessary data type for
* the local copy of the YDRSEG
TYPE-POOLS mmcr.
DATA gt_ydrseg TYPE TABLE OF mmcr_drseg.
DATA gs_ydrseg TYPE mmcr_drseg.
* Execution only when the posting comes from the logistics
* invoice, otherwise there is not any program SAPLMR1M!
CHECK sy-tcode = ‘MIRO’ OR sy-tcode = ‘MIR7’.
* Check assignment via sy-subrc, otherwise
* a short dump occurs when accessing the field symbol
ASSIGN (c_drseg) TO <ydrseg>.
IF sy-subrc = 0.
gt_ydrseg = <ydrseg>.
ENDIF.
* Local copy gt_ydrseg is only run here,
* the field symbol <ydrseg> should not
* continue to be used!
* The assignment of the current G/L account line in BSEG
* to the line of the original document is carried out via EBELN und
EBELP
IF NOT bseg-ebeln IS INITIAL AND
NOT bseg-ebelp IS INITIAL.
READ TABLE gt_ydrseg INTO gs_ydrseg
WITH KEY ebeln = bseg-ebeln
ebelp = bseg-ebelp.
IF sy-subrc = 0.
* ZZ_FELD is a user-defined field in the * Logistics invoice
ref_key = gs_ydrseg-zz_feld.
ENDIF.
ENDIF.
ENDFORM.
Listing 8.6 Transfer of Values from the Original Document
191
Personal Copy for Yang Meteor, user id a8103f58-81fe-4f49-acf6-cfb58959c618
第 192 页 / 共 275 页
© 2013 by Galileo Press Inc., Boston (MA)
第 193 页 / 共 275 页
A User Exits and BAdIs in SAP
Materials Management
In this book, you have received numerous examples for using user exits or BAdIs
in Materials Management. Nevertheless, it isn’t possible to describe all available
enhancements in detail. For this reason, this appendix provides a complete list of
the user exits, BAdIs, and enhancement spots available in MM.
To structure the large quantity of enhancement options, the appendix is divided
into these sections: Purchasing (see Section A.1), External Services Management
(see Section A.2), Inventory Management (see Section A.3), Valuation and Account
Assignment (see Section A.4), and Logistics Invoice Verification (see Section A.5).
Within these sections, the enhancements are summarized as far as possible accord-
ing to document type or call points and transactions. Otherwise, each section pro-
vides the BAdIs first, then the enhancement spots, and finally the enhancements.
Each enhancement is described in the following sections according to the same
schema:
EE Type and name
The following headings may apply:
EE Enhancement <Name>
You can find this enhancement in Transaction SMOD.
EE BAdI <Name>
You can find this BAdI in Transaction SE18.
EE BAdI <Name> (Enhancement spot <Name>)
You can also find this BAdI in Transaction SE18 as an assignment to an
enhancement spot.
EE Description of the function
The function of the enhancement is described in a brief summary. You can see
quickly whether this enhancement is suitable for your project. If available, you
can find further information in the documentation in the system.
EE Release
The availability has been checked for each enhancement following Release
4.6C. For enhancements with the note “following SAP R/3 4.6c (or earlier),” it’s
also possible that these were already available in earlier releases.
193
Personal Copy for Yang Meteor, user id a8103f58-81fe-4f49-acf6-cfb58959c618
第 194 页 / 共 275 页
A User Exits and BAdIs in SAP Materials Management
EE Call points
Under this entry, you can find transactions, reports, or BAPIs in which this
enhancement will run. If an enhancement is able to run from many different
transactions, this has been summarized under a general name, for example,
“Update Material Documents.”
EE Methods/components
The following additional information is provided for each entry:
EE Especially in the case of BAdIs, the name of the method already bears an ini-
tial reference as to which function provides this method. With the quick
search for a suitable enhancement, this can be very helpful as an eye-
catcher.
EE The components of an enhancement, for example, EXIT_SAPMM06E_024, are
less significant. However, they have been listed to enable a cross-reference
from the index to an enhancement.
A.1 Purchasing
Following are all of the enhancement options for the Purchasing area.
A.1.1 Purchase Order Requisitions in General
The following enhancements are provided for the purchase requisitions.
BAdI ME_PROCESS_REQ_CUST
The functionality of Enjoy purchase requisitions can be extensively enhanced via
this BAdI. For example, you can run several checks, overwrite the contents of stan-
dard fields, or post custom data.
EE Release
From SAP R/3 4.7
EE Call points
EE Transactions ME51N, ME52N, ME53N, and ME59N
EE BAPI_PR_CREATE
EE BAPI_PR_CHANGE
194
© 2013 by Galileo Press Inc., Boston (MA)
第 195 页 / 共 275 页
Purchasing A.1
EE Methods
EE INITIALIZE
EE OPEN
EE PROCESS_HEADER
EE PROCESS_ITEM
EE PROCESS_ACCOUNT
EE CHECK
EE POST
EE CLOSE
EE FIELDSELECTION_HEADER_REFKEYS
EE FIELDSELECTION_HEADER
EE FIELDSELECTION_ITEM_REFKEYS
EE FIELDSELECTION_ITEM
BAdI ME_BAPI_PR_CUST (ES_BADI_ME_BAPI Enhancement Spot)
In this enhancement, you can revise the input and output parameters of the BAPI_
PR_CREATE, BAPI_PR_CHANGE, and BAPI_PR_GETDETAIL BAPIs.
EE Release
from SAP ECC 5.0 (from SAP ECC 6.0 as an enhancement spot)
EE Call points
EE BAPI_PR_CREATE
EE BAPI_PR_CHANGE
EE BAPI_PR_GETDETAIL (only outbound)
EE Methods
EE INBOUND
EE OUTBOUND
EE MAP2I_EXTENSIONIN
EE MAP2E_EXTENSIONOUT
195
Personal Copy for Yang Meteor, user id a8103f58-81fe-4f49-acf6-cfb58959c618
第 196 页 / 共 275 页
A User Exits and BAdIs in SAP Materials Management
BAdI ME_REQ_POSTED
You can use this BAdI to implement any follow-on processing (e.g., the posting of
further data or the trigger of a workflow) after updating a purchase requisition.
EE Release
from SAP R/3 4.7
EE Call point
EE Update purchase requisition
EE Method
EE POSTED
BAdI ME_REQ_HEADER_TEXT
With this BAdI, you can control whether the header text of Enjoy purchase requisi-
tions is copied when purchase requisitions are copied.
EE Release
from SAP R/3 4.7
EE Call point
EE Transaction ME51N
EE Method
EE COPY_HEADER_TEXT
Enhancement M06B0001
If you set the workflow indicator 9 in a release procedure for a release code,
the user exit will run for the role resolution (determination of the responsible
person).
EE Release
from SAP R/3 4.6C (or earlier)
EE Call point
EE Purchase requisition release procedure
EE Component
EE EXIT_SAPLEBNF_001
196
© 2013 by Galileo Press Inc., Boston (MA)
第 197 页 / 共 275 页
Purchasing A.1
Enhancement M06B0002
With this enhancement, you can change the content of the CEBAN communications
structure and therefore influence the release strategy used at the item level.
EE Release
from SAP R/3 4.6C (or earlier)
EE Call point
EE Purchase requisition release procedure
EE Component
EE EXIT_SAPLEBND_001
Enhancement M06B0005
With this enhancement, you can change the content of the CEBAN communications
structure and therefore influence the release strategy used in the overall release.
EE Release
from SAP R/3 4.6C (or earlier)
EE Call point
EE Purchase requisition release procedure
EE Component
EE EXIT_SAPLEBND_004
Enhancement M06B0003
In this user exit, you can control the assignment of a custom document number or
specify a number range ID that is used when a purchase requisition is generated.
EE Release
from SAP R/3 4.6C (or earlier)
EE Call points
EE Transactions ME51 and ME51N
EE Component
EE EXIT_SAPMM06B_001
197
Personal Copy for Yang Meteor, user id a8103f58-81fe-4f49-acf6-cfb58959c618
第 198 页 / 共 275 页
A User Exits and BAdIs in SAP Materials Management
Enhancement M06B0004
You can use this enhancement to assign a custom document number or to specify
a number range ID when a purchase requisition is generated via the ME_CREATE_
REQUISITION_EXT function module (and, for example, BAPI_REQUISITION_CREATE
function module).
EE Release
from SAP R/3 4.6C (or earlier)
EE Call points
EE ME_CREATE_REQUISITION_EXT
EE BAPI_REQUISITION_CREATE
EE Component
EE EXIT_SAPLEBNE_001
Enhancement MEREQ001
This enhancement is used in the purchase requisition to implement custom fields,
to update custom tables, or to change standard fields (to a limited extent).
EE Release
from SAP R/3 4.6C (or earlier)
EE Call point
EE Purchase requisition (create, change, display)
EE Components
EE EXIT_SAPLMEREQ_001
EE EXIT_SAPLMEREQ_002
EE EXIT_SAPLMEREQ_003
EE EXIT_SAPLMEREQ_004
EE EXIT_SAPLMEREQ_005
EE EXIT_SAPLMEREQ_006
EE EXIT_SAPLMEREQ_007
EE EXIT_SAPLMEREQ_008
EE EXIT_SAPLMEREQ_009
EE EXIT_SAPLMEREQ_010
198
© 2013 by Galileo Press Inc., Boston (MA)
第 199 页 / 共 275 页
Purchasing A.1
EE Dynpro 0111 in SAPLXM02
EE Database include CI_EBANDB
EE Database include CI_EBANDBX
EE Database include CI_EBANMEM
Enhancement MM06E011
When you implement purchase requisitions via Transaction ME57, these are not
locked for performance reasons. If a purchase requisition is changed simultane-
ously, this can result in an inconsistent purchase requisition commitment. The lock
is activated by calling this enhancement. Refer also to SAP Note 378335.
EE Release
from SAP R/3 4.6C (or earlier)
EE Call point
EE Transaction ME57
EE Component
EE EXIT_SAPMM06E_024
A.1.2 Purchase Orders in General
The enhancements listed in this section are provided for purchase orders.
BAdI ME_BAPI_PO_CUST (Enhancement spot ES_BADI_ME_BAPI)
You have the option in this BAdI to revise the input and output parameters of the
BAPI_PO_CREATE1 and BAPI_PO_CHANGE BAPIs.
EE Release
from SAP ECC 5.0 (from SAP ECC 6.0 as an enhancement spot)
EE Call points
EE BAPI_PO_CREATE1
EE BAPI_PO_CHANGE
EE Methods
EE INBOUND
EE OUTBOUND
EE MAP2I_EXTENSIONIN
199
Personal Copy for Yang Meteor, user id a8103f58-81fe-4f49-acf6-cfb58959c618
第 200 页 / 共 275 页
A User Exits and BAdIs in SAP Materials Management
EE MAP2E_EXTENSIONOUT
EE TEXT_OUTPUT
BAdI ME_CHECK_ALL_ITEMS
This BAdI can control whether the items are to be rerun when you change the
header data in purchase orders, for example, to implement a new pricing.
EE Release
from SAP R/3 4.7
EE Call points
EE Transactions ME21N and ME22N
EE Method
EE RECALCULATE_ITEMS
BAdI ME_HOLD_PO
This BAdI contains an icon via which you can activate or lock the Hold function
in purchase orders. You can find an example of this in Section 2.2, Use of Classic
BAdIs, in Chapter 2.
EE Release
from SAP R/3 4.6C (or earlier)
EE Call points
EE Purchase order in Transactions ME21N and ME22N
EE Method
EE IS_ALLOWED
BAdI ME_POHIST_DISP_CUST (ES_BADI_ME_POHIST Enhancement Spot)
With this BAdI, you can customize the purchase order history display in purchase
order items according to your custom requirements. You can find an example of
this in Section 2.3, Use of New BAdIs (Enhancement Spots), in Chapter 2.
EE Release
from SAP ECC 6.0
EE Call points
EE Purchase orders
200
© 2013 by Galileo Press Inc., Boston (MA)
第 201 页 / 共 275 页
Purchasing A.1
EE Methods
EE FIELDCAT_CHANGE
EE OUTTAB_CHANGE
EE HANDLE_HOTSPOT_CLICK
BAdI ME_PURCHDOC_POSTED
You can use this BAdI to implement any follow-on processing (e.g., to post fur-
ther data or to trigger a workflow) after the purchasing documents have been
updated.
EE Release
from SAP R/3 4.7
EE Call points
EE Updating of purchasing documents
EE Method
EE POSTED
BAdI ME_GUI_PO_CUST
This BAdI allows you to define custom dynpros with custom fields in the Enjoy
purchase order. Moreover, the implementation of ME_PROCESS_PO_CUST is neces-
sary. You can find an example of this in Section 3.1, Customized Fields in Purchase
Orders, in Chapter 3.
EE Release
from SAP R/3 4.7
EE Call points
EE Transactions ME21N, ME22N, and ME23N
EE Transaction ME23N
EE Methods
EE SUBSCRIBE
EE MAP_DYNPRO_FIELDS
EE TRANSPORT_FROM_MODEL
EE TRANSPORT_TO_DYNP
EE TRANSPORT_FROM_DYNP
201
Personal Copy for Yang Meteor, user id a8103f58-81fe-4f49-acf6-cfb58959c618
第 202 页 / 共 275 页
A User Exits and BAdIs in SAP Materials Management
EE TRANSPORT_TO_MODEL
EE EXECUTE
BAdI ME_PROCESS_PO_CUST
With this BAdI, you can extensively enhance the functionality of purchase orders,
for example, via custom checks or the processing of custom input fields (see also
ME_GUI_PO_CUST BAdI). You can find an example of this in Section 3.1, Customized
Fields in Purchase Orders, in Chapter 3.
EE Release
from SAP R/3 4.7
EE Call points
EE Transactions ME21N, ME22N, and ME23N
EE Transaction ME29N
EE BAPI_PO_CREATE1
EE BAPI_PO_CHANGE
EE Methods
EE INITIALIZE
EE OPEN
EE PROCESS_HEADER
EE PROCESS_ITEM
EE PROCESS_SCHEDULE
EE PROCESS_ACCOUNT
EE CHECK
EE POST
EE CLOSE
EE FIELDSELECTION_HEADER_REFKEYS
EE FIELDSELECTION_HEADER
EE FIELDSELECTION_ITEM_REFKEYS
EE FIELDSELECTION_ITEM
202
© 2013 by Galileo Press Inc., Boston (MA)
第 203 页 / 共 275 页
Purchasing A.1
BAdI ME_TAX_FROM_ADDRESS
You can use this BAdI to determine the tax jurisdiction code with the generation
of purchase orders.
EE Release
from SAP R/3 4.7
EE Call point
EE Transaction ME21N
EE Methods
EE GET_TXJCD
EE SERVICES_TXJCD
Enhancement M06E0004
With this user exit, you have the option to change the CEKKO communications
structure to influence the release strategy used.
EE Release
from SAP R/3 4.6C (or earlier)
EE Call point
EE Release procedure purchase order
EE Component
EE EXIT_SAPLEBND_002
Enhancement M06E0005
If you set the workflow indicator 9 for a release code in a release procedure, this user
exit will run for the role resolution (determination of the person responsible).
EE Release
from SAP R/3 4.6C (or earlier)
EE Call point
EE Release procedure purchase order
EE Component
EE EXIT_SAPLEBNF_005
203
Personal Copy for Yang Meteor, user id a8103f58-81fe-4f49-acf6-cfb58959c618
第 204 页 / 共 275 页
A User Exits and BAdIs in SAP Materials Management
Enhancement ME590001
With this enhancement, you can define a custom logic for grouping purchase req-
uisitions for purchase order items when purchase requisitions are automatically
implemented in purchase orders (ME59).
EE Release
from SAP R/3 4.6C (or earlier)
EE Call point
EE Transaction ME59
EE Component
EE EXIT_SAPLME59_001
Enhancement MM06E004
With this enhancement, the processing of the import data screen can be controlled
when the purchasing document is entered.
EE Release
from SAP R/3 4.6C (or earlier)
EE Call points
EE Transactions ME21 and ME21N
EE Component
EE EXIT_SAPMM06E_004
Enhancement MM06E007
With this enhancement, you can control whether a change document is created
in the purchase requisition when a purchase requisition is implemented in a pur-
chase order. You can find an example of this in Section 2.1, Use of User Exits, in
Chapter 2.
EE Release
from SAP R/3 4.6C (or earlier)
EE Call points
EE Transactions ME21 and ME21N
EE Transaction ME59
204
© 2013 by Galileo Press Inc., Boston (MA)
第 205 页 / 共 275 页
Purchasing A.1
EE Component
EE EXIT_SAPMM06E_020
A.1.3 Outline Agreements (Scheduling Agreements/Contracts)
In this section, the following enhancements are provided for scheduling agree-
ments and contracts.
BAdI MEOUT_BAPI_CUST (ES_BADI_ME_BAPI Enhancement Spot)
You can use this BAdI to revise the input and export parameters of the BAPI_
SAG_CREATE, BAPI_SAG_CHANGE, BAPI_CONTRACT_CREATE, and BAPI_CONTRACT_CHANGE
BAPIs.
EE Release
from SAP ECC 6.0
EE Call points
EE BAPI_SAG_CREATE
EE BAPI_SAG_CHANGE
EE BAPI_CONTRACT_CREATE
EE BAPI_CONTRACT_CHANGE
EE Methods
EE INBOUND
EE OUTBOUND
EE MAP2I_EXTENSIONIN
EE MAP2E_EXTENSIONOUT
BAdI ME_PROCESS_OUT_CUST (ME_PROCESS_OUT Enhancement Spot)
With this BAdI, you can influence the generation of scheduling agreements and
contracts if these are generated from the associated BAPIs.
EE Release
from SAP ECC 6.0
EE Call points
EE BAPI_SAG_CREATE
EE BAPI_SAG_CHANGE
205
Personal Copy for Yang Meteor, user id a8103f58-81fe-4f49-acf6-cfb58959c618
第 206 页 / 共 275 页
A User Exits and BAdIs in SAP Materials Management
EE BAPI_CONTRACT_CREATE
EE BAPI_CONTRACT_CHANGE
EE Methods
EE INITIALIZE
EE OPEN
EE PROCESS_HEADER
EE PROCESS_ITEM
EE PROCESS_SCHEDULE
EE PROCESS_ACCOUNT
EE CHECK
EE POST
EE CLOSE
EE FIELDSELECTION_HEADER_REFKEYS
EE FIELDSELECTION_HEADER
EE FIELDSELECTION_ITEM_REFKEYS
EE FIELDSELECTION_ITEM
BAdI ME_RELEASE_CREATE
You can use this BAdI to influence the release creation in scheduling agreements.
This BAdI replaces the EXIT_SAPLEINL_001 and EXIT_SAPLEINL_002 user exits of
the MEETA001 enhancement from earlier releases.
EE Release
from SAP R/3 4.7
EE Call points
EE Scheduling agreements
EE Methods
EE BEFORE_CREATION
EE AFTER_CREATION
206
© 2013 by Galileo Press Inc., Boston (MA)