Skip to Content

take value from string for where condition

Hello,

I have two dropdown by index in my webdynpro where I can get two string values. The first is a string that i would like to use as column name in a 'where condition' of a delete statement, the second is the value to which the field should be equal. How can I use the value of this strings in a where condition?

I tried to use brackets but it doesn't work.

my code is:

  data: lv_attr type string,

        lv_field type string.

*        lv_condition type string,

*        tmp type string,

*        lt_temptab TYPE TABLE OF ZTEST_SFLIGHT,

*        ls_temptab LIKE LINE OF lt_temptab,

*        dref type ref to data.



  WD_CONTEXT->GET_CHILD_NODE( name = 'NODE_DELETEFORM' )->GET_ATTRIBUTE( EXPORTING NAME = 'VALUE' IMPORTING VALUE = lv_attr ).

  WD_CONTEXT->GET_CHILD_NODE( name = 'NODE_TABFIELDS' )->GET_ATTRIBUTE( EXPORTING NAME = 'FIELDS' IMPORTING VALUE = lv_field ).



  delete from ztest_sflight where (lv_field) eq (lv_attr).
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    Oct 19, 2016 at 11:28 AM

    this worked for me!!!

      data: lv_attr type string,
    
            lv_field type string,
    
            s type string.
    
    
    
      WD_CONTEXT->GET_CHILD_NODE( name = 'NODE_DELETEFORM' )->GET_ATTRIBUTE( EXPORTING NAME = 'VALUE' IMPORTING VALUE = lv_attr ).
    
      WD_CONTEXT->GET_CHILD_NODE( name = 'NODE_TABFIELDS' )->GET_ATTRIBUTE( EXPORTING NAME = 'FIELDS' IMPORTING VALUE = lv_field ).
    
    
    
      concatenate lv_field '=' 'lv_attr' into s SEPARATED BY space.
    
    
    
      delete from ztest_sflight where (s).
    Add comment
    10|10000 characters needed characters exceeded

  • Oct 19, 2016 at 09:04 AM

    actually the problem is only with lv_field, because if I write "where carrid = lv_attr" it works. But I would like to take the value of the field from dropdown by index.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 19, 2016 at 09:41 AM

    Hi

    Try using field symbols instead of strings(assign the value of strings to the field symbols).

    Regards

    Raj

    Add comment
    10|10000 characters needed characters exceeded

    • FIELD-SYMBOLS: <fs> TYPE string.
      ASSIGN lv_field TO <fs>.

      WD_CONTEXT->GET_CHILD_NODE( name = 'NODE_DELETEFORM' )->GET_ATTRIBUTE( EXPORTING NAME = 'VALUE' IMPORTING VALUE = lv_attr ).
      WD_CONTEXT->GET_CHILD_NODE( name = 'NODE_TABFIELDS' )->GET_ATTRIBUTE( EXPORTING NAME = 'FIELDS' IMPORTING VALUE = lv_field ).

      delete from ztest_sflight where <fs> eq lv_attr.

      if I write this way and try to activate , an error message says "field <fs> unknown"

  • avatar image
    Former Member
    Oct 19, 2016 at 10:32 AM

    Hi

    Build your whole where condition into field symbol.

    For E.g:

    concatenate <fs_attr> = <lv_field> and move it to <fs>

    DELETE FROM ZTEST_SFLIGHT WHERE <fs>.

    Add comment
    10|10000 characters needed characters exceeded