Many to Many Reporting List

I am trying to become acquainted with the Reporting Add-On. I am getting the basics of it pretty well but I ran into a bit of a wall. I have a many (DEIPRODUCTCONFIG2_PROD_PACKAGE) to many (DEIPRODUCTCONFIG2_ASSEMBLY_CM) relationship that I’m trying to show as a list in my report. So far I can get a single item from the list to show up but I’m at a loss as to how to grab all of the entities and put them in a list.

My query:

select
DEIPRODUCTCONFIG2_PRODUCT.PRODUCT_NUMBER as "productNumber",
DEIPRODUCTCONFIG2_PRODUCT.description as "description",
DEIPRODUCTCONFIG2_PRODUCT.DS_DOC_NUMBER as "dsDocNumber",
DEIPRODUCTCONFIG2_PRODUCT.PACKAGE_SCD_DOC_NUMBER as "packageScdDocNumber",
DEIPRODUCTCONFIG2_PRODUCT.TRAVELER_DOC_NUMBER as "travelerDocNumber",
DEIPRODUCTCONFIG2_PRODUCT_STATUS.FULL_NAME as "status.fullName",
DEIPRODUCTCONFIG2_PROD_PACKAGE.PACKAGE_NUMBER as "packageType.packageNumber",
DEIPRODUCTCONFIG2_ASSEMBLY_CM.NAME as "assemblers"
from DEIPRODUCTCONFIG2_PRODUCT 
join DEIPRODUCTCONFIG2_PRODUCT_STATUS 
on DEIPRODUCTCONFIG2_PRODUCT_STATUS.ID = DEIPRODUCTCONFIG2_PRODUCT.STATUS_ID
join DEIPRODUCTCONFIG2_PACK_DIE_PROD
on DEIPRODUCTCONFIG2_PACK_DIE_PROD.ID = DEIPRODUCTCONFIG2_PRODUCT.ID
join DEIPRODUCTCONFIG2_PROD_PACKAGE
on DEIPRODUCTCONFIG2_PROD_PACKAGE.ID = DEIPRODUCTCONFIG2_PACK_DIE_PROD.PACKAGE_TYPE_ID
join DEIPRODUCTCONFIG2_PROD_PACKAGE_ASSEMBLY_CM_LINK
on DEIPRODUCTCONFIG2_PROD_PACKAGE_ASSEMBLY_CM_LINK.PROD_PACKAGE_ID = DEIPRODUCTCONFIG2_PACK_DIE_PROD.PACKAGE_TYPE_ID
join DEIPRODUCTCONFIG2_ASSEMBLY_CM
on DEIPRODUCTCONFIG2_ASSEMBLY_CM.ID = DEIPRODUCTCONFIG2_PROD_PACKAGE_ASSEMBLY_CM_LINK.ASSEMBLY_CM_ID;

Template for report PackagedDieProduct (2).docx (12.4 KB)

Hello Weston,

SQL enables you to use any number of joins, so this should work, normally. What will not work for sure is the merge of duplicate cells in XLSX/DOCS templates. So, using SQL/JPQL dataset you can make a report with one row per each many-to-many link. To get better result, you can try to create an HTML template with proper grouping.

Another option is to use Groovy dataset instead. You can extract the list of values, concatenate them (with linebreaks or dot-separated) in Groovy and put in one cell of your DOCX report.

Moreover, you can take a look at PivotTable that provides similar functionality in a convenient way.