Skip to Content
author's profile photo Former Member
Former Member

Logs logic implementation in ABAP

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!

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Aug 24, 2007 at 09: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.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 02, 2007 at 03: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.
    
    

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.