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

Move trialing sign to leading sign?

Status
Not open for further replies.

wolves

Programmer
Jan 26, 2001
130
0
0
US
Easy for most I assume, but not for me.

Want to move this : 12456.56-

to this:

-12456.56.


Tried moving pic s9(5)v99 to pic 999,999.99


Thanks in advance.
 
MOVE with a numeric functionas the sending field is an extension (if supported) to the '89 Standard for Intrinsic Functions (which is NOT supported on S/390 - the original environment). It is a part of the 2002 Standard.

Bill Klein
 
Hi Wolves, The most important thing you can do to get a solution to your problem is to determine how the I/P field was defined when it was created.

Take a look at the creating pgm's O/P file definition annd show it to us here. You may also want to peruse the file and determine what variations the data has.

For example, is the field variable in length; does it have leading spaces; does the field always have 2 decimal places or does it vary; does it contain only a leading minus sign for neg #s; does it contain a leading space for pos #s or nothing at all?

In short does the format of the data vary? If so, how?


Regards, Jack.

"A problem well stated is a problem half solved" -- Charles F. Kettering
 
Well unfortunately, I do not have much information on where the data came from, or do I have access. I did find out that it is the output of a some QWIKJOBS/QUIKWRITE programs. So I assume the data is Alphanumeric??

Here is my lates attempt using NUMVAL with error:
As you can see, it moves on fine with the smaller numbers, but the larger numbers have a problem?



Code:
*-------------------------------------
 01  WS-INFILE-RECORD.
    05  WS-IN-PART1        PIC X(80).
    05  WS-IN-PART2        PIC X(13).
*-------------------------------------
*       OUTFILE RECORD LAYOUT                       
*-------------------------------------
 01  WS-OUTFILE-RECORD.
    05  WS-OUT-PART1       PIC X(80).
    05  WS-OUT-PART2       PIC --,---,---.99.
*---------------------------------------------




2000-MAIN-PROCESS.
         DISPLAY "IN" WS-IN-PART2
         COMPUTE WS-OUT-PART2 = FUNCTION NUMVAL (WS-IN-PART2)
         DISPLAY WS-IN-PART2

2000-MAIN-PROCESS-EXIT.
    EXIT.



IDC0002I IDCAMS PROCESSING COMPLETE. MAXIMUM CONDITION CODE WAS 0
BEGIN PROGRAM
IN       661.95
OUT       661.95

IN    34,214.40
IGZ0152S Invalid character , was found in column 7 in argument-1 for function NUMVAL in program FAMR0020 at

         displacement X'06C8'.
         From compile unit PROGRAM at entry point FAMR0020 at compile unit offset +000006C8 at address 0A600C28.

<> LEAID ENTERED (LEVEL 07/09/2002 AT 11.37)

<> LEAID ENTERED (LEVEL 07/09/2002 AT 11.37)
<> LEAID ABENDAID DD ALLOCATED BY #XAMAKDD DYNALLOC RC =00000
CEE3DMP V2 R10.0: Condition processing resulted in the unhandled condition.

 
that was the error I was getting.

try
Code:
*-------------------------------------
 01  WS-INFILE-RECORD.
    05  WS-IN-PART1        PIC X(80).
    05  WS-IN-PART2        PIC X(13).
*-------------------------------------
*       OUTFILE RECORD LAYOUT                       
*-------------------------------------
 01  WS-OUTFILE-RECORD.
    05  WS-OUT-PART1       PIC X(80).
    05  WS-OUT-PART2       PIC --,---,---.99.
 01  WS-OUT-PART-N    PIC S9(13)V99. 
*---------------------------------------------




2000-MAIN-PROCESS.
         DISPLAY "IN" WS-IN-PART2
         COMPUTE WS-OUT-PART-N = FUNCTION NUMVAL-C (WS-IN-PART2)
         MOVE WS-OUT-PART-N TO WS-OUT-PART2
         DISPLAY WS-IN-PART2

2000-MAIN-PROCESS-EXIT.
    EXIT.

Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Do you happen to have hex version of that input? Is there any chance that there is a hex "tab" or binary-zero character in the field? (You can check on this via ISPF edit of the input record and looking in HEX). All "leading" characters should be X'40'. If they aren't that could explain the problem.

Bill Klein
 
Bill,

By looking at the error
(Invalid character , was found in column 7)
and at the output
Code:
   1234567
"IN    34,214.40
we see that the error is the "," on position 7 of the parameter 1 of numval (and internaly numval has two parameters, one in the output var and the other the input var).


This is exactly the error I had on the 400.

Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
New log file:

Code:
IN     7,501.02
OUT      7,501.02
IN   260,312.72-
OUT   -260,312.72
IN   119,183.55-
OUT   -119,183.55
IN     7,501.02-
OUT     -7,501.02


SUCCESS with the last try from Frederico.
Thank you very much all for helping a rookie. Now I have something I can pass on.

Thanks again, this board is great for help.


 
By looking at the reference manual with more detail it seems that the problem is on using numval versus numval-c.

According to the AS400 manual the NUMVAL does NOT allow for COMMA, only for the decimal point, while NUMVAL-C allows for both.

So 12,234.99 is valid for NUMVAL-C but not NUMVAL
(if DECIMAL-POINT IS COMMA is used then the above gets reversed).



Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Hi
I have for long time routine like numval.
That can used in any machin & any cobol virsion.
That routine in RMCOBOL but can convert to otheres (excluding comp-6).
Code:
000001 IDENTIFICATION DIVISION.
000002 PROGRAM-ID. NUMSPL.
000003 ENVIRONMENT DIVISION.
000007 DATA DIVISION.
000008 WORKING-STORAGE SECTION.
000009 01  I            PIC S9(5)  COMP-3 VALUE 0.
000010 01  J            PIC 9(4)   COMP-6 VALUE 0.
000011 01  K            PIC 9(4)   COMP-6 VALUE 0.
000012 01  N1           PIC 9(13).
000013 01  N1-X REDEFINES N1.
000014     02 VEC-N1    PIC X OCCURS 13.
000015 01  N2           PIC V9(5).
000016 01  N2-X REDEFINES N2.
000017     02 VEC-N2    PIC X OCCURS 5.
000018 01  X            PIC X(20) JUST RIGHT.
000019 01  X-R REDEFINES X.
000020     02 VEC-X     PIC X OCCURS 20.
000021 01  SW-PERIOD    PIC 9.
000022 01  SW-SIGN      PIC 9.
000023**********************
000024 LINKAGE SECTION.
000025 01  INP          PIC X(20) JUST RIGHT.
000026 01  N            PIC S9(12)V9(5) COMP-3.
000027********************************************************
000028 PROCEDURE DIVISION USING INP N.
000029 MAIN SECTION.
000030 1.  MOVE INP TO X.
000031     PERFORM IN-NUM.
000032     EXIT PROGRAM.
000033 IN-NUM.
000034     IF VEC-X(20) = SPACE MOVE "," TO VEC-X(20).
000035     INSPECT X REPLACING ALL SPACE BY ZERO.
000036     MOVE 0 TO N1 N2.
000037     MOVE 0 TO K SW-PERIOD SW-SIGN.
000038     PERFORM IN-NUM1 VARYING I FROM 1 BY 1 UNTIL I > 20.
000039     IF SW-PERIOD > 0 SUBTRACT 1 FROM K
000040                 ELSE MOVE 20 TO K.
000041     MOVE 14 TO J.
000042     PERFORM IN-NUM2
000043                  VARYING I FROM K BY -1 UNTIL (J = 1 OR I < 1).
000044     IF SW-PERIOD > 0 ADD 2 TO K
000045                      MOVE 0 TO J
000046                      PERFORM IN-NUM3
000047                   VARYING I FROM K BY 1 UNTIL (J = 5 OR I > 20).
000048     ADD N1 N2 GIVING N.
000049     IF SW-SIGN = 1 MULTIPLY -1 BY N.
000050    IN-NUM1.
000051     IF VEC-X(I) = "." MOVE I TO K
000052                       MOVE 77 TO I
000053                       MOVE 1 TO SW-PERIOD.
000054    IN-NUM2.
000055     IF VEC-X(I) = "-" MOVE 1 TO SW-SIGN
000056      ELSE IF VEC-X(I) NOT = "," SUBTRACT 1 FROM J
000057                                 MOVE VEC-X(I) TO VEC-N1(J).
000058    IN-NUM3.
000059     IF VEC-X(I) = "-" MOVE 1 TO SW-SIGN
000060      ELSE IF VEC-X(I) NOT = "," ADD 1 TO J
000061                                 MOVE VEC-X(I) TO VEC-N2(J).
000062 EX-IN-NUM.

Regards
Baruch
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top