Add Misc Charge in BPM question

Hi,

I’m trying to add a misc charge in a SalesOrder.Update.Post BPM using the following piece of code:

SalesOrderTableset theDS = this.ds;
OrderMscRow newRow;

        pSvc.GetNewOrderMsc(ref theDS, pRow.OrderNum, pRow.OrderLine); 
        newRow = this.ds.OrderMsc.FirstOrDefault(r => r.Added());
        
        if (newRow != null)
        {
            refreshNeeded = true;
            newRow.MiscCode = coLongPanelMscChrgCode;
            pSvc.ChangeMiscCode(ref theDS, "OrderMsc");
            newRow.FreqCode = "F";
            newRow.Type = "A";
        }

But when I call the MasterUpdate method, I received the following message: Charge ID is required

Any though???

Regards
Al

OrderEntry shows Charge ID is like MiscChrg.MiscCode. Any chance the code you’re entering isn’t in setup in Misc Charge Maintenance? Also, are you setting the description? I’ve had to do that with BPM’s that set a value from a dropdown (i.e. set the code and the description).

I’m not a proficient coder, so can’t help you there. Good luck!

Thank’s

Al

~WRD000.jpg

image007.jpg

What it’s weird it’s when I add 2 Misc Charges. I create 2 misc charges as the following:

for (int i = 0; i < 2; i++)
{
pSvc.GetNewOrderMsc(ref theDS, pRow.OrderNum, pRow.OrderLine);
newRow = this.ds.OrderMsc.FirstOrDefault(r => r.Added());
newRow.MiscCode = “SPL” + i.ToString();
pSvc.ChangeMiscCode(ref theDS, “OrderMsc”);

After the first pass, the description, the amount, etc… are filled correctly
But not on the 2nd pass.

But MiscCode exists in the misc charges table.
}

pSvc.MasterUpdate(…);

Regards
Al

Both MiscCodes exist? SPL0 and SPL1?

Also, do you need a MasterUpdate? We have successfully used the Update method for GetNewOrderMsc.

Yes both code exist, if I enter both misc charges manually, everything fine!!!

The problem seem to come from ChangeMscCode method. I think the method always look for the first rowmod <> “” in the dataset which mean if I have 2 rowmod = “A”, only the first one will be take in consideration.

Regards
Al