Hi, I have this ABAP code with me:
Please help to resolve this issue, required images are provided at the end.
REPORT ztest_009.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT–001.
PARAMETERS: p_radio1 RADIOBUTTON GROUP rad1 DEFAULT ‘X’ USER-COMMAND rad,
p_radio2 RADIOBUTTON GROUP rad1.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE TEXT–002.
PARAMETERS: p_file TYPE localfile.
PARAMETERS: p_run AS CHECKBOX.
SELECTION-SCREEN END OF BLOCK b2.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION ‘F4_FILENAME’
IMPORTING
file_name = p_file.
AT SELECTION-SCREEN.
IF p_radio1 = ‘X’ AND p_file IS INITIAL.
MESSAGE ‘Please upload Excel File for excecution’ TYPE ‘E’.
ENDIF.
START-OF-SELECTION.
DATA: vend_data_t TYPE TABLE OF ztmd_lve_ven_vsr,
vend_data_s TYPE ztmd_lve_ven_vsr,
filename TYPE rlgrap–filename,
display_errors_t TYPE TABLE OF string,
display_errors_s TYPE string,
excel_t TYPE TABLE OF alsmex_tabline,
excel_s TYPE alsmex_tabline,
lt_output TYPE TABLE OF ztmd_lve_ven_vsr,
lt_duplicate_check TYPE TABLE OF ztmd_lve_ven_vsr.
* split_lifnr TYPE char10.
filename = p_file.
CALL FUNCTION ‘ALSM_EXCEL_TO_INTERNAL_TABLE’
EXPORTING
filename = filename
i_begin_col = 1
i_begin_row = 2
i_end_col = 5
i_end_row = 1000
TABLES
intern = excel_t
* EXCEPTIONS
* INCONSISTENT_PARAMETERS = 1
* UPLOAD_OLE = 2
* OTHERS = 3
.
IF sy–subrc <> 0.
* Implement suitable error handling here
MESSAGE: ‘upload excel’ TYPE ‘E’.
ENDIF.
CLEAR: excel_s.
LOOP AT excel_t INTO excel_s.
CASE excel_s–col.
WHEN 1.
vend_data_s–lifnr = excel_s–value.
WHEN 2.
vend_data_s–ltsnr = excel_s–value.
WHEN 3.
vend_data_s–zind = excel_s–value.
WHEN 4.
IF excel_s–value IS NOT INITIAL.
SPLIT excel_s–value AT ‘.’ INTO DATA(day) DATA(month) DATA(year).
vend_data_s–zvalfrom = year && month && day. ” Convert to YYYYMMDD
ENDIF.
WHEN 5.
IF excel_s–value = ‘X’.
DELETE FROM ztmd_lve_ven_vsr WHERE lifnr = vend_data_s–lifnr AND ltsnr = vend_data_s–ltsnr.
ENDIF.
ENDCASE.
APPEND vend_data_s TO vend_data_t.
CLEAR: vend_data_s.
ENDLOOP.
Facing issues as data is mismatched in uploaded excel file and my internal table vend_data_t.
Uploaded excel file:
Internal table: vend_data_t:
Data in table excel_t: