jolly
VIP Member
Hi All,
I discovered a very useful undocumented JDE API and would like to share this with the group.
Thanks to Mike Maguire and Shannon Moir for this one!
Have you found debug logging (Output=FILE in JDE.INI) to be a drag? It makes your system run like a dog, and produces a ton of output for stuff you aren't interested in. Plus you have to exit and restart OneWorld whenever you want to turn it on or off! Wouldn't it be cool if you could switch it on or off in the middle of a OW session, or even embed a call in your App or UBE to switch it on for a part of your run which is of interest then revert to whatever the original state was when done?
Well here it is! the OW APIused is :
JDERTN (BOOL) JDEWINAPI changeLogSettings (const char *szEntry, BOOL setting);
Pass in "Output" as *szEntry, and 0 or 1 as setting to switch it off or on respectively.
I've written a BSFN to wrap this, and addred in another option to query the current setting using jdeGetPrivateProfileString. Here's the guts of the BSFN. Just paste this into the "Variable Declarations" section of the BSFN skeleton created by OW:
char lpszValue[5];
... and this into the "Main Processing" section:
if (lpDS->cDebuggingOnOrOff == '0')
changeLogSettings("Output", 0);
else if (lpDS->cDebuggingOnOrOff == '1')
changeLogSettings("Output", 1);
else if (lpDS->cDebuggingOnOrOff == '2') {
// inquiry
jdeGetPrivateProfileString( "Debug", "Output", "None", lpszValue, sizeof lpszValue);
if (!strnicmp(lpszValue, "FILE", 4))
lpDS->cDebuggingOnOrOff = '1';
else
lpDS->cDebuggingOnOrOff = '0';
}
You'll also need a corresponding data structure, that just contains an EV01 value called cDebuggingOnOrOff, and paste the TypeDef into the include file for your BSFN.
I also wrote a trivial App to allow user toggling of debug logging at runtime. To do this, just create an App with one fix/inspect form and no Business View. Add a data dictionary item type A301 to display the debugging state, and call it "Display State", and add a push button to toggle the state. Next, add the "Dialog is Initialised event" as follows:
VA evt_DebugFlag_EV01 = "2"
Toggle JDE Debug Logging
VARIABLE <> cDebuggingOnOrOff
If VA frm_DebugFlag_EV01 is equal to "1"
FC Display State = "On"
Else
FC Display State = "Off"
End If
You'll need to add a form level variable frm_DebugFlag_EV01.
And finally, add the following to the Button Pressed event for the Toggle button:
If VA frm_DebugFlag_EV01 is equal to "1"
// was on, switch off
VA frm_DebugFlag_EV01 = "0"
FC Display State = "Off"
Else
// was off, switch on
VA frm_DebugFlag_EV01 = "1"
FC Display State = "On"
End If
Toggle JDE Debug Logging
VA frm_DebugFlag_EV01 -> cDebuggingOnOrOff
That's it. Enjoy!
Cheers,
JohnO
<P ID="edit"><FONT SIZE=-1><EM>Edited by Sef on 1/29/02 05:55 PM.</EM></FONT></P>
I discovered a very useful undocumented JDE API and would like to share this with the group.
Thanks to Mike Maguire and Shannon Moir for this one!
Have you found debug logging (Output=FILE in JDE.INI) to be a drag? It makes your system run like a dog, and produces a ton of output for stuff you aren't interested in. Plus you have to exit and restart OneWorld whenever you want to turn it on or off! Wouldn't it be cool if you could switch it on or off in the middle of a OW session, or even embed a call in your App or UBE to switch it on for a part of your run which is of interest then revert to whatever the original state was when done?
Well here it is! the OW APIused is :
JDERTN (BOOL) JDEWINAPI changeLogSettings (const char *szEntry, BOOL setting);
Pass in "Output" as *szEntry, and 0 or 1 as setting to switch it off or on respectively.
I've written a BSFN to wrap this, and addred in another option to query the current setting using jdeGetPrivateProfileString. Here's the guts of the BSFN. Just paste this into the "Variable Declarations" section of the BSFN skeleton created by OW:
char lpszValue[5];
... and this into the "Main Processing" section:
if (lpDS->cDebuggingOnOrOff == '0')
changeLogSettings("Output", 0);
else if (lpDS->cDebuggingOnOrOff == '1')
changeLogSettings("Output", 1);
else if (lpDS->cDebuggingOnOrOff == '2') {
// inquiry
jdeGetPrivateProfileString( "Debug", "Output", "None", lpszValue, sizeof lpszValue);
if (!strnicmp(lpszValue, "FILE", 4))
lpDS->cDebuggingOnOrOff = '1';
else
lpDS->cDebuggingOnOrOff = '0';
}
You'll also need a corresponding data structure, that just contains an EV01 value called cDebuggingOnOrOff, and paste the TypeDef into the include file for your BSFN.
I also wrote a trivial App to allow user toggling of debug logging at runtime. To do this, just create an App with one fix/inspect form and no Business View. Add a data dictionary item type A301 to display the debugging state, and call it "Display State", and add a push button to toggle the state. Next, add the "Dialog is Initialised event" as follows:
VA evt_DebugFlag_EV01 = "2"
Toggle JDE Debug Logging
VARIABLE <> cDebuggingOnOrOff
If VA frm_DebugFlag_EV01 is equal to "1"
FC Display State = "On"
Else
FC Display State = "Off"
End If
You'll need to add a form level variable frm_DebugFlag_EV01.
And finally, add the following to the Button Pressed event for the Toggle button:
If VA frm_DebugFlag_EV01 is equal to "1"
// was on, switch off
VA frm_DebugFlag_EV01 = "0"
FC Display State = "Off"
Else
// was off, switch on
VA frm_DebugFlag_EV01 = "1"
FC Display State = "On"
End If
Toggle JDE Debug Logging
VA frm_DebugFlag_EV01 -> cDebuggingOnOrOff
That's it. Enjoy!
Cheers,
JohnO
<P ID="edit"><FONT SIZE=-1><EM>Edited by Sef on 1/29/02 05:55 PM.</EM></FONT></P>