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
 

 

Extracting fields from diff positions based on the first rec

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

Active User


Joined: 10 May 2007
Posts: 147
Location: India

PostPosted: Wed Mar 19, 2008 4:33 pm    Post subject: Extracting fields from diff positions based on the first rec
Reply with quote

Hi all,

Could you please help me out in the below issue?

Current Code:
Code:

//S030    EXEC PGM=SORT
//SYSOUT   DD  SYSOUT=*                                                 
//SORTIN   DD  DSN=MYFILE,                     
//             DISP=SHR                                                 
//SORTOUT  DD  DSN=MYFILE.SRT,                     
//             DISP=(NEW,CATLG,DELETE),
//DATACLAS=DCMULTIC,     
//             SPACE=(CYL,(5,20),RLSE)
//SYSIN    DD  *                                                       
  SORT FIELDS=(02,20,CH,A)                                               
  OMIT COND=(01,01,SS,EQ,C'0,9')                                         
  OUTREC FIELDS=(31:02,20,15X,                                           
                66:C';',                                               
                67:123,3)                                               
/*


The field1 i need to extract from input file is coming in 2 - 21 postion.
The field2 i need to extract is coming in 123 - 125 position in my input file.
Currently i am omitting Header and trailer records using Omit condition.

Now I have got one requirement. Depending on the Month present in the header record (56 - 57 position in input file), i have to pick the field2 from input file in different positions.

For EX, if the month is 01, then i have to extract 123 - 125 as field2 from input file
If the month is 02, then i have to extract 126 - 128 as field2 from input file and so on.

The details of the month is present in header record only and it can be identified by it's first position. It starts with '0'.

Could you please let me know how it can be done in DFSORT?

Thanks,
Sen
Back to top
View user's profile Send private message

sclater

New User


Joined: 22 Jun 2007
Posts: 14
Location: South Africa

PostPosted: Wed Mar 19, 2008 7:10 pm    Post subject:
Reply with quote

Hi senjay

Please have a look at this sort job that should do what you requested:

Code:
//S1    EXEC  PGM=ICETOOL                                             
//TOOLMSG  DD  SYSOUT=*                                               
//DFSMSG   DD  SYSOUT=*                                               
//IN       DD DSN=your.input.dataset                                                     
//OUT      DD DSN=your.output.dataset
//TOOLIN   DD    *                                                   
COPY FROM(IN) USING(CTL1)                                             
SORT FROM(IN) TO(OUT) USING(CTL2)                                     
/*                                                                   
//CTL1CNTL DD *                                                       
  OPTION STOPAFT=1                                               
  SUM FIELDS=NONE                                               
  OUTFIL FNAMES=CTL2CNTL,REMOVECC,                               
    HEADER1=('  SORT FIELDS=(02,20,CH,A)',/,                     
             '  OMIT COND=(01,01,SS,EQ,C''0,9'')',/,             
             '  OUTREC FIELDS=(31:02,2,5X,66:C'';'','),         
    IFTHEN=(WHEN=(56,2,CH,EQ,C'01'),                             
      BUILD=(C'  67:123,3)')),                                   
    IFTHEN=(WHEN=(56,2,CH,EQ,C'02'),                             
      BUILD=(C'  67:126,3'))                                   
/*                                                               
//CTL2CNTL DD DSN=&&C1,UNIT=SYSDA,SPACE=(TRK,(5,5)),DISP=(,PASS)
Back to top
View user's profile Send private message
senjay

Active User


Joined: 10 May 2007
Posts: 147
Location: India

PostPosted: Wed Mar 19, 2008 9:23 pm    Post subject: Reply to: Extracting fields from diff positions based on the
Reply with quote

Hi Sclater,

Thanks. It's giving me the expected output. I couldn't understand it fully. Could you explain in detail?
Back to top
View user's profile Send private message
senjay

Active User


Joined: 10 May 2007
Posts: 147
Location: India

PostPosted: Wed Mar 19, 2008 9:25 pm    Post subject: Reply to: Extracting fields from diff positions based on the
Reply with quote

I mean, the role of CTL2CNTL......
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Wed Mar 19, 2008 10:33 pm    Post subject: Reply to: Extracting fields from diff positions based on the
Reply with quote

senjay,

Here is an alternative way of doing it. We create a 1 record symbol statement depending on the the value of the header record and use it to populate the value.

So the output from step0100 will be as follows if it has 01 in pos 56.
Code:

HDRMNTH,123,03


we later use that in the next step to extract the desired field.

Code:

//STEP0100 EXEC PGM=ICEMAN 
//SYSOUT   DD SYSOUT=*     
//SORTIN   DD DSN=YOUR INPUT DSN,
//            DISP=SHR
//SORTOUT  DD DSN=&&T1,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//SYSIN    DD *                                           
  OPTION COPY,STOPAFT=1                                   
  OUTREC IFTHEN=(WHEN=(56,2,CH,EQ,C'01'),                 
         BUILD=(C'HDRMNTH,123,03',80:X)),                 
         IFTHEN=(WHEN=(56,2,CH,EQ,C'02'),                 
         BUILD=(C'HDRMNTH,126,03',80:X)),                 
         IFTHEN=(WHEN=(56,2,CH,EQ,C'03'),                 
         BUILD=(C'HDRMNTH,129,03',80:X)),                 
         IFTHEN=(WHEN=(56,2,CH,EQ,C'04'),                 
         BUILD=(C'HDRMNTH,132,03',80:X)),                 
         IFTHEN=(WHEN=(56,2,CH,EQ,C'05'),                 
         BUILD=(C'HDRMNTH,135,03',80:X)),                 
         IFTHEN=(WHEN=(56,2,CH,EQ,C'06'),                 
         BUILD=(C'HDRMNTH,138,03',80:X)),                 
         IFTHEN=(WHEN=(56,2,CH,EQ,C'07'),                 
         BUILD=(C'HDRMNTH,141,03',80:X)),                 
         IFTHEN=(WHEN=(56,2,CH,EQ,C'08'),                 
         BUILD=(C'HDRMNTH,144,03',80:X)),                 
         IFTHEN=(WHEN=(56,2,CH,EQ,C'09'),                 
         BUILD=(C'HDRMNTH,147,03',80:X)),                 
         IFTHEN=(WHEN=(56,2,CH,EQ,C'10'),                 
         BUILD=(C'HDRMNTH,150,03',80:X)),                 
         IFTHEN=(WHEN=(56,2,CH,EQ,C'11'),                 
         BUILD=(C'HDRMNTH,153,03',80:X)),                 
         IFTHEN=(WHEN=(56,2,CH,EQ,C'12'),                 
         BUILD=(C'HDRMNTH,156,03',80:X))                 
/*
//STEP0200 EXEC PGM=ICEMAN       
//SYSOUT   DD SYSOUT=*           
//SYMNAMES DD DSN=&&T1,DISP=SHR
//SORTIN   DD DSN=YOUR INPUT DSN,
//            DISP=SHR
//SORTOUT  DD DSN=YOUR OUTPUT DSN,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//SYSIN    DD *                                   
  OMIT COND=(1,1,SS,EQ,C'0,9')                     
  SORT FIELDS=(2,20,CH,A)                         
  OUTREC BUILD=(31:02,20,15X,66:C';',67:HDRMNTH)   
/*
Back to top
View user's profile Send private message
senjay

Active User


Joined: 10 May 2007
Posts: 147
Location: India

PostPosted: Thu Mar 20, 2008 9:30 am    Post subject: Reply to: Extracting fields from diff positions based on the
Reply with quote

Hi Sclater,

I understood your concept. Thanks.

Hi Kolusu,

Thanks for the alternate solution.
Back to top
View user's profile Send private message
sclater

New User


Joined: 22 Jun 2007
Posts: 14
Location: South Africa

PostPosted: Thu Mar 20, 2008 10:10 pm    Post subject: Re: Reply to: Extracting fields from diff positions based on
Reply with quote

senjay wrote:
I mean, the role of CTL2CNTL......


The output from the first sort (ctl1cntl) is used as the sort statements for the second sort (ctl2cntl). Hope it makes sense
Back to top
View user's profile Send private message
Devzee

Active Member


Joined: 20 Jan 2007
Posts: 684
Location: Hollywood

PostPosted: Fri Mar 21, 2008 10:19 am    Post subject:
Reply with quote

Skolusu Your alternate solution is lengthy code when compared to previous solution. Isnt it?
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Fri Mar 21, 2008 9:25 pm    Post subject:
Reply with quote

Devzee,

The solution I posted is not lengthy. I expanded the solution for complete requirement where as the prior solution considered only first 2 months. This is the actual requirement.

senjay wrote:
For EX, if the month is 01, then i have to extract 123 - 125 as field2 from input file If the month is 02, then i have to extract 126 - 128 as field2 from input file and so on.


Op wanted to pick the fields depending on the value of the month. I expanded the solution for complete 12 months and I am NOT creating the control cards on the fly all the time. I just create 1 symbol to pick the position depending on the month.
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 JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts DFSORT MUL FIELDS tspr52 DFSORT/ICETOOL 16 Fri Mar 03, 2017 11:53 pm
No new posts Inserting records based on conditions vickey_dw DFSORT/ICETOOL 9 Wed Feb 22, 2017 1:33 pm
No new posts Sort two file having same field, one ... himanshu malik DFSORT/ICETOOL 7 Thu Feb 02, 2017 10:09 am
No new posts SYNCSORT SEQNUM and FI fields. nartcr SYNCSORT 7 Sat Jan 21, 2017 4:02 am


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