How to get Fieldref value

yekedeyekede Member Posts: 96
Please how do i achieve this:
number: type decimal
recref: type recordref
fieldref: type fieldref

recref.open(27);
fieldref := recref.filedindex(3);
fieldref.setfilter(string);
number := number + fieldref.value;
It throws an error: cannot add decimal and joker

Comments

  • ReinhardReinhard Member Posts: 249
    I'm not sure what the goal is but to get the value from a field ref you need to do something like:
    EVALUATE(number,FORMAT(fieldRef));
    

    Take a look at F1 help as well.
  • vaprogvaprog Member Posts: 1,139
    DecimalVar : type decimal
    DecimalVar := fieldref.value;
    number := number + DecimalVar;
    
    The type to the right of the + operator is not uniquely defined by the operator. Fieldref does not determine it's type from the field it refers to. Therefore you need to help C/AL a little by assigning the value to some object with fixed type.
    The FORMAT / EVALUATE combo will work, but it will be costly and potentiality lossy.
  • yekedeyekede Member Posts: 96
    vaprog wrote:
    DecimalVar : type decimal
    DecimalVar := fieldref.value;
    number := number + DecimalVar;
    
    Error message: type conversion not possible because one of the operator contain an invalid type: Decimal + Joker
    Thanks for your reply.
  • yekedeyekede Member Posts: 96
    yekede wrote:
    vaprog wrote:
    DecimalVar : type decimal
    DecimalVar := fieldref.value;
    number := number + DecimalVar;
    
    Error message: type conversion not possible because one of the operator contain an invalid type: Decimal + Joker
    Thanks for your reply.
    Hello Vaprog,
    I'm sorry. it's working fine. the error message was coming because i was doing
     DecimalVar := DecimalVar + fieldref.value;
    
Sign In or Register to comment.