Sample No. 1 Select CVdtl set order to CVnoacct =Seek(lcDocNumb) IF FOUND() DO while CV_no=lcDocNumb .and. .not. EOF() IIF .not. DELETED() lnSLDBAmt = lnSLDBAmt + SLDebit lnSLCRAmt = lnSLCRAmt + SLCredit lnGLDBAmt = lnGLDBAmt + GLDebit lnGLCRAmt = lnGLCRAmt + GLCredit Endif skip enddo ENDIF Sample No. 2 SELECT SUM(A.SLDebit) as lnSLDBAmt, SUM(SLCredit) as lnSLCRAmt, SUM(GLCredit) as lnGLCRAmt, SUM(GLDebit) as lnGLDBAmt; FROM CVdtl A WHERE A.CV_no=lcDocNumb .and. .not. DELETED() INTO CURSOR Temp1 GROUP BY A.CV_no Sample No. 3 Select CVdtl set order to CVnoacct SCAN FOR CV_no=lcDocNumb IF .not. DELETED() lnSLDBAmt = lnSLDBAmt + SLDebit lnSLCRAmt = lnSLCRAmt + SLCredit lnGLDBAmt = lnGLDBAmt + GLDebit lnGLCRAmt = lnGLCRAmt + GLCredit Endif ENDSCANThanks