Check for Salary field which is in PD



Unicenter CA-Easytrieve Plus Report Generator: CA's information retrieval and data management tool

Check for Salary field which is in PD

Postby Kitz » Sun Nov 08, 2015 2:10 am

Hi,

I have a SALARY field of S9(13)V99 COMP-3 in a VSAM file.

The requirement is to find all the customer details whose SALARY is more than 20000. I tried to run with the below code, but its failing for SOC7. Could you please help in resolving the issue?

FILE FILE2 VS
F2-CUSTID 1 8 P
F2-ACCNO 10 4 P
F2-SAL 73 8 P 2

FILE OUTFILE FB(80 0)
OUT-CUSTID 1 8 P
OUT-ACCNO 20 4 P

JOB INPUT NULL
GET FILE2
DO WHILE NOT EOF FILE2
IF F2-WORK GET X'20000'
MOVE F2-CUSTID TO OUT-CUSTID
MOVE F2-ACCNO TO OUT-ACCNO
PUT OUTFILE
END-IF
GET FILE2
END-DO
STOP
Kitz
 
Posts: 47
Joined: Thu Mar 17, 2011 3:46 am
Has thanked: 0 time
Been thanked: 1 time

Re: Check for Salary field which is in PD

 

Re: Check for Salary field which is in PD

Postby Kitz » Sun Nov 08, 2015 2:45 am

Sorry, the if condition is F2-SAL (not F2-WORK) that i specified in my previous post:

FILE FILE2 VS
F2-CUSTID 1 8 P
F2-ACCNO 10 4 P
F2-SAL 73 8 P 2

FILE OUTFILE FB(80 0)
OUT-CUSTID 1 8 P
OUT-ACCNO 20 4 P

JOB INPUT NULL
GET FILE2
DO WHILE NOT EOF FILE2
IF F2-SAL GET X'20000'
MOVE F2-CUSTID TO OUT-CUSTID
MOVE F2-ACCNO TO OUT-ACCNO
PUT OUTFILE
END-IF
GET FILE2
END-DO
STOP


the error message was:
- must be an even number of digits
- must be 16 HEX digits

if I directly validate with the below code, it is giving SOC7:
If F2-SAL GT 20000

These users thanked the author Kitz for the post:
mywave86ba (Sat Jun 10, 2017 12:37 pm)
Kitz
 
Posts: 47
Joined: Thu Mar 17, 2011 3:46 am
Has thanked: 0 time
Been thanked: 1 time

Re: Check for Salary field which is in PD

Postby Robert Sample » Sun Nov 08, 2015 6:35 am

You have defined an 8-byte packed decimal variable. If you want to compare that variable using a hexadecimal value, you need to ensure the hexadecimal value matches the variable. Your comparison needs to be 16 hexadecimal digits (8 bytes), have the proper format for a packed decimal, and the fact that you're not meeting these conditions is why you got an error. Try comparing against X'000000002000000C' - 8 bytes, 16 packed decimal digits representing a value of 20000.00 (you need to consider the decimal point).

These users thanked the author Robert Sample for the post:
mywave86ba (Sat Jun 10, 2017 12:37 pm)
Robert Sample
Global moderator
 
Posts: 3625
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 267 times

Re: Check for Salary field which is in PD

Postby BillyBoyo » Sun Nov 08, 2015 1:43 pm

Just use GE 20000. Why attempt to use a hexadecimal literal?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Check for Salary field which is in PD

Postby lawnless » Thu Nov 26, 2015 9:42 pm

Are you sure you have your data definition correct? If you have a correctly defined field and valid data, you should be able to just check
> 20000
and not worry about hex values

These users thanked the author lawnless for the post:
mywave86ba (Sat Jun 10, 2017 12:37 pm)
lawnless
 
Posts: 5
Joined: Tue Nov 10, 2015 11:23 pm
Has thanked: 0 time
Been thanked: 1 time


Return to CA-Easytrieve

 


  • Related topics
    Replies
    Views
    Last post