Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

What's the use of BAPI_DOCUMENT_CREATE2?

Former Member
0 Kudos

Hi Guys,

Can anybody tell me what's the use of BAPI_DOCUMENT_Create2 . I was able to see the documentattion but i was not able to understand clearly.Can anybody Pls help me.?

Thanks,

Gopi.

1 REPLY 1

Former Member
0 Kudos

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

You can also check in the original application files into the SAP database, vault, or archive.

  • Classification characteristics

  • Document structures; can be created using table DocumentStructure.

The objects of engineering change management (DOC_BOM_CHANGE_NUMBER DOC_BOM_VALID_FROM oder DOC_BOM_REVISON_LEVEL) relate only to the processing of the document structure. If no additional information for the change object is given, the items in the table document structure apply as the new status of the structure for the current date........... Restrictions: The document key fields are equally keys for the BOM items, which means that a document may not be used for several items. Restrictions:

  • Additional files supported only as interface parameters COMPONENTS for future development.

  • Valuations of object links are not supported.

[edit]

Example

*

o ..... Document data

DATA: ls_doc LIKE bapi_doc_draw2.

*

o ..... Bapi-Returnstruktur

ls_return LIKE bapiret2.

*

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

*

o .... Originals that are checked in simultaneously

DATA: lt_files LIKE bapi_doc_files2 OCCURS 0 WITH HEADER LINE,

*

o .... Short texts

lt_drat LIKE bapi_doc_drat OCCURS 0 WITH HEADER LINE,

*

o .... Object links

lt_drad LIKE bapi_doc_drad OCCURS 0 WITH HEADER LINE.

*

o -


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

*

o Check in original 1 simultaneously in the SAP 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.

*

o Short texts

CLEAR lt_drat. REFRESH lt_drat.

*

o German short text

lt_drat-language = 'DE'. lt_drat-description = 'Getriebe'. APPEND lt_drat.

*

o English short text

lt_drat-language = 'EN'. lt_drat-description = 'gear'. APPEND lt_drat.

*

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

*

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

[edit]

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

Regards..

Anup