Hi, im transferring records to a file, the first line of the file contains the headers (used 'NO END OF LINE'). The problem is that when I write the data records to the file, the first record continues from the end of the Headers line, hence i have a record missing in my statement. I want to append the records below the Headers line. I tried opening the dataset 'for appending' instead of 'for output' but I get the same result.
lv_ds_name_ex = Filename
Code:
Getting field descriptions to use as headers and tranferring to file
open the dataset
OPEN DATASET lv_ds_name_ex FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
CLEAR: lt_dfies.
" Get field descriptions from settlement table
CALL FUNCTION 'DDIF_FIELDINFO_GET'
EXPORTING
tabname = 'zrl_generic_record'
TABLES
dfies_tab = lt_dfies.
write column headers to the file
LOOP AT lt_dfies.
IF lt_dfies-scrtext_m = 'Char15'.
IF lv_counter < 1.
lt_dfies-scrtext_m = 'Remuneration Amount'.
lv_counter = lv_counter + 1.
ELSE.
lt_dfies-scrtext_m = 'Commission Amount'.
ENDIF.
ENDIF.
TRANSFER lt_dfies-scrtext_m TO lv_ds_name_ex NO END OF LINE.
TRANSFER ';' TO lv_ds_name_ex NO END OF LINE.
ENDLOOP.
Close DATASET lv_ds_name_ex.
Transferring data records to file
open the dataset
OPEN DATASET lv_ds_name_ex FOR APPENDING IN TEXT MODE ENCODING DEFAULT.
write records to the file
LOOP AT lt_generic_record_csv INTO ls_generic_record_csv.
TRANSFER ls_generic_record_csv TO lv_ds_name_ex.
ENDLOOP.
"close the dataset
CLOSE DATASET lv_ds_name_ex.