Sage MAS 90 and 200 Sage MAS 500 blogs Product Feedback Support Training
Reply
Sage MAS 90 Customer
rolandc
Posts: 95
Registered: 06-10-2010
0

Inventory Transaction Entry

[ Edited ]

Using MAS 200 v4.4

 

I am trying to write a script that will create a new entry in IM Transaction Entry for an adjustment to an item's quantity. I have the following code snippet with all variables previously defined. After attempting to write the lines, the return value is zero and, of course, the code does not continue successfully from there. Are there any other field values to set?



 

        retVal = oSS.nSetProgram(oSS.nLookupTask("IM_Transaction_ui"))
        imTransEntry = oPVX.NewObject("IM_Transaction_bus", oSS)

        retVal = imTransEntry.nSetValue("TransactionType$", "6")
        NextEntryNo = ""
        retVal = imTransEntry.nGetNextEntryNo(NextEntryNo)
        retVal = imTransEntry.nSetKey(NextEntryNo)
        retVal = imTransEntry.nSetValue("TransactionDate$", "20110509")
        retVal = imTransEntry.nSetValue("DefaultFromWhseCode$", "000")
        retVal = imTransEntry.nSetValue("Comment$", "test")

        retVal = imTransEntry.oLines.nAddLine()
        retVal = imTransEntry.oLines.nSetValue("ItemCode$", "6655")
        retVal = imTransEntry.oLines.nSetValue("TransactionQty", 10)
        retVal = imTransEntry.oLines.nWrite()
        MsgBox("retVal = " & retVal)

        retVal = imTransEntry.nWrite()

 

 

 

Sage MAS 90 Customer
rolandc
Posts: 95
Registered: 06-10-2010
0

Re: Inventory Transaction Entry

Well here is yet another "I answered my own question" reply. :smileyhappy:

 

I missed the WarehouseCode$ and also set the wrong key. Here is the corrected code. Hope someone else finds this useful.

 

    Dim oPVX, oSS, imTransEntry As Object
    Dim retVal As Integer
    Dim NextEntryNo, TransactionType As String

    oPVX = CreateObject("ProvideX.Script")
    oPVX.Init("C:\Sage Software\MAS 200\Version4\MAS90\home")

    oSS = oPVX.NewObject("SY_Session")
    oSS.nSetUser("USERNAME", "PASSWORD")
    oSS.nSetCompany("ABC")
    oSS.nSetDate("I/M", "20110509")
    oSS.nSetModule("I/M")

    retVal = oSS.nSetProgram(oSS.nLookupTask("IM_Transaction_ui"))
    imTransEntry = oPVX.NewObject("IM_Transaction_bus", oSS)

    ' TransactionType: Sale=1, Issue=2, Transfer=4, Adjustment=6, Receipt=8
    TransactionType = "6"
    retVal = imTransEntry.nSetValue("TransactionType$", TransactionType)
    NextEntryNo = ""
    retVal = imTransEntry.nGetNextEntryNo(NextEntryNo)
    retVal = imTransEntry.nSetKey(TransactionType & NextEntryNo)
    retVal = imTransEntry.nSetValue("TransactionDate$", "20110509")
    retVal = imTransEntry.nSetValue("DefaultFromWhseCode$", "000")
    retVal = imTransEntry.nSetValue("Comment$", "test comment")

    retVal = imTransEntry.oLines.nAddLine()
    retVal = imTransEntry.oLines.nSetValue("ItemCode$", "6655")
    retVal = imTransEntry.oLines.nSetValue("WarehouseCode$", "000")
    retVal = imTransEntry.oLines.nSetValue("TransactionQty", 10)
    retVal = imTransEntry.oLines.nWrite()
    retVal = imTransEntry.nWrite()

    retVal = imTransEntry.DropObject()
    retVal = oSS.DropObject()

 

 

Sage MAS 90 Customer
vsivan
Posts: 28
Registered: 01-14-2010
0

Re: Inventory Transaction Entry

What about Batch # ?

Sage MAS 90 Customer
vsivan
Posts: 28
Registered: 01-14-2010
0

Re: Inventory Transaction Entry

oTransEntry.nSelectNewBatch(nextNo, "N", "Transaction entry " + sysDate)

Sage MAS 90 Customer
rolandc
Posts: 95
Registered: 06-10-2010
0

Re: Inventory Transaction Entry

Thanks, we don't use batches but I'm sure someone may find that helpful.

 

BTW, I am using the following to update the Transaction Journal:

 

	retVal = oSS.nSetProgram(oSS.nLookupTask("IM_TransactionRegister_UI"))
        imTransEntry = oPVX.NewObject("IM_TransactionRegister_UPD", oSS)

        oSS.nTerminateUI()

        retVal = imTransEntry.nUpdateInit()
        retVal = imTransEntry.nUpdateMain()
        retVal = imTransEntry.nUpdateCleanup()

 

This works for me without printing the reports.

unidentified user
pablotc
Posts: 1
Registered: 01-23-2012
0

Re: Inventory Transaction Entry

Hi,

 

I need some help. I am trying to do an Inventory Transaction (Specifically Adjustment) and MAS200 keeps on displaying LINE NUMBER 1 HAS NOT BEEN DISTRIBUTED. The item is a FIFO item (NO LOT/SERIAL).

 

Heres my code:

 

'##########################################

'#### Create the IM Transaction Header ####

'##########################################

 

' TransactionType: Sale=1, Issue=2, Transfer=4, Adjustment=6, Receipt=8

retChk(oIMTrans.nSetValue("TransactionType$", "6"), oIMTrans)

retChk(oIMTrans.nGetNextEntryNo(s_NextOrderNo), oIMTrans)

retChk(oIMTrans.nSetKey("6"& s_NextOrderNo), oIMTrans)

retChk(oIMTrans.nSetValue("TransactionDate$", "20120119"), oIMTrans)

retChk(oIMTrans.nSetValue("DefaultFromWhseCode$", "001"), oIMTrans)

retChk(oIMTrans.nSetValue("Comment$", "test comment"), oIMTrans)

 

'##########################################

'#### Create the IM Transaction Detail ####

##########################################

ForEach entryDetail As OrderItem Inentry.Items

retChk(oIMTrans.oLines.nAddLine(), oIMTrans)

retChk(oIMTrans.oLines.nSetValue("ItemCode$", entryDetail.ItemNumber.ToString), oIMTrans.oLines)

retChk(oIMTrans.oLines.nSetValue("TransactionQty", entryDetail.Quantity), oIMTrans.oLines)

retChk(oIMTrans.oLines.nWrite(), oIMTrans.oLines)

oIMTrans.oLines.nMoveFirst()

retChk(oIMTrans.oLines.nGetValue("LineKey$", s_LineKey), oIMTrans.oLines)

retChk(oIMTrans.oLines.nGetValue("Valuation$", s_Valuation), oIMTrans.oLines)

 

' Write the distribution record' TransactionType+EntryNo+LineKey+FifoLifoDate+FifoLifoReferenceNo+LotSerialNo

oIMTrans.oLines.oDistribution.nSetKeyValue("TransactionType$", "6")

oIMTrans.oLines.oDistribution.nSetKeyValue("EntryNo$", s_NextOrderNo)

oIMTrans.oLines.oDistribution.nSetKeyValue("LineKey$", s_LineKey)

oIMTrans.oLines.oDistribution.nSetKeyValue("TierType$", "1")

oIMTrans.oLines.oDistribution.nSetKeyValue("FifoLifoDate$", "20120123")

oIMTrans.oLines.oDistribution.nSetKeyValue("FifoLifoReferenceNo$", "12345678")

oIMTrans.oLines.oDistribution.nSetKey()

retChk(oIMTrans.oLines.oDistribution.nSetValue("ItemCode$", entryDetail.ItemNumber.ToString), oIMTrans.oLines)

retChk(oIMTrans.oLines.oDistribution.nSetValue("WarehouseCode$", "001"), oIMTrans.oLines)

retChk(oIMTrans.oLines.oDistribution.nSetValue("TransactionQty", entryDetail.Quantity), oIMTrans.oLines)

retChk(oIMTrans.oLines.oDistribution.nWrite(), oIMTrans.oLines)

retChk(oIMTrans.oLines.oDistribution.nCommitRow(), oIMTrans.oLines)

Next

 

'###################################

'#### Write the object into MAS ####

'###################################

retChk(oIMTrans.nWrite(), oIMTrans)

Next

 

Can you please help me..

Best Regards

Sage Employee
jepritch
Posts: 233
Registered: 08-25-2009
0

Re: Inventory Transaction Entry

 Hi pablotc,

 

For the Tier distribution layer there are some methods that might make your life a little easier.

 

Instead of using all those SetKeyValue() statements, there is a method called AddDistributionLine(arg).  For lot/serial lines, the arg value is the Lot Number or Serial Number you want to add on that line.  For LIFO/FIFO tiers it's a little different, it's the FifoLifoDate + Chr(138) + FifoLifoReference.  A lot of the rest will be done for you.    So try the following for the distribution level:

 

'Write the distribution record' TransactionType+EntryNo+LineKey+FifoLifoDate+FifoL​ifoReferenceNo+LotSerialNo

oIMTrans.oLines.oDistribution.nAddDistributionLine("20120123" & Chr(138) & "12345678")

' Shouldn't need to set the ItemCode or the Warehouse

retChk(oIMTrans.oLines.oDistribution.nSetValue("TransactionQty", entryDetail.Quantity), oIMTrans.oLines)

retChk(oIMTrans.oLines.oDistribution.nWrite(), oIMTrans.oLines)

 

You shouldn't need the CommitRow either.  Keep in mind this same method can be used for lot/serial tiers as well. 

 

retVal = oIMTrans.oLines.oDistribution.nAddDistributionLine(lotNo)

 

Hope this helps.

 Elliott