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

want to move a comp-3 into a file. Please help


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
abhikulsh
Currently Banned

New User


Joined: 17 Feb 2011
Posts: 12
Location: chennai

PostPosted: Sat Feb 26, 2011 1:10 am
Reply with quote

I want to accept a variable using sysin in JCL to my cobol program .
that variable has to be a COMP-3 variable , since this variable replaces the same comp-3 in a file.
But ACCEPT statement in Cobol doesnt take comp-3.
Kindly advice.
//SYSIN DD *
12.2
/*

in Cobol
how do i move value so that it is in comp-3 .
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sat Feb 26, 2011 1:50 am
Reply with quote

Hello,

ACCEPT the value as pic x(whatever) and then convert it to packed-decimal (comp-3) in the code. Read in the COBOL Language Reference about NUMVAL (link to IBM Manuals at the top of the page).

It is rarely acceptable to make data modifications this way. . . Suggest you get specific direction from management before making this uncontrolled/unaudited change to some Production data. . .

Some organizations terminate people for doing such as this. . .
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Sat Feb 26, 2011 1:53 am
Reply with quote

abhikulsh wrote:
I want to accept a variable using sysin in JCL to my cobol program .
that variable has to be a COMP-3 variable , since this variable replaces the same comp-3 in a file.
But ACCEPT statement in Cobol doesnt take comp-3.
Kindly advice.
//SYSIN DD *
12.2
/*

in Cobol
how do i move value so that it is in comp-3 .


Yes it will accept a comp-3 value but I don't think you need to know how. Just accept into a numeric display field and then move it to a comp-3 field, that was very difficult to figure out.
Back to top
View user's profile Send private message
abhikulsh
Currently Banned

New User


Joined: 17 Feb 2011
Posts: 12
Location: chennai

PostPosted: Sat Feb 26, 2011 1:57 am
Reply with quote

No its not accepting as Comp-3 variabe it says

Identifier "R (PACKED NON-INTEGER)" was used in an
"ACCEPT" statement. The statement was discarded.
Back to top
View user's profile Send private message
abhikulsh
Currently Banned

New User


Joined: 17 Feb 2011
Posts: 12
Location: chennai

PostPosted: Sat Feb 26, 2011 2:02 am
Reply with quote

I am accepting in 77 N PIC 9(3)V9(8).
field and thn moving to 77 R PIC 9(03)V9(8) COMP-3
ACCEPT N.
MOVE N TO R.

when i process this R as
MOVE R TO FUND-NAV-PER-SHARE(2)

Here FUND-NAV-PER-SHARE(2) is of PIC 9(03)V9(8) COMP-3.

it gives invalid in file
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sat Feb 26, 2011 2:17 am
Reply with quote

Hello,

There are multiple ways to do this. . .

Suggest you re-read my first reply and try that. Yes, it does mean that you need to look in the manual - something you should do often. . .
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Sat Feb 26, 2011 2:18 am
Reply with quote

abhikulsh wrote:
I am accepting in 77 N PIC 9(3)V9(8).
field and thn moving to 77 R PIC 9(03)V9(8) COMP-3
ACCEPT N.
MOVE N TO R.

when i process this R as
MOVE R TO FUND-NAV-PER-SHARE(2)

Here FUND-NAV-PER-SHARE(2) is of PIC 9(03)V9(8) COMP-3.

it gives invalid in file

Have you tried declaring N as PIC 9(3).9(8) instead of PIC 9(3)V9(8)?
Back to top
View user's profile Send private message
abhikulsh
Currently Banned

New User


Joined: 17 Feb 2011
Posts: 12
Location: chennai

PostPosted: Sat Feb 26, 2011 2:51 am
Reply with quote

ya tried declaring N as PIC 9(3).9(8) instead of PIC 9(3)V9(8) , it doent work

gives INVALID in file
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sat Feb 26, 2011 2:55 am
Reply with quote

Hello,

Persistent can be a good thing. . . Obstinate is not. . .

Now, maybe you will use the solution that i believe will be easiest for you to accomplish. . .

You have dragged a rather trivial requirement into a many-post topic . . .

d
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Sat Feb 26, 2011 3:01 am
Reply with quote

abhikulsh wrote:
ya tried declaring N as PIC 9(3).9(8) instead of PIC 9(3)V9(8) , it doent work

gives INVALID in file

I see that my statement was a bit too subtle for you.

Your data is "12.2". Why in the name of the Holy One (blessed be He) would you expect those data to be randomly stuffable into a PIC 9(3)V9(8) -- or PIC 9(3).9(8) -- variable? You don't have the same number of digits, before or after the decimal point, nor are the data aligned properly icon_evil.gif

Make your data match the variable, or the variable match your data. Or ACCEPT it into PIC X(80) and then write logic to parse it and move it to a COMP-3 variable as Mr. Scherrer has suggested.
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top