Application Development 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: 

Convert SF into PDF And Attache to FB02

navin_khedikar2
Contributor
0 Kudos
763

Hi All,

Help required on two scenarios:

  1. I want to convert a smartform into PDF and attache that PDF to the same FB02 (accounting document). Converting SF to PDF not big deal, help required for attachment coding.
  2. How to fetch (get the attached document) from FB02 and send mail with that attached document?

-Navin Khedikar

5 REPLIES 5

kumar_sp
Explorer
0 Kudos
344

Hi navin,

Execute SF after that you can enter TCODE: PDF! in Command prompt. it will be convert PDF Format.

if you need more information you can go thourgh below link

  http://scn.sap.com/thread/830969

Regards,

Kumar

raymond_giuseppi
Active Contributor
0 Kudos
344

Which step were you unable to find, there are already some samples at scn on how-to do this.

Try to search for attach document FB03 or send mail with gos attachment


Regards,

Raymond

0 Kudos
344

Thanks Raymond,

please check below code, and let me know what is wrong:

data :   it_lines         TYPE STANDARD TABLE OF tline WITH HEADER LINE,

  DATA : lv_buffer  TYPE string,

         lv_buffer2 TYPE string,

         lv_buffer1 TYPE xstring,

i_content TYPE sbdst_content.

l_hstring(1022) TYPE x.

  l_cstring(255) TYPE c.

   DATA: i_component TYPE sbdst_components

DATA: objkey TYPE sbdst_object_key..

  DATA: i_signature TYPE sbdst_signature.

  CALL FUNCTION 'CONVERT_OTF_2_PDF'

      IMPORTING

        bin_filesize           = lv_bin_filesize

      TABLES

        otf                    = ls_job_output_info-otfdata

        doctab_archive         = it_docs

        lines                  = it_lines

      EXCEPTIONS

        err_conv_not_possible  = 1

        err_otf_mc_noendmarker = 2

        OTHERS                 = 3.

    LOOP AT it_lines.

      TRANSLATE it_lines USING '~'.

      CONCATENATE lv_buffer it_lines INTO lv_buffer.

    ENDLOOP.

    TRANSLATE lv_buffer USING '~'.

  CALL FUNCTION 'SCMS_STRING_TO_XSTRING'

    EXPORTING

      text   = lv_buffer

    IMPORTING

      buffer = lv_buffer1

    EXCEPTIONS

      failed = 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.

  lv_buffer2 = lv_buffer1.

  DO.

    l_hstring = lv_buffer2.

    MOVE l_hstring TO w_content-line.

    APPEND w_content TO i_content.

    SHIFT lv_buffer2 LEFT BY 255 PLACES.

    IF lv_buffer2 IS INITIAL.

      EXIT.

    ENDIF.

  ENDDO.

  l_classname = 'BKPF'.

  CONCATENATE i_bukrs i_belnr i_gjahr INTO objkey.

  w_component-doc_count  = 1.

  w_component-comp_count = 1.

  w_component-comp_id    = objkey.

  w_component-comp_size  = lt_objpack-doc_size.

  SELECT SINGLE mimetype

    FROM toadd

    INTO w_component-mimetype

   WHERE doc_type = 'PDF'.

  APPEND w_component TO i_component.

  w_signature-doc_count  = 1.

  w_signature-doc_id     = 'MESSAGE' .

  w_signature-doc_ver_no = 2.

  w_signature-comp_count = 1.

  w_signature-prop_name  = 'DESCRIPTION'.

  w_signature-prop_value = objkey.

  APPEND w_signature TO i_signature.

  CALL METHOD cl_bds_document_set=>create_with_table

    EXPORTING

      classname       = l_classname

      classtype       = 'BO'

      client          = sy-mandt

      components      = i_component

      content         = i_content

    CHANGING

      object_key      = objkey

      signature       = i_signature

    EXCEPTIONS

      internal_error  = 1

      error_kpro      = 2

      parameter_error = 3

      not_authorized  = 4

      not_allowed     = 5

      nothing_found   = 6

      OTHERS          = 7.

  IF sy-subrc = 0.

    COMMIT WORK AND WAIT.

  ENDIF.

The issue is that , after this code i am able to find the attachment in FB03 as a pdf, but the attachment not open in PDF.

I've tried with CALL FUNCTION 'SO_ATTACHMENT_INSERT' and FM 'BINARY_RELATION_CREATE_COMMIT' but didn't get the attachment.

Please help ...

-Navin

0 Kudos
344

Hi Navin , have u done this ??/ I need process how u convert OTF to Binary to attach to FB02/FB03 ????

please suggest the conversions of OTF !!!!!

FredericGirod
Active Contributor
0 Kudos
344

Post a new question

Check program RSTXPDFT4