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 - subgrouping

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


Joined: 11 Aug 2018
Posts: 8
Topics: 1

PostPosted: Tue Sep 18, 2018 2:44 am    Post subject: DFSORT - subgrouping Reply with quote

Hi,
I'm trying to convert a program written with an obsolete language into a sort.
This program read a file (LREL=120, FB) and reformat it with the following rules:
1. If record type (position=2, length=2) is LESS than "10" and NOT EQUAL "EF" write output unchanged (same of input)
2. If record type (position=2, length=2) is GREATER OR EQUAL "10" (it starts a subgroup) write ouput with changing position 4,7 with number of subgroup (see below)
3. If record type (position=2, length=2) is EQUAL "EF" (it closes a GROUP) write output with changing position 46,7 with total of subgroups of group.

When record type is "EF" the subgroups counter must be reset, so every record "EF" will have at position 46,7 the number of subgroups that compose it.

Input example:
Code:
 00xxxxxxxRec.000001 Must remain unaltered, so any rec. LT 10           
 01xxxxxxxRec.000002 Must remain unaltered, so any rec. LT 10           
 10   a   Rec.000003 On output pos.4,7 must have 0000001 << Subgroup   
 20   a   Rec.000004 On output pos.4,7 must have 0000001 << Subgroup   
 30   a   Rec.000005 On output pos.4,7 must have 0000001 << Subgroup   
 10   b   Rec.000006 On output pos.4,7 must have 0000002 << Subgroup   
 20   b   Rec.000007 On output pos.4,7 must have 0000002 << Subgroup   
 30   b   Rec.000008 On output pos.4,7 must have 0000002 << Subgroup   
 10   c   Rec.000009 On output pos.4,7 must have 0000003 << Subgroup   
 20   c   Rec.000010 On output pos.4,7 must have 0000003 << Subgroup   
 30   c   Rec.000011 On output pos.4,7 must have 0000003 << Subgroup   
 EF   G1  Rec.000012 End GROUP1   >SubGroups>NNNNNNN< Had to be 0000003
 10   c   Rec.000013 On output pos.4,7 must have 0000001 << Subgroup   
 20   c   Rec.000014 On output pos.4,7 must have 0000001 << Subgroup   
 30   c   Rec.000015 On output pos.4,7 must have 0000001 << Subgroup   
 10   d   Rec.000016 On output pos.4,7 must have 0000002 << Subgroup   
 20   d   Rec.000017 On output pos.4,7 must have 0000002 << Subgroup   
 30   d   Rec.000018 On output pos.4,7 must have 0000002 << Subgroup   
 10   e   Rec.000019 On output pos.4,7 must have 0000003 << Subgroup   
 20   e   Rec.000020 On output pos.4,7 must have 0000003 << Subgroup   
 30   e   Rec.000021 On output pos.4,7 must have 0000003 << Subgroup   
 10   f   Rec.000022 On output pos.4,7 must have 0000004 << Subgroup   
 20   f   Rec.000023 On output pos.4,7 must have 0000004 << Subgroup   
 30   f   Rec.000024 On output pos.4,7 must have 0000004 << Subgroup   
 EF   G2  Rec.000025 End GROUP2   >SubGroups>NNNNNNN< Had to be 0000004
 EF   G3  Rec.000026 End GROUP3   >SubGroups>NNNNNNN< Had to be 0000000

Output expected:
Code:
 00xxxxxxxRec.000001 Must remain unaltered, so any rec. LT 10         
 01xxxxxxxRec.000002 Must remain unaltered, so any rec. LT 10         
 100000001Rec.000003 On output pos.4,7 must have 0000001 << Subgroup   
 200000001Rec.000004 On output pos.4,7 must have 0000001 << Subgroup   
 300000001Rec.000005 On output pos.4,7 must have 0000001 << Subgroup   
 100000002Rec.000006 On output pos.4,7 must have 0000002 << Subgroup   
 200000002Rec.000007 On output pos.4,7 must have 0000002 << Subgroup   
 300000002Rec.000008 On output pos.4,7 must have 0000002 << Subgroup   
 100000003Rec.000009 On output pos.4,7 must have 0000003 << Subgroup   
 200000003Rec.000010 On output pos.4,7 must have 0000003 << Subgroup   
 300000003Rec.000011 On output pos.4,7 must have 0000003 << Subgroup   
 EF   G1  Rec.000012 End GROUP1   >SubGroups>0000003< Had to be 0000003
 100000001Rec.000013 On output pos.4,7 must have 0000001 << Subgroup   
 200000001Rec.000014 On output pos.4,7 must have 0000001 << Subgroup   
 300000001Rec.000015 On output pos.4,7 must have 0000001 << Subgroup   
 100000002Rec.000016 On output pos.4,7 must have 0000002 << Subgroup   
 200000002Rec.000017 On output pos.4,7 must have 0000002 << Subgroup   
 300000002Rec.000018 On output pos.4,7 must have 0000002 << Subgroup   
 100000003Rec.000019 On output pos.4,7 must have 0000003 << Subgroup   
 200000003Rec.000020 On output pos.4,7 must have 0000003 << Subgroup   
 300000003Rec.000021 On output pos.4,7 must have 0000003 << Subgroup   
 100000004Rec.000022 On output pos.4,7 must have 0000004 << Subgroup   
 200000004Rec.000023 On output pos.4,7 must have 0000004 << Subgroup   
 300000004Rec.000024 On output pos.4,7 must have 0000004 << Subgroup   
 EF   G2  Rec.000025 End GROUP2   >SubGroups>0000004< Had to be 0000004
 EF   G3  Rec.000026 End GROUP3   >SubGroups>0000000< Had to be 0000000


I tried many solution and read many post and manuals (by Frank Yaeger Smile ), but I can not find a solution.
I suspect need use ICETOOL (which I do not know well) or maybe two step of sort.

This is my sort (one of my many tests) which obviously does not work as expected:
Code:
//SORTIN   DD  DSN=UECWSFS.TSO.DATA120(BD55001I),DISP=SHR         
//SORTOUT  DD  DSN=UECWSFS.TSO.DATA120(BD55001O),DISP=SHR         
//SORTDIS  DD  DSN=UECWSFS.TSO.DATA200(BD55001O),DISP=SHR         
//SYSIN    DD  *                                                 
  OPTION COPY                                                     
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(02,2,CH,EQ,C'10'),             
                             END=(02,2,CH,EQ,C'EF'),             
          PUSH=(121:ID=7),HIT=NEXT),                             
        IFTHEN=(WHEN=GROUP,BEGIN=(02,2,CH,EQ,C'EF'),             
          PUSH=(128:121,7))                                       
  OUTFIL FNAMES=SORTOUT,                                         
  REMOVECC,                                                       
     IFTHEN=(WHEN=(02,2,CH,LT,C'10',AND,02,2,CH,NE,C'EF'),       
      BUILD=(1,120)),                                             
     IFTHEN=(WHEN=(02,2,CH,GE,C'10',AND,02,2,CH,NE,C'EF'),       
      BUILD=(1,3,4:121,07,ZD,SUB,128,07,ZD,M11,LENGTH=07,11,110)),
     IFTHEN=(WHEN=NONE,                                           
      BUILD=(1,45,121,07,53,68))                                 
  OUTFIL FNAMES=SORTDIS,                                         
  REMOVECC,                                                       
      BUILD=(1,134,200:X)
/*

SORTDIS only serves to verify how the various IDs are set and can therefore be omitted.

Any suggestions?

Thanks in advance.
Francesco
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: Tue Sep 18, 2018 11:42 am    Post subject: Re: DFSORT - subgrouping Reply with quote

fspino wrote:

3. If record type (position=2, length=2) is EQUAL "EF" (it closes a GROUP) write output with changing position 46,7 with total of subgroups of group.
I tried many solution and read many post and manuals (by Frank Yaeger Smile ), but I can not find a solution.
I suspect need use ICETOOL (which I do not know well) or maybe two step of sort.



Fspino,

You haven't shown what needs to be summarized for the group end record. So I did not show that piece of code. But it is easy to add

You don't need 2 passes of data. It is quite simple.

Brief description of the job.

Using INREC when=group we tag the records with a 7 byte ID at position 121 for the records that start with '10' in position 1,2. Also we sequence the EF records too on the same INREC

Now using that EF sequence number we push 7 byte ID at 121 on to position 137. This is done to reset the group number after the end of EF record. Since EF record already had an ID number from the '10' record when=group, pushing this number on to next set of 10 records will have the last Seqnum number. Now it is matter of simple subtraction of these 2 numbers. For a better understanding of this piece of code, I suggest you running INREC and OUTREC removing the IFOUTLEN parm, so that you can see the contents of how we are subtracting the values.

With OUTREC we took care of the 10 record group, but we still need to fix the EF record. So we take care of that on OUTFIL. Once we have all the sequence numbering , we simply replace the sequence numbers on to position 4.

Here is a DFSORT JCL that will give you the desired results.

Code:

//STEP0100 EXEC PGM=SORT                                                 
//SYSOUT   DD SYSOUT=*                                                   
//SORTIN   DD *                                                           
00XXXXXXXREC.000001 MUST REMAIN UNALTERED, SO ANY REC. LT 10             
01XXXXXXXREC.000002 MUST REMAIN UNALTERED, SO ANY REC. LT 10             
10   A   REC.000003 ON OUTPUT POS.4,7 MUST HAVE 0000001 << SUBGROUP       
20   A   REC.000004 ON OUTPUT POS.4,7 MUST HAVE 0000001 << SUBGROUP       
30   A   REC.000005 ON OUTPUT POS.4,7 MUST HAVE 0000001 << SUBGROUP       
10   B   REC.000006 ON OUTPUT POS.4,7 MUST HAVE 0000002 << SUBGROUP       
20   B   REC.000007 ON OUTPUT POS.4,7 MUST HAVE 0000002 << SUBGROUP       
30   B   REC.000008 ON OUTPUT POS.4,7 MUST HAVE 0000002 << SUBGROUP       
10   C   REC.000009 ON OUTPUT POS.4,7 MUST HAVE 0000003 << SUBGROUP       
20   C   REC.000010 ON OUTPUT POS.4,7 MUST HAVE 0000003 << SUBGROUP       
30   C   REC.000011 ON OUTPUT POS.4,7 MUST HAVE 0000003 << SUBGROUP       
EF   G1  REC.000012 END GROUP1   >SUBGROUPS>NNNNNNN< HAD TO BE 0000003   
10   C   REC.000013 ON OUTPUT POS.4,7 MUST HAVE 0000001 << SUBGROUP       
20   C   REC.000014 ON OUTPUT POS.4,7 MUST HAVE 0000001 << SUBGROUP       
30   C   REC.000015 ON OUTPUT POS.4,7 MUST HAVE 0000001 << SUBGROUP       
10   D   REC.000016 ON OUTPUT POS.4,7 MUST HAVE 0000002 << SUBGROUP       
20   D   REC.000017 ON OUTPUT POS.4,7 MUST HAVE 0000002 << SUBGROUP       
30   D   REC.000018 ON OUTPUT POS.4,7 MUST HAVE 0000002 << SUBGROUP       
10   E   REC.000019 ON OUTPUT POS.4,7 MUST HAVE 0000003 << SUBGROUP       
20   E   REC.000020 ON OUTPUT POS.4,7 MUST HAVE 0000003 << SUBGROUP       
30   E   REC.000021 ON OUTPUT POS.4,7 MUST HAVE 0000003 << SUBGROUP       
10   F   REC.000022 ON OUTPUT POS.4,7 MUST HAVE 0000004 << SUBGROUP       
20   F   REC.000023 ON OUTPUT POS.4,7 MUST HAVE 0000004 << SUBGROUP       
30   F   REC.000024 ON OUTPUT POS.4,7 MUST HAVE 0000004 << SUBGROUP       
EF   G2  REC.000025 END GROUP2   >SUBGROUPS>NNNNNNN< HAD TO BE 0000004   
EF   G3  REC.000026 END GROUP3   >SUBGROUPS>NNNNNNN< HAD TO BE 0000000   
//SORTOUT  DD SYSOUT=*                                                   
//SYSIN    DD *                                               
  OPTION COPY                                                 
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,2,CH,EQ,C'10'),           
                PUSH=(121:ID=7)),                             
        IFTHEN=(WHEN=(1,2,CH,EQ,C'EF'),                       
             OVERLAY=(129:SEQNUM,7,ZD))                       
                                                               
  OUTREC IFOUTLEN=127,                                         
         IFTHEN=(WHEN=GROUP,BEGIN=(129,7,CH,GT,C' '),         
                 PUSH=(137:121,7)),                           
        IFTHEN=(WHEN=(137,7,CH,GT,C' '),                       
        OVERLAY=(121:121,7,ZD,SUB,137,7,ZD,ZD,LENGTH=7))       
                                                               
  OUTFIL IFOUTLEN=120,                                         
         IFTHEN=(WHEN=GROUP,BEGIN=(121,7,CH,GT,C' ',AND,       
                                   001,2,CH,NE,C'EF'),         
                 PUSH=(129:121,7),RECORDS=2),                 
         IFTHEN=(WHEN=(1,2,CH,EQ,C'EF',AND,129,7,CH,GT,C' '), 
                 OVERLAY=(121:129,7),HIT=NEXT),               
         IFTHEN=(WHEN=(121,1,CH,GT,C' '),                     
        OVERLAY=(004:121,7))                                   
//*                                                           


The output from this job is
Code:

00XXXXXXXREC.000001 MUST REMAIN UNALTERED, SO ANY REC. LT 10           
01XXXXXXXREC.000002 MUST REMAIN UNALTERED, SO ANY REC. LT 10           
10 0000001EC.000003 ON OUTPUT POS.4,7 MUST HAVE 0000001 << SUBGROUP   
20 0000001EC.000004 ON OUTPUT POS.4,7 MUST HAVE 0000001 << SUBGROUP   
30 0000001EC.000005 ON OUTPUT POS.4,7 MUST HAVE 0000001 << SUBGROUP   
10 0000002EC.000006 ON OUTPUT POS.4,7 MUST HAVE 0000002 << SUBGROUP   
20 0000002EC.000007 ON OUTPUT POS.4,7 MUST HAVE 0000002 << SUBGROUP   
30 0000002EC.000008 ON OUTPUT POS.4,7 MUST HAVE 0000002 << SUBGROUP   
10 0000003EC.000009 ON OUTPUT POS.4,7 MUST HAVE 0000003 << SUBGROUP   
20 0000003EC.000010 ON OUTPUT POS.4,7 MUST HAVE 0000003 << SUBGROUP   
30 0000003EC.000011 ON OUTPUT POS.4,7 MUST HAVE 0000003 << SUBGROUP   
EF 0000003EC.000012 END GROUP1   >SUBGROUPS>NNNNNNN< HAD TO BE 0000003
10 0000001EC.000013 ON OUTPUT POS.4,7 MUST HAVE 0000001 << SUBGROUP   
20 0000001EC.000014 ON OUTPUT POS.4,7 MUST HAVE 0000001 << SUBGROUP   
30 0000001EC.000015 ON OUTPUT POS.4,7 MUST HAVE 0000001 << SUBGROUP   
10 0000002EC.000016 ON OUTPUT POS.4,7 MUST HAVE 0000002 << SUBGROUP   
20 0000002EC.000017 ON OUTPUT POS.4,7 MUST HAVE 0000002 << SUBGROUP   
30 0000002EC.000018 ON OUTPUT POS.4,7 MUST HAVE 0000002 << SUBGROUP   
10 0000003EC.000019 ON OUTPUT POS.4,7 MUST HAVE 0000003 << SUBGROUP   
20 0000003EC.000020 ON OUTPUT POS.4,7 MUST HAVE 0000003 << SUBGROUP   
30 0000003EC.000021 ON OUTPUT POS.4,7 MUST HAVE 0000003 << SUBGROUP   
10 0000004EC.000022 ON OUTPUT POS.4,7 MUST HAVE 0000004 << SUBGROUP   
20 0000004EC.000023 ON OUTPUT POS.4,7 MUST HAVE 0000004 << SUBGROUP   
30 0000004EC.000024 ON OUTPUT POS.4,7 MUST HAVE 0000004 << SUBGROUP   
EF 0000004EC.000025 END GROUP2   >SUBGROUPS>NNNNNNN< HAD TO BE 0000004
EF 0000000EC.000026 END GROUP3   >SUBGROUPS>NNNNNNN< HAD TO BE 0000000

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


Joined: 11 Aug 2018
Posts: 8
Topics: 1

PostPosted: Tue Sep 18, 2018 2:22 pm    Post subject: Reply with quote

kolusu,
First of all, thank you for your reply

I didn't understand your phrase:
kolusu wrote:
You haven't shown what needs to be summarized for the group end record. So I did not show that piece of code. But it is easy to add

The record "EF" (that close each group) must be written overwriting the present at position 46 with the total number of subgroups of which its group is composed.

So the output does not have to be like this:
Code:
00XXXXXXXREC.000001 MUST REMAIN UNALTERED, SO ANY REC. LT 10           
01XXXXXXXREC.000002 MUST REMAIN UNALTERED, SO ANY REC. LT 10           
10 0000001EC.000003 ON OUTPUT POS.4,7 MUST HAVE 0000001 << SUBGROUP   
20 0000001EC.000004 ON OUTPUT POS.4,7 MUST HAVE 0000001 << SUBGROUP   
30 0000001EC.000005 ON OUTPUT POS.4,7 MUST HAVE 0000001 << SUBGROUP   
10 0000002EC.000006 ON OUTPUT POS.4,7 MUST HAVE 0000002 << SUBGROUP   
20 0000002EC.000007 ON OUTPUT POS.4,7 MUST HAVE 0000002 << SUBGROUP   
30 0000002EC.000008 ON OUTPUT POS.4,7 MUST HAVE 0000002 << SUBGROUP   
10 0000003EC.000009 ON OUTPUT POS.4,7 MUST HAVE 0000003 << SUBGROUP   
20 0000003EC.000010 ON OUTPUT POS.4,7 MUST HAVE 0000003 << SUBGROUP   
30 0000003EC.000011 ON OUTPUT POS.4,7 MUST HAVE 0000003 << SUBGROUP   
EF 0000003EC.000012 END GROUP1   >SUBGROUPS>NNNNNNN< HAD TO BE 0000003
10 0000001EC.000013 ON OUTPUT POS.4,7 MUST HAVE 0000001 << SUBGROUP   
20 0000001EC.000014 ON OUTPUT POS.4,7 MUST HAVE 0000001 << SUBGROUP   
30 0000001EC.000015 ON OUTPUT POS.4,7 MUST HAVE 0000001 << SUBGROUP   
10 0000002EC.000016 ON OUTPUT POS.4,7 MUST HAVE 0000002 << SUBGROUP   
20 0000002EC.000017 ON OUTPUT POS.4,7 MUST HAVE 0000002 << SUBGROUP   
30 0000002EC.000018 ON OUTPUT POS.4,7 MUST HAVE 0000002 << SUBGROUP   
10 0000003EC.000019 ON OUTPUT POS.4,7 MUST HAVE 0000003 << SUBGROUP   
20 0000003EC.000020 ON OUTPUT POS.4,7 MUST HAVE 0000003 << SUBGROUP   
30 0000003EC.000021 ON OUTPUT POS.4,7 MUST HAVE 0000003 << SUBGROUP   
10 0000004EC.000022 ON OUTPUT POS.4,7 MUST HAVE 0000004 << SUBGROUP   
20 0000004EC.000023 ON OUTPUT POS.4,7 MUST HAVE 0000004 << SUBGROUP   
30 0000004EC.000024 ON OUTPUT POS.4,7 MUST HAVE 0000004 << SUBGROUP   
EF 0000004EC.000025 END GROUP2   >SUBGROUPS>NNNNNNN< HAD TO BE 0000004
EF 0000000EC.000026 END GROUP3   >SUBGROUPS>NNNNNNN< HAD TO BE 0000000

Instead it must be like this:
Code:
 00XXXXXXXREC.000001 MUST REMAIN UNALTERED, SO ANY REC. LT 10           
 01XXXXXXXREC.000002 MUST REMAIN UNALTERED, SO ANY REC. LT 10           
 10 0000001EC.000003 ON OUTPUT POS.4,7 MUST HAVE 0000001 << SUBGROUP   
 20 0000001EC.000004 ON OUTPUT POS.4,7 MUST HAVE 0000001 << SUBGROUP   
 30 0000001EC.000005 ON OUTPUT POS.4,7 MUST HAVE 0000001 << SUBGROUP   
 10 0000002EC.000006 ON OUTPUT POS.4,7 MUST HAVE 0000002 << SUBGROUP   
 20 0000002EC.000007 ON OUTPUT POS.4,7 MUST HAVE 0000002 << SUBGROUP   
 30 0000002EC.000008 ON OUTPUT POS.4,7 MUST HAVE 0000002 << SUBGROUP   
 10 0000003EC.000009 ON OUTPUT POS.4,7 MUST HAVE 0000003 << SUBGROUP   
 20 0000003EC.000010 ON OUTPUT POS.4,7 MUST HAVE 0000003 << SUBGROUP   
 30 0000003EC.000011 ON OUTPUT POS.4,7 MUST HAVE 0000003 << SUBGROUP   
 EF   G1  Rec.000012 End GROUP1   >SubGroups>0000003< Had to be 0000003
 10 0000001EC.000013 ON OUTPUT POS.4,7 MUST HAVE 0000001 << SUBGROUP   
 20 0000001EC.000014 ON OUTPUT POS.4,7 MUST HAVE 0000001 << SUBGROUP   
 30 0000001EC.000015 ON OUTPUT POS.4,7 MUST HAVE 0000001 << SUBGROUP   
 10 0000002EC.000016 ON OUTPUT POS.4,7 MUST HAVE 0000002 << SUBGROUP   
 20 0000002EC.000017 ON OUTPUT POS.4,7 MUST HAVE 0000002 << SUBGROUP   
 30 0000002EC.000018 ON OUTPUT POS.4,7 MUST HAVE 0000002 << SUBGROUP   
 10 0000003EC.000019 ON OUTPUT POS.4,7 MUST HAVE 0000003 << SUBGROUP   
 20 0000003EC.000020 ON OUTPUT POS.4,7 MUST HAVE 0000003 << SUBGROUP   
 30 0000003EC.000021 ON OUTPUT POS.4,7 MUST HAVE 0000003 << SUBGROUP   
 10 0000004EC.000022 ON OUTPUT POS.4,7 MUST HAVE 0000004 << SUBGROUP   
 20 0000004EC.000023 ON OUTPUT POS.4,7 MUST HAVE 0000004 << SUBGROUP   
 30 0000004EC.000024 ON OUTPUT POS.4,7 MUST HAVE 0000004 << SUBGROUP   
 EF   G2  Rec.000025 End GROUP2   >SubGroups>0000004< Had to be 0000004
 EF   G3  Rec.000026 End GROUP3   >SubGroups>0000000< Had to be 0000000

Please note that before the record type at position 2 (00, 01, 10, 20, 30, EF, ...) there is a space, so the position of BEGIN had to be 2,2.

Now I have to go to a meeting that will also last for the whole day tomorrow, but on Thursday I will check well your code to adapt it to my needs.

Thanks again.
Francesco
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: Tue Sep 18, 2018 2:41 pm    Post subject: Reply with quote

fspino wrote:
kolusu,
First of all, thank you for your reply

I didn't understand your phrase:
kolusu wrote:
You haven't shown what needs to be summarized for the group end record. So I did not show that piece of code. But it is easy to add

The record "EF" (that close each group) must be written overwriting the present at position 46 with the total number of subgroups of which its group is composed.


fspino,

In your earlier post

fspino wrote:
3. If record type (position=2, length=2) is EQUAL "EF" (it closes a GROUP) write output with changing position 46,7 with total of subgroups of group.


Total of sub groups would mean 1+2+3 = 6 but I wasn't sure if that is the case or you wanted total number of groups within each group.

fspino wrote:
Please note that before the record type at position 2 (00, 01, 10, 20, 30, EF, ...) there is a space, so the position of BEGIN had to be 2,2.
So the output does not have to be like this:


Now that I know what you want, here are the updated control cards considering the updated position of the indicators.

Code:

//SYSIN    DD *                                                 
  OPTION COPY                                                   
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(2,2,CH,EQ,C'10'),             
                PUSH=(121:ID=7)),                               
        IFTHEN=(WHEN=(2,2,CH,EQ,C'EF'),                         
             OVERLAY=(129:SEQNUM,7,ZD))                         
                                                                 
  OUTREC IFOUTLEN=127,                                           
         IFTHEN=(WHEN=GROUP,BEGIN=(129,7,CH,GT,C' '),           
                 PUSH=(137:121,7)),                             
         IFTHEN=(WHEN=(137,7,CH,GT,C' '),                       
              OVERLAY=(121:121,7,ZD,SUB,137,7,ZD,ZD,LENGTH=7))   
                                                                 
  OUTFIL IFOUTLEN=120,                                           
         IFTHEN=(WHEN=GROUP,BEGIN=(121,7,CH,GT,C' ',AND,         
                                   002,2,CH,NE,C'EF'),           
                 PUSH=(129:121,7),RECORDS=2),                   
         IFTHEN=(WHEN=(2,2,CH,EQ,C'EF'),                         
              OVERLAY=(046:129,7,UFF,M11,LENGTH=7),HIT=NEXT),   
         IFTHEN=(WHEN=(121,1,CH,GT,C' ',AND,2,2,CH,NE,C'EF'),   
              OVERLAY=(004:121,7))                               
/*


This would produce

Code:

00XXXXXXXREC.000001 MUST REMAIN UNALTERED, SO ANY REC. LT 10         
01XXXXXXXREC.000002 MUST REMAIN UNALTERED, SO ANY REC. LT 10         
100000001REC.000003 ON OUTPUT POS.4,7 MUST HAVE 0000001 << SUBGROUP   
200000001REC.000004 ON OUTPUT POS.4,7 MUST HAVE 0000001 << SUBGROUP   
300000001REC.000005 ON OUTPUT POS.4,7 MUST HAVE 0000001 << SUBGROUP   
100000002REC.000006 ON OUTPUT POS.4,7 MUST HAVE 0000002 << SUBGROUP   
200000002REC.000007 ON OUTPUT POS.4,7 MUST HAVE 0000002 << SUBGROUP   
300000002REC.000008 ON OUTPUT POS.4,7 MUST HAVE 0000002 << SUBGROUP   
100000003REC.000009 ON OUTPUT POS.4,7 MUST HAVE 0000003 << SUBGROUP   
200000003REC.000010 ON OUTPUT POS.4,7 MUST HAVE 0000003 << SUBGROUP   
300000003REC.000011 ON OUTPUT POS.4,7 MUST HAVE 0000003 << SUBGROUP   
EF   G1  REC.000012 END GROUP1   >SUBGROUPS>0000003< HAD TO BE 0000003
100000001REC.000013 ON OUTPUT POS.4,7 MUST HAVE 0000001 << SUBGROUP   
200000001REC.000014 ON OUTPUT POS.4,7 MUST HAVE 0000001 << SUBGROUP   
300000001REC.000015 ON OUTPUT POS.4,7 MUST HAVE 0000001 << SUBGROUP   
100000002REC.000016 ON OUTPUT POS.4,7 MUST HAVE 0000002 << SUBGROUP   
200000002REC.000017 ON OUTPUT POS.4,7 MUST HAVE 0000002 << SUBGROUP   
300000002REC.000018 ON OUTPUT POS.4,7 MUST HAVE 0000002 << SUBGROUP   
100000003REC.000019 ON OUTPUT POS.4,7 MUST HAVE 0000003 << SUBGROUP   
200000003REC.000020 ON OUTPUT POS.4,7 MUST HAVE 0000003 << SUBGROUP   
300000003REC.000021 ON OUTPUT POS.4,7 MUST HAVE 0000003 << SUBGROUP   
100000004REC.000022 ON OUTPUT POS.4,7 MUST HAVE 0000004 << SUBGROUP   
200000004REC.000023 ON OUTPUT POS.4,7 MUST HAVE 0000004 << SUBGROUP   
300000004REC.000024 ON OUTPUT POS.4,7 MUST HAVE 0000004 << SUBGROUP   
EF   G2  REC.000025 END GROUP2   >SUBGROUPS>0000004< HAD TO BE 0000004
EF   G3  REC.000026 END GROUP3   >SUBGROUPS>0000000< HAD TO BE 0000000

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


Joined: 11 Aug 2018
Posts: 8
Topics: 1

PostPosted: Wed Sep 19, 2018 4:46 pm    Post subject: Reply with quote

What can I say? You are the best! Very Happy

And forgive me if my English is not so good. With:
fspino wrote:
3. If record type (position=2, length=2) is EQUAL "EF" (it closes a GROUP) write output with changing position 46,7 with total of subgroups of group.
I meant to say "3. If record type (position=2, length=2) is EQUAL "EF" (it closes a GROUP) write output with changing position 46,7 with the number of subgroups of that group. Then first group had 3 subgroups and so on."

Tomorrow morning I will study your code to understand where I was wrong (donkey I am! Embarassed ). On the contrary! It's better if I do it right away and even tomorrow morning. Wink

Thank you again and again and again for your solution.
Back to top
View user's profile Send private message
fspino
Beginner


Joined: 11 Aug 2018
Posts: 8
Topics: 1

PostPosted: Wed Sep 19, 2018 5:23 pm    Post subject: Reply with quote

Now I finally understood where I was wrong.
Only one thing I did not understand. Why you did you insert UFF,M11,LENGTH=7 here?
Code:
         IFTHEN=(WHEN=(2,2,CH,EQ,C'EF'),
              OVERLAY=(046:129,7,UFF,M11,LENGTH=7),HIT=NEXT),

Why not only:
Code:
         IFTHEN=(WHEN=(2,2,CH,EQ,C'EF'),
              OVERLAY=(046:129,7),HIT=NEXT),

Thanks.
Francesco
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 Sep 19, 2018 10:13 pm    Post subject: Reply with quote

fspino wrote:
Now I finally understood where I was wrong.
Only one thing I did not understand. Why you did you insert UFF,M11,LENGTH=7 here?
Code:
         IFTHEN=(WHEN=(2,2,CH,EQ,C'EF'),
              OVERLAY=(046:129,7,UFF,M11,LENGTH=7),HIT=NEXT),

Why not only:
Code:
         IFTHEN=(WHEN=(2,2,CH,EQ,C'EF'),
              OVERLAY=(046:129,7),HIT=NEXT),

Thanks.
Francesco


Fspino,

You will have spaces at position 129 when you have an EF record without any gropus( ex the last EF record in your sample data) that start with 10. Since you wanted zeros I had to use UFF (unsigned free format) which would convert the spaces to zeros.
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
fspino
Beginner


Joined: 11 Aug 2018
Posts: 8
Topics: 1

PostPosted: Thu Sep 20, 2018 2:42 am    Post subject: Reply with quote

kolusu",
Thanks for the explanation.

I had to add a command to your solution:
Code:
//SYSIN    DD  *                                               
  OPTION COPY                                                   
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(02,02,CH,EQ,C'10'),           
*                            END=(02,02,CH,EQ,C'EF'),           
                PUSH=(121:ID=7)),                               
        IFTHEN=(WHEN=(02,02,CH,EQ,C'EF'),                       
             OVERLAY=(129:SEQNUM,7,ZD))                         
  OUTREC IFOUTLEN=127,                                         
         IFTHEN=(WHEN=GROUP,BEGIN=(129,07,CH,GT,C' '),         
                 PUSH=(137:121,07)),                           
         IFTHEN=(WHEN=(137,07,CH,GT,C' '),                     
              OVERLAY=(121:121,07,ZD,SUB,137,07,ZD,ZD,LENGTH=7))
  OUTFIL IFOUTLEN=120,                                         
         IFTHEN=(WHEN=GROUP,BEGIN=(121,07,CH,GT,C' ',           
                               AND,02,02,CH,NE,C'EF'),         
                 PUSH=(129:121,07),RECORDS=2),                 
         IFTHEN=(WHEN=(02,02,CH,EQ,C'EF'),                     
              OVERLAY=(46:129,07,UFF,M11,LENGTH=7),HIT=NEXT),   
         IFTHEN=(WHEN=(121,01,CH,GT,C' ',AND,02,02,CH,LT,C'10'),  <-- added
              OVERLAY=(04:04,07)),                                <-- added
         IFTHEN=(WHEN=(121,01,CH,GT,C' ',AND,02,02,CH,NE,C'EF'),
              OVERLAY=(04:121,07))                             
//*                                                             
Because it is possible that within input file (in the middle) there are other record with type (p.02,02) less than "10". Example:
Code:
 00xxxxxxxRec.000001 Must remain unaltered, so any rec. LT 10         
 01xxxxxxxRec.000002 Must remain unaltered, so any rec. LT 10         
 10   a   Rec.000003 On output pos.4,7 must have 0000001 << Subgroup   
 20   a   Rec.000004 On output pos.4,7 must have 0000001 << Subgroup   
 30   a   Rec.000005 On output pos.4,7 must have 0000001 << Subgroup   
 10   b   Rec.000006 On output pos.4,7 must have 0000002 << Subgroup   
 20   b   Rec.000007 On output pos.4,7 must have 0000002 << Subgroup   
 30   b   Rec.000008 On output pos.4,7 must have 0000002 << Subgroup   
 10   c   Rec.000009 On output pos.4,7 must have 0000003 << Subgroup   
 00xxxxxxxRec.000001 Must remain unaltered, so any rec. LT 10         
 20   c   Rec.000010 On output pos.4,7 must have 0000003 << Subgroup   
 30   c   Rec.000011 On output pos.4,7 must have 0000003 << Subgroup   
 EF   G1  Rec.000012 End GROUP1   >SubGroups>NNNNNNN< Had to be 0000003
 10   c   Rec.000013 On output pos.4,7 must have 0000001 << Subgroup   
 20   c   Rec.000014 On output pos.4,7 must have 0000001 << Subgroup   
 30   c   Rec.000015 On output pos.4,7 must have 0000001 << Subgroup   
 10   d   Rec.000016 On output pos.4,7 must have 0000002 << Subgroup   
 20   d   Rec.000017 On output pos.4,7 must have 0000002 << Subgroup   
 30   d   Rec.000018 On output pos.4,7 must have 0000002 << Subgroup   
 10   e   Rec.000019 On output pos.4,7 must have 0000003 << Subgroup   
 20   e   Rec.000020 On output pos.4,7 must have 0000003 << Subgroup   
 30   e   Rec.000021 On output pos.4,7 must have 0000003 << Subgroup   
 10   f   Rec.000022 On output pos.4,7 must have 0000004 << Subgroup   
 20   f   Rec.000023 On output pos.4,7 must have 0000004 << Subgroup   
 30   f   Rec.000024 On output pos.4,7 must have 0000004 << Subgroup   
 EF   G2  Rec.000025 End GROUP2   >SubGroups>NNNNNNN< Had to be 0000004
 00xxxxxxxRec.000001 Must remain unaltered, so any rec. LT 10         
 01xxxxxxxRec.000002 Must remain unaltered, so any rec. LT 10         
 EF   G3  Rec.000026 End GROUP3   >SubGroups>NNNNNNN< Had to be 0000000
 00xxxxxxxRec.000001 Must remain unaltered, so any rec. LT 10         
With your solution the output was:
Code:
 00xxxxxxxRec.000001 Must remain unaltered, so any rec. LT 10           
 01xxxxxxxRec.000002 Must remain unaltered, so any rec. LT 10           
 100000001Rec.000003 On output pos.4,7 must have 0000001 << Subgroup   
 200000001Rec.000004 On output pos.4,7 must have 0000001 << Subgroup   
 300000001Rec.000005 On output pos.4,7 must have 0000001 << Subgroup   
 100000002Rec.000006 On output pos.4,7 must have 0000002 << Subgroup   
 200000002Rec.000007 On output pos.4,7 must have 0000002 << Subgroup   
 300000002Rec.000008 On output pos.4,7 must have 0000002 << Subgroup   
 100000003Rec.000009 On output pos.4,7 must have 0000003 << Subgroup   
 000000003Rec.000001 Must remain unaltered, so any rec. LT 10           
 200000003Rec.000010 On output pos.4,7 must have 0000003 << Subgroup   
 300000003Rec.000011 On output pos.4,7 must have 0000003 << Subgroup   
 EF   G1  Rec.000012 End GROUP1   >SubGroups>0000003< Had to be 0000003
 100000001Rec.000013 On output pos.4,7 must have 0000001 << Subgroup   
 200000001Rec.000014 On output pos.4,7 must have 0000001 << Subgroup   
 300000001Rec.000015 On output pos.4,7 must have 0000001 << Subgroup   
 100000002Rec.000016 On output pos.4,7 must have 0000002 << Subgroup   
 200000002Rec.000017 On output pos.4,7 must have 0000002 << Subgroup   
 300000002Rec.000018 On output pos.4,7 must have 0000002 << Subgroup   
 100000003Rec.000019 On output pos.4,7 must have 0000003 << Subgroup   
 200000003Rec.000020 On output pos.4,7 must have 0000003 << Subgroup   
 300000003Rec.000021 On output pos.4,7 must have 0000003 << Subgroup   
 100000004Rec.000022 On output pos.4,7 must have 0000004 << Subgroup   
 200000004Rec.000023 On output pos.4,7 must have 0000004 << Subgroup   
 300000004Rec.000024 On output pos.4,7 must have 0000004 << Subgroup   
 EF   G2  Rec.000025 End GROUP2   >SubGroups>0000004< Had to be 0000004
 000000000Rec.000001 Must remain unaltered, so any rec. LT 10           
 010000000Rec.000002 Must remain unaltered, so any rec. LT 10           
 EF   G3  Rec.000026 End GROUP3   >SubGroups>0000000< Had to be 0000000
 000000000Rec.000001 Must remain unaltered, so any rec. LT 10           
Instead of:
Code:
 00xxxxxxxRec.000001 Must remain unaltered, so any rec. LT 10         
 01xxxxxxxRec.000002 Must remain unaltered, so any rec. LT 10         
 100000001Rec.000003 On output pos.4,7 must have 0000001 << Subgroup   
 200000001Rec.000004 On output pos.4,7 must have 0000001 << Subgroup   
 300000001Rec.000005 On output pos.4,7 must have 0000001 << Subgroup   
 100000002Rec.000006 On output pos.4,7 must have 0000002 << Subgroup   
 200000002Rec.000007 On output pos.4,7 must have 0000002 << Subgroup   
 300000002Rec.000008 On output pos.4,7 must have 0000002 << Subgroup   
 100000003Rec.000009 On output pos.4,7 must have 0000003 << Subgroup   
 00xxxxxxxRec.000001 Must remain unaltered, so any rec. LT 10         
 200000003Rec.000010 On output pos.4,7 must have 0000003 << Subgroup   
 300000003Rec.000011 On output pos.4,7 must have 0000003 << Subgroup   
 EF   G1  Rec.000012 End GROUP1   >SubGroups>0000003< Had to be 0000003
 100000001Rec.000013 On output pos.4,7 must have 0000001 << Subgroup   
 200000001Rec.000014 On output pos.4,7 must have 0000001 << Subgroup   
 300000001Rec.000015 On output pos.4,7 must have 0000001 << Subgroup   
 100000002Rec.000016 On output pos.4,7 must have 0000002 << Subgroup   
 200000002Rec.000017 On output pos.4,7 must have 0000002 << Subgroup   
 300000002Rec.000018 On output pos.4,7 must have 0000002 << Subgroup   
 100000003Rec.000019 On output pos.4,7 must have 0000003 << Subgroup   
 200000003Rec.000020 On output pos.4,7 must have 0000003 << Subgroup   
 300000003Rec.000021 On output pos.4,7 must have 0000003 << Subgroup   
 100000004Rec.000022 On output pos.4,7 must have 0000004 << Subgroup   
 200000004Rec.000023 On output pos.4,7 must have 0000004 << Subgroup   
 300000004Rec.000024 On output pos.4,7 must have 0000004 << Subgroup   
 EF   G2  Rec.000025 End GROUP2   >SubGroups>0000004< Had to be 0000004
 00xxxxxxxRec.000001 Must remain unaltered, so any rec. LT 10         
 01xxxxxxxRec.000002 Must remain unaltered, so any rec. LT 10         
 EF   G3  Rec.000026 End GROUP3   >SubGroups>0000000< Had to be 0000000
 00xxxxxxxRec.000001 Must remain unaltered, so any rec. LT 10         
Maybe it's not a fine solution, but it works.

Any way, thanks a lot again.

Francesco
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: Thu Sep 20, 2018 11:01 am    Post subject: Reply with quote

fspino wrote:
kolusu",
Thanks for the explanation.

I had to add a command to your solution
Because it is possible that within input file (in the middle) there are other record with type (p.02,02) less than "10".


Maybe it's not a fine solution, but it works.

Any way, thanks a lot again.

Francesco


fspino,

First things first. Please have all your requirements stated upfront. we can only interpret your posts as we cannot look at your data.

Either way here is a simple fix.

Code:

//SYSIN    DD *                                                     
  OPTION COPY                                                       
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(2,2,CH,EQ,C'10'),                 
                PUSH=(121:ID=7)),                                   
        IFTHEN=(WHEN=(2,2,CH,EQ,C'EF'),                             
             OVERLAY=(129:SEQNUM,7,ZD))                             
                                                                   
  OUTREC IFOUTLEN=127,                                             
         IFTHEN=(WHEN=GROUP,BEGIN=(129,7,CH,GT,C' '),               
                 PUSH=(137:121,7)),                                 
         IFTHEN=(WHEN=(137,7,CH,GT,C' '),                           
              OVERLAY=(121:121,7,ZD,SUB,137,7,ZD,ZD,LENGTH=7),     
                  HIT=NEXT),                              << CHANGED
         IFTHEN=(WHEN=(002,2,CH,LT,C'10'),                << ADDED 
              OVERLAY=(121:4,7))                          << ADDED 
                                                                   
  OUTFIL IFOUTLEN=120,                                             
         IFTHEN=(WHEN=GROUP,BEGIN=(121,7,CH,GT,C' ',AND,           
                                   002,2,CH,NE,C'EF'),             
                 PUSH=(129:121,7),RECORDS=2),                       
         IFTHEN=(WHEN=(2,2,CH,EQ,C'EF'),                           
              OVERLAY=(046:129,7,UFF,M11,LENGTH=7),HIT=NEXT),       
         IFTHEN=(WHEN=(121,1,CH,GT,C' ',AND,2,2,CH,NE,C'EF'),       
              OVERLAY=(004:121,7))                                 
/*

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


Joined: 11 Aug 2018
Posts: 8
Topics: 1

PostPosted: Fri Sep 21, 2018 4:38 am    Post subject: Re: DFSORT - subgrouping Reply with quote

Hi kolusu,
about your sentence:
kolusu wrote:
First things first. Please have all your requirements stated upfront. we can only interpret your posts as we cannot look at your data.

in my first post there was:
fspino wrote:
1. If record type (position=2, length=2) is LESS than "10" and NOT EQUAL "EF" write output unchanged (same of input)
[/quote]
then this was a requirement.

Any way, which differences there are between my and your solution? On running, I mean.
These line was added on OUTFIL of mine:
Code:
         IFTHEN=(WHEN=(121,01,CH,GT,C' ',AND,02,02,CH,LT,C'10'),  <-- added
              OVERLAY=(04:04,07)),                                <-- added
These are the rows that you added in your solution (OUTREC):
Code:
                  HIT=NEXT),                              << CHANGED
         IFTHEN=(WHEN=(002,2,CH,LT,C'10'),                << ADDED
              OVERLAY=(121:4,7))                          << ADDED

The result is not always the same?
Thanks.
Francesco
Back to top
View user's profile Send private message
fspino
Beginner


Joined: 11 Aug 2018
Posts: 8
Topics: 1

PostPosted: Fri Sep 21, 2018 4:40 am    Post subject: Reply with quote

kolusu,
Moreover remember that "EF" is less than "10".
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 Sep 21, 2018 10:51 am    Post subject: Reply with quote

fspino,

What I meant by the statement "First things first. Please have all your requirements stated upfront. we can only interpret your posts as we cannot look at your data." is that I wasn't expecting 00 records in between the groups. And that is the reason I mentioned that we cannot look at the data.

fspino wrote:
Any way, which differences there are between my and your solution? On running, I mean. These line was added on OUTFIL of mine:


Execution wise there is NOT much of a difference. However my order of preference is to have like items processed together. In the OUTREC I am processing the groups and 00 records are part of the group. Even though EF is part of the group, we have an additional processing for that which is done in OUTFIL

fspino wrote:

Moreover remember that "EF" is less than "10".


It does NOT matter, as EF record is getting the value from position 129 instead of position 121. So irrespective of it is lower or higher I am specially processing the EF records on OUTFIL, so they would get the new value.

A minor update to my control cards is that I would expand the search in the LAST IFTHEN to seven bytes instead of just 1 byte.
Code:

         IFTHEN=(WHEN=(121,1,CH,GT,C' ',AND,2,2,CH,NE,C'EF'),       
              OVERLAY=(004:121,7))             


to
Code:

         IFTHEN=(WHEN=(121,7,CH,GT,C' ',AND,2,2,CH,NE,C'EF'),       
              OVERLAY=(004:121,7))             

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


Joined: 11 Aug 2018
Posts: 8
Topics: 1

PostPosted: Fri Sep 21, 2018 11:32 am    Post subject: Reply with quote

Thank you also for the explanation Kolusu and for invaluable support!

Bye
Francesco
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