get one field from itab with read table TRANSPORTING

funkeeiads picture funkeeiads · Jan 8, 2015 · Viewed 24.5k times · Source

I trying to get one field from interal table like this:

READ TABLE tbl_peps TRANSPORTING ususap INTO lv_responsable WITH KEY usr03 = wa_tbl_prps-usr03.

This sentence is wrong, it gives me an error

tbl_peps and lv_responsable are incompatibles

.

Is there a way to achieve that using "transporting fields"?

Answer

Alexander Jäger picture Alexander Jäger · Jan 17, 2015

With the new syntax (At least ABAP 7.40) you do not need a workarea anymore. The coding for your example would be:

try.
    lv_responsable = tbl_peps[ usr03 = wa_tbl_prps-usr03 ]-ususap.
catch CX_SY_ITAB_LINE_NOT_FOUND.
endtry.

Further info of the new table expressions can be found here.