Import into the BM_ComponentReportSelection.M4T!!!!

SOLVED

Is there any way to populate the BM_ComponentReportSelection.M4T  without manually keying it in the Gross Requirements Report?   It is not an available table to import into for Bill of Materials. https://solitaire.onl/ https://9apps.ooo/ https://bluestacks.vip/

  • +1
    verified answer

    You could use a script to get a handle to the BM_ReportBillSelection_bus object and write the records into the table.

    The primary key consists of the BillNo+Revision+BillOption1+BillOption2+BillOption3+BillOption4+BillOption5+BillOption6+BillO
    ption7+BillOption8+BillOption9.

    You can either use SetKey with every part of the key (except the last part) padded to the full length of the field or use SetKeyValue for each field individually followed by a SetKey.

    Then use SetValue on the other fields in the table like QuantityRequired, BillFormat, ComponentWarehouseCode, etc.

    Finally use Write to write the record to the table.

    This link has more details on the rest of the fields in the table.

    http://help-sage100.na.sage.com/2019/FLOR/#File_Layouts/Bill_of_Materials/BM_ComponentReportSelection.htm

  • 0 in reply to David Speck

      I am wondering if you ever got this to work. After a successful login I tried the following snippet which is not working. Everything up to the first SetKeyValue works. All the SetKeyValue's fail (retVal=0) then the SetKey returns a null (retVal = ).

    Set oScript = CreateObject("ProvideX.Script"
    oScript.Init(MASInitPath)
    Set oSS = oScript.NewObject("SY_Session")
    
    retVal = oSS.nSetDate("B/M",ModuleDate)
    retVal = oSS.nSetModule("B/M")
    
    retVal = oSS.nSetProgram(oSS.nLookupTask("BM_ComponentReqrmntReport_ui"))
    Set oBusCompReqRpt = oScript.NewObject("BM_ReportBillSelection_bus",oSS)
    
    retVal = oBusCompReqRpt.nSetKeyValue("BillNo$", sBillNo) 
    retVal = oBusCompReqRpt.nSetKeyValue("Revision$", "000")
    retVal = oBusCompReqRpt.nSetKeyValue("BillOption1$", "")
    retVal = oBusCompReqRpt.nSetKeyValue("BillOption2$", "")
    retVal = oBusCompReqRpt.nSetKeyValue("BillOption3$", "")
    retVal = oBusCompReqRpt.nSetKeyValue("BillOption4$", "")
    retVal = oBusCompReqRpt.nSetKeyValue("BillOption5$", "")
    retVal = oBusCompReqRpt.nSetKeyValue("BillOption6$", "")
    retVal = oBusCompReqRpt.nSetKeyValue("BillOption7$", "")
    retVal = oBusCompReqRpt.nSetKeyValue("BillOption8$", "")
    retVal = oBusCompReqRpt.nSetKey()

  • 0 in reply to connex

    what does oBusCompReqRpt.sLastErrorMsg say?

  • 0 in reply to David Speck

    Sorry, after each oBusCompReqRpt.nSetKeyValue it says "The column is not part of the key."

  • 0 in reply to connex

    Odd, i just stepped through this using the command window with the report task open, and was able to set the key value on every field and SetKey returned 2.

    I wonder if when getting a handle to BM_ReportBillSelection_bus, it expects another parameter to identify the report type since there are three reports that share the selection table.

  • 0 in reply to David Speck

    Does setting the program to the lookup task for "BM_ComponentReqrmntReport_ui" establish the report? Also, I am unable to to a nMoveFirst, nGetKey, nClear or nAddline on the object after setting it with NewObject("BM_ComponentReqrmntReport_ui",oSS). I guess there could be another parameter, but I don't have the source, only the object reference.

  • 0 in reply to connex

    That sets the security object but i'm wondering if the NewObject/GetObject need additional parameters the way the CM_UDT_Svc and CM_UDTMaint_Bus classes need the additional parameter to specify the UDT name.

  • 0 in reply to David Speck

    Well i think i'm on to something but also don't have source.

    Using this snippet, GetTable returns "*SKIP*".

    Yet using GetTable from the command window of the report yields BM_ComponentReportSelection.

    i'm going to test what happens if the new object is actually the RPT class and then try to get the handle to the selection bus object from that.

  • 0 in reply to David Speck

    Got it figured out. You need the following added between after setting the object and before calling any table related methods, like SetKeyValue, MoveFirst, etc. You do not need any additional arguments in the NewObject/GetObject and you do not have to use the _rpt class, i tested this using the _bus class.

    oBusCompReqRpt.nSetSelectionInfo "BM_ComponentReportSelection"

  • 0 in reply to David Speck

    Adding that statement was like the dam breaking and most everything started working. I was able to add lines with BeillNo's. Thank you David! Very much appreciated. Any idea why a SetValue to QuantityRequired would return a 1, but not change that field? (I verified it was invoked with values other than the default 1)

    retVal = oBusCompReqRpt.nSetValue("QuantityRequired", nQuantityRequired)