DATSET 打开、写入文件数据,代码如下:
DATA:
CNS_TAB TYPE CHAR1 VALUE CL_ABAP_CHAR_UTILITIES => HORIZONTAL_TAB.
OPEN DATASET W_FILPATH FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC <> 0.
MESSAGE E043(ZTHL1) WITH W_FILPATH.
ENDIF.
LOOP AT TD_ERRFILE INTO ST_ERRFILE.
CONCATENATE ST_ERRFILE-MBLNR
ST_ERRFILE-ZEILE
INTO LW_OUTDATA
SEPARATED BY CNS_TAB.
TRANSFER LW_OUTDATA TO W_FILPATH.
ENDLOOP.
CLOSE DATASET W_FILPATH.
读取.TXT文件内容到内表,TAB键分开。
OPEN DATASET P_SVINFL FOR INPUT IN LEGACY TEXT MODE.
READ DATASET P_SVINFL INTO LW_LINE.
IF SY-SUBRC = 0.
SPLIT LW_LINE AT CNS_TAB
INTO TH_INPUT_MATL
TH_INPUT_PLANT.
APPEND TH_INPUT TO TD_INPUT.
ENDIF.
原文地址:https://www.cnblogs.com/mmm-iwtb/p/8969022.html
时间: 2024-11-17 04:03:00