SAP Function Modules

CALCULATE_PRIORITY SAP Function module - Priority Calculation







CALCULATE_PRIORITY is a standard SAP function module available within R/3 SAP systems depending on your version and release level. Below is the pattern details for this FM showing its interface including any import and export parameters, exceptions etc as well as any documentation contributions (Comments) specific to the object.

See here to view full function module documentation and code listing, simply by entering the name CALCULATE_PRIORITY into the relevant SAP transaction such as SE37 or SE80.

Associated Function Group: IWO8
Released Date: Not Released
Processing type: Normal fucntion module
Normal function module settings


Pattern for FM CALCULATE_PRIORITY - CALCULATE PRIORITY





CALL FUNCTION 'CALCULATE_PRIORITY' "Priority Calculation
  EXPORTING
*   i_qmtyp =                   " tq80-qmtyp    Message Category
    i_artpr =                   " t356-artpr    Priority type
    i_priok =                   " t356-priok    Priority
    i_strmn =                   " viqmel-strmn  Start date - date
*   i_strur =                   " viqmel-strur  Start date - time
*   i_ltrmn =                   " viqmel-ltrmn
*   i_ltrur =                   " viqmel-ltrur
*   i_calid =                   " thoci-ident   Factory Calendar ID
*   i_warpl =                   " viqmel-warpl  Maintenance Plan
*   i_flg_popup = 'X'           " c
  IMPORTING
    e_strmn =                   " viqmel-strmn  Start date - date
    e_strur =                   " viqmel-strur  Start date - time
    e_ltrmn =                   " viqmel-ltrmn  End date - date
    e_ltrur =                   " viqmel-ltrur  End date - time
    e_priokx =                  " t356_t-priokx  Priority text
  EXCEPTIONS
    INVALID_PRIO = 1            "               Invalid priority type
    INVALID_DATE = 2            "               Invalid start date
    DIMENSION_NOT_FOUND = 3     "               No dimension maintained for specified exponents
    UNIT_NOT_FOUND = 4          "               Unit missing in the check table
    .  "  CALCULATE_PRIORITY

ABAP code example for Function Module CALCULATE_PRIORITY





The ABAP code below is a full code listing to execute function module CALCULATE_PRIORITY including all data declarations. The code uses 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 original method of declaring data variables up front. 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).

DATA:
ld_e_strmn  TYPE VIQMEL-STRMN ,
ld_e_strur  TYPE VIQMEL-STRUR ,
ld_e_ltrmn  TYPE VIQMEL-LTRMN ,
ld_e_ltrur  TYPE VIQMEL-LTRUR ,
ld_e_priokx  TYPE T356_T-PRIOKX .


SELECT single QMTYP
FROM TQ80
INTO @DATA(ld_i_qmtyp).


SELECT single ARTPR
FROM T356
INTO @DATA(ld_i_artpr).


SELECT single PRIOK
FROM T356
INTO @DATA(ld_i_priok).


SELECT single STRMN
FROM VIQMEL
INTO @DATA(ld_i_strmn).


SELECT single STRUR
FROM VIQMEL
INTO @DATA(ld_i_strur).


SELECT single LTRMN
FROM VIQMEL
INTO @DATA(ld_i_ltrmn).


SELECT single LTRUR
FROM VIQMEL
INTO @DATA(ld_i_ltrur).


SELECT single IDENT
FROM THOCI
INTO @DATA(ld_i_calid).


SELECT single WARPL
FROM VIQMEL
INTO @DATA(ld_i_warpl).

DATA(ld_i_flg_popup) = 'Check type of data required'. . CALL FUNCTION 'CALCULATE_PRIORITY' EXPORTING * i_qmtyp = ld_i_qmtyp i_artpr = ld_i_artpr i_priok = ld_i_priok i_strmn = ld_i_strmn * i_strur = ld_i_strur * i_ltrmn = ld_i_ltrmn * i_ltrur = ld_i_ltrur * i_calid = ld_i_calid * i_warpl = ld_i_warpl * i_flg_popup = ld_i_flg_popup IMPORTING e_strmn = ld_e_strmn e_strur = ld_e_strur e_ltrmn = ld_e_ltrmn e_ltrur = ld_e_ltrur e_priokx = ld_e_priokx EXCEPTIONS INVALID_PRIO = 1 INVALID_DATE = 2 DIMENSION_NOT_FOUND = 3 UNIT_NOT_FOUND = 4 . " CALCULATE_PRIORITY
IF SY-SUBRC EQ 0. "All OK ELSEIF SY-SUBRC EQ 1. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 2. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 3. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 4. "Exception "Add code for exception here ENDIF.







ABAP code to compare 7.40 inline data declaration with original syntax

The below ABAP code uses the older none in-line data declarations. This allows you to see the coding differences/benefits of the later inline syntax. It may also be useful if you are using an older version of SAP as some of the newer syntax above, such as the @DATA is not available until 4.70 EHP 8.

DATA:
ld_e_strmn  TYPE VIQMEL-STRMN ,
ld_i_qmtyp  TYPE TQ80-QMTYP ,
ld_e_strur  TYPE VIQMEL-STRUR ,
ld_i_artpr  TYPE T356-ARTPR ,
ld_e_ltrmn  TYPE VIQMEL-LTRMN ,
ld_i_priok  TYPE T356-PRIOK ,
ld_e_ltrur  TYPE VIQMEL-LTRUR ,
ld_i_strmn  TYPE VIQMEL-STRMN ,
ld_e_priokx  TYPE T356_T-PRIOKX ,
ld_i_strur  TYPE VIQMEL-STRUR ,
ld_i_ltrmn  TYPE VIQMEL-LTRMN ,
ld_i_ltrur  TYPE VIQMEL-LTRUR ,
ld_i_calid  TYPE THOCI-IDENT ,
ld_i_warpl  TYPE VIQMEL-WARPL ,
ld_i_flg_popup  TYPE C .


SELECT single QMTYP
FROM TQ80
INTO ld_i_qmtyp.


SELECT single ARTPR
FROM T356
INTO ld_i_artpr.


SELECT single PRIOK
FROM T356
INTO ld_i_priok.


SELECT single STRMN
FROM VIQMEL
INTO ld_i_strmn.


SELECT single STRUR
FROM VIQMEL
INTO ld_i_strur.


SELECT single LTRMN
FROM VIQMEL
INTO ld_i_ltrmn.


SELECT single LTRUR
FROM VIQMEL
INTO ld_i_ltrur.


SELECT single IDENT
FROM THOCI
INTO ld_i_calid.


SELECT single WARPL
FROM VIQMEL
INTO ld_i_warpl.

ld_i_flg_popup = 'Check type of data required'.

Contribute (Add Comments)

Please help keep this info upto date and use the comments section below to add useful hints, tips and information specific to this SAP function. This will then be available for you and other users to easily find by simply searching on the object name CALCULATE_PRIORITY or its description.