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
 

 

Can Sort add a character after a alphanumeric number

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

Active User


Joined: 29 Dec 2005
Posts: 181
Location: Canada

PostPosted: Tue Sep 25, 2007 8:10 am    Post subject: Can Sort add a character after a alphanumeric number
Reply with quote

Hi,

I have got a requirement.

I need to add a character after a alphanumeric number,say X.
The X is a 7 bytes number.

The requirement is

a. X could be the completely numeric number. If it is a numeric number then, I need to add 'N' after X.So if the value of X is 1234567. Then my O/P should look like 1234567N.

b.X could be the alpha numeric number. If it is a numeric number then, I need to add 'A' after X.So if the value of X is PQR1234. Then my O/P should look like PQR1234A.

X's position in input file is fixed and it starts from position 6.

Please advise.

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

murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1439
Location: Bangalore,India

PostPosted: Tue Sep 25, 2007 10:44 am    Post subject:
Reply with quote

ap_mainframes,

You could use the following for your requirement -


Code:
----+----1----+----2----+----3----+----4----+----5----+----6----+--
//SORTIN DD *                                                     
     1234567 11111                                                 
     ABC1234 YYYYY                                                 
     ABCDEFG TTT                                                   
/*                                                                 
//SORTOUT DD SYSOUT=*                                             
//*                                                               
//SYSIN DD *                                                       
  SORT FIELDS=COPY                                                 
  OUTREC IFTHEN=(WHEN=(6,7,ZD,EQ,NUM),OVERLAY=(13:C'N')),         
         IFTHEN=(WHEN=(6,7,ZD,NE,NUM),OVERLAY=(13:C'A'))           
/*                                                                 


OP:

Code:
---+----1----+----2----+----3---
********************************
     1234567N11111             
     ABC1234AYYYYY             
     ABCDEFGATTT               
********************************
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1288
Location: Chennai, India

PostPosted: Tue Sep 25, 2007 12:21 pm    Post subject: Reply to: Can Sort add a character after a alphanumeric numb
Reply with quote

Quote:

I need to add a character after a alphanumeric number,say X.
The X is a 7 bytes number.X's position in input file is fixed and it starts from position 6.


What is the record length? As per your post X (7 bytes) starts from 6th position. What actually will be the value in the 13th byte? What if the 13th byte is populated with value? Do you want to overwrite or shift the value in the 13th byte?
Back to top
View user's profile Send private message
ap_mainframes

Active User


Joined: 29 Dec 2005
Posts: 181
Location: Canada

PostPosted: Tue Sep 25, 2007 5:31 pm    Post subject: Reply to: Can Sort add a character after a alphanumeric numb
Reply with quote

All,

Thanks for the replies.
I dont want to overwrite the value in 13th byte. I want to shift the data.I am increasing the LRECL of the output file to take care of the trunctation,if any.

Can you please advise now.

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

Senior Member


Joined: 03 Jul 2007
Posts: 1288
Location: Chennai, India

PostPosted: Tue Sep 25, 2007 5:53 pm    Post subject: Reply to: Can Sort add a character after a alphanumeric numb
Reply with quote

Use BUILD instead of OVERLAY.

Code:

//SORTIN  DD *                                                         
     1234567 11111                                                     
     ABC1234 YYYYY                                                     
     ABCDEFG TTT                                                       
/*                                                                     
//SORTOUT DD SYSOUT=*                                                   
//SYSIN       DD *                                                     
  SORT FIELDS=COPY                                                     
    OUTREC IFTHEN=(WHEN=(6,7,ZD,EQ,NUM),BUILD=(1,12,13:C'N',14:13,67)),
           IFTHEN=(WHEN=(6,7,ZD,NE,NUM),BUILD=(1,12,13:C'A',14:13,67)) 
/*                                                                     


output:

Code:

     1234567N 11111         
     ABC1234A YYYYY         
     ABCDEFGA TTT           


Just change the sort card as per your requirements.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


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

PostPosted: Tue Sep 25, 2007 8:53 pm    Post subject:
Reply with quote

ap_mainframes,

Aaru's solution will NOT work correctly because a ZD value can look like an alphanumeric value. For example, if the value is 123456J, ZD will treat it as a numeric value of -1234561 instead of as an alphanumeric value.

You can use these DFSORT statements to get the correct result:

Code:

  OPTION COPY                                             
  OUTREC IFTHEN=(WHEN=INIT,BUILD=(1,12,13:C'A',14:13,67)),
     IFTHEN=(WHEN=(6,7,FS,EQ,NUM),OVERLAY=(13:C'N'))       


FS,EQ,NUM treats '0'-'9' as numeric.
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
This topic is locked: you cannot edit posts or make replies. How to move a long alphanumeric data ... lind sh COBOL Programming 8 Mon Dec 05, 2016 7:51 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 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
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts How to delete second instance from Fl... Gunapala CN DFSORT/ICETOOL 6 Tue Oct 18, 2016 11:42 pm


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