cancel
Showing results for 
Search instead for 
Did you mean: 

Printing of DMS documents (attachments of PO) when PO is printed

Former Member
0 Kudos

Hello All,

Below is the functionality that we are trying to acheive : -

1) We have the facility to provide attachments at the PO item level.

2) These attachments are the DMS documents which are created in transaction CV01N.

3) Requirement is, whenever PO form is printed through messsage type automatically all the attachments (in the line item of PO) must also get printed.

We have investigated and identified the following issues until now: -

1)  Printing of DMS documents involves frontend printing (i.e. SAP spool is not generated, its normal printing ). Is there a way to print this DMS document to Spool rather than using frontend printing ?

2) We can access the DMS documents data in Binary/xstring format but there is no way with which we can stream this binary/xstring data to spool ?

3) Whenever we try to print the attachments using frontend printing, incase of PDF files the file just opens and it is not printed automatically. Is there a way to print this PDF's automatically without opening it using frontend printing ?.

4) A temporary copy of the originals in the DMS documents is created in the local directory C:\tmp\. Is there a way (apart from manual way) to delete these temporary copies automatically once they are printed ?

Any help on the above issues will really help.

Thanks & Regards,

Rinkesh Doshi

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Rinkesh, do u have solution problem to your requirement? i have same requirement. 

Former Member
0 Kudos

Hi Vipin,

We implemented the frontend printing solution for the DMS document.

FM

1) BAPI_DOCUMENT_GETOBJECTDOCS

2) CVAPI_DOC_GETDETAIL

3) CVAPI_DOC_VIEW (with p_apptp = 3 --> Printing)

were used in sequence to achieve frontend printing for DMS document.

This would also need, things to be correctly configured in DC10, DC20 and DC30.

Thanks & Regards,

RD

functionalconsu
Explorer
0 Kudos

Hi Rinkesh,

Can u please send the code to print the DMS documents using above FMs.

Pl e-mail them to anil.dhasmana@motherdairy.com

Regards,

Anil.

Former Member
0 Kudos

Hi All,

I encountered with the same issue and Rinkesh suggestion works perfect. I experimented the code as below and the moment i execute the program PDF file is triggered to print and drawing of PDF document printed perfect. Sharing my sample code below just need to change the Object type and Object key based on DRAD table.

report zvenkat_test message-id z1.
types:
       begin of ty_po,
        documenttype type bapi_doc_keys-documenttype,
        documentnumber type bapi_doc_keys-documentnumber,
        documentversion type bapi_doc_keys-documentversion,
        documentpart type bapi_doc_keys-documentpart,
       end of ty_po.

types: begin of ty_files.
        include structure cvapi_doc_file.
types: end of ty_files.

types: begin of ty_comp.
        include structure cvapi_doc_comp.
types: end of ty_comp.

data: wa_po type ty_po,
      wa_files type ty_files,
      wa_comp type ty_comp,
      t_po type table of ty_po,
      t_files type table of ty_files,
      t_comp type table of ty_comp.

call function 'BAPI_DOCUMENT_GETOBJECTDOCS'
  exporting
    objecttype   = 'PORDER' " go to table DRAD & get the Obj type from DOKOB field
    objectkey    = '000017005637H0001          000000000002' " go to table DRAD get the object Key from OBJKY field
  tables
    documentlist = t_po.

loop at t_po into wa_po.
  call function 'CVAPI_DOC_GETDETAIL'
    exporting
      pf_dokar  = wa_po-documenttype
      pf_doknr  = wa_po-documentnumber
      pf_dokvr  = wa_po-documentversion
      pf_doktl  = wa_po-documentpart
    tables
      pt_files  = t_files
    exceptions
      not_found = 1
      no_auth   = 2
      error     = 3
      others    = 4.
  if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
            with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  endif.

  loop at t_files into wa_files.
    call function 'CVAPI_DOC_VIEW'
      exporting
        pf_dokar    = wa_po-documenttype
        pf_doknr    = wa_po-documentnumber
        pf_dokvr    = wa_po-documentversion
        pf_doktl    = wa_po-documentpart
        pf_apptp    = '3'  " Print-3 Display-1 and Change-2
        ps_file     = wa_files
      exceptions
        error       = 1
        not_found   = 2
        no_auth     = 3
        no_original = 4
        others      = 5.
    if sy-subrc <> 0.
      message id sy-msgid type sy-msgty number sy-msgno
      with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.
  endloop.
endloop.

write: 'Process Complete'.

: Thanks alot it was great help, i coded based on your solution and it worked.

Regards

Venkat

former_member585060
Active Contributor
0 Kudos

Hi,

1)     1)     It is not possible, may be if you use 3rd party converter or printer software like DUET you can print. You can try VBScripts to open and issuing print, there are many VBScripts available which can open and print the document without actually openning the document. So you have to first checkout a copy to local folder, then execute the Vbscript from SAP to issue print.

2)     2)     The converters present in SAP cannot convert the MS word or MS excel or JPG documents binary to spool.

3)     3)     Same try with executing Vbscript code from SAP ABAP program to issue prints.

4)    4)      Try to check the SPRO settings

Goto Tcode DC30

Select the WRI application,

Double click it, In the screen WorkStation section select the check box ‘Delete file after Check-in’. So this will delete all the WRI documents in temp folder after check in. Make thse setting for all the application types.

Actually we are using same SAP and VBScript combination to convert all the MS word documents to PDF for Documents in DMS, with out buying 3rd party conversion software we are successfully using this presently.

1) Download the MS word document to local folder.

1)     2)Cretae VBScript to convert the MS word to PDF.  The script makes use of Save As PDF functionality of MS word.

2)     3)Delete all the files in the temp folder except PDF.

3)     4)Check In the PDF back to DMS document.

Thanks & Regards

Bala Krishna

Former Member
0 Kudos

Any suggestions/inputs on the above mentioned issue ?