Is it possible to store a field name in a variable, then assign it a value?

Good day, everyone!
I am working on a program in which there are many different amount fields in which an amount may be assigned.  For reusability purposes, I was wondering if it would be possible to write a routine that identifies the target amount field, stores it in a variable that is passed back to the calling program, and then assigns a value to it.  There may be different structures having the same field name; what I'm trying to do is avoid having to code a huge IF or CASE statement for each structure.  For example:
Structures S1, S2, and S3 have some fields identically named.  Call one of them F1.
What I'd like to do is call a routine that identifies "F1" as my target field to populate.  Then, upon return, I can assign it to the desired structure.  Kinda like this:
S1-fieldname = 24.17.  (but fieldname isn't a true field in the structure -- it would hold the value of the true field, "F1").
I realize this might not even be possible, but given how talented the folks are on this forum, I thought I should at least pose the question.
As always, points given for all helpful answers, and thank you!!
Dave

Ok.  I gave that a shot, but what happens is that my ASSIGN COMPONENT statement doesn't work.  It gets a sy-subrc of 4, and <column> remains unassigned.  The program then abends on the line to assign <a1>-trbtr's value to the field because of <column> being unassigned.
  DATA:
    w_setname         TYPE setleaf-setname,
    w_column_name(20) TYPE c.
    ASSIGN COMPONENT w_column_name OF STRUCTURE wa_expense_ng_report
                  TO <column>.
    <column> = <a1>-trbtr.
Any thoughts on what I might be doing wrong?

Similar Messages

  • Using table field name as a variable

    Hi ,
    Is it possible to map some values to a field in a Ztable , if I have the field name of the Ztable in a variable.
    For ex:
    I have a ZTABLE -- which has some fields - ZF1 and ZF2.
    In my code, I determine the field in which I want to put data at runtime. For ex, in my code i determine at runtime I want to update field ZF2 , but I have this field name in a variable <V_FIELDNAME>
    So, Is it possible to do something as:
    <V_FIELDNAME> = ZF2.
    ZTABLE-<V_FIELDNAME>    =    <VARIABLE -SOME VALUE>.
    and this value should actually maps to ZTABLE-ZF2.
    If it is possible , how to do it ?
    Thanks-

    Hi Tamas,
    Thanks a lot for ur post ! it did certainly help. However, I need some more help.
    Here is what I need -
    I will have a string coming up from an interface which would be something like : Val1;Val2;Val3
    And in SAP R/3 I have a variable maintained as : Field1;Field2;Field3
    Field1 Field2 and Field3 are fields of a ZTABLE.
    So , at runtime, using the variable I have to determine which Value goes to which field and then insert this field in ZTABLE.
    So, ultimately , code should perform the following actions:
    ZTABLE-FIELD1 = Val1
    ZTABLE-FIELD2 = Val2
    ZTABLE-FIELD3 = Val3
    Insert ZTABLE.
    Going by code you provided, I can assign individual values, But then ultimately I need to map it to a structure which can be used to insert in a DB table. How can I do this?
    Thanks-

  • E-recruiting: Requisition management - Possible to change the field names??

    Hi to all e-recruiting experts,
    Need some assistance pertaining to the requisition management portion in e-recruiting.
    We have showed the standard SAP E-recruiting requisition bsp pages to our client and they have requested changes to the field names as they feel that the standard names are not intuitive enough.
    For instance,
    The field - "Hierarchy Level" - They have requested to change to "Job Grade"
    and the field "Functional Area"  to "Type of Work".
    Is there any way that i can change the name of the field through configurations?
    I understand that in a infotype, we can change the field name through translation. But can we change it in BSP? I was told to explore on how to configure via OTR.
    Can anyone share on the steps involved?
    Many thanks in advance.

    Well quite easy,
    create a context for an otr text (E-Recruiting are in package PAOC_RCF_UI). You will find that in SOTR_EDIT.
    Activate this context with implementing BADI BTFR_CONTEXT.
    After doing this, adjust context in SOTR_EDIT with Go To -> Context -> Adjust.
    Eventually refresh otr buffer with Transaction /$otr
    For one text there can be more than one OTR Text in backend, so you might change more than one.
    Regards

  • How can I store a form name with path and then call form from a table

    Is it possible that any form that I built I store that form in some table in DB and then call that form from table, if yes, then how can i get this functionality. I am not very experience in form and do not know if it can be done because i think if it is possible then this can be a good security for application and easy to handle as well.
    Thanks in advance
    Maz

    If you have a Forms block based on this table:
    declare
      module varchar2(100);
    begin
      module := :block.column;
      call_form ( module ) ;
    end;If you don't have any blok based on that table
    declare
      module varchar2(100);
    begin
      select  module_name
      into module
      from ...
      where ...
      call_form ( module ) ;
    end;Francois

  • Is it possible to leave a field alone in an IF THEN formula?

    I'm not sure if I'm asking this right, but I will try as hard as I can to explain it concisely.
    B2 = $180.00
    C2 = B2*.81
    D2 = Checkbox
    How do I make an IF THEN telling B2=$0.00 when D2=TRUE without it affecting the value in B2 if D2=FALSE?
    Basically, I need the checkbox to insert a specific value ($0.00) into B2 without affecting a value I previously entered into B2 if the checkbox is unclicked...
    Is that even possible?  I can get it to zero with no problem, I just can't figure out how to make it so that I can enter a value in a cell with a formula already existing and have it not affected by the IF THEN statement if the checkbox is false... this may be a pipe dream....
    Thanks in advance.

    Hi JayHawk,
    Further to Ian's post...
    Cells in a spreadsheet can contain entered values or values that have been calculated by a formula in the cell.If you enter a value into a cell containing a formula, the entered value replaced the formula (permanently).
    Ian has shown you a way to make the result (in D2) zero when the box in E2 is checked. You can move that calculation into C2 by combining the formulas in D2 and C2:
    C2: =IF(E2,0,B2*$C$1)
    Where =B2*$C$1 was the original formula in C2.
    See Example 1 below.
    Or you can enter the starting value in a separate cell (A2 for Example 2 below) and use the IF function in a formula in B2 to set that value to either A2 or zero, depending on the state of the checkbox in E2:
    B2: =IF(E2,0,A2)
    C2: =B2*0,81
    OR
    C2: =B2*$C$1
    The $C$1 cell reference pulls the percentage from cell C1 and uses that as the multiplier. The $ operators make that an absolute reference. If the formula is filled into other cells, the reference stays fixed on cell C1.
    Regards,
    Barry

  • Is it possible to use internal table field name as variable?

    data : temp_string(10) type c.
    data : result type string.
    temp_string = 'field1'.
    loop at itab1 into str1.
      result =  str1-temp_string. "error here"
    endloop.
    HI.
    think this code not executable and actually fail to compile.
    is it possible to put structure field name with variable?
    anyone can help me ? please
    thank you.
    Regards
    Bae

    You may use of COMPONENT of your structure.
    FIELD-SYMBOLS: <F>.
    ASSIGN COMPONENT I OF STRUCTURE F TO <F>.
    To find index of component you may use
    DESCRIBE FIELD f INTO td.
    (But SAP beware us)
    Regards

  • How to make Form Field names appear for User??

    Hi im creating a form template that will be sent to over 150 stores so I need this to work and be easier for my stores.
    Is is possible to make the field names visable for the user so they know what details are need in the fields?
    Please if anybody can help!!

    Sorry I forgot to mention I need it to visible on Text boxes, doesnt seem to be working

  • Dynamic field name in an assignment statement

    Greetings,
    Is it possible to make the field name of an assignment dynamic?
    For example if I have two text fields called P1_F1 and P1_F2. Is it possible to
    do something like this?
    declare
    X number := 0;
    begin
    X := 1;
    :P1_F || X   = 'value1';
    X := 2;
    :P1_F || X   = 'value2';
    end;Any suggestions would be appreciated.
    Thanks
    Larry

    Use the <tt>apex_util.set_session_state</tt> API method.

  • Fields names and fields labels

    Hello everybody!!
    I would like to know if there is a way to know the name of a field in a dynpro knowing its description.
    Eg:
    I know the field label _(description)--> vendor,  and I want to guess the field name (lifnr)
    thank you very much!

    Hi,
    You can check the table DD04T...to get the data element for the corresponding text..
    Is this what you want??
    If you want to know in debugging..I believe it is not possible to get the field name for the field description..
    Thanks
    Naren

  • Mass t,code field name issue

    Hi
    In t.code massobj bus2105 purchase requisition in field list new entries object type bus2105,table name eban,field name ebakz, save it,then i check mass t.code bus2105 field name ebakz not coming,plz help
    Regards
    Sam

    Sorry, I miss to put the recomendation, that it should be used properly for no risky fields like EBAKZ.
    It might sure create inconsistencies for the unproper use, After finishing the job, it could be restore that app exit as a proper suggestion though.
    thanks for the comment Jürgen L

  • Variables for Field Names.

    This may be a silly one for ya but I am having a brain fart
    now.
    I am doing a dynamic form where the form questions are
    created fro a database.
    The different field names are dynamic variables generated via
    itererations (++) from the database table.
    The problem is that when I submit the form I need the field
    names as the insert or update value to populate the values
    statement in the query. I am having a problem locking down the
    actual values to use for the insert or update statement.
    I will need to use a loop to iterate through the variables.
    Look at the code form the form.
    Thanks in advance.
    Gene

    Too much code for me to analyze.
    But see if any of these development tricks lead the way for
    you.
    On your action page:
    <cfdump var="#form#>
    <cfoutput>
    <cfloop collection="#form#" item="field">
    #field# = #form[field]#<br>
    </cfloop>
    <cfoutput>
    <cfoutput>
    #form.fieldNames#<br>
    <cfloop list="#form.fieldNames#" index="field">
    #field# = #form[field]#<br>
    </cfloop>
    <cfoutput>

  • Dynamic Work Area Field name Assignment.

    hi Guru,
      data: it_SFLIGHT type TABLE OF SFLIGHT,
              wa_SFLIGHT TYPE SFLIGHT,
              lv_field TYPE string.
      lv_field =     'CARRID'.   " Field name
        wa_SFLIGHT-<lv_field> = 'vivek'.  " Assigning Value to workarea.
    When i try this i am getting the error.
    Regards.
    Vivekananthan.S

    Hi,
    assign (p_tc_name) to <tc>.
    TYPES:
      BEGIN OF st_mytable,
        name1 TYPE string,
        name2 TYPE string,
        age TYPE i,
      END OF st_mytable.
    DATA:
      gi_mytable TYPE STANDARD TABLE OF st_mytable,
      g_mytable  TYPE st_mytable.
    * Define field symbols
    FIELD-SYMBOLS:
      <myfield1> TYPE ANY,
      <myfield2> TYPE ANY,
      <myfield3> TYPE ANY,
      <myline>  TYPE ANY.
    * Fill table with data
    g_mytable-name1 = 'John'.
    g_mytable-name2 = 'Johnson'.
    g_mytable-age   = 25.
    APPEND g_mytable TO gi_mytable.
    g_mytable-name1 = 'Claudio'.
    g_mytable-name2 = 'Jensen'.
    g_mytable-age   =  45.
    APPEND g_mytable TO gi_mytable.
    * The normal way to do it
    LOOP AT gi_mytable INTO g_mytable.
      WRITE: / g_mytable-name1, g_mytable-name2 ,g_mytable-age.
    ENDLOOP.
    SKIP 2.
    * Do it with field symbols
    LOOP AT gi_mytable ASSIGNING <myline>.
      ASSIGN COMPONENT 1 OF STRUCTURE <myline> TO <myfield1>.
      ASSIGN COMPONENT 2 OF STRUCTURE <myline> TO <myfield2>.
      ASSIGN component 3 OF STRUCTURE <myline> TO <myfield3>.
      WRITE: / <myfield1>,<myfield2>,<myfield3>.
    ENDLOOP.
    * Unassign field symbols
    UNASSIGN <myfield1>.
    UNASSIGN <myfield2>.
    UNASSIGN <myfield3>.
    UNASSIGN <myline>.
    Regards,
    Prabhudas

  • Icon name as Global variable

    Hi,
    In my forms i can set a single static icon name for a button. Is it possible to give the icon name as global variable name to change the icon of the button dynamically by changin the value of the global variable.
    Using set_item_property i can change. But it seems tough to implement in my forms.
    Please Help!
    Balaji.M

    What's the problem with set_item_property??
    You can use the global variables to store the name of icon file to associate with the button.
    But, ultimately you'll have to use the set_item_property to reflect the changes dynamically.
    set_item_property(<block.item name>,ICON_NAME,:global.<icon file name>);
    I don't think, by just setting global variables you can get your requirement to work.
    You'll have to use set_item_property, if you want to change the icon file name dynamically.
    Please mark answer as helpful / correct, if it helps you
    Navnit

  • Query name in the variable pop up

    Hi everybody,
    does anybody know if it is possible to put the Query name in the variable pop up in a web query? they want to see the name of the query at first sight when they open the web query and variable pop up comes up.
    thanks a lot
    Manu

    Hi Mike,
    I don't think there is much hope in this area. There was another post on this topic that you can look at:
    Re: Web Reporting - Variable Screen - Title of Report

  • Which table stores field names and their description?

    When I go to se11; I can get information about a table; its field names and field description.
    How can I access same information using an ABP Program? I have a third party tool which connects to SAP; it can pull data from any SAP Table or view. I do not know which table or view stores information displayed in SE11.
    Thanks a lot.

    Hi zigzagdna,
    The field names and their description are strored in table DD03L and DD03T.
    SAP DDIC dictionary informations are generally store in DD* tables. You can search this kinds of DD* tables in SE11 using F4 search help.
    With Best Regards
    Julia

Maybe you are looking for

  • Disable Logon for a specific BSP pages?

    One of my requirements is to not have logon to BSP pages. Right now it asks for my SAP logon. I dont want any type of authentication for some of my BSP pages. Any help or suggestion will be helpful and appreciated. Thanks Nahman

  • When to use dithering?

    Hey everybody, Right now I am exporting roughly 100 titling effecs, one at a time, in 16 bit depth at 1920x1080 resolution. Do I need to be using dithering? I remember reading somewhere (the Motion help manual, I think) that dithering should only be

  • Automated work on table existance

    Hello, Oracle9i Enterprise Edition Release 9.2.0.1.0 – Production Windows XP Service Professional Service Pack 1 Is there any way by which we can perform a certain task/job on the event of existence of specific table (whether by create table or sqlld

  • I downloaded a song from Itunes that seems to be corupteed. What do I do???

    The file was ***** as a dandy. Downloaded love rears its ugly head. Hope you can help Cheers Mikkel

  • Could someone help me out?

    Hi,everybody: I don't familiar with Solaris and OAS any more,in fact I'm a freshman in this field.But recently I've done a JAVA project and its enviroment is Solaris 5.7 and OAS R.4.0.8.2. I wanna ask you some questions if not bother you: 1: Can OAS