Focal Point
[SOLVED] How do I loop through records?

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/9571061282

April 28, 2008, 05:39 PM
webmeister
[SOLVED] How do I loop through records?
Does mainframe FOCUS have the equivalent of a DO WHILE function? I need to cycle through records based on an a certain field to see if another field has a certain value. After I finish looping through these records, I want to produce a report that contians only one record from the records that can have multiple values.

Here is a piece of my code where I want ot be able to loop:

 
DEFINE FILE SWFILE                                     
AWARDYR  /A4 = EDIT(SW010,'9999');                     
YRCHECK  /A1 = EDIT('&AWDYR','$$$9');                  
TXGRANT1 /A5 = '8930' | YRCHECK;                       
TXGRANT2 /A5 = '8940' | YRCHECK;                       
TXGRANT3 /A5 = '8950' | YRCHECK;                       
TXGRANT4 /A5 = '8960' | YRCHECK;                       
TXGRANT  /A1 = IF SW025 EQ TXGRANT1 THEN 'Y' ELSE      
               IF SW025 EQ TXGRANT2 THEN 'Y' ELSE      
               IF SW025 EQ TXGRANT3 THEN 'Y' ELSE      
               IF SW025 EQ TXGRANT4 THEN 'Y' ELSE 'N'; 
END    

 


When I get to this point, I want to have only one record from the piece above.


  TABLE FILE SWFILE                        
PRINT                                    
-*   SW025    AS GRANT_CODE              
     TXGRANT  AS TX_GRANT                
     TXGRANT1 TXGRANT2 TXGRANT3 TXGRANT4 
     SW050    AS AWD_PERIOD              
     AWARDYR                             
BY   STU_ID                              
BY   SW050 NOPRINT                       
BY   SW025 NOPRINT                       
WHERE AWARDYR EQ '&AWDYR'                
ON    TABLE    HOLD AS 'S079E&INSTX'     
END                                      
-RUN 


In other words, once I cycle through, say Ralph's data, I want to end up with one record that contains the TX_GRANT code, whether that code be a 'Y' or 'N'. What's happening at present is that I am getting all of Ralph's records, those that have both a 'Y' and an ''N' and my client wants only one record for Ralph (or anyone, for that matter.)

Thank you so much in advance....looking forward to seeing what you have to say.

This message has been edited. Last edited by: webmeister,


Mainframe FOCUS 7.0
VM/CMS and MVS/TSO
April 29, 2008, 02:49 AM
Tony A
Sum would be the easiest way to provide one line, remembering that alphas summed show the last value encountered within your sort level(s). So you'll have to discuss with your user what they want in preference, the 'Y' or 'N' records and then sort accordingly. You might have to introduce an interim hold file stage depending upon what your user requests.

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
April 29, 2008, 09:09 AM
PBrightwell
There is a -REPEAT loop, check your developers manual for the syntax you want to use. SUM will give you one record per student. In looking at your code I think neither is going to give you what you really want. Currently changing PRINT to SUM will give you one record for every SW025 code within every SW050 for RALPH where the &AWDYR equals the AWARDYR. And each record will contain;
RALPH Y 89308 89408 89508 89608 2008


Pat
WF 7.6.8, AIX, AS400, NT
AS400 FOCUS, AIX FOCUS,
Oracle, DB2, JDE, Lotus Notes
April 29, 2008, 11:48 AM
webmeister
Tony and Pat,

Thanks for replying to my plight! I think a good possibility is to use the SUM verb, and create two interim files, one that contains records with only the 'N' value and the other with only the 'Y' value and then use the OLD_NOT_NEW (or one of its variants to rejoin the two interim files in order to then continue with the rest of the process in my FOCEXEC.

I appreciate you both taking the time to reply... it helped me nicely.


Mainframe FOCUS 7.0
VM/CMS and MVS/TSO