Peter warren
Peter warren

Reputation: 11

DFSORT PARSE on optional fields in variable positions

Hi, I have the following code and data that I am trying to extract 3 fields that may/may not be there and are not in fixed positions: Looking on the internet there are many forums saying to use the IFTHEN(WHEN=INIT command but it doesn't work for me - it finds the first field but no more after that - any ideas please.

JCL:
//STEP010  EXEC PGM=ICEMAN                                      
//SORTIN   DD DISP=SHR,DSN=TTFO.PQUQ.NPDARCH.PRPY.D24032.V2     
//SORTOUT  DD  DSN=TTFO.WARREPB.PPAY.ARCH.FUND.Y2024.QMU.&MTH,  
//             DISP=(NEW,CATLG),UNIT=DASD,SPACE=(TRK,(600,      
//             150),RLSE),RECFM=VB,LRECL=400                    
//SYSOUT   DD  SYSOUT=*                                         
//SYSIN    DD  *                                                
 OPTION  VLSCMP                                                 
 INCLUDE COND=((2363,1,CH,NE,C'Y'),                             
           AND,((1,25000,SS,NE,C';0378; '),                     
               OR,(1,25000,SS,NE,C';0379; ')))                  
 INREC IFTHEN=(WHEN=INIT,                                       
       PARSE=(%01=(ABSPOS=1,STARTAT=C';0118;',ENDBEFR=C';0119;',
                 FIXLEN=40))),                                  
       IFTHEN=(WHEN=INIT,                                       
       PARSE=(%02=(ABSPOS=1,STARTAT=C';0004;',ENDBEFR=C';0005;',
                FIXLEN=35))),                                   
       IFTHEN=(WHEN=INIT,                                       
           PARSE=(%03=(ABSPOS=1,STARTAFT=C';0378;',ENDBEFR=C';',
                   FIXLEN=4))),                                 
       IFTHEN=(WHEN=NONE,                                       
            BUILD=(1:1,4,                                       
            %01,C'*', %02,C'&',C' 378 ',   %03,C'£'))                                          
   SORT FIELDS=COPY                                             
/*                                                              
//      

Input file - TTFO.PQUQ.NPDARCH.PRPY.D24032.V2 : NWBDM2I78742122 PROPAY 2024-02-01..........GBPUBNINPI02584368;0117;E;**0118;2024-02-01;0119;**9999-12-31;0120;SHA;0121;N;0122; ;0377;N;0378; ;0379;CODEWORD /RETN/ RECEIVED GO TO PAGE 4 ;0380;/RETN/ ;0381;N;0382;2433;0383;Same account number used for credit and debit

Output file - TTFO.WARREPB.PPAY.ARCH.FUND.Y2024.QMU.ALL : ;0118;2024-02-01 * £ The field 0118 is found but none of the others. If I swap theme around so it looks for field 0378 first it finds that but none of the others. So it seems to not parse after the first successful parse.

Many thanks

Upvotes: 0

Views: 23

Answers (0)

Related Questions