Skip to Content

Send/print PDF file to local printer from Web Dynpro Abap

Hi experts !!

I would like to know if it is possible to print or to send PDF document from the Web Dynpro to a local printer using any command inserted on a button.

I know that I could display PDF file on the Web Dynpro and push "standard print" button. But what I want to do is to send PDF document "by myself" not depending on ADOBE´s standard functionaity.

All this, is because I want to have under control when the user prints out PDF file (not to let him/her print 2 times). If user uses the standard PRINT button there is no way to check that.

Thanks in advance !!!

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Sep 21, 2011 at 12:37 PM

    hi,

    If i understood the reply correctly ... then i guess you want to have a print button on the screen by pressing this button the pdf file should get printed...also after first time pressing the button the button should not be allowed to press again...

    you can always do this i.e you can create a button on the screen and den have a smartform created say ZSMARTFORM..

    now you can write the below mentioned code on the button. you just created.

    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          FORMNAME                 = 'ZSMARTFORM' " smartform name
       IMPORTING
         FM_NAME                  = FM_NAME
                .
      IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      DATA: JOB_OUPUT TYPE SSFCRESCL,
            LT_OTFDATA TYPE TABLE OF ITCOO.
    
      DATA: LA_CTRL_FORM TYPE SSFCTRLOP,
            LA_OUTPUT_OPT TYPE SSFCOMPOP.
    
    ** Spool Parameters
      LA_OUTPUT_OPT-TDIMMED = 'X'.
      LA_OUTPUT_OPT-TDDELETE = 'X'.
      LA_OUTPUT_OPT-TDLIFETIME = 'X'.
      LA_OUTPUT_OPT-TDDEST = 'LOCL'.
    
    *    ****************************************************************************
    * Parameters passes to get the output in PDF format
    ****************************************************************************
      LA_CTRL_FORM-NO_DIALOG = 'X'.
      LA_CTRL_FORM-PREVIEW = 'X'.
      LA_CTRL_FORM-GETOTF = 'X'.
      LA_CTRL_FORM-LANGU = 'EN'.
      LA_CTRL_FORM-DEVICE = 'PRINTER'.
    
      CALL FUNCTION FM_NAME
        EXPORTING
         CONTROL_PARAMETERS         =  LA_CTRL_FORM
         OUTPUT_OPTIONS             = LA_OUTPUT_OPT
          BILLABLE_LOT               = A "ls_ctx_vn_inp-BILLABLE_LOT
          SECTION                    = B "ls_ctx_vn_inp-SECTION
          PROJECT                    = PROJECT
          MGROUP                     = MGROUP
       IMPORTING
         JOB_OUTPUT_INFO            = JOB_OUPUT
       EXCEPTIONS
         FORMATTING_ERROR           = 1
         INTERNAL_ERROR             = 2
         SEND_ERROR                 = 3
         USER_CANCELED              = 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.
      REFRESH LT_OTFDATA.
    
      LT_OTFDATA[] = JOB_OUPUT-OTFDATA[].
    
      CALL FUNCTION 'SSFCOMP_PDF_PREVIEW'
        EXPORTING
          I_OTF                    = LT_OTFDATA
        EXCEPTIONS
          CONVERT_OTF_TO_PDF_ERROR = 1
          CNTL_ERROR               = 2
          OTHERS                   = 3.
    
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    
      DATA: L_DUMMY TYPE STANDARD TABLE OF TLINE,
      PDF_DATA TYPE XSTRING,
      PDF_SIZE TYPE I.
      CLEAR: PDF_DATA, PDF_SIZE.
    
    * convert otf to pdf
      CALL FUNCTION 'CONVERT_OTF'
        EXPORTING
          FORMAT                = 'PDF'
          MAX_LINEWIDTH         = 255
        IMPORTING
          BIN_FILESIZE          = PDF_SIZE
          BIN_FILE              = PDF_DATA
        TABLES
          OTF                   = LT_OTFDATA[]
          LINES                 = L_DUMMY
        EXCEPTIONS
          ERR_MAX_LINEWIDTH     = 1
          ERR_FORMAT            = 2
          ERR_CONV_NOT_POSSIBLE = 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.
    
      WDR_TASK=>CLIENT_WINDOW->CLIENT->ATTACH_FILE_TO_RESPONSE(
    *    *path to the word file
        I_FILENAME = 'JobCard.pdf'
    *     String Variable
        I_CONTENT =  PDF_DATA
    *     File Type
        I_MIME_TYPE = 'PDF' ).

    now you can create an attibute wdui_visibility...and den pass value 1 or 2 and bind this attribute to the visibility property of the button so that the button will be visible for the first time only and afetr getting preesed it will be invisible preventing any further click...

    i think this will solve your problem.

    Regards,

    Sahai.S

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.