Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Encrypted PDF file open error

former_member182040
Active Contributor
0 Kudos

Hi All,

problem is when i open to outlook to check mail at that time i got mail but attached file is not open which is encrypted file

so please help how to open attached file following process i do .

1: convert otf to pdf file

2: download pdf file into application server

3:encrypt pdf file with password protect

4:upload pdf file from application server

5:send mail

1. OTR TO PDF


CALL FUNCTION 'CONVERT_OTF'
   EXPORTING
     format                      = 'PDF'
     max_linewidth               = 132
*   ARCHIVE_INDEX               = ' '
*   COPYNUMBER                  = 0
*   ASCII_BIDI_VIS2LOG          = ' '
*   PDF_DELETE_OTFTAB           = ' '
   IMPORTING
     bin_filesize                = gv_bin_filesize
*   BIN_FILE                    =
    TABLES
      otf                         = gt_otf
      lines                       = gt_pdf_tab
   EXCEPTIONS
     err_max_linewidth           = 1
     err_format                  = 2
     err_conv_not_possible       = 3
     err_bad_otf                 = 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.
  

then download pdf file into application server using following code


 OPEN DATASET l_file FOR OUTPUT IN BINARY MODE  .
  IF  sy-subrc = 0 .
    LOOP AT gt_pdf_tab.
      TRANSFER gt_pdf_tab TO l_file .
    ENDLOOP.
    CLOSE DATASET l_file  .
  ELSE.
    WRITE : / 'operating system could not open file' .
  ENDIF.

*Then i use command line mode Encryptpdf, from verypdf.com, *

  • so successfuly file encrypted and password protected.*

Then upload pdf filw which is encrypted form application server


OPEN DATASET to_file FOR INPUT IN BINARY MODE.
  IF sy-subrc = 0.
    DO .
      READ DATASET to_file INTO gs_objbin. "GS_PDF_TAB.
      IF sy-subrc = 0.
        APPEND gs_objbin TO gt_objbin .  "GS_PDF_TAB TO GT_PDF_TAB.
      ELSE.
        EXIT.
      ENDIF.
    ENDDO.
    CLOSE DATASET to_file.
  ENDIF.

then i use use FM SO_NEW_DOCUMENT_ATT_SEND_API1


CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
      document_data                    = gs_docdata
     put_in_outbox                    = 'X'
     commit_work                      = 'X'
* IMPORTING
*   SENT_TO_ALL                      =
*   NEW_OBJECT_ID                    =
    TABLES
      packing_list                     = gt_objpack
*   OBJECT_HEADER                    =  I_OBJTXT
     contents_bin                     = gt_objbin
     contents_txt                     = i_objtxt
*   CONTENTS_HEX                     =
*   OBJECT_PARA                      =
*   OBJECT_PARB                      =
      receivers                        = gt_reclist
   EXCEPTIONS
     too_many_receivers               = 1
     document_not_sent                = 2
     document_type_not_exist          = 3
     operation_no_authorization       = 4
     parameter_error                  = 5
     x_error                          = 6
     enqueue_error                    = 7
     OTHERS                           = 8
  

Edited by: Krupaji on Oct 27, 2010 11:31 AM

9 REPLIES 9

former_member182040
Active Contributor
0 Kudos

solve :

convert OTF to .PDF and then .ZIP and then send mail

MarkusKlein
Active Contributor
0 Kudos

> *Then i use command line mode Encryptpdf, from verypdf.com, *

> * so successfuly file encrypted and password protected.*

Hey there,

nice approach.

I have one question tho: How do you execute the commands of encryptpdf from your ABAP code?

regards,

Markus

0 Kudos

use FM CALL FUNCTION 'SXPG_COMMAND_EXECUTE'

Former Member
0 Kudos

Hi Krupa,

I am trying to do exactly same thing as you did.. encrypting the PDF.. but when i am decrypting the file received in email getting error" Wrong final block length'...

Could you please tell me, if you had same problem? or something else?

Did zipping it solve the problem? if yes, how did you zipped it?

0 Kudos

for encrypted PDF you can check my following document

http://scn.sap.com/docs/DOC-29209

Clemenss
Active Contributor
0 Kudos

never help users with FM SO_NEW_DOCUMENT_ATT_SEND_API1

0 Kudos

for encrypted PDF you can check my following document

http://scn.sap.com/docs/DOC-29209

0 Kudos

Related FM SO_NEW_DOCUMENT_ATT_SEND_API1 you can check following example:

clear : gs_docdata,gt_objbin. "

    refresh : gt_objbin . "

*   gs_docdata-obj_name = 'ord_accept'.

    gs_docdata-obj_name = 'Invoice'.

    gs_docdata-expiry_dat = sy-datum + 10.

*   gs_docdata-obj_descr = 'Your Invoice No : '.

    gs_docdata-obj_descr = detail1.

    gs_docdata-sensitivty = 'F'. "Functional object

    gs_docdata-doc_size = gv_desc_lines * 255.

    clear gs_objpack-transf_bin.

* Start line of object header in transport packet

*    GS_OBJPACK-TRANSF_BIN = 'X'.

    gs_objpack-doc_size = gv_desc_lines * 255.

    gs_objpack-head_start = 1.

    gs_objpack-head_num = 0.

    gs_objpack-body_start = 1.

    gs_objpack-body_num = gv_desc_lines.

    gs_objpack-doc_type = 'RAW'.

*    GS_OBJPACK-OBJ_NAME = 'ORDER_ACCEPTANCE'.

*    GS_OBJPACK-OBJ_DESCR = 'ORDER_ACCEPTANCE.PDF'.

    append gs_objpack to gt_objpack.

  endif.

*• Passing the SAP Script text lines to SAPoffice: Single List with Column Length 255 table

  clear : gs_objbin, gs_pdf_tab.

&---------------------------------------------------------------------*

*&      Encrypted file

*&---------------------------------------------------------------------*

  filename = name.

  if name is initial.

    concatenate   'd:\pdf\' main_dtl-vbeln '.PDF' into name.

  filename = name.

endif.

data: pdf type ref to cl_hrasr00_pdf_generation.

  data : lt_data            type solix_tab.

  open dataset filename for input in binary mode.

  if sy-subrc eq 0.

    read dataset filename into filex.

  endif.

  if filex is not initial.

    call function 'SCMS_XSTRING_TO_BINARY'

      exporting

        buffer        = filex

      importing

        output_length = file_length

      tables

        binary_tab    = gt_objbin.

  endif.

  close dataset filename.

describe table gt_objbin lines gv_tab_lines.

  clear gs_objbin.

  read table gt_objbin into gs_objbin index gv_tab_lines.

  if sy-subrc = 0.

    gs_objpack-doc_size = ( gv_tab_lines - 1 ) * 255 + strlen( gs_objbin ).

    gs_objpack-transf_bin = 'X'.

    gs_objpack-head_start = 1.

    gs_objpack-head_num = 0.

    gs_objpack-body_start = 1.

    gs_objpack-body_num = gv_tab_lines.

    gs_objpack-doc_type = 'PDF'.

    gs_objpack-obj_name = 'INVOICE'.

    gs_objpack-obj_descr = 'Invoice Order'.

    append gs_objpack to gt_objpack.

  endif.

call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'

    exporting

      document_data                    = gs_docdata

     put_in_outbox                    = 'X'

     commit_work                      = 'X'

* IMPORTING

*   SENT_TO_ALL                      =

*   NEW_OBJECT_ID                    =

    tables

      packing_list                     = gt_objpack

*   OBJECT_HEADER                    =  I_OBJTXT

     contents_bin                     = gt_objbin

     contents_txt                     = i_objtxt

*   CONTENTS_HEX                     =

*   OBJECT_PARA                      =

*   OBJECT_PARB                      =

      receivers                        = gt_reclist

   exceptions

     too_many_receivers               = 1

     document_not_sent                = 2

     document_type_not_exist          = 3

     operation_no_authorization       = 4

     parameter_error                  = 5

     x_error                          = 6

     enqueue_error                    = 7

     others                           = 8

            .

  if sy-subrc <> 0.

    message id sy-msgid type sy-msgty number sy-msgno

            with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

  else.

*

    open dataset name for input in binary mode.

    if sy-subrc eq 0.

      delete dataset filename.

    endif.

Former Member
0 Kudos

This message was moderated.