View previous topic :: View next topic
|
Author |
Message |
dinesh125
New User
Joined: 19 Jan 2007 Posts: 6 Location: India
|
|
|
|
Hi,
I have to do unstring of comma delimited file to some fields.
Input file:
M,7202274886,1.11.111.1,test@test.com,2M4,1,1,4,25,25
Fields to be unstringed:
ACCT-STATUS-TYP PIC 9(10).
CALL-ID PIC X(15).
FRAM-IP-ADDR PIC X(15).
USR-NM PIC X(64).
G3PP2-USR-ZN PIC 9(10).
G3PP2-FWD-MPLX-OPTN PIC 9(10).
G3PP2-REV-MPLX-OPTN PIC 9(10).
G3PP2-CDMA-SER-OPTN PIC 9(10).
G3PP2-FWD-TRF-TYP PIC 9(10).
G3PP2-REV-TRF-TYP PIC 9(10).
I am doing UNSTRING by COMMA Delimited directly to above fields. Then I want to do Numeric Edit check for Numeric fields.
If I unstring a Non-numric like M to ACCT-STATUS-TYP ( PIC 9(10)). Numric check is not working ie; it is treating as Numeric. What is the problem in my approach while doing UNSTRING?
Thanks,
Dinesh |
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
Dinesh,
Without doing any specific tests, I suspect this Previous Post may be the solution. |
|
Back to top |
|
|
dinesh125
New User
Joined: 19 Jan 2007 Posts: 6 Location: India
|
|
|
|
Thanks Dave for quick reply.
Hex values are like this:
M,7202274886,1.11.111,
D6FFFFFFFFFF6F4FF4FFF6
4B7202274886B1B11B111B
So you mean to say when we Unstring 'M' to 9(10) field only '4' being moved? In this cae what may be the solution? To unstring to Character fields and then move them to Numeric fields?
Thanks,
Dinesh |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
If you unstring into all character fields, you will be able to validate properly. Once you are satisfied that the value is acceptable, then move it to the numeric field(s). |
|
Back to top |
|
|
dinesh125
New User
Joined: 19 Jan 2007 Posts: 6 Location: India
|
|
|
|
Thanks Dick.
If I UNSTRING 'M' to X(10), what are the way to do Numeric check? Like can we use 'IS NUMERIC' function or some other ways are there?
Dinesh |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
You're welcome.
Yes, in your code you can say
Code: |
IF X10-FIELD NOT NUMERIC. . . . |
|
|
Back to top |
|
|
dinesh125
New User
Joined: 19 Jan 2007 Posts: 6 Location: India
|
|
|
|
Dick,
UNSTRING WS-RECORD DELIMITED by COMMA
INTO WS-TYPE-CHAR (X(10))....
END-UNSTRING
This WS-TYP-CHAR will have spaces if I Unstring '1' to this.
Then it will be Non-numeric right?
Then how to handle this?
Thanks,
Dinesh |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello Dinesh,
Yes, there will be spaces in WS-TYP-CHAR.
This is from another similar post
Quote: |
You might treat this as an error, you might replace any spaces with zeros, or you might write code to use only the digits provided (after making sure that the field contains no alpha characters).
|
You will need to manipulate the contents to do what meets your requirements. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
UNSTRING WS-RECORD DELIMITED by COMMA
count in ws-len
INTO WS-TYPE-CHAR (X(10))....
END-UNSTRING
if ws-type-char(1:ws-len) numeric....
Should test positive..... |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
That unstring will work for the "M," case, but i believe if the ws-len will not be what is wanted if the value was "MR ," or "98 ,". There would also be the numeric consideration for the "98 ,". |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Dick,
I don't understand, for "MR" or "98", the count value would be 2, not numeric and numeric.....
Bill |
|
Back to top |
|
|
dinesh125
New User
Joined: 19 Jan 2007 Posts: 6 Location: India
|
|
|
|
My plan of approach is:
Define a RIGHT JUSTFIED X(10) field and UNSTING the value into this field.
Use INSPECT ...REPLACING LEADING SPACES BY ZEROS
then MOVE Value TO 9(10) field.
Use NUMERIC to check whether value is numeric or not as I want only Numeric values.
Is this OK or any other simple approach is there? Please let me know...
Thanks all,
Dinesh |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello Dinesh,
Yes, right justifying the data and replacing spaces with zeros should work for you.
Bill,
In my example i intentionally placed a space between the data and the comma. I believe the count would then be 3. . . . |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Dinesh,
Why do you define 2 fields that contain mixed num and alpha chars as PIC 9? And why do you have to num test them?
From the variable names it doesn't sound like you'll be doing arith on them. |
|
Back to top |
|
|
dinesh125
New User
Joined: 19 Jan 2007 Posts: 6 Location: India
|
|
|
|
Jack,
I did not understand your question.
My requirement is like this:
I have a comma delimited file which contains Alphanumeric and Numeric fields to be processed in my program. For this I am using UNSTRING. After USTRING, I want to check whether numeric fields are exactly numeric or not.
Thanks,
Dinesh |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hi Dinesh,
Yes, you will want to check the UNSTRung fields for valid values. If you validate the fields immediately, you will avoid many problems later.
You may also have alpha fields that need to be validated.
Good luck and let us know how it goes. |
|
Back to top |
|
|
|