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

Regarding capturing Error messages

Former Member
0 Likes
710

hi every one,

i just had to create an internal table and capture the error messages ( like vendor not exists) when validation check fails and send these error messages to internal table and also to screen.

can any one please give me piece of code for this.

thank you

pavan.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
677

Hi,

Check this example.

DATA: T_ERROR(50) OCCURS 0 WITH HEADER LINE.

DATA: V_MESSAGE(50).

SELECT SINGLE * FROM LFA1

WHERE VENDOR = P_LIFNR.

IF SY-SUBRC <> 0.

  • Call the function module to format the message.

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

ID = '00'

NO = '398'

V1 = 'Vendor don't exists'

V2 = P_LIFNR

V3 = ''

V4 = ''

IMPORTING

MSG = V_MESSAGE.

  • append the error message.

T_ERROR = V_MESSAGE.

APPEND T_ERROR.

ENDIF.

END-OF-SELECTION.

  • Display the error message.

LOOP AT T_ERROR.

WRITE: / T_ERROR COLOR COL_NEGATIVE.

ENDLOOP.

Thanks,

Naren

6 REPLIES 6
Read only

Former Member
0 Likes
678

Hi,

Check this example.

DATA: T_ERROR(50) OCCURS 0 WITH HEADER LINE.

DATA: V_MESSAGE(50).

SELECT SINGLE * FROM LFA1

WHERE VENDOR = P_LIFNR.

IF SY-SUBRC <> 0.

  • Call the function module to format the message.

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

ID = '00'

NO = '398'

V1 = 'Vendor don't exists'

V2 = P_LIFNR

V3 = ''

V4 = ''

IMPORTING

MSG = V_MESSAGE.

  • append the error message.

T_ERROR = V_MESSAGE.

APPEND T_ERROR.

ENDIF.

END-OF-SELECTION.

  • Display the error message.

LOOP AT T_ERROR.

WRITE: / T_ERROR COLOR COL_NEGATIVE.

ENDLOOP.

Thanks,

Naren

Read only

Former Member
0 Likes
677

thank you narendran, but there are around 20 validation checks so do u think i need to call this function module format_message for each validation check, i mean 20 times.

please revert back if you dont understand my concern.

thank you

pavan kumar

Read only

Former Member
0 Likes
677

Hi,

FORMAT_MESSAGE is used to get the message for the corresponding message id, message no..

If you don't want to use it..You can directly add the message to the error internal table..

Example

-


SELECT SINGLE * FROM LFA1

WHERE VENDOR = P_LIFNR.

IF SY-SUBRC <> 0.

CONCATENATE 'Vendor ' P_LIFNR ' not valid' into T_ERROR.

APPEND T_ERROR.

ENDIF.

Thanks,

Naren

Read only

Former Member
0 Likes
677

thanks for your answer, do you also know how to send the captured error messages in internal table to user's outlook email.

please help me regarding this,

thank you

pavan

Read only

Former Member
0 Likes
677

Hi,

Please create a new thread for this question..

Thanks,

Naren

Read only

Former Member
0 Likes
677

hi naren,

i just posted my question as a new thread, if possible try to answer it.

thanks

pavan