2019 Mar 10 6:13 AM
Hi SAP ABAP Gurus,
Please help. Below code is not working.
Error is "<WA>" cannot be converted to the row type of "_TABLE". The reverse is also not possible.
TYPES: BEGIN OF _struct,
_line TYPE string,
END OF _struct.
DATA _table TYPE STANDARD TABLE OF _struct.
FIELD-SYMBOLS <wa> TYPE x.
OPEN DATASET file1 FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc EQ 0.
DO.
READ DATASET file1 INTO <wa>.
IF sy-subrc EQ 0.
APPEND <wa> TO _table.
ELSE.
EXIT.
ENDIF.
ENDDO.
CLEAR _table.
CLOSE DATASET file1.
* DELETE DATASET file1.
ENDIF.
OPEN DATASET file2 FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc EQ 0.
LOOP AT _table INTO <wa>.
TRANSFER <wa> TO file2.
ENDLOOP.
CLOSE DATASET file2.
ENDIF.
2019 Mar 10 8:39 AM
<wa> is type X, the line type of _table is _struct, which is a isn't type X. Hence the error. Maybe you should check your course notes or abap help about types in ABAP and conversion of types.
<wa> is type X, the line type of _table is _struct, which is a isn't type X. Hence the error. Maybe you should check your course notes or abap help about types in ABAP and conversion of types.
2019 Mar 10 7:45 AM
Open dataset file1 for input in text mode encoding default.
if sy-subrc ne 0. write:/ 'Unable to open file:', file1.
else.
do.
read datasset file1 into <wa>.
if sy-subrc ne o.
exit.
else.
append <wa> to _table.
endif.
close dataset file1.
enddo.
endif.
Open dataset file2 for output in text mode encoding default.
if sy-subrc ne 0.
write:/ 'Unable to open file:', file2.
else.
loop at _table.
transfer <wa> to file2.
endloop.
close dataset file2.
endif.
2019 Mar 10 1:12 PM
It's better to explain what is wrong and why, rather than just correcting without explaining anything
2019 Mar 10 8:37 AM
2019 Mar 10 8:39 AM
<wa> is type X, the line type of _table is _struct, which is a isn't type X. Hence the error. Maybe you should check your course notes or abap help about types in ABAP and conversion of types.
2019 Mar 10 1:13 PM
"code is not working" means nothing, give facts: code is not compiling, there is the following syntax error. Please tell us also the line where the syntax error occurs, rather than letting us reviewing the whole code manually.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |