DATA : LV_FILE TYPE EPS2FILNAM,
p_file LIKE rlgrap-filename.
DATA : p_file_n TYPE localfile ,
iv_file TYPE string.
DATA: lt_dir1 TYPE TABLE OF eps2fili,
wa_dir1 like LINE OF lt_dir1.
DATA : gs_final_t1 TYPE ty_daily,
p_dir TYPE salfile-longname,
gt_final_t1 TYPE TABLE OF ty_daily.
DATA lv_return TYPE c.
TYPES: BEGIN OF ty_daily,
col1 TYPE char18,
col2 TYPE char18,
col3 TYPE char18,
col4 TYPE char18,
col5 TYPE char18,
col6 TYPE char30,
col7 TYPE char18,
col8 TYPE char18,
END OF ty_daily.
DATA : BEGIN OF it_final occurs 0,
a TYPE char20,
b TYPE char20,
c TYPE char20,
d TYPE char20,
e TYPE char20,
f TYPE char30,
g TYPE char20,
h TYPE char20,
END OF it_final.
p_dir = ‘/usr/sap/otattachments/’. " al11 path
CALL FUNCTION 'EPS2_GET_DIRECTORY_LISTING'
EXPORTING
iv_dir_name = p_dir
TABLES
dir_list = lt_dir1
.
IF sy-subrc <> 0.
* Implement suitable error handling here
else.
DELETE lt_dir1 WHERE rc <> '0000'.
ENDIF.
READ TABLE lt_dir1 INTO wa_dir1 INDEX 1.
IF sy-subrc eq 0.
p_file_n = wa_dir1-name.
CONCATENATE p_path '/' wa_dir1-name INTO p_file.
LV_FILE = P_FILE. "File name path create
OPEN DATASET lv_file FOR INPUT IN BINARY MODE .
IF sy-subrc EQ 0.
READ DATASET lv_file INTO lv_xls_xstr.
* lv_xls_xstr = wa_str.
IF sy-subrc NE 0.
* MESSAGE e002 WITH lv_file.
ENDIF.
ELSE.
* MESSAGE e001 WITH lv_file.
ENDIF.
CLOSE DATASET lv_file.
lo_xlsx->if_fdt_doc_spreadsheet~get_worksheet_names(
IMPORTING
worksheet_names = DATA(lt_excel)
).
"
LOOP AT lt_excel INTO DATA(ls_excel).
DATA(ir_ref) = lo_xlsx->if_fdt_doc_spreadsheet~get_itab_from_worksheet( ls_excel ) .
ASSIGN ir_ref->* TO FIELD-SYMBOL(<lfs_data_tab>).
MOVE-CORRESPONDING <lfs_data_tab> TO it_final[].
ENDLOOP.
“ EXCEL DATA POPULATE IN IT FINAL.
DATA: V_OLD type localfile,
V_NEW type localfile,
L_NEWLINE(240) type c.
v_old = lv_file.
P_path_arc = ‘/usr/sap/otattachments/arc’
OPEN DATASET v_old FOR INPUT IN BINARY MODE .
IF sy-subrc eq 0.
CONCATENATE p_path_arc '/' wa_dir1-name INTO p_file_arc.
LV_FILE_ARC = p_file_arc.
v_new = LV_FILE_ARC.
OPEN DATASET v_new FOR OUTPUT IN BINARY MODE .
IF sy-subrc eq 0.
DO.
READ DATASET v_old INTO l_newline.
IF sy-subrc EQ 0.
TRANSFER l_newline TO v_new.
ELSE.
if l_newline is not initial.
TRANSFER l_newline TO v_new.
endif.
EXIT.
ENDIF.
ENDDO.
ENDIF.
ENDIF.
CLOSE DATASET v_new.
CLOSE DATASET v_old.
DELETE DATASET v_old. " v_old is the path from where we want to delete file
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
4 | |
3 | |
3 | |
2 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 |