08-24-2007 9:52 AM
Dear Forum Gurus
I work in SAP for 6 years but sincerly I have never implemented any logs logic in SAP for client application. Do you have any idea how to do it. Is there any class for it. I mean - I have the application some errors occured while running and then I want to send to user the information about this erros in some logs table or something like that. Are there any standards for that?
Thank you in advance Bogusia!
08-24-2007 10:26 AM
Hi,
Steps,
1. create structure ZLOG in data dictionary.
2. fields -
TYPE data element BAPI_MTYPE
MESSAGE data element BAPI_MSG
you can take other fields also which you want to show in log message.
3. UPDATE TYPE WITH 'E'
UPDATE MESSAGE WITH your text (Anything).
AND UPDATE YOUR OTHER FIELDS LIKE THIS WAY.
4. AT FINALY SHOW THIS LOG.
08-27-2007 2:28 PM
09-02-2007 3:35 AM
You can use application logs, which are the standard way of errors collection and logging SAP gives you. Check this links:
http://help.sap.com/saphelp_47x200/helpdata/en/d6/5d7f38f52f923ae10000009b38f8cf/frameset.htm
This link has an ABAP example code.
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/applicationLogginginSAPUsing+ABAP&
Also, run programs SBAL_DOCUMENTATION and SBAL_DEMO_01.
There was another example around SDN of good and bad error logs (with an hypothetic space trip or something like that) but i can't find it now (if someone does, please post the link).
Regards
Please reward points if helpful.
Message was edited by:
Alejandro Bindi
09-02-2007 4:08 AM
Hi,
Check this
**************************************************************
** Validate and create error message
**************************************************************
if not wa_yarsitem-kondm is initial.
read table i_yarsbrands into wa_yarsbrands
with key kondm = wa_yarsitem-kondm
binary search.
if sy-subrc ne c_0.
perform f_update_error_records using 'YARS' c_e '378'
wa_yarsitem-kondm
wa_yarsitem-docno
space space
wa_yarsitem-docno.
endif.
endif.
*&---------------------------------------------------------------------*
* Form f_update_error_records *
*&---------------------------------------------------------------------*
* For updating the error messages *
*----------------------------------------------------------------------*
form f_update_error_records using msgid msgtyp msgnr msgv1 msgv2 msgv3
msgv4 docno.
clear : wa_yerrlog.
wa_yerrlog-msgid = msgid.
wa_yerrlog-msgtyp = msgtyp.
wa_yerrlog-msgnr = msgnr.
wa_yerrlog-msgv1 = msgv1.
wa_yerrlog-msgv2 = msgv2.
wa_yerrlog-msgv3 = msgv3.
wa_yerrlog-msgv4 = msgv4.
wa_yerrlog-docno = docno.
append wa_yerrlog to i_yerrlog.
*
endform. " F_update_error_records
*****************************************************************
** Generate Error Report
*****************************************************************
refresh i_output. clear wa_output.
loop at i_yerrlog into wa_yerrlog.
v_msg_id = wa_yerrlog-msgid.
v_msg_no = wa_yerrlog-msgnr.
v_msg_var1 = wa_yerrlog-msgv1.
v_msg_var2 = wa_yerrlog-msgv2.
v_msg_var3 = wa_yerrlog-msgv3.
v_msg_var4 = wa_yerrlog-msgv4.
* Creating message text
call function 'MESSAGE_PREPARE'
exporting
msg_id = v_msg_id
msg_no = v_msg_no
msg_var1 = v_msg_var1
msg_var2 = v_msg_var2
msg_var3 = v_msg_var3
msg_var4 = v_msg_var4
importing
msg_text = v_text1.
move-corresponding wa_yerrlog to wa_output.
move v_text1 to wa_output-v_text1.
append wa_output to i_output.
endloop.
data : v_flg type c.
data : v_no(3) type n value 1.
sort i_output by docno.
if not i_output[] is initial.
loop at i_output into wa_output.
at new docno.
move 'Y' to v_flg.
endat.
if v_flg eq 'Y'.
v_no = 1.
write: /00 'Document Number :', wa_output-docno
color col_heading.
format color off.
clear v_flg.
endif.
pack v_no to v_no.
write : /00 v_no no-zero, '.'.
write : 5 wa_output-v_text1.
v_no = v_no + 1.
endloop.
uline.
perform f_end_of_page.
endif.
a®