2013 Sep 20 8:42 AM
Hi All,
i have a requirement where i need to transfer the OTF data to PDF data, where i am using FM "
CONVERT_OTFSPOOLJOB_2_PDF", i am pasing the spool number to function module CONVERT_OTFSPOOLJOB_2_PDF
but i am getting pdf data as junk. I even checked RSTXPDFT4 program by passing the spool number , there also i am getting junk values ..However when i try to use GUI_DOWNLOAD function module , though the data is junk i am able to download it and when i open the PDF file the values are coming.
My requirement is not to download but to capture the PDF and email it as an attachment.
I have searched in SCN but unable to find any solution.
Can you please suggest me any solution.
Regards,
Durga Prasad.
Message was edited by: Durgaprasad Thota
2013 Sep 20 10:34 AM
If you try to see the OTF table from spool the values will be junk as they are in binary format.
Mail it to your own id as attachment and check it will be good PDF.
for any issues in mailing please check
Convert Spool request to PDF and send as e-mail - Code Gallery - SCN Wiki
Regards
2013 Sep 20 10:34 AM
If you try to see the OTF table from spool the values will be junk as they are in binary format.
Mail it to your own id as attachment and check it will be good PDF.
for any issues in mailing please check
Convert Spool request to PDF and send as e-mail - Code Gallery - SCN Wiki
Regards
2013 Sep 20 1:01 PM
Hi,
Thanks for the reply...i am getting the email in SOST but when i open the attachment in SOST, i am getting error that the PDF file is corrupted.
Do you think if i get the email i will be getting the correct PDF.
Regards,
Durga Prasad.
2013 Sep 20 2:31 PM
Hi,
Can you paste the code here. We can take a look at it and see whether you have missed something.
Thanks
Sam
2013 Sep 20 2:44 PM
Hi,
i am pasting the code for my requirement as bellow. Check the code and suggest me if any changes are required.
SELECT SINGLE pname FROM tfdir INTO gv_vec
WHERE funcname = gv_fm_name.
CONCATENATE gc_coma gv_vec gc_job INTO gv_vec.
ASSIGN (gv_vec) TO <gf_p>.
IF sy-subrc = 0
AND <gf_p>-spoolids[] IS NOT INITIAL
AND us_screen IS INITIAL.
LOOP AT <gf_p>-spoolids INTO gv_spoolid.
EXIT.
ENDLOOP.
UNASSIGN <gf_p>.
ENDIF.
ENDIF.
* FM TO CONVERT DATA FROM OTF FORMAT TO PDF FORMAT
IF gv_spoolid IS NOT INITIAL.
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = gv_spoolid
no_dialog = ' '
IMPORTING
pdf_bytecount = gv_numbytes
pdf_spoolid = gv_pdfspoolid
btc_jobname = gv_jobname
btc_jobcount = gv_jobcount
TABLES
pdf = gi_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.
gv_spoolid_char = gv_spoolid.
CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
EXPORTING
spoolid = gv_spoolid_char.
IF gi_pdf[] IS NOT INITIAL.
gv_k = gv_i = 0.
LOOP AT gi_pdf INTO gs_pdf.
DO 134 TIMES.
gv_j = sy-index - 1.
gi_object_bin+gv_i(1) = gs_pdf+gv_j(1).
gv_i = gv_i + 1.
IF gv_i > 254.
APPEND gi_object_bin.
CLEAR gv_i.
ENDIF.
gv_k = gv_k + 1.
IF gv_k GE gv_numbytes.
IF gv_i NE 0.
APPEND gi_object_bin.
ENDIF.
EXIT.
ENDIF.
ENDDO.
ENDLOOP.
ELSE.
gv_retcode = 1.
syst-msgid = gc_zfrm.
syst-msgno = gc_009.
syst-msgv1 = gc_spool_txt.
syst-msgv2 = gv_spoolid.
syst-msgv3 = ''.
syst-msgv4 = ''.
syst-msgty = gc_e.
PERFORM zc2cr_f_protocol_update.
EXIT.
ENDIF.
* Generate the Attachment
* Packing List(Att)
DESCRIBE TABLE gi_object_bin LINES gv_tab_lines.
READ TABLE gi_object_bin INDEX gv_tab_lines.
gi_object_pack-doc_size = ( gv_tab_lines - 1 ) * 255 + strlen( gi_object_bin ).
gi_object_pack-transf_bin = gc_x.
gi_object_pack-head_start = 1.
gi_object_pack-head_num = 0.
gi_object_pack-body_start = 1.
gi_object_pack-body_num = gv_tab_lines.
gi_object_pack-doc_type = gc_pdf.
gi_object_pack-obj_name = gc_spool.
gi_object_pack-obj_descr = nast-objky.
APPEND gi_object_pack.
Regards,
Durga Prasad.
2013 Sep 20 3:04 PM
Try this..
* Get data into pdf_xstring
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = p_lv_rqident
no_dialog = c_x
pdf_destination = c_x
no_background = c_x
IMPORTING
pdf_bytecount = l_bin_size
bin_file = pdf_xstring
EXCEPTIONS
err_no_otf_spooljob = 1
OTHERS = 2.
*Send mail as attachment..
DATA: send_request TYPE REF TO cl_bcs,
body TYPE bcsy_text,
sender TYPE REF TO if_sender_bcs,
recipient TYPE REF TO if_recipient_bcs,
bcs_exception TYPE REF TO cx_bcs,
subject TYPE so_obj_des,
pdf_size TYPE so_obj_len,
filename TYPE so_obj_des,
binary TYPE solix_tab,
document TYPE REF TO cl_document_bcs.
TRY.
* Creates persistent send request
send_request = cl_bcs=>create_persistent( ).
APPEND 'Body of mail' TO body.
subject = 'Subject of mail'.
document = cl_document_bcs=>create_document(
i_type = 'RAW' "#EC NOTEXT
i_text = body
i_subject = subject ).
* Add attachment
TRY.
binary =
cl_document_bcs=>xstring_to_solix( p_data ).
CALL METHOD g_document->add_attachment
EXPORTING
i_attachment_type = 'PDF'
i_attachment_subject = filename
i_attachment_size = pdf_size
i_att_content_hex = binary.
CATCH cx_bcs.
MESSAGE e445(so).
ENDTRY.
* Add document to send request
CALL METHOD send_request->set_document( document ).
* Get sender object
sender = cl_sapuser_bcs=>create( sy-uname ).
* Add sender
CALL METHOD send_request->set_sender
EXPORTING
sender = sender.
LOOP AT email_address.
recipient = cl_cam_address_bcs=>create_internet_address( email_address-low ).
* Add recipient with its respective attributes to send request
CALL METHOD send_request->add_recipient
EXPORTING
i_recipient = recipient.
ENDLOOP.
* set send immediately flag
send_request->set_send_immediately( c_x ).
* Send document
CALL METHOD send_request->send( ).
COMMIT WORK.
CATCH cx_bcs INTO bcs_exception.
MESSAGE e865(so) WITH bcs_exception->error_type.
ENDTRY.
2024 Feb 26 10:12 AM
Hi can you help me to get data from spool number I tried with several FM's they are not giving all fields, this FM giving data in pdf format but I need in text internal table
2013 Sep 20 10:36 PM
you would need to convert the SPOOL to XSTRING format for pdfs. pdf works correct only with XSTRING.
Thanks,
Krishna Teja Peddada.
2013 Sep 21 4:03 AM
Hi Duragaprasad,
See this help link to send Spool as PDF and mail you can find more example in scn wiki
2013 Sep 24 7:31 AM
Hi All,
I tried all the possible ways to solve the issue in converting the OTF data to PDF format, still i am facing the same issue.
Is there any configration issue or any other alternative to overcome the junk values problem in PDF documents.
Kindly help me in this senario.
Regards,
DurgaPrasad.
2013 Sep 24 1:53 PM
Hi,
Did you try the code that i had given using xstring?? it should work, since am using that and dint see a prob till now..
Thanks
Sam
2013 Oct 01 2:20 PM
Hi Sam,
sorry for the late reply. the issue was solved. It was with the parameter missing the content bin of the attachement function module.