Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

display errors message

Former Member
0 Likes
1,032

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
800

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.

6 REPLIES 6
Read only

Former Member
0 Likes
800

Hi,

declare a internal table......

and use append statement

Regards,

V.Balaji

Reward if Usefull...

Read only

former_member210123
Active Participant
0 Likes
800

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.

Read only

Former Member
0 Likes
801

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.

Read only

Former Member
0 Likes
800

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.

Read only

Former Member
0 Likes
800

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.

Read only

Former Member
0 Likes
800

Thanks all for your useful answer. It solve my problem.