cancel
Showing results for 
Search instead for 
Did you mean: 

Java Script is not working while sending the Adobe form as an attachment from SAP

Former Member
0 Kudos

Hi Frn's,

I have designed a From in SFP with having some java script to launch URL as well as i put some java script for messgae pop up. When i am trying to preview

Form in SFP as PDF . All java script is working fine.

Now when i send this form from SAP using CL_Document_BCS class as an attachment, script is not working on opening the attached form. I check the downloaded from ADLC and found that there is no script inside the downloaded form .

Now i am not able understand where this script lost during the mail send.Please help to resolve the issue.

Below is the code used by me in the prgoram.

CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'
    EXPORTING
      i_name     = l_formname
    IMPORTING
      e_funcname = l_fm_name.
*   E_INTERFACE_TYPE           =

  fp_outputparams-nodialog = 'X'.
  fp_outputparams-getpdf   = 'X'.

  CALL FUNCTION 'FP_JOB_OPEN'
    CHANGING
      ie_outputparams = fp_outputparams
    EXCEPTIONS
      cancel          = 1
      usage_error     = 2
      system_error    = 3
      internal_error  = 4
      OTHERS          = 5.
  IF sy-subrc <> 0.
    CASE sy-subrc.
      WHEN OTHERS.
    ENDCASE.                           " CASE sy-subrc
  ENDIF.

  fp_docparams-langu = 'X'.
  fp_docparams-country = 'US'.
  fp_docparams-fillable = 'X'.

  CALL FUNCTION l_fm_name
    EXPORTING
      /1bcdwb/docparams  = fp_docparams
      emp_info           = fs_per_info
    IMPORTING
      /1BCDWB/FORMOUTPUT = FP_FORMOUTPUT
    EXCEPTIONS
      usage_error        = 1
      system_error       = 2
      internal_error     = 3
      OTHERS             = 4.

  IF sy-subrc <> 0.
    CASE sy-subrc.
      WHEN OTHERS.
    ENDCASE.                           " CASE sy-subrc
  ENDIF.                               " IF sy-subrc <> 0

  CALL FUNCTION 'FP_JOB_CLOSE'
*   IMPORTING
*     E_RESULT             = result
   EXCEPTIONS
     usage_error          = 1
     system_error         = 2
     internal_error       = 3
     OTHERS               = 4
             .
  IF sy-subrc <> 0.
    CASE sy-subrc.
      WHEN OTHERS.
    ENDCASE.                           " CASE sy-subrc
  ENDIF.                               " IF sy-subrc <> 0.
ENDFORM.                    " GET_FUNCTION_MODULE
*&---------------------------------------------------------------------*
*&      Form  CONVERT_PDF_BINARY
*&---------------------------------------------------------------------
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
*&---------------------------------------------------------------------
FORM MAIL_ATTACHMENT .
  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 'phani.marepalli@yash.com'.
*  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 ).
** 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

Thanks and Regards.

Priyank Dixit

Accepted Solutions (1)

Accepted Solutions (1)

former_member614096
Discoverer
0 Kudos

If you want to run script, you should have the "dynamic" form parameter set to true. I.e:

fp_docparams-dynamic = 'X'.

Former Member
0 Kudos

Thanks Jason ...it working now .

Answers (1)

Answers (1)

ChrisSolomon
Active Contributor
0 Kudos

Is the form set as an "Interactive" form and also have ReaderRights been installed correctly to allow it to be interactive in the user's Reader?

Former Member
0 Kudos

Hi Christopher,

Thanks for you quick response, this is a non-interactive form . and i just want to launch a url or Messgae pop up using Script.

Still you feel that i need to set the form set as an "Interactive" form and also have ReaderRights been installed correctly to allow it to be interactive in the user's Reader.

Then Please suggest. But this this totally a non-interactive form.

Waiting for you Response.

Thanks and Regards.

Priyank Dixit