Reducing an assign and return to a single statement leads to an error.
 
Forums / SmartComponent Library - Developer Forum / Reducing an assign and return to a single statement leads to an error.

Reducing an assign and return to a single statement leads to an error.

2 posts, 0 answered
  1. Simon Prinsloo
    Simon Prinsloo avatar
    11 posts
    Registered:
    20 Feb 2019
    04 May 2020
    Link to this post

    We changed some code from a variable definition and two statements to a single statement, but then the code stopped working.

    Did anybody encounter this before? Any idea why this happens? It happens with any DatasetModel.

    This works:

    method public logical canFindByCustomerNumber(input icCustomerNumber as character):
        define variable CustomerDatasetModel as CustomerDatasetModel no-undo.
        assign CustomerDatasetModel = getByCustomerNumber(icCustomerNumber).
        return CustomerDatasetModel:Customer:Available.
    end method.


    Changing it like this does not:

    method public logical canFindByCustomerNumber(input icCustomerNumber as character):
        return getByCustomerNumber(icCustomerNumber):Customer:Available.
    end method.
    It raises error 10068:
    Lead attributes in a chained-attribute expression (a:b:c) must be type HANDLE or a user-defined type and valid (not UNKNOWN). (10068)

    Stepping with the debugger into the table model's available property reveals that THIS-OBJECT:BufferHandle is valid, but trying to evaluate  BufferHandle:AVAILABLE in the expressions results in "**Not available**".

    The following code gives the message below:
    message 
    1 valid-object(getByCustomerNumber(icCustomerNumber)) skip 
        2 valid-object(getByCustomerNumber(icCustomerNumber):Customer) skip
    3 getByCustomerNumber(icCustomerNumber):Customer:Available
    view-as alert-box.

    1 yes
    2 yes
    3

  2. Mike Fechner
    Mike Fechner avatar
    342 posts
    Registered:
    14 Sep 2016
    06 May 2020 in reply to Simon Prinsloo
    Link to this post
    Interesting. This method here works though:

        METHOD PUBLIC LOGICAL canFindByCustomerNumber2 (piCustNum AS INTEGER):
            RETURN NEW CustomerDatasetModel():Customer:Filter:CustNum:EQ(piCustNum):CanFind() .
        END METHOD.


2 posts, 0 answered