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

slg1

Former Member
0 Likes
426

Hi

i want to use slg1 to display log.Currently using this but not getting anything on output screen.I am using session method.Please tell if this code is fine and we need to write after bdc insert this code.

DATA: BEGIN OF p_prot_mess OCCURS 0.

INCLUDE STRUCTURE balMI.

DATA: END OF p_prot_mess.

DATA: prot_obj LIKE balhdr-object VALUE 'ZBUDGET_UPLOAD',

sub_obj LIKE balhdr-object VALUE 'ZBUDGET_UPLOAD'.

DATA: BEGIN OF prot_nr OCCURS 0.

INCLUDE STRUCTURE balnri.

DATA: END OF prot_nr.

DATA: BEGIN OF prot_head.

INCLUDE STRUCTURE balhdri.

DATA: END OF prot_head.

DATA: client_role TYPE c.

CALL FUNCTION 'TR_SYS_PARAMS'

IMPORTING

system_client_role = client_role.

CALL FUNCTION 'APPL_LOG_INIT'

EXPORTING

object = prot_obj

subobject = sub_obj

EXCEPTIONS

OTHERS = 0.

prot_head-object = prot_obj.

prot_head-subobject = sub_obj.

prot_head-aldate = syst-datum.

prot_head-altime = syst-uzeit.

prot_head-aluser = syst-uname.

prot_head-altcode = syst-tcode.

prot_head-alprog = syst-repid.

prot_head-aldate_del = syst-datum + 100.

prot_head-del_before = 'X'.

CALL FUNCTION 'APPL_LOG_WRITE_HEADER'

EXPORTING

header = PROT_HEAD

EXCEPTIONS

OTHERS = 0.

CALL FUNCTION 'APPL_LOG_WRITE_MESSAGES'

TABLES

messages = P_PROT_MESS

EXCEPTIONS

object_not_found = 0.

CALL FUNCTION 'APPL_LOG_WRITE_DB'

TABLES

object_with_lognumber = PROT_NR

EXCEPTIONS

OTHERS = 0.

Hi

i want to use slg1 to display log.Currently using this but not getting anything on output screen.I am using session method.Please tell if this code is fine and we need to write after bdc insert this code.

DATA: BEGIN OF p_prot_mess OCCURS 0.

INCLUDE STRUCTURE balMI.

DATA: END OF p_prot_mess.

DATA: prot_obj LIKE balhdr-object VALUE 'ZBUDGET_UPLOAD',

sub_obj LIKE balhdr-object VALUE 'ZBUDGET_UPLOAD'.

DATA: BEGIN OF prot_nr OCCURS 0.

INCLUDE STRUCTURE balnri.

DATA: END OF prot_nr.

DATA: BEGIN OF prot_head.

INCLUDE STRUCTURE balhdri.

DATA: END OF prot_head.

DATA: client_role TYPE c.

CALL FUNCTION 'TR_SYS_PARAMS'

IMPORTING

system_client_role = client_role.

CALL FUNCTION 'APPL_LOG_INIT'

EXPORTING

object = prot_obj

subobject = sub_obj

EXCEPTIONS

OTHERS = 0.

prot_head-object = prot_obj.

prot_head-subobject = sub_obj.

prot_head-aldate = syst-datum.

prot_head-altime = syst-uzeit.

prot_head-aluser = syst-uname.

prot_head-altcode = syst-tcode.

prot_head-alprog = syst-repid.

prot_head-aldate_del = syst-datum + 100.

prot_head-del_before = 'X'.

CALL FUNCTION 'APPL_LOG_WRITE_HEADER'

EXPORTING

header = PROT_HEAD

EXCEPTIONS

OTHERS = 0.

CALL FUNCTION 'APPL_LOG_WRITE_MESSAGES'

TABLES

messages = P_PROT_MESS

EXCEPTIONS

object_not_found = 0.

CALL FUNCTION 'APPL_LOG_WRITE_DB'

TABLES

object_with_lognumber = PROT_NR

EXCEPTIONS

OTHERS = 0.

1 REPLY 1
Read only

Former Member
0 Likes
357

hi,

please use this code if possible....since BAL is much more flexible den APP...

First go to SLG0 and create an Object and sub-object in customer name space. Then write the following code in your programu2026..

DATA: w_loghead TYPE bal_s_log,

w_logmsg TYPE bal_s_msg..

w_loghead-object = 'OBJECT NAME'.

w_loghead-subobject = 'SUBOBJECT NAME'.

w_loghead-aldate_del = sy-datum + 90. "expires in 90 days

*Creating LOG

CALL FUNCTION 'BAL_LOG_CREATE'

EXPORTING i_s_log = w_loghead

  • IMPORTING e_log_handle =

EXCEPTIONS

OTHERS = 1.

w_logmsg-msgty = sy-msgty.

w_logmsg-msgid = u2018Message class nameu2019.

w_logmsg-msgno = 'Message number'.

  • w_logmsg-msgv1 = msg_v1.

  • w_logmsg-msgv2 = msg_v2.

  • w_logmsg-msgv3 = msg_v3.

  • w_logmsg-msgv4 = msg_v4.

  • Adding Log

CALL FUNCTION 'BAL_LOG_MSG_ADD'

EXPORTING "i_log_handle =

i_s_msg = w_logmsg

EXCEPTIONS

OTHERS = 1.

  • Saving Log

CALL FUNCTION 'BAL_DB_SAVE'

EXPORTING "i_t_log_handle =

I_SAVE_ALL = 'X'

EXCEPTIONS

OTHERS = 1.

COMMIT WORK.