Dynamic data import / export

datenbank

simply more productive
Up to 10,000 records can be processed with the freeware version!
Welcome, Guest
Username: Password: Remember me
Welcome to the FlowHeater support forum.

Questions about using FlowHeater are answered here.

TOPIC: Adding with NET Script Heater

Adding with NET Script Heater 1 year 3 months ago #2431

  • JD Cox
  • JD Cox's Avatar
  • Offline
  • Junior Member
  • Posts: 39
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
The administrator has disabled public write access.

Adding with NET Script Heater 1 year 3 months ago #2432

  • FlowHeater-Team
  • FlowHeater-Team's Avatar
  • Offline
  • Administrator
  • Posts: 240
Hi JD,

I guess you have just to change two lines.

...

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

Did this answer your question? We would be grateful if you provide a brief comment as feedback. It may also help others who may have encountered a similar problem.
Last Edit: 1 year 3 months ago by FlowHeater-Team.
The administrator has disabled public write access.

Adding with NET Script Heater 1 year 3 months ago #2434

  • JD Cox
  • JD Cox's Avatar
  • Offline
  • Junior Member
  • Posts: 39
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:
The administrator has disabled public write access.

Adding with NET Script Heater 1 year 3 months ago #2435

  • FlowHeater-Team
  • FlowHeater-Team's Avatar
  • Offline
  • Administrator
  • Posts: 240
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!
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

Did this answer your question? We would be grateful if you provide a brief comment as feedback. It may also help others who may have encountered a similar problem.
The administrator has disabled public write access.

Adding with NET Script Heater 1 year 3 months ago #2438

  • JD Cox
  • JD Cox's Avatar
  • Offline
  • Junior Member
  • Posts: 39
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:
The administrator has disabled public write access.

Adding with NET Script Heater 1 year 3 months ago #2439

  • FlowHeater-Team
  • FlowHeater-Team's Avatar
  • Offline
  • Administrator
  • Posts: 240
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
@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

Did this answer your question? We would be grateful if you provide a brief comment as feedback. It may also help others who may have encountered a similar problem.
The administrator has disabled public write access.

Adding with NET Script Heater 1 year 3 months ago #2441

  • JD Cox
  • JD Cox's Avatar
  • Offline
  • Junior Member
  • Posts: 39
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
The administrator has disabled public write access.

Adding with NET Script Heater 1 year 3 months ago #2444

  • FlowHeater-Team
  • FlowHeater-Team's Avatar
  • Offline
  • Administrator
  • Posts: 240
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

Did this answer your question? We would be grateful if you provide a brief comment as feedback. It may also help others who may have encountered a similar problem.
The administrator has disabled public write access.

Adding with NET Script Heater 1 year 2 months ago #2464

  • JD Cox
  • JD Cox's Avatar
  • Offline
  • Junior Member
  • Posts: 39
I have to say I'm loving the Batch finding new things to use it for.

Thanks for all the support...as always.

JD
The administrator has disabled public write access.
Moderators: FlowHeater-Team
Time to create page: 0.092 seconds