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

Convert alphanumeric "1234 " to Numeric 0000123


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sandeepsab1

New User


Joined: 07 Apr 2006
Posts: 6

PostPosted: Fri Apr 21, 2006 6:52 pm
Reply with quote

Using JCL, Can we convert a file having alphanumeric 8 digit Account number

Code:

"1234  "


to a file having Numeric Account Number

Code:

00001234
Back to top
View user's profile Send private message
hariavinash

New User


Joined: 04 Jan 2006
Posts: 64

PostPosted: Fri Apr 21, 2006 8:44 pm
Reply with quote

yes. you can use iceman/icetool. ifthen .. when clause to pad with zeroes.


cheers
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri Apr 21, 2006 9:27 pm
Reply with quote

You can use a DFSORT job like the following to do what you asked for:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=... output file
//SYSIN    DD    *
  OPTION COPY
  INREC BUILD=(1,8,UFF,M11,LENGTH=8)
/*
Back to top
View user's profile Send private message
sandeepsab1

New User


Joined: 07 Apr 2006
Posts: 6

PostPosted: Sat Apr 22, 2006 7:41 pm
Reply with quote

Thanks for the reply.
But I think your solution will convert "1234 " to 12340000. Actually I am desiring to have it converted as 00001234.
Please correct me if I am wrong.
Please let me know if we can actually do this, using JCL

Thanks & regards
Sandeep
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Sat Apr 22, 2006 8:25 pm
Reply with quote

Quote:
But I think your solution will convert "1234 " to 12340000. Actually I am desiring to have it converted as 00001234.
Please correct me if I am wrong. Please let me know if we can actually do this, using JCL


You're wrong. Why do you think that? This IS the way to actually do this using DFSORT.

The DFSORT job does exactly what you asked for - it converts "1234 " to 00001234.

DFSORT's UFF format extracts the digits 1234. Then M11,LENGTH=8 converts the extracted digits to the pattern TTTTTTTT giving the extracted digits padded on the left with zeros, resulting in 00001234.

I tested this before I posted it to make sure it worked correctly. Why didn't you just try it to see if it worked instead of assuming it didn't?

Here's the job I used to test this:

Code:

//S1    EXEC  PGM=ICEMAN                 
//SYSOUT    DD  SYSOUT=*                 
//SORTIN DD *                           
"1234  "                                 
//SORTOUT DD SYSOUT=*                   
//SYSIN    DD    *                       
  OPTION COPY                           
  INREC BUILD=(1,8,UFF,M11,LENGTH=8)     
/*


Here are some of the DFSORT messages I got when I ran this:

Code:

ICE143I 0 BLOCKSET     COPY  TECHNIQUE SELECTED
ICE000I 1 - CONTROL STATEMENTS FOR 5740-SM1, DFSORT REL 14.0 - ...
            OPTION COPY
            INREC BUILD=(1,8,UFF,M11,LENGTH=8)
ICE201I E RECORD TYPE IS F - DATA STARTS IN POSITION 1
ICE193I 0 ICEAM1 ENVIRONMENT IN EFFECT - ICEAM1 INSTALLATION MODULE SELECTED
ICE088I 0 SANDE1  .S1      .        , INPUT LRECL = 80, BLKSIZE = 80, TYPE = FB
ICE093I 0 MAIN STORAGE = (MAX,4194304,4181086)
ICE156I 0 MAIN STORAGE ABOVE 16MB = (4068974,4068974)
...
ICE090I 0 OUTPUT LRECL = 8, BLKSIZE = 80, TYPE = FB
ICE171I 0 SORTOUT LRECL OF 8 IS DIFFERENT FROM SORTIN(NN) LRECL OF 80 - RC=0
ICE055I 0 INSERT 0, DELETE 0
ICE054I 0 RECORDS - IN: 1, OUT: 1
ICE052I 0 END OF DFSORT


Here's the SORTOUT output:

Code:

00001234 
Back to top
View user's profile Send private message
sandeepsab1

New User


Joined: 07 Apr 2006
Posts: 6

PostPosted: Mon Apr 24, 2006 12:35 pm
Reply with quote

Hello

I tried the same code as given by you as follows
//STEP010 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
"1234 "
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC BUILD=(1,8,UFF,M11,LENGTH=8)
/*
******************
But, it is giving me an error U0016, & the error message in SYSOUT as follows
SYSIN :
OPTION COPY
INREC BUILD=(1,8,UFF,M11,LENGTH=8)
*
WER268A INREC STATEMENT : SYNTAX ERROR
WER211B SYNCSMF CALLED BY SYNCSORT; RC=0000
WER449I SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE
******************
I tried with all possible options like replacing BUILD by FIELDS, ICEMAN by SORT, & not getting the reason behind it.
Could you please tell me why the same JCL is giving error to me & ran fine with you.
Back to top
View user's profile Send private message
sril.krishy

Active User


Joined: 30 Jul 2005
Posts: 183
Location: hyderabad

PostPosted: Mon Apr 24, 2006 4:26 pm
Reply with quote

Hi,
The solution that was given by Frank will work for DFSORT ,but not for SYNCSORT it seems.

WER268A INREC STATEMENT : SYNTAX ERROR
WER211B SYNCSMF CALLED BY SYNCSORT; RC=0000
WER449I SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE

WER messages are result of SYNCSORT.Please search the forum for the differneces between SYNCSORT and DFSORT.

Thank you
Krishy
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Mon Apr 24, 2006 9:03 pm
Reply with quote

Sandeep,

The job I gave you works fine with DFSORT. But the WER messages indicate you're using Syncsort, not DFSORT. DFSORT supports the UFF format. Syncsort does not support the UFF format.
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Mon Apr 24, 2006 9:15 pm
Reply with quote

FWIW, a SAS solution:
Code:

//SASSTEP  EXEC SAS                         
//SAS.SASLOG  DD SYSOUT=*                   
//SAS.SYSDUMP DD SYSOUT=*                   
//SAS.SASLIST DD SYSOUT=*                   
//SYSUT1   DD   *                           
1234                                       
/*                                         
//SYSUT2   DD   SYSOUT=*                   
//SYSIN    DD   *                           
DATA _NULL_;                               
INFILE SYSUT1;                             
FILE SYSUT2;                               
INPUT @1 LINE1;                             
  FORMAT LINE1 Z8.;                         
PUT @1 LINE1;                               
/*                                         
Back to top
View user's profile Send private message
sandeepsab1

New User


Joined: 07 Apr 2006
Posts: 6

PostPosted: Tue Apr 25, 2006 9:57 am
Reply with quote

Thanks for the solution.

One more thing I would like to ask is:
If my input file is having data as this
1000(followed by 6 spaces) 30 don
20(followed by 8 spaces) 20 sam
23456(followed by 5 spaces) 10 tim

how can i take care for the data 30 don, 20 sam, 10 tim to go in output file.
That is output file will look as
000001000 30 don
000000020 20 sam
000023456 10 tim

Can we do this?
Please tell me.
Back to top
View user's profile Send private message
chandu_605k

New User


Joined: 17 Apr 2006
Posts: 7
Location: Kansas City

PostPosted: Thu Apr 27, 2006 6:52 pm
Reply with quote

Hi Sandeep,
Frank is correct. Whatever the code frank has given was correct. I don't know, why its giving error when you execute. I have executed the code given by you(and by Frank also). Its giving correct results. See, the following code is same like your code, which you have tried with.

//SORTTEST JOB ,'CSRTEST1',CLASS=D,MSGCLASS=Q,MSGLEVEL=(1,1),
// NOTIFY=&SYSUID
//*
//*
//STEP010 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
"1234"
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC BUILD=(1,8,UFF,M11,LENGTH=8)
/*
//*

The above code is working with input "1234" or '1234'.


Dear Mr Superk,
You are trying with proc "SAS" . But where is that proc. See, given answer should be clear. We can do in somany ways. But atleast one of those methods should give clear picture to others. Sorry for saying like this SuperK.


Ok Sandeep, Please try with that again.


Best Wishes
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Apr 27, 2006 8:41 pm
Reply with quote

CSRao said
Quote:
Frank is correct. Whatever the code frank has given was correct. I don't know, why its giving error when you execute.


As noted previously, the job works fine with DFSORT. It's giving an error when Sandeep runs it because he's using Syncsort, not DFSORT. DFSORT supports UFF. Syncsort doesn't.
Back to top
View user's profile Send private message
sandeepsab1

New User


Joined: 07 Apr 2006
Posts: 6

PostPosted: Fri Apr 28, 2006 9:14 pm
Reply with quote

If anyone can reply to my query I would be thankful to him

SAS solution is working. I also understand how it worked.
But If the field to be operated is at some middle position, how to
code SYSIN DD * for that.

Here is my query once again with little formatting.
Can anyone give me SYSIN DD * for this if I want to use SAS

If my input file is having data as this

NEWJERSY(4-Spaces)1000(followed by 6 spaces) 30 don
FLORIDA(5-Spaces)20(followed by 8 spaces) 20 sam
TEXAS(7 Spaces)23456(followed by 5 spaces) 10 tim

how can i take care for the data 30 don, 20 sam, 10 tim to go in output file.
That is output file will look as
NEWJERSY(4-Spaces)000001000 30 don
FLORIDA(5-Spaces)000000020 20 sam
TEXAS(7 Spaces)000023456 10 tim

Can we do this?
Please tell me.
Back to top
View user's profile Send private message
sandeepsab1

New User


Joined: 07 Apr 2006
Posts: 6

PostPosted: Fri May 05, 2006 12:18 pm
Reply with quote

Can anybody please answer my Question posted about SAS.
I am desperately needing it.
Back to top
View user's profile Send private message
habibullah_j

New User


Joined: 16 Mar 2006
Posts: 3

PostPosted: Tue Jul 11, 2006 5:14 pm
Reply with quote

You can use NUMVAL function to convert an Alphanumeric value to Numeric.

Compute WS-NUM-FLD1 = FUNCTION NUMVAL(WS-ALPHA-NUM-FLD2)

cheers,
habib
Back to top
View user's profile Send private message
Hanfur

Active User


Joined: 21 Jun 2006
Posts: 104

PostPosted: Wed Jul 12, 2006 11:58 am
Reply with quote

Frank,
I tried with your card and it gave the correct result though we have SYNCSORT in our shop.

Sandeepsab1,

I feel you got that error cos of SYNTAX PROBLEMS.




Sort card I used:
Same as Frank gave.

Output in spool:00001234


SYSOUT listing:
-------------------

OPTION COPY
INREC BUILD=(1,8,UFF,M11,LENGTH=8)
WER276B SYSDIAG= 197822, 589946, 589946, 537164
WER164B 31,580K BYTES OF VIRTUAL STORAGE AVAILABLE, MAX REQUESTED,
WER164B 48K BYTES RESERVE REQUESTED, 2,133,960 BYTES USED
WER146B 24K BYTES OF EMERGENCY SPACE ALLOCATED
WER108I SORTIN : RECFM=FB ; LRECL= 80; BLKSIZE= 80
WER257I INREC RECORD LENGTH = 8
WER110I SORTOUT : RECFM=FB ; LRECL= 8; BLKSIZE= 8
WER416B BSAM WAS USED FOR SORTIN
WER416B BSAM WAS USED FOR SORTOUT
WER054I RCD IN 1, OUT 1
WER169I RELEASE 1.2 BATCH 0454 TPF LEVEL 1.0



-Han.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Jul 12, 2006 8:27 pm
Reply with quote

Hanfur,

I last posted on this back in April. It's now July and things may have changed. DFSORT has had the UFF function since Dec, 2004. It may be that a newer level of Syncsort now has that function a year and a half later.
Back to top
View user's profile Send private message
Hanfur

Active User


Joined: 21 Jun 2006
Posts: 104

PostPosted: Thu Jul 13, 2006 11:54 am
Reply with quote

Frank,

Quite right..I haven't checked the dates..

-Han.
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts PuTTY - "User is not a surrogate... IBM Tools 5
No new posts Keep leading zero(s) after convert fl... SYNCSORT 7
No new posts Convert single row multi cols to sing... DFSORT/ICETOOL 6
Search our Forums:

Back to Top