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

UNSTRING problem


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

New User


Joined: 31 Jan 2008
Posts: 15
Location: gurgaon

PostPosted: Tue Mar 25, 2008 6:29 pm
Reply with quote

I have a problem regarding unstring.

I need to use unstring into a line in which line started with spaces,
so please tell me how can I use UNSTRING in this case.

regards,
pritanshu rai
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Tue Mar 25, 2008 6:34 pm
Reply with quote

Hi Pritanshu,

Would you please provide sample input as well as output?
Back to top
View user's profile Send private message
pritanshu

New User


Joined: 31 Jan 2008
Posts: 15
Location: gurgaon

PostPosted: Tue Mar 25, 2008 6:36 pm
Reply with quote

i do have a sequential file in which
i have 88 level
like 88 variable value 'a'.
i need to unstring above line
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Tue Mar 25, 2008 6:43 pm
Reply with quote

Hi Pritanshu,

Would you please provide some sample i/p & o/p?
Still ur requirement is not clear.
Back to top
View user's profile Send private message
pritanshu

New User


Joined: 31 Jan 2008
Posts: 15
Location: gurgaon

PostPosted: Tue Mar 25, 2008 6:55 pm
Reply with quote

ok i tell u real senario wht i m doin is this; i m havin a copy book which had some 02 as well as 88 level code n i need to read this copybook sequentially , and i need to use unstring on 88 level,
10 REQ-V16-RETURN-CODE PIC 999.
88 REQ-RETURN-OK VALUE 000.
88 REQ-INVALID-REQUEST VALUE 100.
88 REQ-NO-DATA-FOUND VALUE 148.
88 REQ-SOURCE-REQ VALUE 128.

so for unstring if i use delimited by space is it ok for 88 level as it has space in the starting of line
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Tue Mar 25, 2008 7:07 pm
Reply with quote

So first identifier will have space in it...
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Tue Mar 25, 2008 7:11 pm
Reply with quote

Hi Pritanshu,

Do you have any idea about 88 level?
Please refer the manual link top of this page.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Mar 25, 2008 7:11 pm
Reply with quote

suggest you use: delimited by all spaces
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Tue Mar 25, 2008 7:22 pm
Reply with quote

Dick,
Quote:
suggest you use: delimited by all spaces

This also results in the same, ie, first identifier in INTO clause has space...

Please correct me if I am wrong.
Back to top
View user's profile Send private message
pritanshu

New User


Joined: 31 Jan 2008
Posts: 15
Location: gurgaon

PostPosted: Tue Mar 25, 2008 7:28 pm
Reply with quote

hi guptae,
i know about 88 level but what i m asking is not related to 88 level it s related to unstring
Back to top
View user's profile Send private message
pritanshu

New User


Joined: 31 Jan 2008
Posts: 15
Location: gurgaon

PostPosted: Tue Mar 25, 2008 7:29 pm
Reply with quote

hi dick
can u tell me how it works delimited by all spaces
in this senario

88 REQ-RETURN-OK VALUE 000.
Back to top
View user's profile Send private message
pritanshu

New User


Joined: 31 Jan 2008
Posts: 15
Location: gurgaon

PostPosted: Tue Mar 25, 2008 7:33 pm
Reply with quote

if i use unstring copy-record delimited by all space.
copy-book
spaces 88 REQ-RETURN-OK VALUE 000.
spaces 88 REQ-INVALID-REQUEST VALUE 100.
Then wht is my result in this case
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Tue Mar 25, 2008 7:54 pm
Reply with quote

I would think this thread is not moving in correct direction.

Anyway it's rough idea,

READ line...
Check & If it contains spaces(in your case, ie, 88 variables), use one more identifier in UNSTRING of INTO clause...
So first identifier will have space...
Refer other identifiers which have the result of UNSTRING...
Back to top
View user's profile Send private message
pritanshu

New User


Joined: 31 Jan 2008
Posts: 15
Location: gurgaon

PostPosted: Tue Mar 25, 2008 8:04 pm
Reply with quote

thax Gnanas

ok i got it i try this if i have any problem than i again cum to u pepole

regards,
pritanshu rai
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Tue Mar 25, 2008 8:15 pm
Reply with quote

Another way...
If you know exactly how many spaces are there in the starting of 88 line...
Code:
MOVE 88-line(2:80) TO 88-modified-line.

Here I assume one space is there in the startring and Record length is 80...
And apply UNSTRING on 88-modified-line...
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Mar 25, 2008 9:01 pm
Reply with quote

ok children, since none of you bother to run tests:

the input line is:
88 THIS-IS-REFERENCE VALUE 1, 2, 4, 5.

there are 13 spaces in front of the '88'.
Code:

now, unstring into  delimited by space

unstrung-1   
unstrung-2
unstrung-3
unstrung-4
unstrung-5
unstrung-6
unstrung-7
unstrung-8
unstrung-9
unstrung-10
unstrung-11
unstrung-12
unstrung-13
unstrung-14  88
unstrung-15
unstrung-16 THIS-IS-THE-REFERENCE

Code:

now, unstring into  delimited by ALL spaceES

unstrung-1   
unstrung-2 88
unstrung-3 THIS-IS-THE-REFERENCE
unstrung-4 VALUE
unstrung-5 1,
unstrung-6 2,
unstrung-7 4,
unstrung-8 5.
unstrung-9
unstrung-10
unstrung-11
unstrung-12
unstrung-13
unstrung-14 
unstrung-15
unstrung-16


Slight difference in results, thus makes the coding easier. You don't have to know anything about the input line other than an inspect returned a positive for an ' 88 ' in the first 30 or so char of the line (that's _space 8 8 space.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Mar 25, 2008 9:04 pm
Reply with quote

when dealing with copybooks, I would not read and process one line at a time. I would read and build the line until I found a period.

otherwise dealing with this:
Code:

05  work-area           pic 9(3).
      88  valid-values  value 1,
                              2,
                              3,
                              4.

would be a lot of fun.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Wed Mar 26, 2008 3:25 pm
Reply with quote

So now you have 2 possibilities:
1. using UNSTRING alone. you know the first identifier will be empty:
Code:
    UNSTRING cobol-line DELIMITED BY ALL SPACES
        INTO ws-dummy ws-level ws-fldname ws-const ws-values
    IF ws-level NOT = '88' THEN
        .
        .

2. using INSPECT and UNSTRING. remove leading spaces then split line:
Code:
    MOVE 0 TO ws-count
    INSPECT cobol-line TALLYING ws-count FOR LEADING SPACE
    ADD 1 TO ws-count
    MOVE cobol-line (ws-count:) TO ws-line
    UNSTRING ws-line DELIMITED BY ALL SPACES
        INTO ws-level ws-fldname ws-const ws-values
    IF ws-level NOT = '88' THEN
        .
        .

All this assuming that there is no numbering in columns 1-6
Also assuming that lines are not splitted, like in:
Code:
    10 REQ-V16-RETURN-CODE PIC 999.
       88 REQ-RETURN-OK
                                         VALUE 000.
       88 REQ-INVALID-REQUEST
                                         VALUE 100.
Back to top
View user's profile Send private message
pritanshu

New User


Joined: 31 Jan 2008
Posts: 15
Location: gurgaon

PostPosted: Wed Mar 26, 2008 7:43 pm
Reply with quote

thanks to all
my problem has been resolved by using
UNSTRING text DELIMITED BY ALL SPACES


regards,
pritanshu rai
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 Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts z/vm installation problem All Other Mainframe Topics 0
No new posts Job scheduling problem. JCL & VSAM 9
No new posts Problem with IFTHEN=(WHEN=GROUP,BEGIN... DFSORT/ICETOOL 5
No new posts Need to add field to copybook, proble... COBOL Programming 14
Search our Forums:

Back to Top