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
 

 

Extract last 2 bytes from a field in input file

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

New User


Joined: 09 Feb 2009
Posts: 57
Location: India

PostPosted: Wed Jul 30, 2014 2:50 pm    Post subject: Extract last 2 bytes from a field in input file
Reply with quote

Hi,

I have an input file holding data as shown below:
Code:

----+----1----+----2----+----3----+----4----+----5
ABCDP01   JEFF                                   
ABCD01    AUGS                                   
ABCDEFGH01ABEDFG                                 
ABC02     ABC                                     
A02       A                                       


Composite Key to my input file is present in first 10 bytes. e.g. Rec# 1, key is ABCDP01.

In the key the last 2 bytes are numeric.

I need to extract the last two bytes from the key and populate them in the output file starting at position 21. So, the final output should look like:

Code:

----+----1----+----2----+----3----+----4----+----5
ABCDP01   JEFF      01                           
ABCD01    AUGS      01                           
ABCDEFGH01ABEDFG    01                           
ABC02     ABC       02                           
A02       A         02                           


I am able to get the length of fields using below control cards:
Code:

//JS010    EXEC PGM=ICETOOL                                             
//TOOLMSG  DD SYSOUT=*                                                 
//DFSMSG   DD SYSOUT=*                                                 
//SYSOUT   DD SYSOUT=*                                                 
//SYSUDUMP DD SYSOUT=*                                                 
//DFSPARM  DD DSN=QCPPNP.CUS.PARMLIB(ADJEL050),DISP=SHR                 
//$ORTPARM DD DSN=QCPPNP.CUS.PARMLIB(ADJELG01),DISP=SHR                 
//X37IGN   DD DUMMY                                                     
//INP      DD *                                                         
ABCDEF01  ABCDEF                                                       
ABCD01    ABCD                                                         
A01       A                                                             
ABCE01    ABCE                                                         
ABCEDEFG01ABCEDEFG                                                     
/*                                                                     
//OUT      DD SYSOUT=*                                                 
//T01      DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)       
//T02      DD SYSOUT=*                                                 
//SORTXSUM DD DUMMY                                                     
//TOOLIN   DD *                                                         
 COPY FROM(INP) USING(CTL1)                                             
 COPY FROM(T01) TO(T02) USING(CTL2)                                     
*COPY FROM(T02) TO(OUT) USING(CTL3)                                     
/*                                                                     
//CTL1CNTL DD *                                                         
  INREC BUILD=(1,10)                                                   
  OUTFIL FNAMES=T01,FTOV,VLTRIM=C' '                                   
/*                                                                     
//CTL2CNTL DD *                                                         
  OUTFIL VTOF,BUILD=(5,10,X,1,2,BI,SUB,+5,TO=ZD,LENGTH=2)               
/*                                                                     

Output of T2 is :
Code:

ABCDEF01   07
ABCD01     05
A01        02
ABCE01     05
ABCEDEFG01 09


Please suggest, how can we use the identified length to BUILD the outrec.
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Wed Jul 30, 2014 4:07 pm    Post subject: Reply to: Extract last 2 bytes from a field in input file
Reply with quote

I'm not sure what you've identified the length of, but although you've applied code to get an answer, if you are reading an input three times you may as well write a program to do it.

However, what you seem to want can be done in one pass of the data. Have a look at what JFY with SHIFT=RIGHT can do. It can slam the contents of your field to the right, so that the last two bytes of the field are in a fixed position, which you can then use in BUILD.

You can't use anything directly from a field to indicate information for position/length in the sort control cards themselves.
Back to top
View user's profile Send private message
VivekKhanna

New User


Joined: 09 Feb 2009
Posts: 57
Location: India

PostPosted: Wed Jul 30, 2014 5:45 pm    Post subject:
Reply with quote

Thanks Bill. I was able to to achieve it using the same approach shared by you. Please find the details mentioned below:
Code:

//JS010    EXEC PGM=ICETOOL                                             
//TOOLMSG  DD SYSOUT=*                                                 
//DFSMSG   DD SYSOUT=*                                                 
//SYSOUT   DD SYSOUT=*                                                 
//SYSUDUMP DD SYSOUT=*                                                 
//DFSPARM  DD DSN=QCPPNP.CUS.PARMLIB(ADJEL050),DISP=SHR                 
//$ORTPARM DD DSN=QCPPNP.CUS.PARMLIB(ADJELG01),DISP=SHR                 
//X37IGN   DD DUMMY                                                     
//INP      DD *                                                         
ABCDEF01     XXCDEF                                                     
ABCD02       XXCD                                                       
A01          DD                                                         
ABCE03       ABGG                                                       
ABCEDEFG05   AFFEDEFG                                                   
/*                                                                     
//OUT      DD SYSOUT=*                                                 
//T01      DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)       
//T02      DD SYSOUT=*                                                 
//SORTXSUM DD DUMMY                                                     
//TOOLIN   DD *                                                         
 COPY FROM(INP) TO(T01) USING(CTL1)                                     
 COPY FROM(T01) TO(T02) USING(CTL2)                                     
/*                                                                     
//CTL1CNTL DD *                                                         
  OPTION COPY                                                           
  INREC PARSE=(%00=(ENDBEFR=C' ',FIXLEN=10),                           
               %01=(ABSPOS=14,ENDBEFR=C' ',FIXLEN=10)),                 
  BUILD=(%00,%00,JFY=(SHIFT=RIGHT),%01)                                 
/*                                                                     
//CTL2CNTL DD *                                                         
  OUTREC BUILD=(1:1,10,11:19,2,13:X,14:21,10)                           
/*                                                                     


The output is:
Code:

ABCDEF01  01 XXCDEF 
ABCD02    02 XXCD   
A01       01 DD     
ABCE03    03 ABGG   
ABCEDEFG0505 AFFEDEFG


Please share your thoughts, in case you have any other approach.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Wed Jul 30, 2014 5:58 pm    Post subject:
Reply with quote

Your code looks as though you are still doing two passes of the data.

I think that Bill was hinting at something like building an INREC record where the right shifted field is added to the end of the record, and an OUTREC BUILD to select the required fields from the layout created by the INREC BUILD.

I have assumed that the RECFM=FB as you are using position 1 as the start of your data.

No mainframe access at the moment so can't test the theory, but it should get this done in a single pass of the data.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Thu Jul 31, 2014 4:43 am    Post subject: Reply to: Extract last 2 bytes from a field in input file
Reply with quote

Code:
  OPTION COPY                                                           
  INREC PARSE=(%00=(ENDBEFR=C' ',FIXLEN=10),                           
               %01=(ABSPOS=14,ENDBEFR=C' ',FIXLEN=10)),                 
  BUILD=(%00,%00,JFY=(SHIFT=RIGHT),%01)                                 
                                                     
  OUTREC BUILD=(1:1,10,11:19,2,13:X,14:21,10)     


That should give you the same output, with only reading the data once.

However, you don't need PARSE, as the fields are in fixed position.

You can have multiple IFTHEN=(WHEN=INIT which allow you to use multiple functions in INREC (or OUTREC or OUTFIL), You can use OVERLAY to add a new temporary field to a record, then BUILD to make you final output. Unless you need column-numbers on a BUILD, it is easier to understand and maintain if you don't use them.
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 Performing arithmetic on input field zh_lad DFSORT/ICETOOL 24 Tue Dec 06, 2016 8:04 pm
No new posts High CPU consumption Job using IAM fi... aswinir JCL & VSAM 8 Thu Dec 01, 2016 8:28 pm
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


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