cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple records should display

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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.

Former Member
0 Kudos

HI ,

I am expecting these result:

Structure 1:

1 A X

2 B Y

3 C Z

Structure 2:

1 M

1 N

2 O

3 P

Result:

1 A X M

N

2 B Y O

3 C Z P

N sholud come under the M column.

Regards,

Prasad

Edited by: prasad kamina on Jul 2, 2009 8:26 AM

Former Member
0 Kudos

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.

Former Member
0 Kudos

HI VJR,

These code is not working perfectly.Particular id which have 2 records that row is not populateing data like empty row it showing.

Regards,

Prasad

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

HI VJR,

I didn't get your idea .Totally 6 columns i am populating data from second struture.So if i have multiple id in struture 2 i need to populate these 2 records in in single row.

Regards,

Prasad

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

HI VJR,

Its working .....thanks a lot...

Regards,

Prasad

Answers (1)

Answers (1)

Former Member
0 Kudos

Can you post your exact code,instead of skeleton?

Former Member
0 Kudos

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

Former Member
0 Kudos

Looks like there are three nodes from which structure you want to copy the values and in which structure u have to put the values

Former Member
0 Kudos

HI Santosh.,

Actulaly i import this RFc in webdynpro and populating data in a table.So i needs to populate data if i have 2 records in seocnd struture.

Regards,

Prasad

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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);