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 file Conversion

Former Member
0 Likes
599

Hello Friends,

In SAP, SOST Transaction, we can see the pdf document of delivery, but when send to the customers by email, the pdf file doesn't open at customer end.SOST sends this

It gives the file conversion error.

What we can do from developer's perspective to solve this ?

Is this a ABAP issue?

Regards

Prashant

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
553
MOVE p_spoolno TO lv_spoolno.

* CONVERT THE SPOOL TO PDF
  CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
    EXPORTING
      src_spoolid                    = lv_spoolno
      no_dialog                      = lc_no_dialog
*     DST_DEVICE                     =
*     PDF_DESTINATION                =
   IMPORTING
     pdf_bytecount                  = lv_bytecount
*     PDF_SPOOLID                    =
*     OTF_PAGECOUNT                  =
*     BTC_JOBNAME                    =
*     BTC_JOBCOUNT                   =
   TABLES
     pdf                            = gt_pdf_output
   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 <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ELSE.
* Transfer the 132-long strings to 255-long strings
    LOOP AT gt_pdf_output INTO wa_pdf_output.
      TRANSLATE wa_pdf_output USING ' ~'.
      CONCATENATE v_buffer wa_pdf_output INTO v_buffer.
      MODIFY gt_pdf_output FROM wa_pdf_output.
      CLEAR wa_pdf_output.
    ENDLOOP.

    • TO CONVERT THE DATA INTO PDF FORMAT ELSE THE PDF FILE*

    • WON'T OPEN & REPORT WOULD GIVE A MESSAGE THAT*

    • THE FILE IS DAMAGED & COULD NOT BE OPENED*

TRANSLATE v_buffer USING '~ '.

    CLEAR : wa_messg_att,
            gt_messg_att.

    DO.
      wa_messg_att = v_buffer.
      APPEND wa_messg_att TO gt_messg_att.
      SHIFT v_buffer LEFT BY 255 PLACES.
      IF v_buffer IS INITIAL.
        EXIT.
      ENDIF.
      CLEAR wa_messg_att.
    ENDDO.
  ENDIF.

Hello Friends,

In SAP, SOST Transaction, we can see the pdf document of delivery, but when send to the customers by email, the pdf file doesn't open at customer end.SOST sends this

It gives the file conversion error.

What we can do from developer's perspective to solve this ?

Is this a ABAP issue?

Regards

Prashant

1 REPLY 1
Read only

Former Member
0 Likes
554
MOVE p_spoolno TO lv_spoolno.

* CONVERT THE SPOOL TO PDF
  CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
    EXPORTING
      src_spoolid                    = lv_spoolno
      no_dialog                      = lc_no_dialog
*     DST_DEVICE                     =
*     PDF_DESTINATION                =
   IMPORTING
     pdf_bytecount                  = lv_bytecount
*     PDF_SPOOLID                    =
*     OTF_PAGECOUNT                  =
*     BTC_JOBNAME                    =
*     BTC_JOBCOUNT                   =
   TABLES
     pdf                            = gt_pdf_output
   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 <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ELSE.
* Transfer the 132-long strings to 255-long strings
    LOOP AT gt_pdf_output INTO wa_pdf_output.
      TRANSLATE wa_pdf_output USING ' ~'.
      CONCATENATE v_buffer wa_pdf_output INTO v_buffer.
      MODIFY gt_pdf_output FROM wa_pdf_output.
      CLEAR wa_pdf_output.
    ENDLOOP.

    • TO CONVERT THE DATA INTO PDF FORMAT ELSE THE PDF FILE*

    • WON'T OPEN & REPORT WOULD GIVE A MESSAGE THAT*

    • THE FILE IS DAMAGED & COULD NOT BE OPENED*

TRANSLATE v_buffer USING '~ '.

    CLEAR : wa_messg_att,
            gt_messg_att.

    DO.
      wa_messg_att = v_buffer.
      APPEND wa_messg_att TO gt_messg_att.
      SHIFT v_buffer LEFT BY 255 PLACES.
      IF v_buffer IS INITIAL.
        EXIT.
      ENDIF.
      CLEAR wa_messg_att.
    ENDDO.
  ENDIF.