SAP KAUF_ORDER_CREATE Function Module for Create Internal Order
KAUF_ORDER_CREATE is a standard kauf order create SAP function module available within SAP R/3 or S/4 Hana systems, depending on your version and release level. It is used for Create Internal Order processing and below is the pattern details for this FM, showing its interface including any import and export parameters, exceptions etc. there is also a full "cut and paste" ABAP pattern code example, along with implementation ABAP coding, documentation and contribution comments specific to this or related objects.
See here to view full function module documentation and code listing for kauf order create FM, simply by entering the name KAUF_ORDER_CREATE into the relevant SAP transaction such as SE37 or SE38.
Function Group: KAUF
Program Name: SAPLKAUF
Main Program: SAPLKAUF
Appliation area: K
Release date: N/A
Mode(Normal, Remote etc): Normal Function Module
Update:

Function KAUF_ORDER_CREATE pattern details
In-order to call this FM within your sap programs, simply using the below ABAP pattern details to trigger the function call...or see the full ABAP code listing at the end of this article. You can simply cut and paste this code into your ABAP progrom as it is, including variable declarations.CALL FUNCTION 'KAUF_ORDER_CREATE'"Create Internal Order.
EXPORTING
* I_AUART = ' ' "Order type
* I_NEGLECT_FIELDSELECTION = ' ' "
* I_APROF = ' ' "
* I_AUFNR = ' ' "Order number (in external number assignment)
* I_AUTYP_ERL = ' ' "Valid order types
* I_DIALOG = ' ' "Dialog messages allowed (popups etc.)
* I_MATNR = ' ' "Material number (only for CO production order)
* I_OREXT = "External model for order
* I_REFNR = ' ' "Reference order
* I_SAVE_FLAG = ' ' "
* I_WERKS = ' ' "Plant (only for CO production order)
IMPORTING
E_AFKO = "Order header (enhancement for CO production order)
E_AFPO = "Order item (only for CO production order)
E_COAS = "Order header
E_KAUF = "Administrative data
E_INDEX = "Order index
EXCEPTIONS
FOREIGN_LOCK = 1 ORDER_TYPE_NOT_VALID = 2 REFERENCE_NOT_VALID = 3 WRONG_INPUT = 4 NO_NUMBER_RANGE = 5
Customer Function user exits
Below is a list of CUSTOMER FUNCTION exit user exits that are available within this program and maybe relevant for this FM.EXIT_SAPLKAUF_001 Function call from master data maintenance
EXIT_SAPLKAUF_004 Customer exit for controlling printing of master data for internal orders
IMPORTING Parameters details for KAUF_ORDER_CREATE
I_AUART - Order type
Data type: AUFK-AUARTDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
I_NEGLECT_FIELDSELECTION -
Data type: BAPI0012_GEN-TESTRUNDefault: SPACE
Optional: Yes
Call by Reference: Yes
I_APROF -
Data type: APROFDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
I_AUFNR - Order number (in external number assignment)
Data type: AUFK-AUFNRDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
I_AUTYP_ERL - Valid order types
Data type:Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
I_DIALOG - Dialog messages allowed (popups etc.)
Data type:Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
I_MATNR - Material number (only for CO production order)
Data type: AFPO-MATNRDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
I_OREXT - External model for order
Data type: OREXTOptional: Yes
Call by Reference: No ( called with pass by value option)
I_REFNR - Reference order
Data type: AUFK-REFNRDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
I_SAVE_FLAG -
Data type:Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
I_WERKS - Plant (only for CO production order)
Data type: AUFK-WERKSDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
EXPORTING Parameters details for KAUF_ORDER_CREATE
E_AFKO - Order header (enhancement for CO production order)
Data type: AFKOOptional: No
Call by Reference: No ( called with pass by value option)
E_AFPO - Order item (only for CO production order)
Data type: AFPOOptional: No
Call by Reference: No ( called with pass by value option)
E_COAS - Order header
Data type: COASOptional: No
Call by Reference: No ( called with pass by value option)
E_KAUF - Administrative data
Data type: KAUFOptional: No
Call by Reference: No ( called with pass by value option)
E_INDEX - Order index
Data type: KAUF-AUF_INDEXOptional: No
Call by Reference: No ( called with pass by value option)
EXCEPTIONS details
FOREIGN_LOCK - Order locked
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
ORDER_TYPE_NOT_VALID - Invalid order type
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
REFERENCE_NOT_VALID - Invalid reference order
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
WRONG_INPUT - Incorrect input parameters
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
NO_NUMBER_RANGE - Order type has no number intervall
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
Copy and paste ABAP code example for KAUF_ORDER_CREATE Function Module
The ABAP code below is a full code listing to execute function module POPUP_TO_CONFIRM including all data declarations. The code uses the original data declarations rather than the latest in-line data DECLARATION SYNTAX but I have included an ABAP code snippet at the end to show how declarations would look using the newer method of declaring data variables on the fly. This will allow you to compare and fully understand the new inline method. Please note some of the newer syntax such as the @DATA is not available until a later 4.70 service pack (SP8), which i why i have stuck to the origianl for this example.| DATA: | ||||
| lv_e_afko | TYPE AFKO, " | |||
| lv_i_auart | TYPE AUFK-AUART, " SPACE | |||
| lv_foreign_lock | TYPE AUFK, " | |||
| lv_i_neglect_fieldselection | TYPE BAPI0012_GEN-TESTRUN, " SPACE | |||
| lv_i_aprof | TYPE APROF, " SPACE | |||
| lv_e_afpo | TYPE AFPO, " | |||
| lv_i_aufnr | TYPE AUFK-AUFNR, " SPACE | |||
| lv_order_type_not_valid | TYPE AUFK, " | |||
| lv_e_coas | TYPE COAS, " | |||
| lv_i_autyp_erl | TYPE COAS, " SPACE | |||
| lv_reference_not_valid | TYPE COAS, " | |||
| lv_e_kauf | TYPE KAUF, " | |||
| lv_i_dialog | TYPE KAUF, " SPACE | |||
| lv_wrong_input | TYPE KAUF, " | |||
| lv_e_index | TYPE KAUF-AUF_INDEX, " | |||
| lv_i_matnr | TYPE AFPO-MATNR, " SPACE | |||
| lv_no_number_range | TYPE AFPO, " | |||
| lv_i_orext | TYPE OREXT, " | |||
| lv_i_refnr | TYPE AUFK-REFNR, " SPACE | |||
| lv_i_save_flag | TYPE AUFK, " SPACE | |||
| lv_i_werks | TYPE AUFK-WERKS. " SPACE |
|   CALL FUNCTION 'KAUF_ORDER_CREATE' "Create Internal Order |
| EXPORTING | ||
| I_AUART | = lv_i_auart | |
| I_NEGLECT_FIELDSELECTION | = lv_i_neglect_fieldselection | |
| I_APROF | = lv_i_aprof | |
| I_AUFNR | = lv_i_aufnr | |
| I_AUTYP_ERL | = lv_i_autyp_erl | |
| I_DIALOG | = lv_i_dialog | |
| I_MATNR | = lv_i_matnr | |
| I_OREXT | = lv_i_orext | |
| I_REFNR | = lv_i_refnr | |
| I_SAVE_FLAG | = lv_i_save_flag | |
| I_WERKS | = lv_i_werks | |
| IMPORTING | ||
| E_AFKO | = lv_e_afko | |
| E_AFPO | = lv_e_afpo | |
| E_COAS | = lv_e_coas | |
| E_KAUF | = lv_e_kauf | |
| E_INDEX | = lv_e_index | |
| EXCEPTIONS | ||
| FOREIGN_LOCK = 1 | ||
| ORDER_TYPE_NOT_VALID = 2 | ||
| REFERENCE_NOT_VALID = 3 | ||
| WRONG_INPUT = 4 | ||
| NO_NUMBER_RANGE = 5 | ||
| . " KAUF_ORDER_CREATE | ||
ABAP code using 7.40 inline data declarations to call FM KAUF_ORDER_CREATE
The below ABAP code uses the newer in-line data declarations. This allows you to see the coding differences/benefits of the later inline syntax. Please note some of the newer syntax below, such as the @DATA is not available until 4.70 EHP 8.| "SELECT single AUART FROM AUFK INTO @DATA(ld_i_auart). | ||||
| DATA(ld_i_auart) | = ' '. | |||
| "SELECT single TESTRUN FROM BAPI0012_GEN INTO @DATA(ld_i_neglect_fieldselection). | ||||
| DATA(ld_i_neglect_fieldselection) | = ' '. | |||
| DATA(ld_i_aprof) | = ' '. | |||
| "SELECT single AUFNR FROM AUFK INTO @DATA(ld_i_aufnr). | ||||
| DATA(ld_i_aufnr) | = ' '. | |||
| DATA(ld_i_autyp_erl) | = ' '. | |||
| DATA(ld_i_dialog) | = ' '. | |||
| "SELECT single AUF_INDEX FROM KAUF INTO @DATA(ld_e_index). | ||||
| "SELECT single MATNR FROM AFPO INTO @DATA(ld_i_matnr). | ||||
| DATA(ld_i_matnr) | = ' '. | |||
| "SELECT single REFNR FROM AUFK INTO @DATA(ld_i_refnr). | ||||
| DATA(ld_i_refnr) | = ' '. | |||
| DATA(ld_i_save_flag) | = ' '. | |||
| "SELECT single WERKS FROM AUFK INTO @DATA(ld_i_werks). | ||||
| DATA(ld_i_werks) | = ' '. | |||
Search for further information about these or an SAP related objects