Page 1 of 1

Check for Salary field which is in PD

PostPosted: Sun Nov 08, 2015 2:10 am
by Kitz
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

Re: Check for Salary field which is in PD

PostPosted: Sun Nov 08, 2015 2:45 am
by Kitz
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

Re: Check for Salary field which is in PD

PostPosted: Sun Nov 08, 2015 6:35 am
by Robert Sample
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).

Re: Check for Salary field which is in PD

PostPosted: Sun Nov 08, 2015 1:43 pm
by BillyBoyo
Just use GE 20000. Why attempt to use a hexadecimal literal?

Re: Check for Salary field which is in PD

PostPosted: Thu Nov 26, 2015 9:42 pm
by lawnless
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