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

How to redefine comp-3 variable?


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
khyati kumar

New User


Joined: 04 Jan 2008
Posts: 15
Location: Pune

PostPosted: Fri Jan 11, 2008 3:53 pm
Reply with quote

How to redefine comp-3 variable?

Suppose I have comp-3 valiable S9(11)V99 comp-3 and I have to move this value to ZZZ,ZZZ,ZZZ,ZZ9.99.So please let me know any suggestion what to do because while moving this variable i am getting S0c7 so i want to redefine ?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Fri Jan 11, 2008 4:14 pm
Reply with quote

If you are getting a SOC7, that means you have non-numerics in your comp-3 variable. What you need to do is insure that you have valid data.
Back to top
View user's profile Send private message
khyati kumar

New User


Joined: 04 Jan 2008
Posts: 15
Location: Pune

PostPosted: Fri Jan 11, 2008 4:52 pm
Reply with quote

Actually if there is any invalid data in the comp-3 variable i want to display that variable in the control report so i am moving that variable to ZZZ,ZZZ,ZZZ,ZZ9.99.Please tell me the solution so that i can display the invalid value present in the comp-3 variable?
Back to top
View user's profile Send private message
Ajay Baghel

Active User


Joined: 25 Apr 2007
Posts: 206
Location: Bangalore

PostPosted: Fri Jan 11, 2008 5:26 pm
Reply with quote

To check for invalid packed decimal fields:

1.Use file aid and in format option mode, give the following :
NV 0

or
2. Use SORT with the below sort card:
include cond=(start position,length,PD,EQ,NUM)

This card will include only those records that have valid values in the packed numeric field indicated by the start position and length.

Thanks,
Ajay
Back to top
View user's profile Send private message
khyati kumar

New User


Joined: 04 Jan 2008
Posts: 15
Location: Pune

PostPosted: Fri Jan 11, 2008 6:05 pm
Reply with quote

Actually i want to write this non numeric field present in comp-3 working storage to a report file so if i am sorting it i will lose these variable.Can you please me the solution for this?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Fri Jan 11, 2008 7:19 pm
Reply with quote

include cond=(start position,length,PD,NE,NUM)
Back to top
View user's profile Send private message
khyati kumar

New User


Joined: 04 Jan 2008
Posts: 15
Location: Pune

PostPosted: Fri Jan 11, 2008 7:24 pm
Reply with quote

Thanks a Lot for your suggestion
Back to top
View user's profile Send private message
Amit Banerjee

New User


Joined: 12 Jan 2008
Posts: 14
Location: india

PostPosted: Sat Jan 12, 2008 3:10 am
Reply with quote

In the cobol program check if the value is numeric by having
IF <variable-name> IS NUMERIC
ELSE
display in your report.
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 Jan 12, 2008 3:36 am
Reply with quote

Amit Banerjee wrote:
In the cobol program check if the value is numeric by having
IF <variable-name> IS NUMERIC
ELSE
display in your report.


Thats a sure way to get an 0C7.
Back to top
View user's profile Send private message
Amit Banerjee

New User


Joined: 12 Jan 2008
Posts: 14
Location: india

PostPosted: Sat Jan 12, 2008 3:54 am
Reply with quote

oh yes..we can't directly check an alphanumeric field for NUMERIC but I guess the packed data can be moved to a variable
VAR-1 PIC 9(11)V9(02)
VAR-2 REDEFINES VAR-1
05 VAR3 PIC X(13)

and then IF VAR-3 IS NUMERIC
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 Jan 12, 2008 8:23 am
Reply with quote

Amit Banerjee wrote:
oh yes..we can't directly check an alphanumeric field for NUMERIC but I guess the packed data can be moved to a variable
VAR-1 PIC 9(11)V9(02)
VAR-2 REDEFINES VAR-1
05 VAR3 PIC X(13)

and then IF VAR-3 IS NUMERIC


var-1 is comp-3 so to redefine it var3 would be x(7) not x(13).
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 Variable Output file name DFSORT/ICETOOL 8
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
No new posts parsing variable length/position data... DFSORT/ICETOOL 5
Search our Forums:

Back to Top