Collapse EDI group records to single output record



Support for NetApp SyncSort for z/OS, Visual SyncSort, SYNCINIT, SYNCLIST and SYNCTOOL

Collapse EDI group records to single output record

Postby tomwrightoak » Fri Feb 21, 2020 1:54 am

Hi All.
Using SYNCSORT FOR Z/OS 3.1.2.0N

I need to grab some fields out of an EDI group record (structure) and output them in a single record, I do not need to output the incoming records.

Data (cleansed and generic):
0000 ABCDEFG                            ZZ ET122123456  
1000 FA                                 922401          
1000AWU ANOTHER THING HERE
1000AV3 0AB1CD2E
2000                     IN123456                      
2000A                                                  
2100 57.000000000000DC20191230
2100AEA92533     012345678000000000000000000          
2100AEA92532     012345679000000000000000000          
2100AEA92522     012345680000000000000000000          
2100AEA92662     012345681000000000000000000          
2100AEA921136    012345682000000000000000000          
2100AEA921140    012345683000000000000000000          
2000                     IN123457                      
2000A                                                  
2100 57.000000000000DC20191230
2100AEA92533     012345990012340010000000000          
2100AEA92532     012345991012340022012340033          
2100AEA92522     012345992000000000000000000          
2100AEA92662     012345993000000000000000000          
2100AEA921136    012345994000000000000000000          
2100AEA921140    012345995000000000000000000          
0000 LMNOPQ                             ZZ ET121123456
1000 FA                                 921234        
1000AWU SOMETHING HERE
1000AV3 123F
2000                     IN456789                      
2000A                                                  
2100 188.00000000000DC20191230
2100AEA92522                                          
2100AEA92662                                          
2100AEA921419                                          
2100AEA921457                                          
 


The group begins with the '0000 ' record, and can have multiple iterations of the '2000 ' through '2100A' block. From one block, to hundreds.
I need to get fields from the '0000 ', '1000 ', '2000 ', and '2100A' records, and output them onto a single record. Bypass/ignore other record types.

The code I have ended up with:
//SYSIN    DD  *                                            
    SORT FIELDS=COPY                                        
    INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,5,CH,EQ,C'0000 '),    
                  PUSH=(390:SEQ=3)),                        
      IFTHEN=(WHEN=(1,5,CH,EQ,C'0000 '),BUILD=(16:46,9)),    
      IFTHEN=(WHEN=(1,5,CH,EQ,C'1000 '),BUILD=(26:43,4)),    
      IFTHEN=(WHEN=(1,5,CH,EQ,C'2000 '),BUILD=(31:28,6)),    
      IFTHEN=(WHEN=(1,5,CH,EQ,C'2100A'),BUILD=(38:18,27))    
/*                                                          
 


The output I get:
122300519
          2401
1000AWU ANOTHER THING HERE                                                                                                                                                                                                                                                                                                                                                                           003
1000AV3 0AB1CD2E                                                                                                                                                                                                                                                                                                                                                                                     004
               123456
2000A                                                                                                                                                                                                                                                                                                                                                                                                006
2100 57.000000000000DC20191230                                                                                                                                                                                                                                                                                                                                                                       007
                      012345678000000000000000000
                      012345679000000000000000000
                      012345680000000000000000000
                      012345681000000000000000000
                      012345682000000000000000000
                      012345683000000000000000000
               123457
2000A                                                                                                                                                                                                                                                                                                                                                                                                015
2100 57.000000000000DC20191230                                                                                                                                                                                                                                                                                                                                                                       016
                      012345990012340010000000000
                      012345991000000000000000000
                      012345992000000000000000000
                      012345993000000000000000000
                      012345994000000000000000000
                      012345995000000000000000000
121123456
          1234
1000AWU SOMETHING HERE                                                                                                                                                                                                                                                                                                                                                                               003
1000AV3 123F                                                                                                                                                                                                                                                                                                                                                                                         004
               456789
2000A                                                                                                                                                                                                                                                                                                                                                                                                006
2100 188.00000000000DC20191230                                                                                                                                                                                                                                                                                                                                                                       007
                      012345996000000000000000000
                      012345997000000000000000000
                      012345998000000000000000000
                      012345999000000000000000000
 


The output I need:
122300519 2401 123456 012345678000000000000000000
122300519 2401 123456 012345679000000000000000000
122300519 2401 123456 012345680000000000000000000
122300519 2401 123456 012345681000000000000000000
122300519 2401 123456 012345682000000000000000000
122300519 2401 123456 012345683000000000000000000
122300519 2401 123457 012345990012340010000000000
122300519 2401 123457 012345991000000000000000000
122300519 2401 123457 012345992000000000000000000
122300519 2401 123457 012345993000000000000000000
122300519 2401 123457 012345994000000000000000000
122300519 2401 123457 012345995000000000000000000
121123456 1234 456789 012345996000000000000000000
121123456 1234 456789 012345997000000000000000000
121123456 1234 456789 012345998000000000000000000
121123456 1234 456789 012345999000000000000000000
 


I get no errors.

I have been working on this for about a day, and there is something I clearly do not grasp. What am I missing or doing wrong?

Thanks in advance
tomwrightoak
 
Posts: 2
Joined: Fri Feb 21, 2020 12:16 am
Has thanked: 0 time
Been thanked: 0 time

Re: Collapse EDI group records to single output record

Postby sergeyken » Fri Feb 21, 2020 5:08 pm

Please, make your example also clear to others: so far cannot find any relation between your input and your desired output?
Javas and Pythons come and go, but JCL and SORT stay forever.
User avatar
sergeyken
 
Posts: 408
Joined: Wed Jul 24, 2019 10:12 pm
Has thanked: 6 times
Been thanked: 40 times

Re: Collapse EDI group records to single output record

Postby tomwrightoak » Fri Feb 21, 2020 6:25 pm

sergeyken wrote:Please, make your example also clear to others: so far cannot find any relation between your input and your desired output?


I want to select specific fields from only 4 of the many record types, and output those fields to a single output record.

From the input '0000 ' record I want position 46 for length 9 to output position 1
From the input '1000 ' record I want position 43 for length 4 to output position 11
From the input '2000 ' record I want position 28 for length 6 to output position 16
From the input '2100A' record I want position 18 for length 27 to output position 23

These 4 fields then placed into a single output record and written out.

At this point I am just trying to get the 4 fields onto a single output record, that is where I am stumped.
tomwrightoak
 
Posts: 2
Joined: Fri Feb 21, 2020 12:16 am
Has thanked: 0 time
Been thanked: 0 time

Re: Collapse EDI group records to single output record

Postby sergeyken » Fri Feb 21, 2020 8:45 pm

As far as I was able to understand your messy and partially invalid example, it can be done like this

//*==================================================================
//* SELECT DATA FROM SPECIFIC LINES                                  
//*==================================================================
//SELECT  EXEC PGM=SORT                                              
//*                                                                  
//SYSOUT   DD  SYSOUT=*                                              
//SORTOUT  DD  SYSOUT=*                                              
//*                                                                  
//SORTIN   DD  *                                                    
0000 ABCDEFG                            ZZ ET122123456              
1000 FA                                 922401                      
1000AWU ANOTHER THING HERE                                          
1000AV3 0AB1CD2E                                                    
2000                     IN123456                                    
2000A                                                                
2100 57.000000000000DC20191230                                      
2100AEA92533     012345678000000000000000000                        
2100AEA92532     012345679000000000000000000                        
2100AEA92522     012345680000000000000000000                        
2100AEA92662     012345681000000000000000000                        
2100AEA921136    012345682000000000000000000                        
2100AEA921140    012345683000000000000000000                        
2000                     IN123457                                    
2000A                                                                
2100 57.000000000000DC20191230                                      
2100AEA92533     012345990012340010000000000                        
2100AEA92532     012345991012340022012340033                        
2100AEA92522     012345992000000000000000000                        
2100AEA92662     012345993000000000000000000                        
2100AEA921136    012345994000000000000000000                        
2100AEA921140    012345995000000000000000000                        
0000 LMNOPQ                             ZZ ET121123456              
1000 FA                                 921234                      
1000AWU SOMETHING HERE                                              
1000AV3 123F                                                        
2000                     IN456789                                    
2000A                                                                
2100 188.00000000000DC20191230                                      
2100AEA92522     ----GARBAGE HERE-----------                        
2100AEA92662     ----GARBAGE HERE-----------                          
2100AEA921419    ----GARBAGE HERE-----------                          
2100AEA921457    ----GARBAGE HERE-----------                          
//*                                                                  
//SYSIN   DD  *                                                      
 SORT FIELDS=COPY                                                    
 INREC IFTHEN=(WHEN=GROUP,                                            
               BEGIN=(1,5,CH,EQ,C'0000 '),                            
               PUSH=(81:46,9)),                                      
       IFTHEN=(WHEN=GROUP,                                            
               BEGIN=(1,5,CH,EQ,C'1000 '),                            
               PUSH=(92:43,4)),                                      
       IFTHEN=(WHEN=GROUP,                                            
               BEGIN=(1,5,CH,EQ,C'2000 '),                            
               PUSH=(97:28,6)),                                      
       IFTHEN=(WHEN=GROUP,                                            
               BEGIN=(1,5,CH,EQ,C'2100A'),                            
               PUSH=(104:18,27)),                                    
       IFTHEN=(WHEN=(1,5,CH,EQ,C'0000 '),                            
               OVERLAY=(92:4X,                                        
                        97:6X,                                        
                       104:27X))                                      
 OUTFIL FNAMES=SORTOUT,                                              
        INCLUDE=(1,5,CH,EQ,C'2100A'),                                
        BUILD=(81,49)                                        
 END                                                                  
//*                                                                  
//*-------------------------------------------------------------------
 


********************************* TOP OF DATA *********
122123456  2401 123456 01234567800000000000000000      
122123456  2401 123456 01234567900000000000000000      
122123456  2401 123456 01234568000000000000000000      
122123456  2401 123456 01234568100000000000000000      
122123456  2401 123456 01234568200000000000000000      
122123456  2401 123456 01234568300000000000000000      
122123456  2401 123457 01234599001234001000000000      
122123456  2401 123457 01234599101234002201234003      
122123456  2401 123457 01234599200000000000000000      
122123456  2401 123457 01234599300000000000000000      
122123456  2401 123457 01234599400000000000000000      
122123456  2401 123457 01234599500000000000000000      
121123456  1234 456789 ----GARBAGE HERE----------      
121123456  1234 456789 ----GARBAGE HERE----------      
121123456  1234 456789 ----GARBAGE HERE----------      
121123456  1234 456789 ----GARBAGE HERE----------      
******************************** BOTTOM OF DATA *******
 
Javas and Pythons come and go, but JCL and SORT stay forever.
User avatar
sergeyken
 
Posts: 408
Joined: Wed Jul 24, 2019 10:12 pm
Has thanked: 6 times
Been thanked: 40 times


Return to Syncsort/Synctool

 


  • Related topics
    Replies
    Views
    Last post