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

Support for NetApp SyncSort for z/OS, Visual SyncSort, SYNCINIT, SYNCLIST and SYNCTOOL
Surabhi
Posts: 49
Joined: Thu Sep 10, 2015 7:51 pm
Skillset: jcl
Referer: internet

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

Postby Surabhi » Wed Nov 23, 2016 3:05 pm

Hi all,

I have a requirement of including a group with multiple start and end.
Example:-

Code: Select all

//abc
//abc
//xyz
//xyz
//123
//lmn
//156
 

Code: Select all

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:-

Code: Select all

//*abc
//*abc
//*xyz
//*xyz
//123
//lmn
//156
 

Can anyone help me with this.

Thank you.

CODE' d

BillyBoyo
Global moderator
Posts: 3805
Joined: Tue Jan 25, 2011 12:02 am
Skillset: Easytrieve Plus, Cobol, Utilities, that sort of stuff
Referer: Google

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

Postby BillyBoyo » Thu Nov 24, 2016 12:07 pm

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.

Surabhi
Posts: 49
Joined: Thu Sep 10, 2015 7:51 pm
Skillset: jcl
Referer: internet

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

Postby Surabhi » Thu Nov 24, 2016 1:36 pm

Hi,

I tried using the below logic but its not working:-

Code: Select all

//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:-

Code: Select all

----+----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.

BillyBoyo
Global moderator
Posts: 3805
Joined: Tue Jan 25, 2011 12:02 am
Skillset: Easytrieve Plus, Cobol, Utilities, that sort of stuff
Referer: Google

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

Postby BillyBoyo » Thu Nov 24, 2016 5:15 pm

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.

Surabhi
Posts: 49
Joined: Thu Sep 10, 2015 7:51 pm
Skillset: jcl
Referer: internet

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

Postby Surabhi » Thu Nov 24, 2016 6:11 pm

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:-

Code: Select all

//******************************************************************
//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:-

Code: Select all

//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:-

Code: Select all

//******************************************************************
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:-

Code: Select all

//******************************************************************
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

BillyBoyo
Global moderator
Posts: 3805
Joined: Tue Jan 25, 2011 12:02 am
Skillset: Easytrieve Plus, Cobol, Utilities, that sort of stuff
Referer: Google

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

Postby BillyBoyo » Fri Nov 25, 2016 12:28 pm

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.


  • Similar Topics
    Replies
    Views
    Last post