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
 

 

Format Character field to Numeric field.

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

New User


Joined: 01 Jul 2009
Posts: 10
Location: india

PostPosted: Mon Feb 15, 2010 12:10 am    Post subject: Format Character field to Numeric field.
Reply with quote

Hi,

I need a SORT job that convert the character to numeric. Following is my scenario.

Input File:
CHAR(5) 1-5
CHAR(5) 6-10 (it will contain numeric values alone no non-numeric value)
CHAR(5)11-15

Code:
AAAAA12345XXXXX
BBBBB05456YYYYY
CCCCC00518ZZZZZ
DDDDD00015WWWWW
EEEEEE00007YYYYY


Expected Output:


Code:
AAAAA12345XXXXX
BBBBB5456bYYYYY
CCCCC518bbZZZZZ
DDDDD015bbWWWWW
EEEEEE007bbYYYYY

The 'b' ---> denotes blank space.

I want to convert input field to be converted to numeric field with leading zeros for values for all three digit values alone. and for four digit it should be left justified with space in the last bit , for five digit it has to come as it is.
Back to top
View user's profile Send private message

gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1703
Location: Australia

PostPosted: Mon Feb 15, 2010 5:56 am    Post subject:
Reply with quote

Hi,

is this correct?
Code:
EEEEEE00007YYYYY
6-10 contains a non numeric value.


Gerry
Back to top
View user's profile Send private message
lasiafjmc

New User


Joined: 01 Jul 2009
Posts: 10
Location: india

PostPosted: Mon Feb 15, 2010 6:36 am    Post subject:
Reply with quote

Sorry its EEEEE00007YYYYY...


Input File:
CHAR(5) 1-5
CHAR(5) 6-10 (it will contain numeric values alone no non-numeric value)
CHAR(5)11-15

AAAAA12345XXXXX
BBBBB05456YYYYY
CCCCC00518ZZZZZ
DDDDD00015WWWWW
EEEEE00007YYYYY


Expected Output:


AAAAA12345XXXXX
BBBBB5456bYYYYY
CCCCC518bbZZZZZ
DDDDD015bbWWWWW
EEEEE007bbYYYYY

b ---> denotes blank space.
Back to top
View user's profile Send private message
lasiafjmc

New User


Joined: 01 Jul 2009
Posts: 10
Location: india

PostPosted: Mon Feb 15, 2010 6:44 am    Post subject:
Reply with quote

ADDED TO THAT EXAMPLE

i/p
EEEEE00000YYYYY

o/p
EEEEE000bbYYYYY


Will this sort card work...

OUTREC FIELDS=(1,5,6,5,ZD,TO=ZD,(EDIT=III),length=5)
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Feb 15, 2010 6:49 am    Post subject:
Reply with quote

Hello,

Quote:
Will this sort card work...
What happens when you run this?
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1703
Location: Australia

PostPosted: Mon Feb 15, 2010 6:50 am    Post subject:
Reply with quote

Hi,

what happens when you try it ?


Gerry
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1238
Location: Richfield, MN, USA

PostPosted: Mon Feb 15, 2010 10:14 am    Post subject:
Reply with quote

lasiafjmc, please use BBCode (see FAQ).
Back to top
View user's profile Send private message
lasiafjmc

New User


Joined: 01 Jul 2009
Posts: 10
Location: india

PostPosted: Mon Feb 15, 2010 11:12 pm    Post subject:
Reply with quote

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

Senior Member


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

PostPosted: Mon Feb 15, 2010 11:43 pm    Post subject:
Reply with quote

lasiafjmc,

Use the following DFSORT JCL which will give you the desired results

Code:

//STEP0100 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//SORTIN   DD DSN=Your input file,DISP=SHR
//SORTOUT  DD SYSOUT=*                                     
//SYSIN    DD *                                           
  SORT FIELDS=COPY                                         
  INREC IFTHEN=(WHEN=INIT,                                 
  OVERLAY=(6:6,5,UFF,M10,LENGTH=5,6:6,5,JFY=(SHIFT=LEFT))),
  IFTHEN=(WHEN=(8,3,CH,EQ,C' ',AND,7,1,CH,GT,C' '),       
  OVERLAY=(7:6,2,6:C'0')),                                 
  IFTHEN=(WHEN=(7,4,CH,EQ,C' ',AND,6,1,CH,GT,C' '),       
  OVERLAY=(8:6,1,6:2C'0'))                                 
//*
Back to top
View user's profile Send private message
lasiafjmc

New User


Joined: 01 Jul 2009
Posts: 10
Location: india

PostPosted: Tue Feb 16, 2010 12:00 am    Post subject:
Reply with quote

Thanks Let me check
Back to top
View user's profile Send private message
lasiafjmc

New User


Joined: 01 Jul 2009
Posts: 10
Location: india

PostPosted: Thu Feb 18, 2010 12:00 pm    Post subject:
Reply with quote

Thanks it working Super...
Back to top
View user's profile Send private message
lasiafjmc

New User


Joined: 01 Jul 2009
Posts: 10
Location: india

PostPosted: Thu Feb 18, 2010 2:22 pm    Post subject:
Reply with quote

I am getting the output as

0EW3 000
1AAAA12345XXXXX
1BBBB5456 YYYYY
1CCCC518 ZZZZZ
1DDDD015 WWWWW
1EEEE007 YYYYY
1EEEE000 YYYYY
957DD000


. How to remove the 000 in header and trailer... Please help me
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Thu Feb 18, 2010 2:54 pm    Post subject:
Reply with quote

lasiafjmc wrote:
How to remove the 000 in header and trailer... Please help me

You never shown you have header and trailer also... This is first time you are revealing after Kolusu has spent time for your solution.
Back to top
View user's profile Send private message
lasiafjmc

New User


Joined: 01 Jul 2009
Posts: 10
Location: india

PostPosted: Thu Feb 18, 2010 2:55 pm    Post subject:
Reply with quote

Oh sorry
Back to top
View user's profile Send private message
lasiafjmc

New User


Joined: 01 Jul 2009
Posts: 10
Location: india

PostPosted: Thu Feb 18, 2010 2:56 pm    Post subject:
Reply with quote

I/p file:
--------

0EW3
1AAAA12345XXXXX
1BBBB05456YYYYY
1CCCC00518ZZZZZ
1DDDD00015WWWWW
1EEEE00007YYYYY
1EEEE00000YYYYY
957DD


Expected Output:
--------------------
0EW3
1AAAA12345XXXXX
1BBBB5456 YYYYY
1CCCC518 ZZZZZ
1DDDD015 WWWWW
1EEEE007 YYYYY
1EEEE000 YYYYY
957DD



record starting with 0 & 9 are header and trailer...
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Thu Feb 18, 2010 10:40 pm    Post subject: Reply to: Format Character field to Numeric field.
Reply with quote

lasiafjmc,

*Sigh* Use the following control cards

Code:

//SYSIN    DD *                                                     
  SORT FIELDS=COPY                                                   
  INREC IFTHEN=(WHEN=(1,1,ZD,EQ,1),                                 
  OVERLAY=(6:6,5,UFF,M10,LENGTH=5,6:6,5,JFY=(SHIFT=LEFT)),HIT=NEXT),
  IFTHEN=(WHEN=(8,3,CH,EQ,C' ',AND,7,1,CH,GT,C' ',AND,1,1,ZD,EQ,1), 
  OVERLAY=(7:6,2,6:C'0')),                                           
  IFTHEN=(WHEN=(7,4,CH,EQ,C' ',AND,6,1,CH,GT,C' ',AND,1,1,ZD,EQ,1), 
  OVERLAY=(8:6,1,6:2C'0'))                                           
//*                                                           
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 Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Low values Results from VARCHAR FORMAT balaji81_k DB2 10 Thu Oct 20, 2016 1:18 am
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm


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