Skip to Content

Flex Development with QUERY_VIEW_DATA

Hi, has anyone developed any applications with Flex using the QUERY_VIEW_DATA XML Output? If so any chance you might pass it on so I can use for testing?

Thanks, Ken Murray

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Nov 08, 2007 at 02:05 AM

    Yup, I've done this before the source is posted below. There are no comments and the code is geared to a query that you don't have on your system but, it should give you a good idea of how to do it.

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
    	layout="absolute" width="454" 
    	creationComplete="onCreationComplete()" height="275">
    	<mx:Script>
    		<![CDATA[
    			import mx.rpc.soap.LoadEvent;
    			import mx.rpc.AbstractOperation;
    			import mx.controls.advancedDataGridClasses.AdvancedDataGridColumn;
    			import mx.rpc.events.HeaderEvent;
    			import mx.controls.dataGridClasses.DataGridColumn;
    			import mx.utils.ArrayUtil;
    			import mx.utils.XMLUtil;
    			[Bindable]public var wsdlName:String = "http://localhost:8000/sap/bc/srt/rfc/sap/query_view_data?sap-client=001&wsdl"; 
    
    			[Bindable]public var queryData:XMLList;
    			import mx.rpc.events.FaultEvent;
    			import mx.rpc.events.ResultEvent;
    			private var queryViewDataService:WidgetWebService;
    			public function onCreationComplete():void{
    				queryViewDataService = new WidgetWebService();
    				queryViewDataService.wsdl = wsdlName;
    				queryViewDataService.addEventListener(LoadEvent.LOAD, loadListener);
    				queryViewDataService.addEventListener(ResultEvent.RESULT, resultTrigger);
    				queryViewDataService.addEventListener(FaultEvent.FAULT,fault);
    				queryViewDataService.loadWSDL();
    			}
    
    			public function loadListener(event:LoadEvent):void{
    				var op:AbstractOperation = queryViewDataService.getOperation("GetQueryViewData");
    				var input:Object = new Object();
    				input.ViewId = confXML.viewName;
    				op.arguments = input;
    				op.send();
    			}
    			public function resultTrigger(event:ResultEvent):void{
     				var output:XML;
     				var columnHeaders:Array;
     				var column:AdvancedDataGridColumn;
     				var response:XMLList;
     				var axisData:XMLList;
     				var axisInfo:XMLList;
     				var yAxis:XMLList;
     				var xAxis:XMLList;
    				var _string:String;
    				var item:XML;
    				namespace soapenv = "http://schemas.xmlsoap.org/soap/envelope/";
    				namespace n0 = "urn:sap-com:document:sap:soap:functions:mc-style";
     				_string = event.message.body.toString();
     				var regex:RegExp = new RegExp("soap-env", "g");
     				_string =_string.replace(regex, "soapenv");
     				output = new XML(_string);
     				use namespace soapenv;
     				response = output.Body;
     				use namespace n0;
     				response = response.GetQueryViewDataResponse;
     				var numHeaderRows:int;
     				var numRows:int;
     				var leadCols:int;
     				var numCols:int;
      				var row:XML;
      				var name:String;
      				var value:String;
      				var tempIndex:int;
      				
            		row = <row></row>;
      				axisData = response.AxisData.item;
     				axisInfo = response.AxisInfo.item; 				
     				numHeaderRows = axisInfo.(Axis == "000").Nchars;
     				numRows = axisInfo.(Axis == "001").Ncoords;
     				leadCols = axisInfo.(Axis == "001").Nchars;
     				numCols = axisInfo.(Axis == "000").Ncoords;
     				numCols = numCols + leadCols;
     				numRows = numRows + numHeaderRows;
      				columnHeaders = new Array();
      				queryData = new XMLList();
      				var rowNum:int;
      				var colNum:int;
     				for(rowNum = 0;rowNum < numRows; rowNum++){
    	         		row = <row></row>;
    	         		name = value = "";
     					for(colNum = 0; colNum < numCols; colNum++){
     						if (rowNum < numHeaderRows && colNum < leadCols){
     							column = new AdvancedDataGridColumn();
     							column.headerText = axisInfo.(Axis == "001").Chars.item[colNum].Caption;
     							column.dataField =axisInfo.(Axis == "001").Chars.item[colNum].Chanm;
     							columnHeaders.push(column);
     						}
     						if (rowNum < numHeaderRows && colNum >= leadCols){
     							column = new AdvancedDataGridColumn();
     							column.headerText = axisData.(Axis == "000").Set.item[colNum - leadCols].Caption;
     							column.dataField = axisData.(Axis == "000").Set.item[colNum - leadCols].Chavl; 							
     							columnHeaders.push(column);
     						}
     						if (rowNum >= numHeaderRows){
     							if (colNum < leadCols){
     								tempIndex = (( rowNum - numHeaderRows ) * (leadCols)) + (colNum);
     								value = axisData.(Axis == "001").Set.item[tempIndex].Caption;
     								name = axisData.(Axis == "001").Set.item[tempIndex].Chanm;
     							}
     							else{
     								tempIndex = (( rowNum - numHeaderRows ) * (numCols - leadCols)) + (colNum - leadCols);
     								value = response.CellData.item[tempIndex].FormattedValue;
     								name = AdvancedDataGridColumn(columnHeaders[colNum]).dataField; 									
     							}
     							row.appendChild(<{name}>{value}</{name}>);
     						}
     					}
     					if (row != <row></row>)
     						queryData += row;
     				}
     						
    				dataGrid.columns = columnHeaders;
    			}
    
    			public function fault(event:FaultEvent):void{
    				var i:Number;
    				i = 0;
    			}
    		
    	
    	
     
      
    		.scrollBar{
    			background-alpha: 1.0;
    		}
    	
     
    	
     
    	
     
    
     
    
      
     
    
     
    ]]>

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 16, 2007 at 11:32 PM

    Hi daniel, I', testing your great post. An issue I found is that Flex 3 Builder says "WidgetWebService not found during compilation".

    Please could you check it?

    Thanks a lot

    Luca

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 19, 2007 at 10:44 PM

    Hi Raja,

    many thanks for the suggestion. Now it works well.

    thx

    Luca

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.