Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

subtotal

Status
Not open for further replies.

sabetik

IS-IT--Management
Nov 16, 2003
80
GU
With this code Can I add a subtotal to fd6 . My data input looks like this
Hxxxx xxxxx
Dzzzz zzzz zzz
Dzzzz zzzz zzz
Dzzzz zzzz zzz (subtotal)
Hxxx xxxxx
Dzzz zzzzz (subtotal)

{

if(substr($0,1,1)=="H") {
# do this
#remove first Character
sub( /./, "" )



fh1 = substr($0,1,7)
fh2 = substr($0,8,6)
fh3 = substr($0,15,8)
fh4 = substr($0,23,8)
fh5 = substr($0,32,40)
printf "\n\n\n" > "test.DAT"
printf ("Dealer_code%-7s INV#%-7s , date%-8s , ETDdate%-8s \n",fh1,fh2,fh3,fh4 ) > "test.DAT"
# printf ("Dealer_code,%-7s \n",fh1) > "test.dat"
# printf ("invoice#, %-8s \n" ,fh2) > "test.dat"
# printf ("Inv_Date, %-8s \n" ,fh3) > "test.dat"
printf "\n" > "test.DAT"


} else if(substr($0,1,1)=="D") {
# do this
sub( /./, "" )

fd1 = substr($0,1,7)
fd2 = substr($0,9,7)
fd3 = substr($0,18,3)

fd4 = substr($0,21,12)
# Insert "-" after each group of 5 chars.
gsub( /...../, "&-", fd4 )
# Remove any trailing "-".
sub( /- *$/, "", fd4 )
fd5 = substr($0,37,5)
fd6 = substr($0,43,9)
fd7 = substr($0,53,14)

printf ("%-8s,%-8s,%-4s,%-15s,%-5s,%10.2f,%10.2f \n",fd1,fd2,fd3,fd4,fd5,fd6/100,fd7/100 ) > "test.DAT"

}



}
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top