Skip to Content
-4

Field symbol is not getting assigned

We have following code:

DATA: l_search_fields TYPE adsrchline,
im_t_search_fields TYPE TABLE OF adsrchline,
l_fieldname TYPE dynfnam.

**----------------------------------------------------------------------
** Field Symbols
**----------------------------------------------------------------------
FIELD-SYMBOLS: <fs_fieldname> TYPE ANY.

LOOP AT im_t_search_fields INTO l_search_fields.
CONCATENATE 'ex_match_struc-'
l_search_fields-fieldname
INTO l_fieldname.
ASSIGN (l_fieldname) TO <fs_fieldname>.
MOVE l_search_fields-content TO <fs_fieldname>.
ENDLOOP.

For 20 millions records above code worked fine but after that it gave dump 'GETWA_NOT_ASSIGNED' at MOVE command. Please help me to solve this as I am clueless why it worked earlier and now it is giving dump.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Jan 12 at 10:24 AM

    Use a more 'solid' code like

    LOOP AT im_t_search_fields INTO l_search_fields.
      ASSIGN COMPONENT l_search_fields-fieldname OF STRUCTURE ex_match_struc TO <fs_fieldname>.
      IF <fs> IS NOT ASSIGNED.
        MESSAGE e207(/bobf/conf) WITH l_search_fields-fieldname 'EX_MATCH_STRUC'.
        " Field &1 of value set is not part of structure of &2
      ELSE.
        MOVE l_search_fields-content TO <fs_fieldname>.
      ENDIF.
    ENDLOOP.

    then look for any recent change in program or ddic structure?

    Hint: If the exported structure is actually dynamic use cl_abap_structdescr or similar class to provide more information, like ddic structure name.

    Add comment
    10|10000 characters needed characters exceeded

    • It's actually irrelevant in this case why this worked before and stopped working. It was poorly written code to begin with. We can't just say ASSIGN and not check if it actually happened ("assumption is mother of all screw-ups"), not to mention ASSIGN COMPONENT has been around for ages already.

      Don't be like the person who wrote that code and read ABAP documentation. There are examples available of the proper use of ASSIGN. There are also many SCN blogs and Q&A on this subject, one recent blog example can be found in Google.

  • Jan 12 at 10:15 AM

    Firstly, please use the code formatting ("CODE" button) when posting code. It makes code look like code and much easier to read.

    The error is telling you that l_fieldname did not get assigned. Please review the contents of your other variables, they should be listed in the dump.

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 12 at 10:23 AM

    It seems to me pretty easy: structure ex_match_struc- doesn't contain a certain field listed in the table im_t_search_fields.

    Avoiding it's easy too: just check your assign has worked otherwise handle the error.

    Add comment
    10|10000 characters needed characters exceeded