public static MPrintFormat loadPrintFormat(Properties ctx,MProcess process,String trxName) throws Exception {
  MPrintFormat retValue=null;
  if (process.getAD_PrintFormat_ID() == 0) {
    I_AD_ReportView reportView=process.getAD_ReportView();
    int reportViewId=0;
    int tableId=0;
    if (reportView != null) {
      reportViewId=reportView.getAD_ReportView_ID();
      tableId=reportView.getAD_Table_ID();
    }
    PreparedStatement pstmt=null;
    ResultSet rs=null;
    String sql="SELECT * FROM AD_PrintFormat WHERE ";
    if (reportViewId > 0) {
      sql+="AD_ReportView_ID=?";
    }
 else {
      sql+="AD_Table_ID=?";
    }
    sql+=" AND AD_Client_ID = " + Env.getAD_Client_ID(ctx);
    sql+=" ORDER BY IsDefault DESC";
    try {
      pstmt=DB.prepareStatement(sql,trxName);
      pstmt.setInt(1,reportViewId > 0 ? reportViewId : tableId);
      rs=pstmt.executeQuery();
      if (rs.next()) {
        retValue=new MPrintFormat(ctx,rs,trxName);
      }
    }
 catch (    Exception e) {
    }
 finally {
      DB.close(rs,pstmt);
      pstmt=null;
      rs=null;
    }
    retValue=retValue == null ? MPrintFormat.createFromTable(ctx,tableId) : retValue;
  }
 else {
    retValue=new MPrintFormat(ctx,process.getAD_PrintFormat_ID(),null);
  }
  return retValue;
}

public static MPrintFormat loadPrintFormat ( Properties ctx , MProcess process , String trxName ) throws Exception { MPrintFormat retValue = null ; if ( process . getAD_PrintFormat_ID ( ) == 0 ) { I_AD_ReportView reportView = process . getAD_ReportView ( ) ; int reportViewId = 0 ; int tableId = 0 ; if ( reportView != null ) { reportViewId = reportView . getAD_ReportView_ID ( ) ; tableId = reportView . getAD_Table_ID ( ) ; } PreparedStatement pstmt = null ; ResultSet rs = null ; String sql = "SELECT * FROM AD_PrintFormat WHERE " ; if ( reportViewId > 0 ) { sql += "AD_ReportView_ID=?" ; } else { sql += "AD_Table_ID=?" ; } sql += " AND AD_Client_ID = " + Env . getAD_Client_ID ( ctx ) ; sql += " ORDER BY IsDefault DESC" ; try { pstmt = DB . prepareStatement ( sql , trxName ) ; pstmt . setInt ( 1 , reportViewId > 0 ? reportViewId : tableId ) ; rs = pstmt . executeQuery ( ) ; if ( rs . next ( ) ) { retValue = new MPrintFormat ( ctx , rs , trxName ) ; } } catch ( Exception e ) { } finally { DB . close ( rs , pstmt ) ; pstmt = null ; rs = null ; } retValue = retValue == null ? MPrintFormat . createFromTable ( ctx , tableId ) : retValue ; } else { retValue = new MPrintFormat ( ctx , process . getAD_PrintFormat_ID ( ) , null ) ; } return retValue ; }
loads the print format associated with a process or if none is found , loads its default one .
