///////////////////////////////////////////////////////// // Method : wf_GetLastRowInGroup() // Author : PowerObject! [Shekar Reddy] // Date : 5/12/2003 ///////////////////////////////////////////////////////// // Arg : val1, val2, ... valN (columns with repeating values) // Return : long ///////////////////////////////////////////////////////// // Desc : The FindGroupChange() has some draw-backs. // This function returns the last row in a // group by manually scanning all the rows in // a group of a dw. Works on dw's without any // groups, too; but, in this case returns the // last row in the dw treating all the rows // as a single group. // // Usage : See below... ///////////////////////////////////////////////////////// long ll_Row, ll_Count // ll_Count = dw.RowCount() // IF ll_Count <= 0 THEN RETURN -1 END IF // // Position the current-row to begin the scan ll_Row = dw.Find( "col1 = '" + val1 + "' and " + & "col2 = '" + val2 + "' and " + & "colN = '" + valN + "'", 1, ll_Count ) // IF ll_Row <= 0 THEN RETURN -1 END IF // // Scan to the end of the group to figure out the last row in the group DO WHILE dw.Object.Col1[ ll_Row ] = val1 AND & dw.Object.Col2[ ll_Row ] = val2 AND & dw.Object.ColN[ ll_Row ] = valN // ll_Row++ // IF ll_Row > ll_Count THEN EXIT // Bypassed the last-row in the dw END IF // LOOP // // Bypassed the last-row in the group to the first row // of the next group or bypassed the last-row RETURN ( ll_Row - 1 ) // Last row in the group ///////////////////////////////////////////////////////// // USAGE (Example of a Validation-script) // Validate all the Group-totals ///////////////////////////////////////////////////////// ll_Count = dw.RowCount() // IF ll_Count <= 0 THEN RETURN 1 END IF // ll_Row = 1 // Start with the first group // DO WHILE TRUE // IF ll_Row > ll_Count THEN EXIT END IF // ls_Division = dw.Object.Division[ ll_Row ] ls_Activity = dw.Object.Activity[ ll_Row ] // // Get the last-row of the group ll_Row = wf_GetLastRowInGroup( ls_Division, ls_Activity ) // IF ll_Row <= 0 OR ll_Row > ll_Count THEN EXIT END IF // // IF dw.Object.Surplus[ ll_Row ] < 0 THEN // Beep( 3 ) ls_Division = Trim( dw.Describe( "Evaluate( 'LookUpDisplay( division )', " + String( ll_Row ) + ")" )) ls_Activity = Trim( dw.Describe( "Evaluate( 'LookUpDisplay( activity )', " + String( ll_Row ) + ")" )) // MessageBox( This.Title, "Division: " + ls_Division + "~r~n" + & "Activity: " + ls_Activity + "~r~n~r~n" + & "has a Negative Surplus so you cannot save it.~r~n" + & "You will need to have a Change Request approved~r~n" + & "to add additional funds." ) // dw.SetFocus() RETURN -1 // END IF // ll_Row++ // Point to the first-row of the next group // LOOP // RETURN 1