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

UNSTRING with two delimiters


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
nazia.lalani
Warnings : 1

New User


Joined: 20 Mar 2009
Posts: 25
Location: hyderabad

PostPosted: Mon Jan 16, 2012 4:50 pm
Reply with quote

Hi,

I have a field WS-FEE which holds the value as
FEECODE,FEE DESC,FEEAMOUNT, FEE INDICATOR

but the WS-FEE is char of 1000 , it can have multiple occurence, each separated by pipe
FEECODE,FEE DESC,FEEAMOUNT, FEE INDICATOR|FEECODE,FEE DESC,FEEAMOUNT, FEE INDICATOR|

I want to fetch all the occurence in an array.


UNSTRING WS-FEE DELIMITED BY ','
INTO WS-FEE-CODE,
WS-FEE-DESC,
WS-FEE-AMOUNT,
WS-FEE-INDICATOR
END-UNSTRING.

This will give me first occurence.
If i perfrom the same in loop then i would the same values everytimes.
Is there any way i can get the second occurence second time.

Can some one help me on this.

Thanks
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Jan 16, 2012 5:01 pm
Reply with quote

Have you perchance looked at UNSTRING in the manual? WITH POINTER may satisfy you.
Back to top
View user's profile Send private message
nazia.lalani
Warnings : 1

New User


Joined: 20 Mar 2009
Posts: 25
Location: hyderabad

PostPosted: Mon Jan 16, 2012 5:09 pm
Reply with quote

okay...but what should be value of pointer for the first time..
second time onwards it should be the Pipe.


UNSTRING WS-FEE DELIMITED BY ','
INTO WS-FEE-CODE,
WS-FEE-DESC,
WS-FEE-AMOUNT,
WS-FEE-INDICATOR
WITH POINTER WC-PNTR
END-UNSTRING.

where WC-PNTR would be "|'.
How would that work for the first occurence.
Please help me in this regard.

Thasnks.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Jan 16, 2012 5:34 pm
Reply with quote

To work in a loop, you have to get the unstring to count the characters it has already looked at and tell unstring where to start next. So, forget the pipe (sort of, you'll need to ignore it) and look in the manual. Link at the top of the page.
Back to top
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 771
Location: Germany

PostPosted: Tue Jan 24, 2012 7:45 pm
Reply with quote

@ nazia.lalani

>> ...where WC-PNTR would be "|'.

No, the pointer is the offset in that whole String you want to unstring.
After unstring the pointer points to the next position. Plse read manual.


Very simply, you could achieve this using 2 unstrings.

Perform until counter...
...perform Unstring-01
...perform Unstring-02
...perform Write-Output
End-Perform

Unstring-01-Section
Unstring WS-FEE ...delimeted by "!" into Work-Area
...with pointer Poi01
End-Unstring
Add 1 to Poi01
Add Poi01 to counter

Unstring-02-Section
Unstring Work-Area delimeted by "," into
...WS-FEE-CODE,
...WS-FEE-DESC,
...WS-FEE-AMOUNT,
...WS-FEE-INDICATOR
End-Unstring
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 Handling the numeric data in unstring... COBOL Programming 18
No new posts Unstring COBOL Programming 4
No new posts UNSTRING problem COBOL Programming 3
No new posts UNSTRING a big string COBOL Programming 16
No new posts Unstring list of values into an array. COBOL Programming 8
Search our Forums:

Back to Top