Quantcast
Channel: SCN : Discussion List - SAP Interactive Forms by Adobe
Viewing all articles
Browse latest Browse all 1237

Send Adobe form as email attachment

$
0
0

Hello Experts,

 

Recently iu2019m facing a problem regarding Adobe form PDF attachment and sending an e-mail along with the PDF attachment to customer mail id.But when i execute the RFC Function module, in customer side no mail is comming. And when i check the transaction SBWP then i found that the PDF attachment hold only 1KB of data which is not right.For that iu2019m sending my code which i was declared in my program.Can anybody Please help me to overcome this problem?

FORM print_form USING p_disp       TYPE char1

                      drb_mail     TYPE char1

                     p_email LIKE itcpo-tdcovtitle

                     p_email1 LIKE itcpo-tdcovtitle.

  DATA ds_recipient  TYPE   swotobjid.

  CLEAR: dg_funcnam, dg_outputparams.

*--Call generated function module

  CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'

    EXPORTING

      i_name     = c_form

    IMPORTING

      e_funcname = dg_funcnam.

 

 

 

dg_outputparams-nodialog = 'X'.

dg_outputparams-getpdf   = 'X'.

  • Job Open for PDF

CALL FUNCTION 'FPCOMP_JOB_OPEN'

  CHANGING

    ie_outpar      = dg_outputparams

  EXCEPTIONS

    cancel         = 1

    usage_error    = 2

    system_error   = 3

    internal_error = 4

    OTHERS         = 5.

IF sy-subrc <> 0.

  MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno

         WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

  EXIT.

ENDIF.

dg_docparams-langu = 'X'.

dg_docparams-country = 'US'.

dg_docparams-fillable = 'X'.

 

 

form CONVERT_PDF_BINARY .

  CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'

    EXPORTING

      BUFFER                = FP_FORMOUTPUT-PDF

  •   APPEND_TO_TABLE         =  ' '

  • IMPORTING

  •   OUTPUT_LENGTH         =

    TABLES

      BINARY_TAB            = t_att_content_hex .

endform.                    " CONVERT_PDF_BINARY

&----


*&      Form  MAIL_ATTACHMENT

&----


  •       text

----


  • -->  p1        text

  • <--  p2        text

----


form MAIL_ATTACHMENT USING  p_email LIKE itcpo-tdcovtitle

                    p_email1 LIKE itcpo-tdcovtitle.

CLASS cl_bcs DEFINITION LOAD.

  DATA:

  lo_send_request TYPE REF TO cl_bcs VALUE IS INITIAL.

  lo_send_request = cl_bcs=>create_persistent( ).

  • Message body and subject

  DATA:

  lt_message_body TYPE bcsy_text VALUE IS INITIAL,

  lo_document TYPE REF TO cl_document_bcs VALUE IS INITIAL.

  APPEND 'Dear,' TO lt_message_body.

  append ' ' to lt_message_body.

  APPEND 'Please fill the attached form and send it back to us.'

  TO lt_message_body.

  append ' ' to lt_message_body.

  APPEND 'Thank You,' TO lt_message_body.  lo_document = cl_document_bcs=>create_document(

  i_type = 'RAW'

  i_text = lt_message_body

  i_subject = 'Personnel Information Form' ).

  DATA: lx_document_bcs TYPE REF TO cx_document_bcs VALUE IS INITIAL.  TRY.

      lo_document->add_attachment(

      EXPORTING

      i_attachment_type = 'PDF'

      i_attachment_subject = 'Personnel Information Form'

  • I_ATTACHMENT_SIZE =

  • I_ATTACHMENT_LANGUAGE = SPACE

  • I_ATT_CONTENT_TEXT =

  • I_ATTACHMENT_HEADER =

      i_att_content_hex = t_att_content_hex ).

    CATCH cx_document_bcs INTO lx_document_bcs.

  ENDTRY.

  • Add attachment

  • Pass the document to send request

  lo_send_request->set_document( lo_document )."* Create sender

  DATA:

  lo_sender TYPE REF TO if_sender_bcs VALUE IS INITIAL,

  l_send type ADR6-SMTP_ADDR value ' here mail id '.

  • l_send = P_email.

  • l_send = P_email1.

  • lo_sender = cl_cam_address_bcs=>create_internet_address( l_send ).

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

  • Set sender

  lo_send_request->set_sender(

  EXPORTING

  i_sender = lo_sender )." Create recipient

  DATA:

  lo_recipient TYPE REF TO if_recipient_bcs VALUE IS INITIAL.

  • lo_recipient = cl_sapuser_bcs=>create( sy-uname ).

  lo_recipient = cl_cam_address_bcs=>create_internet_address( l_send ).

  • lo_recipient = cl_cam_address_bcs=>create_internet_address( l_send ).

    • Set recipient

  lo_send_request->add_recipient(

  EXPORTING

  i_recipient = lo_recipient

  i_express = 'X' ).

 

 

  • lo_send_request->add_recipient(

  • EXPORTING

  • i_recipient = lo_recipient

  • i_express = 'X' ).* Send email

  DATA: lv_sent_to_all(1) TYPE c VALUE IS INITIAL.

  lo_send_request->send(

  EXPORTING

  i_with_error_screen = 'X'

  RECEIVING

  result = lv_sent_to_all ).

  COMMIT WORK.

  message 'The Personnel Information form has been emailed to the Employee' type 'I'.

 

endform.                    " MAIL_ATTACHMENT

 

*--Call Function module

CALL FUNCTION dg_funcnam

  EXPORTING

    /1bcdwb/docparams  = dg_docparams

    im_logo         = dg_logo

    im_user_address = dt_user_address

    im_ship_to_addr = dt_imp_data

    im_text         = ds_text

    im_sales_text   = dt_sales_text

    im_item_data    = dt_item_data

  IMPORTING

    /1BCDWB/FORMOUTPUT = FP_FORMOUTPUT

 

  EXCEPTIONS

    usage_error     = 1

    system_error    = 2

    internal_error  = 3

    OTHERS          = 4.

IF sy-subrc <> 0.

ENDIF.

 

CALL FUNCTION 'FPCOMP_JOB_CLOSE'

  IMPORTING

    e_jobresult    = l_result

  EXCEPTIONS

    usage_error    = 1

    system_error   = 2

    internal_error = 3

    OTHERS         = 4.

IF sy-subrc <> 0.

  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

  • DATA : dl_msg TYPE string.

  • CONCATENATE 'Successfully mailed to' p_email p_email1 INTO dl_msg SEPARATED BY space.

  • IF drb_mail = 'X'.

  •    COMMIT WORK.

  •    MESSAGE dl_msg TYPE 'I' .

        •    MESSAGE i000 WITH 'Successfully mailed to' p_email1.

  • ENDIF.

ENDFORM.                    "print_form

 

Could you please any body help me, it's very uregent issue.

 

Regards

Sandeep


Viewing all articles
Browse latest Browse all 1237

Trending Articles