Tip on how to pass parameters from C#.Net to Crystal Report Application Server

After a long time spent googling, bing'ing I finally found how to pass parameters from C#.Net to the Crystal Report Application server.

It turned out to be pretty easy.
ReportClientDocument rcd = new ReportClientDocument();

rcd.DataDefController.ParameterFieldController.SetCurrentValue("", "@StartDate", yourDateVariable.ToString() );

rcd.DataDefController.ParameterFieldController.SetCurrentValue("", "@EndDate", yourDateVariable.ToString());

Hope this helps you

Tip on how to compare values in a table before and after change

Quite often, when adding features I have had the need to see if my
feature works fine. If the feature adds new records to a table it is
easy to look at the table and see if it updated the record and the
fields correctly. But if it were to change existing records
(especially in inventory control table) it is hard to see if it
updated the correct record and the fields. Here is a tip on how to use
SQL – Select to do this:

1. Of course, before you start to do this you make a copy of the table
For VFP:
USE <table>
COPY to <temp table> WITH CDX
For SQL:
SELECT * INTO <temp table> FROM <table>
2. Test your feature
3. To compare give
For VFP
SELECT * FROM <table> a1
FULL JOIN <temp table> a2
ON <a1.keyfield1> = <a2.keyfield1> [AND <a1.keyfield2> = <a2.keyfield2>]
WHERE ISNULL(a1.keyfield1) OR ISNULL(a2.keyfield2) OR <a1.field1> <>
<a2.field1> [ OR <a1.field2> <> <a2.field2> …]
For SQL change the where clause to
WHERE a1.keyfield1 IS NULL OR a2.keyfield2 IS NULL OR <a1.field1> <>
<a2.field1> [ OR <a1.field2> <> <a2.field2> …]

The key here is the full join. It will show new entries (or entries
deleted) and the field comparison will list the field(s) you are
interested where they have changed.

Example using Sage Pro for icitem, iciloc, iciqty in VFP
USE prodata!icitem01
COPY TO temp1 WITH cdx
USE prodata!iciloc01
COPY TO temp2 WITH cdx
USE prodata!iciqty01
COPY TO temp3 WITH cdx

- Now I ran my test
After test here is the compare program (Use l_GetFieldString to easily add new fields)

SET DELETED ON
LOCAL lc_SelectList, ;
lc_FieldsWhere

lc_SelectList = ""
lc_FieldsWhere = ""

= l_GetFieldString("ionhand, avgcost", @lc_SelectList, @lc_FieldsWhere)

SELECT a1.item, &lc_SelectList. * FROM prodata!icitem01 a1 ;
full join temp1 a2 ;
ON a1.item = a2.item ;
WHERE ISNULL(a1.item) OR ISNULL(a2.item) &lc_FieldsWhere ;
INTO CURSOR ac_temp1
BROWSE LAST nowait

= l_GetFieldString("lonhand, lavgcst", @lc_SelectList, @lc_FieldsWhere)

SELECT a1.item, a1.loctid, &lc_SelectList. * FROM prodata!iciloc01 a1 ;
full join temp2 a2 ;
ON a1.item = a2.item AND a1.loctid = a2.loctid ;
WHERE ISNULL(a1.item) OR ISNULL(a2.item) &lc_FieldsWhere ;
INTO CURSOR ac_temp2
BROWSE LAST nowait

= l_GetFieldString("qonhand", @lc_SelectList, @lc_FieldsWhere)

SELECT a1.item, a1.loctid, a1.qstore, a1.qserial, &lc_SelectList. * ;
FROM prodata!iciqty01 a1 ;
full join temp3 a2 ;
ON a1.item = a2.item AND a1.qserial = a2.qserial ;
WHERE ISNULL(a1.item) OR ISNULL(a2.item) &lc_FieldsWhere ;
INTO CURSOR ac_temp3
BROWSE LAST nowait

FUNCTION l_GetFieldString

LPARAMETERS pc_FieldList, ;
rc_SelectList, ;
rc_WhereClause, ;
lc_Field

LOCAL ARRAY la_FieldList[1]

= ALINES(la_FieldList, pc_FieldList, 1+4+8, ",")

rc_SelectList = ""
rc_WhereClause = ""

FOR EACH lc_Field IN la_FieldList
rc_SelectList = rc_SelectList + "a1." + lc_Field + ", " + "a2." + lc_Field + ", "
rc_WhereClause = rc_WhereClause + " OR a1." + lc_Field + " <> " + "a2." + lc_Field
NEXT

RETURN

Regards,

Sankaran Raman
(work) 804-364-2995
(cell) 804-658-6321
(fax) 540-301-0794
sankaran@saharti.com
www.saharti.com
Saharti

Tip on quick way to find current form's class library in Sage Pro

Sage Pro uses Formsets for all its MDI forms. When debugging if you want to
find out which classlibrary your form belongs to here is what you can do:
- Ensure the form you want to know is the currently selected one.
- Press Ctrl+F9 (ensure you are running from VFP and have SBTDUTIL=ON).
- In the command window give
       MESSAGEBOX( _screen.ActiveForm.Parent.ClassLibrary)
- It will show the class library the form belongs to.

Further, if you are now interested in seeing when a property changes in that
formset you can give
PUBLIC lo_FormSet
Lo_FormSet = _screen.ActiveForm.Parent

Then in the watch window you can use lo_FormSet.so_FS.sc_Sono (or whatever
property you want to track)
Note: If you use the PUBLIC lo_FormSet, you will not be able to close the
formset w/o releasing the variable. To do this, in the command window give
Release lo_formset before you try to close the form.

Regards,
- Sankaran Raman
804-364-2995
sankaran@saharti.com
www.saharti.com
http://saharti.blogspot.com/

Tip for exiting Pro when you get Close open windows and cannot close

This will work only if you have SBTDUTIL=ON in Windows Environment and running Pro from within VFP

If you are trying to exit Pro and have no form open and Sage Pro still gives “Close Open windows”, press Ctrl+F9 to go the command window and give

go_cop.in_controlcount = 0
RESUME
and now you will be exit Pro.

Sage Pro set focus

Sage Pro sets focus in these following ways in the MDI forms:
1. State object sc_StatechangeSetFocus: This is the normal way by which Sage Pro changes focus when user moves from one "state" aka mode to another. In the design time form, hold your mouse over a state object and then press Ctrl+Shift and then click and VFP will select the state object. In the property sheet look for this property. You can set this to the "registry" name of another object in the form.

2. State object m_StateChangeSetFocus: This method is used instead of the property when the focus needs to be set conditionally.

3. In the FS object code. Search for m_SetFocus() and you most likely will find your code.

If you are interested in learning how to Program with Sage Pro you can buy our DVD. See www.saharti.com for details.

Simplify logging into Sage Pro when developing/debugging

You can use the KEYBOARD command to auto login into Sage Pro and
select an application.

Use the auto login only in a "development/debugging test environment"
as you will lose security.

Here is how (in Sage Pro 7.4:

- This is for auto login
Modify pro.prg and before line 4633 (that calls u_getus) give
** Auto login
KEYBOARD "ADMN{Enter}ADMN{Enter}"

- This is to choose an application at startup
Modify pro.prg and at line 5227 (2 lines after it displays
"Select initial application...." give
** Select Purchase orders
KEYBOARD "{ALT-F}OO"

The above two help you to go to the application w/o having to type
anything once you launch Sage Pro.

Sage Pro debugging during transaction rollback

When debugging Sage Pro during the save and that process is part of a
transaction and it throws a dialog, you cannot hit Ctrl+F9 to go to
the line causing the error. This is even if you have SBTDUTIL=ON.

There is a different windows environment variable that you can use
here. It is called TRANPOS.

In your Windows user settings if you add this variable and set it to
ON then it will break whenever the transaction gets an error. Use this
if you are debugging during transaction rollback

VFP 9 and ICASE

VFP 9 has a new useful function (especially for reports) named ICASE.
This helps where you had to do IIF(...(IIF...(IF now you can do it
using ICASE in a simpler way

Example (you can run it from command prompt):
Before:

FOR ln_count = 1 TO 4
DO CASE
CASE ln_count = 1
gc_cstmeth = "A"
CASE ln_count = 2
gc_cstmeth = "F"
CASE ln_count = 3
gc_cstmeth = "C"
CASE ln_count = 4
gc_cstmeth = " "
ENDCASE

? IIF(gc_cstmeth = "A", "Average", IIF(gc_cstmeth = "F", "FIFO",
IIF(gc_cstmeth = "L", "LIFO", "Not entered")))
NEXT

Now, using ICase
FOR ln_count = 1 TO 4
DO CASE
CASE ln_count = 1
gc_cstmeth = "A"
CASE ln_count = 2
gc_cstmeth = "F"
CASE ln_count = 3
gc_cstmeth = "C"
CASE ln_count = 4
gc_cstmeth = " "
ENDCASE

? ICASE(gc_cstmeth = "A", "Average", gc_cstmeth = "F", "FIFO",
gc_cstmeth = "L", "LIFO", "Not Entered")
NEXT