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
 

 

Converting a field in one format to another

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Java & MQSeries
View previous topic :: :: View next topic  
Author Message
prasanth_urs

New User


Joined: 04 Dec 2006
Posts: 44
Location: Pune,India

PostPosted: Mon Apr 16, 2007 11:29 am    Post subject: Converting a field in one format to another
Reply with quote

Hi all,

I need some help in this issue.
Actually, there is a field called 'A' whose value is '030 10670000' which is a numberic filed with length 15.

This format has to be changed to '30+1067' format.
That means the zeros from both are to be suppressed as well as the balnk is to changed to +.

Please help me with the code for this conversion.

Many thanks in advance
Back to top
View user's profile Send private message

Anjani Kiran Mitikiri

New User


Joined: 05 Feb 2007
Posts: 6
Location: Chennai

PostPosted: Wed Apr 25, 2007 1:14 am    Post subject: Re: Converting a field in one format to another
Reply with quote

Hi Prasanth ,
Your field 'A' , you say is numeric, then how come it is having a space in it?Nevertheless , use inspect statement.
First , INSPECT A replacing all Spaces with '+'
Then INSPECT A replacing all '0's with Spaces
Lastly INSPECT A replacing all Spaces with ''(i.e. NULL)
For all this to happen your variable A must be declared as a Character and not as a Numeric!
All the best !
Anjani
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Apr 25, 2007 1:36 am    Post subject:
Reply with quote

Hello,

If i'm missing something here, please let me know, but will that "code" not replace the zeros in 30 and 1067?

Also, the "field" may be 15 in length (per the specs above) - the posted "number" is not 15 long, so i suspect that the initial space to + may generate multiple plus signs icon_confused.gif
Back to top
View user's profile Send private message
Anjani Kiran Mitikiri

New User


Joined: 05 Feb 2007
Posts: 6
Location: Chennai

PostPosted: Wed Apr 25, 2007 1:56 am    Post subject:
Reply with quote

Yeah u r right d.sch ! I missed that part icon_redface.gif
To avoid this for the second inspect we can try movinga character that is not expected to be normally present in 'A' may b by ^ or & and then the thrid inspect also needs to be modified accoridngly
Hope this helps
As for the second part fo ur comemnt , I wud ratehr look into the specific pattern and lenght of 'A' in general and then do something abt the +
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Apr 25, 2007 2:29 am    Post subject:
Reply with quote

Hello Kiran,

Please post the modifications you propose - i'm not sure i understand this
Quote:
To avoid this for the second inspect we can try movinga character that is not expected to be normally present in 'A' may b by ^ or & and then the thrid inspect also needs to be modified accoridngly


This too
Quote:
As for the second part fo ur comemnt , I wud ratehr look into the specific pattern and lenght of 'A' in general and then do something abt the +
has me confused.

Also, (i'm not an adabas/natural person), does Natural have an INSPECT verb? I seem to recall an EXAMINE, but i don't know the syntax. I've helped people debug, but haven't written Natural code of my own. . .
Back to top
View user's profile Send private message
Anjani Kiran Mitikiri

New User


Joined: 05 Feb 2007
Posts: 6
Location: Chennai

PostPosted: Wed Apr 25, 2007 4:40 am    Post subject:
Reply with quote

Am really sorry if I missed this..but are we not talking acout COBOL?
Back to top
View user's profile Send private message
Anjani Kiran Mitikiri

New User


Joined: 05 Feb 2007
Posts: 6
Location: Chennai

PostPosted: Wed Apr 25, 2007 4:44 am    Post subject:
Reply with quote

This shud work if we are talking abt COBOL
If it is NATURAL then pls try implementing this logic

01 WS-IX PIC 9(2).
Perform varying IX from 1 by 1 until A(IX:1) > 0
If A(IX:1) = 0
Move '' to A(IX:1)
END-IF
End-perform
Perform varying IX from 15 by -1 until A(IX:1) > 0
If A(IX:1) = 0
Move '' to A(IX:1)
END-IF
End-perform
Inspect A replacing all Spaces by '+'
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Apr 25, 2007 7:22 am    Post subject:
Reply with quote

Hello Kiran,

Quote:
Am really sorry if I missed this..but are we not talking acout COBOL?


I'm not positive about which language the question referred to, but this one is the Natural & MQSeries forum. Often as i look thru posts, i have to check which forum i'm in at the time icon_confused.gif

Not to worry icon_smile.gif We all get our wires crossed sometimes.

Other than the original post from prasanth_urs (back on the 15th), there has been no follow-up. . .
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 -> Java & MQSeries All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts READ A PACKED "NEGATIVE" FI... jdesouza CA Products 3 Tue May 02, 2017 11:43 pm
No new posts Alter &DATENS field in HEADER1 Angad DFSORT/ICETOOL 4 Mon Apr 24, 2017 11:49 am
No new posts Format record to remove Leading zeroes Learncoholic DFSORT/ICETOOL 14 Wed Apr 05, 2017 2:43 pm
No new posts How to pick only YYMMDD from DATE1P (... atulbaviskar SYNCSORT 7 Wed Mar 22, 2017 11:39 am


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