Hi,
I have a load all subfile in which i want to add search utility so that user can give a specific value at the top right of the screen and see the specific recerod.I mean subfile display should show the page starting by the record which he/she searched for..Any idea please
Thanks in Advance
Bikram
Software/Hardware used:
ASKED:
May 30, 2010 11:30 AM
UPDATED:
May 31, 2010 8:16 PM
The only way I can see this working is by saving the search field and it’s RRN to an array as the subfile is being loaded. That way you can look up the search field in the array and set the subfile RRN to that particular RRN.
you can loop through the subfile until you find the record desired
RRN = 0; <– this would be the same type size as the Subfile record pointer
DOw SFLFld < Request and RRN < current subfile size
RRN += 1;
RRN Chain SFL1 <<– this would be the subfile record name
EndDo
if SFLFld < Request
REC# = RRN <<– REC# is the field for SFLRCDNBR
Endif
The best way to handle this is by using embedded SQL to load your subfile. When someone types search criteria in on the screen, you can rebuild your SQL statement with a where clause searching for the criteria entered on the screen.
It depends on the type of subfile you’re using. If it’s a load-all subfile, you’d either need to rebuild it each time (see OneWork’s comments) or read through the subfile to find the matching value. If it’s a single page subfile, (SFLSIZ = SFLPAG), you can either use SQL or SETLL to position the file (SETLL would require the search field be a key field). Lot’s of options.
Firstly I agre with OneWorks.
Secondly: ‘load all’ file – assuming that you have a loop controlling the ‘read record and display as SFL-line’, I read your requirement as you have the need to ‘qualify’ which records are to be displayed according to entered search/qualify-criterias. If this is the case, simply add an ‘exsr subqualify’ statement in the loop, and create a subroutine ‘subqualify’ subroutine, where the actual qualification (if’s ) takes place. Return an indicator ex ‘qualified’ which tells the loop-proces if the record is going to be displayed as part of the SFL.
Here is some pseude-code to clarify:
I often program this kind of solution into old application-code, and I always isolate the actual qualification-test in a subroutine, because it sometimes tend to be quite advanced with ‘like’-functionality a.o.
happy coding.
DanF