Quantcast
Channel: Vishy
Viewing all articles
Browse latest Browse all 27

Unable to cast CustVendTransOpen to VendTransOpen at method CheckPWPEnabled

$
0
0

I was trying to create a general journal with vendor payments and settle open Vendor transactions. When the code was run manually it worked fine. However when we ran the job in a batch mode it failed with the error “Unable to cast CustVendTransOpen to VendTransOpen. This just did not make sense, so i dug through the code and realized that the error was thrown at this line

CustVendOpenTransManager::UpdateTransMarked method
if (isConfigurationkeyEnabled(configurationKeyNum(PSAPwp)) && (_custVendTransOpen.TableId == tableNum(VendTransOpen)))
{
if (_custVendTransOpen.checkPwpEnabled(_custVendTransOpen)) <<——-
……

Seems strange that _custVendTransOpen.TableId == tableNum(VendTransOpen) is true but we still get this error. Following is the signature of the method checkPwpEnabled of the table VendTransOpen:
public boolean checkPwpEnabled(VendTransOpen _custVendTransOpen)
If we call this code in a non-batch mode, then it runs fine, however when we run it in batch mode, i believe that this method is called through reflection. During the process of reflection something obviously has gone wrong and during deserialization of the parameters, the reflection code is not able to cast the value from CustVendTransOpen to VendTransOpen. To get around this i found every single occurrence of this method in code and passed in explicitly a local variable which is already cast to VendTransOpen. Basically as follows
VendTransOpen vendTransOpenLocal;
if (_custVendTransOpen.TableId == tableNum(VendTransOpen))
{
vendTransOpenLocal = _custVendTransOpen;
}

if (isConfigurationkeyEnabled(configurationKeyNum(PSAPwp)) && (_custVendTransOpen.TableId == tableNum(VendTransOpen)))
{
if (_custVendTransOpen.checkPwpEnabled(vendTransOpenLocal))

This is probably a MS defect, i just fixed it myself for now and will probably go hunting for a hotfix.



Viewing all articles
Browse latest Browse all 27

Trending Articles