Sie sind auf Seite 1von 51

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.

**---------------------------------------------------------------------** 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. ** Did an error occur ?? 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, lf_docnumber LIKE bapi_doc_draw-documentnumber, lf_docpart LIKE bapi_doc_draw-documentpart, lf_docversion LIKE bapi_doc_draw-documentversion, lf_status LIKE bapi_doc_draw-statusextern,

**.... Bapi return structure ls_return LIKE bapiret2. **.... Originals DATA: lt_files LIKE bapi_doc_files OCCURS 0 WITH HEADER LINE. **---------------------------------------------------------------------** Allocate document data lf_doctype = 'DRW'. lf_docnumber = '4711'. lf_docversion = '000'. lf_docpart = '00'. lf_status = 'RE'.

** Check original 1 into the SAP database REFRESH lt_files. CLEAR lt_files.

lt_files-originaltype = '1'. lt_files-datacarrier lt_files-docfile APPEND lt_files. = 'SAP-SYSTEM'. = 'c:\temp\drawing1.dwg'.

" Original 1 " Check in = SAPDB " Original file

**---------------------------------------------------------------------** Check in document **---------------------------------------------------------------------CALL FUNCTION 'BAPI_DOCUMENT_CHECKIN' EXPORTING: documenttype = lf_doctype

documentnumber documentpart

= lf_docnumber

= lf_docpart documentversion = lf_docversion = '' statusintern statusextern

hostname

= '' = 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, **.... Bapi-Return structure ls_return LIKE bapiret2. **.... Originals DATA: lt_files LIKE bapi_doc_files2 OCCURS 0 WITH HEADER LINE. **---------------------------------------------------------------------** Allocate document data lf_doctype = 'DRW'. lf_docnumber = '4711'. lf_docversion = '00'. lf_docpart = '000'. lf_status = 'RE'. ** Check in original 1 into R/3 Database REFRESH lt_files. CLEAR lt_files. lt_files-storagecategory = 'R/3 SYSTEM'. " Storage = R/3-DB lt_files-docfile = 'c:\temp\drawing1.dwg'. " Original file APPEND lt_files. **---------------------------------------------------------------------** 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, lf_docnumber LIKE bapi_doc_draw-documentnumber, lf_docpart LIKE bapi_doc_draw-documenttype, lf_docversion LIKE bapi_doc_draw-documenttype, lf_filename LIKE bapi_doc_draw-docfile1, lf_status LIKE bapi_doc_draw-statusextern,

**.... Bapi-Returnstruktur ls_return LIKE bapiret2. **---------------------------------------------------------------------** Allocate document data lf_doctype = 'DRW'. lf_docnumber = '4711'. lf_docversion = '000'. lf_docpart = '00'. REFRESH lt_files. CLEAR lt_files. ** Define path where original is to be stored lf_filename = 'c:\temp\work.dwg'. ** Set new status for document lf_status = 'IA'. ** 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. ** 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. **---------------------------------------------------------------------** Allocate document data lf_doctype = 'DRW'. lf_docnumber = '4711'. lf_docversion = '00'. lf_docpart = '000'. REFRESH lt_files. CLEAR lt_files. ** Define path in which the original is to be stored ls_documentfile-docfile = 'c:\temp\work.dwg'. * alternative ls_documentfile-docpath = 'c:\temp\.', ls_documentfile-docfile = 'work.dwg'. ** Set new status for document lf_status = 'IA'. ** 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. ** 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, lf_docnumber LIKE bapi_doc_draw-documentnumber, lf_docpart LIKE bapi_doc_draw-documenttype, lf_docversion LIKE bapi_doc_draw-documenttype, lf_pathname LIKE bapi_doc_draw-docfile1,

**.... Bapi return structure ls_return LIKE bapiret2. **.... Originals that have been checked out DATA: lt_files LIKE bapi_doc_files OCCURS 0 WITH HEADER LINE. **---------------------------------------------------------------------** Allocate document data lf_doctype = 'DRW'. lf_docnumber = '4711'. lf_docversion = '000'. lf_docpart = '00'. REFRESH lt_files. CLEAR lt_files. ** Define path where file is stored lf_pathname = 'c:\temp\'. ** 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

hostname IMPORTING: TABLES:

= ' ' return

= ls_return = lt_files.

documentfiles

** 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.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
**..... 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, lf_pathname LIKE bapi_doc_draw-docfile1, **.... Bapi-Returnstruktur ls_return LIKE bapiret2. **.... Originals that were checked out DATA: lt_files LIKE bapi_doc_files2 OCCURS 0 WITH HEADER LINE. DATA: ls_documentfile LIKE bapi_doc_files2. **---------------------------------------------------------------------** Allocate document data lf_doctype = 'DRW'. lf_docnumber = '4711'. lf_docversion = '000'. lf_docpart = '00'. REFRESH lt_files. CLEAR lt_files. ** Define path in which original is stored lf_pathname = 'c:\temp\'. ls_documentfile-wsapplication = 'TXT'. ** 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

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'. 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
**..... Document data DATA: ls_doc LIKE bapi_doc_draw2. **..... Bapi-Returnstruktur ls_return LIKE bapiret2. **.... Key feilds of the document DATA: lf_doctype LIKE bapi_doc_draw2-documenttype, lf_docnumber LIKE bapi_doc_draw2-documentnumber, lf_docpart LIKE bapi_doc_draw2-documenttype, 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, **.... 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. **---------------------------------------------------------------------** Allcoate document data ls_doc-documenttype = 'DRW'. ls_doc-documentnumber = '4711'. ls_doc-documentversion = '00'. ls_doc-documentpart = '000'. ls_doc-statusextern = 'AF'. ls_doc-laboratory = '001'. ** Check in original 1 simultaneously in the R/3 Database REFRESH lt_files. CLEAR lt_files. 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. ** German short text lt_drat-language = 'DE'. lt_drat-description = 'Getriebe'. APPEND lt_drat. ** English short text lt_drat-language = 'EN'. lt_drat-description = 'gear'. APPEND lt_drat. ** Object link to material master CLEAR lt_drad. REFRESH lt_drad. lt_drad-objecttype = 'MARA'. lt_drad-objectkey = 'M4711'. APPEND lt_drad. * --------------------------------------------------------------------* 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. ** Did an error occur ?? IF ls_return-type CA 'EA'. ROLLBACK WORK. MESSAGE ID '26' TYPE 'I' NUMBER '000' WITH ls_return-message. 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. **..... Bapi return structure ls_return LIKE bapiret2. **.... key fields of new document 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. **.... 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-statusextern = '00'. = 'Gear box'. = 'AF'.

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. ** Object link to material master CLEAR lt_drad. REFRESH lt_drad. lt_drad-objecttype = 'MARA'. lt_drad-objectkey = 'M4711'. APPEND lt_drad.

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

** 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, 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
**..... Document data DATA: ls_doc LIKE bapi_doc_draw2. **..... Bapi-Returnstruktur ls_return LIKE bapiret2. **.... Key feilds of the document DATA: lf_doctype LIKE bapi_doc_draw2-documenttype, lf_docnumber LIKE bapi_doc_draw2-documentnumber, lf_docpart LIKE bapi_doc_draw2-documenttype, 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, **.... 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. **---------------------------------------------------------------------** Allcoate document data ls_doc-documenttype = 'DRW'. ls_doc-documentnumber = '4711'. ls_doc-documentversion = '00'. ls_doc-documentpart = '000'. ls_doc-statusextern = 'AF'. ls_doc-laboratory = '001'. ** Check in original 1 simultaneously in the R/3 Database REFRESH lt_files. CLEAR lt_files. 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. ** German short text lt_drat-language = 'DE'. lt_drat-description = 'Getriebe'. APPEND lt_drat. ** English short text lt_drat-language = 'EN'. lt_drat-description = 'gear'. APPEND lt_drat. ** Object link to material master CLEAR lt_drad. REFRESH lt_drad. lt_drad-objecttype = 'MARA'. lt_drad-objectkey = 'M4711'. APPEND lt_drad. * --------------------------------------------------------------------* 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. ** Did an error occur ?? IF ls_return-type CA 'EA'. ROLLBACK WORK. MESSAGE ID '26' TYPE 'I' NUMBER '000' WITH ls_return-message. 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. ********************************************************************* ** Allocate document data lf_doctype = 'DRW'. lf_docnumber = '4711'. lf_docversion = '00'. lf_docpart = '000'. REFRESH lt_files. CLEAR lt_files. ** 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. ** Did error occur ?? IF ls_return-type CA 'EA'. MESSAGE ID '26' TYPE 'I' NUMBER '000' WITH ls_return-message. ENDIF.

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.

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,

**... Value range for document number LT_DOCNR_SEL LIKE BAPI_DOC_SELNR OCCURS 0 WITH HEADER LINE,

**... Bapi return structure LS_RETURN LIKE BAPIRET2, **... Max. number of data records that are returned

LF_MAXROWS LIKE BAPI_DOC_AUX-MAXROWS, **... Number of data records (number of records in the hit list) LF_FOUNDROWS LIKE BAPI_DOC_AUX-MAXROWS. **---------------------------------------------------------------------** Construct value range for document number CLEAR: LT_DOCNR_SEL. 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' 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.

** 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
You can use the following data as search criteria: 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.

Das könnte Ihnen auch gefallen