IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Group selective VB records - Trailer Position is dynamic


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Premnath_TJ

New User


Joined: 13 Sep 2020
Posts: 6
Location: India

PostPosted: Sun Sep 13, 2020 3:38 am
Reply with quote

Hi ,

This is my first post in IBM Mainframe Forum.Need your help & support .Below is my query .
Input file Type : VB Record Length:600
Using DFSORT WHEN=GROUP option below needs to be achieved .(I went through the tutorials and documents ,I could not find one for below scenario .can some one help me out by sharing a dfsort card FOR WHEN=GROUP for below scenario please .)
Step 1 :Identify a detail record based on a string in a particular position
Step2: Group all those records from header to trailer (only those groups that contains that detail record identified above in step1)(record count would vary)
Note: Header identifier position is fixed and trailer identifier position is dynamic and is not predetermined .Which means I should read from a particular record(header) till I identify a Trailer indicator which could be at any position after any number of records.

Header record : Will be identified by ISPF COMMAND F all X’22003A’ 19 (Header is always at position 19.No change)

Trailer Record: Here is the problem .This is dynamic .Some times it could be in position 50 ,sometimes it could be in position 45 .it is identified by ISPF COMMAND F X’220D0A’.Below are few example of various position of trailers which is dynamic and could not be predetermined with respect to position and number of records after which I would get the trailer identifier .

Detail record: (This is fixed.at position 20 shown below identify those detail records using ispf command F X’153A25’ 20. Whenever we identify this record is found ,I need to write all records from header to trailer(which contains this particular detail record at position 20)


I have attached a document which contains the complete details of file of what iam asking above .if some one could help me out in providing the dfsort card for this that would be really helpful for me

Attachment deleted - please post as normal text using code tags for any code and data
Back to top
View user's profile Send private message
Premnath_TJ

New User


Joined: 13 Sep 2020
Posts: 6
Location: India

PostPosted: Sun Sep 13, 2020 3:52 am
Reply with quote

summarizing above situation with simple example .
I want to group a set of records if a particular record is found in the group ..for eg :
Input
Code:

HDR==> this is fixed position
1XXY
2YYYX
3ZZX
TRL==> this is in dynamic position
HDR==> this is fixed position
122X ---> detail record found here ,so write this group of all records under this header and trailer
2XX2
3XXX3
TRL==> this is in dynamic position

Criteria: Group only those records that contains a detail record "22" in bytes 2 and 3
Output
Code:

HDR
122X
2XX2
3XXX3
TRL


Edit by Moderator to
1 - remove shouting (CAPITAL letters)
2 - insert codes tags
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2141
Location: USA

PostPosted: Sun Sep 13, 2020 4:12 am
Reply with quote

Do not use attachments, use code tags instead!

(If you want others to read your code!)
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2454
Location: Hampshire, UK

PostPosted: Sun Sep 13, 2020 4:38 pm
Reply with quote

You posted in a forum for experts so you have, presumably, tried something so show what you have tried and why it fails to work for you.
Back to top
View user's profile Send private message
Premnath_TJ

New User


Joined: 13 Sep 2020
Posts: 6
Location: India

PostPosted: Sun Sep 13, 2020 8:32 pm
Reply with quote

Nic Clouston wrote:
You posted in a forum for experts so you have, presumably, tried something so show what you have tried and why it fails to work for you.


Tried to copy the code and abend sysout info in system which i am unable to copy due to permission issues for now .need to login from office laptop which would take while .Tried when=group option.

If some one could provide me a dfsort solution for this above problem ,that would be really helpful for where iam stuck up now in my project ..apologise i could not post my sysout here .Need experts help here for me .
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1337
Location: Bamberg, Germany

PostPosted: Sun Sep 13, 2020 9:03 pm
Reply with quote

Code:
//EXPERT   EXEC PGM=ICEMAN                                           
//F1       DD DISP=SHR,DSN=<your_input_dsn>                               
//F2       DD DISP=SHR,DSN=<your_input_dsn>                               
//SYSOUT   DD SYSOUT=*                                               
//SORTOUT  DD DSN=&SYSUID..WHATEVER,                                 
//            DISP=(NEW,CATLG),UNIT=SYSALLDA,                         
//            SPACE=(TRK,(2,1),RLSE),                                 
//            DSORG=PS,RECFM=VB,LRECL=600,BLKSIZE=0                   
//SYSIN    DD *                                                       
  OPTION COPY                                                         
  JOINKEYS F1=F1,FIELDS=(601,8,A),TYPE=V                             
  JOINKEYS F2=F2,FIELDS=(601,8,A),TYPE=V                             
  REFORMAT FIELDS=(F1:5,596,F2:609,8)                                 
  OUTFIL FNAMES=(SORTOUT),                                           
    OMIT=(597,8,BI,EQ,+0),                                           
    REMOVECC,FTOV,                                                   
    BUILD=(1,596)                                                     
  END                                                                 
/*                                                                   
//JNF1CNTL DD *                                                       
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(609:8Z)),                         
    IFTHEN=(WHEN=GROUP,                                               
      BEGIN=(23,3,BI,EQ,X'22003A'),END=(5,596,SS,EQ,X'220D0A'),       
      PUSH=(601:ID=8))                                               
  END                                                                 
/*                                                                   
//JNF2CNTL DD *                                                       
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(609:8Z)),                         
    IFTHEN=(WHEN=GROUP,                                               
      BEGIN=(23,3,BI,EQ,X'22003A'),END=(5,596,SS,EQ,X'220D0A'),       
      PUSH=(601:ID=8)),                                               
    IFTHEN=(WHEN=(24,3,BI,EQ,X'153A25'),OVERLAY=(609:+1,BI,LENGTH=8))
    SUM FIELDS=(609,8,BI)                                             
  END                                                                 
/*
Back to top
View user's profile Send private message
Premnath_TJ

New User


Joined: 13 Sep 2020
Posts: 6
Location: India

PostPosted: Mon Sep 14, 2020 12:56 am
Reply with quote

Thanks for your help and support sir .Below is the output when your code is used which is actually not the expected one .

Code:

****** ***************************** Top of Data ******************************
000001 1537159 t 0 Ç 6lpl Ì 9 &d 0 0 &d ç 0 ã 0 1 0
FFFFFFF000A00F0301203063F999307303F3583F3F358332003133243F32343F3F3F0000
15371590003010080420A68A6373A08A1A9A04A0A0A04AA047A18A08A0A3A6A0A1A00000
------------------------------------------------------------------------------
000002 1537159 t 0 qËáÈ 4Á àr 4 3 0
FFFFFFF000A00F0100203000000974703F63493F3F3F2244444444444444444444444444
153715900030200C0726A00000583544A45A49A4A3A02C00000000000000000000000000
------------------------------------------------------------------------------
000003 1537159 t 0 /  0 0 0
FFFFFFF000A00F010020333006643F3F3F33003333322444444444444444444444444444
153715900030300B0D29A2A02121A0A0A0AA00AAAAA2C000000000000000000000000000
------------------------------------------------------------------------------
000004 1537159 t 0 6 &d 0 8 0 &d å ç 1
FFFFFFF000A00F0301213F3583000000003F3F3F358343333433333333213003F3333224
15371590003040050122A6A04A00000000A0A8A0A04A738318A000000A92A00A1AAAA2C0
------------------------------------------------------------------------------
-
-
-


Above is not the expectation .

Actual expectation:DFSORT should only segregate and write to output file "only those GROUP OF RECORDS (THAT CONTAINS ANY ONE or atleast one 1525 record in detail records "(For eg : The group could contain any number of records of various types of strings (1524 or 1523 or 1234 etc) .But if any one record with string 1525 is found then immediately the entire group of records from header to trailer needs to be written in output file .

1.There is only one input file available which dfsort is going to take as input .There are no two input files .
2.Header record :Will be identified by ISPF COMMAND F all X’22003A’ 19 (Header is always at position 19.No change)
3.Trailer Record: Here is the problem .This is dynamic .Some times it could be in position 50 ,sometimes it could be in position 45 .it is identified by ISPF COMMAND F X’220D0A’.Dynamic and could not be predetermined with respect to position and number of records after which I would get the trailer identifier .
4.Detail record (This is fixed.at position 20 shown below identify those detail records using ispf command
F X’153A25’ 20. Whenever we identify this record is found ,I need to write all records from header to trailer(which contains this particular detail record at position 20)

Expected output :(should contain only group of records from header to trailer (all records written) whenever atleast any one single detail record is identified x'153A25" in the group.Write all records in the group to output file without any change .But only those groups to outputfile.(For eg: if mutiple groups contains that detail record 153a25,then all such multiple groups of records from header to trailer needs to be written to the o/p file .But only those multiple groups that contains 153a25 in detail record






Code:

000008 1537159 t 0 Ç 6lpl Ì 9 &d 0 0 &d ç 0 ã 0 1 0
FFFFFFF000A00F0301203063F999307303F3583F3F358332003133243F32343F3F3F0000
15371590003010080420A68A6373A08A1A9A04A0A0A04AA047A18A08A0A3A6A0A1A00000  ==>Header record (ispf command F all X’22003A’ 19)
------------------------------------------------------------------------------
000009 1537159 t 0 qËáÈ 4Á àr 4 3 0
FFFFFFF000A00F0100203000000974703F63493F3F3F2244444444444444444444444444
153715900030200C0726A00000583544A45A49A4A3A02C00000000000000000000000000
------------------------------------------------------------------------------
000010 1537159 t 0 /  0 0 0
FFFFFFF000A00F010020333006643F3F3F33003333322444444444444444444444444444
153715900030300B0D29A2A02121A0A0A0AA00AAAAA2C000000000000000000000000000
------------------------------------------------------------------------------
000011 1537159 t 0 6 &d 0 8 0 &d å ç 1
FFFFFFF000A00F0301213F3583000000003F3F3F358343333433333333213003F3333224
15371590003040050122A6A04A00000000A0A8A0A04A738318A000000A92A00A1AAAA2C0
------------------------------------------------------------------------------
000012 1537159 t 0 ë çâä&|ëé   áë äâä &. äë &/ÀÀÑ>Å       
FFFFFFF000A00F05002[b]132[/b]31003444545543334452444254345356666663443433333433
15371590003050030D2[b]5A5[/b]A204A8230F31115A153F323F0BA33501449E7A117134560172 ==> detail record 153a25 IDENTIFIED in position 20,so write this entire group of records without changing anything to output file .also write all such similar groups to output file .
------------------------------------------------------------------------------
000013 1537159 t 0 A 100
FFFFFFF000A00F010021313C310301033FFF224444444444444444444444444444444444
15371590003060040725A3A1A00A000AA1002C0000000000000000000000000000000000
------------------------------------------------------------------------------
000014 1537159 t 0 0 5e 0 0 0
FFFFFFF000A00F0000213F3F83F3F3F22444444444444444444444444444444444444444
153715900030700F0624A0A55A0A0A02C000000000000000000000000000000000000000
------------------------------------------------------------------------------
000015 1537159 t 0 1 &Ì Ã &d
FFFFFFF000A00F010021303F223573263583122444444444444444444444444444444444
15371590003080050725A2A148A08A26A04A12C000000000000000000000000000000000
------------------------------------------------------------------------------
000016 1537159 t 0 Ã Ç Ì î â
FFFFFFF000A00F0200213630630731330313503133031340[b]200[/b]444444444444444444444
15371590003090010825A6A68A08A1720A1760A1800A1820[b]2DA0[/b]00000000000000000000   ==> last record with delimiter F  X’220D0A’( this could be at  any position for other group of records .This could be considered as trailer record but with no defined particular position


Please kindly help me out in grouping these set of records and writing to seperate file which has a dynamic position trailer whenever it identifies atleast one single 153a25 RECORD IN detail of input file .Thanks for all your support
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1337
Location: Bamberg, Germany

PostPosted: Mon Sep 14, 2020 8:05 am
Reply with quote

One more to try:
Code:
//EXPERT   EXEC PGM=ICEMAN                                           
//F1       DD DISP=SHR,DSN=<your_input_dsn>                               
//F2       DD DISP=SHR,DSN=<your_input_dsn>                               
//SYSOUT   DD SYSOUT=*                                               
//SORTOUT  DD DSN=&SYSUID..WHATEVER,                                     
//            DISP=(NEW,CATLG),UNIT=SYSALLDA,                       
//            SPACE=(TRK,(2,1),RLSE),                               
//            DSORG=PS,RECFM=VB,LRECL=600,BLKSIZE=0                 
//SYSIN    DD *                                                     
  OPTION COPY,EQUALS                                                 
  JOINKEYS F1=F1,FIELDS=(601,8,A),TYPE=V                             
  JOINKEYS F2=F2,FIELDS=(601,8,A),TYPE=V                             
  REFORMAT FIELDS=(F1:5,596,F2:609,8)                               
  OUTFIL FNAMES=(SORTOUT),                                           
    OMIT=(597,8,BI,EQ,+0),                                           
    REMOVECC,FTOV,VLTRIM=C' ',                                       
    BUILD=(1,596)                                                   
  END                                                               
/*                                                                   
//JNF1CNTL DD *                                                     
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(609:8Z)),                         
    IFTHEN=(WHEN=GROUP,                                             
      BEGIN=(23,3,BI,EQ,X'22003A'),END=(5,596,SS,EQ,X'220D0A'),     
      PUSH=(601:ID=8))                                               
  END                                                               
/*                                                                   
//JNF2CNTL DD *                                                     
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(609:8Z)),                         
    IFTHEN=(WHEN=GROUP,                                             
      BEGIN=(23,3,BI,EQ,X'22003A'),END=(5,596,SS,EQ,X'220D0A'),     
      PUSH=(601:ID=8)),                                             
    IFTHEN=(WHEN=(24,3,BI,EQ,X'153A25'),OVERLAY=(609:+1,BI,LENGTH=8))
    SUM FIELDS=(609,8,BI)                                           
  END                                                               
/*
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2454
Location: Hampshire, UK

PostPosted: Mon Sep 14, 2020 4:29 pm
Reply with quote

Quote:
Tried to copy the code and abend sysout info in system which i am unable to copy due to permission issues for now

Surely you can simply cut and paste?
Back to top
View user's profile Send private message
Premnath_TJ

New User


Joined: 13 Sep 2020
Posts: 6
Location: India

PostPosted: Wed Sep 16, 2020 12:12 am
Reply with quote

@Joerg.Findeisen

You are Terrific ! Your code perfectly worked . This really helped me Sir. It took some time for me to validate the test results as the file was huge and complex .

I could see in other threads ,you had provided solutions & support for many people like me sir .This shows your depth of technical capabilities .You rock.Thanks a ton!
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1337
Location: Bamberg, Germany

PostPosted: Wed Sep 16, 2020 12:51 am
Reply with quote

Glad it worked as expected, thank you for letting us know. icon_wink.gif
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2141
Location: USA

PostPosted: Thu Sep 17, 2020 3:03 am
Reply with quote

Joerg.Findeisen wrote:
Glad it worked as expected, thank you for letting us know. icon_wink.gif

What is missing: any explanation, or even a minor note on the approach taken to resolve the original issue, including: not a single comment...

This is just a ready-to-use copy-and-paste solution to be used without a bit of understanding: how actually it works?

As the result, next day the forum to be re-filled with repeating and duplicated questions: “I have a requirement to calculate 2+2 using JCL...”

icon_pray.gif icon_axe.gif 12.gif
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3076
Location: NYC,USA

PostPosted: Thu Sep 17, 2020 6:46 am
Reply with quote

That’s true and similar requirements are already shared on this and other forums if TS would have done some research then would have got it. This won’t be necessarily present in manuals but what to use it present.
Back to top
View user's profile Send private message
Premnath_TJ

New User


Joined: 13 Sep 2020
Posts: 6
Location: India

PostPosted: Fri Oct 16, 2020 8:37 pm
Reply with quote

@Joerg.Findeisen
Just one more help.Wanted to segregate those group of records which DOES NOT contain any or not even a single X'153A25' records in the group which is straight opposite of above discussed scenario.

What did i try ?

IFTHEN=(WHEN=(24,3,BI,NE,X'153A25') ==> Not equal to X'153A25'

Code:
//JNF1CNTL DD *   
INREC IFTHEN=(WHEN=INIT,OVERLAY=(609:8Z)),   
IFTHEN=(WHEN=GROUP,   
BEGIN=(23,3,BI,EQ,X'22003A'),END=(5,596,SS,EQ,X'220D0A'),   
PUSH=(601:ID=8))   
END   
/*   
//JNF2CNTL DD *   
INREC IFTHEN=(WHEN=INIT,OVERLAY=(609:8Z)),   
IFTHEN=(WHEN=GROUP,   
BEGIN=(23,3,BI,EQ,X'22003A'),END=(5,596,SS,EQ,X'220D0A'),   
PUSH=(601:ID=8)),   
IFTHEN=(WHEN=(24,3,BI,NE,X'153A25'),OVERLAY=(609:+1,BI,LENGTH=8))   
SUM FIELDS=(609,8,BI)   
END   
/*   


Result i got was it was fetching all the records from all the groups .It did not exclude those groups which contained x'153a25' in position 20 in vb input file .

Expectation:
Input:
Header1
153a22
153a21
123a22
Trailer1
Header2
153a22
153a25
123a22
Trailer2
Header3
153a22
153a29
123a22
Trailer3

Expected output
Header1
153a22
153a21
123a22
Trailer1
Header3
153a22
153a29
123a22
Trailer3
I am learning a lot from this group .Thank you for your guidence and support
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1337
Location: Bamberg, Germany

PostPosted: Sat Oct 17, 2020 5:29 am
Reply with quote

Just change from:

Code:
OMIT=(597,8,BI,EQ,+0)

to:
Code:
INCLUDE=(597,8,BI,EQ,+0)

That should do it.
Back to top
View user's profile Send private message
premnath

New User


Joined: 08 Jan 2006
Posts: 15

PostPosted: Sat Oct 17, 2020 6:35 pm
Reply with quote

Thanks a ton Joerg.Findeisen! Learning new things in this forum and able to apply those in my day today work .
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1337
Location: Bamberg, Germany

PostPosted: Sat Oct 17, 2020 9:35 pm
Reply with quote

Thank you for the feedback. I like the forum for the same reason. icon_wink.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts combine multiple unique records into ... DFSORT/ICETOOL 2
No new posts To Omit records based n SORT condition DFSORT/ICETOOL 6
No new posts To fetch records that has Ttamp value... DFSORT/ICETOOL 5
No new posts ICETOOL returns no records JCL & VSAM 1
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
Search our Forums:

Back to Top