Table Filter in Report - OR Condition required

Hi All,

I am designing a report considering "Gen. Journal Batch" and "G/L Entry" tables.

I have Batch Name as link field between above tables.

I want to retrieve the records if Sub Type in "Gen. Journal Batch" be either "Cash Receipt Voucher" OR "Cash Payment Voucher" OR "Bank Receipt Voucher" OR "Bank Payment Voucher"

Could you please help with this. How can we apply the OR condition in the Table Filter ?
Chetan
Bangalore

Best Answer

  • vaprogvaprog Member Posts: 1,140
    Answer ✓
    Hi Chetan,

    I doubt your request has been solved by BartD's answer, unless you found out the correct syntax yourself. The correct syntax for a filter expression using alternatives (OR operator) uses the pipe symbol, not the semicolon.

    Furthermore, don't use integer representation for option values if you can avoid it. It produces unreadable code. Furthermore I recommend to always insert values into filter expressions by using the value parameters. Thus, your setfilter statement should look similar to the following:
    "Gen. Journal Batch".SETFILTER("Template Type",'%1|%2|%3',
      "Gen. Journal Batch"."Template Type"::Sales,
      "Gen. Journal Batch"."Template Type"::Purchases,
      "Gen. Journal Batch"."Template Type"::Payments);
    
    In this statement, the filter expression expects the option captions. So there is no way to write rugged and readable code without the value parameters. Also, do not use STRSUBSTNO to insert values into the filter string. STRSUBSTNO does not know about quoting your values for the filter expression, SETFILTER does.

Answers

  • BartDBartD Member Posts: 3
    Hey,

    Setting up in filter can be as follow in c/al:
    GenJnlBatch.SetFilter(GenJnlBatch."Template Type",'0;1;2;3;4');
    The number is the index of the variable in the optionstring. 0 means General, 1 means Sales and so on...

    Or you make an temporary table TmpGen with these options included. GenJnlBatch.SetFilter(GenJnlBatch."Template Type",TmpGenJnlBatch."Template Type");

    Greetnings BartD
  • vaprogvaprog Member Posts: 1,140
    Answer ✓
    Hi Chetan,

    I doubt your request has been solved by BartD's answer, unless you found out the correct syntax yourself. The correct syntax for a filter expression using alternatives (OR operator) uses the pipe symbol, not the semicolon.

    Furthermore, don't use integer representation for option values if you can avoid it. It produces unreadable code. Furthermore I recommend to always insert values into filter expressions by using the value parameters. Thus, your setfilter statement should look similar to the following:
    "Gen. Journal Batch".SETFILTER("Template Type",'%1|%2|%3',
      "Gen. Journal Batch"."Template Type"::Sales,
      "Gen. Journal Batch"."Template Type"::Purchases,
      "Gen. Journal Batch"."Template Type"::Payments);
    
    In this statement, the filter expression expects the option captions. So there is no way to write rugged and readable code without the value parameters. Also, do not use STRSUBSTNO to insert values into the filter string. STRSUBSTNO does not know about quoting your values for the filter expression, SETFILTER does.
Sign In or Register to comment.