Sapscript converted to PDF throug spool and sent via email

Hello gurus, i have the following code for the requeriment and when trying to open file through transaction SOST, the system says that the file is corrupted.
What am I doing wrong please?
Help is very appreciated!!!!
    CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
      EXPORTING
        src_spoolid              = w_spool
        no_dialog                = c_marca
        dst_device               = zcts_itcpo-tddest
      IMPORTING
        pdf_bytecount            = w_numbytes
      TABLES
        pdf                      = i_pdf
      EXCEPTIONS
        err_no_otf_spooljob      = 1
        err_no_spooljob          = 2
        err_no_permission        = 3
        err_conv_not_possible    = 4
        err_bad_dstdevice        = 5
        user_cancelled           = 6
        err_spoolerror           = 7
        err_temseerror           = 8
        err_btcjob_open_failed   = 9
        err_btcjob_submit_failed = 10
        err_btcjob_close_failed  = 11
        OTHERS                   = 12.
        If sy-subrc eq 0.
               PERFORM f_convert_pdf TABLES i_pdf
                                                                 i_objbin.
               PERFORM f_send_mail.
        endif.
FORM f_convert_pdf  TABLES   i_source_tab STRUCTURE tline
                             i_target_tab STRUCTURE zcts_objbin.
  DATA: l_hfeld(1600) TYPE c,
        l_offset TYPE p,
        l_tabix TYPE sy-tabix,
        l_linecount_source TYPE i,
        l_length_source TYPE i,
        l_length_target TYPE i.
  CLEAR: l_hfeld,
         l_offset,
         l_tabix,
         l_linecount_source,
         l_length_source,
         l_length_target,
         zcts_pdf,
         zcts_objbin.
  DESCRIBE FIELD i_source_tab LENGTH l_length_source IN BYTE MODE.
  DESCRIBE FIELD i_target_tab LENGTH l_length_target IN BYTE MODE.
  DESCRIBE TABLE i_source_tab LINES l_linecount_source.
  CLEAR:
    i_target_tab,
    zcts_pdf.
  LOOP AT i_source_tab INTO zcts_pdf.
    l_tabix = sy-tabix.
    MOVE zcts_pdf TO l_hfeld+l_offset.
    IF l_tabix EQ l_linecount_source.
      l_length_source = STRLEN( zcts_pdf ).
    ENDIF.
    l_offset = l_offset + l_length_source.
    WHILE l_offset GE l_length_target.
      zcts_objbin = l_hfeld(l_length_target).
      APPEND zcts_objbin TO i_target_tab.
      CLEAR zcts_objbin.
      SHIFT l_hfeld BY l_length_target PLACES.
      l_offset = l_offset - l_length_target.
    ENDWHILE.
    IF l_tabix EQ l_linecount_source.
      IF l_offset GT 0.
        zcts_objbin = l_hfeld(l_offset).
        APPEND zcts_objbin TO i_target_tab.
        CLEAR zcts_objbin.
      ENDIF.
    ENDIF.
    CLEAR:
      i_source_tab,
      zcts_pdf.
  ENDLOOP.
ENDFORM.                    " f_convert_pdf
FORM f_send_mail .
  DATA: l_lines_txt TYPE i,
        l_lines_bod TYPE i.
  CLEAR: i_reclist,
         i_objpack,
         l_lines_txt,
         l_lines_bod.
  CLEAR i_objhead.
Create here the mail body
  DATA: li_mess_bod LIKE solisti1 OCCURS 0 WITH HEADER LINE.
  CLEAR li_mess_bod.
  li_mess_bod = text-012.
  APPEND li_mess_bod.
  IF sy-subrc EQ 0.
    CLEAR zcts_objtxt.
  ENDIF.
  CLEAR i_materials.
  READ TABLE i_materials INDEX 1.
  IF sy-subrc EQ 0.
    CONCATENATE text-013 i_materials-maktx INTO li_mess_bod SEPARATED BY space.
  ENDIF.
  APPEND li_mess_bod.
  IF sy-subrc EQ 0.
    CLEAR li_mess_bod.
  ENDIF.
  IF p_deliv IS INITIAL.
    CONCATENATE text-014 p_sales INTO li_mess_bod SEPARATED BY space.
  ELSE.
    CONCATENATE text-014 p_deliv INTO li_mess_bod SEPARATED BY space.
  ENDIF.
  APPEND li_mess_bod.
  IF sy-subrc EQ 0.
    CLEAR li_mess_bod.
  ENDIF.
  DESCRIBE TABLE li_mess_bod LINES l_lines_bod.
  CLEAR li_mess_bod.
  READ TABLE li_mess_bod INDEX l_lines_bod.
  IF sy-subrc NE 0.
    CLEAR li_mess_bod.
  ENDIF.
  zcts_doc_chng-obj_name = 'CERTIFICATE'.
Subject
  IF p_deliv IS INITIAL.
    CLEAR i_delivery.
    READ TABLE i_delivery INDEX 1.
    IF sy-subrc EQ 0.
      CONCATENATE text-011 i_delivery-vbeln sy-datum INTO zcts_doc_chng-obj_descr SEPARATED BY space.
    ENDIF.
  ELSE.
    CONCATENATE text-011 p_deliv sy-datum INTO zcts_doc_chng-obj_descr SEPARATED BY space.
  ENDIF.
Fill the document data and get size of attachment
  zcts_doc_chng-sensitivty = c_sens.
  zcts_doc_chng-doc_size = ( l_lines_bod - 1 ) * 255 + STRLEN( li_mess_bod ).
Body mail
  CLEAR zcts_objpack-transf_bin.
  zcts_objpack-head_start = 1.
  zcts_objpack-head_num = 0.
  zcts_objpack-body_start = 1.
  zcts_objpack-body_num = l_lines_bod.
  zcts_objpack-doc_type = c_doc_type.
  APPEND zcts_objpack TO i_objpack.
PDF attachment
  zcts_objpack-transf_bin = c_marca.
  zcts_objpack-head_start = 1.
  zcts_objpack-head_num = 0.
  zcts_objpack-body_start = 1.
  DESCRIBE TABLE i_objbin LINES l_lines_txt.
  zcts_objpack-doc_size = l_lines_txt * 255.
zcts_objpack-doc_size = w_numbytes.
  zcts_objpack-doc_type = c_doc_type2.
  zcts_objpack-obj_name = c_obj_name.
  CONCATENATE text-010 sy-datum INTO zcts_objpack-obj_descr SEPARATED BY space.
  APPEND zcts_objpack TO i_objpack.
Mail destinary
  zcts_reclist-receiver = text-018.
  zcts_reclist-rec_type = c_rec.
  zcts_reclist-com_type = c_com_type.
  APPEND zcts_reclist TO i_reclist.
Call function below to sending PDF object to internet email address
  CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
      document_data              = zcts_doc_chng
      put_in_outbox              = c_marca
      commit_work                = c_marca
    TABLES
      packing_list               = i_objpack
      object_header              = i_objhead
      contents_bin               = i_objbin
      contents_txt               = li_mess_bod
      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 NE 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
ENDFORM.                    " f_send_mail

hi
good
go through this code hope this will help you to solve your problem
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/8cd6adbb-0301-0010-39ba-938c601d5db9
reward point if hlepful.
thanks
mrutyun^

Similar Messages

  • Convert Script to PDF using RVADOPFO, w/o using spool and send via email

    I want to convert output type script to pdf using the standard include RVADOPFO in the program. The output type is defined as medium '5' and comm starategy is also defined as INT(email) as want to send the output via email.
    Now the Include RVADOPFO contains ADDR_KEY-ADDRNUMBER & ADDR_KEY-PERSNUMBER. Where to maintain this info and how to pass in the include..below code is in the include..
    IF NOT NAST-TCODE IS INITIAL AND NAST-NACHA EQ '5'.
      ... use stratagy to get communication type
        CALL FUNCTION 'ADDR_GET_NEXT_COMM_TYPE'
             EXPORTING
                  STRATEGY           = NAST-TCODE
                ADDRESS_TYPE       =
                ADDRESS_NUMBER     = VBDKA-ADRNR
                PERSON_NUMBER      = VBDKA-ADRNP
                  ADDRESS_NUMBER     = ADDR_KEY-ADDRNUMBER
                  PERSON_NUMBER      = ADDR_KEY-PERSNUMBER
             IMPORTING
                  COMM_TYPE          = LVS_COMM_TYPE
                  COMM_VALUES        = LVS_COMM_VALUES
           TABLES
                STRATEGY_TABLE     =
             EXCEPTIONS
                  ADDRESS_NOT_EXIST  = 1
                  PERSON_NOT_EXIST   = 2
                  NO_COMM_TYPE_FOUND = 3
                  INTERNAL_ERROR     = 4
                  PARAMETER_ERROR    = 5
                  OTHERS             = 6.
    Please provide solution asap. Thanks in advance

    Hi,
    Check this links:
    Sending Mail from SAP
    https://wiki.sdn.sap.com/wiki/display/sandbox/SendMailwithPDFAttachment?showChildren=false#children
    Thanks.

  • PDF attachment not getting sent via email. This occurs intermittently.

    Hi All,
    There is a concurrent program which sends report on Purchase Orders. The report is sent as a PDF attachment via email.
    The report is getting attached sometimes and not getting attached sometimes giving an empty email. Checked the log files and output files of the program and couldnt find any issue. There is no specific time/PO/vendor pattern wherein the program fails.
    Please let me know what needs to be done to get this resolved.
    Regards,
    Radhika.

    Hi,
    I am facing this issue with Oracle 11i - US Purchasing SuperUser responsiblity.
    There is a concurrent program which generates a report and then sends the report to printer. The report is not getting stored in a temp file in any directory. It is directly emailed as a PDF attachment.
    Sometimes the attachment is getting sent while sometimes it is not getting attached.
    Please let me know if any other information is required.
    Regards,
    Radhika.

  • Spool file sent via email

    I'm trying to send a spool file out via an email.  I'm having no trouble generating the email, but the file is coming out with extra spaces in the output. 
    f o r  e x a m p l e  i t  l o o k s   l i k e   t h i s
    Does anyone know of a parameter I am mis-using on the function module  'SO_DOCUMENT_SEND_API1' or a similar function module which will fix this issue?
    Points will be rewarded.

    That was my original thought, but the data passed into the function module looks correct and without need of condense statements.
    This is how the data looks after the email.
    I D ; P                                                                                C ; Y 1 ; X 1 ; K   " R o w   1 "                                                                                C ; Y 2 ; X 1 ; K   " R o w   2 "                                                                                C ; Y 3 ; X 1 ; K   " T o t a l "                                                                                C ; Y 1 ; X 2 ; K 1 1                                                                                C ; Y 2 ; X 2 ; K 2 2                                                                                C ; Y 3 ; X 2 ; K 0 ; E R 1 C 2 + R 2 C 2                                                                                E                                                                                P                                            
    This is how it should look, and how the internal table I pass into the function module looks:
    ID;P
    C;Y1;X1;K"Row1"
    C;Y2;X1;K"Row2"
    C;Y3;X1;K"Total"
    C;Y1;X2;K11
    C;Y2;X2;K22
    C;Y3;X2;K0;ER1C2+R2C2
    EP

  • I downloaded the Adobe free trial to convert a PDF to Word and it will not open.  Further, even though I have signed in, it reverts back to the sign in page over and over and over again.  How do I to convert?

    I downloaded the Adobe free trial to convert a PDF to Word and it will not open.  Further, even though I have signed in, it reverts back to the sign in page over and over and over again.  How do I convert?

    Moving this discussion to the Adobe CreatePDF forum.

  • I am trying to convert a pdf to Word and keep receiving an error message "an error occurred while trying to acess the service".  Any suggestions?

    I am trying to convert a pdf to Word and keep receiving an error message "an error occurred while trying to acess the service".  Any suggestions?

    Hi lee,
    Are you still facing this issue?
    Did you tried accessing the service using the browser : http://cloud.acrobat.com/exportpdf
    Regards,
    Rahul

  • I converted a pdf to word and when it opens in word it looks fine but in a few seconds it converts t

                   I converted a pdf to word and when it opens in word it looks fine but in a few seconds it converts to multiple spelling errors ?

    Hi Jim,
    I just responded directly. Unfortunately the original PDF is from an old fax or scan. The random ink marks and blotches along with the runny font won't transfer the proper information from PDF to Word. The only thing I can recommend is to re-create the doc so you have a clean copy. As I offered - if you need a PDF of it after you have completed - I'd be happy to do that for you.
    Kind regards, Stacy

  • No Payment document attachement (PDF) sent via email

    Hi,
    We have been running the auto-email with PDF payment attachement via F110 for quite some times. Recently my user feedback that some of the vendors receive the email sent by SAP system, however, no attachement being sent to them.
    I have checked the F110 log, which the requested email is generated successfully. However, i couldn't check whether there is email attachement being to them via SOST.
    We are in ECC6. The reported cases are perhaps 5% of the batch payment document running affected with no pdf file attachement sent via email.
    I have been searching around any similar case and how we trace the problem. Can someone share on it?
    Thank you very much in advance.

    Hi
    Ask to these vendor what kind of software they have to avoid SPAM, or if they manage black lists, 'grey' list. There are other software tools managing these messages. Sometimes these tools remove the attachments.
    I hope this helps you
    Regards
    Eduardo
    Edited by: E_Hinojosa on Dec 16, 2011 10:22 AM

  • I cannot open PDF filkes sent via email. I used too. nHow do I fix.

    Cannot open PDF files sent via email. The open via Word in encripted jinerish. This has not happend until now.
    Ciro

    I had the same problem.  My version of RoboHelp is pretty old (x5) and the problem was with pdfs made up in version 9.  Some pdfs would open and some would not.  It depended on the version used to make the pdf.  Got error messages and corrupted file messages.
    I solved the problem by using the full version of Acrobat and using the pdf Optimizer to make compatible with version 5( just to make sure).
    Another option is to "print" to the pdf printer when the file is open.
    Both then can be imported into RoboHelp without a problem
    Hope this helps.  It ruined many days at work for me while I tried to figure out what on earth I was going to do.
    Holly

  • I have a large PDF that I cannot send via email because of its size, 76 MB. How do I shrink this file or convert it to another format so I can email this, less than 20MB? Thanks for your help

    I have a large PDF that I cannot send via email because of its size, 76 MB. How do I shrink this file or convert it to another format so I can email this, less than 20MB? Thanks for your help

    Open the file in Preview and select "Save as..." from the File menu. Select "Reduce File Size" from the Quartz Filter menu and save. The size probably won't be reduced enough, though. You may have to split the file into several parts and mail them separately. Or upload it to a web server and send the link.

  • I filled out my own form saved it and sent through email, when I opened it what I filled out was not there, why would this be

    I filled out my own form saved it and sent through email, when I opened it what I filled out was not there, why would this be?

    What software did you use to fill-in the form (Preview, perhaps) and what software did you use to open it after you emailed it?

  • I have been able to open pdfs created in older versions of adobe, but not the newest version. Is anyone having issues opening PDFs sent via email created in version 9?

    I have been able to open pdfs created in older versions of adobe, but not the newest version. Is anyone having issues opening PDFs sent via email created in version 9? If so, what was your solution? I have PDF reader app as well.

    Can you open the files in Preview?

  • I tried sending the Adobe pdf file of a poster via email and it said the file was too large to send.  How do I remedy this?

    I tried sending an Adobe pdf file of a poster via email and it wouldn't go through because it said the file was too large.  How do I remedy this?

    Lots of free file hosters out there. Mediafire.com as an example. Upload a file there, copy and paste the download link you are given into your email to the client, then delete it as soon as the client successfully downloads it. Mediafire has 10 gb storage for free accounts.
    Email is limited to 10 MB on attachments. So that's where file hosting comes in.

  • Keeping PDF form format when sending via email

    Hello, I have created a form using Adobe LiveCycle.  It contains a submit button to send the filled out form to a recipient via email.  After numerous draft attempts the form gets converted into an .XML format when it is attached to a new email message.  I want the form to stay as a PDF but LiveCycle indicates the form would need to be sent to an HTTP address.  I don't have such an address.
    Is there some way to force the form to keep its PDF format and be sent via email by the push of a button?
    (I know that you can click File--attach to Email to but I would like to avoid that method).  Thank you.

    Q: Is there some way to force the form to keep its PDF format and be sent via email by the push of a button?
    A #1: Yes, you can use the standard button, set the format to "PDF" and supply the mailto:[email protected] and it will use the client side email software to attach and send the PDF. Note: You will need to enable usage rights on the PDF to allow Adobe Reader users to submit whole PDF format. Normally Adobe Reader users are only allowed to submit the data formats, XML and XDP for LiveCycle forms, and HTML, XFDF and FDF for Acroforms.
    A #2: You can also bypass client-side email software such as OUTLOOK, if you set the submit button action to a URL of a server-side script, such as PHP or ASP.Net. The script could generate an SMTP message, and attach the submission without the use of client-side email software. By using a server-side script, the PDF submission process is almost fool proof.
    View online examples for emailing PDF form submissions with a server-side script:
    http://www.pdfemail.net/examples/

  • How do i get photos sent via email into the new photos app in yosemite 10.10.3

    Using mail on my mac, having upgraded to Yosemite 10.10.3 i now cant import photos sent via email into the new photos app. if i highlight the photo in mail and right click the mouse the option is still to export to iPhoto !!

    I was clicking on the photo, so thanks for telling me about the save icon - unfortunately this still tries to open up and save to iPhoto the same as clicking on the image but my photos have been moved from iPhoto to the new photos app as part of the update to 10.10.3 Yosemite. Although it also gives me the option to save other places i cant work out how to save into the photo app

Maybe you are looking for