BMW3000
BMW3000

Reputation: 111

How to change loop with SELECT in abap to field-symbol

I have a code like this:

i_mahn is a itab.
Data: gt_mahn type table of i_mahn,
gs_result type i_mahn.
  LOOP AT gt_mahn into gs_result
    SELECT * FROM mhnd
                 INTO gs_mhnd
                 WHERE laufd EQ gs_result-laufd
                 AND   laufi EQ gs_result-laufi
                 AND   cpdky EQ gs_result-cpdky
      MOVE-CORRESPONDING gs_mhnd TO gs_result.
    ENDSELECT.
  ENDLOOP.

and I want to change it to a loop with a field symbol but how? I know that the field-symbol only contains the positions of where the information have been but I dont know how to use the field symbol withe the select in this case....

field-symbols: <gs_mahn> like line of gt_mahn
  LOOP AT gt_mahn appending <gs_mahn>
    SELECT * FROM mhnd
                 INTO ???
                 WHERE laufd EQ <gs_mahn>-laufd
                 AND   laufi EQ <gs_mahn>-laufi
                 AND   cpdky EQ <gs_mahn>-cpdky
      MOVE-CORRESPONDING ??? TO ???.
    ENDSELECT.
  ENDLOOP.

Upvotes: 0

Views: 1999

Answers (1)

dotchuZ
dotchuZ

Reputation: 2641

field-symbols: <gs_mahn> like line of gt_mahn.
  LOOP AT gt_mahn ASSIGNING <gs_mahn>.
    SELECT * FROM mhnd INTO gt_mahn
                 WHERE laufd EQ <gs_mahn>-laufd
                 AND   laufi EQ <gs_mahn>-laufi
                 AND   cpdky EQ <gs_mahn>-cpdky
      MOVE-CORRESPONDING <gs_mahn> TO <whatever>.
    ENDSELECT.
  ENDLOOP.

I really don't know what you are doing, but in my example you can see how to use field-symbols... google might have also known this easily ... https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abenfield-symbol_inline.htm

Upvotes: 0

Related Questions