Page 1 of 1

SORT arithemtic expression

PostPosted: Thu Apr 14, 2022 12:06 am
by cobol_dev
my input file has a 6 byte long number as pd format (cobol comp-3, db2 decimal), for example

HEX-CODE ist
X'00000000449C' -> The representation is the decimal +4.49 -> the nibble c represents a positiv number
X'00000000449D' -> is the opposite, so we have -4,49 -> the nibble d represents a negative number

The goal is to multiply any of them by -1 so the nibble c converts to d and d converts to c.

i tried this one:
OPTION COPY
INREC FIELDS=(1,6,PD,MUL,-1)

that works, but the output must be converted to pd and positioned to it's original position. I don't have a idea doing this in one step. in two steps i can use again the sort, reposition that temporay file and reformating the result of my expression. is there no better way?

The sort trick by converting the format (TO=PDC) won't work but you can't convert to PDD and you can't switch between PDC and PPD with IFTHEN .. WHEN...

Annother Idee is replacing it byte by byte 1C -> 1D, 2C -> 2D, .. 9C -> 9D and also 1D -> 1C, .. 9D -> 1C with sort statement. But in real i have three fields in one data set to convert :-(

Re: SORT arithemtic expression

PostPosted: Thu Apr 14, 2022 12:55 am
by cobol_dev
solved :-)

OPTION COPY
OUTREC FIELDS=(1,6,PD,MUL,-1,TO=PD,LENGTH=6)