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 Symbol issue

Former Member
0 Kudos

Hi,

I am using field symbols for storing name in f_zzname field.

first of all I am assigning component 86 (which is zzname) of <wa_covp_ext> to <f_zzname>.

and then selecting sname in <f_zzname> from pa0001 table.

but then value of this <f_zzname> is not reflecting in <wa_covp_ext>.

Finally I want to get the zzname value in <fs>.

Can anyone help with this?

LOOP AT <fs> ASSIGNING <wa_covp_ext>.

ASSIGN COMPONENT 86 OF STRUCTURE <wa_covp_ext> TO <f_zzname>.

IF sy-subrc = 0.

ASSIGN COMPONENT 158 OF STRUCTURE <wa_covp_ext> TO <f_pernr>.

IF sy-subrc = 0.

ASSIGN pa0001-sname TO <f_zzname>.

SELECT SINGLE sname INTO <f_zzname> FROM pa0001

WHERE pernr = <f_pernr>

AND endda GE sy-datum

AND begda LE sy-datum.

IF sy-subrc EQ 0.

MODIFY <fs> FROM <wa_covp_ext>.

ENDIF.

ENDIF.

ENDIF.

ENDLOOP.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi

U're assigning <f_zzname> again:

The first assignment:

ASSIGN COMPONENT 86 OF STRUCTURE <wa_covp_ext> TO <f_zzname>.

The second assignment:

ASSIGN pa0001-sname TO <f_zzname>.

If you wan to select the data from pa0001 and move it to <wa_covp_ext>, you don't need the second assignment:

LOOP AT <fs> ASSIGNING <wa_covp_ext>.
  ASSIGN COMPONENT 86 OF STRUCTURE <wa_covp_ext> TO <f_zzname>.
  IF sy-subrc = 0.
    ASSIGN COMPONENT 158 OF STRUCTURE <wa_covp_ext> TO <f_pernr>.
      IF sy-subrc = 0.
*ASSIGN pa0001-sname TO <f_zzname>. "<------- It doesn't need it
       SELECT SINGLE sname INTO <f_zzname> FROM pa0001
          WHERE pernr = <f_pernr>
                AND endda GE sy-datum
                AND begda LE sy-datum.
*        IF sy-subrc EQ 0.                                "<------- It doesn't need it
*          MODIFY <fs> FROM <wa_covp_ext>. "<------- It doesn't need it
*        ENDIF.                                                "<------- It doesn't need it
      ENDIF.
   ENDIF.
ENDLOOP.

P.s.: if you use field-symbols u don't need MODIFY statament, but <FS> will be updated automatically: the field-symbol is a pointer so the data is move to the record of the internal table automatically.

Max

3 REPLIES 3

Former Member
0 Kudos

Hi

U're assigning <f_zzname> again:

The first assignment:

ASSIGN COMPONENT 86 OF STRUCTURE <wa_covp_ext> TO <f_zzname>.

The second assignment:

ASSIGN pa0001-sname TO <f_zzname>.

If you wan to select the data from pa0001 and move it to <wa_covp_ext>, you don't need the second assignment:

LOOP AT <fs> ASSIGNING <wa_covp_ext>.
  ASSIGN COMPONENT 86 OF STRUCTURE <wa_covp_ext> TO <f_zzname>.
  IF sy-subrc = 0.
    ASSIGN COMPONENT 158 OF STRUCTURE <wa_covp_ext> TO <f_pernr>.
      IF sy-subrc = 0.
*ASSIGN pa0001-sname TO <f_zzname>. "<------- It doesn't need it
       SELECT SINGLE sname INTO <f_zzname> FROM pa0001
          WHERE pernr = <f_pernr>
                AND endda GE sy-datum
                AND begda LE sy-datum.
*        IF sy-subrc EQ 0.                                "<------- It doesn't need it
*          MODIFY <fs> FROM <wa_covp_ext>. "<------- It doesn't need it
*        ENDIF.                                                "<------- It doesn't need it
      ENDIF.
   ENDIF.
ENDLOOP.

P.s.: if you use field-symbols u don't need MODIFY statament, but <FS> will be updated automatically: the field-symbol is a pointer so the data is move to the record of the internal table automatically.

Max

0 Kudos

Thanks Max. it solved my problem.

Former Member
0 Kudos

Remove

ASSIGN pa0001-sname TO <f_zzname>.

as it is undoing the assignment done to <f_zzname>, by

ASSIGN COMPONENT 86 OF STRUCTURE <wa_covp_ext> TO <f_zzname>.

that links <f_zzname> to the internal table row that you are looping