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
 

 

A complex File Formatting

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Niki

Active User


Joined: 20 Sep 2008
Posts: 102
Location: Bangalore

PostPosted: Fri Jan 20, 2012 1:24 am    Post subject: A complex File Formatting
Reply with quote

Hi All,

Could you please help me on one of the complex file formatting.


Input:
VB, 1000 LRECL

I need to pull the records from the input file, reformat it into a particular format and populate in the output file. The input file looks like below,

Input File:

Code:

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
QWESDRTYURLLL1234ASDAHB ASDAJHASJDH ASDJAHSDJ ASDJHA
QWSADASDERLL12345ASDAS ASDAKJASDKASKADAJ ASD1234
ERSDFQWQECPLER123ASDASD ASWERTKKKK3456 SDADASD
IO09JUHGLKINGHTYUJHYUPLER123KJASDUHA001ASDASD
ASDASDASSDAERWECWQEQ2PLER123ASDASECS09HSAASFASF
HASGTGVDSGFSFGGGFASFDPLER123ASDEECVR0KJASDFAGFCCCCASDASD
ASDASDASHHJCBHGHASGHJPLER123ASDEECVRKKLJASDFAGAA01AGRASFNT
QWEHHDBHGQWGHHBVQDGGHPLER123ASDAEWFJKLI ASDAJASD ASD
ERSDFQWQECXXX1236ASDASD ASWERTJNLO9876 SDADASD
IO09JUHGLKINGHTYUJHYUXXX1236KJASDUHB001ASDASD
ASDD234CASDF3424RSDFDXXX1236KJASDUHS34F001ASDASD
AWDAASDASDZZ30986ASDASDSADASD PPPP9876ASDASDA
ASDASDASDAASDASDASDADZZ30986ASDASAGB09I HGHF
ASDASDSADE34TSDFV44TVZZ30986ASD3CSER001 ASDAAS0987 ASDKJAKD
KJSDHJSDFHMSDGFVSDGHJZZ30986 ASHDGHR002 ASBNSDAAAA ASDAF,NJ
ASFSDGDK.MSNMBHSMMNMBZZ30986ASDAVCER003SDASF SBBBBDFDSF
LKJSKDFHYUBSDGHHVSDHGZZ30986DSVSDHJR004MA SCN CCCCNH AS
KASDBMDSFHJ G SMDF JBZZ30986 ASBHBJR005AS ASMJDDDDBMF MA
ASDGNVABCBCAGNCVNAGVNZZ30986ASDASBMS001 ASDMHABDSMBH
ERSDFQWQECPLER123ASDASD ASWERTKKKK3456 SDADASD
IO09JUHGLKINGHTYUJHYUPLER123KJASDUHA001ASDASD
ASDASDASSDAERWECWQEQ2PLER123ASDASECS09HSAASFASF
HASGTGVDSGFSFGGGFASFDPLER123ASDEECVR0KJASDFAGFZZZZASDASDCCCCASDASD
ASDASDASHHJCBHGHASGHJPLER123ASDEECVRKKLJASDFAGBB01JASKJAA01AGRASFNT
ASDASDASHHJCBHGHASGHJPLER123ASDEECVRKKLJASDFAGCC01JASKJAA01AGRASFNT
ASDASDASDASQWQWDASASDPLER123ASDAJBJASFASFJHASJDD01SADASJB ASHVAHSD\
ASSDFDXGDFHGF SFSFSDF DG DSGDS GDS GSG  DGS


Condition:

1) There are two kinds of records presentin the input file. For one, the key starts from position 11 to length 7. For the

second one the key position starts from 22 to 7. The second record is a kind of subset of the first one.

2) If for a main record, we have sub records associated then pull the main record and sub records as well if we have "R" at

position 36. There will be maximum 5 subrecords preset with value "R" in that position

3) The main key records can have duplicate entries as well in the file.

4) Basically need three kinds of output fils and should come with a FB and LRECL of 80. The output files should look like below,

One output should be,

From main record, 11 to 7 position, Space, 31th to 8 position.
From Sub records, 22 to 7, Space, 47 to 4 position


Code:


PLER123 KKKK3456
PLER123 CCCC
PLER123 AA01
ZZ30986 PPPP9876
ZZ30986 0987
ZZ30986 AAAA
ZZ30986 BBBB
ZZ30986 CCCC
ZZ30986 DDDD
PLER123 KKKK3456
PLER123 AA01
PLER123 BB01
PLER123 CC01



Second Output should merge the multiple rows into one and looks like below,

Code:

PLER123 KKKK3456 CCCC AA01
ZZ30986 PPPP9876 0987 AAAA BBBB CCCC DDDD
PLER123 KKKK3456 ZZZZ AA01 BB01 CC01




The third one should get the count of unique values which can be of 4 digits and looks like below,

Code:

PLER123 KKKK3456 CCCC 1
PLER123 KKKK3456 AA01 2
PLER123 KKKK3456 ZZZZ 1
PLER123 KKKK3456 BB01 1
PLER123 KKKK3456 CC01 1
ZZ30986 PPPP9876 0987 1
ZZ30986 PPPP9876 AAAA 1
ZZ30986 PPPP9876 BBBB 1
ZZ30986 PPPP9876 CCCC 1
ZZ30986 PPPP9876 DDDD 1



All the output should be of FB and LRERCL=80.
Back to top
View user's profile Send private message

Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Jan 20, 2012 1:45 am    Post subject:
Reply with quote

Niki,

Can you identify start of main record with ERS in the first 3 bytes? if not is there any thing unique that identifies the main record?
Back to top
View user's profile Send private message
Niki

Active User


Joined: 20 Sep 2008
Posts: 102
Location: Bangalore

PostPosted: Fri Jan 20, 2012 1:49 am    Post subject:
Reply with quote

Kolusu,

There is not specific identification of the main records. But the trick here would be we are not considering the main records if we dont have any sub ones.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Jan 20, 2012 2:04 am    Post subject:
Reply with quote

Niki wrote:
Kolusu,

There is not specific identification of the main records. But the trick here would be we are not considering the main records if we dont have any sub ones.


huh? if there is no unique identity to main records , how do you distinguish which positions to pick? You are picking fields from 4 different places and there should be a way to identify them.

If you can't identify the main record or the sub records how do you know which record to drop or which record to pick?
Back to top
View user's profile Send private message
Niki

Active User


Joined: 20 Sep 2008
Posts: 102
Location: Bangalore

PostPosted: Fri Jan 20, 2012 2:24 am    Post subject:
Reply with quote

Cannot we have some condition to check, If the first record value from 11 to 7 position is same as the next ones 22 to 7 then the prior one is the main record and the below one as the Sub records.

Because always the key value is getting stored in different places for main record and sub record.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1738
Location: Bloomington, IL

PostPosted: Fri Jan 20, 2012 3:49 am    Post subject:
Reply with quote

Niki wrote:
Cannot we have some condition to check

Of course we can. However, it is necessary that you tell us what the criteria are; we will not play "Hot and Cold" trying to drag them out of you.
Quote:
If the first record value from 11 to 7 position is same as the next ones 22 to 7 then the prior one is the main record and the below one as the Sub records.

Is that the complete and only criterion? Answer "yes" or "no". If the answer is "no", give us the complete list.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Jan 20, 2012 4:37 am    Post subject:
Reply with quote

I looked at this more closely and your shown output does NOT match the input. I don't see a sub record PLER123 AA01 for the 3rd group you show in your output. Where did you get this from?

Assuming that it is a typo, the following DFSORT JCL will give you the desired results.

Step0100 - will create the Output file 1 which will be used later to generate output files 2 and 3.

Step0300 - will create Output 2 and 3.

The only trick here is to use the same input file twice with Joinkeys and create a matched records whenever we find a sub record.

Since your input is a VB file you need to account for the RDW and all the fields you need actual start adding 4 bytes to the positions you mentioned.

Code:

//STEP0100 EXEC PGM=SORT                                     
//SYSOUT   DD SYSOUT=*                                       
//INA      DD DSN=Your input VB Lrecl=1000 file,DISP=SHR
//INB      DD DSN=Same input VB Lrecl=1000 file,DISP=SHR
//SORTOUT  DD DSN=Userid.Out1,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)   
//*
//SYSIN    DD *                                             
  JOINKEYS F1=INA,FIELDS=(24,7,A)                           
  JOINKEYS F2=INB,FIELDS=(05,7,A)                           
  REFORMAT FIELDS=(F1:5,9,24,7,44,8,F2:5,12,26,9)           

  SORT FIELDS=(38,8,CH,A,1,8,CH,A),EQUALS                   

  OUTREC IFTHEN=(WHEN=GROUP,KEYBEGIN=(38,8),PUSH=(47:1,8))   

  OUTFIL INCLUDE=(1,8,CH,EQ,47,8,CH),REMOVECC,               
  BUILD=(25,13,80:X),SECTIONS=(38,8,HEADER3=(25,8,17,8))     
//*
//JNF1CNTL DD *                                             
  INREC BUILD=(1,4,SEQNUM,8,ZD,X,5)                         
//*
//JNF2CNTL DD *                                             
  INCLUDE COND=(40,1,CH,EQ,C'R')                             
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,26,7,X,51,4)),         
  IFTHEN=(WHEN=GROUP,KEYBEGIN=(5,7),PUSH=(27:ID=8))         
//*
//STEP0200 EXEC PGM=ICETOOL                                       
//TOOLMSG  DD SYSOUT=*                                           
//DFSMSG   DD SYSOUT=*                                           
//IN       DD DSN=Userid.Out1,DISP=SHR                                   
//OUT2     DD SYSOUT=*                                           
//OUT3     DD SYSOUT=*                                           
//TOOLIN   DD *                                                   
  SPLICE FROM(IN) TO(OUT2) ON(1,8,CH) WITH(18,5) WITH(24,5) -     
  WITH(30,5) WITH(36,5) WITH(42,5) WITHANY USING(CTL1)           
  SORT FROM(IN) TO(OUT3) USING(CTL2)                             
//*                                                               
//CTL1CNTL DD *                                                   
  SORT FIELDS=COPY                                               
  INREC IFOUTLEN=80,                                             
  IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,7),PUSH=(81:SEQ=1)),             
  IFTHEN=(WHEN=(81,1,ZD,EQ,1),OVERLAY=(18:30X)),                 
  IFTHEN=(WHEN=(81,1,ZD,EQ,2),OVERLAY=(18:9,5)),                 
  IFTHEN=(WHEN=(81,1,ZD,EQ,3),OVERLAY=(24:9,5)),                 
  IFTHEN=(WHEN=(81,1,ZD,EQ,4),OVERLAY=(30:9,5)),                 
  IFTHEN=(WHEN=(81,1,ZD,EQ,5),OVERLAY=(36:9,5)),                 
  IFTHEN=(WHEN=(81,1,ZD,EQ,6),OVERLAY=(42:9,5))                   
//*                                                               
//CTL2CNTL DD *                                                   
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(21:22X)),                     
  IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,7),PUSH=(21:SEQ=1,1,16)),       
  IFTHEN=(WHEN=(21,1,ZD,GT,1),OVERLAY=(38:9,5))                   
  SORT FIELDS=(22,21,CH,A),EQUALS                                 
  OUTFIL REMOVECC,NODETAIL,BUILD=(80X),OMIT=(38,5,CH,EQ,C' '),   
  SECTIONS=(22,21,TRAILER3=(22,16,X,38,5,COUNT=(M10,LENGTH=2)))   
//*
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Fri Jan 20, 2012 4:42 am    Post subject: Reply to: A complex File Formatting
Reply with quote

Isn't every program which reads this file faced with the same problem? It would only know whether a record is "main" (except for the first one) by reference to the previous record? Which could be a "main" or a "sub". Even ignoring the possibility of an unfortunate mismatch of keys (where data happens to equal key value) it is a pretty absurd (rather than complex) structure.

Why don't you change the program which creates the file to include a record-type?

If that is somehow "impossible", why don't you "post-process" the file to include a record-type so that the rest of the system can know easily what is going on? Except...

If the original program creates a sub-record with an incorrect key, you are pickled, as you now have a new "main" record, as are any genuine sub-records which follow it.

Change the program which creates the file, or your system deserves everything it has coming to it.
Back to top
View user's profile Send private message
Niki

Active User


Joined: 20 Sep 2008
Posts: 102
Location: Bangalore

PostPosted: Fri Jan 20, 2012 9:59 pm    Post subject:
Reply with quote

Thanks Kolusu. It is really going to help me.

Bill,
Yes because of all these inconsistencies, we are haveing an re-engineering in our system.
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 -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm


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