Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

how to put the return data from webservice to a text field

jayakumarkb_81
Participant
0 Kudos

Dear All ,

I created a function module for calculating the square of the input given and created a webservice using the create webservice option available for function modules.

function module:-

FUNCTION ZJK_FLEX_TEST.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(DATA) TYPE  ZSLNO OPTIONAL
*"  EXPORTING
*"     VALUE(DATA1) TYPE  ZSLNO
*"  TABLES
*"      IT_DAT STRUCTURE  ZWBSER OPTIONAL
*"----------------------------------------------------------------------
 data: wa_dat LIKE LINE OF it_dat.
data1 = DATA * data.
wa_dat-results =  data * data .
APPEND wa_dat TO it_dat.
ENDFUNCTION.

and i passed the it_dat in table fields and data1 in the export paramenters of FM.

but in the flex i am not getting the table values. but i am able to get the data1 value. but the problem is . I am getting it as an XML format.

<s0:ZJK_FLEX_TEST.Response xmlns:s0="urn:sap-com:document:sap:rfc:functions" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
  <DATA1>0000025</DATA1>
</s0:ZJK_FLEX_TEST.Response>

so how to set the value of data1 to my text field in the flex .

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi jay,

Refer the code snippets below.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
	
	<mx:Script>
		<![CDATA[
			import mx.rpc.events.ResultEvent;
			import mx.rpc.events.FaultEvent;
			import mx.controls.Alert;
			 
			public function fault_getAll(event:FaultEvent):void
			{
				Alert.show(event.fault.faultString);
			} 
			 
			public function result_getAll(event:ResultEvent):void
			{ 
				Alert.show("Message :  " + ws.BAPI_FLIGHT_GETLIST.lastResult.RETURN..MESSAGE.toString());
			 
			}
			 
			 
			public function Test():void
			{
				ws.BAPI_FLIGHT_GETLIST.send();
			}
		 
		 
		
	
	 
	
	 
	
		
		
				
					
						LH
						
						
						10
						
							
								I
								GT
								20000101
								
							
						
						
						
						
						
					
				
		 
	 
	
	
	
		
			
			
			
			 
		
	
	

]]>

Here it's showing the one of the way to fetch data from internal tables of export parameter, also to fetch simple string export parameter.

Hope this will help you.

Regards,

Vivek

4 REPLIES 4

Former Member
0 Kudos

Hi jay,

Refer the code snippets below.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
	
	<mx:Script>
		<![CDATA[
			import mx.rpc.events.ResultEvent;
			import mx.rpc.events.FaultEvent;
			import mx.controls.Alert;
			 
			public function fault_getAll(event:FaultEvent):void
			{
				Alert.show(event.fault.faultString);
			} 
			 
			public function result_getAll(event:ResultEvent):void
			{ 
				Alert.show("Message :  " + ws.BAPI_FLIGHT_GETLIST.lastResult.RETURN..MESSAGE.toString());
			 
			}
			 
			 
			public function Test():void
			{
				ws.BAPI_FLIGHT_GETLIST.send();
			}
		 
		 
		
	
	 
	
	 
	
		
		
				
					
						LH
						
						
						10
						
							
								I
								GT
								20000101
								
							
						
						
						
						
						
					
				
		 
	 
	
	
	
		
			
			
			
			 
		
	
	

]]>

Here it's showing the one of the way to fetch data from internal tables of export parameter, also to fetch simple string export parameter.

Hope this will help you.

Regards,

Vivek

0 Kudos

same effect.

i think the resultFormat="e4x" in the <mx:operation has to be changed.

0 Kudos

Hi Jay,

resultFormat="e4x" will give you resultset in XMLListCollection otherwise resultset will be an ArrayCollection.

For your example try with this statement after web service result:

txtInput.text = ws.ZJK_FLEX_TEST.lastResult.DATA1.toString();

where ws is id for web srvc and txtinput is a simple textInput control UI.

I hope this will solve your query.

Regards,

Vivek

0 Kudos

HI

i got the answer.

public function result_getAll(event:ResultEvent):void

{

myTextField.text = event.result.DATA1.toString();

}

thanks every body.