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
 

 

Need Numeric Fields with no leading zeros or spaces

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
manishm

New User


Joined: 31 Mar 2005
Posts: 5

PostPosted: Tue Dec 23, 2008 12:56 pm    Post subject: Need Numeric Fields with no leading zeros or spaces
Reply with quote

I need to write few numeric fields in my output file along with a few Alphanumeric fields. The problem is that the numeric fields must be written without any leading zeros or spaces, so if the field is defined as S9(09)V99 and the actual value of the field is 178.75, it must be written in the file as 178.75 only, and not as 000000178.75. I also can't use zero suppressors because that will convert leading zeros to leading spaces. I have already implemented the idea of using an array and then getting rid of leading zeros, but looking for a better solution now.
Back to top
View user's profile Send private message

SHAILESH OZA

New User


Joined: 10 Jun 2005
Posts: 21
Location: Mumbai

PostPosted: Tue Dec 23, 2008 4:51 pm    Post subject:
Reply with quote

Hi ManishM,

You can do one thing by using Inspect

Inspect Variable(000000178.75) tallying counter for all leading zeros.

You will get the counter value as 6. So after that you can use the reference modication as Variable(6: L) and use that for your operations.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Dec 23, 2008 5:21 pm    Post subject:
Reply with quote

ManishM,

what does your output file field structure look like?

what kind of field do you want to populate with the space/zero trimmed numeric edited value?
Back to top
View user's profile Send private message
manishm

New User


Joined: 31 Mar 2005
Posts: 5

PostPosted: Tue Dec 23, 2008 6:08 pm    Post subject: Reply to: Need Numeric Fields with no leading zeros or space
Reply with quote

The Output file is a comma separated file with all the fields compressed to their actual lengths (Though they are defined with their maximum possibl e lengths)

The problem in using INSPECT command is that I don't know how many bytes of actual data is present in the field so I can't use reference modification also.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Tue Dec 23, 2008 6:22 pm    Post subject:
Reply with quote

Based on what you're saying, you can either pick a language other than COBOL to write this in, or you can use reference modification to do it. Build your output record one field at a time via reference modification; you can use the INSPECT for leading zeroes to know where to start moving from; the length of the sending field minus the starting position for the move tells you how many bytes you're moving.

This would be a pretty trivial task in SAS, by the way.
Back to top
View user's profile Send private message
SHAILESH OZA

New User


Joined: 10 Jun 2005
Posts: 21
Location: Mumbai

PostPosted: Tue Dec 23, 2008 6:33 pm    Post subject:
Reply with quote

Hi Manish,

Var1 = 000000178.75
Length = Use Length of (Var1) to calulate the length = its 12 in this case
By using inspect tally count for leading zeroes you will get counter = 6
Now Reference modification is like this Var1(counter+1 : length)
i.e Var1(7:12) which contains exactly 178.75 which can used for the operation. Does it make any sense ?

Regards,
Shailesh
Back to top
View user's profile Send private message
manishm

New User


Joined: 31 Mar 2005
Posts: 5

PostPosted: Tue Dec 23, 2008 6:39 pm    Post subject:
Reply with quote

Shailesh,
Let me know if I am wrong but when you try to use the reference modification, the second value which you provide (in the braces), should be the actual length which you want to pull and not the total length of the field. So Var(7:12) means that it'll try to pick-up 12 bytes starting at position 7.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2233
Location: @my desk

PostPosted: Tue Dec 23, 2008 7:34 pm    Post subject:
Reply with quote

Manish,

Guess you missed this one....
Robert Sample wrote:
Based on what you're saying, you can either pick a language other than COBOL to write this in, or you can use reference modification to do it. Build your output record one field at a time via reference modification; you can use the INSPECT for leading zeroes to know where to start moving from; the length of the sending field minus the starting position for the move tells you how many bytes you're moving.
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 -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts DFSORT MUL FIELDS tspr52 DFSORT/ICETOOL 16 Fri Mar 03, 2017 11:53 pm
No new posts Converting decimal to numeric using I... Balaryan DFSORT/ICETOOL 4 Thu Feb 02, 2017 11:27 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm
No new posts Sort two file having same field, one ... himanshu malik DFSORT/ICETOOL 7 Thu Feb 02, 2017 10:09 am
No new posts SYNCSORT SEQNUM and FI fields. nartcr SYNCSORT 7 Sat Jan 21, 2017 4:02 am


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