Application Development and Automation 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: 
Read only

PDF attachment

Former Member
0 Likes
379

Hi frends,

i am sending a mail with PDF attachment.i am receving PDF Document also.But when i am opening it ,it contains Blank and "There was a problem reading this document(14)" getting this message.

Please help me.

for best aswer Points will be rewarded.

i am giving my code also.Plase check it.

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

format = 'PDF'

max_linewidth = 132

IMPORTING

bin_filesize = v_len_in

TABLES

otf = i_otf

lines = i_tline

EXCEPTIONS

err_max_linewidth = 1

err_format = 2

err_conv_not_possible = 3

OTHERS = 4.

IF sy-subrc <> 0.

ENDIF.

LOOP AT i_tline.

TRANSLATE i_tline USING '~'.

CONCATENATE wa_buffer i_tline INTO wa_buffer.

ENDLOOP.

TRANSLATE wa_buffer USING '~'.

DO.

i_record = wa_buffer.

APPEND i_record.

SHIFT wa_buffer LEFT BY 255 PLACES.

IF wa_buffer IS INITIAL.

EXIT.

ENDIF.

ENDDO.

  • Attachment

REFRESH: i_reclist,

i_objtxt,

i_objbin,

i_objpack.

CLEAR wa_objhead.

CALL FUNCTION 'QCE1_CONVERT'

TABLES

t_source_tab = i_record

t_target_tab = i_objbin

  • EXCEPTIONS

  • CONVERT_NOT_POSSIBLE = 1

  • OTHERS = 2

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

  • i_objbin[] = i_record[].

  • i_objbin[] = i_tline[].

  • Create Message Body Title and Description

i_objtxt = text-001.

APPEND i_objtxt.

DESCRIBE TABLE i_objtxt LINES v_lines_txt.

READ TABLE i_objtxt INDEX v_lines_txt.

wa_doc_chng-obj_name = text-001.

wa_doc_chng-expiry_dat = sy-datum + 10.

wa_doc_chng-obj_descr = text-001.

wa_doc_chng-sensitivty = 'F'.

wa_doc_chng-doc_size = v_lines_txt * 255.

  • Main Text

CLEAR i_objpack-transf_bin.

i_objpack-head_start = 1.

i_objpack-head_num = 1.

i_objpack-body_start = 1.

i_objpack-body_num = v_lines_txt.

i_objpack-doc_type = 'RAW'.

APPEND i_objpack.

  • Attachment (pdf-Attachment)

i_objpack-transf_bin = 'X'.

i_objpack-head_start = 1.

i_objpack-head_num = 1.

i_objpack-body_start = 1.

DESCRIBE TABLE i_objbin LINES v_lines_bin.

READ TABLE i_objbin INDEX v_lines_bin.

i_objpack-doc_size = v_lines_bin * 255 .

i_objpack-body_num = v_lines_bin.

i_objpack-doc_type = 'PDF'.

i_objpack-obj_name = text-001.

i_objpack-obj_descr = text-001.

APPEND i_objpack.

CLEAR i_reclist.

*****************************************************

*

  • SELECT SINGLE usrid_long FROM pa0105 INTO maild

  • WHERE pernr = wa_pa9031-pernr

  • AND subty = '0010'.

i_reclist-receiver = ''.

i_reclist-rec_type = 'U'.

i_reclist-com_type = 'INT'.

APPEND i_reclist.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = wa_doc_chng

put_in_outbox = 'X'

commit_work = 'X'

TABLES

packing_list = i_objpack

object_header = wa_objhead

contents_bin = i_objbin

contents_txt = i_objtxt

receivers = i_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.

WRITE:/ 'Error When Sending the File', sy-subrc.

ELSE.

WRITE:/ 'Mail sent'.

ENDIF.

ENDIF.

thanks ,

kumar.

1 REPLY 1
Read only

Former Member
0 Likes
342

hiiii

i had the same problem..

i used following code.try using this.it will solve your problem.

DATA: LVS_ITCPO         TYPE   ITCPO,
      LVF_DEVICE(30)    TYPE   C,
      LVF_DIALOG(1)     TYPE   C   VALUE ' ',
      LVS_RECIPIENT     LIKE   SWOTOBJID,
      LVS_SENDER        LIKE   SWOTOBJID,
      LVS_SNAST         TYPE   SNAST,
      LVF_PROGRAM       LIKE   SY-REPID,
      LVS_COMM_TYPE     TYPE   AD_COMM,
      LVS_COMM_VALUES   TYPE   SZADR_COMM_VALUES.

* convert communication data
MOVE-CORRESPONDING NAST TO LVS_SNAST.
MOVE SY-REPID           TO LVF_PROGRAM.
if LVS_SNAST-NACHA = '5'.
  LVS_SNAST-NACHA = '1'.
  LVS_SNAST-LDEST = 'LP01'.
endif.

CALL FUNCTION 'CONVERT_COMM_TYPE_DATA'
     EXPORTING
          PI_COMM_TYPE              = LVS_COMM_TYPE
          PI_COMM_VALUES            = LVS_COMM_VALUES
          PI_SCREEN                 = US_SCREEN
*           PI_NEWID                  =
          PI_COUNTRY                = US_COUNTRY
          PI_REPID                  = LVF_PROGRAM
          PI_SNAST                  = LVS_SNAST
     IMPORTING
          PE_ITCPO                  = LVS_ITCPO
          PE_DEVICE                 = LVF_DEVICE
          PE_MAIL_RECIPIENT         = LVS_RECIPIENT
          PE_MAIL_SENDER            = LVS_SENDER
     EXCEPTIONS
          COMM_TYPE_NOT_SUPPORTED   = 1
          RECIPIENT_CREATION_FAILED = 2
          SENDER_CREATION_FAILED    = 3
          OTHERS                    = 4.
IF SY-SUBRC <> 0.
  RETCODE = SY-SUBRC.
  SYST-MSGTY = 'E'.
  PERFORM PROTOCOL_UPDATE.
ENDIF.

check retcode eq 0.

* if there is no communication type
IF  LVS_COMM_TYPE IS INITIAL.
*   set device
  CASE NAST-NACHA.
    WHEN '1'.
      *LVF_DEVICE = 'PRINTER'.*
     *LVS_ITCPO-tdgetotf = 'X'.*   "This was my problem..you check this first
    WHEN '2'.
      LVF_DEVICE = 'TELEFAX'.
      LVS_ITCPO-TDTELENUM = NAST-TELFX.
      IF NAST-TLAND IS INITIAL.
        LVS_ITCPO-TDTELELAND = US_COUNTRY.
      ELSE.
        LVS_ITCPO-TDTELELAND = NAST-TLAND.
      ENDIF.
      LVS_ITCPO-TDSENDDATE = NAST-VSDAT.
      LVS_ITCPO-TDSENDTIME = NAST-VSURA.
      LVS_ITCPO-TDFAXUSER  = NAST-USNAM.
    
    WHEN OTHERS.
      LVF_DEVICE = 'PRINTER'.
  ENDCASE.
ENDIF.


CALL FUNCTION 'OPEN_FORM'
    EXPORTING
*           APPLICATION        = 'TX'
         ARCHIVE_INDEX      = TOA_DARA
         ARCHIVE_PARAMS     = ARC_PARAMS
         DEVICE             = LVF_DEVICE
         DIALOG             = ' '
         FORM               = TNAPR-FONAM
         LANGUAGE           = NAST-SPRAS
         OPTIONS            = LVS_ITCPO
         MAIL_SENDER        = LVS_SENDER
         MAIL_RECIPIENT     = LVS_RECIPIENT
    EXCEPTIONS
         CANCELED           = 1
         DEVICE             = 2
         FORM               = 3
         OPTIONS            = 4
         UNCLOSED           = 5
         MAIL_OPTIONS       = 6
         ARCHIVE_ERROR      = 7
         OTHERS             = 8.
IF SY-SUBRC NE 0.
  CASE SY-SUBRC.
    WHEN 7.
      RETCODE = SY-SUBRC.
      SYST-MSGID = 'VN'.
      SYST-MSGNO = '096'.
      SYST-MSGTY = 'E'.
      SYST-MSGV1 = NAST-KSCHL.
      SYST-MSGV2 = NAST-KAPPL.
      PERFORM PROTOCOL_UPDATE.
    WHEN OTHERS.
      RETCODE = SY-SUBRC.
      PERFORM PROTOCOL_UPDATE.
  ENDCASE.
ENDIF.

reward if useful

thx

twinkal