Please help with syntax



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Please help with syntax

Postby minhthy76 » Tue Nov 22, 2011 4:49 am

I'm writing a quick code to examine the address line so that if it starts with C/O or CO, I will move those info into Attention line, The address line should starts with any characters like PO, P.O. or with numeric.

So, I have this following suedo code:

Address line begins with C/O or CO
Search for PO, P.O, or P.O.
----Set subscripts to 1
----Do unitl subscripts is 30 - :x where x = 3, 4,5
----if address (sub:3) = 'PO ' success
----if address (sub:4) = 'P O ' or 'P.O.' success
----if address (sub:5) = 'P.O. ' success
If not found, search for first numeric digit
----if address (sub:1) numeric
Move Address (1:sub - 1) to Attention
Move Address (sub:30) to Address line.

Please help me translate these into COBOL, I'm learning about index and subcribe....Thank you.
minhthy76
 
Posts: 4
Joined: Tue Nov 22, 2011 4:41 am
Has thanked: 0 time
Been thanked: 0 time

Re: Please help with syntax

Postby BillyBoyo » Tue Nov 22, 2011 5:56 am

I'm a little unclear about what you mean.

Do you have something like:

C/O SOME TEXT P.O. BOX 1731


and you want to remove the C/O SOME TEXT and leave the rest in the address?

If not, can you give some examples of what you start with and how you'd like to see it afterwards?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Please help with syntax

Postby minhthy76 » Tue Nov 22, 2011 6:01 am

Yes, my input can be C/O SOME TEXT PO Box 123
or C/O SOME TEXT 123 Y Street

and I want to take the part of C/O SOME TEXT to move it to Attention line and keep PO Box 123 or 123 Y Street on Street Line.
minhthy76
 
Posts: 4
Joined: Tue Nov 22, 2011 4:41 am
Has thanked: 0 time
Been thanked: 0 time

Re: Please help with syntax

Postby Ronald Burr » Tue Nov 22, 2011 8:16 pm

What if your input was, e.g.,

C/O MS. POLLY POINDEXTER PO BOX 123?
Ronald Burr
 
Posts: 7
Joined: Wed Mar 23, 2011 8:18 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Please help with syntax

Postby Robert Sample » Tue Nov 22, 2011 8:40 pm

Having done considerable work with U.S. addresses over the past couple of years, I think you've got -- maybe -- half a specification there. The addresses I deal with are entered by the recipients themselves ( no third-party entry), and I've seen things like
po box
p o box
p  o  box
P o Box
POBOX
P  O  Box
POB
Box
and many other variations. Unless you are sure that your addresses have been standardized already, preferably through a CASS-certified program, you have a real character matching nightmare on your hands.
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Please help with syntax

Postby BillyBoyo » Tue Nov 22, 2011 9:32 pm

As Robert has pointed out, a lot will be to do with the quality of the addresses. You already have CO and C/O. You can probably add to those, in the same way as Robert has shown for the PO.

Your starting point has to be analysing the data. The wildest mistakes you may be able to get corrected, but it will leave you with a number of "valid" combinations.

You might also find C/O on line 1 of the address, or line 2 (in my experience).

I think you first need to see what you have with your data. Your pseudo-code won't change much, just the values being searched for. Implementing the pseudo-code in Cobol is not too tricky.

Now you'll want to know how to analyse the data?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Please help with syntax

Postby minhthy76 » Tue Nov 22, 2011 10:32 pm

Thanks all for input...my data is little stable/standardized since it went thru normalization process before it gets to me.

What I have trouble is translate/implement the above pseudo-code into COBOL, I'm not success with it :-( especially the perform until statement.
minhthy76
 
Posts: 4
Joined: Tue Nov 22, 2011 4:41 am
Has thanked: 0 time
Been thanked: 0 time

Re: Please help with syntax

Postby BillyBoyo » Tue Nov 22, 2011 10:46 pm

minhthy76 wrote:I'm writing a quick code to examine the address line so that if it starts with C/O or CO, I will move those info into Attention line, The address line should starts with any characters like PO, P.O. or with numeric.

So, I have this following suedo code:

Address line begins with C/O or CO
Search for PO, P.O, or P.O.
----Set subscripts to 1
----Do unitl subscripts is 30 - :x where x = 3, 4,5
----if address (sub:3) = 'PO ' success
----if address (sub:4) = 'P O ' or 'P.O.' success
----if address (sub:5) = 'P.O. ' success
If not found, search for first numeric digit
----if address (sub:1) numeric
Move Address (1:sub - 1) to Attention
Move Address (sub:30) to Address line.

Please help me translate these into COBOL, I'm learning about index and subcribe....Thank you.


OK then. If you look in the manuals you'll find PERFORM with VARYING. Combined with TEST BEFORE (default if not specified) and TEST AFTER you can have a DO UNTIL or a DO WHILE.

Also look up "REFERENCE MODIFICATION". You may already know this, or it may be coincidence that your code above is pretty close to that usage.

You have a little note to watch out for the different lenths of comparisons, so you have to remember to code for that.

Your VARYING can be an index or a subscript. Your site standards may dictate which you choose. Subscripts are considered more straightforward, indexes are not a big problem so you could tackle it that way as well.

You need one performing loop (for me a paragraph or section is preferable, but you can do it "inline") which works for the length of the line. "Protect" your tests by only doing them if your have not already run out of space (line-current-position + test length of data <= length of line).

Your pseudo-code is quite close to how you can do it in Cobol. Give it a bash, and come back if you get stuck. Let us know how it goes anyway.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Please help with syntax

Postby minhthy76 » Tue Nov 22, 2011 11:30 pm

Thanks, I'm working on it right now.
minhthy76
 
Posts: 4
Joined: Tue Nov 22, 2011 4:41 am
Has thanked: 0 time
Been thanked: 0 time

Re: Please help with syntax

Postby dick scherrer » Wed Nov 23, 2011 12:08 pm

Good luck - someone is most often "here" 8-)

d
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Next

Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post