Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Field symbols in loop

sudha_naik
Advisor
Advisor
0 Kudos

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

1 ACCEPTED SOLUTION

Clemenss
Active Contributor
0 Kudos

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

6 REPLIES 6

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

Clemenss
Active Contributor
0 Kudos

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

matt
Active Contributor
0 Kudos

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

rainer_hbenthal
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

> 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).