Hello All:
To summarize, the cus_main.prg creates an export text file containing the daily shipping data for importing into customers AS400 host.
An important feature of this cus_main is to consolodate multi-pak shipments into one record. This is the feature that is not working. However, it does create a single record for a multi-pak, but it doesn't calculates the
total weight and total charges correctly.
The purpose of this cus_main routine is to create a text file of the daily shipments in the format that the customers AS400 host system can import. The record format is described below. The other important function that this routine is designed to perform is the consolidation of multi-pkg shipments. The consolidation is to create one record containing the total weight and total freight charges of each shipment of a multi-pkg group.
The cus_main works with the export script named ANAPA. The actual export file name is ‘shipment.txt’. Note that there is a temporary file that is also created during the execution of the ANAPA export script called ‘shipmen2.txt’. This file is used in setting up the cus-main and is always empty. The process for generating this ‘shipment.txt’ file is simply at the end of the day run the export script ANAPA and the file is created in the root of the c: drive.
The record format for shipment.txt:
Col 1-7 consignee code; Col 8-13 invoice #; Col 14-19 weight / lbs
Col 20-30 freight charges; Col 31-33 ‘lbs’
Below there two test files that demonstrate the problem.
The first test file example #1 demonstrates the error in addition with the freight charges. The file contains 4 records; the last record represents the mult-pkg. This multi-pkg is made of 3 shipments; the shipments generated is listed below:
1) 1 lbs @ 4.02 2) 2 lbs @ 4.48 3) 3 lbs @ 4.78; therefore the total (lbs) equals 6 and the total freight equals 13.28. In this case the (lbs) were correct but the freight at 9.56 is not correct.
#1:
0000AZC00111100000100000004.02Lbs
0000CAR00222200000200000004.58Lbs
0000DEC00333300000300000004.46Lbs
0000CTC4444.000000600000009.56Lbs
#2:
0000ALC00100100000100000003.82Lbs
0000FLC00100200001000000006.28Lbs
0000CTC1003.000002000000012.56Lbs
The second file example #2 contains 3 records; the last record represents a 2-package multi-pkg. Note that in this example both the weight and the freight are wrong. The multi-pkg data: 1) 5 lbs @ 5.30 2) 10 lbs @ 6.28; therefore total (lbs) should be 15 and total freight 11.58.
Note that the first records in each test file are single shipments and established for me that the single shipments are being created correctly, in each case the (lbs) and the freight are accurate and match the data for that shipment.
I have been unable to get the freight to calculate correctly for multi-pkg.
Thank you in advance for your help.
~PM
* Code:
Function NapaFileOut()
* This is a function to create a file from export for Napa *that allows certain fields to be padded with zeros and for *a single consolidated record for mutli pack shipments.
************************************************************
Local lnPrevWa
Local lnFileHandle
Local lmCode
Local lmInvnum
Local lmWeight
Local lmChgs
Local lmMasterInvnum
Local lmMasterCode
Local lmTotalWeight
Local lmTotalChgs
Local i
Local lnRecnum
Local answer
local curinvnum
local lcSafety
local lnCurrRec
local lcOrder
*set step on
lcSafety = set("Safety")
set safety off
answer = 6
If file("c:\shipment.txt")
answer =messageb("Do you want to overwrite the export file?",4)
endif
If answer = 7
return ""
endif
lnFileHandle = Fcreate("C:\"+"Shipment.txt")
IF lnFileHandle = -1
=messageb("File Shipment.txt Cannot be Created")
return ""
ENDIF
lnPrevWa = select()
*use upsman.dbf in 0 shared alias napa
select man
lnCurrRec = recno()
lcOrder = order()
index on invnum to man
set index to man
Go Top
lnrecnum = reccount()
i = 0
lmMasterCode = man->cscode
lmMasterInvnum = left(man->invnum,6)
lmTotalweight=0
lmTotalchgs=0
curinvnum = left (man->invnum,6)
do while i <= lnrecnum
if !eof()
lmcode=man->cscode
lminvnum=left (man->invnum,6)
lmweight=man->wight
lmchgs=man->fright
If i <> 0
If left (man->invnum,6) <> curinvnum
=Fputs(lnFileHandle, padl(trim(lmMasterCode), 7, "0") + padl(trim(lmMasterInvnum), 6, "0") + padl(alltrim(str(lmTotalweight, 6, 0)), 6, "0") + padl(alltrim(str(lmTotalChgs, 11, 2)), 11, "0")+"Lbs")
lmMasterInvnum = lminvnum
lmMasterCode = lmCode
lmTotalWeight = lmWeight
lmTotalchgs = lmChgs
curinvnum = left (man->invnum,6)
else
lmTotalWeight = lmWeight + man->wight
lmTotalchgs = lmchgs + man->fright
endif
else
lmTotalweight = lmWeight
lmTotalchgs = lmChgs
endif
skip
else
=Fputs(lnFileHandle, padl(trim(lmMasterCode), 7, "0") + padl(trim(lmMasterInvnum), 6, "0") + padl(alltrim(str(lmTotalweight, 6, 0)), 6, "0") + padl(alltrim(str(lmTotalChgs, 11, 2)), 11, "0")+"Lbs")
endif
i = i+1
enddo
=fclose(lnFileHandle)
*use
set index to
set order to &lcOrder
goto lnCurrRec
select (lnPrevWa)
set safety &lcSafety
return ""
ENDFUNC
To summarize, the cus_main.prg creates an export text file containing the daily shipping data for importing into customers AS400 host.
An important feature of this cus_main is to consolodate multi-pak shipments into one record. This is the feature that is not working. However, it does create a single record for a multi-pak, but it doesn't calculates the
total weight and total charges correctly.
The purpose of this cus_main routine is to create a text file of the daily shipments in the format that the customers AS400 host system can import. The record format is described below. The other important function that this routine is designed to perform is the consolidation of multi-pkg shipments. The consolidation is to create one record containing the total weight and total freight charges of each shipment of a multi-pkg group.
The cus_main works with the export script named ANAPA. The actual export file name is ‘shipment.txt’. Note that there is a temporary file that is also created during the execution of the ANAPA export script called ‘shipmen2.txt’. This file is used in setting up the cus-main and is always empty. The process for generating this ‘shipment.txt’ file is simply at the end of the day run the export script ANAPA and the file is created in the root of the c: drive.
The record format for shipment.txt:
Col 1-7 consignee code; Col 8-13 invoice #; Col 14-19 weight / lbs
Col 20-30 freight charges; Col 31-33 ‘lbs’
Below there two test files that demonstrate the problem.
The first test file example #1 demonstrates the error in addition with the freight charges. The file contains 4 records; the last record represents the mult-pkg. This multi-pkg is made of 3 shipments; the shipments generated is listed below:
1) 1 lbs @ 4.02 2) 2 lbs @ 4.48 3) 3 lbs @ 4.78; therefore the total (lbs) equals 6 and the total freight equals 13.28. In this case the (lbs) were correct but the freight at 9.56 is not correct.
#1:
0000AZC00111100000100000004.02Lbs
0000CAR00222200000200000004.58Lbs
0000DEC00333300000300000004.46Lbs
0000CTC4444.000000600000009.56Lbs
#2:
0000ALC00100100000100000003.82Lbs
0000FLC00100200001000000006.28Lbs
0000CTC1003.000002000000012.56Lbs
The second file example #2 contains 3 records; the last record represents a 2-package multi-pkg. Note that in this example both the weight and the freight are wrong. The multi-pkg data: 1) 5 lbs @ 5.30 2) 10 lbs @ 6.28; therefore total (lbs) should be 15 and total freight 11.58.
Note that the first records in each test file are single shipments and established for me that the single shipments are being created correctly, in each case the (lbs) and the freight are accurate and match the data for that shipment.
I have been unable to get the freight to calculate correctly for multi-pkg.
Thank you in advance for your help.
~PM
* Code:
Function NapaFileOut()
* This is a function to create a file from export for Napa *that allows certain fields to be padded with zeros and for *a single consolidated record for mutli pack shipments.
************************************************************
Local lnPrevWa
Local lnFileHandle
Local lmCode
Local lmInvnum
Local lmWeight
Local lmChgs
Local lmMasterInvnum
Local lmMasterCode
Local lmTotalWeight
Local lmTotalChgs
Local i
Local lnRecnum
Local answer
local curinvnum
local lcSafety
local lnCurrRec
local lcOrder
*set step on
lcSafety = set("Safety")
set safety off
answer = 6
If file("c:\shipment.txt")
answer =messageb("Do you want to overwrite the export file?",4)
endif
If answer = 7
return ""
endif
lnFileHandle = Fcreate("C:\"+"Shipment.txt")
IF lnFileHandle = -1
=messageb("File Shipment.txt Cannot be Created")
return ""
ENDIF
lnPrevWa = select()
*use upsman.dbf in 0 shared alias napa
select man
lnCurrRec = recno()
lcOrder = order()
index on invnum to man
set index to man
Go Top
lnrecnum = reccount()
i = 0
lmMasterCode = man->cscode
lmMasterInvnum = left(man->invnum,6)
lmTotalweight=0
lmTotalchgs=0
curinvnum = left (man->invnum,6)
do while i <= lnrecnum
if !eof()
lmcode=man->cscode
lminvnum=left (man->invnum,6)
lmweight=man->wight
lmchgs=man->fright
If i <> 0
If left (man->invnum,6) <> curinvnum
=Fputs(lnFileHandle, padl(trim(lmMasterCode), 7, "0") + padl(trim(lmMasterInvnum), 6, "0") + padl(alltrim(str(lmTotalweight, 6, 0)), 6, "0") + padl(alltrim(str(lmTotalChgs, 11, 2)), 11, "0")+"Lbs")
lmMasterInvnum = lminvnum
lmMasterCode = lmCode
lmTotalWeight = lmWeight
lmTotalchgs = lmChgs
curinvnum = left (man->invnum,6)
else
lmTotalWeight = lmWeight + man->wight
lmTotalchgs = lmchgs + man->fright
endif
else
lmTotalweight = lmWeight
lmTotalchgs = lmChgs
endif
skip
else
=Fputs(lnFileHandle, padl(trim(lmMasterCode), 7, "0") + padl(trim(lmMasterInvnum), 6, "0") + padl(alltrim(str(lmTotalweight, 6, 0)), 6, "0") + padl(alltrim(str(lmTotalChgs, 11, 2)), 11, "0")+"Lbs")
endif
i = i+1
enddo
=fclose(lnFileHandle)
*use
set index to
set order to &lcOrder
goto lnCurrRec
select (lnPrevWa)
set safety &lcSafety
return ""
ENDFUNC