Page 1 of 1

Logics on Decimal field using REXX program

PostPosted: Sat Apr 16, 2011 12:07 am
by magesh123
Hi All,

This is my requirement. My input dataset contains the below format. i want to do validations on my decimal field(column 13 to column 18). After that
i will move the valid records into the output dataset.

Conditions:
1) first digit should be '0'
2) last digit should be 'C' --> as it is decimal field.
3) There should be only interger value(0 to 9) from column 13 to column 18
Ex for valid record: 2nd record
0001400046
invalid record: 1st record
00014A00038 --> 'A' should not be present here. so we need to omit this record.There should be only interger value(0 to 9) from column 13 to column 18.........


input dataset format:
12345678901234567890123 ----> Column no
0004 ¢ ð03210
4444FFFF4444004008FFFFF
00000004000001A03C03210
-----------------------
0004 %03210
4444FFFF4444004006FFFFF
00000004000001004C03210
-----------------------
0004 <03210
4444FFFF4444004004FFFFF
00000004000001005C03210



output dataset:(1st record should be omitted as it contains invaid decimal vaue)
0004 %03210
4444FFFF4444004006FFFFF
00000004000001004C03210
-----------------------
0004 <03210
4444FFFF4444004004FFFFF
00000004000001005C03210



Program skeleton:
"EXECIO * DISKR INFIL (STEM INF. FINIS)"
DO I = 1 TO INF.0
if (decimal_field(last char))='C' then
do
validate other_fields
if matches then
COPY RECS INTO OUTFILE(OUTPUT FILE)
ELSE
LEAVE THIS RECORD

end

END


Can anyone please suggest me to code the REXX PROGRAM for the above skeleton ?

Re: Logics on Decimal field using REXX program

PostPosted: Sat Apr 16, 2011 12:49 am
by prino
Look at the X2C function

Re: Logics on Decimal field using REXX program

PostPosted: Sat Apr 16, 2011 2:53 am
by Ronald Burr
I believe that the C2X function is what is needed.

DO J=1 to INF.0
UNHEX = C2X(SUBSTR(INF.J,13,6)
IF SUBSTR(UNHEX,12,1) = 'C' THEN
DO
validate other fields
if matches then
COPY RECS INTO OUTFILE(OUTPUT FILE)
ELSE
LEAVE THIS RECORD

end

END

Re: Logics on Decimal field using REXX program

PostPosted: Sat Apr 16, 2011 3:10 am
by prino
Ronald Burr wrote:I believe that the C2X function is what is needed.

Oops, my mistake...

Re: Logics on Decimal field using REXX program

PostPosted: Sat Apr 16, 2011 11:37 am
by NicC
What you want is just 4 posts down from yours. Not that hard to search.

Re: Logics on Decimal field using REXX program

PostPosted: Mon Apr 18, 2011 8:05 am
by magesh123
Thank you very much for your help