open-insight/LSL2/STPROC/AR_INV_EXP.txt
Infineon\StieberD 7762b129af pre cutover push
2024-09-04 20:33:41 -07:00

108 lines
3.6 KiB
Plaintext

compile function ar_inv_exp(Params,Manual)
declare function msg, dialog_box, fieldcount
declare subroutine rlist,activate_save_select
$insert rlist_equates
$insert logical
$insert invoice_equ
$insert invoice_srl_equ
equ CrLf$ to char(13):char(10)
convert '*' to @fm in Params
FromDate = Params<1>
ThruDate = Params<2>
DosTable = Params<3>
open 'INVOICE' to InvoiceTable else
Void = msg( '', 'Unable to open INVOICE...' )
end
TableToUse = 'INVOICE'
oswrite '' on DosTable
Tstat = status()
if Tstat then
Err = 'Bad operating system filename'
Err<-1> = 'Access Denied'
Err<-1> = 'Disk or Directory full'
Err<-1> = 'Operating system error not defined elsewhere'
Err<-1> = 'Attempt to write a read only file'
Void = msg( '', Err<Tstat> )
return 0
end
osopen DosTable to DosTableVar else
Err = 'Bad operating system filename'
Err<-1> = 'Access Denied'
Err<-1> = 'File does not exist'
Err<-1> = 'Undefined error'
Void = msg( '', Err<status()> )
return 0
end
BytePos = 0
Cmd = "SELECT ":TableToUse:" BY SEQ WITH ENTRY_DATE FROM ":QUOTE(FromDate):" TO ":QUOTE(ThruDate)
rlist( Cmd, target_activelist$, '', '', '' )
*activate_save_select( 'BRYCE' )
*DEBUG
*USED WHEN ERROR DURING THE ENDOFMONTH
NumKeys = @reccount
Cnt = 0
if @reccount then
Cnt = 0
NumKeys = @reccount
Eof = false$
loop
readnext @id else Eof = true$
until Eof
read @record from InvoiceTable, @id else
Void = msg( '', 'Unable to read ':@id:' from ':TableToUse )
return 0
end
SalesTots = xlate( TableToUse, @id, 'GL_ACCT_TOTS', 'X' )
CustName = xlate( TableToUse, @id, 'CUST_NAME', 'X' )
InvoiceAmount = oconv( xlate( TableToUse, @id, 'INVOICE_AMOUNT', 'X' ), 'MD2,$' )
Scnt = fieldcount( SalesTots, @vm )
BlobOut = ''
for i = 1 to Scnt
ThisSalesTotLine = SalesTots<1,i>
ThisSalesTotLine = trim( ThisSalesTotLine )
if len( ThisSalesTotLine ) then
SalesCode = field( ThisSalesTotLine, ' ', 1 )
SalesCodeTot = field( ThisSalesTotLine, ' ', 2 )
swap 'CM' with 'C' in @id ;* DUE TO MAS90
BlobOut := quote(@id):',':quote(CustName):','
*TCustNo = '41'
*TCustNo = ''
*TCustNo := oconv( @record<invoice_cust_no$>, 'R(0)#7' )
BlobOut := quote(@record<invoice_cust_no$>):','
BlobOut := quote(oconv(@record<invoice_entry_date$>, 'D2/')):','
BlobOut := quote(oconv(@record<invoice_due_date$>, 'D2/')):','
BlobOut := quote(@record<invoice_po$>):','
BlobOut := quote(SalesCode):','
BlobOut := quote(SalesCodeTot):','
BlobOut := quote(InvoiceAmount):','
BlobOut := quote(oconv( @record<invoice_discount_amount$>, 'MD2,$' ) )
BlobOut := CrLf$
end
next i
osbwrite BlobOut on DosTableVar AT BytePos
Tstat = status()
if Tstat then
Err = 'Bad operating system filename'
Err<-1> = 'Access Denied'
Err<-1> = 'Disk or directory full'
Err<-1> = 'File does not exist'
Err<-1> = 'Undefined error'
Err<-1> = 'Attempt to write a read only file'
Err<-1> = 'Invalid beginning byte position'
Void = msg( '', Err<Tstat> )
return 0
end
BytePos += len( BlobOut )
Cnt += 1
Percent = oconv( iconv(Cnt/NumKeys, 'MD2'), 'MD0' ):'%'
Void = send_info( Percent:' Complete Exporting...' )
repeat
end else
if Manual then
Void = msg('', "NO Records meeting your date criteria!!")
end
end
osclose DosTableVar
return 0