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 

Combine values based on key with certain Output positioning

 
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: Mon Jan 20, 2020 2:46 pm    Post subject: Combine values based on key with certain Output positioning Reply with quote

Good day,
please let me know how to accomplish the following task.

There is an Input dataset, FB, LRECL=100, where there could be different types of payments (13:4) assigned to the same key (52:15).
The goal is to combine all payments for each key on a single record, but place payments into certain positions on Output, based on their type.

'CASH', pos 20
'CHK ', pos 30
'CRED', pos 40
'DEBT', pos 50


Input data.
Code:

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
............CRED     ..............................000000000000001     
............CRED     ..............................000000000000002     
............CASH     ..............................000000000000003     
............DEBT     ..............................000000000000003     
............CHK      ..............................000000000000003     
............CRED     ..............................000000000000004     
............CASH     ..............................000000000000004     
............DEBT     ..............................000000000000004     
............CHK      ..............................000000000000004     
............DEBT     ..............................000000000000005
............CASH     ..............................000000000000006



Desired output.
Code:

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
000000000000001                        CRED                             
000000000000002                        CRED                             
000000000000003    CASH      CHK                 DEBT                   
000000000000004    CASH      CHK       CRED      DEBT                   
000000000000005                                  DEBT                   
000000000000006    CASH                                                 


I've tried SPLICE, but not all records came out correctly. Could that be because SPLICE identified each repeating value
by SEQNUM, and I need it by payment type in (13:4)?

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


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

PostPosted: Tue Jan 21, 2020 12:19 am    Post subject: Reply with quote

ramy2016,

use the following Untested DFSORT JCL which will give you the desired results

Code:

//STEP0100 EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD *                                                         
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
............CRED     ..............................000000000000001     
............CRED     ..............................000000000000002     
............CASH     ..............................000000000000003     
............DEBT     ..............................000000000000003     
............CHK      ..............................000000000000003     
............CRED     ..............................000000000000004     
............CASH     ..............................000000000000004     
............DEBT     ..............................000000000000004     
............CHK      ..............................000000000000004     
............DEBT     ..............................000000000000005     
............CASH     ..............................000000000000006     
............XXXX     ..............................000000000000006     
//SORTOUT  DD SYSOUT=*                                                 
//SYSIN    DD *                                                         
  INREC BUILD=(52,15,                                                   
               13,04,CHANGE=(16,C'CASH',C'0001000000000000',           
                                C'CHK ',C'0000000100000000',           
                                C'CRED',C'0000000000010000',           
                                C'DEBT',C'0000000000000001'),           
                               NOMATCH=(C'0000000000000000'))           
                                                                       
  SORT FIELDS=(1,15,CH,A)                                               
   SUM FIELDS=(16,04,                                                   
               20,04,                                                   
               24,04,                                                   
               28,04),FORMAT=ZD                                         
                                                                       
  OUTREC BUILD=(01,15,                                                 
                20:16,4,CHANGE=(4,C'0000',C'    '),                     
                                NOMATCH=(C'CASH'),                     
                30:20,4,CHANGE=(4,C'0000',C'    '),                     
                                NOMATCH=(C'CHK '),                     
                40:24,4,CHANGE=(4,C'0000',C'    '),                     
                                NOMATCH=(C'CRED'),                     
                50:28,4,CHANGE=(4,C'0000',C'    '),                     
                                NOMATCH=(C'DEBT'))                     
/*

_________________
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: Tue Jan 21, 2020 10:16 am    Post subject: Reply with quote

kolusu, I ran your JCL, worked perfectly, thanks a lot.
And can I ask for a small change? I just learned that business also wants, besides the payment type, to see the entire value (1:16) from Input. I understand that it would change the Output layout, but that doesn't matter, I can always adjust those. I tried changing the NOMATCH value from hardcoded to positional, but it didn't work.
Thank you.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Tue Jan 21, 2020 10:30 am    Post subject: Reply with quote

ramy2016 wrote:
kolusu, I ran your JCL, worked perfectly, thanks a lot.
And can I ask for a small change? I just learned that business also wants, besides the payment type, to see the entire value (1:16) from Input. I understand that it would change the Output layout, but that doesn't matter, I can always adjust those. I tried changing the NOMATCH value from hardcoded to positional, but it didn't work.
Thank you.


ramy2016,

what is the final output layout that you want? Make sure you gather all the information before asking another change. Specify the positions and lengths of the fields you want in output.
_________________
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: Tue Jan 21, 2020 11:11 am    Post subject: Reply with quote

kolusu wrote:

ramy2016,

what is the final output layout that you want? Make sure you gather all the information before asking another change. Specify the positions and lengths of the fields you want in output.


Something like in the code below. Input values from pos. 1:12 + 4 bytes pmt-type = 16 bytes (1:16).
Thank you.

Code:

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
000000000000001                                            ............CRED                             
000000000000002                                            ............CRED                             
000000000000003    ............CASH    ............CHK                         ............DEBT                   
000000000000004    ............CASH    ............CHK     ............CRED    ............DEBT                   
000000000000005                                                                ............DEBT                   
000000000000006    ............CASH                                                 
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Tue Jan 21, 2020 12:07 pm    Post subject: Reply with quote

ramy2016,

would the first 12 bytes be the same for CASH, CHK, DEBT & CRED? or would it have different values?

something like this
Code:

A...........CASH     ..............................000000000000003
B...........DEBT     ..............................000000000000003
C...........CHK      ..............................000000000000003
D...........CRED     ..............................000000000000003


and the output would be the following?
Code:

000000000000003    A...........CASH    C............CHK        D............CHK            B...........DEBT



What happens when you have multiple valued records?

Code:

A...........CASH     ..............................000000000000003
B...........DEBT     ..............................000000000000003
C...........CHK      ..............................000000000000003
D...........CRED     ..............................000000000000003

E...........CASH     ..............................000000000000003
F...........DEBT     ..............................000000000000003
G...........CHK      ..............................000000000000003
H...........CRED     ..............................000000000000003

I...........CASH     ..............................000000000000003
J...........DEBT     ..............................000000000000003
K...........CHK      ..............................000000000000003
L...........CRED     ..............................000000000000003




which value would you take?
_________________
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: Tue Jan 21, 2020 12:25 pm    Post subject: Reply with quote

kolusu,
The first 12 bytes are timestamps and amounts related to payments, so those would be different. And the dataset I'm working with doesn't have similar payment types within the same key. One cash, check, credit and debit per key.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Tue Jan 21, 2020 1:38 pm    Post subject: Reply with quote

ramy2016,

Use the following DFSORT/ICETOOL JCL which will give you the desired results. I assumed your input is sorted on the key at position 52. If it is NOT sorted then remove the OPTION COPY statement in CTL1CNTL

Code:

//STEP0100 EXEC PGM=ICETOOL                                               
//TOOLMSG  DD SYSOUT=*                                                   
//DFSMSG   DD SYSOUT=*                                                   
//IN       DD *                                                           
............CRED     ..............................000000000000001       
............CRED     ..............................000000000000002       
............CASH     ..............................000000000000003       
............DEBT     ..............................000000000000003       
............CHK      ..............................000000000000003       
............CRED     ..............................000000000000004       
............CASH     ..............................000000000000004       
............DEBT     ..............................000000000000004       
............CHK      ..............................000000000000004       
............DEBT     ..............................000000000000005       
............CASH     ..............................000000000000006       
//OUT      DD SYSOUT=*                                                   
//TOOLIN   DD *                                                           
  SPLICE FROM(IN) TO(OUT) ON(1,15,CH) WITHANY KEEPNODUPS USING(CTL1) -   
  WITH(20,16) WITH(40,16) WITH(60,16) WITH(80,16)   
/*                     
//CTL1CNTL DD *                                                           
  OPTION COPY                                                             
  INREC IFOUTLEN=100,                                                     
        IFTHEN=(WHEN=INIT,BUILD=(52,15,101:01,16)),                       
        IFTHEN=(WHEN=(113,4,CH,EQ,C'CASH'),OVERLAY=(20:101,16)),         
        IFTHEN=(WHEN=(113,4,CH,EQ,C'CHK '),OVERLAY=(40:101,16)),         
        IFTHEN=(WHEN=(113,4,CH,EQ,C'CRED'),OVERLAY=(60:101,16)),         
        IFTHEN=(WHEN=(113,4,CH,EQ,C'DEBT'),OVERLAY=(80:101,16))           
                                                                         
/*

_________________
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: Tue Jan 21, 2020 3:16 pm    Post subject: Reply with quote

That's a beautiful thing, kolusu, thank you again, and sorry for the last minute change.
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