Skip to Content

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jun 18, 2008 at 08:31 PM

    Hi,

    The value in the variable w_column_name should be in capital letters...which means the field name in the variable should be in capital letters..

    Thanks

    Naren

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 18, 2008 at 08:04 PM

    You can do that by the use of Field-Symbols.

    http://help.sap.com/saphelp_46c/helpdata/en/fc/eb3923358411d1829f0000e829fbfe/content.htm

    check the link to get the details of how to use a field symbol and try to implement it in your solution

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.