Get one field from itab with reading table TRANSPORTING

I am trying to get one field from an interal table as follows:

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 incompatible

.

Is there a way to achieve this using field transport?

+4
source share
4 answers

in accordance with the ABAP Documentation on READ TABLEif you use the transportation option, the working area that receives the data should be compatible with the type of table line you are reading. Your declared variable lv_responsableseems to be incompatible with tbl_peps, so there is an error checking your code.

This should work:

DATA:
  wa_peps like line of tbl_peps.

  READ TABLE tbl_peps TRANSPORTING ususap INTO wa_peps WITH KEY usr03 = wa_tbl_prps-usr03.  
  move wa_peps-ususap to lv_responsable.
+4
source

( , ABAP 7.40) . :

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

.

+8

, , . , :

READ TABLE tbl_peps 
  ASSIGNING FIELD-SYMBOL(<fs_responsable>) 
  WITH KEY usr03 = wa_tbl_prps-usr03.

ABAP 740 , :

FIELD-SYMBOLS: <fs_responsable> LIKE LINE OF tbl_peps.
READ TABLE tbl_peps 
  ASSIGNING <fs_responsable> 
  WITH KEY usr03 = wa_tbl_prps-usr03.
+2

. Lv_responsable .

DATA: lv_responsable LIKE LINE OF tbl_peps.

lv_responsable-ususap .

0

Source: https://habr.com/ru/post/1570490/


All Articles