Page 1 of 1

How to include when=group with multiple start and end record

PostPosted: Wed Nov 23, 2016 3:05 pm
by Surabhi
Hi all,

I have a requirement of including a group with multiple start and end.
Example:-
//abc
//abc
//xyz
//xyz
//123
//lmn
//156
 

IFTHEN=(WHEN=GROUP,            
       BEGIN=(3,3,CH,EQ,C'abc'),END=(3,3,CH,EQ,C'xyz')

i wann to put ' astrisk * ' in coloumn 3.

Expected output:-
//*abc
//*abc
//*xyz
//*xyz
//123
//lmn
//156
 

Can anyone help me with this.

Thank you.

CODE' d

Re: How to include when=group with multiple start and end re

PostPosted: Thu Nov 24, 2016 12:07 pm
by BillyBoyo
You don't need the data SORTed, so use INREC for your WHEN=GROUP.

Use PUSH to append to the record an indicator. Since you can't use a literal with PUSH, using 1,1 in this case should ensure a non-blank.

The you have an IFTHEN=(WHEN=(logicalexpression) to identify a non-blank, and use BUILD=(1,2,C'* ',3,76). Use IFOUTLEN=80, which will set the record-length to 80 after IFTHEN processing. and your temporary extension will disappear.

Note, I'm suggesting inserting a blank after the asterisk. You don't want to run into the chance of hitting JECL, and why make things more difficult to read/notice either.

Re: How to include when=group with multiple start and end re

PostPosted: Thu Nov 24, 2016 1:36 pm
by Surabhi
Hi,

I tried using the below logic but its not working:-
//S1    EXEC  PGM=SORT                                    
//SYSOUT    DD  SYSOUT=*                                  
//SORTIN DD *                                            
ABC                                                      
ABC                                                      
XYZ                                                      
XYZ                                                      
123                                                      
LMN                                                      
156                                                      
/*                                                        
//SORTOUT DD SYSOUT=*                                    
//SYSIN    DD    *                                        
  INREC IFTHEN=(WHEN=GROUP,                              
          BEGIN=(1,3,CH,EQ,C'ABC'),END=(1,3,CH,EQ,C'XYZ'),
             PUSH=(101:1,1))                              
  OUTFIL REMOVECC,                                        
           IFTHEN=(WHEN=(101,1,CH,EQ,C'1'),              
          BUILD=(1,2,C'*',3,116)),                        
        IFTHEN=(WHEN=NONE,                                
                BUILD=(1,120))                            
  OPTION COPY                                            
/*    
 

SYSOUT:-
----+----1----+----2----+----3----
ABC                              
ABC                              
XYZ                              
XYZ                              
123                              
LMN                              
156                              
 

I am not getting the astrisk sign.
one more concern i have is, i have multiple start and end records, so i want it to consider the first ABC and last XYZ for that group.

Re: How to include when=group with multiple start and end re

PostPosted: Thu Nov 24, 2016 5:15 pm
by BillyBoyo
A couple of things. You are testing for C'1'. Why? Try testing for C'A'.

I see this is probably connected to your "comment out PROCs" topic. You need to show actual data which represents that. For the data you have shown, GROUP is not needed, some simple IFTHEN=(WHEN=(logicalexpression) and the BUILD will be enough. I haven't looked at the other topic, so....

The second thing is, the WHEN=GROUP can't directly do what you want/expect because you get two groups, end the second group ends when you get the first hit for END.

Re: How to include when=group with multiple start and end re

PostPosted: Thu Nov 24, 2016 6:11 pm
by Surabhi
Hi,

Yes its connected to my previous post "comment out procs".

My initial requirement was to comment out ProcXYZ.
I have done this by using When=group.


Input:-
//******************************************************************
//STEP05   EXEC PROCXYZ,                                                                                
//              MEMA=ABCD123,                                      
//              MEMBER=XYZ123,                                    
//STEP10   EXEC PROCABC,                                            
//             DSN='TEST.FILE',                                                                                                          
//STEP40   EXEC PROC123                                                                              
//             DSN1=INPUT.FILE1,                
//             DSN2=OUTPUT.FILE.BKP(+1),            
//             LRECL=800,                                                                                    
//*********************************************************  
 

JCL used for this:-
//STEP01 EXEC PGM=SORT                                                  
//SYSPRINT DD SYSOUT=*                                                  
//SYSOUT DD SYSOUT=*                                                    
//SORTIN   DD  DSN=input.file,DISP=SHR              
//SORTOUT  DD  DSN=output.file,                              
//             DISP=(NEW,CATLG,DELETE),                                
//             RECFM=FB,                                                
//             UNIT=SYSDA                                              
//SYSIN DD *                                                            
  INREC IFTHEN=(WHEN=GROUP,                                            
                BEGIN=(17,4,CH,EQ,C'PROC',)        
                             PUSH=(81:17,7))                            
  OUTFIL REMOVECC,                                                      
           IFTHEN=(WHEN=(81,7,CH,EQ,C'PROCXYZ'),                        
                         BUILD=(1,2,C'*',3,77,81:1,3,C'CMT')),                        
           IFTHEN=(WHEN=NONE,                                          
                         BUILD=(1,90))                                  
  OPTION COPY                                                          
                                                                       
/*
 

Output:-
//******************************************************************
1-----------------------------------------------------------------------------------------80-81-82-83
//*STEP05   EXEC PROCXYZ,                                                                                CMT                                                                              
// *             MEMA=ABCD123,                                                                          CMT
// *            MEMBER=XYZ123,                                                                          CMT
//STEP10   EXEC PROCABC,                                                                             PROCABC
//             DSN='TEST.FILE',                                                                             PROCABC                        
//STEP40   EXEC PROC123                                                                               PROC123
//             DSN1=INPUT.FILE1,                                                                          PROC123
//             DSN2=OUTPUT.FILE.BKP(+1),                                                           PROC123          
//             LRECL=800,                                                                                            PROC123                                                                      
//*********************************************************  
 

Now I have some additional requirements for this:-
If ProcABC is the PROC occurring after PROCXYZ, then even this needs to be comment out.
NOTE- Proc ABC occurs a lot many times , and so we have the condition that it should be the one occurring after ProcXYZ.

So, now I require a logic which can handle multiple begin and end records.

Expected Output:-
//******************************************************************
1-----------------------------------------------------------------------------------------80-81-82-83
//*STEP05   EXEC PROCXYZ,                                                                                CMT                                                                              
// *             MEMA=ABCD123,                                                                             CMT
// *            MEMBER=XYZ123,                                                                              CMT
//*STEP10   EXEC PROCABC,                                                                              PROCABC
//*            DSN='TEST.FILE',                                                                                 PROCABC                        
//STEP40   EXEC PROC123                                                                                   PROC123
//             DSN1=INPUT.FILE1,                                                                              PROC123
//             DSN2=OUTPUT.FILE.BKP(+1),                                                             PROC123          
//             LRECL=800,                                                                                            PROC123                                                                      
//*********************************************************  
 


Can you please help me out with this.

RE CODE' d

Re: How to include when=group with multiple start and end re

PostPosted: Fri Nov 25, 2016 12:28 pm
by BillyBoyo
Still no time for a detailed look, but a few pointers.

You can only know the end of a JCL statement (because it can be on multiple lines) by identifying the start of another. So you use "next jcl statement" as your END, and then test with IFTHEN=(WHEN=(logicalexpression) for the same "end" to not include that as part of the group.

If you have two groups, the second of which depends on the first for its existence, to define the second group, use a "flag" set for the first.

A general note on parsing JCL (probably doesn't affect you, as you can get everything from the first few bytes) - inline comments can... cause problems... you up.