Friday, 27 May 2016

Computed Columns in View

For Enum type field :

 private static server str  TypeLabel()
    {
        DictEnum dictEnum = new DictEnum(enumNum(LedgerTransType));
        int enumIdx;
        Map valuesMap = new Map(Types::String, Types::String);
        for (enumIdx = 1; enumIdx <= dictEnum.values(); enumIdx++)
        {
            valuesMap.insert(int2str(dictEnum.index2Value(enumIdx)), SysComputedColumn::returnLiteral(dictEnum.index2Symbol(enumIdx)));
        }
        return SysComputedColumn::switch(
        SysComputedColumn::returnField(tableStr(CITVendPaymentEntity), identifierStr(VendTransInvoice),
        fieldStr(CITVendPaymentEntity, TransType)),
        valuesMap,
        SysComputedColumn::returnLiteral('[unknown value]'));
       
    }


   public static server str  TypeLabel()
    {
        DictEnum dictEnum = new DictEnum(enumNum(CustVendACType));
        int enumIdx;
        Map valuesMap = new Map(Types::String, Types::String);
        for (enumIdx = 0; enumIdx <= dictEnum.values()-1; enumIdx++)
        {
            valuesMap.insert(int2str(dictEnum.index2Value(enumIdx)), SysComputedColumn::returnLiteral(dictEnum.index2Symbol(enumIdx)));
        }
        return SysComputedColumn::switch(
            SysComputedColumn::returnLiteral(CustVendACType::Vend),
        valuesMap,
        SysComputedColumn::returnLiteral('[unknown value]'));
    }
    public static server str Remaininginvoicebalance()
    {
        return SysComputedColumn::Subtract(
        SysComputedColumn::returnfield(tablestr(CITVendPaymentEntity),identifierStr(VendTransPayment),fieldstr(CITVendPaymentEntity,AmountCur)),
        SysComputedColumn::returnfield(tablestr(CITVendPaymentEntity),identifierStr(VendTransPayment),fieldstr(CITVendPaymentEntity,SettleAmountCur)));
    }

}=====================================================================
public static server str salesStatus()
{
    DictView    dv = new DictView(tableNum(DocuSalesOrderOpenInquiryView));
    str     a,b,c;
    DictEnum dictEnum = new DictEnum(enumNum(SalesStatus));
    int enumIdx;
    Map valuesMap = new Map(Types::String, Types::String);

    for (enumIdx = 1; enumIdx <= dictEnum.values(); enumIdx++)
    {
        valuesMap.insert(int2str(dictEnum.index2Value(enumIdx)), SysComputedColumn::returnLiteral(dictEnum.index2Symbol(enumIdx)));
    }

    a = dv.computedColumnString(identifierStr(Docuref),fieldStr(DocuRef,RefRecId));
    b = SysComputedColumn::returnField(tableStr(DocuSalesOrderOpenInquiryView),identifierStr(SalesTable),fieldStr(SalesTable,RecId));

    c = SysComputedColumn::compareExpressions(a,'=',b);
    return SysComputedColumn::if(c,
    SysComputedColumn::switch(
        SysComputedColumn::returnField(tableStr(DocuSalesOrderOpenInquiryView), identifierStr(SalesTable), fieldStr(SalesTable, SalesStatus)),
        valuesMap,
        SysComputedColumn::returnLiteral('[unknown value]')),
    SysComputedColumn::switch(
        SysComputedColumn::returnField(tableStr(DocuSalesOrderOpenInquiryView), identifierStr(SalesLine), fieldStr(SalesLine,   SalesStatus)),
        valuesMap,
        SysComputedColumn::returnLiteral('[unknown value]')));

}

 For String type field :

public static server str salesStatus()
{
    DictView    dv = new DictView(tableNum(DocuSalesOrderOpenInquiryView));
    str     a,b,c;
    DictEnum dictEnum = new DictEnum(enumNum(SalesStatus));
    int enumIdx;
    Map valuesMap = new Map(Types::String, Types::String);

    for (enumIdx = 1; enumIdx <= dictEnum.values(); enumIdx++)
    {
        valuesMap.insert(int2str(dictEnum.index2Value(enumIdx)), SysComputedColumn::returnLiteral(dictEnum.index2Symbol(enumIdx)));
    }

    a = dv.computedColumnString(identifierStr(Docuref),fieldStr(DocuRef,RefRecId));
    b = SysComputedColumn::returnField(tableStr(DocuSalesOrderOpenInquiryView),identifierStr(SalesTable),fieldStr(SalesTable,RecId));

    c = SysComputedColumn::compareExpressions(a,'=',b);
    return SysComputedColumn::if(c,
    SysComputedColumn::switch(
        SysComputedColumn::returnField(tableStr(DocuSalesOrderOpenInquiryView), identifierStr(SalesTable), fieldStr(SalesTable, SalesStatus)),
        valuesMap,
        SysComputedColumn::returnLiteral('[unknown value]')),
    SysComputedColumn::switch(
        SysComputedColumn::returnField(tableStr(DocuSalesOrderOpenInquiryView), identifierStr(SalesLine), fieldStr(SalesLine, SalesStatus)),
        valuesMap,
        SysComputedColumn::returnLiteral('[unknown value]')));

}


No comments:

Post a Comment