Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Unstring of comma delimited to Numeric fields

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Unstring of comma delimited to Numeric fields
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    Post subject: Re: Unstring of comma delimited to Numeric fields
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    Post subject: Re: Unstring of comma delimited to Numeric fields
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

Site Director


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

PostPosted: Fri Jan 19, 2007 9:04 pm    Post subject:
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    Post subject: Re: Unstring of comma delimited to Numeric fields
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

Site Director


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

PostPosted: Fri Jan 19, 2007 10:13 pm    Post subject:
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    Post subject: Re: Unstring of comma delimited to Numeric fields
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

Site Director


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

PostPosted: Fri Jan 19, 2007 11:19 pm    Post subject:
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: 3158
Location: Tucson AZ

PostPosted: Fri Jan 19, 2007 11:22 pm    Post subject: Re: Unstring of comma delimited to Numeric fields
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

Site Director


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

PostPosted: Sat Jan 20, 2007 12:32 am    Post subject:
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: 3158
Location: Tucson AZ

PostPosted: Sat Jan 20, 2007 12:44 am    Post subject:
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    Post subject: Re: Unstring of comma delimited to Numeric fields
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

Site Director


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

PostPosted: Sat Jan 20, 2007 12:53 am    Post subject:
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    Post subject:
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    Post subject: Re: Unstring of comma delimited to Numeric fields
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

Site Director


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

PostPosted: Mon Jan 22, 2007 9:25 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SORT BUT RETAIN HIGHEST VALUE ON NON-... leondan22 DFSORT/ICETOOL 2 Thu Dec 14, 2017 8:13 pm
No new posts Moving a COMP-3 Variable to a Numeric... ajayachander COBOL Programming 2 Thu Dec 14, 2017 5:46 pm
No new posts Merging 2 records at multiple rows wi... Bijesh DFSORT/ICETOOL 2 Wed Dec 06, 2017 1:50 am
No new posts Subtract the ZD fields to provide neg... Balaryan DFSORT/ICETOOL 4 Wed Oct 11, 2017 10:51 pm
No new posts Addition of two records on 2 fields amar143 SYNCSORT 8 Tue Oct 03, 2017 11:14 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us