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

Format Character field to Numeric field.


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
lasiafjmc

New User


Joined: 01 Jul 2009
Posts: 9
Location: india

PostPosted: Mon Feb 15, 2010 12:10 am
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: 1702
Location: Australia

PostPosted: Mon Feb 15, 2010 5:56 am
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: 9
Location: india

PostPosted: Mon Feb 15, 2010 6:36 am
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: 9
Location: india

PostPosted: Mon Feb 15, 2010 6:44 am
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

Moderator Emeritus


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

PostPosted: Mon Feb 15, 2010 6:49 am
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: 1702
Location: Australia

PostPosted: Mon Feb 15, 2010 6:50 am
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: 1249
Location: Richfield, MN, USA

PostPosted: Mon Feb 15, 2010 10:14 am
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: 9
Location: india

PostPosted: Mon Feb 15, 2010 11:12 pm
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
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: 9
Location: india

PostPosted: Tue Feb 16, 2010 12:00 am
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: 9
Location: india

PostPosted: Thu Feb 18, 2010 12:00 pm
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: 9
Location: india

PostPosted: Thu Feb 18, 2010 2:22 pm
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
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: 9
Location: india

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

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

New User


Joined: 01 Jul 2009
Posts: 9
Location: india

PostPosted: Thu Feb 18, 2010 2:56 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Need to convert date format DFSORT/ICETOOL 20
Search our Forums:

Back to Top