Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Move Comp-3 Field

Status
Not open for further replies.

hayesb2

Programmer
Jul 22, 2002
19
US
I am reading in a field on an input file as a PIC S9(3) COMP-3 field and simply want to move that to another PIC S9(3) COMP-3 field. However I am having problems trying to accomplish this...Can anyone help?
 
Hi,

What kind of problems are you having? Error message?
Also, could you post some of the troublesome code?
 
I am only trying to move an input packed field to an output packed field. However cannot move the entire group because I am adding fields in the output.
WORKING STORAGE.

10 LVL-OUTPUT.
15 INFO-OUTPUT PIC XXX.
15 KEY-SEQ-OUTPUT PIC S9(3) COMP-3.

10 LVL-INPUT.
15 KEY-SEQ-INPUT PIC S9(3) COMP-3.

PROCEDURE DIVISION.

MOVE KEY-SEQ-INPUT TO KEY-SEQ-OUTPUT.

This will not work, please help
 
Tell us what command is not working exactly. If you do not like my post feel free to point out your opinion or my errors.
 
I am sorry for being a pest, but I don't understand what the problem is.

Let's say KEY-SEQ-INPUT = 123. After the MOVE statement, what is in KEY-SEQ-OUTPUT?

Or, are you getting an error on the MOVE statement itself?
 
Hayesb2,
I can't see anything wrong with the code that you have posted, it seems to work OK to me. I would therefore suggest you discount this from your thinking and look elsewhere. Have a look instead at the input file and see if it is really Comp-3 which if you were looking at the value +100 would look something like:
010
00C
in hex mode. Also check that it's in the place in the file that you think it is.

Let us know how you get on, and as Dimandja says, any error messages will be helpful.
hth
Marc
 
Hi B,

From what you've shown us, it should work. One possibility, and IMHO, the most likely:

The input data doesn't contain what you think.

On the other hand, I don't think you can start your Working Storage at level 10. That may be your problem.

You don't tell use How "it won't work", so it's difficult to pinpoint the problem. You also don't tell us what your environment is: Mainframe, PC, Compiler provider, or std, etc. So I can't advise you about how to look at the data format, etc.

HTH, Jack.
 
Hello hayesb2,

I just reread your posts and a couple things seem to stand out:

When you say "I am only trying to move an input packed field to an output packed field. However cannot move the entire group because I am adding fields in the output.", are you saying that you want the group LVL-INPUT moved to LVL-OUTPUT, but you also want to insert/preserve INFO-OUTPUT where indicated?

10 LVL-OUTPUT.
15 INFO-OUTPUT PIC XXX.
15 KEY-SEQ-OUTPUT PIC S9(3) COMP-3.
10 LVL-INPUT.
15 KEY-SEQ-INPUT PIC S9(3) COMP-3.
PROCEDURE DIVISION.
MOVE KEY-SEQ-INPUT TO KEY-SEQ-OUTPUT.

If that is your intention, then I am assuming that you are new to COBOL and programming in general (I am sorry if am off base here - wouldn't be the first time), and this would be your solution:

If you want group LVL-INPUT moved to group LVL-OUTPUT, then you should ascertain that the structures of the two groups are cohesive (these two here are not the same): for example,

10 LVL-INPUT.
15 KEY-SEQ-INPUT PIC S9(3) COMP-3.

is not equivalent to:

10 LVL-OUTPUT.
15 INFO-OUTPUT PIC XXX.
15 KEY-SEQ-OUTPUT PIC S9(3) COMP-3.

If you moved LVL-INPUT into LVL-OUTPUT, the content of KEY-SEQ-INPUT would end up in INFO-OUTPUT, and who knows what KEY-SEQ-OUTPUT would receive. If that is not what you want, do not use a group move. Do exactly as you say: move KEY-SEQ-INPUT to KEY-SEQ-OUTPUT and you are fine.

That said, I still feel unfullfilled. [neutral]

Dimandja



 
Your example should work provided the level 10's are snippets of code that are defined under a level 01.

What platform (i.e. Mainframe or PC) are you running. If PC then what COBOL compiler are you running. I did have problems with the move of numeric fields on some early, older PC Compilers but most of the problems have been resolved with current technologies.

Try the following and let me know what happens.

01 LVL-OUTPUT.
05 INFO-OUTPUT PIC XXX.
05 KEY-SEQ-OUTPUT PIC S9(3) COMP-3.

01 LVL-INPUT.
05 KEY-SEQ-INPUT PIC S9(3) COMP-3.

...

ADD KEY-SEQ-INPUT TO ZERO GIVING KEY-SEQ-OUTPUT

Notice I have changed your level 10 and 15 to level 01 and 05.


Saginaw
helpdesk@simotime.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top