Help to eliminate blank lines in a report or make dynamic arrangements

Other discussions about CSPro
Post Reply
sandraopve
Posts: 2
Joined: February 2nd, 2021, 12:16 pm

Help to eliminate blank lines in a report or make dynamic arrangements

Post by sandraopve » February 2nd, 2021, 12:59 pm

Good afternoon CSPro Users Forum,

I come to you to please help me solve a problem I have when making reports. In fact, they are already done using setreportdata, the report is delivered an array with number of rows and columns, which are set in the PROC GLOBAL section. However, this implies that when the report is painted in the html file, there are excess rows.

I ask,
1. Is it possible that the array only has the number of rows that I need to present? That is, to control the rows of the array dynamically, for example, according to the number of records that the dictionary has ?.

2. Can the blank lines be omitted in the report? as well as apparently CSPRO manages it with a library called mustache.min.js. Or, modifying said library?

I am a beginner in CSPRO development.

Thank you very much for your help.
Attachments
cuadro.png
cuadro.png (109.64 KiB) Viewed 762 times

aaronw
Posts: 458
Joined: June 9th, 2016, 9:38 am
Location: Washington, DC

Re: Help to eliminate blank lines in a report or make dynamic arrangements

Post by aaronw » February 2nd, 2021, 4:01 pm

Try substituting a list for the array. Then you can add elements as necessary.
list: https://www.csprousers.org/help/CSPro/list.html

When working with reports in the past I have made use of the working storage. The working storage is not associated with a dictionary, so it's not persistent. Much like I imagine you're using your array, I loop through the working storage and populate it. However, I am also able to delete occurrences as needed. Then I pass the record to the setreportdata function.

sandraopve
Posts: 2
Joined: February 2nd, 2021, 12:16 pm

Re: Help to eliminate blank lines in a report or make dynamic arrangements

Post by sandraopve » February 4th, 2021, 9:37 am

Nice to greet you. Thank you very much for her timely response.
With her kind input I solve part of the problem. However, we handle more than one dimension and the list is only possible for arrays or matrices of one dimension.

For now we resort to handling the report with query queries, discarding the handling of arrays.

I reiterate my thanks for your help.

Gregory Martin
Posts: 1534
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Help to eliminate blank lines in a report or make dynamic arrangements

Post by Gregory Martin » February 4th, 2021, 4:51 pm

Because of the array issue that you mention, I use working storage dictionaries when writing reports. In summary, you:

1) Add a working storage dictionary to your application (File -> Add Files).

2) Add a repeating record and add items to the record for each column of your table.

3) Instead of populating the array, populate the items in the record.

4) Use the record name when calling setreportdata. In the report, you'll do something like:
{{#WORKING_STORAGE_RECORD_NAME}}
<tr><td>{{WORKING_STORAGE_ITEM_NAME1}}</td><td>{{WORKING_STORAGE_ITEM_NAME2}}</td></tr>
{{/WORKING_STORAGE_RECORD_NAMAE}}
To deal with blank rows, before you populate the record, clear your working storage dictionary:
clear(WS_DICT);
This resets all record occurrences to the maximum value. And then when you're done populating the record, remove unneeded rows:
delete(WORKING_STORAGE_RECORD_NAME, number_rows_used + 1, maxocc(WORKING_STORAGE_RECORD_NAME));

Post Reply