Transforming the string value into a table field - Forum - OpenEdge Development - Progress Community

Transforming the string value into a table field

 Forum

Transforming the string value into a table field

This question is not answered
temp-table tt-param
     field c-from as char
     field c-to as char.

create tt-param.
assign tt-param.c-from = "#name#"
            tt-param.c-to = "customer.name".

def var c-string as char no-undo. assign c-string = "my company #name#". find first customer no-lock no-error.

How to convert the string value "tt-param.c-to"  to table field.

Sorry for bad English.

All Replies
  • The following code'll create a dynamic buffer for the table, then reference the field for that buffer that you want. Because you're creating a dynamic object, you'll also need to delete it from memory when you're done.



    DEFINE VARIABLE hBuffer AS HANDLE NO-UNDO. DEFINE VARIABLE hField AS HANDLE NO-UNDO. CREATE BUFFER hBuffer FOR TABLE ENTRY(1, tt-param.c-to, ".") . hField = hBuffer:BUFFER-FIELD(ENTRY(2, tt-param.c-to, ".")). MESSAGE hField:BUFFER-VALUE VIEW-AS ALERT-BOX INFO BUTTON OK.

    DELETE OBJECT hBuffer.
  • DEFINE VARIABLE hBuffer AS HANDLE NO-UNDO.
    DEFINE VARIABLE hField  AS HANDLE NO-UNDO.
    def var c-string as char no-undo.
    
    
    DEFINE TEMP-TABLE tt-param
        field c-from as char
        field c-to as char.
     
    create tt-param.
    assign tt-param.c-from = "#name#"
                tt-param.c-to = "estabelec.nome".
     
    assign c-string  = "my company #name#".
     
    find first estabelec no-lock no-error.
    
    
    MESSAGE estabelec.nome SKIP
        ENTRY(1, tt-param.c-to, ".") 
        VIEW-AS ALERT-BOX INFO BUTTONS OK.
    
    /* Message: NAME = OK (show) , entry = estabelec */
    
    CREATE BUFFER hBuffer
        FOR TABLE ENTRY(1, tt-param.c-to, ".").
        
    ASSIGN hField = hBuffer:BUFFER-FIELD(ENTRY(2, tt-param.c-to, ".")).
    
    /* Message ERROR: **RECORD NOT AVAILABLE */
    
    MESSAGE hField:BUFFER-VALUE
        VIEW-AS ALERT-BOX info BUTTON OK.
  • Forgot to add that you'll need to do something like this after the CREATE BUFFER.

      hBuffer:FIND-FIRST("estabelec WHERE estabelec.CustNum = 123").

    That'll get you a start on using dynamic buffers. Consult the reference docs for more information on how to proceed.

  • OK, thanks...

    but if so, would somehow too?

    tt-param.c-to = "IF estabelec.state = 1 THEN 'xxxx' ELSE 'aaaa'".

    Sorry ;)

  • You can put that in the WHERE phrase of a dynamic lookup, there's no way to execute that at run-time though.

  • Thank you for the tip... but.... rsrsrs

    /* He has caught the table above information without having to run the statement again. */
    
    hBuffer = BUFFER estabelec:HANDLE.
    hField = hBuffer:BUFFER-FIELD(ENTRY(2, tt-param.c-to, ".")).
    
    /*
    how to change this:  estabelec:HANDLE
    for this: ENTRY(1, tt-param.c-to, ".")
    */
    
    MESSAGE hField:BUFFER-VALUE
        VIEW-AS ALERT-BOX info BUTTON OK.
    
  • If you don't need a dynamic buffer, then you can chain these:

    hField = BUFFER estabelec:HANDLE:BUFFER-FIELD(ENTRY(2, tt-param.c-to, ".")):BUFFER-VALUE
  • Tim,
    I have this temp table with several more in different fields and tables also wanted to automate it.

    table estabelec has can not be fixed.

    ||

    hField = BUFFER estabelec:HANDLE:BUFFER-FIELD(ENTRY(2, tt-param.c-to, ".")):BUFFER-VALUE 

  • Then you have to use the CREATE BUFFER technique. You can put that code into a procedure and then call it as needed for each TT record / configuration you're using.

  • Excuse my ignorance but you could show me an example?

  • Look in the Reference docs for "PROCEDURE", you'll find examples of how to write a procedure, pass parameters, etc.

  • Sorry, I tried using includes and procedures and can not replace 'estabelec:HANDLE' for '{1}:HANDLE'

    He does not use the value of the field only the name of his declaration "ENTRY(1, tt-param.c-to, ".")"