SAP RETR_DOCUMENT Function Module for Find document as replacement for non-functional matchcode subkeys
RETR_DOCUMENT is a standard retr document SAP function module available within SAP R/3 or S/4 Hana systems, depending on your version and release level. It is used for Find document as replacement for non-functional matchcode subkeys 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 retr document FM, simply by entering the name RETR_DOCUMENT into the relevant SAP transaction such as SE37 or SE38.
Function Group: CVIN
Program Name: SAPLCVIN
Main Program: SAPLCVIN
Appliation area: M
Release date: N/A
Mode(Normal, Remote etc): Normal Function Module
Update:

Function RETR_DOCUMENT 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 'RETR_DOCUMENT'"Find document as replacement for non-functional matchcode subkeys.
EXPORTING
DYNAME_IMP = "Name of the program for screen
DYNUMB_IMP = "Number of the screen on which F4 is pressed
F_DOKAR_IMP = "Document type for search
F_DOKNR_IMP = "Document number for search
F_DOKTL_IMP = "Part document for search
F_DOKVR_IMP = "Document version for search
* STEP_LOOP_ZEILE = SY-STEPL "
* MATCHCODE_SELECTION = ' ' "
* DISPLAY = ' ' "
IMPORTING
DOKAR_EXP = "Document type
DOKNR_EXP = "Document number
DOKTL_EXP = "Part document
DOKVR_EXP = "Document version
IMPORTING Parameters details for RETR_DOCUMENT
DYNAME_IMP - Name of the program for screen
Data type: SY-REPIDOptional: No
Call by Reference: No ( called with pass by value option)
DYNUMB_IMP - Number of the screen on which F4 is pressed
Data type: SY-DYNNROptional: No
Call by Reference: No ( called with pass by value option)
F_DOKAR_IMP - Document type for search
Data type: DYNPREAD-FIELDNAMEOptional: No
Call by Reference: No ( called with pass by value option)
F_DOKNR_IMP - Document number for search
Data type: DYNPREAD-FIELDNAMEOptional: No
Call by Reference: No ( called with pass by value option)
F_DOKTL_IMP - Part document for search
Data type: DYNPREAD-FIELDNAMEOptional: No
Call by Reference: No ( called with pass by value option)
F_DOKVR_IMP - Document version for search
Data type: DYNPREAD-FIELDNAMEOptional: No
Call by Reference: No ( called with pass by value option)
STEP_LOOP_ZEILE -
Data type: SY-STEPLDefault: SY-STEPL
Optional: Yes
Call by Reference: No ( called with pass by value option)
MATCHCODE_SELECTION -
Data type:Default: ' '
Optional: Yes
Call by Reference: No ( called with pass by value option)
DISPLAY -
Data type:Default: ' '
Optional: Yes
Call by Reference: No ( called with pass by value option)
EXPORTING Parameters details for RETR_DOCUMENT
DOKAR_EXP - Document type
Data type: DRAW-DOKAROptional: No
Call by Reference: No ( called with pass by value option)
DOKNR_EXP - Document number
Data type: DRAW-DOKNROptional: No
Call by Reference: No ( called with pass by value option)
DOKTL_EXP - Part document
Data type: DRAW-DOKTLOptional: No
Call by Reference: No ( called with pass by value option)
DOKVR_EXP - Document version
Data type: DRAW-DOKVROptional: No
Call by Reference: No ( called with pass by value option)
Copy and paste ABAP code example for RETR_DOCUMENT 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_dokar_exp | TYPE DRAW-DOKAR, " | |||
| lv_dyname_imp | TYPE SY-REPID, " | |||
| lv_doknr_exp | TYPE DRAW-DOKNR, " | |||
| lv_dynumb_imp | TYPE SY-DYNNR, " | |||
| lv_doktl_exp | TYPE DRAW-DOKTL, " | |||
| lv_f_dokar_imp | TYPE DYNPREAD-FIELDNAME, " | |||
| lv_dokvr_exp | TYPE DRAW-DOKVR, " | |||
| lv_f_doknr_imp | TYPE DYNPREAD-FIELDNAME, " | |||
| lv_f_doktl_imp | TYPE DYNPREAD-FIELDNAME, " | |||
| lv_f_dokvr_imp | TYPE DYNPREAD-FIELDNAME, " | |||
| lv_step_loop_zeile | TYPE SY-STEPL, " SY-STEPL | |||
| lv_matchcode_selection | TYPE SY, " ' ' | |||
| lv_display | TYPE SY. " ' ' |
|   CALL FUNCTION 'RETR_DOCUMENT' "Find document as replacement for non-functional matchcode subkeys |
| EXPORTING | ||
| DYNAME_IMP | = lv_dyname_imp | |
| DYNUMB_IMP | = lv_dynumb_imp | |
| F_DOKAR_IMP | = lv_f_dokar_imp | |
| F_DOKNR_IMP | = lv_f_doknr_imp | |
| F_DOKTL_IMP | = lv_f_doktl_imp | |
| F_DOKVR_IMP | = lv_f_dokvr_imp | |
| STEP_LOOP_ZEILE | = lv_step_loop_zeile | |
| MATCHCODE_SELECTION | = lv_matchcode_selection | |
| DISPLAY | = lv_display | |
| IMPORTING | ||
| DOKAR_EXP | = lv_dokar_exp | |
| DOKNR_EXP | = lv_doknr_exp | |
| DOKTL_EXP | = lv_doktl_exp | |
| DOKVR_EXP | = lv_dokvr_exp | |
| . " RETR_DOCUMENT | ||
ABAP code using 7.40 inline data declarations to call FM RETR_DOCUMENT
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 DOKAR FROM DRAW INTO @DATA(ld_dokar_exp). | ||||
| "SELECT single REPID FROM SY INTO @DATA(ld_dyname_imp). | ||||
| "SELECT single DOKNR FROM DRAW INTO @DATA(ld_doknr_exp). | ||||
| "SELECT single DYNNR FROM SY INTO @DATA(ld_dynumb_imp). | ||||
| "SELECT single DOKTL FROM DRAW INTO @DATA(ld_doktl_exp). | ||||
| "SELECT single FIELDNAME FROM DYNPREAD INTO @DATA(ld_f_dokar_imp). | ||||
| "SELECT single DOKVR FROM DRAW INTO @DATA(ld_dokvr_exp). | ||||
| "SELECT single FIELDNAME FROM DYNPREAD INTO @DATA(ld_f_doknr_imp). | ||||
| "SELECT single FIELDNAME FROM DYNPREAD INTO @DATA(ld_f_doktl_imp). | ||||
| "SELECT single FIELDNAME FROM DYNPREAD INTO @DATA(ld_f_dokvr_imp). | ||||
| "SELECT single STEPL FROM SY INTO @DATA(ld_step_loop_zeile). | ||||
| DATA(ld_step_loop_zeile) | = SY-STEPL. | |||
| DATA(ld_matchcode_selection) | = ' '. | |||
| DATA(ld_display) | = ' '. | |||
Search for further information about these or an SAP related objects