Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Question on BAL_LOG_CREATE

Former Member
0 Likes
2,873

Hi All,

I want to know what does this function module do. Does this create an application log or open an application log that is already.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,442

Sham,

It opens the application log.

<b>SAP documentation</b> :

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.

The function module BAL_LOG_CREATE returns the log handle (LOG_HANDLE, CHAR22).

The LOG_HANDLE is a GUID (globally unique identifier) which uniquely identifies a log. You can access this log with this handle, for example, to subsequently change the header data ( BAL_LOG_HDR_CHANGE) or to add a message ( BAL_LOG_MSG_ADD) or an exception text ( BAL_LOG_EXCEPTION_ADD) to the log.

The LOG_HANDLE has its permanent value straight away, so it remains valid after saving.

==>Note:

Logs in memory and in the database are referred to in the new Application Log by the log handle (LOG_HANDLE), but the previous LOGNUMBER, which is assigned from number range interval 01 of number range object APPL_LOG when you save, still exists. A lot of applications have a reference to this LOGNUMBER in their structures, so it is still supported. The LOGNUMBER is also more understandable for users than the LOG_HANDLE. There is a 1:1 relationship between LOG_HANDLE and LOGNUMBER.

Regards

Aneesh.

4 REPLIES 4
Read only

Former Member
0 Likes
2,443

Sham,

It opens the application log.

<b>SAP documentation</b> :

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.

The function module BAL_LOG_CREATE returns the log handle (LOG_HANDLE, CHAR22).

The LOG_HANDLE is a GUID (globally unique identifier) which uniquely identifies a log. You can access this log with this handle, for example, to subsequently change the header data ( BAL_LOG_HDR_CHANGE) or to add a message ( BAL_LOG_MSG_ADD) or an exception text ( BAL_LOG_EXCEPTION_ADD) to the log.

The LOG_HANDLE has its permanent value straight away, so it remains valid after saving.

==>Note:

Logs in memory and in the database are referred to in the new Application Log by the log handle (LOG_HANDLE), but the previous LOGNUMBER, which is assigned from number range interval 01 of number range object APPL_LOG when you save, still exists. A lot of applications have a reference to this LOGNUMBER in their structures, so it is still supported. The LOGNUMBER is also more understandable for users than the LOG_HANDLE. There is a 1:1 relationship between LOG_HANDLE and LOGNUMBER.

Regards

Aneesh.

Read only

Former Member
0 Likes
2,442

Application Log: Log: Create with Header Data

ctionality

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.

The function module BAL_LOG_CREATE returns the log handle (LOG_HANDLE,

CHAR22).

The LOG_HANDLE is a GUID (globally unique identifier) which uniquely

identifies a log. You can access this log with this handle, for example,

to subsequently change the header data ( BAL_LOG_HDR_CHANGE) or to add a

message (BAL_LOG_MSG_ADD) or an exception text (BAL_LOG_EXCEPTION_ADD)

to the log.

The LOG_HANDLE has its permanent value straight away, so it remains

valid after saving.

==>Note:

Logs in memory and in the database are referred to in the new

Application Log by the log handle (LOG_HANDLE), but the previous

LOGNUMBER, which is assigned from number range interval 01 of number

range object APPL_LOG when you save, still exists. A lot of applications

have a reference to this LOGNUMBER in their structures, so it is still

supported. The LOGNUMBER is also more understandable for users than the

LOG_HANDLE. There is a 1:1 relationship between LOG_HANDLE and

Related function modules

Simple log creation call

Methods of collecting messages

BAL_DSP_LOG_DISPLAY displays the collected messages. It can be called

without parameters, in which case all messages in memory are displayed

in a standard format (this standard format is also used in the

transaction SLG1).

==>Note

The log handle is optional for function modules such as BAL_LOG_MSG_ADD,

BAL_LOG_MSG_CUMULATE, BAL_LOG_MSG_ADD_FREE_TEXT, etc.

If it is not specified, the default log, which can be set, with other

default data, with BAL_GLB_MSG_DEFAULTS_SET is used. If no default log

is defined, it is set automatically by BAL_LOG_CREATE (see here).

The 'Application Log' is a tool for collecting messages, saving, reading

and deleting logs in the database, and displaying logs. It is introduced

and described in the following documentation.

Read only

0 Likes
2,442

CALL FUNCTION 'BAL_LOG_CREATE'

EXPORTING

i_s_log = ls_log

IMPORTING

e_log_handle = pc_log_handle

EXCEPTIONS

OTHERS = 1.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ELSE.

  • MESSAGE s000(/bmw/gis_tp_par01) WITH 'Log Created' pc_log_handle

msgtype = 'S'.

msgno = '000'.

CONCATENATE 'Log Created' pc_log_handle INTO l_msg.

PERFORM log_add_msg USING pc_log_handle msgtype msgno l_msg.

this FM create Application log with log handle as key ..

FORM log_add_msg USING pu_log_handle TYPE balloghndl

msgtype TYPE char1

msgno LIKE sy-msgno

l_msg TYPE char100 .

  • Add Message to Application Log

DATA:

ls_msg TYPE bal_s_msg.

  • CHECK: NOT pus_msg-type IS INITIAL.

ls_msg-msgty = msgtype.

ls_msg-msgid = '/BMW/GIS_TP_PAR01'.

ls_msg-msgno = msgno.

ls_msg-msgv1 = l_msg.

  • ls_msg-msgv2 = pus_msg-message_v2.

  • ls_msg-msgv3 = pus_msg-message_v3.

  • ls_msg-msgv4 = pus_msg-message_v4.

*

CALL FUNCTION 'BAL_LOG_MSG_ADD'

EXPORTING

i_log_handle = pu_log_handle

i_s_msg = ls_msg

EXCEPTIONS

log_not_found = 0

OTHERS = 1.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

  • ELSE.

  • MESSAGE s000(/bmw/gis_tp_par01) WITH 'Message added to log'

  • pc_log_handle.

ENDIF.

ENDFORM.

Read only

0 Likes
2,442

Hi,

I would like to know one more doubt. do I ned to call this function all the time before adding the message? If you can give me some more details regarding the usage, that would be great.

Thanks,

Sham.