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 

Update existing record w/multiple totals.

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


Joined: 18 Apr 2016
Posts: 47
Topics: 15

PostPosted: Wed Apr 20, 2016 9:43 am    Post subject: Update existing record w/multiple totals. Reply with quote

Hello, I'd appreciate someone's help to find a solution.

There's a flat file, FB, LRECL=341.
File has 1 header record followed by data records.
Header record is identified by '9' in position 1, and besides other data, has 3 totals.
1.Total number of recs, excluding header = pos 20, x(9).
2.Total number of balanced accounts (space in pos 23 of data record) = pos 30, x(9).
3.Total number of unbalanced accounts (value other that space in pos 23 of data record) = pos 39, x(9).

Header record before update:
Code:

9ASSETPRIM562C7B9MJ0000000000000000000000000000xxxxxxxxxxxxxxxxxxxxxxx


Data records:
Code:

122000002akored0050892A25578119012  <== unbalanced account
122000006llopse0090732 05500942012  <== balanced account
122000006mkerri0091562 15090909028  <== balanced account

Need to update all 3 totals on header record and keep the rest of header unchanged.
Order of records on file should remain unchanged.

Header record AFTER update:
Code:

9ASSETPRIM562C7B9MJ0000000003000000002000000001xxxxxxxxxxxxxxxxxxxxxxx
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: Wed Apr 20, 2016 10:33 am    Post subject: Reply with quote

ramy2016,

How do you distinguish between a Balanced account and unbalanced account?
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ramy2016
Beginner


Joined: 18 Apr 2016
Posts: 47
Topics: 15

PostPosted: Wed Apr 20, 2016 11:19 am    Post subject: Reply with quote

kolusu

balanced accounts (space in pos 23 of data record)
unbalanced accounts (value other that space in pos 23 of data record)
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: Wed Apr 20, 2016 12:30 pm    Post subject: Reply with quote

ramy2016,

Use the following JCL to get the desired results. Btw your position for total record is off. I think it should start at 21 instead of 20 which you show.

Code:

//******************************************************************
//* GENERATE SYMBOLS FOR TOTAL RECORDS, BALANCED RECORD COUNT AND  *
//* UNBALANCED RECORD COUNT                                        *
//******************************************************************
//STEP0100 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD DISP=SHR,DSN=Your Input 341 lrecl file
//SORTOUT  DD DSN=&&S,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE)             
//SYSIN    DD *                                                       
  OPTION COPY                                                         
  OMIT COND=(1,1,CH,EQ,C'9')                       
                 
  INREC BUILD=(23,1,CHANGE=(1,C' ',C'1'),NOMATCH=(C'0'),             
               23,1,CHANGE=(1,C' ',C'0'),NOMATCH=(C'1'))             
                                                                     
  OUTFIL REMOVECC,NODETAIL,BUILD=(80X),                               
  TRAILER1=('TOT-COUNT,C''',COUNT=(M11,LENGTH=9),'''',/,             
            'BLN-COUNT,C''',TOT=(1,1,ZD,M11,LENGTH=9),'''',/,         
            'UBL-COUNT,C''',TOT=(2,1,ZD,M11,LENGTH=9),'''')           
//*
//******************************************************************
//* USE THE SYMBOLS FROM THE PREVIOUS STEP AND UPDATE THE HEADER   *
//* RECORD.                                                        *
//******************************************************************
//STEP0200 EXEC PGM=SORT       
//SYSOUT   DD SYSOUT=*         
//SYMNAMES DD DISP=SHR,DSN=&&S 
//SYMNOUT  DD SYSOUT=*
//SORTIN   DD DISP=SHR,DSN=Your Input 341 lrecl file
//SORTOUT  DD SYSOUT=*                         
//SYSIN    DD *                                 
  OPTION COPY                                   
  INREC IFTHEN=(WHEN=(1,1,CH,EQ,C'9'),         
       OVERLAY=(21:TOT-COUNT,                   
                30:BLN-COUNT,                   
                39:UBL-COUNT))                 
//*

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


Joined: 18 Apr 2016
Posts: 47
Topics: 15

PostPosted: Wed Apr 20, 2016 2:24 pm    Post subject: Reply with quote

kolusu, thank you.
The step0100 works like a charm, but step0200 from what I can see, just creates updated header in the step sortout, but the header on the file is not updated.
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: Wed Apr 20, 2016 2:30 pm    Post subject: Reply with quote

ramy2016 wrote:
kolusu, thank you.
The step0100 works like a charm, but step0200 from what I can see, just creates updated header in the step sortout, but the header on the file is not updated.


Do you want to update the existing dataset? If so you need to do it differently
_________________
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: Wed Apr 20, 2016 2:51 pm    Post subject: Reply with quote

ramy2016,

If you want to update existing dataset you need to make a copy of the existing dataset and then over write it.

use the following JCL

Code:

//******************************************************************
//* GENERATE SYMBOLS FOR TOTAL RECORDS, BALANCED RECORD COUNT AND  *
//* UNBALANCED RECORD COUNT AND COPY THE INPUT AS IS TO TEMP DSN   *
//******************************************************************
//STEP0100 EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD DISP=SHR,DSN=Your Input FB 341 file
//SORTOUT  DD DSN=&&S,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE)           
//DATA     DD DSN=&&D,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)           
//SYSIN    DD *                                                     
  OPTION COPY                                                       
  INREC OVERLAY=(342:23,1,CHANGE=(1,C' ',C'1'),NOMATCH=(C'0'),     
                 343:23,1,CHANGE=(1,C' ',C'0'),NOMATCH=(C'1'),     
                 342:01,1,CHANGE=(1,C'9',C'0'),NOMATCH=(342,1),     
                 343:01,1,CHANGE=(1,C'9',C'0'),NOMATCH=(343,1))     
                                                                   
  OUTFIL REMOVECC,NODETAIL,BUILD=(80X),                             
  TRAILER1=('TOT-COUNT,C''',COUNT-1=(M11,LENGTH=9),'''',/,         
            'BLN-COUNT,C''',TOT=(342,1,ZD,M11,LENGTH=9),'''',/,     
            'UBL-COUNT,C''',TOT=(343,1,ZD,M11,LENGTH=9),'''')       
                                                                   
  OUTFIL FNAMES=DATA,BUILD=(1,341)                                 
//*                                               
//******************************************************************
//* USE THE SYMBOLS FROM THE PREVIOUS STEP AND UPDATE THE HEADER   *
//* RECORD  AND OVERWRITE THE EXISTING DATASET WITH TEMP DSN DATA  *
//******************************************************************
//STEP0200 EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//SYMNAMES DD DISP=SHR,DSN=&&S                                     
//SYMNOUT  DD SYSOUT=*                                             
//SORTIN   DD DISP=SHR,DSN=&D                                       
//SORTOUT  DD DISP=OLD,DSN=Your existing input FB 341 file
//SYSIN    DD *                                                     
  OPTION COPY                                                       
  INREC IFTHEN=(WHEN=(1,1,CH,EQ,C'9'),                             
       OVERLAY=(21:TOT-COUNT,                                       
                30:BLN-COUNT,                                       
                39:UBL-COUNT))                                     
//*

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


Joined: 18 Apr 2016
Posts: 47
Topics: 15

PostPosted: Wed Apr 20, 2016 4:10 pm    Post subject: Reply with quote

Almost there Very Happy
The UBL-COUNT calculates number of unbalanced + 1.
Could that be related to TOT-COUNT also having an extra count, but you even it out by COUNT-1 before storing?
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: Wed Apr 20, 2016 6:32 pm    Post subject: Reply with quote

ramy2016 wrote:
Almost there Very Happy
The UBL-COUNT calculates number of unbalanced + 1.
Could that be related to TOT-COUNT also having an extra count, but you even it out by COUNT-1 before storing?


Ramy2016,

I am not sure if you had noticed that I have made changes to STEP0100 Control cards(4 CHANGE statements vs 2 Change Statements) for accounting the record header record.

Show me your complete sysout
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ramy2016
Beginner


Joined: 18 Apr 2016
Posts: 47
Topics: 15

PostPosted: Thu Apr 21, 2016 9:25 am    Post subject: Reply with quote

kolusu,
yes, I noticed that change.
The issue was elsewhere, not related to the sort.
Found it, fixed it.
Thanks for your assistance.
Back to top
View user's profile Send private message
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