cancel
Showing results for 
Search instead for 
Did you mean: 

How do you sort a result table from a BAPI

Former Member
0 Kudos

Hi,

I'm creating the CAT2 transaction functionality in a Web Dynpro application (pretty ambitious for my first Dynpro app). I have a Model Node that is a result table from Bapi_catimesheetrecord_Getlist. This BAPI returns all rows for a specific date range and I want to turn row data from the result set into column data for the Value node.

I need to sort the results by 6 key columns in order to loop through the result set to populate the Value node.

The six key columns will be:

1. Rec_Order

2. Activity

3. Work_Cntr

4. Abs_Att_Type

5. Acttype

6. Co_Area

The new columns will be the Workdate and Catshours attributes. So, based on the unique 6 attribute key, I want possibly 7 rows from the Model Node to become one displayed row in my Value node for each unique ordering of the 6 key columns (Mon-Sun).

Is this possible and if so, how?

The nodel element is a Bapicats2 type and my model node is wdContext.nodeTimsheetTable().

Thanks,

Andrew

P.S. I will award the points to whomever best solves this problem.

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member182372
Active Contributor
0 Kudos

Hi Andrew,

your explanation is a little bit tangled, but i`ll try:

1) to sort anything inside Node you can use cool Valery`s solution:

2)

> I want possibly 7 rows from the Model Node to become

> one displayed row in my Value node for each unique

> ordering of the 6 key columns (Mon-Sun).

you need to create supply function for your "TimsheetTable" node, where you will iterate through model node and init appropriate attributes in your new node`s element. or you can apply sorting for every column in model node you need and after init attribets of node`s element with "top" values.

Regards, Maxim R.

Former Member
0 Kudos

Hi Maxim,

I have a Model node that has 8 attributes. Six of the attributes are as listed and the other two are Workdate and Catshours. I need to populate a Value Node that will be one row for each unique key of the six columns.

I'm always dealing with 1 week of data starting on a Monday.

Example:

Result set includes 3 rows. The five rows have the same 6 key attributes each with a differt Workdate and Catshours. The Value Node would be one row as follows:

.Key1

.Key2

.Key3

.Key4

.Key5

.Key6

.Monday = 2/18/05 (Monday)

.MondayHours = 8

.Tuesday = 3/1/05

.TuesdayHours = 5

.Wednesday = 3/2/05

.WednesdayHours = 8

.

.

etc.

So, in order to easily build this structure, I need to sort the Model Node on the six columns so I can test to see when I have a different unique key.

The linked example just sorts on one column if I'm reading it correctly.

Does this make it more clear?

Thanks,

Andrew

BTW, sorry about the points... I don't have any to give!

Former Member
0 Kudos

Oops, I see how it does sort on multiple elements.

How do I get this code into my view without it getting deleted after a rebuild of the Project?

Thanks,

Andrew

former_member182372
Active Contributor
0 Kudos

Hi Andrew,

open view, go to "Implementation" scroll to bottom and place code between


//@@begin others
//@@end

Regards, Maxim R.

Former Member
0 Kudos

Thanks for the replies.

When I paste this here and put the imports at the top, I get an error stating that following is not allowed:

public static GenericNodeElementComparator asc(final String attribute)
{
return new GenericNodeElementComparator( new OrderingExpression().asc(attribute));
}

The error states "The method asc cannot be declared static; static methods can only be declared in a static or top level type"

If I change it to just public, I still an error when trying to access the method because it can't see it.

wdContext.nodeTimesheetTable().sortElements(GenericNodeElementComparator.asc("Name") );

The error states: "The method asc(String)from the type TimeEntryComponent.GenericNodeElementComparator is not static"

Any ideas? Wouldn't it be best to put this in it's own package and just import it into my view? If so, how do I do that?

Thanks again!!!

Andrew

former_member182372
Active Contributor
0 Kudos

you have 2 options:

1) declare all inner classes inside view as static;

2) create appropriate folder structure ( "net\sdn\utils\context" or your own if you would like) under "src\packages" in your project. Put file there. In folder def\packages create empty file "net.sdn.utils.context.package" (or your own package with "package" extension). Go to "Nafigator" view and choose "Refresh" from context menu for Dynpro project. It should appear there. After you can use it.

Regards, Maxim R.