on 07-02-2009 6:48 AM
HI,
I have 2 structures in RFC.There is one common column by name"ID " for comparing data between 2 strutures.In fist strucutre
ID column i have uniques ids but in second structureID column i have muitiple ids with same id .
(Ex: fist strucute ID:1 && second Struture ID:1,1)
When i am comparing these two structures i am getting only one record from second strucutres but i have 2 same ids in second strucutre.I need to populate 2 records in a table.
Structure s1, s2
Table node tablenode
for( loop s1){
IPrivateXXXXview.itablenode nodeElement = wdContext.createTablenodeElement();
wdContext.node.addElement(nodeElement);
nodeElement.setAtr1(s1.getattr1());
nodeElement.setAtr2(s1.getattr2());
...
..
nodeElement.setAtr6(s1.getattr6());
for(loop s2){
if(s1.id == s2.id){
nodeElement.setAtr3(s2.getattr1());
nodeElement.setAtr4(s2.getattr2());
...
..
nodeElement.setAtr6(s2.getattr6());
}
}
}
Regards,
Prasad
Hi,
Actually, the first element was replaced by the second one because you are creating only element in each iteration of for loop 1.
Tell me your requirement clearly. How the result should be?
Are you expecting the results like this:
Structure 1:
1 A X
2 B Y
3 C Z
Structure 2:
1 M
1 N
2 O
3 P
Results:
1 A X M
1 A X N
2 B Y O
3 C Z P
If so, try changing your loops.
First loop for s1 and for loop for s2 should be inside s1. some thing like this:
for( loop s2){
IPrivateXXXXview.itablenode nodeElement = wdContext.createTablenodeElement();
wdContext.node.addElement(nodeElement);
for(loop s2){
nodeElement.setAtr3(s2.getattr1());
nodeElement.setAtr4(s2.getattr2());
.......
........
if(s1.id == s2.id){
nodeElement.setAtr1(s1.getattr1());
nodeElement.setAtr2(s1.getattr2());
...
..
nodeElement.setAtr6(s1.getattr6());
}
}
}
Regards,
Jaya.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Prasad,
Try this:
IPatientsElement patientele = null;
ICareHomesReassessmentElement carehomesele = null;
IArticlesElement article = null;
for(int i=0;i<wdContext.nodePatients().size();i++)
{
patientele = wdContext.nodePatients().getPatientsElementAt(i);
carehomesele = wdContext.nodeCareHomesReassessment().createCareHomesReassessmentElement();
wdContext.nodeCareHomesReassessment().addElement(carehomesele);
carehomesele.setPatientID(patientele.getKunn2());
carehomesele.setPatientName(patientele.getName1());
carehomesele.setStatus(patientele.getPtstat());
carehomesele.setDateofBirth(patientele.getBirdt());
carehomesele.setAssesstodate(patientele.getAsmtdt());
carehomesele.setNextAssesstDT(patientele.getNasdt());
carehomesele.setPatientkunnr(patientele.getKunnr());
carehomesele.setPatiennameID(patientele.getName1()+"-"+Long.valueOf(patientele.getKunnr()));
boolean secondRecord = false;
for(int j=0;j<wdContext.nodeArticles().size();j++)
{
article = wdContext.nodeArticles().getArticlesElementAt(j);
if(patientele.getKunnr().trim().equalsIgnoreCase(article.getKunwe().trim()))
{
if(!secondRecord)
{
carehomesele.setProduct(article.getMatnr());
carehomesele.setProductDiscription(article.getArktx());
carehomesele.setAssPadsPD(article.getAsppd());
carehomesele.setActualPPD(article.getAcppd());
carehomesele.setNextDD(article.getZznextdlvy());
carehomesele.setFrequency(article.getDelfr());
secondRecord = true;
}// end of secondRecord if
else
{
// If this is second time then add only the fields present in structure 2.
ICareHomesReassessmentElement carehomesele2 = null;
carehomesele2 = wdContext.nodeCareHomesReassessment().createCareHomesReassessmentElement();
wdContext.nodeCareHomesReassessment().addElement(carehomesele2);
carehomesele.setProduct(article.getMatnr());
carehomesele.setProductDiscription(article.getArktx());
carehomesele.setAssPadsPD(article.getAsppd());
carehomesele.setActualPPD(article.getAcppd());
carehomesele.setNextDD(article.getZznextdlvy());
carehomesele.setFrequency(article.getDelfr());
}
}
Hope this helps!
Regards,
Jaya.
Hi Prasad,
Small correction in my code...
else
{
// If this is second time then add only the fields present in structure 2.
ICareHomesReassessmentElement carehomesele2 = null;
carehomesele2 = wdContext.nodeCareHomesReassessment().createCareHomesReassessmentElement();
wdContext.nodeCareHomesReassessment().addElement(carehomesele2);
carehomesele2.setProduct(article.getMatnr()); //Changed carehomesele to carehomesele2
carehomesele2.setProductDiscription(article.getArktx());//Changed carehomesele to carehomesele2
carehomesele2.setAssPadsPD(article.getAsppd()); //Changed carehomesele to carehomesele2
carehomesele2.setActualPPD(article.getAcppd());//Changed carehomesele to carehomesele2
carehomesele2.setNextDD(article.getZznextdlvy());//Changed carehomesele to carehomesele2
carehomesele2.setFrequency(article.getDelfr());//Changed carehomesele to carehomesele2
}
Copy paste problem :).
Hope this will work.
Regards,
Jaya.
HI VJR,
thanks a lot, Its working but the second record populating in another row but i need to populate same row .
Can youplease give me idea on this issue.
output:
Result
ID
1 X O M
-
N
-
2 A B
3 D C
I need in these format is it possible.
ID
1 X O M
N
-
2 A B
-
3 D C
N sohuld come under M row and Mcolumn
Regards
Prasad
Edited by: prasad kamina on Jul 2, 2009 9:29 AM
Hi Prasad,
If you want it in the same row then you have to manipulate the results like this:
Retain your earlier code asusual (with out using boolean attribute and all) and take string attribute which represents that column and append the values.
for loop 1
{
String thirdcolumn = "";
for loop 2
{
if(<condition to compare id>)
{
thirdcolumn = thirdcolumn + "\\n" + <value from structure 2>;
}
}//end of loop 2
//add thirdcolumn after the for loop.
nodeele.setThirdColumn(thirdcolumn); //Sample code
}
Regards,
Jaya.
Edited by: VJR on Jul 2, 2009 1:18 PM
Hi Prasad,
I am not sure whether the text view will show the values in two rows or not.
Try this:
IPatientsElement patientele = null;
ICareHomesReassessmentElement carehomesele = null;
IArticlesElement article = null;
for(int i=0;i<wdContext.nodePatients().size();i++)
{
patientele = wdContext.nodePatients().getPatientsElementAt(i);
carehomesele = wdContext.nodeCareHomesReassessment().createCareHomesReassessmentElement();
wdContext.nodeCareHomesReassessment().addElement(carehomesele);
carehomesele.setPatientID(patientele.getKunn2());
carehomesele.setPatientName(patientele.getName1());
carehomesele.setStatus(patientele.getPtstat());
carehomesele.setDateofBirth(patientele.getBirdt());
carehomesele.setAssesstodate(patientele.getAsmtdt());
carehomesele.setNextAssesstDT(patientele.getNasdt());
carehomesele.setPatientkunnr(patientele.getKunnr());
carehomesele.setPatiennameID(patientele.getName1()+"-"+Long.valueOf(patientele.getKunnr()));
String product = "";
String productDesc = "";
String assPadsPD = "";
String actualPPD = "";
String nextDD = "";
String frequency = "";
for(int j=0;j<wdContext.nodeArticles().size();j++)
{
article = wdContext.nodeArticles().getArticlesElementAt(j);
if(patientele.getKunnr().trim().equalsIgnoreCase(article.getKunwe().trim()))
{
product = product + "\\n" + article.getMatnr();
productDesc = productDesc + "\\n" + article.getArktx();
assPadsPD = assPadsPD + "\\n" +article.getAsppd();
actualPPD = actualPPD +"\\n" +article.getAcppd();
nextDD = nextDD + "\\n" +article.getZznextdlvy();
frequency = frequency + "\\n" +article.getDelfr();
}
}//2nd for
carehomesele.setProduct(product);
carehomesele.setProductDiscription(productDesc);
carehomesele.setAssPadsPD(article.getAsppd());
carehomesele.setActualPPD(assPadsPD);
carehomesele.setNextDD(nextDD);
carehomesele.setFrequency(frequency);
}// 1st for
Regards,
Jaya.
Edited by: VJR on Jul 2, 2009 2:22 PM
Hi,
I had same requirement which looks like your requirement...
Let me explain you my case...
I have three values in an attribute of a node, say "Yes","No","Not Known". I have to show this values in a single table cell like
-
Yes
No
Not Known
-
I have done this taking a StringBuffer
Lets say this values "Yes","No",:Not Known" are coming in a value attribute "Name" of node called Sourcenode.
StringBuffer objStrBuf = new StringBuffer();
IPrivate<ViewName>.ITargetNodeElement objNodele = null;
for(int iCount=0;iCount<wdContext.nodeSourcenode ().size();iCount++)
{
objStrBuf .append(wdContext.nodeSourcenode().getnodeSourcenodeElementAt(iCount).getName());
objStrBuf.append("\n");
}
objNodele = wdContext.createTargetNodeElement();
objNodele.setName(objStrBuf.toString());
I have given you a simple example, check by any chance it will suite your requirement...
Regards,
Saleem
Can you post your exact code,instead of skeleton?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ,
i wrote this code:
IPatientsElement patientele = null;
ICareHomesReassessmentElement carehomesele = null;
IArticlesElement article = null;
for(int i=0;i<wdContext.nodePatients().size();i++)
{
patientele = wdContext.nodePatients().getPatientsElementAt(i);
carehomesele = wdContext.nodeCareHomesReassessment().createCareHomesReassessmentElement();
wdContext.nodeCareHomesReassessment().addElement(carehomesele);
carehomesele.setPatientID(patientele.getKunn2());
carehomesele.setPatientName(patientele.getName1());
carehomesele.setStatus(patientele.getPtstat());
carehomesele.setDateofBirth(patientele.getBirdt());
carehomesele.setAssesstodate(patientele.getAsmtdt());
carehomesele.setNextAssesstDT(patientele.getNasdt());
carehomesele.setPatientkunnr(patientele.getKunnr());
carehomesele.setPatiennameID(patientele.getName1()"-"Long.valueOf(patientele.getKunnr()));
for(int j=0;j<wdContext.nodeArticles().size();j++)
{
article = wdContext.nodeArticles().getArticlesElementAt(j);
if(patientele.getKunnr().trim().equalsIgnoreCase(article.getKunwe().trim()))
{
carehomesele.setProduct(article.getMatnr());
carehomesele.setProductDiscription(article.getArktx());
carehomesele.setAssPadsPD(article.getAsppd());
carehomesele.setActualPPD(article.getAcppd());
carehomesele.setNextDD(article.getZznextdlvy());
carehomesele.setFrequency(article.getDelfr());
}
Regards,
Prasad
I think you need to add one more createElment line in second loop to have the two records.
I am not still sure of your exact requirement,but if i understood your requirement correctly,I woudl suggest you to change ur code as follows.If not please exlpain ur requirement clearly
for(int j=0;j<wdContext.nodeArticles().size();j++)
{
article = wdContext.nodeArticles().getArticlesElementAt(j);
if(patientele.getKunnr().trim().equalsIgnoreCase(article.getKunwe().trim()))
{
carehomesele.setProduct(article.getMatnr());
carehomesele.setProductDiscription(article.getArktx());
carehomesele.setAssPadsPD(article.getAsppd());
carehomesele.setActualPPD(article.getAcppd());
carehomesele.setNextDD(article.getZznextdlvy());
carehomesele.setFrequency(article.getDelfr());
}
carehomesele = wdContext.nodeCareHomesReassessment().createCareHomesReassessmentElement();
wdContext.nodeCareHomesReassessment().addElement(carehomesele);
}
Edited by: Santhosh Edla on Jul 2, 2009 9:39 AM
Edited by: Santhosh Edla on Jul 2, 2009 9:45 AM
Hi Santosh,
I have a RFC and in that i have 2 strucutres. In first structure i have a column name ID(unique ID) and in second i have another column with same nam 'ID'(multiple id with same name).I am comparing these 2 columns to populate data in a table.
From first loop i am displaying data and i need to compare to populate remaining data from second strucutre.
If have 2 ID with same name i need to populate that 2 record in table liek in belowm result ouputt
Result:
ID
1 A X M
N
Structure 1:
ID
1 A X
2 B Y
3 C Z
Structure 2:
ID
1 M
1 N
2 O
3 P
Regards,
Prasad
Yes Prasad,
The previous lines of code I posted for your second loop should work as per ur requirement.
Here is the full code.Try this and let me know
IPatientsElement patientele = null;
ICareHomesReassessmentElement carehomesele = null;
IArticlesElement article = null;
for(int i=0;i<wdContext.nodePatients().size();i++)
{
patientele = wdContext.nodePatients().getPatientsElementAt(i);
carehomesele = wdContext.nodeCareHomesReassessment().createCareHomesReassessmentElement();
wdContext.nodeCareHomesReassessment().addElement(carehomesele);
carehomesele.setPatientID(patientele.getKunn2());
carehomesele.setPatientName(patientele.getName1());
carehomesele.setStatus(patientele.getPtstat());
carehomesele.setDateofBirth(patientele.getBirdt());
carehomesele.setAssesstodate(patientele.getAsmtdt());
carehomesele.setNextAssesstDT(patientele.getNasdt());
carehomesele.setPatientkunnr(patientele.getKunnr());
carehomesele.setPatiennameID(patientele.getName1()+"-"+Long.valueOf(patientele.getKunnr()));
for(int j=0;j<wdContext.nodeArticles().size();j++)
{
article = wdContext.nodeArticles().getArticlesElementAt(j);
if(patientele.getKunnr().trim().equalsIgnoreCase(article.getKunwe().trim()))
{
carehomesele.setProduct(article.getMatnr());
carehomesele.setProductDiscription(article.getArktx());
carehomesele.setAssPadsPD(article.getAsppd());
carehomesele.setActualPPD(article.getAcppd());
carehomesele.setNextDD(article.getZznextdlvy());
carehomesele.setFrequency(article.getDelfr());
}
carehomesele = wdContext.nodeCareHomesReassessment().createCareHomesReassessmentElement();
wdContext.nodeCareHomesReassessment().addElement(carehomesele);
}
These two lines are added in ur second loop
carehomesele = wdContext.nodeCareHomesReassessment().createCareHomesReassessmentElement();
wdContext.nodeCareHomesReassessment().addElement(carehomesele);
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.