Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

inserting and displaying records to db table using web service

Hi all,

i hv created a web service that has two methods :

public supportClass InsertRec(string, string, date)

and

public supportClass ViewRec()

I m using the WSDL to ctreate a Model and mapped The Request Nodes to the controller and then to the view...

In the context of the controlleri have created a new NOde TESTINGNODE with the value attributes of type String ,String and Date.

my view has a form from which i shud be able to insert records into the table on click of INSERT and retrieve the records on click of SHOW.

so i have bound the input fields to the attr of tresting node , as the attr that i get from web service model are of Calendar type..

And created a table by binding it to the TESTINGNODE.

now to insert and retrieve records i have set the values that i get from my form to the input parameters of REQUEST_MY_WS_insertRecords..

Similarly i have retieve the records of Result_VIEW and set that to testing node..

MY PROBLEM IS I AM NOT ABLE TO INSERT AND RETRIEVE RECORDS

i have written the follwing code..

  public void ExecuteInsert( )
  {
    //@@begin ExecuteInsert()
    
	Request_CHECH_DATE_WSViDocument_insertRecords obj = null;
	//Response_CHECH_DATE_WSViDocument_insertRecords objResp = null;
	
    IPublicDATE_CUST.ITestingNodeNode node = wdContext.nodeTestingNode();
    IPublicDATE_CUST.ITestingNodeElement elem = null;
	
    
	//wdComponentAPI.getMessageManager().reportWarning(String.valueOf(node.size()));
    
   try {
		 
				 obj = new Request_CHECH_DATE_WSViDocument_insertRecords();
		    	elem= node.currentTestingNodeElement();
		    	
				Date start = elem.getStartDate();
				Date end = elem.getEndDate();
				
				Calendar startthis = Calendar.getInstance();
				Calendar endthis = Calendar.getInstance();
			
				SimpleDateFormat inputFormat = new SimpleDateFormat("yyyyMMddHHmmss");
				SimpleDateFormat timeFormatStored = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			
				String temp = start.toString();
				String temp2 = start.toString();
			
				
					startthis.setTime(inputFormat.parse(temp));
					endthis.setTime(inputFormat.parse(temp2));
					
				 obj.setTitle(elem.getTitle());
				 obj.setStatus(elem.getStatus());
				 obj.setStDt(startthis);
				 obj.setEndDt(endthis);
				
			wdContext.currentRequest_CHECH_DATE_WSViDocument_insertRecordsElement().modelObject().execute();    	
		 
	} catch (Exception e) {
		// TODO Auto-generated catch block
		wdComponentAPI.getMessageManager().reportWarning("ERROR : " + e.getLocalizedMessage());
	}
	
	//wdComponentAPI.getMessageManager().reportWarning(obj.getTitle());
    
    wdContext.nodeTestingNode().invalidate();
    
    //@@end
  }

  //@@begin javadoc:ExecuteView()
  /** Declared method. */
  //@@end
  public void ExecuteView( )
  {
    //@@begin ExecuteView()
    
    try {
		
		
		Request_CHECH_DATE_WSViDocument_viewRecords obj = new Request_CHECH_DATE_WSViDocument_viewRecords();
		
		HelperClass[] help = obj.getResponse().getResultAsArray();
		List arr = obj.getResponse().getResult();
		
		for(int i = 0;i<=arr.size();i++)
		{
			IPublicDATE_CUST.ITestingNodeElement elem = wdContext.createTestingNodeElement();
			
			Calendar st = Calendar.getInstance();
			st = help<i>.getStDate();
			java.util.Date dt = st.getTime();
			long theTime = dt.getTime();
			Date start = new Date(theTime);
			
			Calendar endC = Calendar.getInstance();
			st = help<i>.getEndDate();
			java.util.Date dt1 = endC.getTime();
			long theTime1 = dt1.getTime();
			Date end = new Date(theTime1);
			
			elem.setTitle(help<i>.getTitle());
			elem.setStatus(help<i>.getStatus());
			elem.setStartDate(start);
			elem.setEndDate(end);
			
		}
		
		wdContext.currentRequest_CHECH_DATE_WSViDocument_viewRecordsElement().modelObject().execute();
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
    
    //@@end
  }

PLZ help me to solve this problem ..

THANKS AND REGARDS,

Ankita

Former Member
Not what you were looking for? View more on this topic or Ask a question