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

Unstring of comma delimited to Numeric fields


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
dinesh125

New User


Joined: 19 Jan 2007
Posts: 6
Location: India

PostPosted: Fri Jan 19, 2007 7:42 pm
Reply with quote

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
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Fri Jan 19, 2007 8:48 pm
Reply with quote

Dinesh,

Without doing any specific tests, I suspect this Previous Post may be the solution.
Back to top
View user's profile Send private message
dinesh125

New User


Joined: 19 Jan 2007
Posts: 6
Location: India

PostPosted: Fri Jan 19, 2007 8:59 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Fri Jan 19, 2007 9:04 pm
Reply with quote

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
View user's profile Send private message
dinesh125

New User


Joined: 19 Jan 2007
Posts: 6
Location: India

PostPosted: Fri Jan 19, 2007 9:08 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Fri Jan 19, 2007 10:13 pm
Reply with quote

You're welcome.

Yes, in your code you can say
Code:
IF X10-FIELD NOT NUMERIC. . . .
Back to top
View user's profile Send private message
dinesh125

New User


Joined: 19 Jan 2007
Posts: 6
Location: India

PostPosted: Fri Jan 19, 2007 10:23 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Fri Jan 19, 2007 11:19 pm
Reply with quote

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
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Fri Jan 19, 2007 11:22 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Sat Jan 20, 2007 12:32 am
Reply with quote

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 ,". icon_confused.gif
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Sat Jan 20, 2007 12:44 am
Reply with quote

Dick,

I don't understand, for "MR" or "98", the count value would be 2, not numeric and numeric.....

Bill
Back to top
View user's profile Send private message
dinesh125

New User


Joined: 19 Jan 2007
Posts: 6
Location: India

PostPosted: Sat Jan 20, 2007 12:46 am
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Sat Jan 20, 2007 12:53 am
Reply with quote

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. . . . icon_confused.gif
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Jan 20, 2007 9:45 pm
Reply with quote

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
View user's profile Send private message
dinesh125

New User


Joined: 19 Jan 2007
Posts: 6
Location: India

PostPosted: Mon Jan 22, 2007 7:21 am
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Mon Jan 22, 2007 9:25 am
Reply with quote

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
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 Convert HEX to Numeric DB2 3
No new posts Find a record count/numeric is multip... COBOL Programming 1
No new posts Concatenate 2 fields (usage national)... COBOL Programming 2
No new posts Cobol COMP-2 fields getting scrambled... Java & MQSeries 6
Search our Forums:

Back to Top