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 with two delimiters

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: UNSTRING with two delimiters
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7308

PostPosted: Mon Jan 16, 2012 5:01 pm    Post subject: Reply to: UNSTRING WITH TWO DELIMITERS
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    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7308

PostPosted: Mon Jan 16, 2012 5:34 pm    Post subject: Reply to: UNSTRING WITH TWO DELIMITERS
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: 755
Location: Germany

PostPosted: Tue Jan 24, 2012 7:45 pm    Post subject:
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    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 Unstring list of values into an array. Roshnii COBOL Programming 8 Mon Jun 27, 2016 6:25 pm
No new posts Problem with UNSTRING of CSV data Bill Woodger COBOL Programming 14 Tue Dec 15, 2015 5:32 pm
No new posts Add delimiters in a fixed length record Venkata Ramayya DFSORT/ICETOOL 4 Fri Mar 27, 2015 3:49 am
No new posts Unstring in Cobol Govardhana krishna COBOL Programming 7 Thu Oct 17, 2013 8:52 pm
No new posts Unstring the message d katkuri COBOL Programming 13 Wed Aug 14, 2013 12:28 pm


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