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

field symbols

in field symbols while using assign component <name> of structure <str> to <fs>.

how to get more than one particular values

is this syntax correct

assign component name name1 ..................

if not how?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Posted on Sep 10, 2009 at 12:33 PM

    Hello,

    You have to process this in a DO..ENDDO loop.

    Two ways of doing this, easier way of doing this is:

    DO.
    ASSIGN COMPONENT SY-INDEX OF STRUCTURE <STR> TO <FS>.
    
    IF SY-SUBRC NE 0.
      EXIT.
    ENDIF.
    ENDDO.

    Else if you want to capture specific columns:

    DATA: 
    V_COUNT TYPE I,
    V_FDNAME TYPE FIELDNAME.
    
    DO.
    
    IF SY-INDEX GT 1.
    CONCATENATE 'NAME' V_COUNT INTO V_FDNAME.
    CONDENSE V_FDNAME.
    ELSEIF SY-INDEX = 1.
    V_FDNAME = 'NAME'.
    ENDIF.
    
    ASSIGN COMPONENT V_FDNAME OF STRUCTURE <STR> TO <FS>.
    IF SY-SUBRC NE 0.
      V_COUNT = V_COUNT + 1.
    ELSE.
      EXIT.
    ENDIF.
    ENDDO.

    Cheers,

    Suhas

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 10, 2009 at 12:34 PM

    You have to embreace it with a loop, otheriwse you will get only one component.

    do.
      assign component sy-index of strcuture <str> to <fs>.
      if sy-subrc = 0.
        <fs> ... "as long as succesfull assignment your <fs> will hold subsequent fields
      else.
        exit.  "no more components in strucutre, leave the loop
      endif.
    enddo.
    

    Or you can use components names directly

      assign component FIELD1 of strcuture <str> to <fs>.
    
      assign component FIELD2 of strcuture <str> to <fs>.
    

    Note however that single ASSIGN COMPONENT (without loop) will "return" only one field at a time.

    Regards

    Marcin

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 10, 2009 at 12:37 PM

    Hi,

    try this way..

    FIELD-SYMBOLS: <line> TYPE ANY, "Line structure for table
    
    
    Loop at itab into <FS>.
    
    write : <FS>-name , <FS>-name1.
    
    endloop.
    

    or

    Loop at itab .
    
    * Assign field value from structure
    ASSIGN COMPONENT itab-<fieldname> OF STRUCTURE <line> TO <fieldvalue>.
    
    endloop.
    

    Prabhudas

    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.