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

Need Numeric Fields with no leading zeros or spaces


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

PostPosted: Tue Dec 23, 2008 6:22 pm
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
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
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: 2481
Location: @my desk

PostPosted: Tue Dec 23, 2008 7:34 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts Keep leading zero(s) after convert fl... SYNCSORT 7
No new posts Remove leading zeroes SYNCSORT 4
No new posts leading spaces can be removed in trai... DFSORT/ICETOOL 1
No new posts Cobol program with sequence number ra... COBOL Programming 5
Search our Forums:

Back to Top