× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: Header and Detail
  • From: "Stone, Brad V (TC)" <bvstone@xxxxxxxxxxxxxx>
  • Date: Fri, 16 Mar 2001 09:05:02 -0600

I played for a while, and here's what I have:

The basic concept is for every header record (icsmControlList) read 1 or
more detail records (icsmDetailList).

It works so far, but I know there's some "tightening".  As usual, any
comments are welcome.  The reason XML tags are "hard coded" is because this
is a servlet who's specific task is to output this data in XML.  Also, some
methods do take a few parms, but that will be cleaned up later as well.

Basically I build a table object for the header.  I loop through the entries
for the header.  For each loop I return the key values from the header table
and build another table object for the detail records and loop through
those.

    // sendID, recID and batch are read from the browser
    // sqlWhere builds an SQL Where statement
    sqlWhere = buildWhere(sendID, recID, batch);
    sqlOrder = "SND_ID, REC_ID, SND_BATCH";

    // FieldTableDefinition constructor takes a filename for database
properties, a file name to 
    // get data from, an SQL where statement, and SQLOrder statement and the
number of records
    // to store in the field table
    FieldTableDefinition icsmControlList = new
FieldTableDefinition(databaseProperties,"ICSMCTLPF", sqlWhere, sqlOrder, 5);

    out.println("<Group>");

    for (int i = 0; i < icsmControlList.size(); i++)
    {
      out.println("<Batch>");
      out.println("<Control>");
      // this retrieves a string of XML for the list of fields in the vector
      outString = FieldListFormatter.toXML((Vector) icsmControlList.get(i));
      out.println(outString);
      out.println("</Control>");

      // getField retrieves the actual data for the fields in the vector
field list
      sendID = FieldListFormatter.getField((Vector)
icsmControlList.get(i),"SND_ID").data;
      recID = FieldListFormatter.getField((Vector)
icsmControlList.get(i),"REC_ID").data;
      batch = FieldListFormatter.getField((Vector)
icsmControlList.get(i),"SND_BATCH").data;

      sqlWhere = buildWhere(sendID, recID, batch);
      FieldTableDefinition icsmDetailList = new
FieldTableDefinition(databaseProperties,"ICSMEDIPF", sqlWhere, sqlOrder, 5);

      out.println("<DetailRecords>");

      for (int j = 0; j < icsmDetailList.size(); j++)
      {
        out.println("<Detail>");
        outString=FieldListFormatter.toXML((Vector) icsmDetailList.get(j));
        out.println(outString);
        out.println("</Detail>");
      }

      out.println("</DetailRecords>");

      out.println("</Batch>");
    }

    out.println("</Group>");
+---
| This is the JAVA/400 Mailing List!
| To submit a new message, send your mail to JAVA400-L@midrange.com.
| To subscribe to this list send email to JAVA400-L-SUB@midrange.com.
| To unsubscribe from this list send email to JAVA400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner: joe@zappie.net
+---

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.