on 03-21-2008 10:57 AM
Hi,
I need some help regarding to solve my issue. I need create one application which take single no as input .
Ex lead, Opportunity or Quatation
Output comes in table . Then i convert one by one record into string .
Table data like follows.
Lead_No Lead_Date Business_Type Amount
0000010 29/12/2007 Bus200107 10000
Lead_no$Lead_Date$Business_Type$Amount means is should be like follows...
0000010$29/12/2007$Bus200107$10000
where $ is special indicator or breaker for colums.
Then I pass this string to dyn pro which display records liks follows from string....
0000010
29/12/2007
BUS200107
10000
Regards,
Gurprit Bhatia
Hi,
Make use of String tokenizer
http://java.sun.com/j2se/1.4.2/docs/api/java/util/StringTokenizer.html
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
updating String content into table
StringTokenizer Tokenizer = new StringTokenizer(Table_Content," ");
while(Tokens.hasMoreElements())
{
IPrivateApplicationView.IViewElement Element = wdContext.createApplicationViewElement();
Element.setValue1(Tokenizer.nextToken());
Element.setValue2(Tokenizer.nextToken());
Element.setValueN(Tokenizer.nextToken());
}
simillarly we may do the reverse to get table content into String.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Context
\
no (value attribute )
outstr(value attribute)
\
Table (node )
\lead (value attribute)
quotatio (value attribute)
otherfields (value attributes )
send input ---> no
from FM abap side ........send the table data as String with $ as delimeter for separator as output
In the web dynpro java ,,,,,,use that ouput string .....parse it and create element of Table node and set the values
In web dynpro java ..........use StringTokenizer class to breakup the string
String str=wdContext.currentContextElement().getOutstr();
StringTokenizer st = new StringTokenizer(str,"$");
String s="";
while(st.hasMoreTokens())
{
// create an element
IPrivate<viewname>.I<nodename> Node node = wdContext.node<node>();
IPrivate<viewname>.I<nodename>Element ele= node.create<nodename>Element();
{
s=st.nextToken();
ele.setLead(s);
s=st.nextToken();
ele.setQuotation(s);
s=st.nextToken();
ele.setAAA(s);
-
--
}
}
May be this way u can solve u r problem. Make accordingly the code.
If helpful expectiong points from you.
Thanks ,
Srini
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Srinivas,
My code is like that but it gives error.
My code is like as follows.
public void executeZtest_One_Input( )
{
IWDMessageManager manager = wdComponentAPI.getMessageManager();
try
{
wdContext.currentZtest_One_InputElement().setObject_Type("BUS2000117");
wdContext.currentZtest_One_InputElement().modelObject().execute();
wdContext.nodeOutput().invalidate();
manager.reportSuccess(String.valueOf(wdContext.nodeIt_Head().size()));
manager.reportSuccess(String.valueOf(wdContext.nodeOutput().size()));
for (int i=0 ; i<wdContext.nodeIt_Head().size(); i++)
{
String str = wdContext.nodeIt_Head().getIt_HeadElementAt(i).getZchar();
StringTokenizer st = new StringTokenizer(str,"$");
String s= "";
IPrivateTest_AppView.INode_structNode node = wdContext.nodeNode_struct();
IPrivateTest_AppView.INode_structElement ele = node.createNode_structElement();
while(st.hasMoreTokens())
{
s = st.nextToken();
ele.setID(s);
s = st.nextToken();
ele.setBusiness_Type(s);
s = st.nextToken();
ele.setProcess_Type(s);
s = st.nextToken();
ele.setPosting_Date(java.sql.Date.valueOf(s));
s = st.nextToken();
ele.setDescription(s);
node.addElement(i,(IWDNodeElement)ele);
}
}
}
catch(WDDynamicRFCExecuteException e)
{
manager.reportException(e.getMessage(), false);
}
Regards,
Gurprit Bhatia
Edited by: GURPRIT BHATIA on Mar 24, 2008 12:26 PM
Hi,
Pls can u send me the output for this ...atleast 10 lines if more records you have, so that i will write the parse it
and send you the code ....
for (int i=0 ; i<wdContext.nodeIt_Head().size(); i++)
{
wdComponentAPI.getMessageManager.reportSuccess( wdContext.nodeIt_Head().getIt_HeadElementAt(i).getZchar());
}
We have to take care of null values also and suppose every row (Zchar) should have 3$ symbols it contains only one or two $ symobols....
Thanks,
srini
Hi Gurprit ,
I have taken some sample data and tested .....hope this is useful to you .
Step 1 : I have created the node and elements consisting of data.....
But in your case u will get from backend.
IPrivateClearnodeElements.IOutputNode n1 = wdContext.nodeOutput();
IPrivateClearnodeElements.IOutputElement e1 = n1.createOutputElement();
e1.setOutputStr("111$xyz$abc2$12-7-2008$bolt1");
n1.addElement(e1);
IPrivateClearnodeElements.IOutputNode n2 = wdContext.nodeOutput();
IPrivateClearnodeElements.IOutputElement e2 = n2.createOutputElement();
e2.setOutputStr("112$xyz2$abc2$13-4-2008$bolt2");
n2.addElement(e2);
IPrivateClearnodeElements.IOutputNode n3 = wdContext.nodeOutput();
IPrivateClearnodeElements.IOutputElement e3 = n3.createOutputElement();
e3.setOutputStr("113$xyz3$abc3$13-5-2008$bolt3");
n3.addElement(e3);
IPrivateClearnodeElements.IOutputNode n4 = wdContext.nodeOutput();
IPrivateClearnodeElements.IOutputElement e4 = n4.createOutputElement();
e4.setOutputStr("113$null$null$13-5-2008$bolt3");
n4.addElement(e4);
IPrivateClearnodeElements.IOutputNode n5 = wdContext.nodeOutput();
IPrivateClearnodeElements.IOutputElement e5 = n5.createOutputElement();
e5.setOutputStr("115$xyz5$null");
n5.addElement(e5);
Step 2 : Taking the above elements one by one and parsing them into fields of elements of another node.
public void onActionparseStr(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
//@@begin onActionparseStr(ServerEvent)
for(int i=0;i<wdContext.nodeOutput().size();i++)
{
String s=wdContext.nodeOutput().getOutputElementAt(i).getOutputStr();
StringTokenizer stk = new StringTokenizer(s,"$");
try
{
while(stk.hasMoreTokens())
{
IPrivateClearnodeElements.IParsedNode n = wdContext.nodeParsed();
IPrivateClearnodeElements.IParsedElement e = n.createParsedElement();
try
{
s=stk.nextToken();
e.setID(s);
}
catch(Exception ex)
{
}
try
{
s=stk.nextToken();
e.setProcess_Type(s);
}
catch(Exception ex)
{
}
try
{
s=stk.nextToken();
e.setBusineess_Type(s);
}
catch(Exception ex)
{
}
try
{
s=stk.nextToken();
e.setPostingDate(s);
}
catch(Exception ex)
{
}
try
{
s=stk.nextToken();
e.setDescriptors(s);
}
catch(Exception ex)
{
}
n.addElement(e);
}
} // try for while
catch(Exception ex)
{
} // catch for while
} // for loop ending
//@@end
}
Step 3 : I am printing the elements of the node
public void onActionprintElements(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
//@@begin onActionprintElements(ServerEvent)
for(int i=0;i<wdContext.nodeParsed().size();i++)
{
wdComponentAPI.getMessageManager().reportSuccess("ID : "wdContext.nodeParsed().getParsedElementAt(i).getID()"Process Type : "wdContext.nodeParsed().getParsedElementAt(i).getProcess_Type()"Business type : "wdContext.nodeParsed().getParsedElementAt(i).getBusineess_Type()"Posting Date : "+wdContext.nodeParsed().getParsedElementAt(i).getPostingDate() "Descriptors : "wdContext.nodeParsed().getParsedElementAt(i).getDescriptors());
}
//@@end
}
Hope this will solve your problem.
If you still get errors let me know . Very important thing u have to take care is how your output String is coming from backend system .
Please also send the sample output string data ...........of atleast 5 records which are of some different in look.
Thanks ,
Srini
HI Srinivasa,
My Backend output is like...
$0000000292$BUS2000117$ZSVC$$
$0000000301$BUS2000117$SRVC$$
$0000000311$BUS2000117$SRVC$Trial Order$
$0000000291$BUS2000117$ZSVC$$
$0000000086$BUS2000117$SRVC$serv conf 55 - test hos$
$0000000088$BUS2000117$SRVC$serv conf 10$
$0000000089$BUS2000117$SRVC$$
$0000000091$BUS2000117$SRVC$$
$0000000092$BUS2000117$SRVC$$
$0000000093$BUS2000117$SRVC$$
My frontend gives error like this.....
java.util.NoSuchElementException
at java.util.StringTokenizer.nextToken(StringTokenizer.java:259)
at test_app.Test_AppView.executeZtest_One_Input(Test_AppView.java:175)
Regards,
Gurprit Bhatia
Hi GURPRIT,
Just remove <b>while loop</b> and make sure <b> wdContext.nodeIt_Head().size()</b> is not 0 .
try
{
for (int i=0 ; i<wdContext.nodeIt_Head().size(); i++)
{
String str = wdContext.nodeIt_Head().getIt_HeadElementAt(i).getZchar();
<b>StringTokenizer st = new StringTokenizer(str,"$");
String s= "";
IPrivateTest_AppView.INode_structNode node = wdContext.nodeNode_struct();
IPrivateTest_AppView.INode_structElement ele = node.createNode_structElement();
s = st.nextToken();
ele.setID(s);
s = st.nextToken();
ele.setBusiness_Type(s);
s = st.nextToken();
ele.setProcess_Type(s);
s = st.nextToken();
ele.setPosting_Date(java.sql.Date.valueOf(s));
s = st.nextToken();
ele.setDescription(s); </b>
node.addElement(i,(IWDNodeElement)ele);
}
}
catch (Exception e)
{
}
Regards,
Mithu
Hi,
use try catch .......where ever necessary to avoid ........runtime exceptions
Hi Gurprit,
I think code which I sent you will work .
Try once !
You have sent me the output of backend. With that one my code is working fine. I think only date field you have to take care.
But , also send me the following code :
for (int i=0 ; i<wdContext.nodeIt_Head().size(); i++)
{
wdComponentAPI.getMessageManager.reportSuccess( wdContext.nodeIt_Head().getIt_HeadElementAt(i).getZchar());
}
More better output :
$$ , when parsing in my code it is taking null as string tokenizer ...
so add in every try...catch ..for every token...like this ....
try
{
s=stk.nextToken();
if (s!=null)
e.setID(s);
else
e.setID("");
}
catch(Exception ex)
{
}
See look at my code even if i take two $$ symbols ...(Already given above thread in 3 steps )
// init where u will get from backend
IPrivateClearnodeElements.IOutputNode n1 = wdContext.nodeOutput();
IPrivateClearnodeElements.IOutputElement e1 = n1.createOutputElement();
e1.setOutputStr("111$xyz$abc2$12-7-2008$$");
n1.addElement(e1);
IPrivateClearnodeElements.IOutputNode n2 = wdContext.nodeOutput();
IPrivateClearnodeElements.IOutputElement e2 = n2.createOutputElement();
e2.setOutputStr("112$xyz2$abc2$13-4-2008$$");
n2.addElement(e2);
IPrivateClearnodeElements.IOutputNode n3 = wdContext.nodeOutput();
IPrivateClearnodeElements.IOutputElement e3 = n3.createOutputElement();
e3.setOutputStr("113$xyz3$abc3$13-5-2008$$");
n3.addElement(e3);
IPrivateClearnodeElements.IOutputNode n4 = wdContext.nodeOutput();
IPrivateClearnodeElements.IOutputElement e4 = n4.createOutputElement();
e4.setOutputStr("113$null$null$13-5-2008$bolt3");
n4.addElement(e4);
IPrivateClearnodeElements.IOutputNode n5 = wdContext.nodeOutput();
IPrivateClearnodeElements.IOutputElement e5 = n5.createOutputElement();
e5.setOutputStr("115$xyz5$null");
n5.addElement(e5);
// output i am getting when printing the elements
ID : 111Process Type : xyzBusiness type : abc2Posting Date : 12-7-2008Descriptors : null
ID : 112Process Type : xyz2Business type : abc2Posting Date : 13-4-2008Descriptors : null
ID : 113Process Type : xyz3Business type : abc3Posting Date : 13-5-2008Descriptors : null
ID : 113Process Type : nullBusiness type : nullPosting Date : 13-5-2008Descriptors : bolt3
ID : 115Process Type : xyz5Business type : nullPosting Date : nullDescriptors : null
Thanks ,
Srini
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.