0

I am implementing a new report system in my company. The transfer of data from ERP to the report builder software is handled with a temporary JSON array.

Within the report builder I can manipulate the data with C#. Currently I am working on a new report for our shipping labels. Sometimes (not always, pseudocode follows) I need to print multiple labels of the same kind.

I think the easiest way to achieve this would be by iterating through the array and duplicate the entries according to my logic. I could put this code in the "DoBeforeYouPrint"-Void of my report then and should get the desired amount of labels.

The data looks something like this (simplified)

  {
    "CustomerID": "1337",
    "ArticleName": "Strawberry",
    "DeliveryWeek": "45",
    "PackagingCount": "50"
  }

Pseudocode:

x = PackagingCount
y = Number of extra rows (labels)

foreach (Entry in DataSource) {

if x < 48 then 
{
y = Math.Ceiling(x / 12)
}

if else x >= 48 then
{
y = Math.Ceiling(x / 60) 
}

if else x > 840 then
{
y = 14
}

for (i = 1 to y) 
{
Duplicate(Entry);
}

}

I need help with a function that will do the duplication of the row and copy all information into an identical new row directly beneath the original row.

Is this possible at all with JSON arrays? I am not a real programmer, I work in a greenhouse.

9
  • A JSON array [ ] can contain many objects { } (each object is separated by a comma). That's the whole purpose of an array. Commented Nov 26, 2021 at 14:34
  • You can create a new output List<Entry>, adding any number of time the same entry to this list then serializing this list to Json. Commented Nov 26, 2021 at 14:37
  • IMHO, it's sounds simpler to just "print the same data twice" on those "sometimes". IOW, instead of mucking with with the data, identify those "sometimes" and see if you can just "print the same data x times" (sort of the print function that asks for number of copies) Commented Nov 26, 2021 at 14:41
  • I see. In my case I think the objects are the orderlines which were selected through an SQL query in my ERP. This is just the way my report-builder is handling the data. I can do further aggregations of the data within my report with no problems. Here I want to do the opposite though. Commented Nov 26, 2021 at 14:42
  • @EdSF That was my original intention but the actual code is hidden. I will continue to try and find that function though. I have also asked the developers. This was just my idea for a quick solution. Commented Nov 26, 2021 at 14:50

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.