Bapis For The Document Management System
Bapis For The Document Management System
Bapis For The Document Management System
Since release 4.5 we have BAPIs for the Document Management System. With these BAPIs you
can access nearly all the functions of the DMS from external programs. The BAPIs contain all
the functions from the PP-DMS dialog interface (look into the PP-CAD documentation for
details of the dialog functions).
Since release 4.5, new functionality in the PP-DMS interface will only be accessible with the
BAPIs. The functions of the CAD dialog interface will not be enhanced any more.
Recommendation:
New integrations for release 4.5 using the PP-DMS interface shall only use the BAPIs. Existing
integrations shall be converted to BAPIs if possible.
List of new BAPIs:
Document.Change
Change document
Functionality
You can use this method to change documents.
You can also check the original application files (1 and 2) into the SAP database, vault, or archive at the same time.
Limitations:
Additional files are not supported Long texts for object links are not supported Value assignments for the object
links are not supported Mass check-ins are not supported
Example
**..... Document data
DATA: ls_doc LIKE bapi_doc_draw.
**.... Descriptions
lt_drat LIKE bapi_doc_drat OCCURS 0 WITH HEADER LINE,
**----------------------------------------------------------------------
ls_doc-documenttype = 'DRW'.
ls_doc-documentnumber = '4711'.
ls_doc-documentversion = '000'.
ls_doc-documentpart = '00'.
**----------------------------------------------------------------------
CALL FUNCTION 'BAPI_DOCUMENT_CHANGE'
documentpart = ls_doc-documentpart
documentversion = ls_doc-documentversion
documentdata = ls_doc
documentdatax = ls_docx
** Error occurred ??
IF ls_return-type CA 'EA'.
ROLLBACK WORK.
MESSAGE ID '26' TYPE 'I' NUMBER '000'
WITH ls_return-message.
ELSE.
COMMIT WORK.
ENDIF.
Notes
Apart from the document data, the follwoing data can be changed:
Object links
Classifications and characteristic value assignments
Language-dependent document descriptions
Document long texts
Document structures
Originals (1 and 2)
Method
Document.Change2
Change document
Functionality
You can change documents with this function module.
It can also be used to check in original application files into the SAP database, vault, or archive simultaneously.
Restrictions:
Additonal files are supported only as interface parameter for future deveoplemnt Mass check in is not supported
Example
**..... Document data
DATA: ls_doc LIKE bapi_doc_draw2.
**----------------------------------------------------------------------
ls_doc-documenttype = 'DRW'.
ls_doc-documentnumber = '4711'.
ls_doc-documentversion = '00'.
ls_doc-documentpart = '000'.
ls_doc-description = 'Transmission'.
ls_doc-laboratory = ''.
ls_docx-description = 'X'.
ls_docX-laboratory = 'X'.
REFRESH lt_drad.
lt_drad-objecttype = 'MARA'.
lt_drad-objectkey = 'M0815'.
APPEND lt_drad.
**----------------------------------------------------------------------
** Change document
**----------------------------------------------------------------------
CALL FUNCTION 'BAPI_DOCUMENT_CHANGE2'
documentpart = ls_doc-documentpart
documentversion = ls_doc-documentversion
documentdata = ls_doc
documentdatax = ls_docx
IF ls_return-type CA 'EA'.
ROLLBACK WORK.
MESSAGE ID '26' TYPE 'I' NUMBER '000'
WITH ls_return-message.
ELSE.
COMMIT WORK.
ENDIF.
Notes
In addition to the document data you can also change the following data:
Object links
Classification and characteristic valuations
Language dependent document descriptions
Document long texts
Document structures
Original application files
Method
Document.CheckIn
Check in document
Functionality
You can use this method to check a document into an archive, a vault, or the SAP database. You can check both
original application files (1 and 2) in at the same time.
When you check a document in, you can set a new status.
Restrictions:
Additional files are not supported
Example
**..... Document key
DATA: lf_doctype LIKE bapi_doc_draw-documenttype,
**.... Originals
**----------------------------------------------------------------------
**----------------------------------------------------------------------
** Check in document
**----------------------------------------------------------------------
CALL FUNCTION 'BAPI_DOCUMENT_CHECKIN'
documentpart = lf_docpart
documentversion = lf_docversion
hostname = ''
statusintern = ''
statusextern = lf_status
statuslog = ''
IMPORTING: return = ls_return
TABLES: documentfiles = lt_files.
** Error occurred ??
IF ls_return-type CA 'EA'.
ROLLBACK WORK.
MESSAGE ID '26' TYPE 'I' NUMBER '000'
WITH ls_return-message.
ELSE.
COMMIT WORK.
ENDIF.
Method
Document.CheckIn2
Check in document
Functionality
You can use a function module to check in a document into an archive, a vault, or into the R/3 Database. You can
also check in originals "DOCUMENTFILES" at the same time.
Optional you can also set the following data when you check in a document:
Status with log entry Revision level Change number
restrictions:
Additional files are supported only as interface parameters for future development.
Example
**..... Document key
DATA: lf_doctype LIKE bapi_doc_draw-documenttype,
lf_docnumber LIKE bapi_doc_draw-documentnumber,
lf_docpart LIKE bapi_doc_draw-documenttype,
lf_docversion LIKE bapi_doc_draw-documentversion,
lf_status LIKE bapi_doc_draw-statusextern,
**.... Originals
DATA: lt_files LIKE bapi_doc_files2 OCCURS 0 WITH HEADER LINE.
**----------------------------------------------------------------------
**----------------------------------------------------------------------
** Check in document
**----------------------------------------------------------------------
CALL FUNCTION 'BAPI_DOCUMENT_CHECKIN2'
EXPORTING: documenttype = lf_doctype
documentnumber = lf_docnumber
documentpart = lf_docpart
documentversion = lf_docversion
hostname = ''
statusintern = ''
statusextern = lf_status
statuslog = ''
IMPORTING: return = ls_return
TABLES: documentfiles = lt_files.
** Error occured ??
IF ls_return-type CA 'EA'.
ROLLBACK WORK.
MESSAGE ID '26' TYPE 'I' NUMBER '000'
WITH ls_return-message.
ELSE.
COMMIT WORK.
ENDIF.
Method
Document.CheckOutModify
Check out document for processing
Functionality
This method is used to check out a document for processing.
Restrictions:
Additional files are not supported. You cannot check out several documents for processing at the same time.
Example
**..... Document key
DATA: lf_doctype LIKE bapi_doc_draw-documenttype,
**.... Bapi-Returnstruktur
ls_return LIKE bapiret2.
**----------------------------------------------------------------------
REFRESH lt_files.
CLEAR lt_files.
lf_status = 'IA'.
documentpart = lf_docpart
documentversion = lf_docversion
originaltype = '1'
documentfile = lf_filename
statusextern = lf_status
IMPORTING: return = ls_return.
** Errors occurred ??
IF ls_return-type CA 'EA'.
ROLLBACK WORK.
MESSAGE ID '26' TYPE 'I' NUMBER '000'
WITH ls_return-message.
ELSE.
COMMIT WORK.
ENDIF.
Method
Document.CheckOutModify2
Check out document for processing
Functionality
You use this method to check out a document for processing. Optionally you can assign the following data when
you check in a document:
Status with log entry Revision level Change number
Restrictions:
Additional files are not supported. These exist as interface parameters for future development. You cannot check out
several documents for processing.
Example
**..... Document key
DATA: lf_doctype LIKE bapi_doc_draw-documenttype,
lf_docnumber LIKE bapi_doc_draw-documentnumber,
lf_docpart LIKE bapi_doc_draw-documenttype,
lf_docversion LIKE bapi_doc_draw-documenttype,
ls_documentfile LIKE bapi_doc_files2,
ls_checkedoutfile LIKE bapi_doc_files2,
lf_status LIKE bapi_doc_draw-statusextern,
**.... Bapi-Returnstruktur
ls_return LIKE bapiret2.
**----------------------------------------------------------------------
REFRESH lt_files.
CLEAR lt_files.
** Errors occurred ??
IF ls_return-type CA 'EA'.
ROLLBACK WORK.
MESSAGE ID '26' TYPE 'I' NUMBER '000'
WITH ls_return-message.
ELSE.
COMMIT WORK.
ENDIF.
Method
Document.CheckOutView
Check out document for display
Functionality
You can use this method to check out a document and any existing document structure for display.
You can use the "GetStructure" button if you want to check out the document structure aswell. The
"DocumentStructure" table is used to define how many documents should be checked out in the document structure
(certain documents may be checked out in current status). When the documents are transferred to the function
module using the "DocumentStructure" table, only the documents that you have preselected are checked out.
Restrictions:
Additional files are not supported.
Example
**..... Document key
DATA: lf_doctype LIKE bapi_doc_draw-documenttype,
**----------------------------------------------------------------------
REFRESH lt_files.
CLEAR lt_files.
documentnumber = lf_docnumber
documentpart = lf_docpart
documentversion = lf_docversion
originaltype = '1'
getstructure = '1'
originalpath = lf_pathname
hostname = ' '
IMPORTING: return = ls_return
** Errors occurred ??
IF ls_return-type CA 'EA'.
ROLLBACK WORK.
ELSE.
COMMIT WORK.
ENDIF.
Method
Document.CheckOutView2
Check out document for display
Functionality
You use this function module to check out originals of a document and available dokument structures for display.
The function module BAPI_DOCUMENT_CHECKOUTVIEW has been enhanced to allow checking out document
types that have two originals allocated to them.
The parameter DOCUMENTFILE controls which original you want to check out.
You can decide with the switch GetStructure whether an available document structure can also be checked out. The
application (DOCUMENTFILE-WSAPPLICATION) is also available as a selection criterion. The table
DocumentStructure is used to define which documents of the structure you want to check out (certain documents
can already have been checked out in the current status).
Only consistent documents in a table are checked out.
If no entry is made the function module checks out all documents of the structure for
display.
Restrictions:
Additional files are supported only as interface parameters for future developments.
Example
**.... Bapi-Returnstruktur
ls_return LIKE bapiret2.
**----------------------------------------------------------------------
REFRESH lt_files.
CLEAR lt_files.
** Error occurred ??
IF ls_return-type CA 'EA'.
ROLLBACK WORK.
MESSAGE ID '26' TYPE 'I' NUMBER '000'
WITH ls_return-message.
ELSE.
COMMIT WORK.
ENDIF.
Method
Document.Create2
Create document
Functionality
You can use this function module to create documents and all data that belongs to it. You can create a document info
record with the following data:
Langauge dependent short and long texts Any number of originals Object links Classification characteristics
Document structures
You can also check in the original application files into the R/3 Database, vault, or archive.
Restrictions:
Additional files supported only as interface parameters COMPONENTS for future development. Valuations of
object links are not supported.
Example
**..... Bapi-Returnstruktur
ls_return LIKE bapiret2.
ls_doc-statusextern = 'AF'.
ls_doc-laboratory = '001'.
lt_files-storagecategory = 'SAP-SYSTEM'.
lt_files-docfile = 'c:\temp\drawing.txt'.
lt_wsapplication = 'TXT'.
APPEND lt_files.
lt_files-storagecategory = 'VAULT'.
lt_files-docfile = 'c:\temp\drawing.dwg'.
lt_wsapplication = 'DWG'.
APPEND lt_files.
lt_files-storagecategory = 'SAP-SYSTEM'.
lt_files-docfile = 'c:\temp\drawing.ppt'.
lt_wsapplication = 'PPT'.
APPEND lt_files.
** Short texts
CLEAR lt_drat.
REFRESH lt_drat.
* ---------------------------------------------------------------------
* Create document
* ---------------------------------------------------------------------
CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'
EXPORTING: documentdata = ls_doc
IMPORTING: documenttype = lf_doctype
documentnumber = lf_docnumber
documentpart = lf_docpart
documentversion = lf_docversion
return = ls_return
TABLES: documentdescriptions = lt_drat
objectlinks = lt_drad
documentfiles = lt_files.
ELSE.
COMMIT WORK.
ENDIF.
Notes
You can insert the following data in addition to document data:
Object links Classifications and characteristic valuation Language dependent document descriptions Long text
documents Document structure Originals
Method
Document.CreateFromData
Create document
Functionality
You can use this method to create documents and their respective data.
You can also check the original application files (1 and 2) into the SAP data base, vault, or archive.
Restrictions:
Additional files are not supported Long texts for object links are not supported Value assignments for the object
links are not supported
Example
**..... Document data
DATA: ls_doc LIKE bapi_doc_draw.
**.... Descriptions
**----------------------------------------------------------------------
ls_doc-documenttype = 'DRW'.
ls_doc-documentnumber = '4711'.
ls_doc-documentversion = '000'.
ls_doc-documentpart = '00'.
ls_doc-laboratory = '001'.
ls_doc-wsapplication1 = 'DWG'.
** Check original 1 into the SAP data base at the same time
REFRESH lt_files.
CLEAR lt_files.
lt_files-originaltype = '1'.
lt_files-datacarrier = 'SAP-SYSTEM'.
lt_files-docfile = 'c:\temp\drawing1.dwg'.
APPEND lt_files.
** Description in english
CLEAR lt_drat.
REFRESH lt_drat.
lt_drat-language = 'EN'.
lt_drat-description = 'gear'.
APPEND lt_drat.
* ---------------------------------------------------------------------
* Create document
* ---------------------------------------------------------------------
CALL FUNCTION 'BAPI_DOCUMENT_CREATE'
documentnumber = lf_docnumber
documentpart = lf_docpart
documentversion = lf_docversion
return = ls_return
documentfiles = lt_files.
** Error occurred ??
IF ls_return-type CA 'EA'.
ROLLBACK WORK.
ELSE.
COMMIT WORK.
ENDIF.
Notes
Apart from the document data, you can create the following data:
Object links
Classifications and characteristic value assignments
Language-dependent document descriptions
Document long texts
Document structures
Originals (1 and 2)
Method
Document.CreateFromData2
Create document
Functionality
You can use this function module to create documents and all data that belongs to it. You can create a document info
record with the following data:
Langauge dependent short and long texts Any number of originals Object links Classification characteristics
Document structures
You can also check in the original application files into the R/3 Database, vault, or archive.
Restrictions:
Additional files supported only as interface parameters COMPONENTS for future development. Valuations of
object links are not supported.
Example
**..... Bapi-Returnstruktur
ls_return LIKE bapiret2.
ls_doc-statusextern = 'AF'.
ls_doc-laboratory = '001'.
lt_files-storagecategory = 'SAP-SYSTEM'.
lt_files-docfile = 'c:\temp\drawing.txt'.
lt_wsapplication = 'TXT'.
APPEND lt_files.
lt_files-storagecategory = 'VAULT'.
lt_files-docfile = 'c:\temp\drawing.dwg'.
lt_wsapplication = 'DWG'.
APPEND lt_files.
lt_files-storagecategory = 'SAP-SYSTEM'.
lt_files-docfile = 'c:\temp\drawing.ppt'.
lt_wsapplication = 'PPT'.
APPEND lt_files.
** Short texts
CLEAR lt_drat.
REFRESH lt_drat.
* ---------------------------------------------------------------------
* Create document
* ---------------------------------------------------------------------
CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'
EXPORTING: documentdata = ls_doc
IMPORTING: documenttype = lf_doctype
documentnumber = lf_docnumber
documentpart = lf_docpart
documentversion = lf_docversion
return = ls_return
TABLES: documentdescriptions = lt_drat
objectlinks = lt_drad
documentfiles = lt_files.
ELSE.
COMMIT WORK.
ENDIF.
Notes
You can insert the following data in addition to document data:
Object links Classifications and characteristic valuation Language dependent document descriptions Long text
documents Document structure Originals
Method
Document.CreateFromSource
Create Document with Template Source
Functionality
You can use this method to create a new document by copying from an existing document.
Notes
When the new document is created, any document structure that may exist is also copied. You can define whether
all, only specific, or no object links are copied.
Method
Document.CreateFromSource2
Create Document with Template Source
Functionality
You use this function for creating new documents using a template.
Optionally you can assign the following data:
Status log entry Revision level Change number
Notes
An existing document structure is copied when you create a new document. You can define how you want to copy
the object links:
Copye Value for OBJECTTYPE
all *
Only certain <Database table>
None Blank
Explanation of the <Database table>
The internal descriptions from the table TCLO (for example, MARA for material) are used for the object type
OBJECTTYPE.
The object key OBJECTKEY is made of key fields of the SAP object that is also in the table TCLO.
Method
Document.CreateNewVersion
Create new document version
Functionality
You can use this method to create a new version for an existing document.
Notes
When you create the new document, any existing document structure is also copied. You can define whether all,
only specific, or no object links at all should be copied.
Method
Document.CreateNewVersion2
Create new document version
Functionality
You use this function module to create new versions of documents. Optionally the following data can be changed:
Log entry Revision level Change number
Notes
You can copy an available document structure when creating a new document. You can also set how you want to
copy object links:
Copy Value for OBJECTTYPE
all *
Only certain <Databasetable>
none Blank
Explanation for <Databasetable>
The internal descriptions from the table TCLO (for example, MARA for material) are used for the object type
OBJECTTYPE. The object key OBJECTKEY contains the kex fields of the SAP Object that is also taken from the
table TCLO.
Method
Document.Delete
Delete document or set deletion indicator
Functionality
You can use this method to delete documents.
Method
Document.Dequeue
Unlock document
Functionality
You can use this method to withdraw a change lock.
Method
Document.Enqueue
Lock document
Functionality
You can use this method to lock a document against a change.
Notes
The lock is withdrawn by either the following change BAPI or by calling BAPI_DOCUMENT_DEQUEUE.
Method
Document.ExistenceCheck1
Check if document exists
Functionality
ou can use this method to check whether a document exists.
Method
Document.GetActualVersion
Determine valid versions for a document
Functionality
You can use this method to determine the current and valid version of a document.
Notes
You can use the "ReleasedOnly" button to determine whether just the released versions or all the versions should be
determined.
Method
Document.GetApplication
Determine Data for an Application
Functionality
You can use this method to determine all the Customizing settings for one work station application.
Method
Document.GetDataCarrierDetail
Determine detail data of a data carrier
Functionality
You can use this method to determine the Customizing settings for a specific data carrier.
Method
Document.GetDataCarrierList
Determine List of Data Carriers
Functionality
ou can use this method to determine the data carriers defined in Customizing.
You can use the appropriate button to define which types of data carrier should be displayed, for example, only
archives, vaults, and so on.
Notes
See also: BAPI_DOCUMENT_GETDCDETAIL
Method
Document.GetDCList2
Determine List of Data Carriers
Functionality
You can use this method to report the data carriers that are defined in Customizing.
You can use each switch to define which tyoe of data carrier you want to display, for example, only archives, vaults
and so on.
Notes
See also BAPI_DOCUMENT_GETDCDETAIL
Method
Document.GetDetail
Determine Detail Data for a Document
Functionality
You can use this method to determine detailed data for a document.
Notes
The following data can be read:
Main document data Short texts/descriptions Long texts Object links
Method
Document.GetDetail2
Determine Detail Data for a Document
Functionality
You can use this method to set detail data for a document. The following import parameters are available for
controlling output:
GetObjectLinks GetStatusLog GetLongTexts GetActiveFiles
Setting additional files is not supported. Future development supports the interface parameters GetComponents and
COMPONENTS.
Example
** Document key
DATA: lf_doctype LIKE bapi_doc_draw-documenttype,
lf_docnumber LIKE bapi_doc_draw-documentnumber,
lf_docpart LIKE bapi_doc_draw-documenttype,
lf_docversion LIKE bapi_doc_draw-documenttype.
** Bapi-Return structure
ls_return LIKE bapiret2.
** Originals Document hierarchy
DATA: lt_files LIKE bapi_doc_files2 OCCURS 0 WITH HEADER LINE,
ls_document LIKE bapi_doc_draw2.
*********************************************************************
REFRESH lt_files.
CLEAR lt_files.
Document.GetDocumentTypeDetail
Determine Data for a Document Type
Functionality
You can use this method to determine the Customizing settings for a specific document type.
Method
Document.GetFrontendType
Determine Frontend Type for Computer
Functionality
You can use this method to determine the appropriate front end type for a front end computer.
Method
Document.GetList
Find Document
Functionality
You can use this method to find a document and select a list of documents. A table containing the document data is
created.
You can use the "MAXROWS" parameter to restrict the number of selected documents in the hit list.
Example
**... List of selected documents
DATA: LT_DOC_DATA LIKE BAPI_DOC_DRAW OCCURS 0 WITH HEADER LINE,
**----------------------------------------------------------------------
LT_DOCNR_SEL-SIGN = 'I'.
LT_DOCNR_SEL-OPTION = 'CP'.
LT_DOCNR_SEL-DOCUMENTNUMBER_LOW = 'JB*'.
APPEND LT_DOCNR_SEL.
** Select documents
CALL FUNCTION 'BAPI_DOCUMENT_GETLIST'
RETURN = LS_RETURN
TABLES: DOCNUMBERSELECTION = LT_DOCNR_SEL
DOCUMENTLIST = LT_DOC_DATA.
** Errors occurred ??
IF ls_return-type CA 'EA'.
MESSAGE ID '26' TYPE 'E' NUMBER '000'
WITH ls_return-message.
EXIT.
ENDIF.
LOOP AT LT_DOC_DATA.
....
....
ENDLOOP.
Notes
Document type
Document number (as value range from ... to ...)
Document part
Document version
Description
Person responsible
Authorization group
Office/laboratory
Change number
Deletion flag
Data carrier
CAD indicator
Work station application
Document status
Method
Document.GetObjectDocuments
Determine Documents for an Object
Functionality
You can use this method to determine all the documents that are linked to an object (for example, material master).
Notes
The internal descriptions from TCLO are used for the object type (for example, MARA for material master). The
object key is copied as a string (according to TCLO).
Method
Document.GetStatus
Determine document status
Functionality
You can use this method to read the current status of the document.
Notes
The external language-dependent status abbreviation (in the appropriate logon language) and the internal status are
entered.
Method
Document.GetStatusList
Determine Status List for a Document Type
Functionality
You can use this method to determine the features of the status that are defined in Customizing.
If no status is entered, all the statuses that are defined for the document type are determined.
These are, for example:
List of all the statuses (F4 help) Status network Status types .....
Method
Document.GetStructure
Determine document structure
Functionality
You can use this method to determine the document structure for an existing document.
Method
Document.SetFrontendType
Set frontend type for computer
Functionality
You can use this method to set the appropriate front end type for a front end computer.
Method
Document.SetStatus
Set Document Status
Functionality
You can use this method to set a new status for the document.
Notes
The internal and external status is displayed. Basically the following applies: if the internal status is displayed, this
has priority, otherwise the internal status is read via the external status abbreviation.