| Home • Tips • Tutorials • Forums • Certification Q's • Interview Q's • Jobs • Testimonials • Contact Us | ||
Document Categories:
What's New?
Contribute?Sample SpecsWhat's Hot? |
ABAP based Application LogStep
2 à
Write the code in your program from where you want to create application log. In
our case we will incorporate the logic in our PO and GR posting programs. So
as seen from the screen shot below. We will create PO using the standard BAPI.
So once the BAPI is called we will write the application log with any errors
messages or any success messages. So
we are calling the CREAT_APPLICATION_LOG routine after the BAPI call.
The
routine looks something similar to this
As
seen from the above screen shots. The coding involves using SAP std function
modules. The function modules starting with “BAL_” are all provided by SAP
for Application log development. Basically
the code involves 3 major steps: 1).
The function module BAL_LOG_CREATE
opens the Application Log whose header data is in the Importing parameter
I_S_LOG_HEADER, which has the structure BAL_S_LOG. 2).
Next you loop at the internal table( table for holding error records or
application log records which needs to be stored in the application log) and
call the function module BAL_LOG_MSG_ADD. A message is added to the log with the ( log handle )
I_LOG_HANDLE The
message data is passed to the function module BAL_LOG_MSG_ADD in the IMPORTING
parameter I_S_MSG (structure BAL_S_MSG). A message handle, which uniquely identifies this
message, is returned in E_S_MSG_HANDLE. The Application Log configuration controls whether a
message is directly displayed or collected. The Exporting parameters
E_MSG_WAS_DISPLAYED and E_MSG_WAS_LOGGED tell you what was done with the message
3).
You can save logs in memory in the database with the function module BAL_DB_SAVE.
You can save all data in memory (Importing parameter I_SAVE_ALL = 'X') or a
subset specified by a set of log handles (Importing parameter I_T_LOG_HANDLE). You can get the log handle table by calling the
function module BAL_GLB_SEARCH_LOG which searches for logs in memory by
specified filter criteria. When
logs are saved, an internal log number is issued (field LOGNUMBER). At runtime
this field has a temporary value (e.g. $00001). The function module BAL_DB_SAVE returns a table
(Exporting parameter E_NEW_LOGNUMBERS), which relates LOG_HANDLE, external
number EXTNUMBER, temporary LOGNUMBER and permanent LOGNUMBER, so you can find
out which number was assigned to a log after saving. 4).
This data can be displayed by calling the function module BAL_DSP_LOG_DISPLAY
via the program. All
the above function modules have been nicely documented by SAP. Please use the
online function module documentation for more Information. The
output of program looks as shown below. This output is displayed by just calling
the BAL_DSP_LOG_DISPLAY function module in our program.
The
same screen is displayed when you use the sap std provided transaction SLG1.
Step
3 à
Display Application log using SLG1.
On
this screen enter the name of the object created in the first step. IF required
enter a date range to filter the data and click on the execute button you will
get the screen as shown below.
Additional
Information: ·
The set of messages is a log. A log usually also has header
information (log number, creator, creation time, etc.). The application log
consists of several table entries. Applications write their entries
object-specifically to these tables using SAP function modules ·
The log data are initially collected in local memory, and can
be written to the database. This procedure speeds up processing and reduces the
number of database accesses. ·
A transaction can generate several logs, e.g. one for
temporary data to be displayed, one for persisting data on the database. ·
If you use the application log in complex scenarios such as
the ticket selling by internet used by a lot of users the application developer
has to consider and to take care of some fundamental programming principles. If
different users need to write into the same log you have to use the enqueue
mechanism for the application log. The tool offers corresponding function
modules to enqueue and dequeue the log. The log needs to be enqueued after
creating it and dequeued after the save and commit. ·
Application Log is designed for temporary logs, but not for
mission critical data: Data that, for reasons of revision security, have to be
available for a long period of time, should not be stored with the Application
Log but with the change documents. ·
The data of an application log are written to database when
you commit them (COMMIT WORK) after save. If you want to save application log
data independently of other application data (e.g., at a rollback of the
application) you have to save them in a separate LUW. ·
You will also find answers for many questions in OSS notes
(search component BC-SRV-BAL). ·
You can also find many demo programs provides by SAP on
application logs. Just do a F4 on “SBAL_DEMO_*” in se38.
|
|
|
Please send us your feedback/suggestions at webmaster@SAPTechnical.COM Home • Contribute • About Us • Privacy • Terms Of Use • Disclaimer • Safe • Companies: Advertise on SAPTechnical.COM | Post Job • Contact Us ©2006-2007 SAPTechnical.COM. All rights reserved. All
product names are trademarks of their respective companies. SAPTechnical.COM
is in no way affiliated with SAP AG. Graphic Design by Round the Bend Wizards |
||