Generic Object Read

SOLVED

I need to create a generic function to read an object in X3.  I'm thinking some of the standard object functionality could be used, or maybe even a dynamic query, but I'm not completely sure how to approach it.

For example, I want to pass a table name, select field, and compare field:

TABLE = "BPCUSTOMER"

SELFLD = "BPCNUM"

CMPFLD = "NA009"

And it would return the customer from BPCUSTOMER where BPCNUM="NA009".

I have done queries with dynamic select criteria, but I'm not sure how to make the entire query/read statement dynamic.

Read [F:BPC]BPC0=CMPFLD

or

For [F:BPC] Where BPCNUM=CMPFLD

Has anybody done anything like this?

  • +1
    verified answer

    hello Denise, 

    STD subprob may help you here 
    Call LECTURE("BPC",TIERS,"") From CONTOBJ

    Or maybe this

    Funprog TEST(ZTABLE,ZSELFLD,ZVAL)
    Value Char ZTABLE
    Value Char ZSELFLD
    Value Char ZVAL
    Local Char RES

    If !clalev([F:ZZZ]): Local File =nomap+"."+ZTABLE [F:ZZZ] : Endif

    RES = ''
    Local Char ZFILTER(250)
    ZFILTER = "1=1"
    ZFILTER += "&" - ZSELFLD - "='"+ZVAL+"'"

    For [F:ZZZ] Where evalue(ZFILTER)
      RES = evalue("[ZZZ]"+ZSELFLD)
    Next

    End RES

    To be adapted of course, if you need more fields as filters or other types. 

  • 0 in reply to JulienB

    Thank you.  I will give this a try.