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 Document.Change2 Document.CheckIn Document.CheckIn2 Document.CheckOutModify Document.CheckOutModify2 Document.CheckOutView Document.CheckOutView2 Document.Create2 Document.CreateFromData Document.CreateFromData2 Document.CreateFromSource Document.CreateFromSource2 Document.CreateNewVersion Document.CreateNewVersion2 Document.Delete Document.Dequeue Document.Enqueue Document.ExistenceCheck1 Document.GetActualVersion Document.GetApplication Document.GetDataCarrierDetail Document.GetDataCarrierList Document.GetDCList2 Document.GetDetail Document.GetDetail2 Document.GetDocumentTypeDetail Document.GetFrontendType Document.GetList Document.GetObjectDocuments Document.GetStatus Document.GetStatusList Document.GetStructure Document.SetFrontendType Document.SetStatus 4.5 4.6 4.5 4.6 4.5 4.6 4.5 4.6 4.6 4.5 4.6 4.5 4.6 4.5 4.6 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.6 4.5 4.6 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5 Change document Change document Check in document Check in document Check out document for processing Check out document for processing Check out document for display Check out document for display Create document Create document Create document Create Document with Template Source Create Document with Template Source Create new document version Create new document version Delete document or set deletion indicator Unlock document Lock document Check if document exists Determine valid versions for a document Determine Data for an Application Determine detail data of a data carrier Determine List of Data Carriers Determine List of Data Carriers Determine Detail Data for a Document Determine Detail Data for a Document Determine Data for a Document Type Determine Frontend Type for Computer Find Document Determine Documents for an Object Determine document status Determine Status List for a Document Type Determine document structure Set frontend type for computer Set Document Status

Method

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. **..... Indicator for relevancy to change ls_docx LIKE bapi_doc_drawx,

**..... Bapi return structure ls_return LIKE bapiret2.

**.... Originals that are checked in at the same time DATA: lt_files LIKE bapi_doc_files OCCURS 0 WITH HEADER LINE,

**.... Descriptions lt_drat LIKE bapi_doc_drat OCCURS 0 WITH HEADER LINE, **.... Object links lt_drad LIKE bapi_doc_drad OCCURS 0 WITH HEADER LINE.

**---------------------------------------------------------------------** Allocate document data ls_doc-documenttype = 'DRW'. ls_doc-documentnumber = '4711'. ls_doc-documentversion = '000'. ls_doc-documentpart ls_doc-description ls_doc-laboratory = '00'. = 'Gear box'. = ''.

** Set indicator for relevancy to change ls_docx-description = 'X'. ls_docX-laboratory = 'X'.

** Add/create object link CLEAR lt_drad. REFRESH lt_drad. lt_drad-objecttype = 'MARA'. lt_drad-objectkey = 'M0815'. APPEND lt_drad.

**---------------------------------------------------------------------** Change document **---------------------------------------------------------------------CALL FUNCTION 'BAPI_DOCUMENT_CHANGE' EXPORTING: documenttype = ls_doc-documenttype documentnumber = ls_doc-documentnumber documentpart = ls_doc-documentpart documentversion = ls_doc-documentversion = ls_doc documentdatax

documentdata

= ls_docx

IMPORTING: return = ls_return TABLES: objectlinks = lt_drad. ** 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. **..... Indicator for change relevance ls_docx LIKE bapi_doc_drawx2,

**..... Bapi return structure ls_return LIKE bapiret2.

**.... Originals that are checked in simultaneously lt_files LIKE bapi_doc_files OCCURS 0 WITH HEADER LINE,

**.... Short texts lt_drat LIKE bapi_doc_drat OCCURS 0 WITH HEADER LINE, **.... Object links lt_drad LIKE bapi_doc_drad OCCURS 0 WITH HEADER LINE.

**----------------------------------------------------------------------

ls_doc-documenttype

= 'DRW'.

ls_doc-documentnumber = '4711'. ls_doc-documentversion = '00'. ls_doc-documentpart = '000'.

ls_doc-description ls_doc-laboratory **

= 'Transmission'. = ''.

Set indicator for change relevance = 'X'. = 'X'.

ls_docx-description ls_docX-laboratory ** Insert object links CLEAR lt_drad.

REFRESH lt_drad. lt_drad-objecttype = 'MARA'. lt_drad-objectkey = 'M0815'. APPEND lt_drad.

MESSAGE ID '26' TYPE 'I' NUMBER '000' WITH ls_return-message.**---------------------------------------------------------------------** Change document **---------------------------------------------------------------------CALL FUNCTION 'BAPI_DOCUMENT_CHANGE2' EXPORTING: documenttype = ls_doc-documenttype documentnumber = ls_doc-documentnumber documentpart = ls_doc-documentpart documentversion = ls_doc-documentversion = ls_doc documentdatax documentdata = ls_docx IMPORTING: return = ls_return TABLES: objectlinks = lt_drad. COMMIT WORK. ENDIF. ROLLBACK WORK. ** Did an error occur ?? IF ls_return-type CA 'EA'. 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 . ELSE.

. a vault. Bapi return structure ls_return LIKE bapiret2. you can set a new status. lf_status LIKE bapi_doc_draw-statusextern. = 'c:\temp\drawing1. ** Check original 1 into the SAP database REFRESH lt_files... **. lf_docnumber LIKE bapi_doc_draw-documentnumber.. When you check a document in. lt_files-originaltype = '1'. CLEAR lt_files. lf_docpart LIKE bapi_doc_draw-documentpart. lt_files-datacarrier lt_files-docfile APPEND lt_files. lf_docversion LIKE bapi_doc_draw-documentversion. Originals DATA: lt_files LIKE bapi_doc_files OCCURS 0 WITH HEADER LINE. You can check both original application files (1 and 2) in at the same time.. = 'SAP-SYSTEM'. **....dwg'.. lf_status = 'RE'. lf_docversion = '000'. Document key DATA: lf_doctype LIKE bapi_doc_draw-documenttype. lf_docnumber = '4711'. **---------------------------------------------------------------------** Allocate document data lf_doctype = 'DRW'. Restrictions: Additional files are not supported Example **. lf_docpart = '00'. " Original 1 " Check in = SAPDB " Original file **---------------------------------------------------------------------** Check in document **---------------------------------------------------------------------CALL FUNCTION 'BAPI_DOCUMENT_CHECKIN' EXPORTING: documenttype = lf_doctype .Method Document.CheckIn Check in document Functionality You can use this method to check a document into an archive. or the SAP database..

ROLLBACK WORK. . ** Error occurred ?? IF ls_return-type CA 'EA'. ENDIF. MESSAGE ID '26' TYPE 'I' NUMBER '000' WITH ls_return-message.documentnumber documentpart = lf_docnumber = lf_docpart documentversion = lf_docversion = '' statusintern statusextern hostname = '' = lf_status statuslog = '' IMPORTING: return = ls_return TABLES: documentfiles = lt_files. COMMIT WORK. ELSE.

. a vault.dwg'.. lf_docpart LIKE bapi_doc_draw-documenttype.Method Document. ** Check in original 1 into R/3 Database REFRESH lt_files. lf_status LIKE bapi_doc_draw-statusextern. Document key DATA: lf_doctype LIKE bapi_doc_draw-documenttype. " Original file APPEND lt_files. or into the R/3 Database. lf_status = 'RE'.. lf_docnumber LIKE bapi_doc_draw-documentnumber..CheckIn2 Check in document Functionality You can use a function module to check in a document into an archive. CLEAR lt_files.. lf_docversion LIKE bapi_doc_draw-documentversion. **---------------------------------------------------------------------** Allocate document data lf_doctype = 'DRW'. lf_docversion = '00'. " Storage = R/3-DB lt_files-docfile = 'c:\temp\drawing1. lf_docnumber = '4711'. lf_docpart = '000'.. 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. lt_files-storagecategory = 'R/3 SYSTEM'. **---------------------------------------------------------------------** 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. Originals DATA: lt_files LIKE bapi_doc_files2 OCCURS 0 WITH HEADER LINE.. You can also check in originals "DOCUMENTFILES" at the same time... **. Bapi-Return structure ls_return LIKE bapiret2. . Example **. **..

ROLLBACK WORK. ENDIF. ELSE. MESSAGE ID '26' TYPE 'I' NUMBER '000' WITH ls_return-message.** Error occured ?? IF ls_return-type CA 'EA'. COMMIT WORK. .

** Check out document (original 1) for processing CALL FUNCTION 'BAPI_DOCUMENT_CHECKOUTMODIFY' EXPORTING: documenttype = lf_doctype documentnumber = lf_docnumber documentpart = lf_docpart documentversion = '1' documentfile = lf_docversion originaltype = lf_filename statusextern = lf_status IMPORTING: return = ls_return. CLEAR lt_files.. lf_docpart = '00'.. ** Errors occurred ?? . Document key DATA: lf_doctype LIKE bapi_doc_draw-documenttype. ** Define path where original is to be stored lf_filename = 'c:\temp\work. ** Set new status for document lf_status = 'IA'. lf_docpart LIKE bapi_doc_draw-documenttype. You cannot check out several documents for processing at the same time... Restrictions: Additional files are not supported. **.Method Document.dwg'. Bapi-Returnstruktur ls_return LIKE bapiret2. **---------------------------------------------------------------------** Allocate document data lf_doctype = 'DRW'. lf_docversion = '000'.. lf_status LIKE bapi_doc_draw-statusextern.. REFRESH lt_files. lf_docnumber LIKE bapi_doc_draw-documentnumber. Example **. lf_filename LIKE bapi_doc_draw-docfile1..CheckOutModify Check out document for processing Functionality This method is used to check out a document for processing. lf_docversion LIKE bapi_doc_draw-documenttype. lf_docnumber = '4711'.

MESSAGE ID '26' TYPE 'I' NUMBER '000' WITH ls_return-message.IF ls_return-type CA 'EA'. . COMMIT WORK. ELSE. ENDIF. ROLLBACK WORK.

ls_documentfile LIKE bapi_doc_files2. REFRESH lt_files. **.CheckOutModify2 Check out document for processing Functionality You use this method to check out a document for processing. Example **.. These exist as interface parameters for future development. lf_docversion LIKE bapi_doc_draw-documenttype. ls_documentfile-docfile = 'work. lf_docnumber LIKE bapi_doc_draw-documentnumber. Bapi-Returnstruktur ls_return LIKE bapiret2. lf_docpart LIKE bapi_doc_draw-documenttype. lf_docnumber = '4711'. ** Set new status for document lf_status = 'IA'. Document key DATA: lf_doctype LIKE bapi_doc_draw-documenttype. You cannot check out several documents for processing.'.. * alternative ls_documentfile-docpath = 'c:\temp\. CLEAR lt_files. lf_docversion = '00'. **---------------------------------------------------------------------** Allocate document data lf_doctype = 'DRW'. ls_checkedoutfile LIKE bapi_doc_files2.. ** Errors occurred ?? IF ls_return-type CA 'EA'.Method Document.. ** Check out document (Original 1) for changes CALL FUNCTION 'BAPI_DOCUMENT_CHECKOUTMODIFY2' EXPORTING: documenttype = lf_doctype documentnumber = lf_docnumber documentpart = lf_docpart documentversion = lf_docversion documentfile = ls_documentfile statusextern = lf_status IMPORTING: return = ls_return checkedoutfile = ls_checkedoutfile... 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. ** Define path in which the original is to be stored ls_documentfile-docfile = 'c:\temp\work. lf_status LIKE bapi_doc_draw-statusextern.dwg'. . ROLLBACK WORK.dwg'. lf_docpart = '000'..

ELSE.MESSAGE ID '26' TYPE 'I' NUMBER '000' WITH ls_return-message. COMMIT WORK. ENDIF. .

CheckOutView Check out document for display Functionality You can use this method to check out a document and any existing document structure for display. lf_docpart LIKE bapi_doc_draw-documenttype... REFRESH lt_files.. **. lf_docnumber = '4711'. lf_docpart = '00'. 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).. only the documents that you have preselected are checked out. You can use the "GetStructure" button if you want to check out the document structure aswell. Document key DATA: lf_doctype LIKE bapi_doc_draw-documenttype. When the documents are transferred to the function module using the "DocumentStructure" table. Restrictions: Additional files are not supported. **---------------------------------------------------------------------** Allocate document data lf_doctype = 'DRW'. lf_docnumber LIKE bapi_doc_draw-documentnumber. ** Check out document (original 1) for viewing CALL FUNCTION 'BAPI_DOCUMENT_CHECKOUTVIEW' EXPORTING: documenttype = lf_doctype documentnumber = lf_docnumber documentpart = lf_docversion originaltype = '1' originalpath = lf_docpart documentversion = '1' getstructure = lf_pathname . Originals that have been checked out DATA: lt_files LIKE bapi_doc_files OCCURS 0 WITH HEADER LINE.. CLEAR lt_files. **. ** Define path where file is stored lf_pathname = 'c:\temp\'. lf_docversion = '000'... Bapi return structure ls_return LIKE bapiret2. lf_pathname LIKE bapi_doc_draw-docfile1.. Example **...Method Document. lf_docversion LIKE bapi_doc_draw-documenttype.

ROLLBACK WORK. . COMMIT WORK. ELSE. documentfiles ** Errors occurred ?? IF ls_return-type CA 'EA'. MESSAGE ID '26' TYPE 'I' NUMBER '000' WITH ls_return-message. ENDIF.hostname IMPORTING: TABLES: = ' ' return = ls_return = lt_files.

DATA: ls_documentfile LIKE bapi_doc_files2. lf_docversion = '000'... 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).Method Document. The parameter DOCUMENTFILE controls which original you want to check out.. lf_docnumber LIKE bapi_doc_draw-documentnumber. Document key DATA: lf_doctype LIKE bapi_doc_draw-documenttype. **. REFRESH lt_files. Example **. The application (DOCUMENTFILE-WSAPPLICATION) is also available as a selection criterion. lf_docpart LIKE bapi_doc_draw-documenttype. Only consistent documents in a table are checked out. lf_docnumber = '4711'. **---------------------------------------------------------------------** Allocate document data lf_doctype = 'DRW'.. lf_docpart = '00'. Bapi-Returnstruktur ls_return LIKE bapiret2. Originals that were checked out DATA: lt_files LIKE bapi_doc_files2 OCCURS 0 WITH HEADER LINE.. CLEAR lt_files. ** Define path in which original is stored lf_pathname = 'c:\temp\'. If no entry is made the function module checks out all documents of the structure for display. **... The function module BAPI_DOCUMENT_CHECKOUTVIEW has been enhanced to allow checking out document types that have two originals allocated to them. You can decide with the switch GetStructure whether an available document structure can also be checked out.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.. ** Document (Originals of application type WRD) check out for viewing CALL FUNCTION 'BAPI_DOCUMENT_CHECKOUTVIEW2' EXPORTING: documenttype = lf_doctype documentnumber = lf_docnumber documentpart = lf_docpart documentversion = lf_docversion . Restrictions: Additional files are supported only as interface parameters for future developments. ls_documentfile-wsapplication = 'TXT'. lf_pathname LIKE bapi_doc_draw-docfile1.. lf_docversion LIKE bapi_doc_draw-documenttype..

. ENDIF. ELSE. ROLLBACK WORK. MESSAGE ID '26' TYPE 'I' NUMBER '000' WITH ls_return-message. COMMIT WORK.documentfile = ls_documentfile getstructure = '1' originalpath = lf_pathname hostname = ' ' IMPORTING: return = ls_return TABLES: documentfiles = lt_files. ** Error occurred ?? IF ls_return-type CA 'EA'.

.Create2 Create document Functionality You can use this function module to create documents and all data that belongs to it. lf_docpart LIKE bapi_doc_draw2-documenttype. Bapi-Returnstruktur ls_return LIKE bapiret2..dwg'. lt_files-docfile = 'c:\temp\drawing.... ls_doc-documentversion = '00'. CLEAR lt_files. Key feilds of the document DATA: lf_doctype LIKE bapi_doc_draw2-documenttype.txt'. APPEND lt_files. **---------------------------------------------------------------------** Allcoate document data ls_doc-documenttype = 'DRW'. **. lf_docnumber LIKE bapi_doc_draw2-documentnumber.... **. Restrictions: Additional files supported only as interface parameters COMPONENTS for future development. lt_files-storagecategory = 'SAP-SYSTEM'... lt_files-storagecategory = 'VAULT'.. vault. ls_doc-documentnumber = '4711'.. ls_doc-documentpart = '000'. lt_files-docfile = 'c:\temp\drawing. lf_docversion LIKE bapi_doc_draw2-documenttype... . Originals that are checked in simultaneously DATA: lt_files LIKE bapi_doc_files2 OCCURS 0 WITH HEADER LINE. lt_wsapplication = 'TXT'.. **...Method Document. ls_doc-laboratory = '001'. ls_doc-statusextern = 'AF'. Short texts lt_drat LIKE bapi_doc_drat OCCURS 0 WITH HEADER LINE. **.. or archive. Object links lt_drad LIKE bapi_doc_drad OCCURS 0 WITH HEADER LINE. **.. Document data DATA: ls_doc LIKE bapi_doc_draw2.. Valuations of object links are not supported. 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. ** Check in original 1 simultaneously in the R/3 Database REFRESH lt_files. Example **.

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 . ** Object link to material master CLEAR lt_drad.ppt'. ENDIF. APPEND lt_drat. lt_drat-description = 'Getriebe'. lt_wsapplication = 'PPT'. lt_drad-objecttype = 'MARA'. ELSE. lt_files-docfile = 'c:\temp\drawing. ** Short texts CLEAR lt_drat. lt_drat-description = 'gear'. * --------------------------------------------------------------------* 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. APPEND lt_files. APPEND lt_files. REFRESH lt_drad. ** German short text lt_drat-language = 'DE'. APPEND lt_drat. lt_files-storagecategory = 'SAP-SYSTEM'. REFRESH lt_drat. ROLLBACK WORK. lt_drad-objectkey = 'M4711'. APPEND lt_drad. ** Did an error occur ?? IF ls_return-type CA 'EA'.lt_wsapplication = 'DWG'. COMMIT WORK. MESSAGE ID '26' TYPE 'I' NUMBER '000' WITH ls_return-message. ** English short text lt_drat-language = 'EN'.

. **.. or archive. = 'Gear box'.. Restrictions: Additional files are not supported Long texts for object links are not supported Value assignments for the object links are not supported Example **.. Bapi return structure ls_return LIKE bapiret2. lf_docpart LIKE bapi_doc_draw-documenttype.CreateFromData Create document Functionality You can use this method to create documents and their respective data...Method Document. **. **---------------------------------------------------------------------** Allocate document data ls_doc-documenttype = 'DRW'.. vault... Object links lt_drad LIKE bapi_doc_drad OCCURS 0 WITH HEADER LINE. **. ls_doc-laboratory = '001'. ls_doc-documentversion = '000'. ls_doc-wsapplication1 = 'DWG'. ** Check original 1 into the SAP data base at the same time REFRESH lt_files. Document data DATA: ls_doc LIKE bapi_doc_draw. **. You can also check the original application files (1 and 2) into the SAP data base. CLEAR lt_files........ lf_docnumber LIKE bapi_doc_draw-documentnumber.. = 'AF'. Originals that are checked in at the same time DATA: lt_files LIKE bapi_doc_files OCCURS 0 WITH HEADER LINE. lf_docversion LIKE bapi_doc_draw-documenttype.. ls_doc-documentpart ls_doc-description ls_doc-statusextern = '00'. **.. Descriptions lt_drat LIKE bapi_doc_drat OCCURS 0 WITH HEADER LINE. ls_doc-documentnumber = '4711'. key fields of new document DATA: lf_doctype LIKE bapi_doc_draw-documenttype...

dwg'. Notes Apart from the document data. lt_drat-language = 'EN'. APPEND lt_files. lt_files-docfile = 'c:\temp\drawing1. REFRESH lt_drad. ** Object link to material master CLEAR lt_drad. ROLLBACK WORK. you can create the following data: . ELSE. ** Description in english CLEAR lt_drat. lt_drad-objectkey = 'M4711'. APPEND lt_drat. REFRESH lt_drat. lt_files-datacarrier = 'SAP-SYSTEM'. * --------------------------------------------------------------------* Create document * --------------------------------------------------------------------CALL FUNCTION 'BAPI_DOCUMENT_CREATE' EXPORTING: documentdata IMPORTING: documenttype documentnumber = ls_doc = lf_doctype = lf_docnumber documentpart = lf_docversion return = lf_docpart documentversion = ls_return TABLES: documentdescriptions = lt_drat objectlinks = lt_drad documentfiles = lt_files. lt_drat-description = 'gear'. ** Error occurred ?? IF ls_return-type CA 'EA'. lt_drad-objecttype = 'MARA'. ENDIF. APPEND lt_drad. COMMIT WORK.lt_files-originaltype = '1'. MESSAGE ID '26' TYPE 'I' NUMBER '000' WITH ls_return-message.

Object links Classifications and characteristic value assignments Language-dependent document descriptions Document long texts Document structures Originals (1 and 2) .

APPEND lt_files... or archive.. Example **. ls_doc-documentpart = '000'.. lt_files-docfile = 'c:\temp\drawing..dwg'. vault. Bapi-Returnstruktur ls_return LIKE bapiret2. Valuations of object links are not supported... ls_doc-documentversion = '00'. lf_docversion LIKE bapi_doc_draw2-documenttype. Restrictions: Additional files supported only as interface parameters COMPONENTS for future development. 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.. lt_files-docfile = 'c:\temp\drawing. lt_wsapplication = 'TXT'. ls_doc-documentnumber = '4711'..Method Document. Originals that are checked in simultaneously DATA: lt_files LIKE bapi_doc_files2 OCCURS 0 WITH HEADER LINE.CreateFromData2 Create document Functionality You can use this function module to create documents and all data that belongs to it.. Object links lt_drad LIKE bapi_doc_drad OCCURS 0 WITH HEADER LINE. **. ls_doc-statusextern = 'AF'. ** Check in original 1 simultaneously in the R/3 Database REFRESH lt_files.. Key feilds of the document DATA: lf_doctype LIKE bapi_doc_draw2-documenttype. lt_files-storagecategory = 'VAULT'... **. lt_files-storagecategory = 'SAP-SYSTEM'. lf_docnumber LIKE bapi_doc_draw2-documentnumber. . **.... CLEAR lt_files... ls_doc-laboratory = '001'. **. Short texts lt_drat LIKE bapi_doc_drat OCCURS 0 WITH HEADER LINE. **---------------------------------------------------------------------** Allcoate document data ls_doc-documenttype = 'DRW'. lf_docpart LIKE bapi_doc_draw2-documenttype. Document data DATA: ls_doc LIKE bapi_doc_draw2.txt'.. **..

REFRESH lt_drad. lt_wsapplication = 'PPT'. lt_files-docfile = 'c:\temp\drawing. lt_drat-description = 'gear'.lt_wsapplication = 'DWG'.ppt'. ** Object link to material master CLEAR lt_drad. ENDIF. APPEND lt_drad. COMMIT WORK. ** Did an error occur ?? IF ls_return-type CA 'EA'. ** Short texts CLEAR lt_drat. ** German short text lt_drat-language = 'DE'. REFRESH lt_drat. lt_files-storagecategory = 'SAP-SYSTEM'. MESSAGE ID '26' TYPE 'I' NUMBER '000' WITH ls_return-message. lt_drad-objecttype = 'MARA'. * --------------------------------------------------------------------* 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. lt_drad-objectkey = 'M4711'. 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 . ** English short text lt_drat-language = 'EN'. APPEND lt_files. APPEND lt_files. ROLLBACK WORK. ELSE. lt_drat-description = 'Getriebe'. APPEND lt_drat. APPEND lt_drat.

only specific. Notes When the new document is created.Method Document. or no object links are copied. You can define whether all.CreateFromSource Create Document with Template Source Functionality You can use this method to create a new document by copying from an existing document. any document structure that may exist is also copied. .

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. 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. .Method Document.CreateFromSource2 Create Document with Template Source Functionality You use this function for creating new documents using a template. 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.

.CreateNewVersion Create new document version Functionality You can use this method to create a new version for an existing document. only specific. or no object links at all should be copied.Method Document. You can define whether all. any existing document structure is also copied. Notes When you create the 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. The object key OBJECTKEY contains the kex fields of the SAP Object that is also taken from the table TCLO. . MARA for material) are used for the object type OBJECTTYPE.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.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.Method Document. Notes The lock is withdrawn by either the following change BAPI or by calling BAPI_DOCUMENT_DEQUEUE.

.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.Method 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.

Notes See also: BAPI_DOCUMENT_GETDCDETAIL . for example. You can use the appropriate button to define which types of data carrier should be displayed.Method Document.GetDataCarrierList Determine List of Data Carriers Functionality ou can use this method to determine the data carriers defined in Customizing. vaults. only archives. and so on.

GetDCList2 Determine List of Data Carriers Functionality You can use this method to report the data carriers that are defined in Customizing. Notes See also BAPI_DOCUMENT_GETDCDETAIL . for example. You can use each switch to define which tyoe of data carrier you want to display. only archives. vaults and so on.Method Document.

Method Document. Notes The following data can be read: Main document data Short texts/descriptions Long texts Object links .GetDetail Determine Detail Data for a Document Functionality You can use this method to determine detailed data for a document.

** Did error occur ?? IF ls_return-type CA 'EA'.GetDetail2 Determine Detail Data for a Document Functionality You can use this method to set detail data for a document. lf_docversion LIKE bapi_doc_draw-documenttype. ** Originals Document hierarchy DATA: lt_files LIKE bapi_doc_files2 OCCURS 0 WITH HEADER LINE. ** Set detail information for the document CALL FUNCTION 'BAPI_DOCUMENT_GETDETAIL2' EXPORTING: documenttype = lf_doctype documentnumber = lf_docnumber documentpart = lf_docpart documentversion = lf_docversion getobjectlinks = 'X' getstatuslog = 'X' getlongtexts = 'X' getactivefiles = 'X' IMPORTING: documentdata = ls_document return = ls_return TABLES: documentfiles = lt_files. . lf_docpart = '000'. MESSAGE ID '26' TYPE 'I' NUMBER '000' WITH ls_return-message. Example ** Document key DATA: lf_doctype LIKE bapi_doc_draw-documenttype. ** Bapi-Return structure ls_return LIKE bapiret2. lf_docversion = '00'. lf_docnumber = '4711'. CLEAR lt_files. ENDIF. ********************************************************************* ** Allocate document data lf_doctype = 'DRW'.Method Document. lf_docnumber LIKE bapi_doc_draw-documentnumber. ls_document LIKE bapi_doc_draw2. The following import parameters are available for controlling output: GetObjectLinks GetStatusLog GetLongTexts GetActiveFiles Setting additional files is not supported. lf_docpart LIKE bapi_doc_draw-documenttype. REFRESH lt_files. Future development supports the interface parameters GetComponents and COMPONENTS.

Notes The following data can be read: Document main data Short texts Long texts Object links Originals .

Method Document. .GetDocumentTypeDetail Determine Data for a Document Type Functionality You can use this method to determine the Customizing settings for a specific document type.

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. .

. **. **. You can use the "MAXROWS" parameter to restrict the number of selected documents in the hit list. Bapi return structure LS_RETURN LIKE BAPIRET2. APPEND LT_DOCNR_SEL. Number of data records (number of records in the hit list) LF_FOUNDROWS LIKE BAPI_DOC_AUX-MAXROWS.Method Document. number of data records that are returned LF_MAXROWS LIKE BAPI_DOC_AUX-MAXROWS.. **.... LT_DOCNR_SEL-OPTION = 'CP'.. List of selected documents DATA: LT_DOC_DATA LIKE BAPI_DOC_DRAW OCCURS 0 WITH HEADER LINE... LT_DOCNR_SEL-SIGN = 'I'. ** Select documents CALL FUNCTION 'BAPI_DOCUMENT_GETLIST' EXPORTING: DOCUMENTTYPE DESCRIPTION MAXROWS = 250 IMPORTING: FOUNDROWS RETURN TABLES: DOCUMENTLIST = 'DRW' = 'Gear*' " max 250 data records = LF_FOUNDROWS = LS_RETURN DOCNUMBERSELECTION = LT_DOCNR_SEL = LT_DOC_DATA.. Example **. LT_DOCNR_SEL-DOCUMENTNUMBER_LOW = 'JB*'.. **.GetList Find Document Functionality You can use this method to find a document and select a list of documents. Value range for document number LT_DOCNR_SEL LIKE BAPI_DOC_SELNR OCCURS 0 WITH HEADER LINE. Max. ** Errors occurred ?? IF ls_return-type CA 'EA'. **---------------------------------------------------------------------** Construct value range for document number CLEAR: LT_DOCNR_SEL. A table containing the document data is created..

.. ENDLOOP.. . EXIT.MESSAGE ID '26' TYPE 'E' NUMBER '000' WITH ls_return-message.. LOOP AT LT_DOC_DATA.. ENDIF. ... Notes You can use the following data as search criteria: Document type Document number (as value range from ....) Document part Document version Description Person responsible Authorization group Office/laboratory Change number Deletion flag Data carrier CAD indicator Work station application Document status . to .

The object key is copied as a string (according to TCLO).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).

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.

... all the statuses that are defined for the document type are determined. If no status is entered. These are...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. for example: List of all the statuses (F4 help) Status network Status types .

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. . Basically the following applies: if the internal status is displayed.Method Document. otherwise the internal status is read via the external status abbreviation. Notes The internal and external status is displayed. this has priority.