Skip to Content

Field symbols in loop

Hello ,

I have a loop like this

LOOP AT t_marm INTO p_mattab FROM sy-tabix.

IF p_mattab-matnr NE p_matnr.

CLEAR p_mattab.

EXIT.

ENDIF.

ENDLOOP.

t_marm is of type marm and p_mattab is of type meinh

If we are modifying marm with an include, error is thrown in this loop becoz of unicode.

I want to use field symbols for this .Could anyone please help me in this.

Thanks in advance

Sudha

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    Posted on Dec 05, 2007 at 08:12 AM

    Hi Sudha,

    if you use loop at itab .. assigning <fs> you will save time because nothing is ever copied into a header line but you are working on the table line directly. For this reason you will never use a MODIFY itab. I don't know why it is syntactically allowed although it has no effect and no sense at all.

    You will not solve any unicode issues by just replacing the header line/work area with a field-symbol. You must analyze the error reason and resolve it. Field-symbols might help you when they are assigned to components of structure, but I really don't know what the unicode issue is in your case.

    Regards,

    Clemens

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Clemens.

      There is still a use for MODIFY. I frequently process tables where I don't know until runtime the structure. So I have to use ASSIGN COMPONENT. If I loop at ASSIGNING, then I have to do the component assignment inside the loop. If I instead create a work area, and loop INTO, I can do the component assignment outside the loop. This latter approach is more efficient.

      Matt

  • author's profile photo Former Member
    Former Member
    Posted on Dec 05, 2007 at 07:46 AM

    hi,

    Field-symbols: <fs-name> as a modified internal tbale type.

    LOOP AT t_marm INTO p_mattab FROM sy-tabix asssigning <fs_name>

    IF p_mattab-matnr NE p_matnr.

    <fs-name>-field = modifiing table field

    modify itable.

    CLEAR p_mattab.

    EXIT.

    ENDIF.

    ENDLOOP.

    I will give you example code. after 10mins

    sekhar

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 05, 2007 at 07:52 AM

    hi,

    Again Sekar here

    you can observe the following code, you might be get some idea........

    Data: BEGIN OF i_easte OCCURS 0,

    perverbr LIKE easte-perverbr,

    logikzw LIKE easts-logikzw,

    END OF i_easte.

    FIELD-SYMBOLS:

    <f_easts> LIKE i_easts.

    IF sy-subrc EQ 0.

    SELECT perverbr

    logikzw

    FROM easte

    INTO TABLE i_easte

    FOR ALL ENTRIES IN i_easts

    WHERE logikzw EQ i_easts-logikzw.

    ENDIF.

    IF NOT i_easte[] IS INITIAL.

    LOOP AT i_easts ASSIGNING <f_easts>.

    READ TABLE i_easte WITH KEY logikzw = <f_easts>-logikzw.

    IF sy-subrc EQ 0.

    <f_easts>-perverbr = i_easte-perverbr.

    ENDIF.

    ENDLOOP.

    ENDIF.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 05, 2007 at 08:26 AM

    You can not solve your unicode problem just by using fieldsysombols. Even fieldsymbols have a type and what you get is a typeconflict. Typeconflicts cant be solved this way.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 05, 2007 at 10:12 AM

    > t_marm is of type marm and p_mattab is of type meinh

    That's your problem right there. Whether you're using a field symbol or a work area the type should be the same (unless you're trying to do the equivalent of a C union, which doesn't appear to make sense here).

    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.