Sie sind auf Seite 1von 4

*&---------------------------------------------------------------------* *& Report ZV_ADOBE_OFFLINE_FORM_PRG *& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* REPORT zv_adobe_offline_form_prg.

PARAMETER : p_addr TYPE adr6-smtp_addr DEFAULT ''. DATA : form TYPE fpwbformname, l_name TYPE funcname. *Find out the name of the generated function module name CALL FUNCTION 'FP_FUNCTION_MODULE_NAME' EXPORTING i_name = 'ZV_ADOBE_OFFLINE_FORM' IMPORTING e_funcname = l_name * E_INTERFACE_TYPE = . DATA : l_output_params TYPE sfpoutputparams. l_output_params-getpdf = 'X'. *Start Form Processing CALL FUNCTION 'FP_JOB_OPEN' CHANGING ie_outputparams = l_output_params EXCEPTIONS cancel = 1 usage_error = 2 system_error = 3 internal_error = 4 OTHERS = 5. 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 : fp_docparams TYPE sfpdocparams, reservedonly TYPE bapisbodat-reserved, booking_data TYPE bapisbonew, fp_result TYPE fpformoutput. fp_docparams-fillable = 'X'. fp_docparams-langu = sy-langu. CALL FUNCTION l_name EXPORTING /1bcdwb/docparams = fp_docparams reserved = reservedonly booking_data = booking_data IMPORTING /1bcdwb/formoutput = fp_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 : pdf TYPE fpformoutput-pdf. pdf = fp_result-pdf.

*End Form Processing CALL FUNCTION 'FP_JOB_CLOSE' * IMPORTING * E_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. *create and send the email. DATA: bcs_exception TYPE REF TO cx_bcs. TRY. *create Email subject and body DATA : l_subject TYPE so_obj_des, l_mailtext TYPE bcsy_text, l_mailtext_row TYPE soli. l_subject = 'Trip Creation Form'. CONCATENATE 'Pleae fill out the form and return it to :' 'mailid' INTO l_mailtext_row. APPEND l_mailtext_row TO l_mailtext. *(2)create the email document object DATA : document TYPE REF TO cl_document_bcs, num_rows TYPE i, textlength TYPE so_obj_len. DESCRIBE TABLE l_mailtext LINES num_rows. num_rows = num_rows * 255. MOVE num_rows TO textlength. document = cl_document_bcs=>create_document( i_type = 'RAW' i_text = l_mailtext i_length = textlength

i_subject = l_subject ). *(3) Add Attachment DATA : attdoctype TYPE soodk-objtp, atttitle TYPE sood-objdes, attsize TYPE sood-objlen, pdftab TYPE solix_tab. attdoctype = 'pdf' . atttitle = 'Create Flight '. attsize = XSTRLEN( pdf ). pdftab = cl_document_bcs=>xstring_to_solix( ip_xstring = pdf ) .

document->add_attachment( EXPORTING i_attachment_type = attdoctype i_attachment_subject = atttitle i_attachment_size = attsize i_attachment_language = sy-langu i_att_content_hex = pdftab ) .

*(4)create persistent send request DATA : send_request TYPE REF TO cl_bcs. send_request = cl_bcs=>create_persistent( ). *Add document to send request send_request->set_document( document ).

*(5)GET THE SENDER AND RECEIPENT ON THE CL_BCS OBJECT *get the sender object * DATA : sender TYPE REF TO cl_sapuser_bcs. * sender = cl_sapuser_bcs=>create( 'SAPATL2' ). **Add sender * CALL METHOD send_request->set_sender * EXPORTING * i_sender = sender. *create receipent DATA : receipent TYPE REF TO if_recipient_bcs. receipent = cl_cam_address_bcs=>create_internet_address( p_addr ). *Add receipent with its respective attributes to send request send_request->add_recipient( EXPORTING i_recipient = receipent ). ********************for second mail receipt receipent = cl_cam_address_bcs=>create_internet_address( 'mailid.com' ). send_request->add_recipient( EXPORTING i_recipient = receipent ). *******************************************************

*SEND THE EMAIL *Set send immediately send_request->set_send_immediately( 'X' ). *send Document send_request->send( ). COMMIT WORK. WRITE : 'Email containing the interactive form was sent'. CATCH cx_bcs INTO bcs_exception. DATA : ex_msg TYPE string. ex_msg = bcs_exception->get_text( ). WRITE : 'Caught Exception.', ex_msg. ENDTRY.

Das könnte Ihnen auch gefallen