cancel
Showing results for 
Search instead for 
Did you mean: 

Table UI sort Automatically with respect to one column

Former Member
0 Kudos

Hi Experts,

My requirement is to call a Bapi from r/3 and show the result in a Table UI Element, here am doing a direct binding with the context attribute and table ui. Till now everthing is according to requirement .

Now further to it I have to automatically sort the table based on one attribute of the node say "Fpperiod". I am trying to sort the model node just after the ".....execute()" method,

1. I dont need any sorting/ filtering options in the View .

. wdContext			.nodeBapi_Get_Payroll_Result_List_Input()
				.nodeOutput()				.nodeResults_Out().sortElements(new Comparator()public int compare(Object x, Object y) {
					int iX, iY;

					IPublicTable.IResults_OutElement rx =
						(IPublicTable.IResults_OutElement) x;
					IPublicTable.IResults_OutElement ry =
						(IPublicTable.IResults_OutElement) y;
					iX = Integer.parseInt(rx.getFpperiod());

					iY = Integer.parseInt(ry.getFpperiod());
					while (rx.getFpperiod() != null && ry.getFpperiod() != null) {						rx.getFpperiod().compareTo(ry.getFpperiod());					}					return iY - iX;				}			}); 

But its not working, and also if anyone could help me how the "comapre() " works it would be of great help ...

Can anyone help me with it .

Thanks in Advance

Tony

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

What is the data type of attribute "Fpperiod" and how should it be sorted?

For understanding the Comparator interface, please have a look at the JDK doc.

Armin

Answers (2)

Answers (2)

Former Member
0 Kudos

Fpperiod type -- com.model.table.types.Faper

Just breif you regarding sorting requirements, model returns a table , and when I display the result in the view ( Table UI element ) I want

it to be displayed based on Fpperiod attribute of the node .

Regards,

Antony

Former Member
0 Kudos

Hi Armin ,

Thank you for giving it a look . Regarding Fperiod , Model uses following Bapi,

Bapi_Get_Payroll_Result_List_Input and Fperiod is contained in the structure of table parameter "Results.

Fperiod determinies the period for the pay roll run .

For Reference below mentioned is the code i am using to get the latest period, after executing the model .

Bapi7004_Rl payperiod = null;
	    while (itr_period.hasNext()) {
	   payperiod = (Bapi7004_Rl) itr_period.next();
	    pay_per.add(payperiod.getFpperiod());
                     }
	Collections.sort(pay_per);
	pay_str = pay_per.getLast().toString();

Hope you can figure out from the above code .

And as per the previous post dou you think the compare() code am using will be sufficient enough to achive sorting .

Regards,

Tony

Former Member
0 Kudos

I am sorry, but I have no idea about this BAPI. Just tell what datatype the attribute has and how it should be sorted.

Your comparator code looks quite strange to me.

Armin