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
 

 

Can i do it with unstring clause in COBOL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
rgarg

New User


Joined: 15 Feb 2006
Posts: 18

PostPosted: Thu Jul 12, 2007 8:10 am    Post subject: Can i do it with unstring clause in COBOL
Reply with quote

I have a variable lets say A with PIC clause X(40).

01 A PIC X(40) VALUE 'GARG,RAJIV KUMAR'

I want to unstring it and move it in the new variable such that the B has value as follows

01 B
05 B-FIRST-NAME PIC X(10) value moved should be RAJIV
05 B-MIDDLE-NAME PIC X(10) value moved should be KUMAR
05 B-LAST-NAME PIC X(10) value moved should be GARG

Can i do it with unstring clause in COBOL. If no, how can i possible do it? Again this all is dynamic. May be sometimes i don't get the middle name i.e. GARG

Thanks and Regards,
Rajiv Garg
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: Thu Jul 12, 2007 8:35 am    Post subject:
Reply with quote

Hello,

If your data will not be predictable, you will probably not be able to use the UNSTRING function to do what you want. If there is a way to ensure that the name field will always have the first, middle, and last name or at least an agreed upon delimiter when there is no corresponding data, you may be able to use UNSTRING.

If you have unpredictable data, your task will be more difficult. You will need to determine some rules, break the 40 byte field 1nto at least 4 smaller fields (last, first, middle, other), and then apply the rules to the values in those fields. Can you be sure the order of the name field will be the same? You will also need to determine if the comma, the space, or something else might be used as a delimiter.

If this is a typo, please let me know and i'll correct it.
Quote:
May be sometimes i don't get the middle name i.e. GARG
Should GARG be last name?
Back to top
View user's profile Send private message
rgarg

New User


Joined: 15 Feb 2006
Posts: 18

PostPosted: Thu Jul 12, 2007 8:43 am    Post subject:
Reply with quote

I am sorry for the typo. Yes, GARG is the last name. Kumar is the Middle name.

Yes the format i receive is same always and is as follows

GARG,RAJIV KUMAR

LAST NAME,FIRST NAME MIDDLE NAME

i.e. Comma between last name and first name(GARG,RAJIV). Space between first name and middle name(RAJIV KUMAR)

But may be there will be no middle name(KUMAR) sometimes. Then how will i divide the corresponding fields.

Thanks and Regards
Rajiv Garg
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: Thu Jul 12, 2007 8:47 am    Post subject:
Reply with quote

Hello,

Will any part of a name ever have a space in it?
Back to top
View user's profile Send private message
rgarg

New User


Joined: 15 Feb 2006
Posts: 18

PostPosted: Thu Jul 12, 2007 8:54 am    Post subject:
Reply with quote

Yes, there is space between first name and middle name. Another example

DRFNE,IRMIE R

Here last name is DRFNE
first name is IRMIE
middle name is R

This is the format i will receive everytime. Now i need to break it in first,middle and last name. Can you please help me with this

Thanks and Regards
Rajiv Garg
Back to top
View user's profile Send private message
William Thompson

Global Moderator


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

PostPosted: Thu Jul 12, 2007 10:04 am    Post subject:
Reply with quote

Unstring will work just fine, go for it.....
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: Thu Jul 12, 2007 7:27 pm    Post subject:
Reply with quote

Hello,

I don't believe i've made my question quite clear.

Might there ever be a name like
DRFNE,IRMIE R DONALD or
DRFNE,IRMIE RON DON or
DRFNE,IRMIE JOE RONALD where IRMIE JOE is the first name and RONALD is the middle name
(with a 2-part first or middle name)?

If the name will always be like DRFNE,IRMIE R and the only variance is that sometimes there may be a middle initial instead of a middle name, UNSTRING should do what you want.
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
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am
No new posts Cobol upgrade - source code missing f... gthmrj IBM Tools 1 Wed Apr 26, 2017 6:04 pm
No new posts COBOL Programming Sandpit? jodrisco COBOL Programming 6 Wed Apr 12, 2017 3:47 am


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