View previous topic :: View next topic
|
Author |
Message |
nazia.lalani Warnings : 1 New User
Joined: 20 Mar 2009 Posts: 25 Location: hyderabad
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Have you perchance looked at UNSTRING in the manual? WITH POINTER may satisfy you. |
|
Back to top |
|
|
nazia.lalani Warnings : 1 New User
Joined: 20 Mar 2009 Posts: 25 Location: hyderabad
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
UmeySan
Active Member
Joined: 22 Aug 2006 Posts: 771 Location: Germany
|
|
|
|
@ 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 |
|
|
|