Extending Outbound Function Modules 

For each extension segment, there is a customer extension in the coding of the outbound function module, which enters the application data in the extension segment.

Prerequisites

You must have completed the required steps in Extending an IDoc Type .

Procedure

  1. You write the customer extension of the corresponding function modules via a function or user exit in the project management: From the initial screen of the ABAP Wokbench choose Utilities ® Extensions ® Project management. Enter a project name (note the customer namespace!) and choose Attributes (radio button) and create. Enter a short text and save it.
  2. More detailed information about enhancement projects can be found in the R/3 Library under Basis ® ABAP Workbench ® Changing the SAP Standard ® The R/3 Enhancement Concept.

  3. Return to the initial screen of the project management and select the sub-object extensions allocation. Choose Change to assign SAP extensions to your project. Use the F4 Help to find the SAP extensions. Save your entries.
  4. An SAP extension contains as components function exits (function modules), from which you will choose those required in the next step.

  5. Now choose the sub-object Components in the initial screen of project management. Choose Change.
  6. A list of all the function exits is output. By selecting Extension, documentation on the individual Exits is displayed.

  7. By double-clicking on the function exit required, the ABAP Editor is displayed.
  8. The function exit contains the line include <customer include>. Create this include by double-clicking on the name (confirm system queries). Enter your source text and then save your entries.
  9. You do not have to maintain the fields HLEVEL (hierarchy level of the segment) and PSGNUM (number of the parent segment) in the IDoc data record. This is done by the IDoc interface, which can obtain the information about the position of the segment in the IDoc type from the definition of the extension.

  10. You must now define your new extension segments as global structures in the customer-specific TOP include. Choose Goto ® Global data in the ABAP Editor.
  11. The TOP program is displayed.

  12. Create the customer TOP Include by double-clicking on the name (confirm system queries!). Enter your extension segments as TABLES data declarations.
  13. If you have activated the segment before, there should be no problems with the syntax check ( ). You should never create the segment directly in the Dictionary! Always use the segment editor!

  14. Activate your entire project. To do this access the initial project management screen and select .

 

In the example, extend the function module IDOC_OUTPUT_ORDERS in the additional project ZM06E001.

SAP extension

MM06E001

Function exit

EXIT_SAPLEINM_002 (Customer extension of data segments for outbound purchasing document)

Include

ZXM06U02

Segment

Z1TEST1

Main program

SAPLXM06

TOP program

LXM06TOP

Customer Top Include

ZXM06TOP

 

The source text appears as follows:

DATA segnam(27).

segnam = int_edidd-segnam.

CASE segnam.

WHEN 'E1EDP19'.

CLEAR int_edidd. "Clear work area

int_edidd-segnam = 'Z1TEST1'. "Name of customer segment

z1test1-continent = 'Europe'.

int_edidd-sdata = z1test1. "Remaining fields from int_edidd

"can be copied

APPEND int_edidd.

ENDCASE .

The CASE instruction in the coding is essential because the same customer exit is called for each segment in the function module IDOC_OUTPUT_ORDERS. For this reason, the new include must first determine whether the call came from the correct parent segment.