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
 

 

How to remove zeroes from a comp-3 field

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

New User


Joined: 07 Sep 2010
Posts: 22
Location: hyderabad

PostPosted: Mon Apr 09, 2012 9:20 pm    Post subject: How to remove zeroes from a comp-3 field
Reply with quote

Hi,

In my input file one of the field is zip pic s9(9) comp-3.it's data is 465280000
my requirement is i want to copy the all the fields in to another file along with the zip field with out zeroes.

ex
--------
Code:
i/p                                                               o/p
-----                                                           -------             
485690000                                                  48569   
568920000                                                  56892
 65320000                                                   6532

please help me regarding this problem..
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Mon Apr 09, 2012 9:21 pm    Post subject:
Reply with quote

What if the input value is 400390000?
Back to top
View user's profile Send private message
somapradeep1

New User


Joined: 07 Sep 2010
Posts: 22
Location: hyderabad

PostPosted: Mon Apr 09, 2012 9:35 pm    Post subject: Reply to: How to remove zeroes from a comp-3 field
Reply with quote

if the i/p is 400390000 the o/p should be


40039 it should take first five values only.....
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Mon Apr 09, 2012 9:48 pm    Post subject:
Reply with quote

somapradeep1,
Are you always going to have 4 trailing zeros? What is the exact field definition for the output field?

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

New User


Joined: 07 Sep 2010
Posts: 22
Location: hyderabad

PostPosted: Mon Apr 09, 2012 9:51 pm    Post subject: Reply to: How to remove zeroes from a comp-3 field
Reply with quote

yes,the o/p field is numeric...
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Mon Apr 09, 2012 10:05 pm    Post subject:
Reply with quote

Untested...

Code:
//STEP0100 EXEC PGM=SORT                           
//SYSOUT   DD SYSOUT=*                             
//SORTIN   DD *                                     
 รค                                                 
//SORTOUT  DD  OUTPUT.FILE,                       
//SYSIN    DD *                                     
  OPTION COPY                                       
  INREC OVERLAY=(1,5,PD,DIV,+10000,TO=PD,LENGTH=5) 
/*


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

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Mon Apr 09, 2012 10:39 pm    Post subject:
Reply with quote

Quote:
Sqlcode,

Length=9 will increase the output field. Did you mean TO=ZD?

No I meant to keep it as PD only. Length was a typo, it should be 5.


Thanks,
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: Mon Apr 09, 2012 11:32 pm    Post subject:
Reply with quote

somapradeep1,

Let's assume that your 5-byte PD field is in positions 11-15 and always ends with 4 zeros (e.g. X'485690000C') and you want to convert it to a 5-byte PD field in positions 11-15 without the 4 zeros (e.g. X'000048569C').

Here are two ways to do it with DFSORT:

Code:

  OPTION COPY                               
  INREC OVERLAY=(11:11,3,PD,TO=PD,LENGTH=5)


or

Code:

  OPTION COPY                                           
  INREC OVERLAY=(11:11,5,PD,DIV,+10000,TO=PD,LENGTH=5) 


If that's not what you want to do, then please explain more clearly what you want to do with examples of input and expected output in HEX.
Back to top
View user's profile Send private message
somapradeep1

New User


Joined: 07 Sep 2010
Posts: 22
Location: hyderabad

PostPosted: Tue Apr 10, 2012 5:58 pm    Post subject: Reply to: How to remove zeroes from a comp-3 field
Reply with quote

thank you ver much....
Back to top
View user's profile Send private message
somapradeep1

New User


Joined: 07 Sep 2010
Posts: 22
Location: hyderabad

PostPosted: Thu Apr 12, 2012 4:11 pm    Post subject: Reply to: How to remove zeroes from a comp-3 field
Reply with quote

your sort card is working very fine but,if the field contains only one 0 its giving soc 7 can u help me in this situuation please sir...
Back to top
View user's profile Send private message
somapradeep1

New User


Joined: 07 Sep 2010
Posts: 22
Location: hyderabad

PostPosted: Thu Apr 12, 2012 4:49 pm    Post subject: Reply to: How to remove zeroes from a comp-3 field
Reply with quote

Hi,

In my input file one of the field is zip pic s9(9) comp-3.it's data is 465280000
my requirement is i want to copy the all the fields in to another file along with the zip field with out zeroes.

ex
--------
Code:
i/p                                                                                    o/p
-----                                                                                -------
485690000                                                                      48569
568920000                                                                      56892
65320000                                                                         6532
            0                                                                              0
    space                                                                                0

please help me regarding this problem..
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Thu Apr 12, 2012 4:56 pm    Post subject: Reply to: How to remove zeroes from a comp-3 field
Reply with quote

looks like You did not care to understand ...
Quote:
Let's assume that your 5-byte PD field is in positions 11-15 and always ends with 4 zeros (e.g. X'485690000C')


it is more intelligent to post the complete requirement beforehand,
than complain afterward that the provide solution does not work !
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: Thu Apr 12, 2012 10:38 pm    Post subject:
Reply with quote

somapradeep1,

If you can have spaces for your PD value, then you just need to add an IFTHEN clause to handle that as follows:

Method 1:

Code:

  OPTION COPY                                         
  INREC IFTHEN=(WHEN=(11,5,CH,NE,C' '),               
        OVERLAY=(11:11,3,PD,TO=PD,LENGTH=5)),         
     IFTHEN=(WHEN=NONE,OVERLAY=(11:+0,TO=PD,LENGTH=5))


Method 2:

Code:

  OPTION COPY                                           
  INREC IFTHEN=(WHEN=(11,5,CH,NE,C' '),                 
     OVERLAY=(11:11,5,PD,DIV,+10000,TO=PD,LENGTH=5)),   
     IFTHEN=(WHEN=NONE,OVERLAY=(11:+0,TO=PD,LENGTH=5))   


Please do try to give the complete requirement in your first post from now on.
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 15 Tue Dec 06, 2016 8:04 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 How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts Amount field is getting corrupted whe... thesumitk SYNCSORT 5 Tue Oct 18, 2016 8:20 pm


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