Skip to Content

Scenario, you have an interactive form embedded on the ABAP WebDynpro view and want to email a static copy of the form to an internet email address.  This example will start from the beginning and create a WebDynpro application and form.  If you wish to skip the form creation and jump ahead to the emailing, feel free.

Step 1:  Create an Abap WebDynpro application with one main screen and view


Step 2:  Create a Node with two attributes on the COMPONENTCONTROLLER context


Step 3:  Map the Node PDF_CONTENT from the COMPONENTCONTROLLER to the View


Step 4:  Place an InteractiveForm element control on your view


Map the dataSource property of the InteractiveForm element as follows:


Step 5:  Creating the Form Template

In the templateSource property of the InteractiveForm, type a name for the form you wish to create.

For example:


Hit the enter key and you will be prompted to specify the form interface name which needs to be created. Type in a name for the interface and then choose the V_MAIN.PDF_CONTENT context node using the context button. This will create an interface for the form and model the interface the same as the context node which includes the two attributes:


Step 6:  Editing the Form

On the form properties tab, change the Layout Type to ZCI Layout:


Under the Utilities menu, select Insert Web DynPro Script:


Step 7:  Drag the two attributes TEXTLINE1 & TEXTLINE2 to the form


Save & Activate the form

Step 8:  On the WebDynpro View, create two input fields and a submit button


Map the input fields vales to the attributes textline1 and textline2:


In the OnAction event of the submit button, create an action method (no code needed):



Save & Activate

Step 9:  Create an application for the form so you can test that it is working correctly.  The form should load and when text is typed into the two input fields on the WebDynpro, the values should show up in the form after the button has been pressed.


Step 10:  We now have a form embedded within the ABAP WebDynpro application.  Let’s add code to email the form when the user chooses.

Add a button on the ABAP WebDynpro view to allow emailing a static copy of the interactive form.  We will hardcode a recipient email address for now.


Create an action for the button:


Enter the following code for the action on this button:

method onactionemailform .

  class cl_bcs definition load.

  data l_xml type string.
data l_xstring type xstring.
data lo_send_request type ref to cl_bcs value is initial.
data lt_message_body type bcsy_text value is initial.
data lo_document type ref to cl_document_bcs value is initial.
data lo_sender type ref to if_sender_bcs value is initial.
data lo_recipient type ref to if_recipient_bcs value is initial.
data l_recipient type adr6smtp_addr.
data l_function_name type rs38l_fnam.
data l_form_name type fpname value ‘ZADB_FRM_EMAIL_1’. “Name of Form
data fp_docparams type sfpdocparams.
data fp_formoutput type fpformoutput.
data fp_outputparams type sfpoutputparams.
data t_att_content_hex type solix_tab.
data lo_nd_pdf_content type ref to if_wd_context_node.

  lo_nd_pdf_content = wd_context->get_child_node( name = wd_this->wdctx_pdf_content ).
->to_xml( receiving xml = l_xml ).

  replace first occurence of ‘<context>’ in l_xml with space.
shift l_xml left deleting leading space.
replace first occurence of ‘</context>’ in l_xml with space.
shift l_xml right deleting trailing space.

  call function ‘SCMS_STRING_TO_XSTRING’
text   = l_xml
buffer = l_xstring
= 1
others = 2.

  call function ‘FP_FUNCTION_MODULE_NAME’
= l_form_name
= l_function_name.

  fp_outputparamsnodialog = ‘X’.
getpdf   = ‘X’.
connection = ‘ADS’.

  call function ‘FP_JOB_OPEN’
= fp_outputparams.

  fp_docparamslangu = ‘E’.
country = ‘US’.
*  fp_docparams-fillable = ‘X’. “Only Use this is Form is Fillable by receiver.

  call function l_function_name
= fp_docparams
= l_xstring
= fp_formoutput.

  call function ‘FP_JOB_CLOSE’.

  call function ‘SCMS_XSTRING_TO_BINARY’
buffer     = fp_formoutputpdf
= t_att_content_hex.

  lo_send_request = cl_bcs=>create_persistent( ).
= ‘“Hardcoded for now
append ‘Document Attached’ to lt_message_body.
= cl_document_bcs=>create_document( i_type = ‘RAW’ i_text = lt_message_body i_subject = ‘Document Attached’ ).
->add_attachment( exporting i_attachment_type = ‘PDF’ i_attachment_subject = ‘Form’ i_att_content_hex = t_att_content_hex ).
->set_document( lo_document ).
= cl_sapuser_bcs=>create( syuname ).
->set_sender( exporting i_sender = lo_sender ).
= cl_cam_address_bcs=>create_internet_address( l_recipient ).
->add_recipient( exporting i_recipient = lo_recipient i_express = ‘X’ ).
->send( ).
commit work.


Save & Activate

Step 11:  Now test your application.  After entering text values try the Send Email option and then view the email in transaction SOST.

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply