Problem reading text file
Posted: Thu Oct 12, 2006 2:54 pm
I am having a problem when reading text from a file. The file is large 1.5MB to 4MB (200,000 lines or more). Usuaally around 100,000 lines the program exits prematurely with no errors. I would appreciate any help. Here is the code for reading file.
DO WHILE ! lEof
// Init...
cLine := ""
// Read...
Ureadln( hCTS, @cLine, 1, @lEof )
// Criteria...
IF EMPTY( cLine )
LOOP
ENDIF
nLine++
// Log...
cDat := cCTS + " EOF = " + IF(lEof,"YES","NO") + " = " + LTRIM(TRANSF(nLine,"999,999")) + cEol
FWRITE( hLog, cDat )
// Tag...
cTag := UPPER( LEFT( cLine, AT("*",cLine)-1 ) )
cValue := UPPER( SUBSTR( cLine, AT("*",cLine)+1 ) )
DO CASE
CASE ( cTag == "OVERSEAS" )
cOverseas := cValue
CASE ( cTag == "USA" )
cUsa := cValue
CASE ( cTag == "PROFILE" )
cProfile := cValue
CASE ( cTag == "SHIPNAME" )
cShipname := cValue
CASE ( cTag == "SHIPADD1" )
cShipadd1 := cValue
CASE ( cTag == "SHIPADD2" )
cShipadd2 := cValue
CASE ( cTag == "SHIPADD3" )
cShipadd3 := cValue
CASE ( cTag == "SHIPADD4" )
cShipadd4 := cValue
CASE ( cTag == "SVC" )
cSvc := cValue
CASE ( cTag == "REF" )
cRef := cValue
CASE ( cTag == "MBL" )
cMbl := cValue
CASE ( cTag == "HBL" )
cHbl := cValue
CASE ( cTag == "BKG" )
cBkg := cValue
CASE ( cTag == "CONSNAME" )
cConsname := cValue
CASE ( cTag == "CONSADD1" )
cConsadd1 := cValue
CASE ( cTag == "CONSADD2" )
cConsadd2 := cValue
CASE ( cTag == "CONSADD3" )
cConsadd3 := cValue
CASE ( cTag == "CONSADD4" )
cConsadd4 := cValue
CASE ( cTag == "NOTINAME" )
cNotiname := cValue
CASE ( cTag == "NOTIADD1" )
cNotiadd1 := cValue
CASE ( cTag == "NOTIADD2" )
cNotiadd2 := cValue
CASE ( cTag == "NOTIADD3" )
cNotiadd3 := cValue
CASE ( cTag == "NOTIADD4" )
cNotiadd4 := cValue
CASE ( cTag = "RCPTCD" )
cRcptcd := cValue
CASE ( cTag == "RCPT" )
cRcpt := cValue
CASE ( cTag == "POLCD" )
cPolcd := cValue
CASE ( cTag == "POL" )
cPol := cValue
CASE ( cTag == "POULCD" )
cPoulcd := cValue
CASE ( cTag == "POUL" )
cPoul := cValue
CASE ( cTag == "DSTCD" )
cDstcd := cValue
CASE ( cTag == "DEST" )
cDest := cValue
CASE ( cTag == "CARRIER" )
cCarrier := cValue
CASE ( cTag == "VESSEL" )
cVessel := cValue
CASE ( cTag == "VOY" )
cVoy := cValue
CASE ( cTag == "COMM" )
cComm := cValue
CASE ( cTag == "PCS" )
cPcs := cValue
CASE ( cTag == "PKG" )
cPkg := cValue
CASE ( cTag == "KGS" )
cKgs := cValue
CASE ( cTag == "CBM" )
cCbm := cValue
CASE ( cTag == "ETD" )
cEtd := cValue
CASE ( cTag == "ETA" )
cEta := cValue
CASE ( cTag == "WK" )
cWk := cValue
CASE ( cTag == "SONO" )
cSoNo := cValue
CASE ( cTag == "OBL" )
cObtype := cValue
CASE ( cTag == "DOOR" )
cDoor := cValue
CASE ( cTag == "BLFORM" )
cBlform := cValue
CASE ( cTag == "SALES" )
cSales := cValue
CASE ( cTag == "DOCDATE" )
cDocdate := cValue
CASE ( cTag == "CTNR" )
nCtnr++
aCtnr[nCtnr] := cValue
CASE ( cTag == "PONO" )
nPo++
aPo[nPo] := cValue
CASE ( cTag == "END" )
lStart := .T.
ENDCASE
// Update...
IF lStart
// Init...
lProcess := .T.
lEmail := .F.
lDest := .F.
cUsa1 := ""
lObl := .F.
cObl1 := ""
cTo := ""
cCClist := ""
cSubject := "Apex_CTS_destination_station_change"
cSay := "Uploading RCA " + cOverseas + " - " + cHbl + " . . ."
oSay:Refresh()
SysRefresh()
SELECT rca
SET ORDER TO TAG S5
GO TOP
SEEK LEFT( cHbl + SPACE(20), 20 )
IF ! FOUND()
APPEND BLANK
ELSE
cUsa1 := rca->usa
cObl1 := rca->obltype
ENDIF
DO WHILE (.T.)
IF rca->( rlock() )
rca->shipname := cShipname
rca->shipadd1 := cShipadd1
rca->shipadd2 := cShipadd2
rca->shipadd3 := cShipadd3
rca->shipadd4 := cShipadd4
rca->consname := cConsname
rca->consadd1 := cConsadd1
rca->consadd2 := cConsadd2
rca->consadd3 := cConsadd3
rca->consadd4 := cConsadd4
rca->notiname := cNotiname
rca->notiadd1 := cNotiadd1
rca->notiadd2 := cNotiadd2
rca->notiadd3 := cNotiadd3
rca->notiadd4 := cNotiadd4
rca->mode := "O"
rca->trans := "E"
rca->svc := cSvc
rca->ref := cRef
rca->master := cMbl
rca->house := cHbl
rca->booking := cBkg
rca->orgcd := cRcptcd
rca->origin := cRcpt
rca->polcd := cPolcd
rca->pol := cPol
rca->poulcd := cPoulcd
rca->poul := cPoul
rca->destcd := cDstcd
rca->dest := cDest
rca->plccd := cDstcd
rca->plc_delv := cDest
rca->carrier := cCarrier
rca->vessel := cVessel
rca->voyage := cVoy
rca->comm := cComm
rca->pcs := VAL( cPcs )
rca->pkg := cPkg
rca->kgs := VAL( cKgs )
rca->cm := VAL( cCbm )
rca->etd := CTOD( cEtd )
rca->eta := CTOD( cEta )
rca->date := DATE()
rca->time := TIME()
rca->serial := cRef
rca->overseas := cOverseas
rca->usa := cUsa
rca->week := cWk
rca->sono := cSoNo
rca->obltype := cObtype
rca->door := cDoor
rca->blform := cBlform
rca->sales1 := cSales
rca->docdate := CTOD( cDocdate )
rca->lastdate := DATE()
rca->lasttime := LEFT(TIME(),5)
// USA Destination changes...
IF ! EMPTY( cUsa1 )
IF ! ( ALLTRIM( cUsa1 ) == ALLTRIM( cUsa ) )
rca->manifest := ""
rca->file := ""
rca->usaold := cUsa1
rca->usadate := DATE()
rca->usatime := TIME()
rca->prthd := CTOD( " / / " )
rca->prtmd := CTOD( " / / " )
rca->prtfd := CTOD( " / / " )
rca->prtid := CTOD( " / / " )
lEmail := .T.
lDest := .T.
ENDIF
ENDIF
IF ! EMPTY( cObl1 )
IF ( ALLTRIM( cObl1 )$"3S" ) .AND. ( ALLTRIM(cObtype)="0" )
rca->obltypeold := cObl1
rca->obltypedte := DATE()
rca->obltypetme := TIME()
lEmail := .T.
lObl := .T.
ENDIF
ENDIF
rca->( dbunlock() )
EXIT
ENDIF
ENDDO
rca->( dbcommit() )
// Email...
IF lEmail
DO CASE
CASE lDest .AND. lObl
cSubject := "Apex_CTS_destination_station_change_AND_telex_release_notification"
CASE lDest
cSubject := "Apex_CTS_destination_station_change"
CASE lObl
cSubject := "Apex_CTS_telex_release_notification"
ENDCASE
// Init...
cTo := 'info@cdmsoft.com'
cCClist := "<darrell.ortiz@cdmsoft.com>"
cMsg := LEFT( "EMAIL TO" + SPACE(20), 20 ) + " : " + cTo + cEol
cMsg += LEFT( "EMAIL CC" + SPACE(20), 20 ) + " : " + cCClist + cEol
cMsg += LEFT( "ORIGIN STATION" + SPACE(20), 20 ) + " : " + cOverseas + cEol
cMsg += LEFT( "OLD USA STATION" + SPACE(20), 20 ) + " : " + cUsa1 + cEol
cMsg += LEFT( "NEW USA STATION" + SPACE(20), 20 ) + " : " + cUsa + cEol
cMsg += LEFT( "APEX HBL" + SPACE(20), 20 ) + " : " + cHbl + cEol
cMsg += LEFT( "MBL" + SPACE(20), 20 ) + " : " + cMbl + cEol
cMsg += LEFT( "CARRIER" + SPACE(20), 20 ) + " : " + cCarrier + cEol
cMsg += LEFT( "VESSEL" + SPACE(20), 20 ) + " : " + cVessel + cEol
cMsg += LEFT( "VOYAGE" + SPACE(20), 20 ) + " : " + cVoy + cEol
cMsg += LEFT( "ETD" + SPACE(20), 20 ) + " : " + cEtd + cEol
cMsg += LEFT( "PORT OF LOADING" + SPACE(20), 20 ) + " : " + cPol + cEol
cMsg += LEFT( "PORT OF DISCHARGE" + SPACE(20), 20 ) + " : " + cPoul + cEol
cMsg += LEFT( "ETA" + SPACE(20), 20 ) + " : " + cEta + cEol
cMsg += LEFT( "FINAL DESTINATION" + SPACE(20), 20 ) + " : " + cDest + cEol
cMsg += LEFT( "SHIPPER" + SPACE(20), 20 ) + " : " + cShipname + cEol
cMsg += LEFT( "CONSIGNEE" + SPACE(20), 20 ) + " : " + cConsname + cEol
cMsg += LEFT( "OBL TYPE" + SPACE(20), 20 ) + " : " + cObtype + cEol
// Create file...
cMsgfile = ALLTRIM(cHbl)+".TXT"
hCts = FCREATE( cMsgfile, 0)
FWRITE( hCts, cMsg )
FCLOSE( hCts )
// Send email...
IF ! EMPTY( cTo )
cCmd := "mailer " + cFrom + ' ' + cTo + ' ' + cSubject + ' ' + cMsgfile + ' ' + cCClist
WaitRun( cCmd, 2 )
ENDIF
ENDIF
cSay := "Resetting RCACTNR " + cOverseas + " - " + cHbl + " . . ."
oSay:Refresh()
SysRefresh()
// RCACTNR...
SELECT rcactnr
SET ORDER TO TAG S1
GO TOP
SEEK rca->serial
IF FOUND()
DO WHILE ! EOF() .AND. ( rca->serial == rcactnr->serial )
DO WHILE (.T.)
IF rcactnr->( rlock() )
rcactnr->code := SPACE(1)
rcactnr->( dbunlock() )
EXIT
ENDIF
ENDDO
SELECT rcactnr
SKIP
ENDDO
ENDIF
cSay := "Resetting RCAPO " + cOverseas + " - " + cHbl + " . . ."
oSay:Refresh()
SysRefresh()
// RCAPO...
DO WHILE (.T.)
SELECT rcapo
SET ORDER TO TAG S1
GO TOP
SEEK rca->serial
IF FOUND()
DO WHILE (.T.)
IF rcapo->( rlock() )
rcapo->( dbdelete() )
rcapo->( dbunlock() )
EXIT
ENDIF
ENDDO
ELSE
EXIT
ENDIF
ENDDO
// Container...
FOR nC=1 TO nCtnr
// Init...
cCC := aCtnr[nC]
nCC := 0
cTT := ""
AFILL( aCC, "" )
FOR nC1=1 TO LEN(cCC)
cChar := SUBSTR( cCC, nC1, 1 )
IF cChar="*" .OR. ( nC1 = LEN(cCC) )
IF (nCC<9)
IF ( nC1 = LEN(cCC) )
cTT += cChar
ENDIF
nCC++
aCC[nCC] := cTT
ENDIF
cTT := ""
ELSE
cTT += cChar
ENDIF
NEXT nC1
cSay := "Uploading RCACTNR " + cOverseas + " - " + cHbl + " . . ."
oSay:Refresh()
SysRefresh()
// Update...
SELECT rcactnr
SET ORDER TO TAG S1
GO TOP
SEEK LEFT( cRef + SPACE(10), 10) + LEFT( aCC[01] + SPACE(15), 15 )
IF ! FOUND()
APPEND BLANK
ENDIF
DO WHILE (.T.)
IF rcactnr->( rlock() )
rcactnr->serial := cRef
rcactnr->ctnr := aCC[01]
rcactnr->size := aCC[02]
rcactnr->seal := aCC[03]
rcactnr->pcs := VAL(aCC[04])
rcactnr->uom := aCC[05]
rcactnr->svc := aCC[06]
rcactnr->kgs := VAL(aCC[07])
rcactnr->cbm := VAL(aCC[08])
rcactnr->packmemo := aCC[09]
rcactnr->code := "U"
rcactnr->( dbunlock() )
EXIT
ENDIF
ENDDO
rcactnr->( dbcommit() )
NEXT nC
// Remove Non-Updated containers...
DO WHILE (.T.)
SELECT rcactnr
SET ORDER TO TAG S2
GO TOP
SEEK rca->serial + SPACE(1)
IF FOUND()
DO WHILE (.T.)
IF rcactnr->( rlock() )
rcactnr->( dbdelete() )
rcactnr->( dbunlock() )
EXIT
ENDIF
ENDDO
ELSE
EXIT
ENDIF
ENDDO
// Purchase Orders...
FOR nP=1 TO nPo
// Init...
cCC := aPo[nP]
nCC := 0
cTT := ""
AFILL( aCC, "" )
FOR nC1=1 TO LEN(cCC)
cChar := SUBSTR( cCC, nC1, 1 )
IF cChar="*" .OR. ( nC1 = LEN(cCC) )
IF ( nC1 = LEN(cCC) )
cTT += cChar
ENDIF
nCC++
aCC[nCC] := cTT
cTT := ""
ELSE
cTT += cChar
ENDIF
NEXT nC1
cSay := "Uploading RCAPO " + cOverseas + " - " + cHbl + " . . ."
oSay:Refresh()
SysRefresh()
// Update...
SELECT rcapo
SET ORDER TO TAG S1
GO TOP
SEEK LEFT( cRef + SPACE(10), 10) + LEFT( aCC[01] + SPACE(35), 35 ) + LEFT( aCC[02] + SPACE(35), 35 ) + LEFT( aCC[04] + SPACE(15), 15 )
IF ! FOUND()
APPEND BLANK
ENDIF
DO WHILE (.T.)
IF rcapo->( rlock() )
rcapo->serial := cRef
rcapo->ponum := aCC[01]
rcapo->invoice := aCC[02]
rcapo->item := aCC[03]
rcapo->ctnr := aCC[04]
rcapo->( dbunlock() )
EXIT
ENDIF
ENDDO
rcapo->( dbcommit() )
NEXT nP
// Init...
cOverseas := ""
cUsa := ""
cProfile := ""
cShipname := ""
cShipadd1 := ""
cShipadd2 := ""
cShipadd3 := ""
cShipadd4 := ""
cSvc := ""
cRef := ""
cMbl := ""
cHbl := ""
cBkg := ""
cConsname := ""
cConsadd1 := ""
cConsadd2 := ""
cConsadd3 := ""
cConsadd4 := ""
cNotiname := ""
cNotiadd1 := ""
cNotiadd2 := ""
cNotiadd3 := ""
cNotiadd4 := ""
cRcptcd := ""
cRcpt := ""
cPolcd := ""
cPol := ""
cPoulcd := ""
cPoul := ""
cDstcd := ""
cDest := ""
cCarrier := ""
cVessel := ""
cVoy := ""
cComm := ""
cPcs := ""
cPkg := ""
cKgs := ""
cCbm := ""
cEtd := ""
cDocdate := ""
cEta := ""
cWk := ""
cSoNo := ""
cObtype := ""
cDoor := ""
cBlform := ""
cSales := ""
nCtnr := 0
nPo := 0
lStart := .F.
AFILL( aCtnr, "" )
AFILL( aPo , "" )
ENDIF
ENDDO
// Close...
FCLOSE( hCTS )
FCLOSE( hLog )
DO WHILE ! lEof
// Init...
cLine := ""
// Read...
Ureadln( hCTS, @cLine, 1, @lEof )
// Criteria...
IF EMPTY( cLine )
LOOP
ENDIF
nLine++
// Log...
cDat := cCTS + " EOF = " + IF(lEof,"YES","NO") + " = " + LTRIM(TRANSF(nLine,"999,999")) + cEol
FWRITE( hLog, cDat )
// Tag...
cTag := UPPER( LEFT( cLine, AT("*",cLine)-1 ) )
cValue := UPPER( SUBSTR( cLine, AT("*",cLine)+1 ) )
DO CASE
CASE ( cTag == "OVERSEAS" )
cOverseas := cValue
CASE ( cTag == "USA" )
cUsa := cValue
CASE ( cTag == "PROFILE" )
cProfile := cValue
CASE ( cTag == "SHIPNAME" )
cShipname := cValue
CASE ( cTag == "SHIPADD1" )
cShipadd1 := cValue
CASE ( cTag == "SHIPADD2" )
cShipadd2 := cValue
CASE ( cTag == "SHIPADD3" )
cShipadd3 := cValue
CASE ( cTag == "SHIPADD4" )
cShipadd4 := cValue
CASE ( cTag == "SVC" )
cSvc := cValue
CASE ( cTag == "REF" )
cRef := cValue
CASE ( cTag == "MBL" )
cMbl := cValue
CASE ( cTag == "HBL" )
cHbl := cValue
CASE ( cTag == "BKG" )
cBkg := cValue
CASE ( cTag == "CONSNAME" )
cConsname := cValue
CASE ( cTag == "CONSADD1" )
cConsadd1 := cValue
CASE ( cTag == "CONSADD2" )
cConsadd2 := cValue
CASE ( cTag == "CONSADD3" )
cConsadd3 := cValue
CASE ( cTag == "CONSADD4" )
cConsadd4 := cValue
CASE ( cTag == "NOTINAME" )
cNotiname := cValue
CASE ( cTag == "NOTIADD1" )
cNotiadd1 := cValue
CASE ( cTag == "NOTIADD2" )
cNotiadd2 := cValue
CASE ( cTag == "NOTIADD3" )
cNotiadd3 := cValue
CASE ( cTag == "NOTIADD4" )
cNotiadd4 := cValue
CASE ( cTag = "RCPTCD" )
cRcptcd := cValue
CASE ( cTag == "RCPT" )
cRcpt := cValue
CASE ( cTag == "POLCD" )
cPolcd := cValue
CASE ( cTag == "POL" )
cPol := cValue
CASE ( cTag == "POULCD" )
cPoulcd := cValue
CASE ( cTag == "POUL" )
cPoul := cValue
CASE ( cTag == "DSTCD" )
cDstcd := cValue
CASE ( cTag == "DEST" )
cDest := cValue
CASE ( cTag == "CARRIER" )
cCarrier := cValue
CASE ( cTag == "VESSEL" )
cVessel := cValue
CASE ( cTag == "VOY" )
cVoy := cValue
CASE ( cTag == "COMM" )
cComm := cValue
CASE ( cTag == "PCS" )
cPcs := cValue
CASE ( cTag == "PKG" )
cPkg := cValue
CASE ( cTag == "KGS" )
cKgs := cValue
CASE ( cTag == "CBM" )
cCbm := cValue
CASE ( cTag == "ETD" )
cEtd := cValue
CASE ( cTag == "ETA" )
cEta := cValue
CASE ( cTag == "WK" )
cWk := cValue
CASE ( cTag == "SONO" )
cSoNo := cValue
CASE ( cTag == "OBL" )
cObtype := cValue
CASE ( cTag == "DOOR" )
cDoor := cValue
CASE ( cTag == "BLFORM" )
cBlform := cValue
CASE ( cTag == "SALES" )
cSales := cValue
CASE ( cTag == "DOCDATE" )
cDocdate := cValue
CASE ( cTag == "CTNR" )
nCtnr++
aCtnr[nCtnr] := cValue
CASE ( cTag == "PONO" )
nPo++
aPo[nPo] := cValue
CASE ( cTag == "END" )
lStart := .T.
ENDCASE
// Update...
IF lStart
// Init...
lProcess := .T.
lEmail := .F.
lDest := .F.
cUsa1 := ""
lObl := .F.
cObl1 := ""
cTo := ""
cCClist := ""
cSubject := "Apex_CTS_destination_station_change"
cSay := "Uploading RCA " + cOverseas + " - " + cHbl + " . . ."
oSay:Refresh()
SysRefresh()
SELECT rca
SET ORDER TO TAG S5
GO TOP
SEEK LEFT( cHbl + SPACE(20), 20 )
IF ! FOUND()
APPEND BLANK
ELSE
cUsa1 := rca->usa
cObl1 := rca->obltype
ENDIF
DO WHILE (.T.)
IF rca->( rlock() )
rca->shipname := cShipname
rca->shipadd1 := cShipadd1
rca->shipadd2 := cShipadd2
rca->shipadd3 := cShipadd3
rca->shipadd4 := cShipadd4
rca->consname := cConsname
rca->consadd1 := cConsadd1
rca->consadd2 := cConsadd2
rca->consadd3 := cConsadd3
rca->consadd4 := cConsadd4
rca->notiname := cNotiname
rca->notiadd1 := cNotiadd1
rca->notiadd2 := cNotiadd2
rca->notiadd3 := cNotiadd3
rca->notiadd4 := cNotiadd4
rca->mode := "O"
rca->trans := "E"
rca->svc := cSvc
rca->ref := cRef
rca->master := cMbl
rca->house := cHbl
rca->booking := cBkg
rca->orgcd := cRcptcd
rca->origin := cRcpt
rca->polcd := cPolcd
rca->pol := cPol
rca->poulcd := cPoulcd
rca->poul := cPoul
rca->destcd := cDstcd
rca->dest := cDest
rca->plccd := cDstcd
rca->plc_delv := cDest
rca->carrier := cCarrier
rca->vessel := cVessel
rca->voyage := cVoy
rca->comm := cComm
rca->pcs := VAL( cPcs )
rca->pkg := cPkg
rca->kgs := VAL( cKgs )
rca->cm := VAL( cCbm )
rca->etd := CTOD( cEtd )
rca->eta := CTOD( cEta )
rca->date := DATE()
rca->time := TIME()
rca->serial := cRef
rca->overseas := cOverseas
rca->usa := cUsa
rca->week := cWk
rca->sono := cSoNo
rca->obltype := cObtype
rca->door := cDoor
rca->blform := cBlform
rca->sales1 := cSales
rca->docdate := CTOD( cDocdate )
rca->lastdate := DATE()
rca->lasttime := LEFT(TIME(),5)
// USA Destination changes...
IF ! EMPTY( cUsa1 )
IF ! ( ALLTRIM( cUsa1 ) == ALLTRIM( cUsa ) )
rca->manifest := ""
rca->file := ""
rca->usaold := cUsa1
rca->usadate := DATE()
rca->usatime := TIME()
rca->prthd := CTOD( " / / " )
rca->prtmd := CTOD( " / / " )
rca->prtfd := CTOD( " / / " )
rca->prtid := CTOD( " / / " )
lEmail := .T.
lDest := .T.
ENDIF
ENDIF
IF ! EMPTY( cObl1 )
IF ( ALLTRIM( cObl1 )$"3S" ) .AND. ( ALLTRIM(cObtype)="0" )
rca->obltypeold := cObl1
rca->obltypedte := DATE()
rca->obltypetme := TIME()
lEmail := .T.
lObl := .T.
ENDIF
ENDIF
rca->( dbunlock() )
EXIT
ENDIF
ENDDO
rca->( dbcommit() )
// Email...
IF lEmail
DO CASE
CASE lDest .AND. lObl
cSubject := "Apex_CTS_destination_station_change_AND_telex_release_notification"
CASE lDest
cSubject := "Apex_CTS_destination_station_change"
CASE lObl
cSubject := "Apex_CTS_telex_release_notification"
ENDCASE
// Init...
cTo := 'info@cdmsoft.com'
cCClist := "<darrell.ortiz@cdmsoft.com>"
cMsg := LEFT( "EMAIL TO" + SPACE(20), 20 ) + " : " + cTo + cEol
cMsg += LEFT( "EMAIL CC" + SPACE(20), 20 ) + " : " + cCClist + cEol
cMsg += LEFT( "ORIGIN STATION" + SPACE(20), 20 ) + " : " + cOverseas + cEol
cMsg += LEFT( "OLD USA STATION" + SPACE(20), 20 ) + " : " + cUsa1 + cEol
cMsg += LEFT( "NEW USA STATION" + SPACE(20), 20 ) + " : " + cUsa + cEol
cMsg += LEFT( "APEX HBL" + SPACE(20), 20 ) + " : " + cHbl + cEol
cMsg += LEFT( "MBL" + SPACE(20), 20 ) + " : " + cMbl + cEol
cMsg += LEFT( "CARRIER" + SPACE(20), 20 ) + " : " + cCarrier + cEol
cMsg += LEFT( "VESSEL" + SPACE(20), 20 ) + " : " + cVessel + cEol
cMsg += LEFT( "VOYAGE" + SPACE(20), 20 ) + " : " + cVoy + cEol
cMsg += LEFT( "ETD" + SPACE(20), 20 ) + " : " + cEtd + cEol
cMsg += LEFT( "PORT OF LOADING" + SPACE(20), 20 ) + " : " + cPol + cEol
cMsg += LEFT( "PORT OF DISCHARGE" + SPACE(20), 20 ) + " : " + cPoul + cEol
cMsg += LEFT( "ETA" + SPACE(20), 20 ) + " : " + cEta + cEol
cMsg += LEFT( "FINAL DESTINATION" + SPACE(20), 20 ) + " : " + cDest + cEol
cMsg += LEFT( "SHIPPER" + SPACE(20), 20 ) + " : " + cShipname + cEol
cMsg += LEFT( "CONSIGNEE" + SPACE(20), 20 ) + " : " + cConsname + cEol
cMsg += LEFT( "OBL TYPE" + SPACE(20), 20 ) + " : " + cObtype + cEol
// Create file...
cMsgfile = ALLTRIM(cHbl)+".TXT"
hCts = FCREATE( cMsgfile, 0)
FWRITE( hCts, cMsg )
FCLOSE( hCts )
// Send email...
IF ! EMPTY( cTo )
cCmd := "mailer " + cFrom + ' ' + cTo + ' ' + cSubject + ' ' + cMsgfile + ' ' + cCClist
WaitRun( cCmd, 2 )
ENDIF
ENDIF
cSay := "Resetting RCACTNR " + cOverseas + " - " + cHbl + " . . ."
oSay:Refresh()
SysRefresh()
// RCACTNR...
SELECT rcactnr
SET ORDER TO TAG S1
GO TOP
SEEK rca->serial
IF FOUND()
DO WHILE ! EOF() .AND. ( rca->serial == rcactnr->serial )
DO WHILE (.T.)
IF rcactnr->( rlock() )
rcactnr->code := SPACE(1)
rcactnr->( dbunlock() )
EXIT
ENDIF
ENDDO
SELECT rcactnr
SKIP
ENDDO
ENDIF
cSay := "Resetting RCAPO " + cOverseas + " - " + cHbl + " . . ."
oSay:Refresh()
SysRefresh()
// RCAPO...
DO WHILE (.T.)
SELECT rcapo
SET ORDER TO TAG S1
GO TOP
SEEK rca->serial
IF FOUND()
DO WHILE (.T.)
IF rcapo->( rlock() )
rcapo->( dbdelete() )
rcapo->( dbunlock() )
EXIT
ENDIF
ENDDO
ELSE
EXIT
ENDIF
ENDDO
// Container...
FOR nC=1 TO nCtnr
// Init...
cCC := aCtnr[nC]
nCC := 0
cTT := ""
AFILL( aCC, "" )
FOR nC1=1 TO LEN(cCC)
cChar := SUBSTR( cCC, nC1, 1 )
IF cChar="*" .OR. ( nC1 = LEN(cCC) )
IF (nCC<9)
IF ( nC1 = LEN(cCC) )
cTT += cChar
ENDIF
nCC++
aCC[nCC] := cTT
ENDIF
cTT := ""
ELSE
cTT += cChar
ENDIF
NEXT nC1
cSay := "Uploading RCACTNR " + cOverseas + " - " + cHbl + " . . ."
oSay:Refresh()
SysRefresh()
// Update...
SELECT rcactnr
SET ORDER TO TAG S1
GO TOP
SEEK LEFT( cRef + SPACE(10), 10) + LEFT( aCC[01] + SPACE(15), 15 )
IF ! FOUND()
APPEND BLANK
ENDIF
DO WHILE (.T.)
IF rcactnr->( rlock() )
rcactnr->serial := cRef
rcactnr->ctnr := aCC[01]
rcactnr->size := aCC[02]
rcactnr->seal := aCC[03]
rcactnr->pcs := VAL(aCC[04])
rcactnr->uom := aCC[05]
rcactnr->svc := aCC[06]
rcactnr->kgs := VAL(aCC[07])
rcactnr->cbm := VAL(aCC[08])
rcactnr->packmemo := aCC[09]
rcactnr->code := "U"
rcactnr->( dbunlock() )
EXIT
ENDIF
ENDDO
rcactnr->( dbcommit() )
NEXT nC
// Remove Non-Updated containers...
DO WHILE (.T.)
SELECT rcactnr
SET ORDER TO TAG S2
GO TOP
SEEK rca->serial + SPACE(1)
IF FOUND()
DO WHILE (.T.)
IF rcactnr->( rlock() )
rcactnr->( dbdelete() )
rcactnr->( dbunlock() )
EXIT
ENDIF
ENDDO
ELSE
EXIT
ENDIF
ENDDO
// Purchase Orders...
FOR nP=1 TO nPo
// Init...
cCC := aPo[nP]
nCC := 0
cTT := ""
AFILL( aCC, "" )
FOR nC1=1 TO LEN(cCC)
cChar := SUBSTR( cCC, nC1, 1 )
IF cChar="*" .OR. ( nC1 = LEN(cCC) )
IF ( nC1 = LEN(cCC) )
cTT += cChar
ENDIF
nCC++
aCC[nCC] := cTT
cTT := ""
ELSE
cTT += cChar
ENDIF
NEXT nC1
cSay := "Uploading RCAPO " + cOverseas + " - " + cHbl + " . . ."
oSay:Refresh()
SysRefresh()
// Update...
SELECT rcapo
SET ORDER TO TAG S1
GO TOP
SEEK LEFT( cRef + SPACE(10), 10) + LEFT( aCC[01] + SPACE(35), 35 ) + LEFT( aCC[02] + SPACE(35), 35 ) + LEFT( aCC[04] + SPACE(15), 15 )
IF ! FOUND()
APPEND BLANK
ENDIF
DO WHILE (.T.)
IF rcapo->( rlock() )
rcapo->serial := cRef
rcapo->ponum := aCC[01]
rcapo->invoice := aCC[02]
rcapo->item := aCC[03]
rcapo->ctnr := aCC[04]
rcapo->( dbunlock() )
EXIT
ENDIF
ENDDO
rcapo->( dbcommit() )
NEXT nP
// Init...
cOverseas := ""
cUsa := ""
cProfile := ""
cShipname := ""
cShipadd1 := ""
cShipadd2 := ""
cShipadd3 := ""
cShipadd4 := ""
cSvc := ""
cRef := ""
cMbl := ""
cHbl := ""
cBkg := ""
cConsname := ""
cConsadd1 := ""
cConsadd2 := ""
cConsadd3 := ""
cConsadd4 := ""
cNotiname := ""
cNotiadd1 := ""
cNotiadd2 := ""
cNotiadd3 := ""
cNotiadd4 := ""
cRcptcd := ""
cRcpt := ""
cPolcd := ""
cPol := ""
cPoulcd := ""
cPoul := ""
cDstcd := ""
cDest := ""
cCarrier := ""
cVessel := ""
cVoy := ""
cComm := ""
cPcs := ""
cPkg := ""
cKgs := ""
cCbm := ""
cEtd := ""
cDocdate := ""
cEta := ""
cWk := ""
cSoNo := ""
cObtype := ""
cDoor := ""
cBlform := ""
cSales := ""
nCtnr := 0
nPo := 0
lStart := .F.
AFILL( aCtnr, "" )
AFILL( aPo , "" )
ENDIF
ENDDO
// Close...
FCLOSE( hCTS )
FCLOSE( hLog )