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 

Counting & adding the amounts on the basis of sign bit.

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


Joined: 03 Nov 2021
Posts: 15
Topics: 5

PostPosted: Wed Dec 15, 2021 11:57 am    Post subject: Counting & adding the amounts on the basis of sign bit. Reply with quote

Hi Team,

I have one requirement, we have one input file (FB, LRECL-200) where we have amounts with signed bytes defined as PIC S9(11)V9(2), sign is stored in the last bit. In the file we can see them from position 4 till 16 in the detailed record.

In the below input file first record is header starting with '1' and records starting with '2' are detailed records and record starting with '3' is trailer:
Code:

120211204header
299000000000015GISTA
201000000000263IUSDB
202000000000022ROOOB
300000000000200000000000100000000000284G00000000000022R00000000000261Q

We want to create two output files on the basis of last record at position 20. If it is 'A' than write it in output FILE1 else if 'B' write in output FILE2.
But with this we need to write the header and trailers as well in both the files. Header will be same but in trailer we need to have in below layout:
Code:

First byte is '3'
12 bytes - Counts of positive amounts
12 bytes - Counts of negative amounts
15 bytes - sum of positive amounts - S9(13)V9(02)
15 bytes - sum of negative amounts -S9(13)V9(02)
15 bytes - Total amount (sum of positive and negative amts) -S9(13)V9(02)

Desired output:
Code:

File1(FB, LRECL-200):
120211204header
299000000000015GISTA
300000000000100000000000000000000000015G00000000000000000000000000015G

File2(FB, LRECL-200):
Code:

120211204header
201000000000263IUSDB
202000000000022ROOOB
300000000000100000000000100000000000263I00000000000022R000000000000241{

How can we achieve this. To identify the positive and negative records, do we need to first change it to ZD or we simply have a way in DFSORT to identify the positive and negative records from last byte.

Can anyone please suggest.

Thanks & Regards,
Srishti Rawat.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Wed Dec 15, 2021 2:26 pm    Post subject: Reply with quote

Srishti Rawat,

You need to start using code tags. I have been editing them for you. Here is an example of how to use code tags

https://www.mvsforums.com/helpboards/viewtopic.php?p=19031#19031

Now coming to the requirement , it is quite easy. Essentially your amount is ZD format which has the sign over punched. This is the representation of the ZD numbers . The number on top represents the sign overpunch and the lower number represents the readable decimal number

Code:

{ABCDEFGHI}JKLMNOPQR
CCCCCCCCCCDDDDDDDDDD
01234567890123456789


Hex C0 thru C9 are positive numbers and D0 thru D9 are negative numbers. So -5 would look as 000000000000N

Since your input field already had the sign overpunched we simply can check if it is a positive or not by checking > 0 for positive numbers and < 0 for negative numbers.

Here is an untested JCL which will give you the desired results
Code:

//STEP0100 EXEC PGM=SORT             
//SYSOUT   DD SYSOUT=*               
//SORTIN   DD DISP=SHR,DSN=your.input.fb200.file
//FILEA    DD SYSOUT=*
//FILEB    DD SYSOUT=*
//SYSIN    DD *                                                         
  OPTION COPY                                                           
  INCLUDE COND=(01,1,CH,EQ,C'1',OR,          $ HEADER                   
                20,1,SS,EQ,C'A,B')           $ A OR B RECORDS           
                                                                         
  INREC IFTHEN=(WHEN=INIT,                                               
       OVERLAY=(201:C'0',                    $ INIT POSITIVE COUNT       
                202:C'0',                    $ INIT NEGATIVE COUNT       
                204:+0,TO=ZD,LENGTH=13,      $ INIT POSITIVE TOTAL       
                220:+0,TO=ZD,LENGTH=13,      $ INIT NEGATIVE TOTAL       
                235:+0,TO=ZD,LENGTH=13)),    $ INIT FULL TOTAL           
                                                                         
        IFTHEN=(WHEN=(04,13,ZD,GT,0,AND,     $ IF VALUE > 0             
                      20,1,SS,EQ,C'A,B'),    $ AND HAS A OR B           
       OVERLAY=(201:C'1',                    $ 1 FOR POSITIVE COUNT     
                204:04,13,                   $ POSITIVE TOTAL           
                235:04,13)),                 $ FULL TOTAL               
                                                                         
        IFTHEN=(WHEN=(04,13,ZD,LT,0,AND,     $ IF VALUE < 0             
                      20,1,SS,EQ,C'A,B'),    $ AND HAS A OR B           
       OVERLAY=(202:C'1',                    $ 1 FOR NEGATIVE COUNT     
                220:04,13,                   $ NEGATIVE TOTAL           
                235:04,13))                  $ FULL TOTAL               
                                                                         
  OUTFIL FNAMES=FILEA,REMOVECC,              $ OUTFILE A                 
  BUILD=(1,200),                             $ ORIGINAL LRECL           
  INCLUDE=(01,1,CH,EQ,C'1',OR,               $ HEADER OR                 
           20,1,CH,EQ,C'A'),                 $ TYPE A RECORD             
  TRAILER1=('3',                             $ TRAILER ID               
            TOT=(201,01,ZD,M11,LENGTH=12),   $ TOTAL POSITIVE COUNT     
            TOT=(202,01,ZD,M11,LENGTH=12),   $ TOTAL NEGATIVE COUNT     
            TOT=(204,13,ZD,ZDC,LENGTH=15),   $ TOTAL POSITIVE AMOUNT     
            TOT=(220,13,ZD,ZDC,LENGTH=15),   $ TOTAL POSITIVE AMOUNT     
            TOT=(235,13,ZD,ZDC,LENGTH=15))   $ TOTAL AMOUNT
                                                                     
  OUTFIL FNAMES=FILEB,REMOVECC,              $ OUTFILE B             
  BUILD=(1,200),                             $ ORIGINAL LRECL       
  INCLUDE=(01,1,CH,EQ,C'1',OR,               $ HEADER OR             
           20,1,CH,EQ,C'B'),                 $ TYPE B RECORD         
  TRAILER1=('3',                             $ TRAILER ID           
            TOT=(201,01,ZD,M11,LENGTH=12),   $ TOTAL POSITIVE COUNT 
            TOT=(202,01,ZD,M11,LENGTH=12),   $ TOTAL NEGATIVE COUNT 
            TOT=(204,13,ZD,ZDC,LENGTH=15),   $ TOTAL POSITIVE AMOUNT
            TOT=(220,13,ZD,ZDC,LENGTH=15),   $ TOTAL POSITIVE AMOUNT
            TOT=(235,13,ZD,ZDC,LENGTH=15))   $ TOTAL AMOUNT         
/*

_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

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


Joined: 03 Nov 2021
Posts: 15
Topics: 5

PostPosted: Thu Dec 16, 2021 12:39 am    Post subject: Reply with quote

Okay understood.

Thanks alot Kolusu for such a clear explanation. This helps a lot in building the understanding.
Back to top
View user's profile Send private message
Srishti Rawat
Beginner


Joined: 03 Nov 2021
Posts: 15
Topics: 5

PostPosted: Thu Nov 17, 2022 10:27 am    Post subject: Reply with quote

Hi Kolusu,

Adding to my previous query. Could you please help me by suggesting that in case in my File A there is no record(empty file created) than no record should be written into the file. As of now Trailer record is getting printed. I want my file to be blank in case no record selected.

Can you please help.

Thanks,
Srishti.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Nov 17, 2022 1:48 pm    Post subject: Reply with quote

Srishti Rawat wrote:
Hi Kolusu,

Adding to my previous query. Could you please help me by suggesting that in case in my File A there is no record(empty file created) than no record should be written into the file. As of now Trailer record is getting printed. I want my file to be blank in case no record selected.

Srishti Rawat,

You can add a step to check if the file is empty and then skip the actual step that is creating the totals.

Code:

//EMPTCHK EXEC PGM=ICETOOL                                     
//TOOLMSG  DD SYSOUT=*                                         
//DFSMSG   DD SYSOUT=*                                         
//IN       DD DISP=SHR,DSN=your.input.fb200.file
//TOOLIN   DD *                                                 
  COUNT FROM(IN) EMPTY RC4 USING(CTL1)                         
/*                                                             
//CTL1CNTL DD *                                                 
  INCLUDE COND=(01,1,CH,EQ,C'1',OR,          $ HEADER           
                20,1,SS,EQ,C'A,B')           $ A OR B RECORDS   
/*         
//STEP0100 EXEC PGM=SORT,COND=(4,EQ,EMPTCHK)   
..


or
Code:

//EMPTCHK EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD DISP=SHR,DSN=your.input.fb200.file
//SORTOUT  DD DUMMY
//SYSIN    DD *                                               
  OPTION COPY,NULLOUT=RC4                                     
  INCLUDE COND=(01,1,CH,EQ,C'1',OR,          $ HEADER         
                20,1,SS,EQ,C'A,B')           $ A OR B RECORDS
/*
//STEP0100 EXEC PGM=SORT,COND=(4,EQ,EMPTCHK)   

_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

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


Joined: 03 Nov 2021
Posts: 15
Topics: 5

PostPosted: Thu Nov 17, 2022 3:52 pm    Post subject: Reply with quote

Hi Kolusu,

Thanks for your reply.

But I need if at 20th position we have 'A' than do not right anything, create an empty file. Whereas, File B is fine, trailer should be written to it for the given condition even if we dont have matching records.
Is it possible to do with the same sortcard rather than having additional steps in PROC?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Nov 17, 2022 6:47 pm    Post subject: Reply with quote

Srishti Rawat wrote:
Hi Kolusu,

Thanks for your reply.

But I need if at 20th position we have 'A' than do not right anything, create an empty file. Whereas, File B is fine, trailer should be written to it for the given condition even if we dont have matching records.


Srishti Rawat,

You are better off having the EMPTY file check after you have created the Summary files A and B.

Srishti Rawat wrote:

Is it possible to do with the same sortcard rather than having additional steps in PROC?


NO
_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

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


Joined: 03 Nov 2021
Posts: 15
Topics: 5

PostPosted: Fri Nov 18, 2022 12:12 am    Post subject: Reply with quote

Sure Kolusu. That's what I am doing right now. I thought may be we can do something within the card itself.
Thanks for your time and confirmation.

Regards,
Srishti
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