‎2008 Mar 31 1:58 PM
Hi,
I would like to collect all the errors message into another internal table for ease me to display the output report which contain either errors / processed records at the end of processing. May I know how I can do that instead code it like using write as below code.
Expected Output Report:
Errors list:
Student ID: 101001 not found.
Student name: Alice not found in the system.
Processed list:
Student name: David
Current code:
code....
............
If sy-burc NE 0.
write: / 'Student ID', l_studID, 'not found'.
endif.
code .....
.............
If sy-burc NE 0.
write: / 'Course, l_courseid, 'not found'.
endif.
‎2008 Mar 31 2:05 PM
Hi,
Follow the coding,
data : begin of errtab occurs 0,
l_studID (10) type c,
errtxt(40) type c,
end of errtab.
If sy-subrc NE 0.
move : l_studID to errtab-l_studID.
'not found' to errtab-errtxt.
append errtxt.clear errtxt.
endif.
loop at errtab.
write:/1 errtab-_studID,20 errtab-errtxt.
endloop.Regards,
Morris Bond.
Reward Points if Helpful.
‎2008 Mar 31 2:01 PM
Hi,
declare a internal table......
and use append statement
Regards,
V.Balaji
Reward if Usefull...
‎2008 Mar 31 2:03 PM
types : begin of t_internal ,
student id,
desc type string,
end of t_internal.
data i_table type table of t_internal.
is_table type t_internal.
instaed of write.
is_table-studentid = student id.
is_table-desc = 'desc.
append is_internal to i_internal.
Finally loop on the table and write it.
‎2008 Mar 31 2:05 PM
Hi,
Follow the coding,
data : begin of errtab occurs 0,
l_studID (10) type c,
errtxt(40) type c,
end of errtab.
If sy-subrc NE 0.
move : l_studID to errtab-l_studID.
'not found' to errtab-errtxt.
append errtxt.clear errtxt.
endif.
loop at errtab.
write:/1 errtab-_studID,20 errtab-errtxt.
endloop.Regards,
Morris Bond.
Reward Points if Helpful.
‎2008 Mar 31 2:13 PM
You can use the MESSAGE statement to store it into a field, and then append it into a table.
MESSAGE 'My error message' TYPE 'E' INTO wa_myWorkArea-field.
APPEND wa_myWorkArea TO gt_myGlobalTable.
‎2008 Mar 31 2:18 PM
Hi,
Just have a variable in your internal table as like follows.
data : begin of itab occurs 0,
field1,
field2,
excflag(1), 'Exception flag,
end of itab.
select query.
loop at itab.
if sy-subrc ne 0.
itab-excflag = '.X'.
endif.
modify itab.
clear itab.
endloop.
*updated records.
loop at itab where excflag = ' '.
endloop.
*Falied records.
loop at itab where excflag = ' X'.
endloop.
Regards,
Sankar.
‎2008 Mar 31 3:00 PM