Numeric Edited Picture clause



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Numeric Edited Picture clause

Postby Bhargavi S » Sat Jun 04, 2011 9:00 pm

Hi,
Please help me with this problem....

I have a negative value in my file... I have to add such numbers together..
And have to write the final result in a file with the negative sign displayed in the result...

I have ddeclared the input variable as PIC +9(7).9(2)
I have moved it to a s9(7)v9(2) and the next record is read into another S9(7)v9(2)
and I have moved the result into +9(7).9(2).

I am getting a invalied numeric edited move abend..

Can anyone solve this..
Tell me the PIC clause of the variables I have to use..


Thanks
Bhargavi
Bhargavi S
 
Posts: 3
Joined: Tue May 17, 2011 10:24 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Numeric Edited Picture clause

Postby dick scherrer » Sat Jun 04, 2011 9:05 pm

Hello,

Using the "Code" tag, post a few of the actual values in hex (HEX ON). When we see what you actually are working with we can talk about the proper PICture.

Show the output you want when these values are totaled.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Numeric Edited Picture clause

Postby Robert Sample » Sat Jun 04, 2011 9:08 pm

Can anyone solve this..
Tell me the PIC clause of the variables I have to use..
Not with what you've told us. We have to see some actual data values to determine what the picture clause needs to be.
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Numeric Edited Picture clause

Postby BillyBoyo » Sun Jun 05, 2011 1:03 am

Bhargavi S wrote:[...]

I am getting a invalied numeric edited move abend..

[...]


I don't think you are. There is no such thing.

For your input PICTURE, it has to match the data. For your output PICTURE it has to match what you want to see.

The manual is pretty good here, if have a look, try some things out. If you need more, we need more from you.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Numeric Edited Picture clause

Postby dick scherrer » Sun Jun 05, 2011 1:49 am

Hi Billy,

I don't think you are. There is no such thing.
Sure there is - as has ben attested to. . . 8-)

Like you, i'd prefer the actual diagnostic information generated rather than the interpretation that was posted. . .

Maybe Bhargavi will post both some actual input data (and desired "output") as well as the diagnostic information generated.

d
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Numeric Edited Picture clause

Postby BillyBoyo » Sun Jun 05, 2011 4:15 am

Hi Dick,

Yes. To guess, a compiler message.

Bhargavi, we can help, but need more if you still have a problem. Not every job failure is an abend. We might seem picky about it, but the wrong information starts us on the wrong track, if we take what you say at face value. The more you give us, the more likely, and easier, it is for us to help you.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Numeric Edited Picture clause

Postby Bhargavi S » Sun Jun 05, 2011 3:10 pm

The inputs are from file :
0000005.12
-0000012.89
0000034.76
-0000987.23
I am performing addition on these values..
The resultant has to b stored in a file with the sign in readable format..
Bhargavi S
 
Posts: 3
Joined: Tue May 17, 2011 10:24 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Numeric Edited Picture clause

Postby BillyBoyo » Sun Jun 05, 2011 6:56 pm

This is not actually a "numeric" format in that you cannot define a numeric picture for this data. So, PIC X(?). But you negative values are 11 characters and positives only 10 characters. Makes me think you input file has fields which are not in fixed positions.

Can you show us a couple of records from your input file? If not all the characters are "readable" to the human (if you have lots of dots, or funny-looking characters, or lower-case for instance) then try to do the display in HEX).

You can turn the edited numbers into something you can do calculations with using a Cobol "intrinsic function". Try looking them up in the manual and see if you can see something likely. There is even a bit of example code there, from memory.

If your output is on a file and you want to retain the same non-numeric format, then you could use a Numeric-edited PICture. Again, try in the manual, see how far you get.

Normally, for input like yours, we would convert it for storage in the system as a numeric item. Saves converting it each time. And then when required for viewable output (print or screen) use a numeric-edited picture to display it for a human.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Numeric Edited Picture clause

Postby Bhargavi S » Sun Jun 05, 2011 8:08 pm

ok.. heres how the record looks like..
I doesnot have unreadable characters for sure..
the length of the record is 140+
I cannot extract the whole record..
so have given you the location of the variable in the file
(type1= and type2= are present in the file as such)

type1= 0000056.96
type2= -0009860.56
type1= 0001003.45
type2= -0009563.90

I have to add type1 values and type2 values..
and have to store it in the file as

type1= total value1
type2= totalvalue2..

so i am comparing the type field and adding them in a variable s9(7)v9(2)
and when reading and writing the varaiable I am facing the abends and
execution errors..

I guess you have a better idea as to what records i deal with now..
Bhargavi S
 
Posts: 3
Joined: Tue May 17, 2011 10:24 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Numeric Edited Picture clause

Postby BillyBoyo » Sun Jun 05, 2011 8:37 pm

01  INPUT-NUMBER-FILE.
      05  INF-TYPE-SHOWING-SIGN-AND-LENGTH PIC X(5).
      05  FILLER PIC XX.
      05  INF-NEGATIVE-VALUE PIC X(11).
      05  FILLER REDEFINES INF-NEGATIVE-VALUE.
            10  INF-POSITIVE-VALUE PIC X(10).
            10  FILLER PIC X.
      05  FILLER PIC X(?).


OK, calculate what ? should be and you have an input record which suits the data you have shown. If your data is not at the start of the record, you'll have to have a filler at the front and adjust the one at the back suitably.

Construct your output in a similar manner, replacing the X(11) and X(10) by numeric-edited pictures suiting your requirement (-9(7).99 and 9(7).99).

Use intrinsic function NUMVAL as in the example in the manual with the positive or negative value depending on the current value in INF-TYPE-SHOWING-SIGN-AND-LENGTH. The value you have as the result of the COMPUTE can be

COMP-3 PIC S9(7)V99.


Calculate the total of each type of record in similarly defined fields but two digits bigger.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Next

Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post