Crystal Report number of pages according to field value - crystal-reports

My first question, so please excuse any mistakes.
We have internal ID numbers for product that we are selling, composed of: [SalesOrder_Num]/[Num].
For each Id No. we offer a Test Certificate to the client. Test Certificate defines the suitable age of product, along with its technical specification. Multiple items (20-30) on sales order can have same technical specification, but different ID number. ID Number also becomes Certificate Number.
We need to print/pdf these test certificates using Crystal Reports. There is a custom made Certificate Window on which technical specs are manually typed, along with sales order number. We also fill in number of Certificates (= [Num]).
What we now want is: Print [Num] of records/PDF with Certificate Number incrementally increasing on each PDF - [SalesOrder_Num]/1, [SalesOrder_Num]/2, ... ... ,[SalesOrder_Num]/[Num-1], [SalesOrder_Num]/[Num].
How is it possible?
Best Regards,
K

Create a REPEATER table with a single column (How_Many) that looks like this:
How_Many
1
2
3
4
5
6
etc..
Now, in your report, add the Repeater Table and add a join condition of:
Order.quantity >= Repeater.How_Many
If the ">=" join option is not available, remove the join to the REPEATER table and create this condition in the Record Selection condition:
{Order.quantity} >= {Repeater.How_Many}
This would cause each order to be duplicated as many times as the value of {Order.quantity}.
If you are restricted to using an equal join, you can also modify the repeater table to include N records for each quantity N:
1
2
2
3
3
3
...
This would cause each order to be duplicated as many times as the value of {Order.quantity}.
If you need to print "N of M" modify the repeater table to look like this:
N M
1 1
2 1
2 2
3 1
3 2
3 3
and use an equal join to the N column.
An alternative solution is to use a 3rd-party Crystal tool. At least one of the 3rd-party Crystal Reports viewers listed here provides the functionality you are seeking (without needing to add a Repeater table to your database).

Related

Crystal Report - Label Printing with a varied page counter

So, our branches are wanting shipping labels created which I have created a template on Crystal reports.
Our issue is using the NofM function. If the user prints one label it will say 1of1 which is correct. We want it so the counter is determined by the number of prints they require for example:
If the user prints 4 pages it will be 1of4 to 4of4.
Any assistance would be appreciated
In Field Explorer, expand 'Special Fields'.
Use the 'Page N of M' special field.
It sounds like you need a solution to duplicate the printing copies based on a parameter.
Option 1. if the max expected quantity is not too large, you can create multiple sections (Details a, Details b, Details c, ...) and use a dynamic suppress condition to hide the sections beyond the quantity parameter.
Option 2. Create a "REPEATER" table with a single column (How_Many) and rows for 1 | 2 | 3 | 4 | 5 | 6 | ...
Now, in your report, add the REPEATER Table and add a Record Selection condition of
{?QTY} >= {Repeater.How_Many}

Increment, display, and print a number of pages up to a Parameter maximum

I am trying to set up a Crystal Report to generate pallet labels which include a "Pallet N of M" line on each page.
The order in the database only has one entry, which contains all of the other information for the label(s). My issue is that the number of pallets isn't known until print time, and each label needs the same order information as well as a pallet ID. What I am looking for is for the user to enter a parameter for the total number of pallets, then have Crystal generate the correct number of unique labels.
For example, if the order has 4 pallets then Crystal should generate 4 copies of the label, the only difference on each copy being the last line which should read 'Pallet 1 of 4', 'Pallet 2 of 4', 'Pallet 3 of 4', and 'Pallet 4 of 4' respectively.
The only solution I can think of would be to create a number of sections equal to the maximum number of pallets, all containing my real data as a sub-report, then suppress any which are greater than the entered parameter. I am trying to avoid this because we may have greater than 50 pallets on a given order, so that would be tedious to create and is just not a very clean solution.
-= EDIT =-
Big thanks to Aliqux for the solution. In the end I needed to change the syntax to be Oracle compatible and also include the LINKVALUE field in the report, but the answer was 99% there especially considering I had not mentioned that my datasource was Oracle. The Command syntax I ended up using (with my parameter called TotalPallets) was:
SELECT
-1 AS "LINKVALUE"
FROM table
WHERE rownum <= {?TotalPallets}
You will need to Add a command to your tables.
1) Under database Expert in the Database you used select Add Command.
2) Click create to Create a Parameter.
3) Create the requested values, you can leave the Default Value blank if you want, and change the Value Type to Number. (I will be calling my parameter Counter)
4) Put the following in the SQL query where table is the main table you are using
SELECT TOP {?Counter}
-1 AS LINKVALUE
FROM table
5) Click okay and enter a value if prompted
6) In links link a number field, that will never go into negative numbers as we are using -1 for a base, to the LINKVALUE in the Command Table.
7)Link Options are as followed
Join Type: Inner Join, Enforce Join: Not Enforced, Link Type: !=
8) In your report create a formula with a shared numbervalue the starts from one.
shared numbervar counters;
if counters = {?Counter} then counters := 0;
counters := counters + 1
9) You can use that formula and the Counter Parameter for your labels
totext({#Counts},0,"")+" of "+totext({?Counter},0,"")
Credit reference: https://blogs.sap.com/2014/01/24/duplicating-data-details-records-n-times-eg-repeating-labels-n-times/

DSUM function in crystal reports?

I am trying to convert an old Microsoft Access report into Crystal reports. I have everything working perfectly except for this last small detail. The Access report uses a DSUM function within an if statement for one of the fields on the report.
After much searching, I've determined that CR doesn't have anything similar.
Here's basically what I'm dealing with.
I have a proposal report. In the details of the report I print the qty, description, and a couple of price fields.
The data looks like something this:
Proposalnum Partitem RolltoItem Unitprice
18611.............1.......... NULL........0.00
18611.............2......... NULL.......17225.92
18611............3............ 2............156.90
18611............4............. 2............482.05
What I need to do is when I print a specific part, I need to query through the rest of the records to find the parts that have a matching number in the rolltoitem field and add the unitprice to the part I'm printing.
So in this example when I print partitem #2, I need to add the 156.90 and the 482.05 from parts 3 and 4 to the 17225.92 so I print a total of 17864.87.
Is there any way to do this?
As far as i know, there is no such function.
But I would try this.
The general idea is: group the data by ProposalNum and use a subreport to select the "children rows" and sum the "children prices".
Details:
Create an empty group section by PartItem.
If you want to show only items where RoolToItem is null, use a suppress function for this case.
In the details section, put a subreport. The data source of the subreport would be the same of the main report.
Change subreport links to select data in subreport based on fields: PartItem in the main report = RolltoItem in the subreport.
Pass other fields to the subreport without select data: ProposalNum, PartItem, UnitPrice. I think you need to create parameters in the subreports before doing that - example: ParentProposalNum, ParentPartItem, ParentUnitPrice.
Create a new formula: ParentUnitPrice + Sum ({YourDataSource.UnitPrice})
Put the formula in the subreport footer a long with the other fields. Maybe: ParentProposalNum, ParentPartItem, formula.
It is a theoretical solution. I hope it points out to the right direction.
If you are trying to sum the Unitprice column for all items that have the same value in Rolltoitem, you could do this with a SQL Expression Field. The code would look something like this. My Where clause may need tweaked though since I'm not sure what your database structure looks like.
(
Select Sum("YourDataBaseTableName"."Unitprice")
From YourDataBaseTableName
Where "YourDataBaseTableName"."Rolltoitem" = *currentRolltoitemValue*
)
Syntax can also vary for SQL Expression Fields based upon what type of database you are using. The syntax I provided is fairly general, but should work on SQL Server.
EDIT: Adding example with explanation of how it works.
Here is one of my SQL Expression Fields from a crystal report that prints a Bill of Lading for shipped goods.
(
Select Sum("SHIPMENTS"."PALLET_COUNT")
From SHIPMENTS
Where "SHIPMENTS"."BOL_ID" = "BOL"."ID"
)
In my database the BOL table is the starting point. A single BOL can contain 1 or more SHIPMENTS, and a single SHIPMENTS can contain one or more PRODUCTS.
Top level grouping is on BOL.ID. The PALLET_COUNT is found once and only once on each SHIPMENTS. I also had a sorting requirement for the data in the details section that prevented me from using a Running Total Field.
This allows a BOL with 2 SHIPMENTS that contains a total of 3 products to look like this:
BOL.ID SHIPMENTS.ID SHIPMENTS.BOL_ID PALLET_COUNT PRODUCT.ID
1 10 1 2 XXX
1 9 1 1 YYY
1 10 1 2 ZZZ
The correct PALLET_COUNT for this BOL should be 3, since PRODUCTS XXX and ZZZ are in the same SHIPMENTS and the PALLET_COUNT is duplicated because of its relationship to the PRODUCTS.

Crystal Reports - Checking for a row in a table based on criteria from two different columns

I have a table of jobs, with columns showing which engineer the job is assigned to and the area of the country, which can be simplified like this:
JobNumber Area Engineer
1 A 3
2 D 1
3 E 2
4 B 2
5 A 1
I have a table of engineers, and a table of areas of the country.
I have a final table which shows the areas of the country each engineer is assigned to, like this:
Area Engineer
A 1
A 2
A 3
B 2
B 3
What I need to do in Crystal Reports, is create a formula field (or similar) to show whether or not the engineer was in one of his assigned areas.
I think the reason my efforts thus far have failed is that the join is effectively circular. I have played around with SQL Commands and join options to no avail.
Can anybody offer advice on how I can solve this problem?

Crystal Reports 7 CrossTab Suppress Column

I'm trying to modify a report created in Crystal Reports 7 (which I know almost nothing about). I want to use a CrossTab, as this seems to be the best way to accomplish what I want. I have a column with three possible values: A, B, C. The cross tab creates three columns. I want to suppress C. How can I do this?
Also, is there anyway to create rows based on one field (i.e. a PK value), but display another - like a description? For example, if a list of states have a PK value of 1-50, I want them ordered by PK, but I want to display the state name.
All you ask is possible;
i suggest not to use cross tab: cross tab is intended for an uknown number of rows and columns (varying on data) ad for summarizing (max value, sum of values) results on a grid.
you should, instead:
Create a blank report
Drop the fields from the Field explrorer into the Details Section (just A and B columns)
Use Report Sort Expert to sort elements no the PK value