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

How to remove zeroes from a comp-3 field


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Mon Apr 09, 2012 9:21 pm
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
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: 577
Location: USA

PostPosted: Mon Apr 09, 2012 9:48 pm
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
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: 577
Location: USA

PostPosted: Mon Apr 09, 2012 10:05 pm
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: 577
Location: USA

PostPosted: Mon Apr 09, 2012 10:39 pm
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 Developer


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

PostPosted: Mon Apr 09, 2012 11:32 pm
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
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
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
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Apr 12, 2012 4:56 pm
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 Developer


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

PostPosted: Thu Apr 12, 2012 10:38 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Remove leading zeroes SYNCSORT 4
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Join 2 files according to one key field. JCL & VSAM 3
Search our Forums:

Back to Top