Dynamically Assign Field Content

How to dynamically assign field content?

This will answer your query:

data: rec type string.
        s = lv_index.

---------------->

This is how you can populate dynamically using <FS>.

loop at t_temp_rec .

    loop at t_rec_tst into  wa_rec_tst where matnr =
      t_temp_rec-matnr and werks = t_temp_rec-werks.

      s = lv_index.
      concatenate 'wa_rec-rec' s into recpt.

      assign  (recpt)  to <fs1>.

      <fs1> = wa_rec_tst-real_qty.
      lv_index = lv_index + 1.

    endloop.

    wa_rec-matnr = wa_rec_tst-matnr.
    wa_rec-werks = wa_rec_tst-werks.
    clear: t_temp_rec , wa_rec_tst.
    append wa_rec to t_rec.
    clear: wa_rec.
    lv_index = 1.

endloop.

t_rec will have fields rec1, rec2 populated dynamically depending on the matching condition & sy-tabix that is lv_index.

ABAP Books List
ABAP/4 Certification, Programming, Smartforms, Sapscripts and Object Oriented Programming Books

Smart Forms
SAP Smartforms

ABAP Menu:
ABAP Example Hints and Tips

Return to Index:-
SAP ABAP/4 Programming, Basis Administration, Configuration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.  The site www.gotothings.com is in no way affiliated with SAP AG.
Any unauthorised copying or mirroring is prohibited.