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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Few Questions...

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I'm doing some homework for class and I'm stumped by these questions...

What can't be done with edited picture clauses that can be done with strictly numericp ics, and is the reason they can't be used for math?

Why do progarmmers check items with picture clauses of X to see if they contain digits?

Under what conditions may result fields in math statements haev edited picture clauses?
 
Hi Ichi,

I won't repeat the ques, and I won't answer them directly but I will comment on them in the order asked. Hopefully the comments will lead you to the answer.

1) What do fields w/edited pics contain?

2) What can a pic x field contain? What if the field was supposed to contain numbers that I was to use in a computation? Should I take their word for it? What would happen if I moved an "A" to a pic 9 field?

3) What's the difference between thes 3 stmts; what would result from the execution of each?

compute ws-num-fld = ws-num-fld + 1
compute ws-ed1-fld = ws-num-fld + 1
compute ws-ed1-fld = ws-ed1-fld + 1

The fields and their contents before the comp:

05 ws-num-fld pic 999V99 conentent - 00500
05 ws-ed1-fld pic $$9.99 conentent - b$5.00

The general question I can ask for all your questions is:

How would YOU add a 1 and a 1;a period and a 1; a $sign and a 1?

HTH, Jack.

 
I was a fairly good student in COBOL and my instructor asked me to work in the Lab at night to help the evening instructor. We had just set up the AS400 the year before, and I kind of learned how to use it from the beginning.

The most common error I noticed other than typing errors was a DECIMAL DATA ERROR. This is a difficult problem, because the program may compile and then it will crash when it sees the bad data. The compiler won't always find all of the programmers mistakes.

This is AS400 for "You can not do mathematics with non-numeric items."

If you have a field with the picture clause "PIC Z9" or "$$9.99", it has characters in it that are not numbers. You have to add a number to a number!

I recommend that you make a test COBOL program and try to do what the questions are asking. This will give you some of the answers you want to know.

One other main problem is that the programmer uses a numeric item before data is moved to it. There is always something in a memory location. When you make a variable you get whatever is there to begin with. Some compilers may be initializing numeric variables to 0 and alpanumeric variables to spaces, but you can not extect this to occur. It is always safe to know what is in a variable by giving it an initial value or moving a value to it to initialize it.

You can move a non-numeric value to a numeric field.

Try this Idea

01 TOTAL-FIELDS.
05 FINAL-TOTAL-9 pic 999.
05 FINAL-TOTAL-X pic 999.

FINAL-TOTAL-ROUTINE.
MOVE 976 TO FINAL-TOTAL-9.
MOVE ABC TO TOTAL-FIELDS. (CONSIDERED A GROUP MOVE)
ADD 1 TO FINAL-TOTAL-9.

Will it compile?
Will it Run?

FINAL-TOTAL-ROUTINE.
MOVE 783 TO FINAL-TOTAL-X.
MOVE ABC TO TOTAL-FIELDS. (CONSIDERED A GROUP MOVE)
IF FINAL-TOTAL-9 IS NUMERIC
ADD 1 TO FINAL-TOTAL-9.

Will it compile?
Will it Run?

Why?
Why not?

The best way to learn is to program the questions and make the compiler give you the results.

My JAVA instructor always asked all kinds of wild questions, and we always compiled everything as a test. Java is a lot more complicated than COBOL.


If you do not like my post feel free to point out your opinion or my errors.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top