Filtering field problem in item and itemledger entry table

monir_asianmonir_asian Member Posts: 80
edited 2012-03-28 in NAV Three Tier
IF((StartDate<>0D) AND(EndDate<>0D)) THEN BEGIN
SETRANGE("Posting Date", StartDate, EndDate);
END;



IF (ProductSubGroupCode<>'') THEN BEGIN
SETFILTER("Product Sub Group Code", '=%1',ProductSubGroupCode) ;
END;

IF ( ProductSize<>'') THEN BEGIN

SETFILTER( "Product Size", '=%1',ProductSize) ;
END;

IF ( Color<>'') THEN BEGIN
SETFILTER("Item Ledger Entry".Color, '=%1', Color) ;

END;



IF ( Material<>'') THEN BEGIN

SETFILTER("Item Ledger Entry".Material, '=%1', Material) ;
END;




IF (FORMAT( SeasonYear)<>'') THEN BEGIN


CASE SeasonYear OF

2001: BEGIN
SETRANGE("Season Year",2001) ;


END;

2002: BEGIN
SETRANGE("Season Year",2002) ;


END;

2003: BEGIN
SETRANGE("Season Year",2003) ;
END;

2004: BEGIN
SETRANGE("Season Year",2004) ;
END;

2005: BEGIN
SETRANGE("Season Year",2005) ;
END;

2006: BEGIN
SETRANGE("Season Year",2006) ;
END;
2007: BEGIN
SETRANGE("Season Year",2007) ;
END;
2008: BEGIN
SETRANGE("Season Year",2008) ;
END;
2009: BEGIN
SETRANGE("Season Year",2009) ;
END;

2010: BEGIN
SETRANGE("Season Year",2010) ;
END;

2011: BEGIN
SETRANGE("Season Year",2011) ;
END;

2012: BEGIN
SETRANGE("Season Year",2012) ;
END;

2013: BEGIN
SETRANGE("Season Year",2013) ;
END;
2014: BEGIN
SETRANGE("Season Year",2014) ;
END;
2015: BEGIN
SETRANGE("Season Year",2015) ;
END;
2016: BEGIN
SETRANGE("Season Year",2016) ;
END;
2017: BEGIN
SETRANGE("Season Year",2017) ;
END;
2018: BEGIN
SETRANGE("Season Year",2018) ;
END;
2019: BEGIN
SETRANGE("Season Year",2019) ;
END;

2020: BEGIN
SETRANGE("Season Year",2020) ;
END;

END;
END;



IF (FORMAT( Season)<>'') THEN BEGIN
CASE Season OF

Season::Spring: BEGIN
"Item Ledger Entry".SETFILTER( "Item Ledger Entry".Season,'=%1',Season::Spring) ;
END;

Season::Summer:BEGIN
"Item Ledger Entry".SETFILTER( "Item Ledger Entry".Season,'=%1',Season::Summer) ;
END;
Season::"Spring-Summer":BEGIN
"Item Ledger Entry".SETFILTER( "Item Ledger Entry".Season,'=%1',Season::"Spring-Summer") ;
END;
Season::Autumn:BEGIN
"Item Ledger Entry".SETFILTER( "Item Ledger Entry".Season,'=%1',Season::Autumn) ;
END;
Season::Winter:BEGIN
"Item Ledger Entry".SETFILTER( "Item Ledger Entry".Season,'=%1',Season::Winter) ;
END;
Season::"Autumn-Winter":BEGIN
"Item Ledger Entry".SETFILTER( "Item Ledger Entry".Season,'=%1',Season::"Autumn-Winter") ;
END;
END;
END;


IF (FORMAT( Style)<>'') THEN BEGIN


CASE Style OF
Style::premium: BEGIN
"Item Ledger Entry".SETFILTER( "Item Ledger Entry".Style,'=%1',Style::premium) ;
END;
Style::economy:BEGIN
"Item Ledger Entry".SETFILTER( "Item Ledger Entry".Style,'=%1',Style::economy) ;
END;
Style::casual:BEGIN
"Item Ledger Entry".SETFILTER( "Item Ledger Entry".Style,'=%1',Style::casual) ;
END;

Style::classic:BEGIN
"Item Ledger Entry".SETFILTER( "Item Ledger Entry".Style,'=%1',Style::classic) ;
END;
Style::fashion:BEGIN
"Item Ledger Entry".SETFILTER( "Item Ledger Entry".Style,'=%1',Style::fashion) ;
END;


Style::biom:BEGIN
"Item Ledger Entry".SETFILTER( "Item Ledger Entry".Style,'=%1',Style::biom) ;
END;

Style::performance:BEGIN
"Item Ledger Entry".SETFILTER( "Item Ledger Entry".Style,'=%1',Style::performance) ;
END;



END;

END;


IF (BuyerNo<>'') THEN BEGIN
"Item Ledger Entry".SETFILTER( "Item Ledger Entry"."Buyer No.", '=%1',BuyerNo) ;
END;


IF (ItemCategoryCode<>'') THEN BEGIN
"Item Ledger Entry".SETFILTER( "Item Ledger Entry"."Item Category Code", '=%1',ItemCategoryCode) ;
END;


IF (ProductGroupCode<>'') THEN BEGIN
"Item Ledger Entry".SETFILTER("Item Ledger Entry"."Product Group Code", '=%1',ProductGroupCode) ;
END;



IF (ItemNo<>'') THEN BEGIN

"Item Ledger Entry".SETRANGE("Item Ledger Entry"."Item No.",ItemNo) ;
END;





IF (ItemNo2<>'') THEN BEGIN

"Item Ledger Entry".SETRANGE("Item Ledger Entry"."Item No. 2",ItemNo2) ;
END;



IF (GlobalDimension2Code<>'') THEN BEGIN
SETFILTER("Global Dimension 2 Code",'=%1',GlobalDimension2Code) ;


END;


IF (LocationCode<>'') THEN BEGIN
"Item Ledger Entry".SETFILTER( "Item Ledger Entry"."Location Code", '=%1', LocationCode);
END;






IF (Description<>'') THEN BEGIN

"Item Ledger Entry".SETFILTER("Item Ledger Entry".Description, '=%1',Description);
END;




////////////////////////////////////


"Item Ledger Entry".SETFILTER("Entry Type", '=%1',"Item Ledger Entry"."Entry Type"::Purchase);



I used this filtering field. but it is not working.

when we should use setrange filter and when we should use setfilter field?

Comments

  • mohana_cse06mohana_cse06 Member Posts: 5,504
    why do you need all this code?
    IF (FORMAT( SeasonYear)<>'') THEN BEGIN
    
    
    CASE SeasonYear OF
    
    2001: BEGIN
    SETRANGE("Season Year",2001) ;
    
    
    END;
    
    2002: BEGIN
    SETRANGE("Season Year",2002) ;
    
    
    END;
    
    2003: BEGIN
    SETRANGE("Season Year",2003) ;
    END;
    
    2004: BEGIN
    SETRANGE("Season Year",2004) ;
    END;
    
    2005: BEGIN
    SETRANGE("Season Year",2005) ;
    END;
    
    2006: BEGIN
    SETRANGE("Season Year",2006) ;
    END;
    2007: BEGIN
    SETRANGE("Season Year",2007) ;
    END;
    2008: BEGIN
    SETRANGE("Season Year",2008) ;
    END;
    2009: BEGIN
    SETRANGE("Season Year",2009) ;
    END;
    
    2010: BEGIN
    SETRANGE("Season Year",2010) ;
    END;
    
    2011: BEGIN
    SETRANGE("Season Year",2011) ;
    END;
    
    2012: BEGIN
    SETRANGE("Season Year",2012) ;
    END;
    
    2013: BEGIN
    SETRANGE("Season Year",2013) ;
    END;
    2014: BEGIN
    SETRANGE("Season Year",2014) ;
    END;
    2015: BEGIN
    SETRANGE("Season Year",2015) ;
    END;
    2016: BEGIN
    SETRANGE("Season Year",2016) ;
    END;
    2017: BEGIN
    SETRANGE("Season Year",2017) ;
    END;
    2018: BEGIN
    SETRANGE("Season Year",2018) ;
    END;
    2019: BEGIN
    SETRANGE("Season Year",2019) ;
    END;
    
    2020: BEGIN
    SETRANGE("Season Year",2020) ;
    END;
    
    END;
    END;
    

    Can it be simply?
    IF SeasonYear <> 0 THEN
      SETRANGE("Season Year",SeasonYear) ;
    
  • SogSog Member Posts: 1,023
    get some senior help, this is godawefull

    Seasonyear is awefull, remove the entire case structure and use setrange("season year",seasonyear)
    if you have a type mismatch then change type of seasonyear...
    and more of those ](*,)
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
Sign In or Register to comment.