‎2006 Sep 21 3:34 PM
Hello,
May I know how could I store the error msgs of various kinds in an internal table instead of display them without physically add in the msg themselves. For example,
MESSAGE e046(0q).
* Error occurred during file selection
I would like to store the msg in an internal table as a warning without physically store the string of msg the error contains. May I know is there a way to get that done?
Also, if I would like to display, on my final report screen, say, the color and icon for error (the red ones), warning (the yellow ones) and others followed by the msgs themselves, is there a way to get that one done?
Thanks a lot!
Regards,
Anyi
‎2006 Sep 21 3:47 PM
Hi,
Please try like this.
INCLUDE: <ICON>.
DATA: BEGIN OF I_MSG OCCURS 0,
ICON TYPE ICON-ID,
MESSAGE TYPE STRING.
DATA: END OF I_MSG.
...
MESSAGE ID 'BD' TYPE 'I' NUMBER '001' INTO I_MSG-MESSAGE.
MOVE '@0A@' TO I_MSG-ICON.
APPEND I_MSG.
...
LOOP AT I_MSG.
WRITE: / I_MSG-MESSAGE.
ENDLOOP.Regards,
Ferry Lianto
‎2006 Sep 21 3:36 PM
hi,
declare a variable of type string and store that value into that and display it at the end ..
i.e,
data : v_error1 type string.
select * from mara where matnr = '0000014'.
if sy-subrc ne 0.
v_error1 = ' No data Found '.
endif.
Regards,
santosh
Regards,
santosh
‎2006 Sep 21 3:38 PM
Hi,
DATA: T_ERROR TYPE STANDARD TABLE OF BAPIRET2 WITH HEADER LINE.
STORE THE MESSAGE IN THE INTERNAL TABLE
T_ERROR-TYPE = 'E'.
T_ERROR-ID = '0Q'.
T_ERROR-NUMBER = '046'.
Prepare the message text
CALL FUNCTION 'MESSAGE_PREPARE'
EXPORTING
msg_id = T_ERROR-ID
msg_no = T_ERROR-NUMBER
MSG_VAR1 = ' '
MSG_VAR2 = ' '
MSG_VAR3 = ' '
MSG_VAR4 = ' '
IMPORTING
MSG_TEXT = T_ERROR-TEXT
EXCEPTIONS
FUNCTION_NOT_COMPLETED = 1
MESSAGE_NOT_FOUND = 2
OTHERS = 3
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
APPEND T_ERROR.
output..
LOOP AT T_ERROR.
IF T_ERROR-TYPE = 'W'.
WRITE: / T_ERROR-TEXT COLOR COLOR_TOTAL.
..
ENDIF.
ENDIF.
ENDLOOP.
Thanks,
Naren
‎2006 Sep 21 3:40 PM
hi,
*-- Internal table for messages
data: lt_message like bdcmsgcoll occurs 0 with header line.
data: lv_msg(220) type c , " To store the error msg
*if error occurs.
perform format_messages tables lt_message
using lv_msg lv_lines.
* To append error messages
perform append_message tables lt_message
return
using lv_msg.
form format_messages tables pt_messages structure bdcmsgcoll
using pv_msg pv_lines.
clear : pv_lines,pt_messages,pv_msg.
describe table pt_messages lines pv_lines.
read table pt_messages index pv_lines.
check not pt_messages-msgid is initial.
*-- Function module to format the message given
call function 'FORMAT_MESSAGE'
exporting
id = pt_messages-msgid
lang = sy-langu
no = pt_messages-msgnr
v1 = pt_messages-msgv1
v2 = pt_messages-msgv2
v3 = pt_messages-msgv3
v4 = pt_messages-msgv4
importing
msg = pv_msg
exceptions
not_found = 1
others = 2.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 into pv_msg.
endif.
endform. " format_messages
form append_message tables p_message structure bdcmsgcoll
p_return structure BAPIRET2
using p_msg .
move : p_message-msgtyp to p_return-type,
p_message-msgid to p_return-id,
p_message-msgnr to p_return-number,
p_msg to p_return-message.
append p_return.
clear p_return.
endform. " append_messageRegards,
Richa
‎2006 Sep 21 3:40 PM
U can store the messages into an internal table with msgtype and msgtext as the fields.
Msgtype : contains an indicator whether it is Warning/Error etc.
MsgTExt : the actual message.
U can use the msgtype to sort and display the light symbol depending on the msgtype in the output. I will comeback on the light indicators on how to use it.
‎2006 Sep 21 3:41 PM
Declare a internal table like this:
TYPES: BEGIN OF ty_final_log,
status TYPE iconname,
legacykey TYPE char30,
po TYPE ebeln,
message TYPE char100,
status_invoice TYPE iconname,
message_invoice TYPE char100,
END OF ty_final_log.
Here u can populate the error message.
For Icon's goto ICON Table select a icon.
For succ u can populate - '@01@'
For fail u can populate - '@02@'.
Regards,
Prakash.
‎2006 Sep 21 3:47 PM
Hi,
Please try like this.
INCLUDE: <ICON>.
DATA: BEGIN OF I_MSG OCCURS 0,
ICON TYPE ICON-ID,
MESSAGE TYPE STRING.
DATA: END OF I_MSG.
...
MESSAGE ID 'BD' TYPE 'I' NUMBER '001' INTO I_MSG-MESSAGE.
MOVE '@0A@' TO I_MSG-ICON.
APPEND I_MSG.
...
LOOP AT I_MSG.
WRITE: / I_MSG-MESSAGE.
ENDLOOP.Regards,
Ferry Lianto
‎2006 Sep 21 3:48 PM
How about declaring an internal table with two fields, one for Message Type and another for Mesg
Eg:
*** Global Declaration
types: begin of t_error,
type(1) type c,
mesg(100) type c,
end of t_error.
data: it_error type standard table of t_error,
wa_error type t_error.
data: g_text(100) type c.
constants: c_err(1) type c value 'E',
c_war(1) type c value 'W'.
*** whenever there is a mesg that can be populated
eg:
clear: g_text.
concatenate 'Material:' it_data-matnr 'does not exist'
into g_text separated by space.
perform append_mesg using c_error g_text.
form append_mesg using p_type p_text.
clear: wa_error.
wa_error-type = p_type.
wa_error-text = p_text.
append wa_error to it_error.
endform.
form display_mesgs.
loop at it_error into wa_error.
case wa_error-type.
when 'E'.
*** Use FORMAT Color statement to define the colour
when 'W'.
*** Use FORMAT Color statement to define the colour
endcase.
write:/ wa_error-mesg.
format reset.
endloop.
endform.Am not on SAP now to give you more details, kindly use the above as start up and modify as per the requirement.
Kind Regards
Eswar
‎2006 Sep 21 3:58 PM
Hi Anyi,
You can declare an internal table like this -
types : begin of t_error,
msgno type sy-msgno,
msgty type sy-msgty,
msgid type sy-msgid,
msgv1 type sy-msgv1,
msgv2 type sy-msgv2,
msgv3 type sy-msgv3,
msgv4 type sy-msgv4,
end of t_error.
data : i_error type standard table of t_error.
As and when you get any error or warning messages you can append the details in table i_error.
At the end of your processing you can loop at this table to read the error messages, get the text from table T100 and display it.
For displaying the different coloured icons for error and warnings use the table ICON. Name ICON_LED_RED for Error and ICON_LED_YELLOW for Warning can be used.
Hope this helps!
Regards,
Saurabh