- Posts: 109
Adding with NET Script Heater
- JD Cox
- Topic Author
- Offline
- User
Less
More
9 years 3 months ago #2431
by JD Cox
Adding with NET Script Heater - Post(2431) was created 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
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.
- FlowHeater-Team
- Offline
- Admin
9 years 3 months ago - 9 years 3 months ago #2432
by FlowHeater-Team
Best wishes
Robert Stark
Replied by FlowHeater-Team on topic Adding with NET Script Heater - Post(2432)
Hi JD,
I guess you have just to change two lines.
In case this doesn’t solve your problem please post the exception text on If possible the created definition file.
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.
- JD Cox
- Topic Author
- Offline
- User
Less
More
- Posts: 109
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:
Attachments:
Please Log in or Create an account to join the conversation.
- FlowHeater-Team
- Offline
- Admin
9 years 3 months ago #2435
by FlowHeater-Team
Best wishes
Robert Stark
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!
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.
- JD Cox
- Topic Author
- Offline
- User
Less
More
- Posts: 109
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.
- FlowHeater-Team
- Offline
- Admin
9 years 3 months ago - 1 year 1 month ago #2439
by FlowHeater-Team
Best wishes
Robert Stark
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
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.
- JD Cox
- Topic Author
- Offline
- User
Less
More
- Posts: 109
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
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.
- FlowHeater-Team
- Offline
- Admin
9 years 3 months ago #2444
by FlowHeater-Team
Best wishes
Robert Stark
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!
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!
Best wishes
Robert Stark
Attachments:
Please Log in or Create an account to join the conversation.
- JD Cox
- Topic Author
- Offline
- User
Less
More
- Posts: 109
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
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