Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Inspect tallying?
I was wondering if anyone could help me out here on what is the best
way to accomplsh this:

I have a customer-name stored in a 40 byte field    ie Joe Johnson
I need to move this to:
01 cust-rec.
03 cust-key-1.
05 cust-name.
07 cust-last-name           pic x(20).
07 cust-first-name          pic x(20).
In order to read it. Trying to figure out if/how would I use the
inspect statement to move the first name to cust-first-name and last
name to cust-last-name.


Report this thread to moderator Post Follow-up to this message
Old Post
jeff@sum-it.com
07-17-06 11:55 PM


Re: Inspect tallying?
On 17 Jul 2006 09:49:24 -0700, jeff@sum-it.com wrote:

>I was wondering if anyone could help me out here on what is the best
>way to accomplsh this:
>
>I have a customer-name stored in a 40 byte field    ie Joe Johnson
>I need to move this to:
>       01 cust-rec.
>           03 cust-key-1.
>               05 cust-name.
>                   07 cust-last-name           pic x(20).
>                   07 cust-first-name          pic x(20).
>In order to read it. Trying to figure out if/how would I use the
>inspect statement to move the first name to cust-first-name and last
>name to cust-last-name.

First, do you know what you want to do about people with two last
names, Jr. and other variations from the "standard"?

Report this thread to moderator Post Follow-up to this message
Old Post
Howard Brazee
07-17-06 11:55 PM


Re: Inspect tallying?
Howard Brazee wrote:
> On 17 Jul 2006 09:49:24 -0700, jeff@sum-it.com wrote:
> 
>
> First, do you know what you want to do about people with two last
> names, Jr. and other variations from the "standard"?

Not sure how to handle that as well. This is for a sales report.
Another part of the key is the cust no, but the system allows no
cust-no and enter a Cust-name in any format, most enter as Joe Johnson.
Should I use an inspect tally before initial space? Or a perform
varying loop?


Report this thread to moderator Post Follow-up to this message
Old Post
jeff@sum-it.com
07-17-06 11:55 PM


Re: Inspect tallying?
On 17 Jul 2006 10:17:04 -0700, jeff@sum-it.com wrote:
 
>
>Not sure how to handle that as well. This is for a sales report.
>Another part of the key is the cust no, but the system allows no
>cust-no and enter a Cust-name in any format, most enter as Joe Johnson.
>Should I use an inspect tally before initial space? Or a perform
>varying loop?

I used to use INSPECT for this kind of thing, I've pretty much
switched to using reference modification loops.

When I'm given an assignment like this, I have learned to expect that
there will need to be some further data manipulation to handle
exceptions.

Report this thread to moderator Post Follow-up to this message
Old Post
Howard Brazee
07-17-06 11:55 PM


Re: Inspect tallying?
Howard Brazee wrote:
> On 17 Jul 2006 10:17:04 -0700, jeff@sum-it.com wrote:
> 
>
> I used to use INSPECT for this kind of thing, I've pretty much
> switched to using reference modification loops.
>
> When I'm given an assignment like this, I have learned to expect that
> there will need to be some further data manipulation to handle
> exceptions.


2 seperate loops?  perform move first-name
perform move last-name


Report this thread to moderator Post Follow-up to this message
Old Post
jeff@sum-it.com
07-17-06 11:55 PM


Re: Inspect tallying?
On 17 Jul 2006 11:05:26 -0700, jeff@sum-it.com wrote:
 
>
>
>2 seperate loops?  perform move first-name
>                           perform move last-name


Here's an approach (without error checking):

PERFORM VARYING LAST-CHAR FROM 40 BY -1 UNTIL FULL-NAME (LAST-CHAR >
space)
END-PERFORM.

PERFORM VARYING FIRST-CHARACTER FROM LAST-CHAR by -1 UNTIL FULL-NAME
(FIRST-CHAR) = SPACE
END-PERFORM.

ADD 1 TO FIRST-CHAR.
MOVE  FULL-NAME (FIRST-CHAR:LAST-CHAR) TO CUST-LAST-NAME.

SUBTRACT 2 from FIRST-CHAR GIVING LAST-CHAR.
MOVE  FULL-NAME (1:LAST-CHAR) TO CUST-FIRST-NAME.

This fails for Ken Griffey jr., for Madonna, Maria Gomez y Jones.

Report this thread to moderator Post Follow-up to this message
Old Post
Howard Brazee
07-17-06 11:55 PM


Re: Inspect tallying?
Howard Brazee wrote:
> On 17 Jul 2006 11:05:26 -0700, jeff@sum-it.com wrote:
> 
>
>
> Here's an approach (without error checking):
>
> PERFORM VARYING LAST-CHAR FROM 40 BY -1 UNTIL FULL-NAME (LAST-CHAR >
> space)
> END-PERFORM.
>
> PERFORM VARYING FIRST-CHARACTER FROM LAST-CHAR by -1 UNTIL FULL-NAME
> (FIRST-CHAR) = SPACE
> END-PERFORM.
>
> ADD 1 TO FIRST-CHAR.
> MOVE  FULL-NAME (FIRST-CHAR:LAST-CHAR) TO CUST-LAST-NAME.
>
> SUBTRACT 2 from FIRST-CHAR GIVING LAST-CHAR.
> MOVE  FULL-NAME (1:LAST-CHAR) TO CUST-FIRST-NAME.
>
> This fails for Ken Griffey jr., for Madonna, Maria Gomez y Jones.

Thanks, I was going to move full-name to a char-array pic x occurs and
look for first space move to first-name. add 2 to i and do the same for
last name. I will try your way.


Report this thread to moderator Post Follow-up to this message
Old Post
jeff@sum-it.com
07-17-06 11:55 PM


Re: Inspect tallying?
Howard Brazee wrote:
> On 17 Jul 2006 11:05:26 -0700, jeff@sum-it.com wrote:
> 
>
>
> Here's an approach (without error checking):
>
> PERFORM VARYING LAST-CHAR FROM 40 BY -1 UNTIL FULL-NAME (LAST-CHAR >
> space)
> END-PERFORM.
>
> PERFORM VARYING FIRST-CHARACTER FROM LAST-CHAR by -1 UNTIL FULL-NAME
> (FIRST-CHAR) = SPACE
> END-PERFORM.
>
> ADD 1 TO FIRST-CHAR.
> MOVE  FULL-NAME (FIRST-CHAR:LAST-CHAR) TO CUST-LAST-NAME.
>
> SUBTRACT 2 from FIRST-CHAR GIVING LAST-CHAR.
> MOVE  FULL-NAME (1:LAST-CHAR) TO CUST-FIRST-NAME.
>
> This fails for Ken Griffey jr., for Madonna, Maria Gomez y Jones.



Getting these errors on the compile
\salescust.cbl, line 2208: ':' expected, '>' found
\salescust.cbl, line 2208: identifier expected, '>' found
\salescust.cbl, line 2208: Verb expected, '>' found
\salescust.cbl, line 2211: ':' expected, ')' found
\salescust.cbl, line 2211: identifier expected, ')' found
\salescust.cbl, line 2211: Verb expected, ')' found

2206    move-name-fields.
2207            perform varying last-char from 40 by -1 until
2208             ws-psc-cust-name(last-char > " ").

2210           perform varying first-char from last-char by -1 until
2211             ws-psc-cust-name(first-char) = " ".

2213           add 1 to first-char.
2214           move  ws-psc-cust-name(first-char:last-char) to
2215                        cust-last-name.
2216           subtract 2 from first-char giving last-char.
2217           move ws-psc-cust-name(1:last-char) to cust-first-name.


Report this thread to moderator Post Follow-up to this message
Old Post
jeff@sum-it.com
07-17-06 11:55 PM


Re: Inspect tallying?
On 17 Jul 2006 11:38:42 -0700, jeff@sum-it.com wrote:

>Getting these errors on the compile
>\salescust.cbl, line 2208: ':' expected, '>' found
>\salescust.cbl, line 2208: identifier expected, '>' found
>\salescust.cbl, line 2208: Verb expected, '>' found
>\salescust.cbl, line 2211: ':' expected, ')' found
>\salescust.cbl, line 2211: identifier expected, ')' found
>\salescust.cbl, line 2211: Verb expected, ')' found
>
>2206    move-name-fields.
>2207            perform varying last-char from 40 by -1 until
>2208             ws-psc-cust-name(last-char > " ").
>
>2210           perform varying first-char from last-char by -1 until
>2211             ws-psc-cust-name(first-char) = " ".
>
>2213           add 1 to first-char.
>2214           move  ws-psc-cust-name(first-char:last-char) to
>2215                        cust-last-name.
>2216           subtract 2 from first-char giving last-char.
>2217           move ws-psc-cust-name(1:last-char) to cust-first-name.

Sorry, wrote fast.   The format of the UNTIL is:
until (ws-pc-cust-name(last-char:1) > space).

Look up reference modification to see what it does.   I recommend
working backwards on the assumption that the last name is the
important one.

Report this thread to moderator Post Follow-up to this message
Old Post
Howard Brazee
07-17-06 11:55 PM


Re: Inspect tallying?
jeff@sum-it.com wrote:
> I was wondering if anyone could help me out here on what is the best
> way to accomplsh this:
>
> I have a customer-name stored in a 40 byte field    ie Joe Johnson
> I need to move this to:
>        01 cust-rec.
>            03 cust-key-1.
>                05 cust-name.
>                    07 cust-last-name           pic x(20).
>                    07 cust-first-name          pic x(20).
> In order to read it. Trying to figure out if/how would I use the
> inspect statement to move the first name to cust-first-name and last
> name to cust-last-name.
>
Move space to custname.
unstring customer-name delimited by all space into cust-first-name,
cust-last-name.

Tally counts things.

Of course, that only works if there are two valid names. It might be
preferable to unstring into first, middle and last, then move the middle
to last if it ends up blank.

Donald

Report this thread to moderator Post Follow-up to this message
Old Post
Donald Tees
07-17-06 11:55 PM


Sponsored Links




Last Thread Next Thread Next
Pages (2): [1] 2 »
Search this forum -> 
Post New Thread

Cobol archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 03:20 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.