Skip to Content
-2

field-name and field-value in two different variables... how can i equate them?

I have fieldname and fieldvalue in two different variables... how can i equate them?is it possible.
field_name = abc
field_value = xyz
I want abc = xyz

fyi, all 3 fields( field_name , field_value, abc) declared in the program so no issue with declaration.

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Posted on May 11 at 08:01 AM

    Hi,

    No need for macro. Simply use dynamic ABAP programming and fields symbols. Something like this:

    DATA:
      ls_configuration TYPE ztable. " your configuration from table
    
    FIELD-SYMBOLS:
      <lv_field> TYPE any.
    
    SELECT SINGLE *
      INTO @ls_configuration
      FROM ztable
      WHERE key = 'key_value';
    IF sy-subrc = 0.
      ASSIGN COMPONENT ls_configuration-field OF STRUCTURE febre TO <lv_field>.
      IF sy-subrc = 0.
        <lv_field> = ls_configuration-value.
      ENDIF.
    ENDIF.
    

    If you have multiple fields with multiple value then selected them into internal table and then do the ASSIGN COMPONENT part in a LOOP.

    Hope this helps.

    regards,

    Mateusz

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Mar 30 at 05:22 AM
    -1

    Hi Venkat,
    My apologies for not explaining correctly. Explaining the requirement in a simple way.
    Suppose I have table with 3 columns as below

    We will select column 2 and column 3 with where condition on column 1.Now in our program , we have structure FEBRE with many fields(vwezw,zuonr etc) . which field of FEBRE has to be filled and with what value will be decided respectively by column 2 and column 3 selected from table.Basically I dont want to write field name (FEBRE-VWEZW or FEBRE-ZUONR) in the program.Something dynamically should be done to fill the field of structure as maintained in the table. So after selecting from table i will have column 2 and column3 in different variable and want to equate them like below.
    select column2 and column 3 from table where column = 111 into variable 1 and variable 2.
    Variable 1 = FEBRE-VWEZW
    variable 2 = XYZ
    My requirement to make FEBRE-VWEZW = XYZ in program
    Please note FEBRE-VWEZW is already declared as a structure-field in the program.

    Thanks Venkat for helping me in this:)


    Add a comment
    10|10000 characters needed characters exceeded