[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

RE: [sqr-users] Very beginner



1. When a variable has ":" in front, it means that the procedure is going to
change the value of that variable and the new value should be returned to
whereever the procedure was called from.  Without the colon, you could
change the value of a variable in the procedure, but the new value would not
go back to the calling procedure.

2. The "A.PO_ID = $PO_ID" is part of a SQL where clause.  In this context,
it means: only look at rows of the database table where the contents of the
PO_ID field are equal to the value stored in the $PO_ID variable.  In this
case, the field name and variable name are the same, but that's not
required.  The construct "A.PO_ID  &PO_ID" means: take the contents of the
PO_ID field in table A (A is the alias defined in the "FROM" clause) and
store it in the column variable named "&PO_ID".  Again, the field and the
column variable don't have to have the same name, but column variables
always start with ampersands.  If you didn't have the "&PO_ID" on that line,
SQR would put the data in "&A.PO_ID".

3. This procedure doesn't try to send data back through a variable, so the
variables don't need a colon.

4. Step 4 looks like $First-In equals "Y" the first time this procedure is
called.  It performs the tasks within the "true" branch of the "if"
statement, and then sets $First-In to "N" so that future calls to that
procedure will find the "if" test to be false.  Then, when the procedure is
called again, if performs the tasks within the "false" branch of the "if"
statement.  That branch seems to be saying, when the new value of PO_ID is
different from the previous value, print totals and set the variable
$save-po-id to the new value.

Step 5 is printing vendor totals when the vendor changes and then printing
individual vendor data.

-----Original Message-----
From: maria tong [mailto:yh266515@yahoo.com]
Sent: Thursday, February 20, 2003 1:39 PM
To: sqr
Subject: [sqr-users] Very beginner


Sorry I was so goofy and accidently hit the sent
button by mistatke:

I took SQR class a couple of weeks ago and I'm very
much in "fuzzy" state. I'd appreciate very much if
anyone would be willing to explain it to me in plain
English these procedures: 

1. In STEP1,2,3,4: Begin-Procedure
Get-Total-PO-Amt($BUSINESS_UNIT, $PO_ID, :#tot-po-amt)
I remember in class, the instructor said something
about the ":#tot-po-amt", something with the "global"
stuff but I don't remember. Please explain the ":".

2. What is the difference between: A.PO_ID = $PO_ID
and A.PO_ID &PO_ID. 

3. Why is the ":" disappear in STEP3? 

4. STEP4 & STEP5:  I don't understand these steps.

I'd very much appreciate it if you would please
explain it in an easy term and at your convenient
time.

April


!********************** 
STEP1: Begin-Procedure
Get-Total-PO-Amt($BUSINESS_UNIT, $PO_ID, :#tot-po-amt)

begin-select SUM(A.MERCHANDISE_AMT) &A.MERCHANDISE_AMT

Let #tot-po-amt = &A.MERCHANDISE_AMT

FROM PS_PO_LINE_SHIP A

WHERE A.BUSINESS_UNIT = $BUSINESS_UNIT
      AND A.PO_ID = $PO_ID 
end-select 
End-Procedure Get-Total-PO-Amt

!**********************
STEP2: 
Begin-Procedure Get-Total-Invc-Amt($BUSINESS_UNIT,
$PO_ID, :#tot-invc-amt)

begin-select
SUM(A.MERCHANDISE_AMT) &A.MERCHANDISE_AMT 
Let #tot-invc-amt = &A.MERCHANDISE_AMT

FROM PS_VOUCHER_LINE A

WHERE A.BUSINESS_UNIT = $BUSINESS_UNIT
 AND A.PO_ID = $PO_ID 
end-select
End-Procedure Get-Total-Invc-Amt

!**********************
STEP3: 
Begin-Procedure Get-Totals

Do Get-Total-PO-Amt(&A.BUSINESS_UNIT, &A.PO_ID,
#tot-po-amt)
Do Get-Total-Invc-Amt(&A.BUSINESS_UNIT, &A.PO_ID,
#tot-invc-amt)

End-Procedure Get-Totals 

!**********************
STEP4: 
Begin-Procedure Print-Report

If $First-in = 'Y' 
Do Get-totals 
Do Get-Budget-Year
Do print-summary-line

Let $save-po-id = &A.PO_ID
Let $save-vendor-id = &d.vendor_id
Let $first-in = 'N' 

else
   if $save-po-id <> &A.PO_ID
    Do Get-totals
    Do Get-Budget-Year
    Do print-summary-line

    Let $save-po-id = &A.PO_ID
    Let $save-vendor-id = &d.vendor_id
   end-if

end-if
End-Procedure Print-Report

!**********************
STEP5:
Begin-Procedure Print-Summary-Line

if $first-in = 'Y'
 !next sentence
 else 

 if $save-vendor-id <> &d.vendor_id
   print 'Number of POs: ' (+2,65)
   print #po-cnt-subtotal (,85) edit 99,999,999 
   print 'Subtotal: ' (,112)
   print #po-amt-subtotal (,125) edit 99,999,999.99 
   print #invc-amt-subtotal (,158) edit 99,999,999.99 

   print ' ' (+1,1) 

  let #po-cnt-subtotal = 0 
  let #po-amt-subtotal = 0
  let #invc-amt-subtotal = 0 
  end-if
end-if

print $vendor-id (+1,1)
print $budget-year (,114)
print #tot-po-amt (,125) edit 99,999,999.99
print #tot-invc-amt (,158) edit 99,999,999.99

Let #po-cnt-subtotal = #po-cnt-subtotal + 1 
Let #po-amt-subtotal = #po-amt-subtotal + #tot-po-amt 
Let #invc-amt-subtotal = #invc-amt-subtotal +
#tot-invc-amt 
Let #po-cnt-grandtotal = #po-cnt-grandtotal + 1
Let #po-amt-grandtotal = #po-amt-grandtotal +
#tot-po-amt
Let #invc-amt-grandtotal = #invc-amt-grandtotal +
#tot-invc-amt 
End-Procedure Print-Summary-Line

__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/

_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users

_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users