View previous topic :: View next topic
|
Author |
Message |
prasanth_urs
New User
Joined: 04 Dec 2006 Posts: 44 Location: Pune,India
|
|
|
|
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 |
|
|
Anjani Kiran Mitikiri
New User
Joined: 05 Feb 2007 Posts: 6 Location: Chennai
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
Back to top |
|
|
Anjani Kiran Mitikiri
New User
Joined: 05 Feb 2007 Posts: 6 Location: Chennai
|
|
|
|
Yeah u r right d.sch ! I missed that part
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Anjani Kiran Mitikiri
New User
Joined: 05 Feb 2007 Posts: 6 Location: Chennai
|
|
|
|
Am really sorry if I missed this..but are we not talking acout COBOL? |
|
Back to top |
|
|
Anjani Kiran Mitikiri
New User
Joined: 05 Feb 2007 Posts: 6 Location: Chennai
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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
Not to worry 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 |
|
|
|