Skip to Content
avatar image
Former Member

Multiple records should display

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Jul 02, 2009 at 06:17 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 02, 2009 at 06:09 AM

    Can you post your exact code,instead of skeleton?

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

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