Skip to main content
simply more productive

The Data Specialist

Thanks to our intuitive transformation designer, you can convert data effortlessly to a variety of formats without knowing how to program. It’s not only efficient, it’s also easy to use.
Up to 100,000 records can be processed with the freeware version!
Flowheater Chart

Adding with NET Script Heater

More
9 years 3 months ago #2431 by JD Cox
During the import I’m calculating the number of cases per line item.
I need to know the total case count per order.
I tried using the GroupBy Heater which worked but the import is reduced to one line per order. So, I modified a script, not successfully, provided by Robert a while back,

string sLastOrder = String.Empty;
int iXCaseCT = 0;

public object DoWork()
{
if (InValues.Length != 0)
throw new Exception("one input parameter expected");

// get the first input parameter
string sOrder = (string)InValues[0].GetString();
int iCaseCT = (int)InValues[1].GetString();

if (sLastOrder == sOrder)
{
iXCaseCT = iXCaseCT + iCaseCT;
}
else
{
iXCaseCT = iCaseCT;
}

sLastOrder = sOrder;

return iXCaseCT;
}

I’m guessing this is the best way to do this. The syntax checks out okay but when I run it I get the exception message.
I need this to establish the correct carrier based on the load size to avoid office staff having to manually do it for each order.
I know what to do before and after the script I just need a little help keeping a running sum of the case count per order.

Thanks for any help you guys can provide.
JD

Please Log in or Create an account to join the conversation.

More
9 years 3 months ago - 9 years 3 months ago #2432 by FlowHeater-Team
Replied by FlowHeater-Team on topic Adding with NET Script Heater - Post(2432)
Hi JD,

I guess you have just to change two lines.

Code:
... if (InValues.Length != 2) throw new Exception("two input parameter expected"); ... int iCaseCT = (int)InValues[1].GetInt(); ...

In case this doesn’t solve your problem please post the exception text on If possible the created definition file.

Best wishes
Robert Stark
Last edit: 9 years 3 months ago by FlowHeater-Team.

Please Log in or Create an account to join the conversation.

More
9 years 3 months ago #2434 by JD Cox
Replied by JD Cox on topic Adding with NET Script Heater - Post(2434)
Sorry but scripts are just not my thing…trying to learn but so far I know just enough to be dangerous. See attachment for more info. :unsure:

Please Log in or Create an account to join the conversation.

More
9 years 3 months ago #2435 by FlowHeater-Team
Replied by FlowHeater-Team on topic Adding with NET Script Heater - Post(2435)
Hi JD,

Please find below the modified script, it´s working on my side.

Note: The script but´s just in the last record for each order the right count!
Code:
string sLastOrder = String.Empty; int iXCaseCT = 0; public object DoWork() { if (InValues.Length != 2) throw new Exception("two input parameter expected"); // get the first input parameter string sOrder = (string)InValues[0].GetString(); // get the second input parameter int iCaseCT = (int)InValues[1].GetInt(); if (sLastOrder == sOrder) { iXCaseCT += iCaseCT; } else { iXCaseCT = iCaseCT; } sLastOrder = sOrder; return iXCaseCT; }

Best wishes
Robert Stark

Please Log in or Create an account to join the conversation.

More
9 years 3 months ago #2438 by JD Cox
Replied by JD Cox on topic Adding with NET Script Heater - Post(2438)
In the attachment…I’m trying to match the Desired Results column. This column would not be in the actual import file, I put it there just for comparison. I need the total case count per order then assign the appropriate carrier. As it is now office staff makes that determination after the import is complete.
Attachments:

Please Log in or Create an account to join the conversation.

More
9 years 3 months ago - 1 year 1 month ago #2439 by FlowHeater-Team
Replied by FlowHeater-Team on topic Adding with NET Script Heater - Post(2439)
Hi JD,

For this you need a second Definition. With the first Definition you have to use the GroupBy Heater to calculate the count like described in your first post. For the output are just two fields (order number and the calculated Count) necessary and the output must be a CSV file .

In the second Definition you have to implement a CSV Lookup with the String Replace Heater . This replace the unique criteria “Order Number” with the desired count.

Here you find an examples how it works: mapping info from 2 different csv files

The tow definition can be run automated successively by using the Batch Module and a simple CMD script like this
Code:
@echo off set FHBATCH="C:\Program Files (x86)\FlowHeater V3\BIN\FHBatch.exe" %FHBATCH% calculate-sum.fhd %FHBATCH% csv-replace.fhd

Best wishes
Robert Stark
Last edit: 1 year 1 month ago by FlowHeater-Team.

Please Log in or Create an account to join the conversation.

More
9 years 3 months ago #2441 by JD Cox
Replied by JD Cox on topic Adding with NET Script Heater - Post(2441)
I kind of had a feeling that’s where we would end up.

I have everything working with the exception of the Batch Module, I’m not sure how to run it or even what to do. For now they are able to run the first definition to get the case count then run the import. That in itself is a huge improvement but if I can eliminate one more step in the process I’ll be a rock star.


Thanks for all of your help.

JD

Please Log in or Create an account to join the conversation.

More
9 years 3 months ago #2444 by FlowHeater-Team
Replied by FlowHeater-Team on topic Adding with NET Script Heater - Post(2444)
Hi JD,

Please find attached a short example. The first definition creates just the CSV Lookup text file for the “casecount” field. The second definition import the data into the desired Excel sheet.

In the ZIP archive I’ve also attached a short Batch cmd script for the automation.

NOTE: To run this example you need FlowHeater Version 3x!

File Attachment:

File Name: csv-replac...mple.zip
File Size:5 KB

Best wishes
Robert Stark

Please Log in or Create an account to join the conversation.

More
9 years 3 months ago #2464 by JD Cox
Replied by JD Cox on topic Adding with NET Script Heater - Post(2464)
I have to say I'm loving the Batch finding new things to use it for.

Thanks for all the support...as always.

JD

Please Log in or Create an account to join the conversation.

Time to create page: 0.315 seconds
FlowHeater Logo

FlowHeater - The Data Specialist

Efficient data integration and transformation with FlowHeater – the perfect solution for a seamless transfer of your data.

Legal information

Support & Contact

Contact

Phone:
0951 / 9933 9792

eMail:
This email address is being protected from spambots. You need JavaScript enabled to view it.


Copyright © 2009-2024 by FlowHeater GmbH. All rights reserved.