"The Module Code is Required" IM_PhysicalCountWrkst_rpt nSetKey()

SOLVED

I'm trying to script against IM_PhysicalCountWrkst_rpt but keep getting "The Module Code is Required" when calling nSetKey(). Script sample is below. We are running 5.10.4.0. Anyone have any suggestions on what to try?

Const HKEY_CURRENT_USER = &H80000001
Set oReg = GetObject("winmgmts:\\.\root\default:StdRegProv")
oReg.GetExpandedStringValue HKEY_CURRENT_USER,"Software\Sage Software\MAS 90 Business Desktop\Settings","MAS90RootDirectory",PathRoot
PathHome = PathRoot & "\Home"
Set oReg = Nothing

Set oScript = CreateObject ("ProvideX.Script")
oScript.Init(PathHome)
Set oSS = oScript.NewObject("SY_Session")

retVAL = oSS.nLogon()
If retVAL = 0 Then
 ShowError "Logon", oSS.sLastErrorMsg
End If

retVAL = oSS.nSetCompany("TST", 1)
If retVAL = 0 Then
 ShowError "SetCompany", oSS.sLastErrorMsg
End If

retVAL = oSS.nSetDate("I/M","20150128")
If retVAL = 0 Then
 ShowError "SetDate", oSS.sLastErrorMsg
End If

retVAL = oSS.nSetModule("I/M")
If retVAL = 0 Then
 ShowError "SetModule", oSS.sLastErrorMsg
End If

retVAL = oSS.nSetProgram(oSS.nLookupTask("IM_PhysicalCountWrkst_ui"))
If retVAL = 0 Then
 ShowError "SetProgram", oSS.sLastErrorMsg
End If

Set oPhysCount = oScript.NewObject("IM_PhysicalCountWrkst_rpt", oSS)

retVAL = oPhysCount.nSelectReportSetting("STANDARD")
If retVAL = 0 Then
 ShowError "SelectReportSetting", oPhysCount.sLastErrorMsg
End If

retVAL = oPhysCount.nSetKeyValue("ReportSetting$", "STANDARD")
If retVAL = 0 Then
 ShowError "SetKeyValue, ReportSetting$", oPhysCount.sLastErrorMsg
End If

retVAL = oPhysCount.nSetKeyValue("RowKey$", "1")
If retVAL = 0 Then
 ShowError "SetKeyValue, RowKey$", oPhysCount.sLastErrorMsg
End If

strOp = ""
retVAL = oPhysCount.nGetOptions(strOp)
If retVAL = 0 Then
 ShowError "GetOptions", oPhysCount.sLastErrorMsg
End If

retVAL = oPhysCount.nSetKey()  ' <-- Error here: "The Module Code is Required."
If retVAL = 0 Then
 ShowError "SetKey", oPhysCount.sLastErrorMsg
End If

'
'
'

Cleanup

Sub Cleanup
 If IsObject(oPhysCount) Then
  oPhysCount.DropObject()
 End If

 oSS.nCleanup()
 oSS.DropObject()
 Set oPhysCount = Nothing
 Set oSS = Nothing
 Set oScript = Nothing
End Sub

Sub ShowError(sOperation, sMessage)
 MsgBox "Error (" + sOperation + "): " + sMessage
 Cleanup 
 WScript.Quit
End Sub

 

Parents
  • 0
    verified answer

    Hi,

    To show the pertinent error for the SetKey() you should be using the oPhysCount object and not the session object.

    ShowError "SetKey", oPhysCount.sLastErrorMsg

    This will hopefully, give you a better idea as to the real error.

    After reviewing this, you should set the ModuleCode and the ReportID$ as well.  So add before you do the SetKey() the following:

    retVAL = oPhysCount.nSetKeyValue("ModuleCode$", "I/M")

    If retVAL = 0 Then

       ShowError "SetKeyValue, ModuleCode$", oPhysCount.sLastErrorMsg

    End If

    retVal = oPhysicalCount.nSetKeyValue("ReportID$", "IM_PhysicalCountWrkst_ui")

    If retVAL = 0 Then

       ShowError "SetKeyValue, ReportID$", oPhysCount.sLastErrorMsg

    End If

    Hope this helps

    Elliott

  • 0 in reply to jepritch

    Good catch. Haven't done anything with scripts in a while. The error is "The Module Code is Required"

Reply Children