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

Corrupted data in pdf generated by CONVERT_OTF

Former Member
0 Likes
2,350

Hello Experts,

I have got a issue in a z-program which is used to print a notification and eventually sends the same print output in a pdf to the customer. In the program, after the function module close_form, the Function module  CONVERT_OTF is used to generate pdf. Later the pdf is sent as attachment in the mail using the FM -  SO_DOCUMENT_SEND_API1 . But the pdf is unreadable when it is sent to customer. Please help. Attached is the example of the problem.

Hello Experts,

I have got a issue in a z-program which is used to print a notification and eventually sends the same print output in a pdf to the customer. In the program, after the function module close_form, the Function module  CONVERT_OTF is used to generate pdf. Later the pdf is sent as attachment in the mail using the FM -  SO_DOCUMENT_SEND_API1 . But the pdf is unreadable when it is sent to customer. Please help. Attached is the example of the problem.

7 REPLIES 7
Read only

former_member188724
Contributor
0 Likes
1,719

Hi,

Did you check by generating a spool and converting it manually to pdf using rstx*.. program.

Pls check whether it works.

Hope this helps.

Regds,

K.S

Read only

0 Likes
1,719

Hello K.S,

The print version is fine. But the problem is only in pdf format. As you can see the content is overwritten.

Thanks & Regards,

Sainath

Read only

Former Member
0 Likes
1,719

Hi Sainath Raj,

Did you check whether there was actual OTF data present? If your FM doesn't return the OTF data, the CONVERT_TO pdf will run successfully, but the pdf can't be opened (error).

Best regards,

Zhou

Read only

0 Likes
1,719

Hello Zhou Tsui,

Yes, i can see the data OTF data in debug mode. And there is no problem in opening the pdf file. the only problem is with the content in the pdf. it is overwritten and not readable.

Thanks & Regards,

Sainath

Read only

Former Member
0 Likes
1,719

Hello,

This problem happens to a particular user. Is there anything wrong with user data or printer configuration? I have checked the user master with the successful user master data. No differences are found.

Thanks,

Sainath

Read only

0 Likes
1,719

Hi Sainath,

I can't think of anything particular since we don't have the exact code here (yet).

But one thing which might be user specific, is the printer used.

Have you checked the default printer for this user in the output options?

Try setting it to 'LOCAL' in case you would like to create an email.

ls_output_options-tddest = 'LOCAL'.

Put you code here so we can help you even better 🙂

Best regards,

Zhou

Read only

Former Member
0 Likes
1,719

Hi sainath,

If you use the function module SO_DOCUMENT_SEND_API1 to send the mail as pdf attachment it will show Such error. I also had a similar scenario.

You can use the class CL_BCS to send the mail with PDF attachment. Very simple method it is.

Please check with below mentioned code.

DATA: LCL_send_request TYPE REF TO cl_bcs,         " Send request

       body      TYPE bcsy_text,                " Mail body

       attachment    TYPE bcsy_text,                " Attachment

       text     TYPE soli,                     " Work area for attach

       lcl_document  TYPE REF TO cl_document_bcs,   " Mail body

       sender    TYPE REF TO if_sender_bcs,     " Sender address

       recipient TYPE REF TO if_recipient_bcs" Recipient

       email     type ad_smtpadr,               " Email ID

       extension type soodk-objtp value 'OTF'" TXT format

       size      TYPE sood-objlen,              " Size of Attachment

       name type char50,

         sent_to_all TYPE os_boolean.

APPEND 'Dear  ,' TO body.

   APPEND ' ' TO BODY.   " body of the mail

    attachment[] = st_job_output_info-otfdata[].  " pass the otfdata table

   doc_line = LINES( attachment ).

   size = doc_line * 255.

   TRY.

       lcl_send_request = cl_bcs=>create_persistent( ).

       lcl_document = cl_document_bcs=>create_document(

                   i_type    = 'RAW'

                   i_text    = body

                   i_subject = '  ' ).

   

       CALL METHOD l_document->add_attachment

         EXPORTING

           i_attachment_type    = extension    "'PDF'

           i_attachment_subject =name

           i_attachment_size    = size

           i_att_content_text   = attachment.

       CALL METHOD lcl_send_request->set_document( document ).

       sender = cl_sapuser_bcs=>create( sy-uname ).

       CALL METHOD lcl_send_request->set_sender

         EXPORTING

           i_sender = sender.

       email = ''. " email id

       recipient = cl_cam_address_bcs=>create_internet_address( email ).

       CALL METHOD lcl_send_request->add_recipient

         EXPORTING

           i_recipient  = recipient

           i_express    = 'X'

           i_copy       = ' '

           i_blind_copy = ' '

           i_no_forward = ' '.

       CLEAR l_email.

      lcl_send_request->set_send_immediately( 'X' ). " send mail directly without queuing in sost

       sent_to_all = lcl_send_request->send( ).

       COMMIT WORK.



Regards,

Sajeesh