on 2024 Dec 26 12:02 PM
following is my code.
TYPES: BEGIN OF t_str,
col1 TYPE c,
col2 TYPE i,
END OF t_str.
TYPES: t_itab type TABLE of t_str.
data: gs_str type t_str,
gt_itab type t_itab.
data gv_name type char10 value 'COL1'.
gs_str-col1 = 'A'.
gs_str-col2 = 1.
APPEND gs_str to gt_itab.
gs_str-col1 = 'B'.
gs_str-col2 = 2.
APPEND gs_str to gt_itab.
PERFORM test_itab USING gt_itab.
*FORM test_itab using pt_itab type t_itab.
* READ TABLE pt_itab with key col1 = 'A' into gs_str.
* if sy-subrc = 0.
* write: gs_str-col1, gs_str-col2.
* ENDIF.
*endform.
FORM test_itab using pt_itab type ANY TABLE.
READ TABLE pt_itab with key (gv_name) = 'A' into gs_str.
if sy-subrc = 0.
write: gs_str-col1, gs_str-col2.
ENDIF.
endform.I don't know why it does works with dynamic variable (gv_name) when I choose 'type any table'.
Could you please do me a favor to explain a little bit? Thanks
Request clarification before answering.
| User | Count |
|---|---|
| 14 | |
| 8 | |
| 6 | |
| 6 | |
| 3 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.