awk -F"^" '  {
split($0,x)
printf "C^%s^%s^%s\n",$1,$2,$3
s=$6
if ($7+$8)
{
	printf "T^FOLIO^FECHA^TP^REGISTRO^GLOSA DEL MOVIMIENTO^DEBE^HABER^ANALISIS^DOC REFER^FECHA REF^CC^SALDO\n"
	ff="./tmp/"$1
	while ( getline < ff > 0)
	{
		s +=$6-$7
		printf "M^%s%d\n",substr($0,1,length -1),s
	}
}
print "S^^^^^ACUMULADO^DEBITOS^CREDITOS^SALDO"
printf "A^^^^^ANTERIOR^%s^%s^%s\n",x[4],x[5],x[6]
printf "P^^^^^MENSUAL^%s^%s^%s\n",x[7],x[8],x[9]
printf "F^^^^^FINAL^%s^%s^%s\n\n",x[10],x[11],x[12]

	close(ff)
}
END { print "FIN" }  ' ./tmp/planc.1 >../xls/myr


