SAP PREFERENCE_COSTING Function Module for NOTRANSL: Präferenzkalkualtion









PREFERENCE_COSTING is a standard preference costing SAP function module available within SAP R/3 or S/4 Hana systems, depending on your version and release level. It is used for NOTRANSL: Präferenzkalkualtion 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 preference costing FM, simply by entering the name PREFERENCE_COSTING into the relevant SAP transaction such as SE37 or SE38.

Function Group: PREF
Program Name: SAPLPREF
Main Program:
Appliation area: V
Release date: N/A
Mode(Normal, Remote etc): Normal Function Module
Update:



Function PREFERENCE_COSTING 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 'PREFERENCE_COSTING'"NOTRANSL: Präferenzkalkualtion
EXPORTING
P_WERKS = "Plant in which preference is calculated
* P_UPDATE = ' ' "ID simulation or update Space = simu, X = upd
* P_MDMPS = ' ' "ID explosion type Space = all, X = single level
TOPMAT = "Data of BOM initial material
* P_ALPAUF = ' ' "
* P_PWLEN = 4 "
* P_PROZEN = 0 "

IMPORTING
W_MARC = "MARC work area
KZ_NO_MATSTAMM_UPDATE = "
KZ_NO_CONDITION_INSERT = "
KP_PROZEN = "

TABLES
STB = "BOM item data
* REGELTAB = "
MATCAT = "BOM item key data
T_MATWERTE = "
DATA_LOG = "
ERROR_LOG = "
K_TAB = "
INT_MAPE = "
* BG_WERTE = "
* BG_KOND = "

EXCEPTIONS
HS_OPCODE_FAILURE = 1 NO_PLANT = 2 NO_STAWN = 3 NO_RULE_DEFINED = 4 NO_PROCEDURE_DEFINED = 5 FAILURE_READ_TAB = 6 FAILURE_READ_MARC = 7 FAILURE_MOD_TAB = 8 FAILURE_KOMPONENTE = 9
.




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_SAPLPREF_001 Customer enhancement margin of safety for planned price
EXIT_SAPLPREF_002 Customer enhancement security surcharge for components cost/standard price

IMPORTING Parameters details for PREFERENCE_COSTING

P_WERKS - Plant in which preference is calculated

Data type: T001W-WERKS
Optional: No
Call by Reference: No ( called with pass by value option)

P_UPDATE - ID simulation or update Space = simu, X = upd

Data type: CSDATA-XFELD
Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)

P_MDMPS - ID explosion type Space = all, X = single level

Data type: CSDATA-XFELD
Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)

TOPMAT - Data of BOM initial material

Data type: CSTMAT
Optional: No
Call by Reference: No ( called with pass by value option)

P_ALPAUF -

Data type: CSDATA-XFELD
Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)

P_PWLEN -

Data type: STPOX-AUFST
Default: 4
Optional: Yes
Call by Reference: No ( called with pass by value option)

P_PROZEN -

Data type: RVSEL-P_PROZEN
Optional: Yes
Call by Reference: No ( called with pass by value option)

EXPORTING Parameters details for PREFERENCE_COSTING

W_MARC - MARC work area

Data type: MARC
Optional: No
Call by Reference: No ( called with pass by value option)

KZ_NO_MATSTAMM_UPDATE -

Data type: CSDATA-XFELD
Optional: No
Call by Reference: No ( called with pass by value option)

KZ_NO_CONDITION_INSERT -

Data type: CSDATA-XFELD
Optional: No
Call by Reference: No ( called with pass by value option)

KP_PROZEN -

Data type: RVSEL-P_PROZEN
Optional: No
Call by Reference: No ( called with pass by value option)

TABLES Parameters details for PREFERENCE_COSTING

STB - BOM item data

Data type: RL0PRE_2
Optional: No
Call by Reference: No ( called with pass by value option)

REGELTAB -

Data type: RL0PRE_5
Optional: Yes
Call by Reference: No ( called with pass by value option)

MATCAT - BOM item key data

Data type: CSCMAT
Optional: No
Call by Reference: No ( called with pass by value option)

T_MATWERTE -

Data type: RL0PRE_1
Optional: No
Call by Reference: No ( called with pass by value option)

DATA_LOG -

Data type: RL0PRE_3
Optional: No
Call by Reference: No ( called with pass by value option)

ERROR_LOG -

Data type: RL0PRE_3
Optional: No
Call by Reference: No ( called with pass by value option)

K_TAB -

Data type: RL0PRE_4
Optional: No
Call by Reference: No ( called with pass by value option)

INT_MAPE -

Data type: MAPE
Optional: No
Call by Reference: No ( called with pass by value option)

BG_WERTE -

Data type: MAPE
Optional: Yes
Call by Reference: No ( called with pass by value option)

BG_KOND -

Data type:
Optional: Yes
Call by Reference: No ( called with pass by value option)

EXCEPTIONS details

HS_OPCODE_FAILURE - Wrong OPCODE for HS item in table T604R

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

NO_PLANT - Plant in table T001W not available

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

NO_STAWN - Commodity code not maintained

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

NO_RULE_DEFINED - No rule available in T604

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

NO_PROCEDURE_DEFINED - No procedure defined in T604V

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

FAILURE_READ_TAB - Error on access to T604x tables

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

FAILURE_READ_MARC - No MARC segment available

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

FAILURE_MOD_TAB - Modify error in internal table

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

FAILURE_KOMPONENTE -

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

Copy and paste ABAP code example for PREFERENCE_COSTING 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:
lt_stb  TYPE STANDARD TABLE OF RL0PRE_2, "   
lv_w_marc  TYPE MARC, "   
lv_p_werks  TYPE T001W-WERKS, "   
lv_hs_opcode_failure  TYPE T001W, "   
lt_regeltab  TYPE STANDARD TABLE OF RL0PRE_5, "   
lt_matcat  TYPE STANDARD TABLE OF CSCMAT, "   
lv_no_plant  TYPE CSCMAT, "   
lv_p_update  TYPE CSDATA-XFELD, "   SPACE
lv_kz_no_matstamm_update  TYPE CSDATA-XFELD, "   
lv_p_mdmps  TYPE CSDATA-XFELD, "   SPACE
lv_no_stawn  TYPE CSDATA, "   
lt_t_matwerte  TYPE STANDARD TABLE OF RL0PRE_1, "   
lv_kz_no_condition_insert  TYPE CSDATA-XFELD, "   
lv_topmat  TYPE CSTMAT, "   
lt_data_log  TYPE STANDARD TABLE OF RL0PRE_3, "   
lv_kp_prozen  TYPE RVSEL-P_PROZEN, "   
lv_no_rule_defined  TYPE RVSEL, "   
lv_p_alpauf  TYPE CSDATA-XFELD, "   SPACE
lt_error_log  TYPE STANDARD TABLE OF RL0PRE_3, "   
lv_no_procedure_defined  TYPE RL0PRE_3, "   
lt_k_tab  TYPE STANDARD TABLE OF RL0PRE_4, "   
lv_p_pwlen  TYPE STPOX-AUFST, "   4
lv_failure_read_tab  TYPE STPOX, "   
lt_int_mape  TYPE STANDARD TABLE OF MAPE, "   
lv_p_prozen  TYPE RVSEL-P_PROZEN, "   0
lv_failure_read_marc  TYPE RVSEL, "   
lt_bg_werte  TYPE STANDARD TABLE OF MAPE, "   
lv_failure_mod_tab  TYPE MAPE, "   
lt_bg_kond  TYPE STANDARD TABLE OF MAPE, "   
lv_failure_komponente  TYPE MAPE. "   

  CALL FUNCTION 'PREFERENCE_COSTING'  "NOTRANSL: Präferenzkalkualtion
    EXPORTING
         P_WERKS = lv_p_werks
         P_UPDATE = lv_p_update
         P_MDMPS = lv_p_mdmps
         TOPMAT = lv_topmat
         P_ALPAUF = lv_p_alpauf
         P_PWLEN = lv_p_pwlen
         P_PROZEN = lv_p_prozen
    IMPORTING
         W_MARC = lv_w_marc
         KZ_NO_MATSTAMM_UPDATE = lv_kz_no_matstamm_update
         KZ_NO_CONDITION_INSERT = lv_kz_no_condition_insert
         KP_PROZEN = lv_kp_prozen
    TABLES
         STB = lt_stb
         REGELTAB = lt_regeltab
         MATCAT = lt_matcat
         T_MATWERTE = lt_t_matwerte
         DATA_LOG = lt_data_log
         ERROR_LOG = lt_error_log
         K_TAB = lt_k_tab
         INT_MAPE = lt_int_mape
         BG_WERTE = lt_bg_werte
         BG_KOND = lt_bg_kond
    EXCEPTIONS
        HS_OPCODE_FAILURE = 1
        NO_PLANT = 2
        NO_STAWN = 3
        NO_RULE_DEFINED = 4
        NO_PROCEDURE_DEFINED = 5
        FAILURE_READ_TAB = 6
        FAILURE_READ_MARC = 7
        FAILURE_MOD_TAB = 8
        FAILURE_KOMPONENTE = 9
. " PREFERENCE_COSTING




ABAP code using 7.40 inline data declarations to call FM PREFERENCE_COSTING

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 WERKS FROM T001W INTO @DATA(ld_p_werks).
 
 
 
 
 
"SELECT single XFELD FROM CSDATA INTO @DATA(ld_p_update).
DATA(ld_p_update) = ' '.
 
"SELECT single XFELD FROM CSDATA INTO @DATA(ld_kz_no_matstamm_update).
 
"SELECT single XFELD FROM CSDATA INTO @DATA(ld_p_mdmps).
DATA(ld_p_mdmps) = ' '.
 
 
 
"SELECT single XFELD FROM CSDATA INTO @DATA(ld_kz_no_condition_insert).
 
 
 
"SELECT single P_PROZEN FROM RVSEL INTO @DATA(ld_kp_prozen).
 
 
"SELECT single XFELD FROM CSDATA INTO @DATA(ld_p_alpauf).
DATA(ld_p_alpauf) = ' '.
 
 
 
 
"SELECT single AUFST FROM STPOX INTO @DATA(ld_p_pwlen).
DATA(ld_p_pwlen) = 4.
 
 
 
"SELECT single P_PROZEN FROM RVSEL INTO @DATA(ld_p_prozen).
 
 
 
 
 
 


Search for further information about these or an SAP related objects



Comments on this SAP object

What made you want to lookup this SAP object? Please tell us what you were looking for and anything you would like to be included on this page!