View previous topic :: View next topic
|
Author |
Message |
pritanshu
New User
Joined: 31 Jan 2008 Posts: 15 Location: gurgaon
|
|
|
|
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 |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
Hi Pritanshu,
Would you please provide sample input as well as output? |
|
Back to top |
|
|
pritanshu
New User
Joined: 31 Jan 2008 Posts: 15 Location: gurgaon
|
|
|
|
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 |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
Hi Pritanshu,
Would you please provide some sample i/p & o/p?
Still ur requirement is not clear. |
|
Back to top |
|
|
pritanshu
New User
Joined: 31 Jan 2008 Posts: 15 Location: gurgaon
|
|
|
|
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 |
|
|
Gnanas N
Active Member
Joined: 06 Sep 2007 Posts: 792 Location: Chennai, India
|
|
|
|
So first identifier will have space in it... |
|
Back to top |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
Hi Pritanshu,
Do you have any idea about 88 level?
Please refer the manual link top of this page. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
suggest you use: delimited by all spaces |
|
Back to top |
|
|
Gnanas N
Active Member
Joined: 06 Sep 2007 Posts: 792 Location: Chennai, India
|
|
|
|
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 |
|
|
pritanshu
New User
Joined: 31 Jan 2008 Posts: 15 Location: gurgaon
|
|
|
|
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 |
|
|
pritanshu
New User
Joined: 31 Jan 2008 Posts: 15 Location: gurgaon
|
|
|
|
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 |
|
|
pritanshu
New User
Joined: 31 Jan 2008 Posts: 15 Location: gurgaon
|
|
|
|
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 |
|
|
Gnanas N
Active Member
Joined: 06 Sep 2007 Posts: 792 Location: Chennai, India
|
|
|
|
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 |
|
|
pritanshu
New User
Joined: 31 Jan 2008 Posts: 15 Location: gurgaon
|
|
|
|
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 |
|
|
Gnanas N
Active Member
Joined: 06 Sep 2007 Posts: 792 Location: Chennai, India
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
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 |
|
|
pritanshu
New User
Joined: 31 Jan 2008 Posts: 15 Location: gurgaon
|
|
|
|
thanks to all
my problem has been resolved by using
UNSTRING text DELIMITED BY ALL SPACES
regards,
pritanshu rai |
|
Back to top |
|
|
|