7202629 bapis for dms

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.

Upload: adrian-marchis

Post on 26-Oct-2014

185 views

Category:

Documents


11 download

TRANSCRIPT

Page 1: 7202629 Bapis for DMS

BAPIs for the Document Management System

Since release 4.5 we have BAPIs for the Document Management System. With these BAPIs youcan access nearly all the functions of the DMS from external programs. The BAPIs contain allthe functions from the PP-DMS dialog interface (look into the PP-CAD documentation fordetails of the dialog functions).

Since release 4.5, new functionality in the PP-DMS interface will only be accessible with theBAPIs. 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. Existingintegrations shall be converted to BAPIs if possible.

Page 2: 7202629 Bapis for DMS

List of new BAPIs:

Document.Change 4.5 Change document Document.Change2 4.6 Change documentDocument.CheckIn 4.5 Check in documentDocument.CheckIn2 4.6 Check in documentDocument.CheckOutModify 4.5 Check out document for processingDocument.CheckOutModify2 4.6 Check out document for processingDocument.CheckOutView 4.5 Check out document for displayDocument.CheckOutView2 4.6 Check out document for displayDocument.Create2 4.6 Create documentDocument.CreateFromData 4.5 Create documentDocument.CreateFromData2 4.6 Create documentDocument.CreateFromSource 4.5 Create Document with Template SourceDocument.CreateFromSource2 4.6 Create Document with Template SourceDocument.CreateNewVersion 4.5 Create new document versionDocument.CreateNewVersion2 4.6 Create new document versionDocument.Delete 4.5 Delete document or set deletion indicatorDocument.Dequeue 4.5 Unlock document Document.Enqueue 4.5 Lock documentDocument.ExistenceCheck1 4.5 Check if document existsDocument.GetActualVersion 4.5 Determine valid versions for a documentDocument.GetApplication 4.5 Determine Data for an ApplicationDocument.GetDataCarrierDetail 4.5 Determine detail data of a data carrierDocument.GetDataCarrierList 4.5 Determine List of Data CarriersDocument.GetDCList2 4.6 Determine List of Data CarriersDocument.GetDetail 4.5 Determine Detail Data for a DocumentDocument.GetDetail2 4.6 Determine Detail Data for a DocumentDocument.GetDocumentTypeDetail 4.5 Determine Data for a Document TypeDocument.GetFrontendType 4.5 Determine Frontend Type for ComputerDocument.GetList 4.5 Find DocumentDocument.GetObjectDocuments 4.5 Determine Documents for an Object Document.GetStatus 4.5 Determine document statusDocument.GetStatusList 4.5 Determine Status List for a Document TypeDocument.GetStructure 4.5 Determine document structureDocument.SetFrontendType 4.5 Set frontend type for computerDocument.SetStatus 4.5 Set Document Status

Page 3: 7202629 Bapis for DMS

Method

Document.ChangeChange document

FunctionalityYou 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 objectlinks are not supported Mass check-ins are not supported

Example**..... Document dataDATA: 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 timeDATA: 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 = '00'.

ls_doc-description = 'Gear box'. ls_doc-laboratory = ''.

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

Page 4: 7202629 Bapis for DMS

**----------------------------------------------------------------------** Change document

**---------------------------------------------------------------------- CALL FUNCTION 'BAPI_DOCUMENT_CHANGE'

EXPORTING: documenttype = ls_doc-documenttype documentnumber = ls_doc-documentnumber

documentpart = ls_doc-documentpart documentversion = ls_doc-documentversion

documentdata = ls_doc documentdatax = 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 linksClassifications and characteristic value assignmentsLanguage-dependent document descriptionsDocument long textsDocument structuresOriginals (1 and 2)

Page 5: 7202629 Bapis for DMS

Method

Document.Change2Change document

FunctionalityYou 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 dataDATA: 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 = 'Transmission'. ls_doc-laboratory = ''.

** Set indicator for change relevance

ls_docx-description = 'X'. ls_docX-laboratory = 'X'.

** Insert object links CLEAR lt_drad.

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

Page 6: 7202629 Bapis for DMS

**----------------------------------------------------------------------** Change document

**---------------------------------------------------------------------- CALL FUNCTION 'BAPI_DOCUMENT_CHANGE2'

EXPORTING: documenttype = ls_doc-documenttype documentnumber = ls_doc-documentnumber

documentpart = ls_doc-documentpart documentversion = ls_doc-documentversion

documentdata = ls_doc documentdatax = 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 linksClassification and characteristic valuationsLanguage dependent document descriptionsDocument long textsDocument structuresOriginal application files

Page 7: 7202629 Bapis for DMS

Method

Document.CheckInCheck in document

FunctionalityYou can use this method to check a document into an archive, a vault, or the SAP database. You can check bothoriginal 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 keyDATA: 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'. " Original 1

lt_files-datacarrier = 'SAP-SYSTEM'. " Check in = SAPDB

lt_files-docfile = 'c:\temp\drawing1.dwg'. " Original file APPEND lt_files.

**----------------------------------------------------------------------** Check in document

**---------------------------------------------------------------------- CALL FUNCTION 'BAPI_DOCUMENT_CHECKIN'

EXPORTING: documenttype = lf_doctype

Page 8: 7202629 Bapis for DMS

documentnumber = lf_docnumber

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.

Page 9: 7202629 Bapis for DMS

Method

Document.CheckIn2Check in document

FunctionalityYou can use a function module to check in a document into an archive, a vault, or into the R/3 Database. You canalso 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 numberrestrictions:Additional files are supported only as interface parameters for future development.

Example**..... Document keyDATA: 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 structurels_return LIKE bapiret2.

**.... OriginalsDATA: lt_files LIKE bapi_doc_files2 OCCURS 0 WITH HEADER LINE.

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

** Allocate document datalf_doctype = 'DRW'.lf_docnumber = '4711'.lf_docversion = '00'.lf_docpart = '000'.lf_status = 'RE'.

** Check in original 1 into R/3 DatabaseREFRESH lt_files.CLEAR lt_files.

lt_files-storagecategory = 'R/3 SYSTEM'. " Storage = R/3-DBlt_files-docfile = 'c:\temp\drawing1.dwg'. " Original fileAPPEND lt_files.

**----------------------------------------------------------------------** Check in document**----------------------------------------------------------------------CALL FUNCTION 'BAPI_DOCUMENT_CHECKIN2'EXPORTING: documenttype = lf_doctypedocumentnumber = lf_docnumberdocumentpart = lf_docpartdocumentversion = lf_docversionhostname = ''statusintern = ''statusextern = lf_statusstatuslog = ''IMPORTING: return = ls_returnTABLES: documentfiles = lt_files.

Page 10: 7202629 Bapis for DMS

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

Page 11: 7202629 Bapis for DMS

Method

Document.CheckOutModifyCheck out document for processing

FunctionalityThis 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 = lf_docversion

originaltype = '1' documentfile = lf_filename

statusextern = lf_status IMPORTING: return = ls_return.

** Errors occurred ??

Page 12: 7202629 Bapis for DMS

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

ELSE. COMMIT WORK. ENDIF.

Page 13: 7202629 Bapis for DMS

Method

Document.CheckOutModify2Check out document for processing

FunctionalityYou use this method to check out a document for processing. Optionally you can assign the following data whenyou check in a document:Status with log entry Revision level Change numberRestrictions:Additional files are not supported. These exist as interface parameters for future development. You cannot check outseveral documents for processing.

Example**..... Document keyDATA: 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-Returnstrukturls_return LIKE bapiret2.**----------------------------------------------------------------------

** Allocate document datalf_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 storedls_documentfile-docfile = 'c:\temp\work.dwg'.* alternativels_documentfile-docpath = 'c:\temp\.',ls_documentfile-docfile = 'work.dwg'.

** Set new status for documentlf_status = 'IA'.

** Check out document (Original 1) for changesCALL FUNCTION 'BAPI_DOCUMENT_CHECKOUTMODIFY2'EXPORTING: documenttype = lf_doctypedocumentnumber = lf_docnumberdocumentpart = lf_docpartdocumentversion = lf_docversiondocumentfile = ls_documentfilestatusextern = lf_statusIMPORTING: return = ls_returncheckedoutfile = ls_checkedoutfile.

** Errors occurred ??IF ls_return-type CA 'EA'.ROLLBACK WORK.

Page 14: 7202629 Bapis for DMS

MESSAGE ID '26' TYPE 'I' NUMBER '000'WITH ls_return-message.

ELSE.COMMIT WORK.ENDIF.

Page 15: 7202629 Bapis for DMS

Method

Document.CheckOutViewCheck out document for display

FunctionalityYou 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 functionmodule 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_docpart

documentversion = lf_docversion originaltype = '1'

getstructure = '1' originalpath = lf_pathname

Page 16: 7202629 Bapis for DMS

hostname = ' ' IMPORTING: return = ls_return

TABLES: documentfiles = 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.

Page 17: 7202629 Bapis for DMS

Method

Document.CheckOutView2Check out document for display

FunctionalityYou 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 documenttypes 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. Theapplication (DOCUMENTFILE-WSAPPLICATION) is also available as a selection criterion. The tableDocumentStructure is used to define which documents of the structure you want to check out (certain documentscan 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 fordisplay.

Restrictions:Additional files are supported only as interface parameters for future developments.

Example

**..... Document keyDATA: 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-Returnstrukturls_return LIKE bapiret2.

**.... Originals that were checked outDATA: lt_files LIKE bapi_doc_files2 OCCURS 0 WITH HEADER LINE.DATA: ls_documentfile LIKE bapi_doc_files2.

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

** Allocate document datalf_doctype = 'DRW'.lf_docnumber = '4711'.lf_docversion = '000'.lf_docpart = '00'.

REFRESH lt_files.CLEAR lt_files.

** Define path in which original is storedlf_pathname = 'c:\temp\'.ls_documentfile-wsapplication = 'TXT'.

** Document (Originals of application type WRD) check out for viewingCALL FUNCTION 'BAPI_DOCUMENT_CHECKOUTVIEW2'EXPORTING: documenttype = lf_doctypedocumentnumber = lf_docnumberdocumentpart = lf_docpartdocumentversion = lf_docversion

Page 18: 7202629 Bapis for DMS

documentfile = ls_documentfilegetstructure = '1'originalpath = lf_pathnamehostname = ' 'IMPORTING: return = ls_returnTABLES: 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.

Page 19: 7202629 Bapis for DMS

Method

Document.Create2Create document

FunctionalityYou can use this function module to create documents and all data that belongs to it. You can create a document inforecord with the following data:Langauge dependent short and long texts Any number of originals Object links Classification characteristicsDocument structuresYou 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 ofobject links are not supported.

Example

**..... Document dataDATA: ls_doc LIKE bapi_doc_draw2.

**..... Bapi-Returnstrukturls_return LIKE bapiret2.

**.... Key feilds of the documentDATA: 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 simultaneouslyDATA: lt_files LIKE bapi_doc_files2 OCCURS 0 WITH HEADER LINE,

**.... Short textslt_drat LIKE bapi_doc_drat OCCURS 0 WITH HEADER LINE,

**.... Object linkslt_drad LIKE bapi_doc_drad OCCURS 0 WITH HEADER LINE.**----------------------------------------------------------------------

** Allcoate document datals_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 DatabaseREFRESH 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'.

Page 20: 7202629 Bapis for DMS

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 textsCLEAR lt_drat.REFRESH lt_drat.

** German short textlt_drat-language = 'DE'.lt_drat-description = 'Getriebe'.APPEND lt_drat.

** English short textlt_drat-language = 'EN'.lt_drat-description = 'gear'.APPEND lt_drat.

** Object link to material masterCLEAR 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_docIMPORTING: documenttype = lf_doctypedocumentnumber = lf_docnumberdocumentpart = lf_docpartdocumentversion = lf_docversionreturn = ls_returnTABLES: documentdescriptions = lt_dratobjectlinks = lt_draddocumentfiles = 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.

NotesYou can insert the following data in addition to document data:Object links Classifications and characteristic valuation Language dependent document descriptions Long textdocuments Document structure Originals

Page 21: 7202629 Bapis for DMS

Method

Document.CreateFromDataCreate document

FunctionalityYou 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 objectlinks are not supported

Example**..... Document dataDATA: ls_doc LIKE bapi_doc_draw.

**..... Bapi return structure

ls_return LIKE bapiret2.

**.... key fields of new documentDATA: 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 = '00'.

ls_doc-description = 'Gear box'. ls_doc-statusextern = '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.

Page 22: 7202629 Bapis for DMS

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

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

Page 23: 7202629 Bapis for DMS

Object linksClassifications and characteristic value assignmentsLanguage-dependent document descriptionsDocument long textsDocument structuresOriginals (1 and 2)

Page 24: 7202629 Bapis for DMS

Method

Document.CreateFromData2Create document

FunctionalityYou can use this function module to create documents and all data that belongs to it. You can create a document inforecord with the following data:Langauge dependent short and long texts Any number of originals Object links Classification characteristicsDocument structuresYou 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 ofobject links are not supported.

Example

**..... Document dataDATA: ls_doc LIKE bapi_doc_draw2.

**..... Bapi-Returnstrukturls_return LIKE bapiret2.

**.... Key feilds of the documentDATA: 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 simultaneouslyDATA: lt_files LIKE bapi_doc_files2 OCCURS 0 WITH HEADER LINE,

**.... Short textslt_drat LIKE bapi_doc_drat OCCURS 0 WITH HEADER LINE,

**.... Object linkslt_drad LIKE bapi_doc_drad OCCURS 0 WITH HEADER LINE.**----------------------------------------------------------------------

** Allcoate document datals_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 DatabaseREFRESH 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'.

Page 25: 7202629 Bapis for DMS

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 textsCLEAR lt_drat.REFRESH lt_drat.

** German short textlt_drat-language = 'DE'.lt_drat-description = 'Getriebe'.APPEND lt_drat.

** English short textlt_drat-language = 'EN'.lt_drat-description = 'gear'.APPEND lt_drat.

** Object link to material masterCLEAR 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_docIMPORTING: documenttype = lf_doctypedocumentnumber = lf_docnumberdocumentpart = lf_docpartdocumentversion = lf_docversionreturn = ls_returnTABLES: documentdescriptions = lt_dratobjectlinks = lt_draddocumentfiles = 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.

NotesYou can insert the following data in addition to document data:Object links Classifications and characteristic valuation Language dependent document descriptions Long textdocuments Document structure Originals

Page 26: 7202629 Bapis for DMS

Method

Document.CreateFromSourceCreate Document with Template Source

FunctionalityYou can use this method to create a new document by copying from an existing document.

NotesWhen the new document is created, any document structure that may exist is also copied. You can define whetherall, only specific, or no object links are copied.

Page 27: 7202629 Bapis for DMS

Method

Document.CreateFromSource2Create Document with Template Source

FunctionalityYou use this function for creating new documents using a template.Optionally you can assign the following data:Status log entry Revision level Change number

NotesAn existing document structure is copied when you create a new document. You can define how you want to copythe object links:Copye Value for OBJECTTYPEall *Only certain <Database table>None BlankExplanation of the <Database table>The internal descriptions from the table TCLO (for example, MARA for material) are used for the object typeOBJECTTYPE.The object key OBJECTKEY is made of key fields of the SAP object that is also in the table TCLO.

Page 28: 7202629 Bapis for DMS

Method

Document.CreateNewVersionCreate new document version

FunctionalityYou can use this method to create a new version for an existing document.

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

Page 29: 7202629 Bapis for DMS

Method

Document.CreateNewVersion2Create new document version

FunctionalityYou use this function module to create new versions of documents. Optionally the following data can be changed:Log entry Revision level Change number

NotesYou can copy an available document structure when creating a new document. You can also set how you want tocopy object links:Copy Value for OBJECTTYPEall *Only certain <Databasetable>none BlankExplanation for <Databasetable>The internal descriptions from the table TCLO (for example, MARA for material) are used for the object typeOBJECTTYPE. The object key OBJECTKEY contains the kex fields of the SAP Object that is also taken from thetable TCLO.

Page 30: 7202629 Bapis for DMS

Method

Document.DeleteDelete document or set deletion indicator

FunctionalityYou can use this method to delete documents.

Page 31: 7202629 Bapis for DMS

Method

Document.DequeueUnlock document

FunctionalityYou can use this method to withdraw a change lock.

Page 32: 7202629 Bapis for DMS

Method

Document.EnqueueLock document

FunctionalityYou can use this method to lock a document against a change.

NotesThe lock is withdrawn by either the following change BAPI or by calling BAPI_DOCUMENT_DEQUEUE.

Page 33: 7202629 Bapis for DMS

Method

Document.ExistenceCheck1Check if document exists

Functionalityou can use this method to check whether a document exists.

Page 34: 7202629 Bapis for DMS

Method

Document.GetActualVersionDetermine valid versions for a document

FunctionalityYou can use this method to determine the current and valid version of a document.

NotesYou can use the "ReleasedOnly" button to determine whether just the released versions or all the versions should bedetermined.

Page 35: 7202629 Bapis for DMS

Method

Document.GetApplicationDetermine Data for an Application

FunctionalityYou can use this method to determine all the Customizing settings for one work station application.

Page 36: 7202629 Bapis for DMS

Method

Document.GetDataCarrierDetailDetermine detail data of a data carrier

FunctionalityYou can use this method to determine the Customizing settings for a specific data carrier.

Page 37: 7202629 Bapis for DMS

Method

Document.GetDataCarrierListDetermine List of Data Carriers

Functionalityou 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, onlyarchives, vaults, and so on.

NotesSee also: BAPI_DOCUMENT_GETDCDETAIL

Page 38: 7202629 Bapis for DMS

Method

Document.GetDCList2Determine List of Data Carriers

FunctionalityYou 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, vaultsand so on.

NotesSee also BAPI_DOCUMENT_GETDCDETAIL

Page 39: 7202629 Bapis for DMS

Method

Document.GetDetailDetermine Detail Data for a Document

FunctionalityYou can use this method to determine detailed data for a document.

NotesThe following data can be read:Main document data Short texts/descriptions Long texts Object links

Page 40: 7202629 Bapis for DMS

Method

Document.GetDetail2Determine Detail Data for a Document

FunctionalityYou can use this method to set detail data for a document. The following import parameters are available forcontrolling output:GetObjectLinks GetStatusLog GetLongTexts GetActiveFilesSetting additional files is not supported. Future development supports the interface parameters GetComponents andCOMPONENTS.

Example** Document keyDATA: 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 structurels_return LIKE bapiret2.** Originals Document hierarchyDATA: lt_files LIKE bapi_doc_files2 OCCURS 0 WITH HEADER LINE,ls_document LIKE bapi_doc_draw2.

*********************************************************************

** Allocate document datalf_doctype = 'DRW'.lf_docnumber = '4711'.lf_docversion = '00'.lf_docpart = '000'.

REFRESH lt_files.CLEAR lt_files.

** Set detail information for the documentCALL FUNCTION 'BAPI_DOCUMENT_GETDETAIL2'EXPORTING: documenttype = lf_doctypedocumentnumber = lf_docnumberdocumentpart = lf_docpartdocumentversion = lf_docversiongetobjectlinks = 'X'getstatuslog = 'X'getlongtexts = 'X'getactivefiles = 'X'IMPORTING:documentdata = ls_documentreturn = ls_returnTABLES: documentfiles = lt_files.

** Did error occur ??IF ls_return-type CA 'EA'.MESSAGE ID '26' TYPE 'I' NUMBER '000'WITH ls_return-message.ENDIF.

Page 41: 7202629 Bapis for DMS

NotesThe following data can be read:Document main data Short texts Long texts Object links Originals

Page 42: 7202629 Bapis for DMS

Method

Document.GetDocumentTypeDetailDetermine Data for a Document Type

FunctionalityYou can use this method to determine the Customizing settings for a specific document type.

Page 43: 7202629 Bapis for DMS

Method

Document.GetFrontendTypeDetermine Frontend Type for Computer

FunctionalityYou can use this method to determine the appropriate front end type for a front end computer.

Page 44: 7202629 Bapis for DMS

Method

Document.GetListFind Document

FunctionalityYou can use this method to find a document and select a list of documents. A table containing the document data iscreated.You can use the "MAXROWS" parameter to restrict the number of selected documents in the hit list.

Example**... List of selected documentsDATA: 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 = 'DRW' DESCRIPTION = 'Gear*'

MAXROWS = 250 " max 250 data records IMPORTING: FOUNDROWS = LF_FOUNDROWS

RETURN = LS_RETURN TABLES: DOCNUMBERSELECTION = LT_DOCNR_SEL

DOCUMENTLIST = LT_DOC_DATA.

** Errors occurred ?? IF ls_return-type CA 'EA'.

Page 45: 7202629 Bapis for DMS

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 typeDocument number (as value range from ... to ...)Document partDocument versionDescriptionPerson responsibleAuthorization groupOffice/laboratoryChange numberDeletion flagData carrierCAD indicatorWork station applicationDocument status

Page 46: 7202629 Bapis for DMS

Method

Document.GetObjectDocumentsDetermine Documents for an Object

FunctionalityYou can use this method to determine all the documents that are linked to an object (for example, material master).

NotesThe internal descriptions from TCLO are used for the object type (for example, MARA for material master). Theobject key is copied as a string (according to TCLO).

Page 47: 7202629 Bapis for DMS

Method

Document.GetStatusDetermine document status

FunctionalityYou can use this method to read the current status of the document.

NotesThe external language-dependent status abbreviation (in the appropriate logon language) and the internal status areentered.

Page 48: 7202629 Bapis for DMS

Method

Document.GetStatusListDetermine Status List for a Document Type

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

Page 49: 7202629 Bapis for DMS

Method

Document.GetStructureDetermine document structure

FunctionalityYou can use this method to determine the document structure for an existing document.

Page 50: 7202629 Bapis for DMS

Method

Document.SetFrontendTypeSet frontend type for computer

FunctionalityYou can use this method to set the appropriate front end type for a front end computer.

Page 51: 7202629 Bapis for DMS

Method

Document.SetStatusSet Document Status

FunctionalityYou can use this method to set a new status for the document.

NotesThe internal and external status is displayed. Basically the following applies: if the internal status is displayed, thishas priority, otherwise the internal status is read via the external status abbreviation.