cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI_DOCUMENT_CREATE2

Former Member
0 Kudos

Hi,

We want to load documents to Portpolio item folder in PLM. How can I use BAPI_DOCUMENT_CREATE2 to load the documents? Have somebody done this using the BAPI? Could you tell me what I need to post to the OBJECTLINKS table, specifically, the OBJECTKEY? How is the document linked to the folder in the portfolio item?

Thanks,

Sonny

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Sonny,

The function module 'BAPI_DOCUMENT_CREATE2' is well documented with example. Please refer, if you have not done it yet.

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

Looking at the code, object link, I believe is linking the document to a material (objectkey is mara-matnr, I think). I have not actually worked on creating documents in PLM.

Regards,

Shyam

Former Member
0 Kudos

Hi Shyam,

Thank you for your quick response.

I think it is different in PLM. Part of my abap code is below:

CLEAR LW_DOCDATA.

LW_DOCDATA-DOCUMENTTYPE = 'PED'.

......

CLEAR LW_OBJLINK.

LW_OBJLINK-OBJECTTYPE = 'DRAW'.

LW_OBJLINK-OBJECTKEY = 'OS100916'. "<=== what's the document number to use?

"How do I link it to the portfolio item?

LW_OBJLINK-DOCUMENTDIRECTION = 'X'.

APPEND LW_OBJLINK TO LT_OBJLINK.

CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'

EXPORTING

DOCUMENTDATA = LW_DOCDATA

IMPORTING

DOCUMENTNUMBER = lv_docnum

RETURN = LW_RETURN

TABLES

DOCUMENTDESCRIPTIONS = LT_DSP

OBJECTLINKS = LT_OBJLINK

DOCUMENTFILES = LT_DOCFILE.

I need to link the document to the folder of the portfolio item in PLM.

Thanks,

Sonny

Former Member
0 Kudos

Hi Sonny,

Try passing a combination of all the key fields, viz. document document number,document type

document part, version and check if it works.

For Data Element documentation

-


DE OBJKY

____________________________________________________

Short Text

Document management object key

Definition

Number which identifies the master record of an object that is allocated to a document.

Dependencies

The number is generated by the system based on key fields of the object for example:

change object key fields

material BOM materials, plant, use

document document number,document type

document part, version

-


Regards,

Shyam

Former Member
0 Kudos

Hi Shyam,

I will try using that key structure.

Thanks,

Sonny