Tuesday, 16 July 2013

Trade Agreement Form Duplicates:(b/w from date and todate)


Trade agreement duplicates:


static void findDuplicateTradeAgreements(Args _args)
{
    PriceDiscTable PriceDiscTable,PriceDiscTableLoop;
    InventDim      inventDim,inventDimLoop;
    InventLocationId locationId;
    str            combineOfItemWHouse;
    container      con;
    int            conLength;
    TransDate      fromDate,toDate;
    ;
    while select PriceDiscTable join inventDim where inventDim.inventDimId ==
                                                    PriceDiscTable.InventDimId
    {
        locationId = inventDim.InventLocationId;
        fromDate = PriceDiscTable.FromDate;
        toDate = PriceDiscTable.ToDate;
        combineOfItemWHouse = PriceDiscTable.AccountRelation +
                              PriceDiscTable.ItemRelation + locationId;
        conLength = conLen(con);

        if(!conFind(con,combineOfItemWHouse))
        {
            con = conIns(con,conLength+1,combineOfItemWHouse);
            while select PriceDiscTableLoop where PriceDiscTableLoop.AccountRelation == PriceDiscTable.AccountRelation &&                                                  PriceDiscTableLoop.ItemRelation == PriceDiscTable.ItemRelation
            {
                inventDimLoop = PriceDiscTableLoop.inventDim();
                if(inventDimLoop.InventLocationId == locationId)
                {
                    if(PriceDiscTableLoop.FromDate > fromDate &&
                        PriceDiscTableLoop.FromDate < toDate)
                    {
                        info(strFmt("Vendor = %1 , Item = %2 FromDate = %3 WareHouse = %4 ", PriceDiscTableLoop.AccountRelation,PriceDiscTableLoop.ItemRelation,
PriceDiscTableLoop.FromDate,inventDimLoop.InventLocationId));
                    }
                    if(PriceDiscTableLoop.ToDate > fromDate &&
                             PriceDiscTableLoop.ToDate < toDate)
                    {
                        info(strFmt("Vendor = %1 , Item = %2 Todate = %3 WAreHouse = %4", PriceDiscTableLoop.AccountRelation,PriceDiscTableLoop.ItemRelation,
PriceDiscTableLoop.ToDate,inventDimLoop.InventLocationId));
                    }
                }
            }
        }
    }
}



Trade agreement duplicates:

static void findDuplicateTradejul13(Args _args)
{
    PriceDiscTable  _PriceDiscTable, _PriceDiscTable2;
    InventDim       _InventDim, _InventDim2;
    Set s = new Set(Types::Int64);
    ;

    while select _PriceDiscTable join _InventDim
        order by _PriceDiscTable.AccountRelation,
                 _PriceDiscTable.ItemRelation,
                _InventDim.InventLocationId,
                _PriceDiscTable.FromDate,_PriceDiscTable.ToDate
        //group by _PriceDiscTable.AccountRelation,_PriceDiscTable.ItemRelation
,_InventDim.InventLocationId,_PriceDiscTable.FromDate,_PriceDiscTable.ToDate,_PriceDiscTable.RecId
       
where _PriceDiscTable.InventDimId == _InventDim.inventDimId
        //&& _PriceDiscTable.FromDate != dateNull() && _PriceDiscTable.ToDate != dateNull()
    {

        while select _PriceDiscTable2 join _InventDim2
        order by _PriceDiscTable2.AccountRelation,_PriceDiscTable2.ItemRelation,
                _InventDim2.InventLocationId,_PriceDiscTable2.FromDate,_PriceDiscTable2.ToDate
        where  _PriceDiscTable2.ItemRelation == _PriceDiscTable.ItemRelation
        && _PriceDiscTable2.AccountRelation == _PriceDiscTable.AccountRelation
        && _InventDim2.inventDimId == _PriceDiscTable2.InventDimId
        && _InventDim2.InventLocationId == _InventDim.InventLocationId
        && _PriceDiscTable.RecId != _PriceDiscTable2.RecId
        //&& _PriceDiscTable2.FromDate != dateNull() && _PriceDiscTable2.ToDate != dateNull()
        {
            if(!s.in(_PriceDiscTable2.RecId))
            {
                s.add(_PriceDiscTable2.RecId);

                if(_PriceDiscTable2.FromDate >= _PriceDiscTable.FromDate &&
                   _PriceDiscTable2.ToDate <= _PriceDiscTable.FromDate)
                {
              info(strFmt("%1,%2,%3,%4,%5   ",                      _PriceDiscTable2.AccountRelation,_PriceDiscTable2.ItemRelation,
            _PriceDiscTable2.FromDate,_InventDim2.InventLocationId, _PriceDiscTable2.ToDate));
                }
                else if(_PriceDiscTable2.FromDate <= _PriceDiscTable.FromDate &&
                       _PriceDiscTable2.ToDate <= _PriceDiscTable.ToDate &&
                       _PriceDiscTable2.ToDate >= _PriceDiscTable.FromDate)
                {
                    info(strFmt("%1,%2,%3,%4,%5 ", _PriceDiscTable2.AccountRelation,_PriceDiscTable2.ItemRelation,
_PriceDiscTable2.FromDate,_InventDim2.InventLocationId, _PriceDiscTable2.ToDate));
                }
                else if(_PriceDiscTable2.FromDate <= _PriceDiscTable.ToDate &&
_PriceDiscTable2.FromDate >= _PriceDiscTable.FromDate &&
 _PriceDiscTable2.ToDate >= _PriceDiscTable.ToDate)
                {
                    info(strFmt("%1,%2,%3,%4,%5 ", _PriceDiscTable2.AccountRelation,_PriceDiscTable2.ItemRelation,
_PriceDiscTable2.FromDate,_InventDim2.InventLocationId, _PriceDiscTable2.ToDate));
                }
            }
        }
    }

}


No comments:

Post a Comment