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 Replacing same string with different ... vickey_dw DFSORT/ICETOOL 6 Wed Feb 22, 2017 10:44 pm
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Execute TSO ACF commands from COBOL-I... supreethi.srid TSO/ISPF 0 Tue Feb 21, 2017 5:19 pm
No new posts Mainframe Interview Questions CICS,CO... akshathan Mainframe Interview Questions 6 Thu Feb 09, 2017 6:38 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm


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