The next sample code illustrates the use of a character string to sort a group view on one field.
15- --- EVENT ACTION accounts_pb_new_click 16- | --- CREATE account 17- | | SET Description TO input account description 18- | | SET type TO input account type 19- | | SET number TO input account number 20- | |--- WHEN successful 21- | | --- IF LAST OF export_account IS EQUAL TO MAX OF export_account 22- | | | SET SUBSCRIPT OF export_account TO LAST OF export_account 23- | | | --- IF input account number IS GREATER THAN export_line 24- | | | | account_number 25- | | | | EXIT STATE IS account_out_of_list_box 26- | | | |--- ELSE 27- | | | | MOVE input account TO export_line account 28- | | | --- SORT export_account BY 4A 29- | | | 30- | | |--- ELSE 31- | | | SET SUBSCRIPT OF export_account TO LAST OF export_account +1 32- | | | MOVE input account TO export_line account 33- | | --- SORT export_account BY 4A 34- | | 35- | |--- WHEN already exists 36- | | MAKE output account number Unprotected Normal Intensity Normal 37- | | Color containing Cursor 38- | | EXIT STATE IS account_already_exists 39- | | WHEN permitted value violation 40- | --- EXIT STATE IS account_invalid_permitted_values 41- | 42- | GET ROW HIGHLIGHTED IN export_account STARTING AT 1 GIVING 43- | SUBSCRIPT OF export_account 44- | --- IF SUBSCRIPT OF export_account IS GREATER THAN 0 45- | | MOVE export_line account TO output account 46- | |--- ELSE 47- | | MOVE local_account_blank account TO output account 48- | --- SET output account type TO E 49- | 50- ---
In lines 27 and 32, the group view containing accounts is sorted ascending on the fourth field in the view, which is account number.
This example also shows how a new entity can be added to the bottom of a group view (if it is within the range contained in the group view). This logic is contained in the nested IF statements in lines 21 through 33. The group is then sorted to put the list back in sequence.
Another method of putting lists back in sequence is to use the ADD EMPTY ROW statement. For more information, see ADD EMPTY ROW Statement.
Always use a local character view for the sort argument character expression. Assign it a value in one place for ease of maintenance. Additionally, if plans call for the sort sequence to be user-defined, you must use a variable.
The next sample code shows one way to set up user definable sort sequences. The next sample code shows one way to set up user definable sort sequences.
|
Copyright © 2013 CA.
All rights reserved.
|
|