SAP Function Modules

BAPI_DOCUMENT_GETLATEST2 SAP Function module







BAPI_DOCUMENT_GETLATEST2 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 BAPI_DOCUMENT_GETLATEST2 into the relevant SAP transaction such as SE37 or SE80.

Associated Function Group: CVBAPI
Released Date: Not Released
Processing type: Remote-Enabled
remote enabled module settings


Pattern for FM BAPI_DOCUMENT_GETLATEST2 - BAPI DOCUMENT GETLATEST2





CALL FUNCTION 'BAPI_DOCUMENT_GETLATEST2' "
  EXPORTING
    documenttype =              " bapi_doc_aux-doctype  Document type
    documentnumber =            " bapi_doc_aux-docnumber  Document number
    documentpart =              " bapi_doc_aux-docpart  Documentation - text lines
    documentversion =           " bapi_doc_aux-docversion  Document version
    multilevelexplosion = 'X'   " bapi_doc_aux-flag  Document management indicator
*   docbomchangenumber = SPACE  " bapi_doc_draw2-ecnumber  Change number
*   docbomvalidfrom = SY-DATUM  " bapi_doc_draw2-validfromdate  Valid-From Date
*   docbomrevisionlevel = SPACE  " bapi_doc_draw2-revlevel  Revision level
*   loadlatest = 'X'            " bapi_doc_aux-flag  Document management indicator
*   loadlatestreleased = 'X'    " bapi_doc_aux-flag  Document management indicator
*   search_new_maindoc = SPACE  " bapi_doc_aux-flag  Document management indicator
*   getdocdata = SPACE          " bapi_doc_aux-flag  Document management indicator
*   getobjectlinks = SPACE      " bapi_doc_aux-flag  Document management indicator
*   getdocdescriptions = SPACE  " bapi_doc_aux-flag  Document management indicator
*   getlongtexts = SPACE        " bapi_doc_aux-flag  Document management indicator
*   getstatuslog = SPACE        " bapi_doc_aux-flag  Document management indicator
*   getdocfiles = SPACE         " bapi_doc_aux-flag  Document management indicator
*   getcomponents = SPACE       " bapi_doc_aux-flag  Document management indicator
*   getclassification =         " bapi_doc_aux-flag  Document Management Indicator
*   getstructures =             " bapi_doc_aux-flag  Document Management Indicator
*   getwhereused =              " bapi_doc_aux-flag  Document Management Indicator
*   sortf_exclude = SPACE       " stpox-sortf   Sort string
*   sortf_stop_expl = SPACE     " stpox-sortf   Sort string
*   expl_docs_only_once = 'X'   " bapi_doc_aux-flag  Document management indicator
*   stop_on_first_error = SPACE  " bapi_doc_aux-flag  Document Management Indicator
  IMPORTING
    return =                    " bapiret2      Return parameter
    newversion =                " bapi_doc_aux-docversion  Document version
  TABLES
    docstructure =              " stpox         BOM Items (Extended for List Displays)
*   changedversions =           " tchg_vers     Table for Transferring Changed Document Versions
*   statuslist =                " tstate_order  Sequence of Status Check
*   documentdata =              " bapi_doc_draw2  BAPIS DMS: document data
*   objectlinks =               " bapi_doc_drad_keys  BAPIS DMS: document data
*   documentdescriptions =      " bapi_doc_drat_keys  BAPIS DMS: document data
*   longtexts =                 " bapi_doc_text_keys  BAPIS DMS: document data
*   statuslog =                 " bapi_doc_drap_keys  BAPIS DMS: document data
*   documentfiles =             " bapi_doc_files2_keys  BAPIS DMS: document data
*   components =                " bapi_doc_comp_keys  BAPIS DMS: document data
*   all_returns =               " bapiret2      Return Parameters
*   characteristicvalues =      " bapi_char_values_keys  BAPI Structure for Characteristic Value Assignment (Docs)
*   classallocations =          " bapi_class_allocation_keys  BAPI Structure for the Assignment of Classes to Several Objects
*   documentstructures =        " bapi_doc_structure_keys  BAPIs DMS: Structure Data for Several Documents
*   whereusedlists =            " bapi_doc_structure_keys  BAPIs DMS: Structure Data for Several Documents
    .  "  BAPI_DOCUMENT_GETLATEST2

ABAP code example for Function Module BAPI_DOCUMENT_GETLATEST2





The ABAP code below is a full code listing to execute function module BAPI_DOCUMENT_GETLATEST2 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_return  TYPE BAPIRET2 ,
ld_newversion  TYPE BAPI_DOC_AUX-DOCVERSION ,
it_docstructure  TYPE STANDARD TABLE OF STPOX,"TABLES PARAM
wa_docstructure  LIKE LINE OF it_docstructure ,
it_changedversions  TYPE STANDARD TABLE OF TCHG_VERS,"TABLES PARAM
wa_changedversions  LIKE LINE OF it_changedversions ,
it_statuslist  TYPE STANDARD TABLE OF TSTATE_ORDER,"TABLES PARAM
wa_statuslist  LIKE LINE OF it_statuslist ,
it_documentdata  TYPE STANDARD TABLE OF BAPI_DOC_DRAW2,"TABLES PARAM
wa_documentdata  LIKE LINE OF it_documentdata ,
it_objectlinks  TYPE STANDARD TABLE OF BAPI_DOC_DRAD_KEYS,"TABLES PARAM
wa_objectlinks  LIKE LINE OF it_objectlinks ,
it_documentdescriptions  TYPE STANDARD TABLE OF BAPI_DOC_DRAT_KEYS,"TABLES PARAM
wa_documentdescriptions  LIKE LINE OF it_documentdescriptions ,
it_longtexts  TYPE STANDARD TABLE OF BAPI_DOC_TEXT_KEYS,"TABLES PARAM
wa_longtexts  LIKE LINE OF it_longtexts ,
it_statuslog  TYPE STANDARD TABLE OF BAPI_DOC_DRAP_KEYS,"TABLES PARAM
wa_statuslog  LIKE LINE OF it_statuslog ,
it_documentfiles  TYPE STANDARD TABLE OF BAPI_DOC_FILES2_KEYS,"TABLES PARAM
wa_documentfiles  LIKE LINE OF it_documentfiles ,
it_components  TYPE STANDARD TABLE OF BAPI_DOC_COMP_KEYS,"TABLES PARAM
wa_components  LIKE LINE OF it_components ,
it_all_returns  TYPE STANDARD TABLE OF BAPIRET2,"TABLES PARAM
wa_all_returns  LIKE LINE OF it_all_returns ,
it_characteristicvalues  TYPE STANDARD TABLE OF BAPI_CHAR_VALUES_KEYS,"TABLES PARAM
wa_characteristicvalues  LIKE LINE OF it_characteristicvalues ,
it_classallocations  TYPE STANDARD TABLE OF BAPI_CLASS_ALLOCATION_KEYS,"TABLES PARAM
wa_classallocations  LIKE LINE OF it_classallocations ,
it_documentstructures  TYPE STANDARD TABLE OF BAPI_DOC_STRUCTURE_KEYS,"TABLES PARAM
wa_documentstructures  LIKE LINE OF it_documentstructures ,
it_whereusedlists  TYPE STANDARD TABLE OF BAPI_DOC_STRUCTURE_KEYS,"TABLES PARAM
wa_whereusedlists  LIKE LINE OF it_whereusedlists .


DATA(ld_documenttype) = some text here

DATA(ld_documentnumber) = some text here

DATA(ld_documentpart) = some text here

DATA(ld_documentversion) = some text here

DATA(ld_multilevelexplosion) = some text here

DATA(ld_docbomchangenumber) = some text here

DATA(ld_docbomvalidfrom) = 20210129

DATA(ld_docbomrevisionlevel) = some text here

DATA(ld_loadlatest) = some text here

DATA(ld_loadlatestreleased) = some text here

DATA(ld_search_new_maindoc) = some text here

DATA(ld_getdocdata) = some text here

DATA(ld_getobjectlinks) = some text here

DATA(ld_getdocdescriptions) = some text here

DATA(ld_getlongtexts) = some text here

DATA(ld_getstatuslog) = some text here

DATA(ld_getdocfiles) = some text here

DATA(ld_getcomponents) = some text here

DATA(ld_getclassification) = some text here

DATA(ld_getstructures) = some text here

DATA(ld_getwhereused) = some text here

DATA(ld_sortf_exclude) = some text here

DATA(ld_sortf_stop_expl) = some text here

DATA(ld_expl_docs_only_once) = some text here

DATA(ld_stop_on_first_error) = some text here

"populate fields of struture and append to itab
append wa_docstructure to it_docstructure.

"populate fields of struture and append to itab
append wa_changedversions to it_changedversions.

"populate fields of struture and append to itab
append wa_statuslist to it_statuslist.

"populate fields of struture and append to itab
append wa_documentdata to it_documentdata.

"populate fields of struture and append to itab
append wa_objectlinks to it_objectlinks.

"populate fields of struture and append to itab
append wa_documentdescriptions to it_documentdescriptions.

"populate fields of struture and append to itab
append wa_longtexts to it_longtexts.

"populate fields of struture and append to itab
append wa_statuslog to it_statuslog.

"populate fields of struture and append to itab
append wa_documentfiles to it_documentfiles.

"populate fields of struture and append to itab
append wa_components to it_components.

"populate fields of struture and append to itab
append wa_all_returns to it_all_returns.

"populate fields of struture and append to itab
append wa_characteristicvalues to it_characteristicvalues.

"populate fields of struture and append to itab
append wa_classallocations to it_classallocations.

"populate fields of struture and append to itab
append wa_documentstructures to it_documentstructures.

"populate fields of struture and append to itab
append wa_whereusedlists to it_whereusedlists. . CALL FUNCTION 'BAPI_DOCUMENT_GETLATEST2' EXPORTING documenttype = ld_documenttype documentnumber = ld_documentnumber documentpart = ld_documentpart documentversion = ld_documentversion multilevelexplosion = ld_multilevelexplosion * docbomchangenumber = ld_docbomchangenumber * docbomvalidfrom = ld_docbomvalidfrom * docbomrevisionlevel = ld_docbomrevisionlevel * loadlatest = ld_loadlatest * loadlatestreleased = ld_loadlatestreleased * search_new_maindoc = ld_search_new_maindoc * getdocdata = ld_getdocdata * getobjectlinks = ld_getobjectlinks * getdocdescriptions = ld_getdocdescriptions * getlongtexts = ld_getlongtexts * getstatuslog = ld_getstatuslog * getdocfiles = ld_getdocfiles * getcomponents = ld_getcomponents * getclassification = ld_getclassification * getstructures = ld_getstructures * getwhereused = ld_getwhereused * sortf_exclude = ld_sortf_exclude * sortf_stop_expl = ld_sortf_stop_expl * expl_docs_only_once = ld_expl_docs_only_once * stop_on_first_error = ld_stop_on_first_error IMPORTING return = ld_return newversion = ld_newversion TABLES docstructure = it_docstructure * changedversions = it_changedversions * statuslist = it_statuslist * documentdata = it_documentdata * objectlinks = it_objectlinks * documentdescriptions = it_documentdescriptions * longtexts = it_longtexts * statuslog = it_statuslog * documentfiles = it_documentfiles * components = it_components * all_returns = it_all_returns * characteristicvalues = it_characteristicvalues * classallocations = it_classallocations * documentstructures = it_documentstructures * whereusedlists = it_whereusedlists . " BAPI_DOCUMENT_GETLATEST2
IF SY-SUBRC EQ 0. "All OK 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_return  TYPE BAPIRET2 ,
ld_documenttype  TYPE BAPI_DOC_AUX-DOCTYPE ,
it_docstructure  TYPE STANDARD TABLE OF STPOX ,
wa_docstructure  LIKE LINE OF it_docstructure,
ld_newversion  TYPE BAPI_DOC_AUX-DOCVERSION ,
ld_documentnumber  TYPE BAPI_DOC_AUX-DOCNUMBER ,
it_changedversions  TYPE STANDARD TABLE OF TCHG_VERS ,
wa_changedversions  LIKE LINE OF it_changedversions,
ld_documentpart  TYPE BAPI_DOC_AUX-DOCPART ,
it_statuslist  TYPE STANDARD TABLE OF TSTATE_ORDER ,
wa_statuslist  LIKE LINE OF it_statuslist,
ld_documentversion  TYPE BAPI_DOC_AUX-DOCVERSION ,
it_documentdata  TYPE STANDARD TABLE OF BAPI_DOC_DRAW2 ,
wa_documentdata  LIKE LINE OF it_documentdata,
ld_multilevelexplosion  TYPE BAPI_DOC_AUX-FLAG ,
it_objectlinks  TYPE STANDARD TABLE OF BAPI_DOC_DRAD_KEYS ,
wa_objectlinks  LIKE LINE OF it_objectlinks,
ld_docbomchangenumber  TYPE BAPI_DOC_DRAW2-ECNUMBER ,
it_documentdescriptions  TYPE STANDARD TABLE OF BAPI_DOC_DRAT_KEYS ,
wa_documentdescriptions  LIKE LINE OF it_documentdescriptions,
ld_docbomvalidfrom  TYPE BAPI_DOC_DRAW2-VALIDFROMDATE ,
it_longtexts  TYPE STANDARD TABLE OF BAPI_DOC_TEXT_KEYS ,
wa_longtexts  LIKE LINE OF it_longtexts,
ld_docbomrevisionlevel  TYPE BAPI_DOC_DRAW2-REVLEVEL ,
it_statuslog  TYPE STANDARD TABLE OF BAPI_DOC_DRAP_KEYS ,
wa_statuslog  LIKE LINE OF it_statuslog,
ld_loadlatest  TYPE BAPI_DOC_AUX-FLAG ,
it_documentfiles  TYPE STANDARD TABLE OF BAPI_DOC_FILES2_KEYS ,
wa_documentfiles  LIKE LINE OF it_documentfiles,
it_components  TYPE STANDARD TABLE OF BAPI_DOC_COMP_KEYS ,
wa_components  LIKE LINE OF it_components,
ld_loadlatestreleased  TYPE BAPI_DOC_AUX-FLAG ,
ld_search_new_maindoc  TYPE BAPI_DOC_AUX-FLAG ,
it_all_returns  TYPE STANDARD TABLE OF BAPIRET2 ,
wa_all_returns  LIKE LINE OF it_all_returns,
it_characteristicvalues  TYPE STANDARD TABLE OF BAPI_CHAR_VALUES_KEYS ,
wa_characteristicvalues  LIKE LINE OF it_characteristicvalues,
ld_getdocdata  TYPE BAPI_DOC_AUX-FLAG ,
it_classallocations  TYPE STANDARD TABLE OF BAPI_CLASS_ALLOCATION_KEYS ,
wa_classallocations  LIKE LINE OF it_classallocations,
ld_getobjectlinks  TYPE BAPI_DOC_AUX-FLAG ,
it_documentstructures  TYPE STANDARD TABLE OF BAPI_DOC_STRUCTURE_KEYS ,
wa_documentstructures  LIKE LINE OF it_documentstructures,
ld_getdocdescriptions  TYPE BAPI_DOC_AUX-FLAG ,
it_whereusedlists  TYPE STANDARD TABLE OF BAPI_DOC_STRUCTURE_KEYS ,
wa_whereusedlists  LIKE LINE OF it_whereusedlists,
ld_getlongtexts  TYPE BAPI_DOC_AUX-FLAG ,
ld_getstatuslog  TYPE BAPI_DOC_AUX-FLAG ,
ld_getdocfiles  TYPE BAPI_DOC_AUX-FLAG ,
ld_getcomponents  TYPE BAPI_DOC_AUX-FLAG ,
ld_getclassification  TYPE BAPI_DOC_AUX-FLAG ,
ld_getstructures  TYPE BAPI_DOC_AUX-FLAG ,
ld_getwhereused  TYPE BAPI_DOC_AUX-FLAG ,
ld_sortf_exclude  TYPE STPOX-SORTF ,
ld_sortf_stop_expl  TYPE STPOX-SORTF ,
ld_expl_docs_only_once  TYPE BAPI_DOC_AUX-FLAG ,
ld_stop_on_first_error  TYPE BAPI_DOC_AUX-FLAG .


ld_documenttype = some text here

"populate fields of struture and append to itab
append wa_docstructure to it_docstructure.

ld_documentnumber = some text here

"populate fields of struture and append to itab
append wa_changedversions to it_changedversions.

ld_documentpart = some text here

"populate fields of struture and append to itab
append wa_statuslist to it_statuslist.

ld_documentversion = some text here

"populate fields of struture and append to itab
append wa_documentdata to it_documentdata.

ld_multilevelexplosion = some text here

"populate fields of struture and append to itab
append wa_objectlinks to it_objectlinks.

ld_docbomchangenumber = some text here

"populate fields of struture and append to itab
append wa_documentdescriptions to it_documentdescriptions.

ld_docbomvalidfrom = 20210129

"populate fields of struture and append to itab
append wa_longtexts to it_longtexts.

ld_docbomrevisionlevel = some text here

"populate fields of struture and append to itab
append wa_statuslog to it_statuslog.

ld_loadlatest = some text here

"populate fields of struture and append to itab
append wa_documentfiles to it_documentfiles.

"populate fields of struture and append to itab
append wa_components to it_components.

ld_loadlatestreleased = some text here

ld_search_new_maindoc = some text here

"populate fields of struture and append to itab
append wa_all_returns to it_all_returns.

"populate fields of struture and append to itab
append wa_characteristicvalues to it_characteristicvalues.

ld_getdocdata = some text here

"populate fields of struture and append to itab
append wa_classallocations to it_classallocations.

ld_getobjectlinks = some text here

"populate fields of struture and append to itab
append wa_documentstructures to it_documentstructures.

ld_getdocdescriptions = some text here

"populate fields of struture and append to itab
append wa_whereusedlists to it_whereusedlists.

ld_getlongtexts = some text here

ld_getstatuslog = some text here

ld_getdocfiles = some text here

ld_getcomponents = some text here

ld_getclassification = some text here

ld_getstructures = some text here

ld_getwhereused = some text here

ld_sortf_exclude = some text here

ld_sortf_stop_expl = some text here

ld_expl_docs_only_once = some text here

ld_stop_on_first_error = some text here

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 BAPI_DOCUMENT_GETLATEST2 or its description.