IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Identify the count from two diffrent file and execute steps


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
UmashankarSubramani

New User


Joined: 11 Jul 2020
Posts: 8
Location: US

PostPosted: Sat Jul 11, 2020 4:35 am
Reply with quote

Hello Friends,

I got one requirement and able to write a code in cobol.

But, It would be great if I able to get this in sort card in Jcl. Can someone please help me in this?
Here are my Requirement is

InputFile:( header record has sequence number)
FHR00000001P08KGAE1617XXV0000291862020071014161700000000

CountFile(Contains Expected next Sequence Number):
00002918

I need to read the InputFile and check the sequence number from CountFile and update the CountFile as per below scenarios and conditions and execute new step.

Execution| CountFile| InputFile| Conditions | CountFile(To be updated) | NewStep(to be executed)
Execution1 | 00002918 | 00002918 | InputFile = CountFile | 00002919 (Incremented by 1 from Input file count) | No
Execution2 | 00002919 | 00002919 | InputFile = CountFile | 00002920 (Incremented by 1 from Input file count) | No
Execution3 | 00002920 | 00002922 | InputFile > CountFile | 00002923 (Incremented by 1 from Input file count) | Yes
Execution4 | 00002923 | 00002920 | InputFile < CountFile | 00002923 (No Increment,same from Input file count) | No
Execution5 | 00002923 | 00002923 | InputFile = CountFile | 00002924 (Incremented by 1 from Input file count) | No
Execution6 | 00002924 | 00002921 | InputFile < CountFile | 00002924 (No Increment,same from Input file count) | No
Execution7 | 00002924 | 00002924 | InputFile = CountFile | 00002925 (Incremented by 1 from Input file count) | No
Execution8 | 00002925 | 00002926 | InputFile > CountFile | 00002927 (Incremented by 1 from Input file count) | Yes


can someone help to get this via JCL sort utility?
Back to top
View user's profile Send private message
UmashankarSubramani

New User


Joined: 11 Jul 2020
Posts: 8
Location: US

PostPosted: Sat Jul 11, 2020 9:19 am
Reply with quote

FHR00000001P08KGAE1617XXV0000291862020071014161700000000

Highlighted is the sequence number position in Input file.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1222
Location: Bamberg, Germany

PostPosted: Sat Jul 11, 2020 12:36 pm
Reply with quote

Your highlighted sequence is too long (9 instead of 8 digits). Also you can not do this in JCL but w/ a SORT utility.

Sample:
Code:
//UPDATE   EXEC PGM=ICEMAN                         
//SORTIN   DD DISP=OLD,DSN=&SYSUID..INPUT <* FB;80               
//         DD DISP=OLD,DSN=&SYSUID..COUNT <* FB;80               
//SORTOUT  DD DISP=OLD,DSN=&SYSUID..COUNT <* FB;80               
//NEEDSUPD DD DUMMY                                             
//SYSOUT   DD SYSOUT=*                                           
//SYSIN    DD *                                                 
  OPTION COPY,EQUALS                                             
  INREC IFTHEN=(WHEN=GROUP,                                     
    BEGIN=(1,3,CH,EQ,C'FHR'),PUSH=(57:SEQ=1,58:26,8),RECORDS=2),
    IFTHEN=(WHEN=(57,1,ZD,EQ,+2,AND,(1,8,ZD,EQ,58,8,ZD)),       
      OVERLAY=(10:58,8,ZD,ADD,+1,M11,LENGTH=8)),                 
    IFTHEN=(WHEN=(57,1,ZD,EQ,+2,AND,(1,8,ZD,LT,58,8,ZD)),       
      OVERLAY=(10:58,8,ZD,ADD,+1,M11,LENGTH=8)),                 
    IFTHEN=(WHEN=(57,1,ZD,EQ,+2,AND,(1,8,ZD,GT,58,8,ZD)),       
      OVERLAY=(10:1,8))                                         
  OUTFIL FNAMES=(SORTOUT),                                       
    INCLUDE=(57,1,ZD,EQ,+2),                                     
    REMOVECC,                                                   
    BUILD=(10,8,72X)                                             
  OUTFIL FNAMES=(NEEDSUPD),                                     
    INCLUDE=(57,1,ZD,EQ,+2,AND,1,8,ZD,GE,58,8,ZD),               
    REMOVECC,NULLOFL=RC4,                                       
    BUILD=(10,8,72X)                                             
/*

It will return RC4 as indicator for NewStep to be run.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1222
Location: Bamberg, Germany

PostPosted: Sat Jul 11, 2020 5:59 pm
Reply with quote

Count DSN (sample):
Code:
****** *********
000001 00002925
****** *********

Input DSN (sample):
Code:
****** **************************** Datenanfang *******************
000001 FHR00000001P08KGAE1617XXV0000292662020071014161700000000   
****** **************************** Datenende *********************

Sample Code:
Code:
//UPDATE0  EXEC PGM=ICEMAN                                       
//SORTIN   DD DISP=OLD,DSN=&SYSUID..COUNT <* FB;80               
//         DD DISP=OLD,DSN=&SYSUID..INPUT <* FB;80               
//SORTOUT  DD DISP=OLD,DSN=&SYSUID..COUNT <* FB;80               
//NEEDSUPD DD DUMMY                                               
//SYSOUT   DD SYSOUT=*                                           
//SYSIN    DD *                                                   
  OPTION COPY,EQUALS,STOPAFT=2                                   
  INREC IFTHEN=(WHEN=GROUP,                                       
    BEGIN=(1,8,CSF,EQ,NUM),PUSH=(57:SEQ=1,58:1,8)),     
    IFTHEN=(WHEN=(57,1,ZD,EQ,+2,AND,(26,8,ZD,EQ,58,8,ZD)),       
      OVERLAY=(58:26,8,ZD,ADD,+1,M11,LENGTH=8)),                 
    IFTHEN=(WHEN=(57,1,ZD,EQ,+2,AND,(26,8,ZD,GT,58,8,ZD)),       
      OVERLAY=(57:+9,ZD,LENGTH=1,58:26,8,ZD,ADD,+1,M11,LENGTH=8))
  OUTFIL FNAMES=(SORTOUT),                                       
    INCLUDE=(57,1,ZD,GE,+2),                                     
    REMOVECC,BUILD=(58,8,72X)                                     
  OUTFIL FNAMES=(NEEDSUPD),                                       
    INCLUDE=(57,1,ZD,EQ,+2),                                     
    REMOVECC,NULLOFL=RC4,BUILD=(58,8,72X)                         
  END                                                             
/*
Back to top
View user's profile Send private message
UmashankarSubramani

New User


Joined: 11 Jul 2020
Posts: 8
Location: US

PostPosted: Mon Jul 13, 2020 2:51 am
Reply with quote

Hi Joe, Thank you Very Much.

And I am unable to execute and I checked with our team and it seems like I can't use ICEMAN.
However, I can use ICETOOL and SORT utility.

Q1. Is there a way to acheive it using ICETOOL or SORT?


And Input file has more records (Header, Body and Trailer Records).
I need to use take the sequence number from Header record only.
InputFile:( header record has sequence number with 9 digits starts from 26th position to 35th Position.)
Code:
FHR00000001P08KGAE1617XXV0000291862020071014161700000000
TBMbg99999999999999999999999999999                       
TBLbg99999999999999999999999999999
HDR878970   


CountFile(Contains only Expected next Sequence Number):
Code:
000002918



Execution| CountFile| InputFile| Conditions | CountFile(To be updated) | NewStep(to be executed)
Execution1 | 000002918 | 000002918 | InputFile = CountFile | 000002919 (Incremented by 1 from Input file count) | No
Execution2 | 000002919 | 000002919 | InputFile = CountFile | 000002920 (Incremented by 1 from Input file count) | No
Execution3 | 000002920 | 000002922 | InputFile > CountFile | 000002923 (Incremented by 1 from Input file count) | Yes
Execution4 | 000002923 | 000002920 | InputFile < CountFile | 000002923 (No Increment,same from Input file count) | No
Execution5 | 000002923 | 000002923 | InputFile = CountFile | 000002924 (Incremented by 1 from Input file count) | No
Execution6 | 000002924 | 000002921 | InputFile < CountFile | 000002924 (No Increment,same from Input file count) | No
Execution7 | 000002924 | 000002924 | InputFile = CountFile | 000002925 (Incremented by 1 from Input file count) | No
Execution8 | 000002925 | 000002926 | InputFile > CountFile | 000002927 (Incremented by 1 from Input file count) | Yes


I have three conditions
InputFile = CountFile
InputFile < CountFile
InputFile > CountFile

Can you please help in this?
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1222
Location: Bamberg, Germany

PostPosted: Mon Jul 13, 2020 3:16 am
Reply with quote

Replace EXEC PGM=ICEMAN with EXEC PGM=SORT and make sure you use the second Sample I have posted. I put that one also Online because I was thinking about the HDR/Data/TRL scenario as a possible one too. icon_wink.gif
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1222
Location: Bamberg, Germany

PostPosted: Mon Jul 13, 2020 3:52 am
Reply with quote

Something is wrong with your given offsets, please check. Your header has 4 leading zeros, count has 5 and the last digit at the end is cut.
Code:
****** **************************** Datenanfang *******************
=COLS> ----+----1----+----2----+vvvvvvvvv+----4----+----5----+----6
000001 FHR00000001P08KGAE1617XXV0000291862020071014161700000000   
000002 TBMbg99999999999999999999999999999                         
000003 TBLbg99999999999999999999999999999                         
000004 HDR878970                                                   
****** **************************** Datenende *********************

Code:
****** ***************
=COLS> vvvvvvvvv1----+
000001 000002918     
****** ***************
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2010
Location: USA

PostPosted: Mon Jul 13, 2020 5:37 pm
Reply with quote

UmashankarSubramani wrote:
But, It would be great if I able to get this in sort card in Jcl.

There is no such thing as "sort card in Jcl", or even as "SORT card in JCL"!

"SORT card" is actually one of multiple control statements of one of SORT utilities (mainly two of them, the most popular ones); those utilities have no more relation to JCL language than any other executable program (load module) in the mainframe world.

Even more: the control statement SORT of a SORT utility can do very little without other multiple control statements of the same SORT utilities.

It is important to use the exact terminology when discussing or questioning such issues.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Tue Jul 14, 2020 1:13 am
Reply with quote

Welcome!!
If this step gives you RC-4 then execute next step else No. Either case the CFIL will have the count that you looking for and use the same file as SORTJNF1. Ignore SDUMMY as its is just to control the RC.

Code:
//S1    EXEC  PGM=SORT                                                 
//SORTLIST  DD  SYSOUT=*                                               
//SYSOUT    DD  SYSOUT=*                                               
//SORTJNF1 DD *                                                         
00002927                                                               
//SORTJNF2 DD *                                                         
FHR00000001P08KGAE1617XXV0000292262020071014161700000000               
TBMbg99999999999999999999999999999                                     
TBLbg99999999999999999999999999999                                     
HDR878970                                                               
//CFIL     DD  SYSOUT=*                                                 
//SDUMMY   DD  SYSOUT=*                                                 
//SYSIN  DD *                                                           
  OPTION COPY                                                           
  JOINKEYS FILE=F1,FIELDS=(81,1,A),SORTED,NOSEQCK                       
  JOINKEYS FILE=F2,FIELDS=(81,1,A),SORTED,NOSEQCK                       
  JOIN UNPAIRED,F1,F2                                                   
  REFORMAT FIELDS=(F1:1,8,F2:26,8)                                     
  OUTREC IFTHEN=(WHEN=(1,8,ZD,EQ,9,8,ZD),                               
                 OVERLAY=(82:9,8,ZD,ADD,+1,TO=ZDF,LENGTH=8,100:C'N')), 
         IFTHEN=(WHEN=(1,8,ZD,GT,9,8,ZD),                               
                 OVERLAY=(82:1,8,ZD,EDIT=(TTTTTTTT),100:C'N')),         
         IFTHEN=(WHEN=(1,8,ZD,LT,9,8,ZD),                               
                 OVERLAY=(82:9,8,ZD,ADD,+1,TO=ZDF,LENGTH=8,100:C'Y'))   
  OUTFIL FNAMES=CFIL,REMOVECC,BUILD=(82,8)                             
  OUTFIL FNAMES=SDUMMY,REMOVECC,                                       
                       BUILD=(82,8),                                   
                       OMIT=(100,1,CH,EQ,C'Y'),                         
                       NULLOFL=RC4                                     
//JNF2CNTL DD  *                                                       
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:C'1'))                           
  INCLUDE COND=(1,03,CH,EQ,C'FHR')                                     
//JNF1CNTL DD  *                                                       
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:C'1'))     
Back to top
View user's profile Send private message
UmashankarSubramani

New User


Joined: 11 Jul 2020
Posts: 8
Location: US

PostPosted: Wed Jul 15, 2020 9:01 am
Reply with quote

Hi Joe, Thank you Very Much.

I can able to execute the code.
But our upstream system has changed the requirement and design also modified.

I apologize for this.

New requirement is

And Input file has more records (Header, Body and Trailer Records).
I need to use take the sequence number from Header record only.
InputFile:( header record has sequence number with 9 digits starts from 26th position to 35th Position.)

Code:
FHR00000001P08KGAE1617XXV0000029182020071014161700000000
TBMbg99999999999999999999999999999                       
TBLbg99999999999999999999999999999
HDR878970 

Seq number starts from position 26 to 34

CountFile(+0)(gdg):

Code:
EXPECTED GMDL SEQNUM:000002918,ACTUAL GMDL SEQNUM:000002917


EXPECTED GMDL SEQNUM starts from the position 22 to 30
ACTUAL GMDL SEQNUM starts from the position 51 to 59

CountFile(+1) (Gdg) same file as (+0):
Code:
EXPECTED GMDL SEQNUM:000002919,ACTUAL GMDL SEQNUM:000002918



Read the latest GDG(+0) and get the EXPECTED GMDL SEQNUM and update the expected and actual seq num in countfile(+1) as per below condition

Execution|CountFile(+0) Expected,Actual|InputFile|Conditions|CountFile(+1)(Both Seq Expected,Actual to be updated)|NewStep(to be executed)
Execution1|000002918,000002917|000002918|InputFile = CountFile |000002919,000002918 | No
Execution2|000002919,000002918|000002919|InputFile = CountFile |000002920,000002919 | No
Execution3|000002920,000002919|000002922|InputFile > CountFile |000002923,000002922 | Yes
Execution4|000002923,000002922|000002920|InputFile < CountFile |000002923,000002920 | No
Execution5|000002923,000002920|000002923|InputFile = CountFile |000002924,000002923 | No
Execution6|000002924,000002923|000002921|InputFile < CountFile |000002924,000002921 | No
Execution7|000002924,000002921|000002924|InputFile = CountFile |000002925,000002924 | No
Execution8|000002925,000002924|000002926|InputFile > CountFile |000002927,000002926 | Yes

Can you please help me in this?
Back to top
View user's profile Send private message
UmashankarSubramani

New User


Joined: 11 Jul 2020
Posts: 8
Location: US

PostPosted: Wed Jul 15, 2020 4:00 pm
Reply with quote

Hi , Can someone please help me?
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2010
Location: USA

PostPosted: Wed Jul 15, 2020 4:38 pm
Reply with quote

UmashankarSubramani wrote:
Hi , Can someone please help me?

It looks like you've received a very good help in previous responses. The given ideas are supposed to force you begin thinking with your own mind, instead of begging new charity after you've got "a new requirement" from your management, isn't it?

This forum is mainly not to do other people's job free of charge, but rather to teach them: HOW TO THINK WITH THEIR OWN BRAINS.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Wed Jul 15, 2020 4:45 pm
Reply with quote

Who is this 'Joe' that you keep thanking? The nearest name to that is 'Joerg'. Please be polite and use the name that the poster uses.
Back to top
View user's profile Send private message
UmashankarSubramani

New User


Joined: 11 Jul 2020
Posts: 8
Location: US

PostPosted: Wed Jul 15, 2020 5:03 pm
Reply with quote

Hello Mr.sergeyken/ Mr.Nic,
First, I would like to apologize for addressing in short name.

Yes, I tried the solution given by Mr. Joerg and modified the code as per actual input file.

Code:
//PS026    EXEC PGM=SORT                                               
//SORTIN   DD DISP=OLD,DSN=EXPECTED.SEQNUM         
//         DD DISP=SHR,DSN=CURRENT.SEQNUM         
//SORTOUT  DD DISP=OLD,DSN=EXPECTED.SEQNUM         
//SETRC4   DD DUMMY                                                   
//SYSOUT   DD SYSOUT=*                                                 
//SYSIN DD *                                                           
    OPTION COPY,EQUALS,STOPAFT=2                                       
    INREC IFTHEN=(WHEN=GROUP,                                         
    BEGIN=(1,8,CSF,EQ,NUM),PUSH=(57:SEQ=1,58:1,9)),                   
    IFTHEN=(WHEN=(57,1,ZD,EQ,+2,AND,(26,9,ZD,EQ,58,9,ZD)),             
          OVERLAY=(58:26,9,ZD,ADD,+1,M11,LENGTH=9)),                   
    IFTHEN=(WHEN=(57,1,ZD,EQ,+2,AND,(26,9,ZD,GT,58,9,ZD)),             
          OVERLAY=(57:+9,ZD,LENGTH=1,58:26,9,ZD,ADD,+1,M11,LENGTH=9)) 
      OUTFIL FNAMES=(SORTOUT),                                         
      INCLUDE=(57,1,ZD,GE,+2),                                         
      REMOVECC,BUILD=(58,9,71X)                                       
      OUTFIL FNAMES=(SETRC4),                                         
      INCLUDE=(57,1,ZD,EQ,+2),                                         
      REMOVECC,NULLOFL=RC4,BUILD=(58,9,71X)                           
      END                                                             
/*             


I never used SORT utility.

So I have executed line by line and understood the code.

I can see PUSH=(57:SEQ=1,58:1,9)),
this code pulls the data from the same record.

However, after the requirement change, I need to pull the first record in the second line also where we are adding the key field 2 and 9.
But Not sure how to to acheive this.

Thats why I posted again.

I will go thru some more posts in this forum and understand the SORT functionality and respective commands and try to solve this.

I apologize once again for the inconvenience caused.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2010
Location: USA

PostPosted: Wed Jul 15, 2020 5:47 pm
Reply with quote

Absolute mess continues...

I give up.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Wed Jul 15, 2020 7:58 pm
Reply with quote

Sorry, but the topic should be locked.

If you can not modify even 0.01% to the working code provided above to your earlier requirement to be able to modify for the little "requirement change" then that means you must really need to start looking at the DFSORT manuals from the start before attempting anything further in DFSORT and continue with your COBOL version running until then.
Back to top
View user's profile Send private message
UmashankarSubramani

New User


Joined: 11 Jul 2020
Posts: 8
Location: US

PostPosted: Wed Jul 15, 2020 9:53 pm
Reply with quote

Hello Rohit/Sergey,

I can able to modify the code as per new requirement.

Here it is.

Code:
//PS026    EXEC PGM=SORT                                             
//SORTIN   DD DISP=OLD,DSN=EXPECTED.SEQNUM.BKP   
//         DD DISP=SHR,DSN=CURRENT.SEQNUM         
//SORTOUT  DD DISP=OLD,DSN=EXPECTED.SEQNUM.BKP1         
//SETRC4   DD DUMMY                                                                                                 
//SYSOUT   DD SYSOUT=*                                               
//SYSIN DD *                                                         
    OPTION COPY,EQUALS,STOPAFT=2                                     
    INREC IFTHEN=(WHEN=GROUP,                                         
    BEGIN=(1,8,CH,EQ,C'EXPECTED'),PUSH=(60:SEQ=1,61:22,9)),           
    IFTHEN=(WHEN=(60,1,ZD,EQ,+2,AND,(26,9,ZD,EQ,61,9,ZD)),           
          OVERLAY=(61:26,9,ZD,ADD,+1,M11,LENGTH=9)),                 
    IFTHEN=(WHEN=(60,1,ZD,EQ,+2,AND,(26,9,ZD,GT,61,9,ZD)),           
          OVERLAY=(60:+9,ZD,LENGTH=1,61:26,9,ZD,ADD,+1,M11,LENGTH=9))
      OUTFIL FNAMES=(SORTOUT),                                       
      INCLUDE=(60,1,ZD,GE,+2),                                       
      REMOVECC,BUILD=(1:C'EXPECTED GMDL SEQNUM:',22:61,9,             
                      31:C',ACTUAL GMDL SEQNUM:',51:26,9,21X)         
      OUTFIL FNAMES=(SETRC4),                                         
      INCLUDE=(60,1,ZD,EQ,+2),                                       
      REMOVECC,NULLOFL=RC4,BUILD=(1:C'EXPECTED GMDL SEQNUM:',22:61,9,
                      31:C',ACTUAL GMDL SEQNUM:',51:26,9,21X)                                             
/*


I can able to understand the code now.

Thank you very much for motivating me to get this modify by myself with the given code.

Thank you Rohit, Sergey, Joerg and Nic for the valuable input.

And again I apologize for the inconvenience caused.

can you please let me know the DFSORT manual link if you have?
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Wed Jul 15, 2020 10:07 pm
Reply with quote

Quote:
can you please let me know the DFSORT manual link if you have?


why not google Yourself with ( for example )

ibm dfsort manuals
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Thu Jul 16, 2020 3:49 am
Reply with quote

Or look at the manuals link at the very top of each page of this forum?
Back to top
View user's profile Send private message
UmashankarSubramani

New User


Joined: 11 Jul 2020
Posts: 8
Location: US

PostPosted: Thu Jul 16, 2020 6:11 am
Reply with quote

Hi Nic/Enrico, I will look into manuals. Thank you
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts To get the count of rows for every 1 ... DB2 3
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Execute secondary panel of sdsf with ... CLIST & REXX 1
No new posts Access to non cataloged VSAM file JCL & VSAM 18
Search our Forums:

Back to Top