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
 

 

UNSTRING problem

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: UNSTRING problem
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: 1187
Location: Bangalore,India

PostPosted: Tue Mar 25, 2008 6:34 pm    Post subject:
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    Post subject:
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: 1187
Location: Bangalore,India

PostPosted: Tue Mar 25, 2008 6:43 pm    Post subject:
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    Post subject:
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: 785
Location: Chennai, India

PostPosted: Tue Mar 25, 2008 7:07 pm    Post subject:
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: 1187
Location: Bangalore,India

PostPosted: Tue Mar 25, 2008 7:11 pm    Post subject:
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    Post subject:
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: 785
Location: Chennai, India

PostPosted: Tue Mar 25, 2008 7:22 pm    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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: 785
Location: Chennai, India

PostPosted: Tue Mar 25, 2008 7:54 pm    Post subject:
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    Post subject:
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: 785
Location: Chennai, India

PostPosted: Tue Mar 25, 2008 8:15 pm    Post subject:
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    Post subject:
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    Post subject:
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: 1218
Location: Israel

PostPosted: Wed Mar 26, 2008 3:25 pm    Post subject:
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    Post subject:
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    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 Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm
No new posts Problem in Running Query via JCL vickey_dw DB2 3 Tue Oct 18, 2016 11:11 pm
No new posts DB2 Streaming Batch Processing Problem Manshadi DB2 4 Sat Sep 24, 2016 12:14 pm
No new posts Problem with GETMAIN command amitc23 CICS 6 Thu Sep 01, 2016 1:01 pm
No new posts TXT2PDF problem - printing @ in PDF vipul65 All Other Mainframe Topics 9 Thu Aug 25, 2016 12:48 am


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