private void genTable(String tableName,String whereClause,boolean completeXML,Properties ctx,WebInfo wi){
  String l_szTrxName=null;
  StringBuffer tmpCode=new StringBuffer();
  String dataTableName=tableName;
  String l_whereClause=replaceSessionElements(wi,whereClause);
  tmpCode.append("<" + tableName + ">\n");
  if (whereClause.indexOf("AD_Reference") > -1) {
    dataTableName="AD_Ref_List";
  }
  int[] l_nIDs=PO.getAllIDs(dataTableName,l_whereClause,l_szTrxName);
  int[] l_nTableIDs=MTable.getAllIDs("AD_Table","TableName='" + dataTableName + "'",l_szTrxName);
  if (l_nTableIDs.length > 0) {
    MTable table=MTable.get(ctx,l_nTableIDs[0]);
    PO l_Object=null;
    if (completeXML) {
      for (int i=0; i < l_nIDs.length; i++) {
        l_Object=table.getPO(l_nIDs[i],l_szTrxName);
        l_Object.get_xmlString(tmpCode);
      }
    }
 else {
      String sql=MLookupFactory.getLookup_TableDirEmbed(Language.getLanguage("en"),dataTableName + "_ID",dataTableName);
      sql=sql.concat(" AND " + l_whereClause);
      PreparedStatement pstm=DB.prepareStatement(sql,l_szTrxName);
      ResultSet rs=null;
      try {
        rs=pstm.executeQuery();
      }
 catch (      Exception e) {
      }
      for (int i=0; i < l_nIDs.length; i++) {
        l_Object=table.getPO(l_nIDs[i],l_szTrxName);
        tmpCode.append("<" + dataTableName + " AD_Table_ID=\""+ table.get_ID()+ "\" Record_ID=\""+ l_Object.get_ID()+ "\">\n");
        tmpCode.append("<" + dataTableName + "_ID>");
        tmpCode.append(l_Object.get_ID());
        tmpCode.append("</" + dataTableName + "_ID>\n");
        if (dataTableName.equals("AD_Ref_List")) {
          tmpCode.append("<Value>");
          tmpCode.append("<![CDATA[" + l_Object.get_Value("Value") + "]]>\n");
          tmpCode.append("</Value>\n");
        }
        if (dataTableName.equals("AD_User") || dataTableName.equals("C_Project")) {
          tmpCode.append("<C_BPartner_ID>");
          tmpCode.append(l_Object.get_Value("C_BPartner_ID"));
          tmpCode.append("</C_BPartner_ID>\n");
        }
        tmpCode.append("<DisplayName>\n");
        try {
          if (rs.next()) {
            tmpCode.append("<![CDATA[" + rs.getString(1) + "]]>\n");
          }
        }
 catch (        SQLException e) {
          tmpCode.append("<![CDATA[" + e.getMessage() + "]]\n");
        }
        tmpCode.append("</DisplayName>\n");
        tmpCode.append("</" + dataTableName + ">\n");
      }
      try {
        rs.close();
        pstm.close();
      }
 catch (      Exception e) {
      }
    }
  }
  tmpCode.append("</" + tableName + ">\n");
  xmlCode.append(tmpCode);
}

private void genTable ( String tableName , String whereClause , boolean completeXML , Properties ctx , WebInfo wi ) { String l_szTrxName = null ; StringBuffer tmpCode = new StringBuffer ( ) ; String dataTableName = tableName ; String l_whereClause = replaceSessionElements ( wi , whereClause ) ; tmpCode . append ( "<" + tableName + ">\n" ) ; if ( whereClause . indexOf ( "AD_Reference" ) > - 1 ) { dataTableName = "AD_Ref_List" ; } int [ ] l_nIDs = PO . getAllIDs ( dataTableName , l_whereClause , l_szTrxName ) ; int [ ] l_nTableIDs = MTable . getAllIDs ( "AD_Table" , "TableName='" + dataTableName + "'" , l_szTrxName ) ; if ( l_nTableIDs . length > 0 ) { MTable table = MTable . get ( ctx , l_nTableIDs [ 0 ] ) ; PO l_Object = null ; if ( completeXML ) { for ( int i = 0 ; i < l_nIDs . length ; i ++ ) { l_Object = table . getPO ( l_nIDs [ i ] , l_szTrxName ) ; l_Object . get_xmlString ( tmpCode ) ; } } else { String sql = MLookupFactory . getLookup_TableDirEmbed ( Language . getLanguage ( "en" ) , dataTableName + "_ID" , dataTableName ) ; sql = sql . concat ( " AND " + l_whereClause ) ; PreparedStatement pstm = DB . prepareStatement ( sql , l_szTrxName ) ; ResultSet rs = null ; try { rs = pstm . executeQuery ( ) ; } catch ( Exception e ) { } for ( int i = 0 ; i < l_nIDs . length ; i ++ ) { l_Object = table . getPO ( l_nIDs [ i ] , l_szTrxName ) ; tmpCode . append ( "<" + dataTableName + " AD_Table_ID=\"" + table . get_ID ( ) + "\" Record_ID=\"" + l_Object . get_ID ( ) + "\">\n" ) ; tmpCode . append ( "<" + dataTableName + "_ID>" ) ; tmpCode . append ( l_Object . get_ID ( ) ) ; tmpCode . append ( "</" + dataTableName + "_ID>\n" ) ; if ( dataTableName . equals ( "AD_Ref_List" ) ) { tmpCode . append ( "<Value>" ) ; tmpCode . append ( "<![CDATA[" + l_Object . get_Value ( "Value" ) + "]]>\n" ) ; tmpCode . append ( "</Value>\n" ) ; } if ( dataTableName . equals ( "AD_User" ) || dataTableName . equals ( "C_Project" ) ) { tmpCode . append ( "<C_BPartner_ID>" ) ; tmpCode . append ( l_Object . get_Value ( "C_BPartner_ID" ) ) ; tmpCode . append ( "</C_BPartner_ID>\n" ) ; } tmpCode . append ( "<DisplayName>\n" ) ; try { if ( rs . next ( ) ) { tmpCode . append ( "<![CDATA[" + rs . getString ( 1 ) + "]]>\n" ) ; } } catch ( SQLException e ) { tmpCode . append ( "<![CDATA[" + e . getMessage ( ) + "]]\n" ) ; } tmpCode . append ( "</DisplayName>\n" ) ; tmpCode . append ( "</" + dataTableName + ">\n" ) ; } try { rs . close ( ) ; pstm . close ( ) ; } catch ( Exception e ) { } } } tmpCode . append ( "</" + tableName + ">\n" ) ; xmlCode . append ( tmpCode ) ; }
creates the nodes for the request tables in the xml - tree .
