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
 

 

string & unstring in cobol

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: string & unstring in cobol
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

Site Director


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

PostPosted: Mon Oct 12, 2009 11:04 pm    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Tue Oct 13, 2009 12:17 am    Post subject: Reply to: string & unstring in cobol
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    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 Fileaid Update Replace with null string descann Compuware & Other Tools 4 Mon May 15, 2017 3:00 pm
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


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