Hi Karan,
The output which is shown in the screenshot is picked from the following statement.
loop at it_tab into wa_tab.
write :/ wa_tab-EMPName,
wa_tab-Designation,
wa_tab-Salary.
endloop.
Here we are updating the Excel work area
LOOP AT it_tab INTO wa_tab.
ZEXCEL-EMPNAme = wa_tab-EMPName.
ZEXCEL-Designation = wa_tab-Designation.
ZEXCEL-Salary = wa_tab-Salary.
We are Updating the Excel Table here based on Work area, based on the SUBRC value, we are updating the Error Table. ZEXCEL is defined as with Header line statement in declaration statement
MODIFY ZEXCEL.
if sy-subrc <> 0.
MOVE-CORRESPONDING wa_tab to wa_error.
append wa_error to it_error.
clear wa_error.
endif.
clear wa_tab.
ENDLOOP.
After the loop, we are printing the Error log as below.
Checking Error Table have value or not, If value is not available, throwing the Message as successfully updated as shown below, if error value available in IT_ERROR, we are printing the errors in screen using 'WRITE' statement inside LOOP.
if it_error is initial.
message 'all data updated Sucessfully' type 'S'.
else.
loop at it_error into wa_error.
write:/ wa_error-empname.
endloop.
endif.
Regards
Rajkumar Narasimman