20 pts.
 How to implement find utility in a load all subfile
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

Answer Wiki:
Hi, i understood as if u need to display the search value at the top of the search record? For instance let us assume that there is a search column called EMPNO, So when the user types the EMPNO, that particular value will be dispalyed. Remember EMPFILE should be Keyed on EMPNO, Then Start reading the EMPFILE from the beginning , and when the search value exists , SETLL the EMPNO with the search value and load the files using Load all, I hope i would have solved the problem. If i am wrong correct me. 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. http://www.oneworksinc.com/qanda/how-to-implement-find-utility-in-a-load-all-subfile/
Last Wiki Answer Submitted:  May 31, 2010  7:02 pm  by  as400dev   180 pts.
All Answer Wiki Contributors:  as400dev   180 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

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.

 1,410 pts.

 

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

 44,190 pts.

 

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.

 55 pts.

 

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.

 5,670 pts.

 

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:

*loval setll myfile;
read myfile;
dow not %eof;
exsr subqual;
if qualified;
  write record to sfl:
endif;
==========
begsr subqual;
if recfield1 = searchfield1;
  qualified = '1';
else;
  qualified = '0',
endif;
endsr;
read myfile;
enddo;

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

 2,540 pts.