07-26-2006 7:23 AM
Hi friends,
I have one query regarding fm.
Suppose i m calling one fm.
Now i wanted to display the error message by using fm. I have 10 error messages so i saved all the messages in one message class.
Will u tell me how to call the error messages based on type of error???
07-26-2006 7:26 AM
Hello,
To show error message use this syntax :
Message e001(zmsg).
Regards,
Naimesh
07-26-2006 7:28 AM
Hi,
Check this code :
if your FM has 10 exceptions, then if any exception raised from the FM , sy-subrc is equal to exception number , if FM success , sy-subrc equal to 0.
case sy-subrc.
when 0
message e000(ZMSG).
when 1.
message e001(ZMSG).
other
endcase.
Regards
Appana
07-26-2006 7:30 AM
07-26-2006 7:31 AM
Hi,
Use If and Endif.
If condition1.
Message e001.
else ifcondition2.
Message e002.
endif.
This way.. u can do...
Cheers,
SImha.
07-26-2006 7:42 AM
Hi Salil,
You cannot write error messages in the FM.
Exceptions are to be used.
The calling program gets the exception after returning from execution of the called FM.
Based on the Exception give the relevant error messages.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = space
filetype = 'ASC'
has_field_separator = '#'
TABLES
data_tab = t_header
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
CASE sy-subrc.
WHEN 1.
MESSAGE ID 'SU' TYPE 'E' NUMBER '004' WITH data.
WHEN 2.
.....
ENDCASE.
Regards,
AS.
07-26-2006 7:43 AM
07-26-2006 8:04 AM
hi,
try this code
SY-MSGID = 'ZMRO1'.
SY-MSGTY = 'E'.
SY-MSGNO = '016'.
SY-MSGV1 = TEXT-007.
PERFORM BUILD_MSG_TABLE TABLES T_MSGTAB
USING SY-MSGTY
SY-MSGID
SY-MSGNO
SY-MSGV1
SY-MSGV2
SY-MSGV3
SY-MSGV4.
FORM BUILD_MSG_TABLE TABLES P_T_RETURN STRUCTURE BAPIRET2
USING P_T_RETURN_TYPE
P_T_RETURN_ID
P_T_RETURN_NUMBER
P_T_RETURN_MESSAGE_V1
P_T_RETURN_MESSAGE_V2
P_T_RETURN_MESSAGE_V3
P_T_RETURN_MESSAGE_V4.
Update Return table
P_T_RETURN-TYPE = P_T_RETURN_TYPE.
P_T_RETURN-ID = P_T_RETURN_ID.
P_T_RETURN-NUMBER = P_T_RETURN_NUMBER.
P_T_RETURN-MESSAGE_V1 = P_T_RETURN_MESSAGE_V1.
P_T_RETURN-MESSAGE_V2 = P_T_RETURN_MESSAGE_V2.
P_T_RETURN-MESSAGE_V3 = P_T_RETURN_MESSAGE_V3.
P_T_RETURN-MESSAGE_V4 = P_T_RETURN_MESSAGE_V4.
APPEND P_T_RETURN.
noe u get ur message according to the id and number
hope it will help u
with regards
chetan vishnoi
07-26-2006 8:09 AM
Hi,
You can use function module MESSAGE_TEXT_BUILD to get the exact error message as defined in the message class.
You need to pass the Message ID and number to this function module and the returning text message can be collected in an internal table and finally used to display the collective error messages.
Hope this helps.
Rgds,
HR
07-26-2006 8:16 AM
07-26-2006 8:23 AM
Hi Salil,
here the code is for all type of msges-
DATA: BEGIN OF T_ICON OCCURS 0,
ID LIKE ICON-ID,
TEXT LIKE T100-TEXT,
END OF T_ICON.
LOOP AT T_MESSAGE.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = T_MESSAGE-ID
LANG = 'E'
NO = T_MESSAGE-NUMBER
V1 = T_MESSAGE-MESSAGE_V1
V2 = T_MESSAGE-MESSAGE_V2
V3 = T_MESSAGE-MESSAGE_V3
V4 = T_MESSAGE-MESSAGE_V4
IMPORTING
MSG = T_ICON-TEXT.
IF T_MESSAGE-TYPE = 'E'.
T_ICON-ID = '@0A@'.
ENDIF.
IF T_MESSAGE-TYPE = 'S'.
T_ICON-ID = '@08@'.
ENDIF.
IF T_MESSAGE-TYPE = 'W'.
T_ICON-ID = '@09@'.
ENDIF.
IF T_MESSAGE-TYPE = 'I'.
T_ICON-ID = '@0S@'.
ENDIF.
APPEND T_ICON.
ENDLOOP.
CALL METHOD ALV->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_BYPASSING_BUFFER = 'X'
IS_LAYOUT = GS_LAYOUT
CHANGING
IT_OUTTAB = T_ICON[]
IT_FIELDCATALOG = FIELDCATTAB[].
Regards,
Seema.
07-26-2006 8:34 AM
Hi
You can give the <b>RETURN</b> (type - BAPIRET1) as an export parameter of the FM.
you can use the following code to populate the RETURN parameter inside the FM.
DATA: bapiret LIKE bapiret1.
CALL FUNCTION 'BALW_BAPIRETURN_GET1'
EXPORTING
type = msgty
cl = msgid
number = msgno
par1 = msgv1
par2 = msgv2
par3 = msgv3
par4 = msgv4
* LOG_NO = ' '
* LOG_MSG_NO = ' '
IMPORTING
bapireturn = bapiret
EXCEPTIONS
OTHERS = 1.
MOVE-CORRESPONDING bapiret TO return.
best regards,
Thangesh
07-26-2006 8:39 AM
Hi,
U can call error messges direstly in FM using MESSAGE suntax. But it is not recomended, u need to handle this using exceptons, since if the error message is raised in FM, the control never comes back to ur program to handle anything else based on FM output or errors.
Sreedhar
07-26-2006 8:49 AM
hi,
sorry to say u that we r spend our time for give ans to u so u hv to gave responce to perticular man yaar.
thanks
chetan