Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Assistance required for WHEN=GROUP scenario

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
thirumalasetty

New User


Joined: 17 Jun 2014
Posts: 13
Location: india

PostPosted: Wed Sep 10, 2014 12:56 am    Post subject: Assistance required for WHEN=GROUP scenario
Reply with quote

Hi,

Can you review and provide your suggestion for the below scenario.

My input file has a set of groups. Each group begins with a record starts with the characters ISA and ends with a record that starts with IEA. Anything in between these records (including these 2 records) is a GROUP.

My requirement is to identify such groups along with another condition : if every 3rd record of the group starts with characters GS, then I need that particular group be captured into an output file.

I have tried the below code and stuck up in between. Any assistance would be greatly appreciated.

Code:
INREC IFTHEN=(WHEN=GROUP,                                   
          BEGIN=(1,1,CH,EQ,C'ISA'),                         
          PUSH=(81:ID=8,90:SEQ=6)),                         
          IFTHEN=(WHEN=(90,6,ZD,EQ,3),OVERLAY=(95:C'GS'))
SORT FIELDS=COPY   


Thank You.
Rajesh.
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Wed Sep 10, 2014 1:52 am    Post subject: Reply to: Assistance required for WHEN=GROUP scenario
Reply with quote

You are testing 1,1 for C'ISA'. That isn't going to work, although it may look like it works if there are no other "C"s in the first column of the records.

You don't have any code to END the group. You will need to check also that the end of the group is present, it doesn't know way up at the top of the group that there is going to be an ending record.

You don't test for the value on the third record, you are just adding a constant to the third record of a group, all of them.

Can there be a starting record without an ending record in your data? Can you provide representative sample data, and expected output?
Back to top
View user's profile Send private message
thirumalasetty

New User


Joined: 17 Jun 2014
Posts: 13
Location: india

PostPosted: Wed Sep 10, 2014 2:03 am    Post subject: Reply to: Assistance required for WHEN=GROUP scenario
Reply with quote

Hi,

Here is the sample INPUT data and expected OUTPUT data; END record is there too in the group, that would have IEA as first 3 characters in it.

INPUT -

Code:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
ISA*00*          *00*          *08*9254110IAF     *08*9254110060     *140909*140
0*¬*00501*000060720*0*P*>~                                                     
GS*FA*5137624126*5137624388*20140909*1400*3748790*T*005010UCS~                 
ST*997*003748789~                                                               
AK1*OG*20787~                                                                   
AK2*875*20787001~                                                               
IEA*1*000060720~                                                               
ISA*00*          *00*          *01*6151957240001  *08*9254110060     *140909*111
0*¬*00501*000011841*0*P*>~                                                     
LL*FA*6151957240001*5137624388*20140909*1110*11839*X*005010~                   
ST*997*000000001~                                                               
AK1*PO*11911~                                                                   
AK5*A~                                                                         
IEA*1*000060720~                                                               
ISA*00*          *00*          *01*6151957240001  *08*9254110060     *140909*111
0*¬*00501*000011841*0*P*>~                                                     
GS*FA*6151957240001*5137624388*20140909*1110*11839*X*005010~                   
ST*997*000000001~                                                               
IEA*1*000011841~                                                               
ISA*00*          *00*          *08*9254110IAF     *08*9254110060     *140909*140
0*¬*00501*000060720*0*P*>~                                                     
GS*FA*5137624126*5137624388*20140909*1400*3748790*T*005010UCS~                 
ST*997*003748789~                                                               
AK1*OG*20787~                                                                   
AK2*875*20787001~                                                               
IEA*1*000060720~                                                               
ISA*00*          *00*          *01*6151957240001  *08*9254110060     *140909*111
0*¬*00501*000011841*0*P*>~                                                     
LL*FA*6151957240001*5137624388*20140909*1110*11839*X*005010~                   
ST*997*000000001~                                                               
AK1*PO*11911~                                                                   
AK5*A~                                                                         
IEA*1*000060720~                                                               
ISA*00*          *00*          *01*6151957240001  *08*9254110060     *140909*111
0*¬*00501*000011841*0*P*>~                                                     
GS*FA*6151957240001*5137624388*20140909*1110*11839*X*005010~                   
ST*997*000000001~                                                               
IEA*1*000011841~                                                               



OUTPUT -

Code:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
ISA*00*          *00*          *08*9254110IAF     *08*9254110060     *140909*140
0*¬*00501*000060720*0*P*>~                                                     
GS*FA*5137624126*5137624388*20140909*1400*3748790*T*005010UCS~                 
ST*997*003748789~                                                               
AK1*OG*20787~                                                                   
AK2*875*20787001~                                                               
IEA*1*000060720~                                                               
ISA*00*          *00*          *01*6151957240001  *08*9254110060     *140909*111
0*¬*00501*000011841*0*P*>~                                                     
GS*FA*6151957240001*5137624388*20140909*1110*11839*X*005010~                   
ST*997*000000001~                                                               
IEA*1*000011841~                                                               
ISA*00*          *00*          *08*9254110IAF     *08*9254110060     *140909*140
0*¬*00501*000060720*0*P*>~                                                     
GS*FA*5137624126*5137624388*20140909*1400*3748790*T*005010UCS~                 
ST*997*003748789~                                                               
AK1*OG*20787~                                                                   
AK2*875*20787001~                                                               
IEA*1*000060720~                                                               
ISA*00*          *00*          *01*6151957240001  *08*9254110060     *140909*111
0*¬*00501*000011841*0*P*>~                                                     
GS*FA*6151957240001*5137624388*20140909*1110*11839*X*005010~                   
ST*997*000000001~                                                               
IEA*1*000011841~   
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Wed Sep 10, 2014 4:05 am    Post subject: Reply to: Assistance required for WHEN=GROUP scenario
Reply with quote

Try this. You will need to understand it. If you do have a group without the end record, and with the GS in the third position, it will be extracted and remember that the group will run on until the next start. You said it can't happen, so this is a solution.

Code:
  INREC IFTHEN=(WHEN=GROUP,
               BEGIN=(1,3,CH,EQ,C'ISA'),
               END=(1,3,CH,EQ,C'IEA'),
               PUSH=(81:ID=8,90:SEQ=6)),
       IFTHEN=(WHEN=GROUP,
               BEGIN=(90,6,CH,EQ,C'000001'),
               PUSH=(100:1,80),
               RECORDS=3),
       IFTHEN=(WHEN=GROUP,
               BEGIN=(90,6,CH,EQ,C'000002'),
               PUSH=(180:1,80),
               RECORDS=2),
       IFTHEN=(WHEN=GROUP,
               BEGIN=(90,6,CH,EQ,C'000003',
                     AND,1,2,CH,EQ,C'GS'),
               END=(1,3,CH,EQ,C'IEA'),
                     PUSH=(97:1,2))
 SORT FIELDS=COPY
 OUTFIL INCLUDE=(90,6,CH,GE,C'000003',
                AND,
                 97,2,CH,EQ,C'GS'),
        IFTHEN=(WHEN=(90,6,CH,EQ,C'000003'),
                 BUILD=(100,80,/,
                       180,80,/,
                       1,80)),
        IFTHEN=(WHEN=NONE,
                 BUILD=(1,80))
Back to top
View user's profile Send private message
thirumalasetty

New User


Joined: 17 Jun 2014
Posts: 13
Location: india

PostPosted: Wed Sep 10, 2014 4:00 pm    Post subject: Reply to: Assistance required for WHEN=GROUP scenario
Reply with quote

Hi Bill, The code ran fine, but the output looks exactly same as the input. Here are the messages from the spool; There seems to be a condition missing to eliminate other GROUPs of records which doesn't have a value of "GS" in first 2 characters of 3rd record. I'm looking at my end to see if I can find out any gap, but would you please let me know if you see an issue with the code.



Code:
SYNCSORT LICENSED FOR CPU SERIAL NUMBER XXXXX, MODEL XXXX XX            LICENSE/PRODUCT EXPIRATION DATE: 31 DEC 2016
SYSIN :                                                                                                               
  INREC IFTHEN=(WHEN=GROUP,                                             00009804                                       
                 BEGIN=(1,3,CH,EQ,C'ISA'),                              00009904                                       
                 END=(1,3,CH,EQ,C'IEA'),                                00010004                                       
                 PUSH=(81:ID=8,90:SEQ=6)),                              00010104                                       
         IFTHEN=(WHEN=GROUP,                                            00010204                                       
                 BEGIN=(90,6,CH,EQ,C'000001'),                          00010304                                       
                 PUSH=(100:1,80),                                       00010404                                       
                 RECORDS=3),                                            00010504                                       
         IFTHEN=(WHEN=GROUP,                                            00010604                                       
                 BEGIN=(90,6,CH,EQ,C'000002'),                          00010704                                       
                 PUSH=(180:1,80),                                       00010804                                       
                 RECORDS=2),                                            00010904                                       
         IFTHEN=(WHEN=GROUP,                                            00011004                                       
                 BEGIN=(90,6,CH,EQ,C'000003',&,1,2,CH,EQ,C'GS'),        00012005                                       
                 END=(1,3,CH,EQ,C'IEA'),                                00014005                                       
                 PUSH=(97:1,2))                                         00015005                                       
  SORT FIELDS=COPY                                                      00016004                                       
   OUTFIL INCLUDE=(90,6,CH,GE,C'000003',&,97,2,CH,EQ,C'GS'),             00017005     
          IFTHEN=(WHEN=(90,6,CH,EQ,C'000003'),                           00020005     
                  BUILD=(100,80,/,                                       00030005     
                        180,80,/,                                        00040005     
                        1,80)),                                          00050005     
          IFTHEN=(WHEN=NONE,                                             00060005     
                  BUILD=(1,80))                                          00070005     
 WER108I  SORTIN   : RECFM=FB   ; LRECL=    80; BLKSIZE= 27920                         
 WER073I  SORTIN   : DSNAME=D956.EDISQ.PBACKUP.INBOUND.EDIDATA.G3172V00               
 WER257I  INREC RECORD LENGTH =   259                                                 
 WER238I  POTENTIALLY INEFFICIENT USE OF INREC                                         
 WER110I  SORTOUT  : RECFM=FB   ; LRECL=    80; BLKSIZE= 27920                         
 WER074I  SORTOUT  : DSNAME=#956.EDISQ.PBACKUP.INBOUND.EDID                           
 WER405I  SORTOUT  :  DATA RECORDS OUT      23133; TOTAL RECORDS OUT      23507       
 WER449I  SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE                                         
 WER054I  RCD IN      23507, OUT      23507                                           
 WER169I  RELEASE 1.4 BATCH 0520 TPF LEVEL 0.1                                         
 WER052I  END SYNCSORT - #9101164,SORT001,,DIAG=8200,51CE,AA00,00E6,CAFE,6DE2,AA08,2CE4
EDITED: CPU details
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Wed Sep 10, 2014 4:53 pm    Post subject: Reply to: Assistance required for WHEN=GROUP scenario
Reply with quote

Did you run it with the sample data you provided?
Back to top
View user's profile Send private message
thirumalasetty

New User


Joined: 17 Jun 2014
Posts: 13
Location: india

PostPosted: Wed Sep 10, 2014 5:42 pm    Post subject: Reply to: Assistance required for WHEN=GROUP scenario
Reply with quote

Hi Bill,

My apologies. My input data has got all GS record groups. I have now changed the data and tested it multiple times again and have seen it is working perfectly fine. Thank you very much for being patient and for your time.

However, I understood the logic until SORT FIELDS=COPY. I did not completely understood the BUILD statement in the OUTFIL option.

Code:
OUTFIL INCLUDE=(90,6,CH,GE,C'000003',&,97,2,CH,EQ,C'GS'),
IFTHEN=(WHEN=(90,6,CH,EQ,C'000003'), 
                  BUILD=(100,80,/,                 
                        180,80,/,                       
                        1,80)),                           
          IFTHEN=(WHEN=NONE,                 
                  BUILD=(1,80))                     
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Wed Sep 10, 2014 6:06 pm    Post subject: Reply to: Assistance required for WHEN=GROUP scenario
Reply with quote

No problem. I know that. You'll only get output if GS is present on the third record of a group, and you were getting everything output, so GS was present in all groups.

Records one and two of a group will be ignored - their data has been appended to record three (strictly, record one's data is appended to records one through three, and record two's data appended to records two through three - record three is used because it has (or doesn't have) the GS on it).

When record three gets past the INCLUDE=, we need to strip out the extra data from that record, and make it into new records one and two again.

This is done with the slash operator (/). This, in BUILD in OUTFIL only, says "finished with the previous, now make a new record". If you look at the reporting functions of OUTFIL you'll find uses of it to create multiple lines for headers, trailers and control breaks as well.

So, from the third record of the original group (now the first record of the group) three records are created, firstly from the data on the original first record, then the data on the original second record, then the actual data belonging to the current record.

Then, for records which aren't the third, a simple BUILD to drop of the excess bytes (group ID, group sequence, GS marker, and 160 bytes of blank).

You can change that simple IFTHEN and BUILD to IFOUTLEN=80, once you understand the process. This will set the record-length to 80 at the end of IFTHEN processing.

If you want to see the data as it was created out of INREC, drop the IFTHEN processing on the OUTFIL and send the SORTOUT to a dataset. You can then see the extended records and the data they contain.
Back to top
View user's profile Send private message
thirumalasetty

New User


Joined: 17 Jun 2014
Posts: 13
Location: india

PostPosted: Wed Sep 10, 2014 6:20 pm    Post subject: Reply to: Assistance required for WHEN=GROUP scenario
Reply with quote

Thank you very much Bill. Everything makes sense now. Thank you for the explanation. I understood the first part even better now, yes, I would like to play around it to know more practically by directing the data to SORTOUT by dropping IFTHEN. Have a good day ahead icon_smile.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm
No new posts Get Record count in summary record fo... Atul Banke DFSORT/ICETOOL 21 Fri Sep 23, 2016 4:17 pm
No new posts Select first 2 group data vice_versa DFSORT/ICETOOL 10 Mon Jun 13, 2016 2:21 pm
No new posts FTP help required amitc23 All Other Mainframe Topics 3 Thu Apr 28, 2016 12:02 pm
No new posts Why Newcopy is required when we have ... DIXINSH CICS 5 Thu Apr 28, 2016 9:47 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us