SAP GET_SORT_BY_EXP Function Module for Select material stock sorted by expiration date









GET_SORT_BY_EXP is a standard get sort by exp SAP function module available within SAP R/3 or S/4 Hana systems, depending on your version and release level. It is used for Select material stock sorted by expiration date 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 get sort by exp FM, simply by entering the name GET_SORT_BY_EXP into the relevant SAP transaction such as SE37 or SE38.

Function Group: LMGT
Program Name: SAPLLMGT
Main Program: SAPLLMGT
Appliation area: L
Release date: N/A
Mode(Normal, Remote etc): Normal Function Module
Update:



Function GET_SORT_BY_EXP 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 'GET_SORT_BY_EXP'"Select material stock sorted by expiration date
EXPORTING
I_MATNR = "Material
I_LGNUM = "Warehouse id
I_WERKS = "Plant
I_STORAGE_TYP = "Storage type

IMPORTING
EV_UOM = "Unit of measure for loading equipment quantity 1

TABLES
T_INV_DATA = "Quants data

EXCEPTIONS
NOT_FOUND = 1 WRONG_CALL = 2 EXP_DATE_NOT_SUPPORTED = 3
.




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_SAPLLMGT_001 Extension for barcode translation
EXIT_SAPLLMGT_083 User exit for print

IMPORTING Parameters details for GET_SORT_BY_EXP

I_MATNR - Material

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

I_LGNUM - Warehouse id

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

I_WERKS - Plant

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

I_STORAGE_TYP - Storage type

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

EXPORTING Parameters details for GET_SORT_BY_EXP

EV_UOM - Unit of measure for loading equipment quantity 1

Data type: MLGN-LHME1
Optional: No
Call by Reference: Yes

TABLES Parameters details for GET_SORT_BY_EXP

T_INV_DATA - Quants data

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

EXCEPTIONS details

NOT_FOUND -

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

WRONG_CALL -

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

EXP_DATE_NOT_SUPPORTED -

Data type:
Optional: No
Call by Reference: Yes

Copy and paste ABAP code example for GET_SORT_BY_EXP 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_ev_uom  TYPE MLGN-LHME1, "   
lv_i_matnr  TYPE LQUA-MATNR, "   
lv_not_found  TYPE LQUA, "   
lt_t_inv_data  TYPE STANDARD TABLE OF LQUA, "   
lv_i_lgnum  TYPE LQUA-LGNUM, "   
lv_wrong_call  TYPE LQUA, "   
lv_i_werks  TYPE LQUA-WERKS, "   
lv_exp_date_not_supported  TYPE LQUA, "   
lv_i_storage_typ  TYPE LQUA-LGTYP. "   

  CALL FUNCTION 'GET_SORT_BY_EXP'  "Select material stock sorted by expiration date
    EXPORTING
         I_MATNR = lv_i_matnr
         I_LGNUM = lv_i_lgnum
         I_WERKS = lv_i_werks
         I_STORAGE_TYP = lv_i_storage_typ
    IMPORTING
         EV_UOM = lv_ev_uom
    TABLES
         T_INV_DATA = lt_t_inv_data
    EXCEPTIONS
        NOT_FOUND = 1
        WRONG_CALL = 2
        EXP_DATE_NOT_SUPPORTED = 3
. " GET_SORT_BY_EXP




ABAP code using 7.40 inline data declarations to call FM GET_SORT_BY_EXP

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 LHME1 FROM MLGN INTO @DATA(ld_ev_uom).
 
"SELECT single MATNR FROM LQUA INTO @DATA(ld_i_matnr).
 
 
 
"SELECT single LGNUM FROM LQUA INTO @DATA(ld_i_lgnum).
 
 
"SELECT single WERKS FROM LQUA INTO @DATA(ld_i_werks).
 
 
"SELECT single LGTYP FROM LQUA INTO @DATA(ld_i_storage_typ).
 


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!