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

code check

Former Member
0 Likes
469

can anyone check the code of mine for mistakes. here i want to capture the error messages into the global internal table from routines..

data: messtab like bdcmsgcoll occurs 0 with headerline.

form file_housekeep.

data: l_msg(60),

check g_housekeep_stat is initial.

check not g_server_prc_file is initial.

open dataset g_server_prc_file for output in text mode

encoding non-unicode message l_msg.

if sy-subrc ne 0.

write: at /3 'Error writing to Processed file:',

g_server_prc_file,

  • (70) g_server_prc_file,

at /3 'Error message:', l_msg.

else.

write: at /3 'Writing to Processed file:',

g_server_prc_file.

move l_msg to messtab.

append messtab.

3 REPLIES 3
Read only

Former Member
0 Likes
433

Hi,

<b>data: messtab type string occurs 0 with header line.</b>

form file_housekeep.

data: l_msg(60),

check g_housekeep_stat is initial.

check not g_server_prc_file is initial.

open dataset g_server_prc_file for output in text mode

encoding non-unicode message l_msg.

if sy-subrc ne 0.

write: at /3 'Error writing to Processed file:',

g_server_prc_file,

  • (70) g_server_prc_file,

at /3 'Error message:', l_msg.

else.

write: at /3 'Writing to Processed file:',

g_server_prc_file.

move l_msg to messtab.

append messtab.

Best regards,

Prashant

Read only

0 Likes
433

Hi Prasanth,

thanks for the prompt reply. here i wan tto capture all the error messages from different subroutines to the globally declared internal table messtab.

if i put it as <b>messtab type string</b> occurs 0.

does it serves my purpose or is there anything i need to do more.

regards...

Read only

wilbertsison
Active Participant
0 Likes
433

Hello Nihi,

You have several issues here...

Naming conventions aside. Attached below is something which could pass a prelimary code review.

Some notes

  • Do NOT use bdcmsgcoll for this as it has a structure behind it. It will work but it shows improper use of data structures.

  • Use of header line is no longer recommended - infact will error out in an OO context.

  • Suggest passing parameters instead of using global variables

  • I would suggest using an application log instead of passing messages to a file.

  • If you are or are hoping to be a developer, do read the help and practice solving simple problems like this independently. It will sharpen you out. The forum is probably not the best way to solve these.

Good luck.

types: begin of ty_msg,

message(132),

end of ty_msg.

data: messtab type standard table of ty_msg.

  • g_housekeep_stat,g_server_prc_file are assumed

  • to have been declared

form file_housekeep.

data: l_msg(60).

check g_housekeep_stat is initial.

check not g_server_prc_file is initial.

open dataset g_server_prc_file for output in text mode

encoding non-unicode message l_msg.

if sy-subrc ne 0.

write: /3 'Error writing to Processed file:',

g_server_prc_file,

/3 'Error message:', l_msg.

else.

write: /3 'Writing to Processed file:',

g_server_prc_file.

endif.

append l_msg to messtab.

endform.