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

Using the MESSAGE statement

Former Member
0 Likes
5,004

Greetings.

I'm working on a program that will, among other things, process inbound files. If the filename specified does not exist I thought I would use the MESSAGE command to generate a runtime error using a parameterized Text Symbol which would have the name of the errant file; something like this:

text-m02 = "File &1 Not Found'.

MESSAGE text-m02 TYPE 'X' DISPLAY LIKE 'E'.

However, when I add the "WITH dobj" (where dobj is a string var w/ the name of the file) it won't compile saying that the "WITH dobj" statement is unexpected (regardless of where I put it).

But that got me thinking - is this the best approach? This program will be ran and the selection screen saved as a variant for each input file but it is entirely possible the file may not be around when this program fires off so I have to account for that possibility, along with processing errors.

Is there a recommended or "best" practice for handling errors in applications that will be ran in batch? If so, what are they?

Thanks!

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,055

Hi Steve,

Use,

CONCATENATE 'File' v_filename 'Not found' INTO msg SEPARATED BY space.

MESSAGE msg TYPE 'E' DISPLAY LIKE 'E' .

OR

Create your message class in SE93/ or use existing appropriate message class and use below syntax

message e001(zmsg) with FILENAME

where 001 = u201CFile & Not Foundu201D defined in SE93

Using message in batch processing program does not raise any problem. All message will be logged for batch job and can be used result, status, problem investigation etcu2026

Regards,

Nisarg

2 REPLIES 2
Read only

Former Member
0 Likes
2,056

Hi Steve,

Use,

CONCATENATE 'File' v_filename 'Not found' INTO msg SEPARATED BY space.

MESSAGE msg TYPE 'E' DISPLAY LIKE 'E' .

OR

Create your message class in SE93/ or use existing appropriate message class and use below syntax

message e001(zmsg) with FILENAME

where 001 = u201CFile & Not Foundu201D defined in SE93

Using message in batch processing program does not raise any problem. All message will be logged for batch job and can be used result, status, problem investigation etcu2026

Regards,

Nisarg

Read only

Former Member
0 Likes
2,055

Effect

When you use this addition, the icon of the message type specified in dtype is displayed instead of the associated icon. A character-type data object is expected for dtype. This data object has to contain one of the values "A", "E", "I", "S" or "W" in upper-case letters.

The message short text is still displayed as a dialog window for messages that are displayed this way by default. Messages with the type "E" or "W" (except those for PBO and LOAD-OF-PROGRAM) are displayed as a dialog window if dtype contains "A" or "I". Messages with the type "S" are always displayed in the status bar, independently of dtype. The latter also applies to messages of the type "I" for PBO and LOAD-OF-PROGRAM. Messages of the type "X" always cause a runtime error.

MESSAGE text-m02 TYPE 'X' DISPLAY LIKE 'E'.

the above statement lead to Dump, as per the SAP documentation. So change your code.