STRPDM.COM                  

   Home    |    IBM Manuals Direct    |    iBytes Library   |    Links    |   About     |   Book Store   |  On-Line Code

 

iByte

Subject – iByte - Advanced Searches

Giving users advanced searching capability is very easy in RPG IV.  Just adding these 2 steps to a search will give users more flexibility.
 

C*                                                                 
C* FIRST GET THE LENGTH OF THE USER ENTERED SEARCH STRING          
C*                                                                 
C                   EVAL      SSLength = %LEN(%TRIM(SearchString)) 
C*                                                                 
C* NEXT SCAN THE FIELD TO BE SEARCHED FOR ANY OCCURRENCE OF THE     
C* USER ENTERED STRING.                                            
C*                                                                 
C                   IF        %SCAN(%SUBST(SearchString:1:SSLength)
C                             :Field4Search:1) > 0                 
C                                                         

Say we have the following search screen.

 
Search for name containing     AR_________________
 
Message
JIM
BOB
JOE
CAROL
FRED
DON
HOWARD
 
If we rebuild the subfile based on records that passed the IF condition above we would end up with a search result of...
 
CAROL
HOWARD