cancel
Showing results for 
Search instead for 
Did you mean: 

Link DMS document to Sales Order

Former Member
0 Kudos

Hello -

Currenlty, our Quality Department manually opens each applicable sales order and manually attaches a required document via the "Extras/Documents" path from within VA02 menu bar. It is extremely time consuming.

I want to know if it is possible to automatically attach a "linked document" to a sales order after it has been saved? I'd like to create/run a batch job that loops through these sales orders, and if applicable, attaches the "linked document". DMS is setup and working and the document that I need to attach is ready. I don't know where I need to put the record of this "link". I can see all of the "links" via CV03N (Object Links/Sales Document Item), but I don't know how they get there.

Any advice or link to documentation would be greatly appreciated.

Thanks,

Bryan

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

This is passible by using BAPI Creat Document2, in this u have to fill object link field EX in your case VBAP for sales order item.

you need to implement this will creates document as well as links to VA02.

Benakaraj ES

Former Member
0 Kudos

I will take a look at the BAPI you suggested. Thank you!

Former Member
0 Kudos

Benakaraj ES -

A few more questions with BAPI_DOCUMENT_CREATE2.

Here is the FM. Can you assist in helping me establish which parameters I need to provide?

Example:

Sales Order: 2142342 with one line item.

Document:

TYPE: ZQN (DRAW-DOKAR)

DOC: QZ6 (DRAW-DOKNR)

PART: 000 (DRAW-DOKTL)

VER: 00 (DRAW-DOKVR)

CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'

EXPORTING

documentdata = ls_doc

HOSTNAME =

DOCBOMCHANGENUMBER =

DOCBOMVALIDFROM =

DOCBOMREVISIONLEVEL =

CAD_MODE = ' '

PF_FTP_DEST = ' '

PF_HTTP_DEST = ' '

IMPORTING

documenttype = lf_doctype

documentnumber = lf_docnumber

documentpart = lf_docpart

documentversion = lf_docversion

return = ls_return

TABLES

CHARACTERISTICVALUES =

CLASSALLOCATIONS =

DOCUMENTDESCRIPTIONS =

OBJECTLINKS = lt_drad

DOCUMENTSTRUCTURE =

DOCUMENTFILES =

LONGTEXTS =

COMPONENTS =

I see that there is an objectlinks table which I assume is used to create the link between the document and VA02/VA03. The underlying structure for the objectlinks table is BAPI_DOC_DRAD. I'm not clear on what values I need to add to this table when calling the BAPI_DOCUMENT_CREATE2. FM.??

Any advice on how to fill stucture BAPI_DOC_DRAD?

Also, I don't want to create any documents. The document already exists. I just want to establish a link. Can I do that without creating a document that already exists?

Thanks,

Bryan

Former Member
0 Kudos

hi,

Bryan,

at object link you have to enter the folwoing

    • Object link to Sales Order Item

CLEAR lt_drad.

REFRESH lt_drad.

lt_drad-objecttype = 'VBAP'.

lt_drad-objectkey = '2142342'.

APPEND lt_drad.

benakaraja es

Former Member
0 Kudos

Thanks for the quick response. I appreciate it.

One last question, I hope.

This link/document that I want to attach is at ITEM level.

I see from your example how to tell the FM what table and sales order to attach to, but how do I tell it what line item? There may be scenarios where the sales order has 10 line items and I only want to attach it to line item 9.

I assume I'll need to loop thru each line item on the sales order and if that line needs the document attached/linked, then execute the FM?? the FM will just "know" that I want the doc/link created for the item that is currently being looped on??

Bryan

Former Member
0 Kudos

HI,

I understood reqirements, this looks like uplaoding document. this needs LSMW development.

benakaraja ES