Printing the document attachments

hi all,
i have a requirement to print the attachments of a document in background or forground. i have done a good search on sdn and also other help forums but couldnt find a right solution. i know that we can achive this using gos services, i can read and view them but unable to do a print function. can anyone please help me
thanks,
anupama.

here is the solution
CONSTANTS : lc_objtype    TYPE saeanwdid VALUE 'BUS2081',
lc_directory  TYPE string VALUE 'C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe',
lc_directory1 TYPE string VALUE 'rundll32.exe C:\WINDOWS\System32\shimgvw.dll,ImageView_PrintTo /pt'
DATA : ls_items     TYPE rfposxext,
        lv_length    TYPE num12,
        lv_binleg    TYPE num12,
         lt_uri_tab   TYPE TABLE OF toauri,
         ls_uri_tab   TYPE toauri,
         lt_arch_tab  TYPE TABLE OF docs,
         ls_arch_tab  TYPE docs,
         lt_bin_tab   TYPE TABLE OF tbl1024,
         ls_bin_tab   TYPE tbl1024,
         lv_buffer    TYPE xstring,
         lv_saeobjid  TYPE saeobjid,
        lt_mess_att  TYPE STANDARD TABLE OF solisti1,
        ls_mess_att  TYPE solisti1,
         lv_filename  TYPE string,
         lv_batch     TYPE string,
         lv_parameter TYPE string,
         lv_rcode     TYPE i,
         lt_binary    TYPE solix_tab,
         ls_binary    TYPE LINE OF solix_tab,
         lt_filename  TYPE STANDARD TABLE OF string,
         ls_filename  TYPE string,
         lv_doctype   TYPE saedoktyp,
         lv_directory TYPE string,
         lv_prdefault TYPE rspoprname,
         lt_batch_tab TYPE TABLE OF string.
*line items which are selected or only processed
  LOOP AT it_items INTO ls_items WHERE xselp = 'X'.
*check if reference key is not initial
    IF NOT ls_items-u_awkey IS INITIAL.
      MOVE ls_items-u_awkey TO lv_saeobjid.
*get the url link based on the BUS2081 and the reference key(document number followed the year)
      REFRESH : lt_uri_tab, lt_arch_tab, lt_bin_tab.
      CALL FUNCTION 'ARCHIVOBJECT_GET_URI'
        EXPORTING
          objecttype               = lc_objtype
          object_id                = lv_saeobjid
        TABLES
          uri_table                = lt_uri_tab
        EXCEPTIONS
          error_archiv             = 1
          error_communicationtable = 2
          error_kernel             = 3
          error_http               = 4
          error_dp                 = 5.
      IF NOT lt_uri_tab[] IS INITIAL.
        CLEAR ls_uri_tab.
        READ TABLE lt_uri_tab INTO ls_uri_tab INDEX 1.
        IF sy-subrc EQ 0.
          CLEAR lv_doctype.
          IF ls_uri_tab-mimetype CS 'pdf'.
            MOVE : 'PDF' TO lv_doctype .
          ELSEIF ls_uri_tab-mimetype CS 'tiff'.
            MOVE : 'TIF' TO lv_doctype .
          ENDIF.
*get the archive id and the type of document
          CALL FUNCTION 'ARCHIVOBJECT_GET_TABLE'
            EXPORTING
              archiv_id                = ls_uri_tab-archiv_id
              document_type            = lv_doctype
              archiv_doc_id            = ls_uri_tab-arc_doc_id
              signature                = 'X'
              compid                   = 'data'
           IMPORTING
             length                   = lv_length
             binlength                = lv_binleg
            TABLES
              archivobject             = lt_arch_tab
              binarchivobject          = lt_bin_tab
            EXCEPTIONS
              error_archiv             = 1
              error_communicationtable = 2
              error_kernel             = 3.
          IF sy-subrc EQ 0.
            CLEAR : ls_bin_tab, lv_buffer.
            REFRESH : lt_binary.
            LOOP AT lt_bin_tab INTO ls_bin_tab.
              CONCATENATE lv_buffer ls_bin_tab-line INTO lv_buffer IN BYTE MODE.
            ENDLOOP.
*convert to binary
            CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
              EXPORTING
                buffer     = lv_buffer
              TABLES
                binary_tab = lt_binary.
            CONCATENATE 'C:\Mass Print\' ls_items-u_awkey '.' lv_doctype INTO lv_filename.
*download to the local drive
            CALL FUNCTION 'GUI_DOWNLOAD'
              EXPORTING
                filename                = lv_filename
                filetype                = 'BIN'
              TABLES
                data_tab                = lt_binary
              EXCEPTIONS
                file_write_error        = 1
                no_batch                = 2
                gui_refuse_filetransfer = 3
                invalid_type            = 4
                no_authority            = 5
                unknown_error           = 6
                header_not_allowed      = 7
                separator_not_allowed   = 8
                filesize_not_allowed    = 9
                header_too_long         = 10
                dp_error_create         = 11
                dp_error_send           = 12
                dp_error_write          = 13
                unknown_dp_error        = 14
                access_denied           = 15
                dp_out_of_memory        = 16
                disk_full               = 17
                dp_timeout              = 18
                file_not_found          = 19
                dataprovider_exception  = 20
                control_flush_error     = 21.
            IF sy-subrc EQ 0.
              CLEAR : lv_directory, lv_parameter.
              IF lv_doctype EQ 'PDF'.
                MOVE : lc_directory TO lv_directory.
                CONCATENATE '/n /t'  lv_filename INTO lv_parameter SEPARATED BY space.
              ELSE.
                CLEAR : lv_prdefault, lv_batch.
                REFRESH :lt_batch_tab.
*get default printer
                CALL FUNCTION 'RSPO_FRONTEND_PRINTERS_FOR_DEV'
                  EXPORTING
                    device         = 'LOCL'
                  IMPORTING
                    prdefault      = lv_prdefault
                  EXCEPTIONS
                    no_list        = 1
                    list_truncated = 2
                    name_not_found = 3.
                CONCATENATE lc_directory1 lv_filename lv_prdefault INTO lv_parameter SEPARATED BY space.
                CONCATENATE 'C:\Mass Print\' ls_items-u_awkey '.bat' INTO lv_batch.
                APPEND lv_parameter TO lt_batch_tab.
                CLEAR lv_parameter.
                APPEND lv_batch TO lt_filename.
                CALL FUNCTION 'GUI_DOWNLOAD'
                  EXPORTING
                    filename                = lv_batch
                    filetype                = 'ASC'
                  TABLES
                    data_tab                = lt_batch_tab
                  EXCEPTIONS
                    file_write_error        = 1
                    no_batch                = 2
                    gui_refuse_filetransfer = 3
                    invalid_type            = 4
                    no_authority            = 5
                    unknown_error           = 6
                    header_not_allowed      = 7
                    separator_not_allowed   = 8
                    filesize_not_allowed    = 9
                    header_too_long         = 10
                    dp_error_create         = 11
                    dp_error_send           = 12
                    dp_error_write          = 13
                    unknown_dp_error        = 14
                    access_denied           = 15
                    dp_out_of_memory        = 16
                    disk_full               = 17
                    dp_timeout              = 18
                    file_not_found          = 19
                    dataprovider_exception  = 20
                    control_flush_error     = 21.
                MOVE lv_batch TO lv_directory.
              ENDIF.
*print the pdf file from command line
              cl_gui_frontend_services=>execute(
                EXPORTING
                  application            = lv_directory
                  parameter              = lv_parameter
                  synchronous            = 'X'
                EXCEPTIONS
                  cntl_error             = 1
                  error_no_gui           = 2
                  bad_parameter          = 3
                  file_not_found         = 4
                  path_not_found         = 5
                  file_extension_unknown = 6
                  error_execute_failed   = 7
                  synchronous_failed     = 8
                  not_supported_by_gui   = 9  ).
              IF sy-subrc <> 0.
                MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                           WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
              ENDIF.
              MOVE : lv_filename TO ls_filename .
              APPEND ls_filename TO lt_filename.
              CLEAR ls_filename.
            ENDIF.
          ENDIF.
        ENDIF.
      ENDIF.
    ENDIF.
  ENDLOOP.
  IF NOT lt_filename[] IS INITIAL.
   WAIT UP TO 30 SECONDS.
    LOOP AT lt_filename INTO ls_filename.
*delete the file from local drive
      cl_gui_frontend_services=>file_delete(
        EXPORTING
          filename             = ls_filename
        CHANGING
          rc                   = lv_rcode
        EXCEPTIONS
          file_delete_failed   = 1
          cntl_error           = 2
          error_no_gui         = 3
          file_not_found       = 4
          access_denied        = 5
          unknown_error        = 6
          not_supported_by_gui = 7
          wrong_parameter      = 8      ).
      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.
  ENDIF.
solved ...
thanks,
anupama

Similar Messages

  • My setup: iMac hardline to Canon i960 printer. Issue: endless printing of the same document. The printer window states that the pinter is in use and there is nothing listed in the Print Queue.  How can I stop printing the document?

    My setup: iMac hardline to Canon i960 printer. Issue: endless printing of the same document. The printer window states that the pinter is in use and there is nothing listed in the Print Queue.  How can I stop printing the document?

    Soution: Delete the printer and add the same printer back in, therefore creating a new print queue.

  • How to Restrict printing the document using IRM for a Single Document?Allow printing for some documents and restrict the printing for particular documents in same document library?

    Can we able to Configure the IRM in Document Level in SharePoint Document libraries?
    The document library contains multiple document sets , Can we restrict the printing according to document sets? Allow printing for some documents and restrict the printing for particular documents in same document library
     Is this possible?Please suggest.

    Yes, that can be done. But note that all administrators will have the same right to print, so you need to make sure the users are not administrators. You can include a macro to disable printing, but if the users disable macro, they can print the documents.
    Hence, there is no foolproof way to prevent printing documents. If you still need a foolproof security, PDF format provides password based security (viewing doesn't require a password) that can be implemented to prevent the document from printing,
    which doesn't require any special scripts and is tough.
    You can have a look at the following links:
    http://msdn.microsoft.com/en-us/library/office/ms458245(v=office.14).aspx
    http://msgroups.net/microsoft.public.word.docmanagement/prevent-printing-of-docum/91353
    http://www.go4sharepoint.com/Forum/prevent-printing-saving-documents-10150.aspx
    The following link explains about the security features in PDF. This is for information purpose only and not for promotion of any products:
    http://www.pdflib.com/knowledge-base/pdf-security/
    Balaji Kundalam

  • How to list printers on the client machine to print the documents in ADF

    Hi,
    I have a requirement to print multiple documents stored on the server. I am trying to find out how to list the printers or get a default printer on the client machine and print the documents using ADF.
    Thanks
    Sukarna

    I tried that solution. but I am not getting any printer list.
    public void printDocument(ActionEvent actionEvent){
    BindingContainer bindings =
    BindingContext.getCurrent().getCurrentBindingsEntry();
    PrintService[] service = PrintServiceLookup.lookupPrintServices(null, null);
    if (service.length == 0){
    JOptionPane.showMessageDialog(null, "No Printer Selected");
    The printer Service is not returing any data.
    Thanks
    Sukarna
    Edited by: 911653 on Oct 5, 2012 9:01 AM

  • Bapi or FM to print the document attached in DMS

    Hi,
    We have a requirement to print the document in DMS as one of the functionalities of a report.
    Is there any BAPI or Function modules that can be used to print the documents checked in using transactions CV01N or CV02N.
    Thanks,
    Simmi

    We had the same issue. Where we stored PDF's in DMS and we needed to print multiple files in an automated fashion.
    We used "CV120_DOC_CHECKOUT_VIEW" to get the document and "CV120_START_APPLICATION" to print.
    Note "CV120_START_APPLICATION" uses the front end application to print, so the user needs to have the applicaiton of the original file installed. Also, there can be memory limitations that restrict the number of files that can be printed at any one time.
    For example if you are printing 20 originals, you will be opening 20 files on the desktop and printing. You get the picture...

  • Unable to print the document thru Crystal Integration

    Hi All,
    Could anybody help me on the issue given below.
    One of our client Issue while printing from crystal Integration in SAP Business One. I can able to view the crystal report through Crystal Integration but i am unable to print the document.No Error is getting displayed .If i am printing from PLD it's working fine .After exporting to PDF from crytal integration i can able to Print but not able to print directly from the crystal Integration.
    Thanks,
    Vishwanath

    Hi,
    Please try to post in the Integration forum have some answers there.
    Regards,
    Clint

  • Is there a way to sort a PDF file with multiple pages by a specific field within the PDF? All pages have the same invoice format and i would like to sort by a field within and then print the documents. (Vendor, PO

    Is there a way to sort a PDF file with multiple pages by a specific field within the PDF? All pages have the same invoice format and i would like to sort by a field within and then print the documents. (Vendor, PO#, Date, ect.)

    When you say field, do you mean specifically a form field, such as a text field? Or is the information regular text on the page?

  • Error in Printer Selection while print the document

    Dear All,
    Error in Printer Selection,  while print the document in Quotation.
    Also both side Printing is not happening.
    My Report is in Crystal Report format.
    Suggest any solution on this as earlier as possible.
    Regards,
    Sumeet Vaity

    hi,
    are you printing locally or shared printer?
    pls check the ff.
    1. make sure your printer is on and Online (For local and shared)
    2. make sure the host PC is connected in the network., ping the host PC to make sure your host PC is Connected (Shared)
    3. make it as your default printer.
    regards,
    Fidel

  • Restrict user to print the document

    Dear Friends,
    I have uploaded and linked a scanned document to SAP FI Document by transaction code OAWD  by SAP Archive Link.
    Say 1700000145,
    Co.Co. BP01
    Fis Yr. 2011.
    Object BKPF
    User is able to see the linked document in FB03 from Services for Object>Attachment List.
    I want to restrict the user from printing the document.
    I checked with Authorization Object "S_WFAR_KPR" & "S_WFAR_OBJ". But this did not help.
    Can you please guide me how to handle this scenario.
    With Warm Regards
    Mangesh Pande

    Hi Mangesh,
    Have you seen in roles , object for activities like create,change,display. Kindly check if you have a option for print in activity. from there you can restrict. But if don't find such a option then you can't control printing otherwise you have to restrict the user for displaying also.
    Hope this will help.
    Regards,
    Ravindra

  • Adobe: How to print the documents more than once with different data.

    Hi Experts,
    I have a requirement to print the document of minimum 5 employee's at a time.
    First we are displaying the list of employee's and then the user is provided an option to select the employee's and print their details.
    A form has been created. We are able to print the document for a single employee. But now the requirement is to select multiple employee's and print their details at one time.
    I am able to get the contents all the employee's in an internal table. But i am not getting to combine the contents together and print the document.
    So could some one help me how to get the contents of all the selected employee's and print the document's.
    Thanks.

    I don't understand whether you want to print several different documents in a row each with  an employee or one pdf document with several employees in it.
    If you want to print one document with multiple employees inside, then you have to recode your PDF to be able to handle a table containing each employee data.
    If you want to print multiple pdf documents each containing one employee info, then this is done in abap. [see BC480]
    i.e.
    DATA:
    gt_customers TYPE TABLE OF scustom,
    gs_customer LIKE LINE OF gt_customers,
    gt_bookings TYPE ty_bookings, "table of sbook
    gt_sums TYPE flprice_t,
    gv_image_url TYPE string,
    gv_fm_name TYPE rs38l_fnam,
    * parameters for calling the generated function module
    gs_docparams TYPE sfpdocparams,
    gs_outputparams TYPE sfpoutputparams,
    Event START-OF-SELECTION:
    * Please note that the error handling implemented here is very
    * rudimentary!
    *>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    * Get name of the generated function module
    TRY.
    CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'
    EXPORTING
    i_name = pa_form
    IMPORTING
    e_funcname = gv_fm_name.
    CATCH cx_root.
    MESSAGE e004 WITH pa_form.
    * No active form &1 available
    ENDTRY.
    *>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    * Optional: Set output parameters
    gs_outputparams-nodialog = space.
    gs_outputparams-preview = 'X'.
    gs_outputparams-dest = pa_prnt.
    *>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    * Open print job
    CALL FUNCTION 'FP_JOB_OPEN'
    CHANGING
    ie_outputparams = gs_outputparams
    EXCEPTIONS
    OTHERS = 1.
    IF sy-subrc <> 0.
    MESSAGE e020.
    * Form processing could not be started
    ENDIF.
    LOOP AT gt_customers INTO gs_customer.
    * Set form language and country (->form locale)
    gs_docparams-langu = pa_lang.
    gs_docparams-country = pa_cntry.
    PERFORM find_bookings_for_customer.
    *>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    * Now call the generated function module
    CALL FUNCTION gv_fm_name
    EXPORTING
    /1bcdwb/docparams = gs_docparams
    is_customer = gs_customer
    it_bookings = gt_bookings
    it_sums = gt_sums
    iv_image_url = gv_image_url
    iv_sending_country = pa_cntry
    EXCEPTIONS
    OTHERS = 1.
    IF sy-subrc <> 0.
    MESSAGE e021.
    ENDIF.
    ENDLOOP.
    *>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    * Close spool job
    CALL FUNCTION 'FP_JOB_CLOSE'.
    In the above pay attention to the loop.
    Cheers,

  • HT4199 I was trying to fax from my iMac to my HP office jet 8600, ran into a snag, so Ithough I would just print the document , then fax it from printer. I hit print and its telling me its offline, how do I correct this issue?

    Hi, I tried to make my first fax from the imac, I went into apple pref. to print and scan to change printer but could not get it to fax.
    So I thought I would just print the document place it on the HP Officejet 8600 and fax that way. Now its stuck on print stating I am offline?
    How do I correct this issue?
    Thanks..

    Hello,
    Mac OS X: About the Reset Printing System feature ...
    http://support.apple.com/kb/HT1341?viewlocale=en_US
    10.5/10.6/10.7/10.8 instructions...
    In System Preferences>Fax & Print, Right click or Control+click on the Printers list Sidebar, choose Reset Printing System.
    if you hold option and click the "-" tab it resets the printing system.
    http://www.macosxhints.com/article.php?story=20031215144430486
    Safe Boot from the HD, (holding Shift key down at bootup), run Disk Utility in Applications>Utilities, then highlight your drive, click on Repair Permissions.
    Any devices that previously appeared in your Printer List and Fax List will need to be added again after resetting the printing system.
    Resetting the printing system in Mac OS X 10.5.x+++
        1.    To use the Reset Printing System feature in Mac OS X 10.5.x, follow these steps:
        2.    Choose System Preferences from the Apple menu.
        3.    Choose Print & Fax from the View menu.
        4.    Control-click on list of printers on the left side of the window, then choose "Reset printing system" from the contextual menu. If you don't see a list of printers, Control-click on the text "Click + to add a printer or fax" and select "Reset printing system..." 
   
  As an alternative, if you currently have one or more printers listed, you can Option-click the "-" (Remove printer) button.
    http://support.apple.com/kb/ht1341
    Reboot.

  • Printing the document grid does not work

    Hi,
    I got here a lot of master documents. The design is built with a squre document grid. I need to print or export it as PDF. But activating the checkbox does not work. Is it possible to print it? Ruler guides and the base grid are working. But I need to print the document grid.
    Is there any possiblility to to this?
    Thanks
    DerSiedler

    Printing the document grid is not an option, but you might be able to work around it by creating your own grid using Layout > Create Guides... then printing the visible guides.
    I'd do that on a separate layer. If you want  the grid, but not other guide, make a real grid with colored strokes using step and repeat, again on a separate layer.

  • Scanning in both HP Officejet 7210 and Samsung printer - the document scans but no file is generated - any ideas how to fix this?  (It worked fine before installing Mavericks)

    Scanning in both HP Officejet 7210 and Samsung printer - the document scans but no file is generated - any ideas how to fix this?  (It worked fine before installing Mavericks)

    PS: forgot to mention: if your printer is on your wifi network, you'll have to enter your wifi password on the printer to connect it to the network before Printers & Scanners will see it.
    Sometimes a reset of the wifi system is needed too. A full set of directions would be:
    Try:
    uninstall all printer manufacturer apps and "utilities"
    go to System Preferences > Printers & Scanners > Print
    control-click on your printer in the column on the left
    select "Reset Printing System..." and "reset" in the dialog that follows
    do a factory reset on your printer. You'll have to consult the printer manual for how.
    power down everything: modem, router, computer, and printer
    power up each item in turn in the same order: modem, router, computer, and printer. Let each power up completely before moving on to the next
    enter your wifi password in your printer so it can connect to the network
    go back to printers & scanners and it should see your printer and download a driver for it from Apple
    resist the temptation to install any printer manufacturer apps in the future.

  • I copied a pnt. However, when I print the document the symbol doesn't print in color - how to fix it ?

    I copied a pictogram, incolor, from the internet and pasted into a pages document. However, when the document is printed the pictogram prints in
    black and white, not color.. How can I print it in color?

    What format is the pictogram?
    What color mode is the pictogram?
    Does it print in color from anywhere else?
    Have you tried editing the pictogram in anything else?
    …just maybe the problem is with the the pictogram.
    Peter

  • Each time I try to print a .pdf file, I get a message that Visual C ++ has requested the runtime to terminate it in an unusual way and shuts down so I can't print the document.

    How do I get rid of this problem so I can print pdf documents?

    If repairing doesn't work, then try a clean install. You will need to run the Acrobat/Reader Clean script: Download Adobe Reader and Acrobat Cleaner Tool - Adobe Labs

Maybe you are looking for

  • NotPrmUser showing up more often than it is supposed to

    Hello, I'm the admin for our P6 v7 system and we have recently expanded our user group to about 30 folks. 25 of the 30 access the software through the Web Access interface. According to Oracle technical solution ID 906128.1 the "NotPrmUser" should on

  • Oracle 10g Release 2 Ultra Search Install

    Hello, I am trying to install Oracle 10g Release 2 ultra seach feature. I have installed the Oracle 10g database and also the "Procedure for Installing Oracle Database 10g Products" option of the companion CD. But, I cannot seem to see the "wksys" us

  • Using PowerShell Functions in t-SQL scripts

    experts, Can I use a power shell function that gets file size given file path by cross applying it to a table in SQL Server that holds file path of files? fileID    filepath 1         L:\DemoWebPages\About.cshtml.txt 2         L:\DemoWebPages\default

  • Rebooting in solaris 10

    hi all, I am facing a unique problem with solaris 10. The system is rebooting every few seconds. When i boot in the fail safe mode everything is fine, i mean the file system is al fine. I even ran fdisk.everything seems to be fine..someone help!

  • Best Practices Web Services - Complex Data Types

    Can someone provide some best practices documentation or info that for customers using CR against web services? Speciffically any information on complex data types such as  String[] or Address. Thanks Ian S