Skip to Content
author's profile photo Former Member
Former Member

How to get every field of a struct. While we donu2019t know about the structure

I want to make a function which accepts the structure as parameter and added all numeric fields of that structure.

While I donu2019t know how much fields does a structure have which is going to be passed to function.

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 Nov 01, 2008 at 11:11 AM

    hi:

    this fm just give the fields name of the structure. i want too the values which each field have.

    can u helpout.

    Add a comment
    10|10000 characters needed characters exceeded

    • Try this

      DATA: l_count TYPE i.
      
      FIELD-SYMBOLS: <fld> TYPE ANY.
      
      l_count = 0.
      DO.
        ADD 1 TO l_count.
        ASSIGN COMPONENT l_count OF STRUCTURE mystruc TO <fld>.
        IF sy-subrc IS NOT INITIAL.
          EXIT.
        ENDIF.
        DESCRIBE FIELD <fld> TYPE the_type.
        IF the_type is a numeric field - see the DESCRIBE help for more info
        ADD <fld> TO total.
      ENDDO.

      If the structure is defined in the data dictionary, then you can use the FM mentioned above DDIF_FIELDINFO_GET , and use ASSIGN COMPONENT (fieldname) OF STRUCTURE mystruc TO <fld>.

      matt

  • author's profile photo Former Member
    Former Member
    Posted on Nov 01, 2008 at 09:38 AM

    Hi,

    fm DDIF_FIELDINFO_GET

    check it...

    Regards

    Debarshi

    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.