MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

DFSORT to update Gregorian date from a vsam file

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
Magesh_J
Intermediate


Joined: 21 Jun 2014
Posts: 259
Topics: 54

PostPosted: Fri Jul 11, 2014 10:31 am    Post subject: DFSORT to update Gregorian date from a vsam file Reply with quote

Input fILE
Code:

---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8-
AAaaaa                                                               
BBBBBB
cd qqqqqq\qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq1
PUT  'ZZZ.ZZZ.ZZZZZZZZ.ZZZZ.ZZZZ'         DDUMMY_@.data                 
QUIT


I need to update this FTP control card with a Gregorian date from another vsam file which has Julian date in Packed.

VSAM File - to refer
Code:

Field1
4/PS           
(434-437)       
52--------------
****************
          214191


output

Code:

---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8-
AAaaaa                                                               
BBBBBB
cd qqqqqq\qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq1
PUT  'ZZZ.ZZZ.ZZZZZZZZ.ZZZZ.ZZZZ'         DDUMMY_07102014.data                 
QUIT



I wrote below code, but it looks very complex, is there any easy way to achive this.

Code:


//SYSIN    DD *                                       
  JOINKEYS FILE=F1,FIELDS=(80,1,A)                   
  JOINKEYS FILE=F2,STOPAFT=1,FIELDS=(1,1,A)           
  REFORMAT FIELDS=(F1:1,80,F2:2,5)                   
  OPTION COPY                                         
  OUTFIL IFTHEN=(WHEN=(1,3,CH,EQ,C'PUT'),             
         BUILD=(1,49,81,5,Y2T,TOGREG=Y4W,51,25)),     
         IFTHEN=(WHEN=NONE,BUILD=(1,80))             
//JNF2CNTL DD *                                       
  INREC BUILD=(1:C' ',434,4,PD,TO=ZD,LENGTH=5)       
//*                                                   
//JNF1CNTL DD *                                       
   INREC BUILD=(1,79,80:C' ')                         
/*                                                   



Thanks
Magesh
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Fri Jul 11, 2014 12:04 pm    Post subject: Reply with quote

Magesh_J,

What kind of date is 214191? Does the vsam file has just 1 date record?

Btw you don't need Joinkeys to do get the desired results and you are simply wasting resources as you just need a COPY operation instead of SORT operation.
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Magesh_J
Intermediate


Joined: 21 Jun 2014
Posts: 259
Topics: 54

PostPosted: Fri Jul 11, 2014 12:32 pm    Post subject: Reply with quote

Hi kolusu,

Vsam file has many lines of records..
We need to pickup the first record..
Its a julian date in comp 3. we need to convert to gregorian date.

Thanks

Magesh
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Fri Jul 11, 2014 1:02 pm    Post subject: Reply with quote

Magesh_J wrote:
Hi kolusu,

Vsam file has many lines of records..
We need to pickup the first record..
Its a julian date in comp 3. we need to convert to gregorian date.

Thanks

Magesh


Magesh_J,

you are merely wasting resources when you just need the first record with Joinkeys approach

What is the format of julian date? Y4U - P'ccyyddd' ?
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Fri Jul 11, 2014 1:44 pm    Post subject: Reply with quote

Assuming your julian date is the format of P'CCYYDDD' use the following jcl

Code:

//STEP0100 EXEC PGM=SORT,PARM='VSAMEMT=YES'                             
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD DISP=SHR,DSN=Your input vsam file                             
//SORTOUT  DD DSN=&&S,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE)               
//SYSIN    DD *                                                         
  OPTION COPY,STOPAFT=1,NULLOUT=RC4                                     
  RECORD TYPE=F                                                         
  INREC BUILD=(C'RPTDATE,C''',                                         
               C'_',434,4,Y4U,TOGREG=Y4W,C'.DATA''',80:X)               
//*                                                                     
//STEP0200 EXEC PGM=SORT,COND=(4,EQ,STEP0100)                           
//SYSOUT   DD SYSOUT=*                                                 
//SYMNOUT  DD SYSOUT=*                                                 
//SYMNAMES DD DISP=SHR,DSN=&&S                                         
//SORTIN   DD *                                                         
AAAAAA                                                                 
BBBBBB                                                                 
CD                                                                     
QQQQQQ\QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ
Q1                                                                     
PUT  'ZZZ.ZZZ.ZZZZZZZZ.ZZZZ.ZZZZ'         DDUMMY_@.DATA                 
QUIT                                                                   
//SORTOUT  DD SYSOUT=*                                                 
//SYSIN    DD *                                                         
  OPTION COPY                                                           
  INREC FINDREP=(IN=C'_@.DATA',OUT=RPTDATE)                             
//*

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Magesh_J
Intermediate


Joined: 21 Jun 2014
Posts: 259
Topics: 54

PostPosted: Sat Jul 12, 2014 1:50 am    Post subject: Reply with quote

Hi Kolusu,

Thanks for the solution, but the date format is 'cyyddd'. Not sure what is the format in dfsort for cyyddd.

Here is the Julian format below and later it is moved to s9(07) comp-3 variable.

Code:

01  JULIAN                  PIC 9(6).         
01  JULIANX             REDEFINES   JULIAN.   
    05  JUL-CYR             PIC 999.         
    05  FILLER            REDEFINES  JUL-CYR.
        10  JUL-C           PIC 9.           
        10  JUL-YR          PIC 99.           
    05  JUL-DA              PIC 999.         


Thanks
Magesh
Back to top
View user's profile Send private message
Magesh_J
Intermediate


Joined: 21 Jun 2014
Posts: 259
Topics: 54

PostPosted: Sat Jul 12, 2014 2:05 am    Post subject: Reply with quote

Kolusu,


Date is changing properly, but it is displaying as below

Code:

DDUMMY_07110214.DATA


Expected is
Code:

DDUMMY_07112014.DATA


it is taking 02 instead of 20 Sad

Thanks
Magesh
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Sat Jul 12, 2014 8:48 pm    Post subject: Reply with quote

Magesh_J wrote:
Thanks for the solution, but the date format is 'cyyddd'. Not sure what is the format in dfsort for cyyddd.

Here is the Julian format below and later it is moved to s9(07) comp-3 variable.


Magesh_J,

You could have used the DT1 format which is a 4-byte SMF date value in the form P'cyyddd' (X'0cyydddF') is converted to a Z'yyyymmdd' value. However c = 0 will be transformed to 19 and C = 1 will be transformed to 20 and any thing greater than 1 will be transformed to 21.

In your case you have 2 which would make the date as 2114 instead of 2014. I am not sure as to how you arrived at having 2 as the century.

Anyway here is an untested version of step0100 control cards. I assumed that you always have a CC of 20 for the dates. If you have some other format we have to deal it separately.

Code:

//SYSIN    DD *                                                 
  OPTION COPY,STOPAFT=1,NULLOUT=RC4                             
  RECORD TYPE=F                                                 
  INREC BUILD=(C'20',434,4,PD,EDIT=(TTTTT))                     
  OUTREC BUILD=(C'RPTDATE,C''',                                 
                C'_',1,7,Y4T,TOGREG=Y4W,C'.DATA''',80:X)       
//*

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Magesh_J
Intermediate


Joined: 21 Jun 2014
Posts: 259
Topics: 54

PostPosted: Mon Jul 14, 2014 10:54 am    Post subject: Reply with quote

Hi Kolusu,

Awesome solution !!! worked like a charm...Thank you very much..

Quote:

I am not sure as to how you arrived at having 2 as the century.


Me too had a same doubt... what to do..we have to live with this design Sad

But any way, Your soultion will work for another 84 Years and 5 months and 17 days Wink
Which is more than sufficient.

Thanks
Magesh
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Mon Jul 14, 2014 11:58 am    Post subject: Reply with quote

Magesh_J wrote:
Hi Kolusu,

Awesome solution !!! worked like a charm...Thank you very much..


Notice that the FINDREP step will NOT run if the VSAM file is empty. So you should have the same code checking on the FTP step too which uses the control cards.

Magesh_J wrote:
But any way, Your soultion will work for another 84 Years and 5 months and 17 days Wink Which is more than sufficient.


Slight correction, It is 85 years 5 Months and 18 days to 2100-01-01
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group