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

string & unstring in cobol


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

New User


Joined: 24 Sep 2009
Posts: 2
Location: chennai

PostPosted: Mon Oct 12, 2009 8:45 pm
Reply with quote

Hi,

I am reading an customer name (pic x(26)) from an input file which is in the format (lastname,firstname) . i need to write the cust name in output file in this format (firstname lastname).

How can we acheive ths without using inspect statement ?

i m trying

unstring customer-name delimited by ',' into ws-lstname,ws-fsname.

how can we define ws-lstname & ws-fstname ?
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 Oct 12, 2009 11:04 pm
Reply with quote

Hello,

Quote:
how can we define ws-lstname & ws-fstname ?
We can't say as this depends on your site/application-specific data rules.

If you define them both as x(26), nothing would be lost due to overflow. . .

Quote:
How can we acheive ths without using inspect statement ?
I don't see how this might be achieved with inspect. . . icon_confused.gif

After the unstring, issue a string delimiting the 2 separate fields by space and inserting a space or a comma,space between the re-arranged data.

Keep in mind that this will only work for very simple names. . .
Back to top
View user's profile Send private message
Mickeydusaor

Active User


Joined: 24 May 2006
Posts: 258
Location: Salem, Oregon

PostPosted: Mon Oct 12, 2009 11:39 pm
Reply with quote

Dick the Unstring will work, but if the name in the input field has leading spaces and not the first character then the new output field will reflect this and that is why I wrote our NAME subroutine using the inspect statements
so that I would find the actual beginning of each of the names.


Code:

Examples: "         lastname,     firstname"
          "    lastname,  firstname"
          "lastname,                 firstname"
          "lastname,firstname"

The INSPECCT statement allows you to locate the begining of each name
and then I use a STRING command to put the name in output.
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: Tue Oct 13, 2009 12:17 am
Reply with quote

Yup, INSPECT could identify leading spaces, but wouldn't do the re-arranging. . . icon_smile.gif

This looked like a class exercise so i gave the "simple solution". . .

d
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 Replace each space in cobol string wi... COBOL Programming 3
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
Search our Forums:

Back to Top