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

Extracting fields from diff positions based on the first rec


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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
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
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
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
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
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Help in extracting data between doubl... DFSORT/ICETOOL 5
No new posts To search DB2 table based on Conditio... DB2 1
This topic is locked: you cannot edit posts or make replies. Merge 2 input files based on the reco... JCL & VSAM 2
Search our Forums:

Back to Top