cancel
Showing results for 
Search instead for 
Did you mean: 

looping for one atrribute depending on another attribute

Former Member
0 Kudos

Hi,

I want to include the other courses(first attribute) for the current studentid which is second attribute(by looping through the student table and looking for courses for the current studentid and adding to student table before executing the RFC) .Please suggest me how to do this.

Thanks & Regards,

Reinuka.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

I am assuming that node Student_List has all the information about studentids and courses. Then try the following.

Replace <STUDENT_ID> with the value of the student id for which you want to print the information. If this is coming

from any input field, then you can grab that value and replace here. If it is directly coming from table itself, then use

student id of currentStudent_ListElement. Make sure the looping here is done only once and it prints the information

about one student.

Y_21714_Web_Generate_Forms_Input formsObj = null;

formsObj = new Y_21714_Web_Generate_Forms_Input();

Yweb_Student_List objStudentList = null;

AbstractList abStudentList = null;

abStudentList = new Yweb_Student_List.Yweb_Student_List_List();

wdContext.nodeY_21714_Web_Generate_Forms_Input().bind(formsObj);

for( int count = 0; count < wdContext.nodeStudent_List().size(); count++ )

{

IStudent_ListElement listElement = wdContext.nodeStudent_List().getStudent_ListElementAt(count );

if( listElement.getStudentid().equals( <STUDENT_ID>) )

{

objStudentList.setstudentid(listElement.getStudentid());

objStudentList.setcourse(listElement.getcourse());

abStudentList.add(objStudentList);

}

}

formsObj.setStudent_List(abStudentList);

formsObj.execute();

wdContext.nodeOutput_forms().invalidate();

Kiran

Answers (3)

Answers (3)

Former Member
0 Kudos

Amit,

check your modifications once. You end up adding duplicates.

Kiran

Former Member
0 Kudos

Thanks Kiran .

I had done the same thing and i got it.

Former Member
0 Kudos

Hi,

I am going to make a slight modification in the above code.So please try this one and let me know about your results.

Y_21714_Web_Generate_Forms_Input formsObj = null;

formsObj = new Y_21714_Web_Generate_Forms_Input();

Yweb_Student_List objStudentList = null;

AbstractList abStudentList = null;

abStudentList = new Yweb_Student_List.Yweb_Student_List_List();

wdContext.nodeY_21714_Web_Generate_Forms_Input().bind(formsObj);

for( int row1 = 0; count < wdContext.nodeStudent_List().size(); row1++ )

{

IStudent_ListElement row1Element = wdContext.nodeStudent_List().getStudent_ListElementAt(row1 );

for(int row2=row1;row2< wdContext.nodeStudent_List().size();row2++){

IStudent_ListElement row2Element = wdContext.nodeStudent_List().getStudent_ListElementAt(row2 );

if( row1Element.getStudentid().equals(row2Element.getStudentid() ) )

{

objStudentList.setstudentid(row2Element.getStudentid());

objStudentList.setcourse(row2Element.getcourse());

abStudentList.add(objStudentList);

}

}

}

formsObj.setStudent_List(abStudentList);

formsObj.execute();

wdContext.nodeOutput_forms().invalidate();

regards,

amit bagati

Former Member
0 Kudos

Hi,

Can you please explain your query in detail..I did nit get your query

regards,

amit bagati

Former Member
0 Kudos

Hi Amit,

I have a table called student which has colmns as:

studentid

courses

location

and for every student id we have one or more than one courses like for studentid no.4567 courses are 1980,2467.Now I want to print this onto a fax machine for which I have written a code in component controller in which I was just printing the first value of the course only for the current student id but I need to print all the course values for a particular studentid.Presently I am able to print only the first value by the code given below:

Y_21714_Web_Generate_Forms_Input formsObj = null;

formsObj = new Y_21714_Web_Generate_Forms_Input();

Yweb_Student_List objStudentList = null;

AbstractList abStudentList = null;

abStudentList = new Yweb_Student_List.Yweb_Student_List_List();

wdContext.nodeY_21714_Web_Generate_Forms_Input().bind(formsObj);

objStudentList.setstudentid(wdContext.currentStudent_List__Element().getStudentid());

objStudentList.setcourse(wdContext.currentStudent_List__Element().getcourse());

abStudentList.add(objStudentList);

formsObj.setStudent_List(abStudentList);

formsObj.execute();

wdContext.nodeOutput_forms().invalidate();

I want to include the other courses(first attribute) for the current studentid which is second attribute(by looping through the student table and looking for courses for the current studentid and adding to student table before executing the RFC) .Please suggest me how to do this.