View previous topic :: View next topic
|
Author |
Message |
pratiksha Warnings : 1 New User
Joined: 10 Feb 2006 Posts: 10 Location: Bangalore
|
|
|
|
Hi,
The program is used is as below,
Code: |
WORKING-STORAGE SECTION.
01 WS-SUM-TOTAL PIC 9(5) VALUE ZEROS.
01 WS-TEMP-VAR PIC 9(5) .
01 WS-ARMSTRNG-NUM PIC 9(5) VALUE ZEROS.
01 WS-ARMTEMP-NUM PIC 9(5).
LINKAGE SECTION.
01 LS-PARM-LINK.
05 LS-PARM-LENGTH PIC S9(04) COMP.
05 LS-ARMSTRNG-NUM PIC 9(5).
PROCEDURE DIVISION USING LS-PARM-LINK.
DISPLAY 'BEFORE MOVE WS-ARMSTRNG-NUM:'WS-ARMSTRNG-NUM.
DISPLAY 'YOU HAVE ENTERED:'LS-ARMSTRNG-NUM.
MOVE LS-ARMSTRNG-NUM TO WS-ARMSTRNG-NUM.
DISPLAY 'AFTER MOVE WS-ARMSTRNG-NUM:'WS-ARMSTRNG-NUM. |
The JCl used is
Code: |
//STEP1 EXEC PGM=ABCD001,PARM=153
//SYSOUT DD SYSOUT=*
//SYSIN DD DUMMY
//SYSUDUMP DD SYSOUT=* |
In the Sysout when checked , I see as below
Code: |
BEFORE MOVE WS-ARMSTRNG-NUM:00000
YOU HAVE ENTERED:153
AFTER MOVE WS-ARMSTRNG-NUM:153 0 |
Because of this when i compare the value enterd later in the process it does not match.
Thanks
Pratiksha |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
There are examples of using parms in this forum. Did you look at those?
Exactly what do you want to do? Do you want different length numbers, or only five digits? Makes a big difference. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
This problem could have been avoided had you, pratiksha,
referenced LS-PARM-LENGTH before the MOVE.
Suggest you do something along the lines of the following:
Code: |
01 LS-PARM-LINK.
05 LS-PARM-LENGTH PIC S9(04) COMP.
05 LS-INPUT-AREA.
10 LS-INPUT-NUM PIC X(05).
10 LS-INPUT-WORK1
REDEFINES
LS-INPUT-NUM.
15 LS-ARMSTRNG-NUM-4-1 PIC 9(1).
15 PIC X(4).
10 LS-INPUT-WORK2
REDEFINES
LS-INPUT-NUM.
15 LS-ARMSTRNG-NUM-4-2 PIC 9(2).
15 PIC X(3).
10 LS-INPUT-WORK3
REDEFINES
LS-INPUT-NUM.
15 LS-ARMSTRNG-NUM-4-3 PIC 9(3).
15 PIC X(2).
10 LS-INPUT-WORK4
REDEFINES
LS-INPUT-NUM.
15 LS-ARMSTRNG-NUM-4-4 PIC 9(4).
15 PIC X(1).
10 LS-INPUT-WORK5
REDEFINES
LS-INPUT-NUM.
15 LS-ARMSTRNG-NUM-4-5 PIC 9(5).
DISPLAY 'INPUT PARM/LENGTH:' LS-INPUT-NUM/LS-PARM-LENGTH
EVALUATE LS-PARM-LENGTH
WHEN 0
MOVE ZERO TO WS-ARMSTRNG-NUM
WHEN 1
MOVE LS-ARMSSTRNG-NUM-4-1 TO WS-ARMSTRNG-NUM
WHEN 2
MOVE LS-ARMSSTRNG-NUM-4-2 TO WS-ARMSTRNG-NUM
WHEN 3
MOVE LS-ARMSSTRNG-NUM-4-3 TO WS-ARMSTRNG-NUM
WHEN 4
MOVE LS-ARMSSTRNG-NUM-4-4 TO WS-ARMSTRNG-NUM
WHEN 5
MOVE LS-ARMSSTRNG-NUM-4-5 TO WS-ARMSTRNG-NUM
WHEN OTHER
MOVE ZERO TO WS-ARMSTRNG-NUM
END-EVALUATE
|
YES, it could be done with reference modification,
but I don't think with your level of expertise that you should employ that method. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10888 Location: italy
|
|
|
|
my 2 cents...
for a beginner the less troublesome way is to force a fixed length parameter
Code: |
//stepname EXEC PGM=programname,PARM='12345' |
and inside the program check that the parm length is 5, and proceed from there
usually once, at the time of elfs and faeries,
most organization used to provide in house developed routines to do the sanity checks on the parameters passed thru jck,
in order to save the beginners the hassle of parsing!
but now it looks that all the basic good sense and skills have gone down the sink
|
|
Back to top |
|
|
kumar1234
New User
Joined: 06 Nov 2007 Posts: 84 Location: bangalore
|
|
|
|
Remove value zeros for the WS variable. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
kumar1234 wrote: |
Remove value zeros for the WS variable. |
kumar1234,
you got me! could you please explain how this would help? |
|
Back to top |
|
|
kumar1234
New User
Joined: 06 Nov 2007 Posts: 84 Location: bangalore
|
|
|
|
Remove values zeros from the variable 01 WS-ARMSTRNG-NUM PIC 9(5) VALUE ZEROS. And then you can move the numeric what you want. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
kumar1234 wrote: |
Remove values zeros from the variable 01 WS-ARMSTRNG-NUM PIC 9(5) VALUE ZEROS. And then you can move the numeric what you want. |
so, what would the results be?
(have you tested this by the way?) |
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
a possibility is : make LS-PARMS pic X() & use function NUMVAL
Code: |
01 LS-PARM-LINK.
05 LS-PARM-LENGTH PIC S9(04) COMP.
05 LS-ARMSTRNG-NUM PIC X(5).
PROCEDURE DIVISION USING LS-PARM-LINK.
compute ws-ARMSTRNG-NUM = function numval(LS-ARMSTRNG-NUM (1:LS-PARM-LENGTH)) |
|
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
kumar1234 wrote: |
Remove values zeros from the variable 01 WS-ARMSTRNG-NUM PIC 9(5) VALUE ZEROS. And then you can move the numeric what you want. |
This is plain, flat, wrong.
You will get the identical result to the original problem.
Changing the value of a field that is later the target of a later move will have no affect whatsoever on the move.
You could put bananas in WS-ARMSTRNG-NUM, you'd still gate the identical result when the MOVE comes around.
Try it, please, Kumar1234, let us know the result. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
The result of the MOVE is easily explained: you move 3 bytes of number with probably LOW-VALUES following those 3 bytes into a 5-byte numeric variable -- since you defined LS-ARMSTRONG-NUM as 5 bytes, COBOL will always use 5 bytes for the MOVE. The first three bytes moved fine. The fourth byte is probably a non-display character; since the original post does not have the DISPLAY in hex we don't know for sure what it is, although X'00' is most likely. The fifth byte, again most likely X'00', was moved and then COBOL did its usual clean up on the variable to make sure there is no sign and made the fifth byte X'F0'. Hence the actual value in WS-ARMSTRONG-NUM is 153?0 where the ? represents the unknown value.
Others have already presented several possible solutions for this issue. |
|
Back to top |
|
|
pratiksha Warnings : 1 New User
Joined: 10 Feb 2006 Posts: 10 Location: Bangalore
|
|
|
|
Thank you Dick..
I was also keen on knowing why it moved 153?0 . I got the answer here.Thanks to TANSTAAFL.
I implemented with the redefines mentioned above and also tried refernce modification.This is what i get in the sysout.
BEFORE MOVE WS-ARMSTRNG-NUM:00000
YOU HAVE ENTERED:0153
LS PARM LENGTH :0004
AFTER MOVE WS-ARMSTRNG-NUM:00153
Thank you all |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Pratiksha,
As with any data which is from outside your system, it would be good to validate it. It doesn't take much to typo a letter instead of a number, and if that happens in the right-hand byte, your program will "work", but likely with the wrong value.
So, I'd suggest you test the parm (the right amount of it) inside each of the WHENs (except the WHEN OTHER).
You can't test the target of the move, by the way, as you have seen from your first shot at this.
Code: |
DISPLAY "SOME TEXT" ">" W-FIELD-TO-DISPLAY "<" ">" W-ANOTHER-FIELD "<" |
Doing displays like this I found extremely useful. You can always tell what is in the field, and what is just "paper" on the screen. |
|
Back to top |
|
|
|