close
public class InventSum_View extends common
{

    private static str prepareInventPhyStr(str key)
    {
        #define.ViewName(InventSum_View)
        #define.DataSourceName("InventSum")

        #define.FieldPostedQty("postedQty")
        #define.FieldPostedValue("PostedValue")
        #define.FieldPhysicalValue("PhysicalValue")
        
        str sReturn,
            postedQty,
            postedValue,
            PhysicalValue;

        DictView dictView2;
        // Construct a DictView object for the present view.
        dictView2 = new DictView(tableNum(#ViewName));
            
        postedQty = dictView2.computedColumnString
        (#DataSourceName,
        #FieldPostedQty,
        FieldNameGenerationMode::FieldList,
        true);

        postedValue = dictView2.computedColumnString
        (#DataSourceName,
        #FieldPostedValue,
        FieldNameGenerationMode::FieldList,
        true);
        
        physicalValue = dictView2.computedColumnString
        (#DataSourceName,
        #FieldPhysicalValue,
        FieldNameGenerationMode::FieldList,
        true);
                      
       switch(key)
        {   
        case "Cost":
            sReturn = "CASE WHEN  sum(" +  postedQty +   ") = 0 OR sum(" +  postedQty +   ") IS NULL "
                    + " THEN 0 "
                    + " ELSE sum(" +  postedValue + ") / sum("  + postedQty +   ")"
                    + " END";
        break;
        case "PostedQty":
            sReturn ="sum("
                    +   postedQty
                    +   ")"    ;
            break;
        case "PostedValue":
            sReturn ="sum("
                    +   PostedValue
                    +   ")"    ;
            break;

            }

        return sReturn;
    }

    private static server str compCostMethod()
    {
        str sReturn;
        sReturn = InventSum_View::prepareInventPhyStr("Cost");
        return sReturn;
    }

    private static server str compPosteQtyMethod()
    {
        str sReturn;
        sReturn = InventSum_View::prepareInventPhyStr("PostedQty");
        return sReturn;
    }

    private static server str compPostedValueMethod()
    {
        str sReturn;
        sReturn = InventSum_View::prepareInventPhyStr("PostedValue");
        return sReturn;
    }

}

 

2. CAL ROW VIEW:

public class DGS_EstByBUTableRowView extends common
{
    private static str prepareSQLStr(str key)
    {
        #define.ViewName(DGS_EstByBUTableRowView)
        #define.DataSourceName3("THK_EstByBUTable")
        
        #define.FieldCalcuDate("CalcuDate")
        #define.FieldWeight("Weight")

        
        str sReturn,          
            Weight,
            CalcuDate;

        DictView dictView2;
        // Construct a DictView object for the present view.
        dictView2 = new DictView(tableNum(#ViewName));
            
    
        CalcuDate = dictView2.computedColumnString
        (#DataSourceName3,
        #FieldCalcuDate,
        FieldNameGenerationMode::FieldList,
        true);
        
        Weight = dictView2.computedColumnString
        (#DataSourceName3,
        #FieldWeight,
        FieldNameGenerationMode::FieldList,
        true);

      
                          
        switch(key)
        {
       
            case "pEstCost":
                sReturn = "ROW_NUMBER() OVER (PARTITION BY  BU, Weight  order by Weight, CalcuDate DESC)";
                break;
        }

        return sReturn;
    }

    private static server str compEstCostMethod()
    {
        str sReturn;
        sReturn = DGS_EstByBUTableRowView::prepareSQLStr("pEstCost");
        return sReturn;
    }

}
arrow
arrow
    全站熱搜

    lionlionchopper 發表在 痞客邦 留言(0) 人氣()