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
 

 

Spacing out the word & adjusting space bween remaining c
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
vinu78

Active User


Joined: 02 Oct 2008
Posts: 129
Location: India

PostPosted: Thu Dec 17, 2009 10:55 pm    Post subject: Spacing out the word & adjusting space bween remaining c
Reply with quote

Hi,

I need to Blank out P.O. BOX <num/alphabet> wherever it comes in the Address field.
Eg: P.O. BOX 68 300 S. MAIN ST should be 300 S. MAIN ST
P.O. BOX M, 12 FEDERAL DR should be 12 FEDERAL DR

The logic I have in mind is

Code:
INSPECT WS-DESC-CHK TALLYING Z-COUNT FOR ALL 'P.O. BOX'
IF Z-COUNT > 0                                       
   UNSTRING WS-ADDRESS-POST DELIMITED BY 'P.0. BOX ' 
       INTO WS-ADDR-PART1   WS-ADDR-PART2               
   UNSTRING WS-ADDR-PART2 DELIMITED BY SPACES
       INTO WS-ADDR-PART3  WS-ADDR-PART4
   MOVE SPACES TO WS-ADDR-PART3


I was trying to do the below mentioned logic but lost in the coding part.
- To find if the address field contains 'P.O. BOX'
- If yes, find the numeral or alphabet attached to P.O. BOX and space it
out.
- Then blank out the P.O. BOX
- Write the remaining charcters to Output address field

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

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Dec 18, 2009 12:29 am    Post subject:
Reply with quote

Hello,

Will the literal always be first in the string and always spelled as shown? What about PO BOX or P O BOX?
Back to top
View user's profile Send private message
vinu78

Active User


Joined: 02 Oct 2008
Posts: 129
Location: India

PostPosted: Fri Dec 18, 2009 12:39 am    Post subject:
Reply with quote

Hi Dick,

The literal will always be the same - P.O. BOX <any number/alphabet>
Only the number. alphabet following the P.O. BOX differs.

Mostly it comes as first in the string but can come in midway too.

Thanks
Vinu
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Dec 18, 2009 2:17 am    Post subject:
Reply with quote

Hello,

Quote:
Mostly it comes as first in the string but can come in midway too.
One approach might be to parse the entire field (using reference modification) looking for the literal as a single value 'P.O. BOX'.

If it doesn't exist, the string is ok as is.

If it does exist, change it to '$$$FOUND'. Then do the unstring as you did in the eariler requirement. When re-building the string to remove the po box, skip the field with the $$$FOUND and the field after it (using reference modified MOVEs rather than STRING).
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Dec 18, 2009 2:37 am    Post subject:
Reply with quote

you already have a table containing
values in text - replacement value

add a new field to your item - special handling.
before = UNSTRUNG TEXT
after = replacement text
special handling=routine to do something
so your table would be:
Code:

before     after                            spec handling
====       =====                        =======
P.O.BOX    (contains spaces)            space out next UNSTRUNG field
AVENUE     AVE                          NONE
1          1st                          NONE


since you can delimit your STRING with space, you would not have any extra spaces.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Dec 18, 2009 2:41 am    Post subject:
Reply with quote

Hello,

I believe there is a space in the input between P.O. and BOX. . .
Back to top
View user's profile Send private message
vinu78

Active User


Joined: 02 Oct 2008
Posts: 129
Location: India

PostPosted: Fri Dec 18, 2009 3:00 am    Post subject:
Reply with quote

Yes there is a space between P.O. and BOX
Here the concern is that I need to SPACE out P.O. BOX and also the number/alphabet coming along with it. So just spacing out P.O. BOX will leave the number alone in the output address field

For finding the P.O. BOX, I have used
Code:
INSPECT WS-DESC-CHK TALLYING Z-COUNT FOR ALL 'P.O. BOX'
If Z-COUNT > 0
    The string contains P.O. BOX   

Now I need to find the number/alphabet following the P.O. BOX and space out that too.

Thanks
Vinu
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Dec 18, 2009 3:16 am    Post subject:
Reply with quote

Dick,

you are correct and your solution is probably better for this situation.

Vinu,

Quote:
Now I need to find the number/alphabet following the P.O. BOX and space out that too.


well, maaayyyybeee you are on the wrong track.

go back and read Dick's suggestion.
He already provided you with a solution.
If you don't understand what he said, say: please explain in more detail
instead of repeating your request and repeating your flawed logic.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1238
Location: Richfield, MN, USA

PostPosted: Fri Dec 18, 2009 3:18 am    Post subject:
Reply with quote

Your original post indicated both an alphabetic O and the numeral 0. Be careful when coding the abbreviation for Office.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Dec 18, 2009 3:37 am    Post subject:
Reply with quote

Hello,

To repeat with a bit of emphasis:
Quote:
. . .When re-building the string to remove the po box, skip the field with the $$$FOUND and the field after it . . .
Whatever is in the "field after" can be skipped - alpha or numberic or both. . .
Back to top
View user's profile Send private message
vinu78

Active User


Joined: 02 Oct 2008
Posts: 129
Location: India

PostPosted: Fri Dec 18, 2009 5:17 am    Post subject:
Reply with quote

Sorry Dick Brenholtz. I am trying to understand Dick Scherrer's logic.
Thanks a lot Dick for providing the logic.

As per my understanding, this is what I need to do
- Find for 'P.O. BOX' occurance in the string and replace it as $$$FOUND
- Unstring the above string having $$$FOUND delimited by spaces
- When rebuilding the string back, skip the field containing $$$FOUND
and the immediate next field.

In the Reference modification to check for 'P.O. BOX', can you please help me how to check for the whole literal 'P.O. BOX'.
I tried searching in this forum but was not able to find it out. Can anyone please give me pointers in that.

Thanks
Vinu
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Dec 18, 2009 7:36 am    Post subject:
Reply with quote

Hi Vinu,

Pseudo code:
Code:
Define a numeric "displacement" field (ws-d) in ws.
Move 1 to it.
Loop thru the input string
  If input-string(ws-d : 7) = 'p.o. box'
    - you need to replace the literal with $$$FOUND (ws-d points there)
      and leave this loop.
  Increment ws-d.
  If ws-d < 28 - continue the loop
   otherwise - the literal is not in this string.
Back to top
View user's profile Send private message
Lijo

New User


Joined: 24 Aug 2008
Posts: 41
Location: Cochin

PostPosted: Fri Dec 18, 2009 2:54 pm    Post subject: Reply to: Spacing out the word & adjusting space bween r
Reply with quote

Probably Dick's method will be more efficient, but I am just posting another way:

Code:
INSPECT WS-DESC-CHK REPLACING ALL 'P.O. BOX' BY '$$$FOUND'
   UNSTRING WS-DESC-CHK DELIMITED BY SPACES
       INTO WS-ADDR-PART1 WS-ADDR-PART2
   STRING WS-ADDR-PART1 DELIMITED BY SPACES
          ' '           DELIMITED BY SIZE
          WS-ADDR-PART2 DELIMITED BY SPACES
     INTO WS-ADDR-PART4
INSPECT WS-DESC-CHK REPLACING ALL WS-ADDR-PART4 BY SPACES
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Dec 18, 2009 9:48 pm    Post subject:
Reply with quote

Hi Lijo,

Good catch - i should have been using $$$FOUND (rather than the $$FOUND typo i got stuck on - i've hopefully corrected the previous replies) icon_smile.gif

Will the code you posted handle the P.O. BOX if it is not in the beginning of the string?
Back to top
View user's profile Send private message
vinu78

Active User


Joined: 02 Oct 2008
Posts: 129
Location: India

PostPosted: Sat Dec 19, 2009 2:31 am    Post subject:
Reply with quote

Thanks Dick and Lijo for the pseudo code.
I will try the logics posted by you and will let you know the result.

Dick - Thanks for the reference modification logic.

Lijo - Your code works great when 'P.O. BOX' comes in the starting of the string. Or is there any way to UNSTRING from $$$FOUND word.

Thanks
Vinu
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Sat Dec 19, 2009 3:26 am    Post subject:
Reply with quote

$$FOUND starts in position 11 of the text.

UNSTRING text(17:)
into .....
Back to top
View user's profile Send private message
Lijo

New User


Joined: 24 Aug 2008
Posts: 41
Location: Cochin

PostPosted: Mon Dec 21, 2009 12:24 pm    Post subject: Reply to: Spacing out the word & adjusting space bween r
Reply with quote

Sorry Guys. I didn't consider the occurrence of 'P.O. Box' in the middle of the string in my earlier post. If you've not got a solution yet, you can try this out:

Code:
INSPECT WS-DESC-CHK TALLYING Z-COUNT FOR CHARACTERS
BEFORE INITIAL 'P.O. BOX' (assuming that P.O. Box will come only once as per your example)
ADD 10 TO Z-COUNT GIVING WS-START (8bytes for P.O. BOX and one space after that as shown in your example, so the next character is likely to be start at 10th position)
SUBTRACT WS-START FROM 28 GIVING WS-LENGTH(assuming total length of the straing as 28)
UNSTRING WS-DESC-CHK(WS-START:WS-LENGTH) DELIMITED BY SPACES
         INTO WS-ADDR-PART1 WS-ADDR-PART2
STRING 'P.O. BOX '    DELIMITED BY SIZE
        WS-ADDR-PART1 DELIMITED BY SPACES
        INTO WS-ADDR-PART4
INSPECT WS-DESC-CHK REPLACING ALL WS-ADDR-PART4 BY SPACES


First INSPECT is the same thing which Dick showed using loop constraints. May be I am too lazy to follow loop constarints;)...
Back to top
View user's profile Send private message
vinu78

Active User


Joined: 02 Oct 2008
Posts: 129
Location: India

PostPosted: Tue Dec 22, 2009 3:25 am    Post subject:
Reply with quote

Thanks a lot Lijo for the code.

I tried testing this code and found that WS-ADDR-PART4 contains the literal 'P.O. BOX <number/alphabet till spaces> which is exactly that I wanted. However on executing the last line
INSPECT WS-DESC-CHK REPLACING ALL WS-ADDR-PART4 BY SPACES

I have found the following concerns.

- If the WS-DESC-CHK contains 'P.O. BOX <num/alphabet> at the beginning of text, the code is not replacing.
Eg: P.O. BOX 68; 300 S MAIN STREET

- If the WS-DESC-CHK contains 'P.O. BOX <num/alphabet> at the end of text, it is erased and the code works FINE.
Eg: 148 STAUFFER ROAD; P.O. BOX 267

- If the WS-DESC-CHK contains 'P.O. BOX <num/alphabt> as the only string, it is erased and the code works FINE.
Eg: P.O. BOX 460

So for the first case, whether the problem is because of WS-ADDR-PART4 contains spaces at the end.

Please help.

Thanks
Vinu
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue Dec 22, 2009 3:52 am    Post subject:
Reply with quote

Hello,

One reason i use "loop constraints" is that at any given point in the execution, i am in control of the process. When a function is invoked, it will run to completion or fail with little opportunity in between.

Another is "scope creep" - the realization that there is more to the requirement than was identified originally (or is discovered later).

From within one loop, another loop might be performed which could modify the operation of the original loop. From within a function, nothing else can happen until the function completes - successful or otherwise.
Back to top
View user's profile Send private message
Lijo

New User


Joined: 24 Aug 2008
Posts: 41
Location: Cochin

PostPosted: Tue Dec 22, 2009 11:11 am    Post subject: Reply to: Spacing out the word & adjusting space bween r
Reply with quote

Vinu,

Yes. Problem is because of the spaces only. You need to decide up on the size of WS-ADDR-PART4. Especially size of "<number/alphabet till spaces>". You should find out how many bytes can this info occur. (I think this info is needed even if you use any other method to extract 'P.O. Box and <number/alphabet till spaces>'). Then allocate only that much storage and use replace option.
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
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Difference space showed for TS and it... autobox DB2 1 Thu Apr 14, 2016 1:07 pm
No new posts How to find Table-space and Index-spa... venksiv DB2 5 Wed Feb 03, 2016 6:16 pm
No new posts VTS and space BobGilbert All Other Mainframe Topics 2 Mon Jan 11, 2016 5:08 am
No new posts DFSORT - Space issue santosh_g DFSORT/ICETOOL 3 Fri Sep 04, 2015 7:44 am
No new posts Select "SECOND WORD" in tex... jackare SYNCSORT 3 Fri Aug 07, 2015 8:17 pm


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