MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Alphanumeric to comp-3

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
sant_1028
Beginner


Joined: 23 Dec 2004
Posts: 8
Topics: 4

PostPosted: Thu Jan 20, 2005 2:08 pm    Post subject: Alphanumeric to comp-3 Reply with quote

We have a alphanumeric field to be moved to comp-3

We are getting SOC7 error for the following

01 WS-A PIC X(15).
01 WS-N REDEFINES WS-A PIC +9(11).99.
01 WS-NUM PIC S9(11)V9(2) COMP-3.

MOVE '123333.22' TO WS-A.
MOVE WS-N TO WS-NUM.


Adv Thanks,
Sant
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Thu Jan 20, 2005 3:18 pm    Post subject: Reply with quote

sant_1028,

You need to remove the explicit decimal in your input field before moving. You cannot use numeric edited sending field.

try this

Code:

WORKING-STORAGE SECTION.                                     
01 WS-A         PIC X(15).                                   
01 WS-WHOLE     PIC X(11).                                   
01 WS-DEC       PIC X(02).                                   
01 WS-IN2       PIC 9(11)V9(2).                               
01 WS-TALLY     PIC S9(04) COMP VALUE ZERO.                   
01 WS-NUM       PIC S9(11)V9(2) COMP-3.                       
                                                             
PROCEDURE DIVISION.                                           
                                                             
    MOVE '123333.22' TO WS-A.                                 
    UNSTRING WS-A   DELIMITED BY '.' INTO WS-WHOLE,           
    COUNT IN WS-TALLY WS-DEC                                 
                                                             
    MOVE ZERO           TO WS-IN2 (1: 13)                     
    MOVE WS-WHOLE(1: WS-TALLY )                               
                        TO WS-IN2 (13 - WS-TALLY : WS-TALLY) 
    MOVE WS-DEC            TO WS-IN2 (12 : 2)                 
    MOVE WS-IN2            TO WS-NUM                         


Hope this helps...

Cheers

kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sant_1028
Beginner


Joined: 23 Dec 2004
Posts: 8
Topics: 4

PostPosted: Thu Jan 20, 2005 4:41 pm    Post subject: Reply with quote

Thanks for your time. We tried same solution in this way.

01 WS-ALPHA JUSTIFIED RIGHT PIC X(14).

01 WS-ALPHA-SPLIT REDEFINES WS-ALPHA.

05 WS-ALPHA-SPLIT1-11 PIC X(11).
05 WS-ALPHA-SPLIT-ELIM PIC X(01).
05 WS-ALPHA-SPLIT13-14 PIC X(02).

01 WS-ALPHA-USE.

05 WS-ALPHA-USE-1 PIC X(11).
05 WS-ALPHA-USE-2 PIC X(02).

01 WS-NUM REDEFINES WS-ALPHA-USE PIC S9(11)V99.

01 WS-NUM-COMP3 PIC S9(11)V99 COMP-3.

MOVE STORED-PROC-VALUE TO WS-ALPHA.

MOVE WS-ALPHA-SPLIT1-11 TO WS-ALPHA-USE-1.
MOVE WS-ALPHA-SPLIT13-14 TO WS-ALPHA-USE-2.


MOVE WS-NUM TO WS-NUM-COMP.
Back to top
View user's profile Send private message
slade
Intermediate


Joined: 07 Feb 2003
Posts: 266
Topics: 1
Location: Edison, NJ USA

PostPosted: Sat Jan 22, 2005 8:05 pm    Post subject: Reply with quote

Hi Sant,

Seems like you could have made things a lot easier for yourself by doing something like this:
Code:

05  alpha-j-right    pic x(14) value spaces.
05  edit-fld redefines
      alpha-j-right   pic z(11).99.
05  num-fld          pic 9(13)v99.
05  pd-fld             pic s(11)9v99 comp-3.

move stored-p-fld to num-fld
move num-fld to pd-fld
move edit-fld to num-fld

You may be able to eliminate the move to the num-fld, but I'm not sure. You'd have to test it.
_________________
Regards, Jack.

"A problem well stated is a problem half solved" -- Charles F. Kettering
Back to top
View user's profile Send private message
Mervyn
Moderator


Joined: 02 Dec 2002
Posts: 415
Topics: 6
Location: Hove, England

PostPosted: Sun Jan 23, 2005 6:00 pm    Post subject: Reply with quote

You might also want to have a look at the NUMVAL function
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IGY3LR10/7.1.32?DT=20020920180651
_________________
The day you stop learning the dinosaur becomes extinct
Back to top
View user's profile Send private message
slade
Intermediate


Joined: 07 Feb 2003
Posts: 266
Topics: 1
Location: Edison, NJ USA

PostPosted: Sun Jan 30, 2005 8:39 pm    Post subject: Reply with quote

That's right Merv! Even easier. Add WS-NUM-DISP PIC S9(11)V99 to the orig WS.
Then:
Code:

COMPUTE WS-NUM-DISP  = FUNCTION NUMVAL(WS-A)
MOVE    WS-NUM-DISP TO WS-NUM 

_________________
Regards, Jack.

"A problem well stated is a problem half solved" -- Charles F. Kettering
Back to top
View user's profile Send private message
Mervyn
Moderator


Joined: 02 Dec 2002
Posts: 415
Topics: 6
Location: Hove, England

PostPosted: Mon Jan 31, 2005 10:04 am    Post subject: Reply with quote

Hi, Jack. Been away for a week?

I was thinking more along the lines of

Code:

COMPUTE WS-NUM = FUNCTION NUMVAL(WS-A)


or even

Code:

MOVE FUNCTION NUMVAL(WS-A) TO WS-NUM

_________________
The day you stop learning the dinosaur becomes extinct
Back to top
View user's profile Send private message
sant_1028
Beginner


Joined: 23 Dec 2004
Posts: 8
Topics: 4

PostPosted: Tue Feb 01, 2005 2:25 pm    Post subject: Reply with quote

Hi All,
Thanks everyone. We used the following code, but we are missing -ve sign in the database after storing.
Somebody help us. But other replies are not working for us. Example NUMVAL.

WORKING-STORAGE SECTION.
01 WS-A PIC X(15).
01 WS-WHOLE PIC X(11).
01 WS-DEC PIC X(02).
01 WS-IN2 PIC 9(11)V9(2).
01 WS-TALLY PIC S9(04) COMP VALUE ZERO.
01 WS-NUM PIC S9(11)V9(2) COMP-3.

PROCEDURE DIVISION.

MOVE '123333.22' TO WS-A.
UNSTRING WS-A DELIMITED BY '.' INTO WS-WHOLE,
COUNT IN WS-TALLY WS-DEC

MOVE ZERO TO WS-IN2 (1: 13)
MOVE WS-WHOLE(1: WS-TALLY )
TO WS-IN2 (13 - WS-TALLY : WS-TALLY)
MOVE WS-DEC TO WS-IN2 (12 : 2)
MOVE WS-IN2 TO WS-NUM
Back to top
View user's profile Send private message
slade
Intermediate


Joined: 07 Feb 2003
Posts: 266
Topics: 1
Location: Edison, NJ USA

PostPosted: Tue Feb 01, 2005 10:05 pm    Post subject: Reply with quote

Hi Sant,

If your value can contain a minus sign, e.g. -12.34, you might try moving the WS-IN2 field to a PIC -(11).99 numeric edited field. Then move that to WS-NUM.

With this approach you should not have to strip the decimal point "manually".
_________________
Regards, Jack.

"A problem well stated is a problem half solved" -- Charles F. Kettering
Back to top
View user's profile Send private message
slade
Intermediate


Joined: 07 Feb 2003
Posts: 266
Topics: 1
Location: Edison, NJ USA

PostPosted: Tue Feb 01, 2005 10:26 pm    Post subject: Reply with quote

Sorry, I should have said:

.... you might try redefininging the WS-IN2 field to a PIC -(10)V99 numeric edited field.

With this approach you should not have to strip the decimal point "manually". You then redefine as PIC -(10).99.
_________________
Regards, Jack.

"A problem well stated is a problem half solved" -- Charles F. Kettering
Back to top
View user's profile Send private message
sant_1028
Beginner


Joined: 23 Dec 2004
Posts: 8
Topics: 4

PostPosted: Wed Feb 02, 2005 2:03 pm    Post subject: Reply with quote

Thanks everyone.
Still we didn't figureout how to move -ve sign values. We tried with the given option declaring -9(10)v99. But getting abending errors.
Could you please through us some more details.

Thanks,
Sant
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Wed Feb 02, 2005 2:51 pm    Post subject: Reply with quote

Sant_1028,

Quote:

Still we didn't figureout how to move -ve sign values. We tried with the given option declaring -9(10)v99. But getting abending errors. Could you please through us some more details.


Add the following code to the example shown in post 2 from the top which will take of the negative numbers. I am assuming that a negative number is denoted with '-' symbol in your input .

ex: MOVE '-12345.67' TO WS-A.

Code:

01 WS-SIGN      PIC S9(04) COMP VALUE ZERO.
INSPECT WS-A TALLYING WS-SIGN FOR ALL '-'   
IF WS-SIGN > 0                             
   COMPUTE WS-NUM = WS-NUM * -1             
END-IF                                     


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sant_1028
Beginner


Joined: 23 Dec 2004
Posts: 8
Topics: 4

PostPosted: Wed Feb 02, 2005 3:58 pm    Post subject: Reply with quote

Hi Friends,
Its working fine. I could able to see -ve amounts in the data base.

Thanks,
Sant
Back to top
View user's profile Send private message
slade
Intermediate


Joined: 07 Feb 2003
Posts: 266
Topics: 1
Location: Edison, NJ USA

PostPosted: Thu Feb 03, 2005 8:42 pm    Post subject: Reply with quote

Looks like I missed the boat. Very Happy

For what it's worth, I tested the code and it works OK.

I used JUST RIGHT to get the amt into the low order bytes of JS-TEST-R. You could use INSPECT with the REVERSED function to count the trailing spaces and use that to calculate the string's length, then ref/mod MOVE it to JS-TEST-R.

There are other ways, of course.


Code:

05  JS-TEST-XN              PIC  X(7) VALUE '-123.45'.
05  JS-TEST-X               PIC  X(6) VALUE '123.45'. 
05  JS-TEST-R JUST RIGHT    PIC  X(14) VALUE SPACES.   
05  JS-TEST-ED REDEFINES JS-TEST-R                     
                            PIC  -(11).99.             
05  JS-TEST-C3              PIC S9(11)V99 COMP-3.     

MOVE JS-TEST-XN TO JS-TEST-R                           
MOVE JS-TEST-ED TO JS-TEST-C3                         
DISPLAY 'JS-TEST-C3 NEG SIGN >' JS-TEST-C3 '<'         
MOVE JS-TEST-X  TO JS-TEST-R                           
MOVE JS-TEST-ED TO JS-TEST-C3                         
DISPLAY ' JS-TEST-C3 NO SIGN >' JS-TEST-C3 '<'         

_________________
Regards, Jack.

"A problem well stated is a problem half solved" -- Charles F. Kettering
Back to top
View user's profile Send private message
slade
Intermediate


Joined: 07 Feb 2003
Posts: 266
Topics: 1
Location: Edison, NJ USA

PostPosted: Fri Feb 04, 2005 8:25 pm    Post subject: Reply with quote

OK, one more once. Here's my ent-to-end version.
Pgraph 1000-convert-rtn is the guts of it.
Code:

05  JS-TAL-FLD              PIC S9(04) COMP. 
05  JS-STR-LEN              PIC S9(04) COMP.     
05  JS-TEST-FLD             PIC  X(14).   
05  JS-JUST-R JUST RIGHT    PIC  X(14) VALUE SPACES.       
05  JS-JUST-ED REDEFINES JS-JUST-R                         
                            PIC  -(11).99.                 
05  JS-TEST-C3              PIC S9(07)V99 COMP-3.

         
    MOVE '-123.45' TO JS-TEST-FLD                   
    PERFORM 1000-CONVERT-RTN                         
    DISPLAY 'JS-TEST-C3 NEG SIGN >' JS-TEST-C3 '<'   
    MOVE ' 123.45'  TO JS-TEST-FLD                   
    PERFORM 1000-CONVERT-RTN                         
    DISPLAY 'JS-TEST-C3  NO SIGN >' JS-TEST-C3 '<'   
    STOP RUN                                         
    .                                           
         
1000-CONVERT-RTN.                                       
    MOVE     ZERO TO JS-TAL-FLD                         
    INSPECT  FUNCTION REVERSE(JS-TEST-FLD)             
    TALLYING JS-TAL-FLD FOR LEADING SPACES             
    COMPUTE  JS-STR-LEN                                 
          =  LENGTH OF JS-TEST-FLD - JS-TAL-FLD         
    MOVE     JS-TEST-FLD(1:JS-STR-LEN) TO JS-JUST-R     
    MOVE     JS-JUST-ED TO JS-TEST-C3                   
    .

Process output:

JS-TEST-C3 NEG SIGN >00001234N<
JS-TEST-C3 NO SIGN >000012345<
_________________
Regards, Jack.

"A problem well stated is a problem half solved" -- Charles F. Kettering
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group