cancel
Showing results for 
Search instead for 
Did you mean: 

setsort is not working after create group in datawindow

Former Member
0 Kudos

Hi All,

With PB12.5 here.

I have datawindow, which is set to group by stockclass (Group Definition = "stockclass" and Group Sort = stockclass A ), and this is actual to generate a PDF report and user is allowed to select sorting column and ordering from dropdownlist below:

ddlb_order_3.insertitem('Ascending',1)

ddlb_order_3.insertitem('Descending',2)

ddlb_order_3.selectitem(1)

ddlb_sortingcol_countsheet_pdf.insertitem('Location',1)

ddlb_sortingcol_countsheet_pdf.insertitem('Amos No.',2)

ddlb_sortingcol_countsheet_pdf.insertitem('Description',3)

ddlb_sortingcol_countsheet_pdf.insertitem('Maker Name',4)

ddlb_sortingcol_countsheet_pdf.insertitem('Stock Class',5)

ddlb_sortingcol_countsheet_pdf.insertitem('Balance',6)

ddlb_sortingcol_countsheet_pdf.insertitem('Unit Cost (Avg)',7)

ddlb_sortingcol_countsheet_pdf.insertitem('UOM',8)

ddlb_sortingcol_countsheet_pdf.selectitem(1)

To get the sorting column and ordering (Asc or Desc) from user's input:

Ordering = ls_ordering_3

SortColumnIndex_countsheet_pdf = ls_sortcolumnindex_countsheet_pdf

Sorting_Parm = '#'+SortColumnIndex_countsheet_pdf+""+' '+Ordering

dw_composite.SetTransObject(SQLCA)

dw_composite.Retrieve(InstCode,ll_list,ll_list_location,ll_list_maker)

dw_composite.SetSort ( Sorting_Parm)

My problem is, the setsort is not working after I create the grouping. It works fine before create the grouping.

Kindly advise if any other setting is avaiable for other alternative to go.

Thank you in advance.

BR,

Yow

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello Yow,

Code wise, you can either add a sort()

dw_composite.Retrieve(InstCode,ll_list,ll_list_location,ll_list_maker)

dw_composite.SetSort(Sorting_Parm)

dw_composite.Sort()

OR move the setSort above the retrieve

dw_composite.SetSort(Sorting_Parm)

dw_composite.Retrieve(InstCode,ll_list,ll_list_location,ll_list_maker)

Have you checked the return code from the setSort() to make sure it succeeded?  I don't think your parameter in the SetSort() call will work.  Run the debugger and see what it is equal to and try using it in the painter.  I tried the '#' notation for column number in the painter and it doesn't work.  Try using the name instead.

Something like: Sorting_Parm = dw_composite.Describe('#'+SortColumnIndex_countsheet_pdf + '.Name') + ' '+ Left(Ordering, 1)

arnd_schmidt
Active Contributor
0 Kudos

An additional dw.GroupCalc()  is also welcome after a dw.Sort().

hth

Arnd

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Yow;

   For give me but, I'm confused ...

1) I do not see any grouping action going on.

2) I do not see a Sort ( ) command after the SetSort ( ) command

Note: Have you run this through the PB Debugger? If so ... did you capture the value of the Sorting_Parm variable and then try running this in the  DW Painter's preview pane with the sort option on the DW Painter's menu to see if it works?

Regards ... Chris

Former Member
0 Kudos

Why do you use group sort for stockclass instead of a normal sort in this case?

I think you should use normal sort. Combine sort by stockclass and the selected sort from users input.