cancel
Showing results for 
Search instead for 
Did you mean: 

Special character in flat file

MAYIANAN
Advisor

Special character in flat file

Hi,
I am generating a flat file with some amount fields. I may get positive or negative amount fields where i need to populate the last digit in decimal in a specific format,

For positive amounts:
Value Character
0 {
1 A
2 B
3 C
4 D
5 E
6 F
7 G
8 H
9 I

For negative amounts,
Value Character
0 }
1 J
2 K
3 L
4 M
5 N
6 O
7 P
8 Q
9 R

Is there any convertion method to achieve this?/
4 REPLIES
Dennis Handly
Acclaimed Contributor

Re: Special character in flat file

These look like COBOL signed DISPLAY numbers, that are overpunched. Typically they are fixed width with zero fill.
Laurent Menase
Honored Contributor

Re: Special character in flat file

I have some difficulties to understand what you means.

Can you give an exemple of what you want in inbound and outbound of the script.
OldSchool
Honored Contributor

Re: Special character in flat file

Since you don't have any sample input file, then how/what places the amounts in the file today and how does it know its a negative number?
Laurent Menase
Honored Contributor

Re: Special character in flat file

is it to transform a file like

12345
23456
-1234
...

to

1234E
2345F
123M
?
#!/usr/bin/ksh


typeset -i j=0
for i in '{' A B C D E F G H I
do
x_p[$j]=$i
j=j+1
done
j=0
for i in '}' J K L M N O P Q R
do
x_n[$j]=$i
j=j+1
done
while read a
do
b=${a#-}
c=${a%%?}
eval "c=\${a#$c}"
if [ "$b" != "$a" ]
then
echo ${b%?}${x_n[$c]}
else
echo ${b%?}${x_p[$c]}
fi
done