We have a business requirement to print a list of ticket numbers into a fixed column format and include an asterisk at the beginning of each row.
The following @PopulateList formula is currently used within the detail section of the report:
// {@TicketNo} is the trimmed Ticket
// {@TicketLength} is a variable used to define the number of characters for each ticket including spaces
WhilePrintingRecords;
stringvar stTickets :=
if (instr(stTickets, {@TicketNo}) >0 )
then stTickets // if the ticket is already in stTickets then do nothing
else stTickets + replicatestring(" ",{@TicketLength}-len({@TicketNo})) + {@TicketNo} // add the ticket with prefix spaces so all tickets are fixed width
-------------------
The above @PopulateList formula currently produces the following output:
100 1000 10000 100000 200000 300000
400000 1000000 3000000 10000000 20000000 500000
600000 700000 8000000 4000000 60000000 70000000
101 1001 10001 100001 200001 300001 400001
1000001 3000001 10000001 20000001 201 2001
20001 500001 600001 700001 8000001 4000001
60000001 70000001
-------------------
Our business requirement is for the @PopulateList formula to produce the following output, where the number of tickets included per row is defined in a variable (5 in this example) and each row begins with an asterisk:
* 100 1000 10000 100000 200000
* 300000 400000 1000000 3000000 10000000
* 20000000 500000 600000 700000 8000000
* 4000000 60000000 70000000 101 1001
* 10001 100001 200001 300001 400001
* 1000001 3000001 10000001 20000001 201
* 2001 20001 500001 600001 700001
* 8000001 4000001 60000001 70000001
-------------------
An @DisplayFixedColTickets formula was created in a group footer in an effort to format the @PopulateList results to meet the business requirements, but it only produces the first row, and it needs to execute multiple times until all of the tickets are included (this is where I am stuck):
numbervar StringLength := len({@DisplayTickets});
numbervar TicketLength := 15;
numbervar TickstsPerRow := 5;
numbervar TicketPosition := 1;
stringvar Identifier := " * ";
stringvar Output := "";
Output := mid({@DisplayTickets}, TicketPosition, (TicketLength * TickstsPerRow));
Output := Identifier + Output + chr(13)
// need logic to read through @DisplayTickets that will:
// allow the number of tickets per row to be controlled by the TicketsPerRow variable
// Include the " * " identifier at the beginning of each row
// Dynamically generate enough rows until all tickets are printed
-------------------
Please share any ideas on how to modify these formulas so the output will include all tickets within the fixed-column format.
The following SQL includes sample ticket information for two plants. There are some intentional duplicate tickets in the sample data; the printed ticket list should only include distinct tickets (no duplicates):
Select '100' as Ticket, 1 as Plant
Union ALL Select '100', 1
Union ALL Select '1000', 1
Union ALL Select '1000', 2
Union ALL Select '10000', 1
Union ALL Select '100000', 1
Union ALL Select '200000', 1
Union ALL Select '300000', 1
Union ALL Select '400000', 1
Union ALL Select '1000000', 1
Union ALL Select '2000000', 2
Union ALL Select '3000000', 1
Union ALL Select '3000000', 2
Union ALL Select '10000000', 1
Union ALL Select '20000000', 1
Union ALL Select '200', 1
Union ALL Select '2000', 1
Union ALL Select '2000', 2
Union ALL Select '20000', 1
Union ALL Select '200000', 1
Union ALL Select '500000', 1
Union ALL Select '600000', 1
Union ALL Select '700000', 1
Union ALL Select '8000000', 1
Union ALL Select '9000000', 2
Union ALL Select '4000000', 1
Union ALL Select '4000000', 2
Union ALL Select '60000000', 1
Union ALL Select '70000000', 1
Union ALL Select '101', 1
Union ALL Select '1001', 1
Union ALL Select '1001', 2
Union ALL Select '10001', 1
Union ALL Select '100001', 1
Union ALL Select '200001', 1
Union ALL Select '300001', 1
Union ALL Select '400001', 1
Union ALL Select '1000001', 1
Union ALL Select '2000001', 2
Union ALL Select '3000001', 1
Union ALL Select '3000001', 2
Union ALL Select '10000001', 1
Union ALL Select '20000001', 1
Union ALL Select '201', 1
Union ALL Select '2001', 1
Union ALL Select '2001', 2
Union ALL Select '20001', 1
Union ALL Select '200001', 1
Union ALL Select '500001', 1
Union ALL Select '600001', 1
Union ALL Select '700001', 1
Union ALL Select '8000001', 1
Union ALL Select '9000001', 2
Union ALL Select '4000001', 1
Union ALL Select '4000001', 2
Union ALL Select '60000001', 1
Union ALL Select '70000001', 1
The following @PopulateList formula is currently used within the detail section of the report:
// {@TicketNo} is the trimmed Ticket
// {@TicketLength} is a variable used to define the number of characters for each ticket including spaces
WhilePrintingRecords;
stringvar stTickets :=
if (instr(stTickets, {@TicketNo}) >0 )
then stTickets // if the ticket is already in stTickets then do nothing
else stTickets + replicatestring(" ",{@TicketLength}-len({@TicketNo})) + {@TicketNo} // add the ticket with prefix spaces so all tickets are fixed width
-------------------
The above @PopulateList formula currently produces the following output:
100 1000 10000 100000 200000 300000
400000 1000000 3000000 10000000 20000000 500000
600000 700000 8000000 4000000 60000000 70000000
101 1001 10001 100001 200001 300001 400001
1000001 3000001 10000001 20000001 201 2001
20001 500001 600001 700001 8000001 4000001
60000001 70000001
-------------------
Our business requirement is for the @PopulateList formula to produce the following output, where the number of tickets included per row is defined in a variable (5 in this example) and each row begins with an asterisk:
* 100 1000 10000 100000 200000
* 300000 400000 1000000 3000000 10000000
* 20000000 500000 600000 700000 8000000
* 4000000 60000000 70000000 101 1001
* 10001 100001 200001 300001 400001
* 1000001 3000001 10000001 20000001 201
* 2001 20001 500001 600001 700001
* 8000001 4000001 60000001 70000001
-------------------
An @DisplayFixedColTickets formula was created in a group footer in an effort to format the @PopulateList results to meet the business requirements, but it only produces the first row, and it needs to execute multiple times until all of the tickets are included (this is where I am stuck):
numbervar StringLength := len({@DisplayTickets});
numbervar TicketLength := 15;
numbervar TickstsPerRow := 5;
numbervar TicketPosition := 1;
stringvar Identifier := " * ";
stringvar Output := "";
Output := mid({@DisplayTickets}, TicketPosition, (TicketLength * TickstsPerRow));
Output := Identifier + Output + chr(13)
// need logic to read through @DisplayTickets that will:
// allow the number of tickets per row to be controlled by the TicketsPerRow variable
// Include the " * " identifier at the beginning of each row
// Dynamically generate enough rows until all tickets are printed
-------------------
Please share any ideas on how to modify these formulas so the output will include all tickets within the fixed-column format.
The following SQL includes sample ticket information for two plants. There are some intentional duplicate tickets in the sample data; the printed ticket list should only include distinct tickets (no duplicates):
Select '100' as Ticket, 1 as Plant
Union ALL Select '100', 1
Union ALL Select '1000', 1
Union ALL Select '1000', 2
Union ALL Select '10000', 1
Union ALL Select '100000', 1
Union ALL Select '200000', 1
Union ALL Select '300000', 1
Union ALL Select '400000', 1
Union ALL Select '1000000', 1
Union ALL Select '2000000', 2
Union ALL Select '3000000', 1
Union ALL Select '3000000', 2
Union ALL Select '10000000', 1
Union ALL Select '20000000', 1
Union ALL Select '200', 1
Union ALL Select '2000', 1
Union ALL Select '2000', 2
Union ALL Select '20000', 1
Union ALL Select '200000', 1
Union ALL Select '500000', 1
Union ALL Select '600000', 1
Union ALL Select '700000', 1
Union ALL Select '8000000', 1
Union ALL Select '9000000', 2
Union ALL Select '4000000', 1
Union ALL Select '4000000', 2
Union ALL Select '60000000', 1
Union ALL Select '70000000', 1
Union ALL Select '101', 1
Union ALL Select '1001', 1
Union ALL Select '1001', 2
Union ALL Select '10001', 1
Union ALL Select '100001', 1
Union ALL Select '200001', 1
Union ALL Select '300001', 1
Union ALL Select '400001', 1
Union ALL Select '1000001', 1
Union ALL Select '2000001', 2
Union ALL Select '3000001', 1
Union ALL Select '3000001', 2
Union ALL Select '10000001', 1
Union ALL Select '20000001', 1
Union ALL Select '201', 1
Union ALL Select '2001', 1
Union ALL Select '2001', 2
Union ALL Select '20001', 1
Union ALL Select '200001', 1
Union ALL Select '500001', 1
Union ALL Select '600001', 1
Union ALL Select '700001', 1
Union ALL Select '8000001', 1
Union ALL Select '9000001', 2
Union ALL Select '4000001', 1
Union ALL Select '4000001', 2
Union ALL Select '60000001', 1
Union ALL Select '70000001', 1