Skip to end of metadata
Go to start of metadata

Back to Sending Mails - Home Page

Applies to:

SAP  Netweaver 7.0 and Higher


This article explains about the Publishing a webservice in R/3, Consuming a Webservice in R/3 and Consuming the same webservice in ADOBE flex.


Company:      Kaar Technologies - SAP Netweaver Application development Consultant
Created on:   Sep 9th 2009
Author(s) Bio:

 Rajkumar Shanmuganathan is a SAP Certified Netweaver Application Consultant worked on various areas like  OO-ABAP,Workflow, Business server pages, ABAP  webdynpro, and Adobe Flex and was involved in SAP implementations for around 4+ years.

Publishing a Webservice in R/3.

Create a RFC enabled Function module that will send Email to the person based on the input parameters.

Check whether your mail is being sent in SOST transaction. Once SAP BASIS Team configures mail connections in SCOT transaction, all the mails in the Queue will be sent to the external



Source code for the Function module are as follows:

*"*"Local Interface:

* CLASS-DEFINITIONS                                                    *

* INTERNAL TABLES                                                      *

* Create persistent send request

* Move the Subject from string to BCS subject type

* Move the message from string to internal table
          TEXT      = MESSAGE

* Create the Document
                          I_TYPE    = 'RAW'
                          I_TEXT    = L_MAILTEXT
                          I_SUBJECT = L_SUBJECT ).

* Add document to send request

* Get sender object
      L_SENDER = FROM.

* Add sender
          I_SENDER = SENDER.

* Get Recipient Object


* Add recipient with its respective attributes to send request

* Set that you don't need a Return Status E-mail
          I_REQUESTED_STATUS = 'E'
          I_STATUS_MAIL      = 'E'.

* set send immediately flag

* Send document


      IF SY-SUBRC EQ 0.
        RETURN = 'Message Sent Successfully'.
        RETURN = 'Error in Sending Email'.
*      data: l_message type string.
*      l_message = bcs_exception->GET_TEXT( ).


Now this Function module has to be published as a Webservice.

Once you complete the above steps, go to transaction soamanager** and check whether your webservice is available.

Click the tab Application and Scenario communication and click the hyperlink Single service Administration.

Click Apply selection.

 Click Show WSDL options and change the settings as below,

Click the hyperlink Open WSDL document for selected bindings to see the generated WSDL file.


Consuming webservice in R/3.


First of all we need to check whether the above published webservice can be consumed inside R/3. That makes easy to integrate with other technologies such as Flex, .net...etc

Create a client Proxy.

Enter the URL that was generated from SOAMANAGER Transaction.

Once you complete the above steps, activate the generated proxy class.

Create a logical port for the generated proxy class in order to consume the Webservice in the transaction LPCONFIG.

Provide the URL of the WSDL location in the call parameters tab.

 Creating a simple Report to check the consumption of webservice:

The above report will have the following code.


           ZTO       TYPE STRING,



ZINPUT-TO         = ZTO.


        INPUT  = ZINPUT



  WRITE: 'Message Sent successfully'.


Check whether your mail is being sent in SOST transaction as before. Once SAP BASIS Team configures mail connections in SCOT transaction, all the mails in the Queue will be transferred to the external world.

The above step confirms that Webservice is successfully consumed inside R/3.

Consuming Webservice in ADOBE Flex.

Create a Flex Project in the Flex Builder 3.0.

Click Data in the menu path and select import WSDL,

Paste the WSDL link generated from SAP,



Once you import the WSDL file successfully package will be created in your Flex project.


Just create a simple Design that takes the input from the flex and processes the same with webservice.


Parameter is returned from SAP.


Add the following code in the Source Tab.

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="" layout="absolute">



import mx.controls.Alert;

import com.kaartechsap.;;

var zservice:Service=new Service();

public function sendmail():void



<mx:Canvas x="140" y="49" width="308" height="351" borderColor="#090A0B" backgroundColor="#DAEFF2">

<mx:Form x="21.5" y="50" width="265" height="291" backgroundColor="#C6C4B8">

<mx:FormItem label="From" >

<mx:TextInput id="zFrom"/>


<mx:FormItem label="To" >

<mx:TextInput id="zTo"/>


<mx:FormItem label="Subject" >

<mx:TextInput id="zSubject"/>


<mx:FormItem label="Message" >

<mx:TextInput id="zMessage" height="112"/>


<mx:Button label="Send" click="sendmail()"/>


<mx:Label x="30" y="24" text="Send Email From Flex Application" width="256.5" fontWeight="bold" fontSize="13"/>



There will be a delay in getting the response, so set busy cursor in Flex code. With the above code I have to click the button twice to get the response.

Check in the SOST transaction in SAP you will get the mails in Queue.

Related Content

Please include at least three references to SDN documents or web pages.;jsessionid=(J2EE3417800)ID1031504650DB01409508375869655617End?blog=/pub/wlg/1645