// Control Options ctl-opt ActGrp(*Caller) Main(Main); // Display File dcl-f INVOICE01D WorkStn Handler('UNIVERSAL(HANDLER)') UsrOpn; // Data Files dcl-f INHEADERP ExtFile('UNIDEMO/INHEADERP') Keyed UsrOpn; dcl-f INDETAILP ExtFile('UNIDEMO/INDETAILP') Keyed UsrOpn; dcl-f CSMASTERP ExtFile('UNIDEMO/CSMASTERP') Keyed UsrOpn; // Main Procedure Dcl-Proc Main; Open INVOICE01D; Open INHEADERP; Open INDETAILP; Open CSMASTERP; // Get Invoice Number (Query String Parameter) Read HEADER; // Find Invoice Chain Invoice INHEADERR; If Not %Found(); Message = 'Invoice cannot be found.'; Write ERROR; Else; // Get Customer Name from Customer Master CMNAME = ''; Chain HDCMID CSMASTERR; InvDate = %Char(%Date(HDTIME) : *USA); Write HEADER; // Output Detail Records SubTotal = 0; SetLL Invoice INDETAILR; ReadE Invoice INDETAILR; Dow Not %Eof(); Write DETAIL; SubTotal += DTXAMOUNT; ReadE Invoice INDETAILR; EndDo; Total = SubTotal + HDSTAXAMT; Write FOOTER; EndIf; Close INVOICE01D; Close INHEADERP; Close INDETAILP; Close CSMASTERP; End-Proc;