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: 

Assign Statement not working

vallamuthu_madheswaran2
Active Contributor
0 Kudos
492

Hi Friends,

Kindly find the attached code. I have tried the assign statement. all the statement gives an error.

LOOP AT t_t682z INTO DATA(lwa_varkey) WHERE qufna CS lv_qufna.
              lv_fieldname    = lwa_varkey-qustr.
              lv_fieldname+31 = '-'.
              lv_fieldname+32 = lwa_varkey-qufna.
              CONDENSE lv_fieldname NO-GAPS.
              CONCATENATE '''' lv_fieldname '''' INTO w_field.
              lv_fld = w_field.
              ASSIGN (w_field) TO <fs_qunfa>.
              ASSIGN (w_field) TO <f>.
              ASSIGN (lv_fld) TO <fs_qunfa>.
              ASSIGN (lv_fld) TO <f>.
              IF sy-subrc = 0.
                <fs_qunfa> = <fs_field>.
              ENDIF.
          ENDLOOP.<br>

Thanks with regards,
Vallamuthu M

7 REPLIES 7

jens_michaelsen
Participant
0 Kudos
383

I can't see the ASSIGN for <fs_field>???

Sandra_Rossi
Active Contributor
0 Kudos
383

What error message?

Eduardo-CE
Active Participant
0 Kudos
383
DATA: BEGIN OF line,
        col1 TYPE i VALUE 11,
        col2 TYPE i VALUE 22,
        col3 TYPE i VALUE 33,
      END OF line.

DATA comp(5) TYPE c VALUE 'COL3'.

FIELD-SYMBOLS: <f1> TYPE ANY, <f2> TYPE ANY, <f3> TYPE ANY.

ASSIGN line TO <f1>.
ASSIGN comp TO <f2>.

  DO 3 TIMES.
  ASSIGN COMPONENT sy-index OF STRUCTURE <f1> TO <f3>.
  WRITE <f3>.
  ENDDO.

ASSIGN COMPONENT <f2> OF STRUCTURE <f1> TO <f3>.

0 Kudos
383

I have assign the field to KOMK and KOMP field.

Thanks with regards,

Vallamuthu M.

vallamuthu_madheswaran2
Active Contributor
0 Kudos
383

Hi Sandra Rossi,

Thanks for your update.

sy-subrc = 4.

Thanks with regards,

Vallamuthu M.

Sandra_Rossi
Active Contributor
0 Kudos
383

If you do that:

ASSIGN (w_field) TO <fs_qunfa>.

the variable W_FIELD must contain a variable name WITHOUT QUOTES, so, instead of doing this:

CONCATENATE '''' lv_fieldname '''' INTO w_field.

you should just do that:

w_field = lv_fieldname.

ASSIGN (w_field) TO <fs_qunfa>.

matt
Active Contributor
383

Love it. Prefixing field-symbols with FS. As though < > wasn't sufficient identifier!