1
votes

Looking for the best way to solve my dilemma. I am building a report and the data source that is being used is JSON <- Not much experience with JSON.

This is how data looks coming across to me via JSON

Parent
    Child
        Child (NEED SOME FIELDS HERE FOR HEADER)
             FINAL CHILD (Need Fields In Here) (Setup as array bc multiple of Final Child)
             FINAL CHILD
             FINAL CHILD and so on (FINAL CHILD will be repeating in the Detail section.)
               ALSO FINAL CHILD IS SETUP IN ARRAY FOR EACH FINAL CHILD

Currently, I have built a master and subreport. I do not need to pass any data because of the parent only has children... but could not get it working where the detail section of the master report would cycle through all the Final Children.

Master Report PreView: Master Report Preview SubReport PreView: SubReport Preview No matter what I do to the sizing, I cannot get it to shrink down in size and compactness...

Master Report Code

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.4.0.final using JasperReports Library version 6.4.1  -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Test4BD" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="65794bef-41ec-4ebe-9237-6c5db5cb403c">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="BD JSON Data Adapter"/>
    <queryString language="json">
        <![CDATA[tXML.Message.InboundReportXML.MESSAGEDATA.ASNDATA.INBOUNDHEADER]]>
    </queryString>
    <field name="ASNID" class="java.lang.String">
        <fieldDescription><![CDATA[ASNID]]></fieldDescription>
    </field>
    <field name="ASN" class="java.lang.String">
        <fieldDescription><![CDATA[ASN]]></fieldDescription>
    </field>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="7" splitType="Stretch"/>
    </title>
    <pageHeader>
        <band height="14" splitType="Stretch"/>
    </pageHeader>
    <columnHeader>
        <band height="62" splitType="Stretch">
            <textField>
                <reportElement x="70" y="0" width="100" height="30" uuid="0f247a53-6ea3-462d-a655-0e3f02f2b611"/>
                <textFieldExpression><![CDATA[$F{ASNID}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="330" y="0" width="100" height="30" uuid="2c72da14-4800-4d2c-af67-58d27232133d"/>
                <textFieldExpression><![CDATA[$F{ASN}]]></textFieldExpression>
            </textField>
        </band>
    </columnHeader>
    <detail>
        <band height="75" splitType="Stretch">
            <subreport>
                <reportElement x="40" y="0" width="460" height="70" uuid="684434fc-a528-4e65-b7e8-6192048ae611"/>
                <parametersMapExpression><![CDATA[$P{REPORT_PARAMETERS_MAP}]]></parametersMapExpression>
                <subreportExpression><![CDATA["SubReport2.jasper"]]></subreportExpression>
            </subreport>
        </band>
    </detail>
    <columnFooter>
        <band height="45" splitType="Stretch"/>
    </columnFooter>
    <pageFooter>
        <band height="54" splitType="Stretch"/>
    </pageFooter>
    <summary>
        <band height="42" splitType="Stretch"/>
    </summary>
</jasperReport>

SubReport:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.4.0.final using JasperReports Library version 6.4.1  -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="SubReport2" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="2d15bbaf-6da1-4158-83b1-6a069fa6144b">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="BD JSON Data Adapter"/>
    <queryString language="json">
        <![CDATA[tXML.Message.InboundReportXML.MESSAGEDATA.ASNDATA.INBOUNDHEADER.INBOUNDDETAILS]]>
    </queryString>
    <field name="ASNDETAILID" class="java.lang.String">
        <fieldDescription><![CDATA[ASNDETAILID]]></fieldDescription>
    </field>
    <field name="LINENBR" class="java.lang.String">
        <fieldDescription><![CDATA[LINENBR]]></fieldDescription>
    </field>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="8" splitType="Stretch"/>
    </title>
    <pageHeader>
        <band height="9" splitType="Stretch"/>
    </pageHeader>
    <columnHeader>
        <band height="32" splitType="Stretch">
            <staticText>
                <reportElement x="84" y="0" width="100" height="30" uuid="3b17e526-5b45-45db-b75f-4a86a1608bec"/>
                <text><![CDATA[ASNDETAILID]]></text>
            </staticText>
            <staticText>
                <reportElement x="310" y="0" width="100" height="30" uuid="cd6e9ad5-60a5-4041-894d-970faa1d4bd5"/>
                <text><![CDATA[LINENBR]]></text>
            </staticText>
        </band>
    </columnHeader>
    <detail>
        <band height="33" splitType="Stretch">
            <textField>
                <reportElement x="70" y="0" width="100" height="30" uuid="e8036cc3-bddc-47d7-9686-bbea50bc7f1c"/>
                <textFieldExpression><![CDATA[$F{ASNDETAILID}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="210" y="0" width="100" height="30" uuid="5f3a97c2-6f8e-4458-8f9e-c13890a6b308"/>
                <textFieldExpression><![CDATA[$F{LINENBR}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
    <columnFooter>
        <band height="10" splitType="Stretch"/>
    </columnFooter>
    <pageFooter>
        <band height="7" splitType="Stretch"/>
    </pageFooter>
    <summary>
        <band height="8" splitType="Stretch"/>
    </summary>
</jasperReport>

I am open to all suggestions... again, very little experience with JSON and Jasper... especially around subreports... I was hoping I would not even need a subreport.

1

1 Answers

0
votes

In Subreport, delete all bands except column header and detail . from properties, make all the margins to zero.

In main report, make column header height = field height and delete all other bands. This is all basic alignment.