IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Move PARM value into a working storage variable


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
pratiksha
Warnings : 1

New User


Joined: 10 Feb 2006
Posts: 10
Location: Bangalore

PostPosted: Tue Jul 05, 2011 1:00 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Jul 05, 2011 1:19 pm
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Jul 05, 2011 1:55 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Tue Jul 05, 2011 2:23 pm
Reply with quote

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
icon_sad.gif
Back to top
View user's profile Send private message
kumar1234

New User


Joined: 06 Nov 2007
Posts: 84
Location: bangalore

PostPosted: Tue Jul 05, 2011 2:42 pm
Reply with quote

Remove value zeros for the WS variable.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Jul 05, 2011 2:45 pm
Reply with quote

kumar1234 wrote:
Remove value zeros for the WS variable.


kumar1234,

you got me! could you please explain how this would help?
Back to top
View user's profile Send private message
kumar1234

New User


Joined: 06 Nov 2007
Posts: 84
Location: bangalore

PostPosted: Tue Jul 05, 2011 2:52 pm
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Jul 05, 2011 3:04 pm
Reply with quote

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
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Tue Jul 05, 2011 3:06 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Jul 05, 2011 3:23 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue Jul 05, 2011 3:58 pm
Reply with quote

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
View user's profile Send private message
pratiksha
Warnings : 1

New User


Joined: 10 Feb 2006
Posts: 10
Location: Bangalore

PostPosted: Tue Jul 05, 2011 4:36 pm
Reply with quote

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 icon_smile.gif
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Jul 06, 2011 4:48 am
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts CLIST - Virtual storage allocation error CLIST & REXX 5
No new posts JCL EXEC PARM data in C Java & MQSeries 2
No new posts Need to specify PARM='POSIX(ON) Java & MQSeries 4
No new posts PD not working for unsigned packed JO... DFSORT/ICETOOL 5
Search our Forums:

Back to Top