Wednesday, February 13, 2008

How to create ABAP reports with IS-U like logs.

Today I want to share you with a powerfull tool which is the IS-U like log system.
You can display an IS-U like log using transaction SLG1 or SLG_ISU.

How can you create ABAP reports with IS-U like logs?

This is a picture of how a IS-U like log looks like:



You need/can define your own log object in the system in the view BALOBJ. Using SM30 you can define your own log object. Let's define a ZTEST log in this view.






After that you can use the log object in your ABAP reports.
You can copy and paste the above text into SE38 ABAP Editor.

*You need to include the EMSG include program in your report.

INCLUDE EMSG.

*This include contains a lots of macros used to write log messages.
*Second you need the type pool EEMSG.

TYPE-POOLS: eemsg.

*Define a log parameter structure :

DATA: xy_parm TYPE eemsg_parm_open.

*And the log handle:
DATA: handle LIKE emsg_gen-handle.

*Define a parameter to hold the internal log number like this:

PARAMETERS extnr LIKE balhdr-extnumber NO-DISPLAY.

*Open the log using the above code.

CLEAR xy_parm.
xy_parm-extnumber = extnr.
xy_parm-appl_log = 'ZTEST'.

CALL FUNCTION 'MSG_OPEN'
EXPORTING
x_no_dialog = ' '
x_log = 'X'
x_next_msg = ' '
x_obj_twice = ' '
IMPORTING
y_msg_handle = handle
CHANGING
xy_parm = xy_parm.


*Now you can write to the log using the macro mac_msg_putx.

mac_msg_putx co_msg_information '398' '00'
'INFO' '123' space space space.

mac_msg_putx co_msg_error '398' '00' 'Error' '123' space space space.


*When the program is finished you should:

*Save the log like
CALL FUNCTION 'MSG_ACTION'
EXPORTING
x_msg_handle = handle
x_action = co_msg_save
EXCEPTIONS
OTHERS = 1.

IF sy-subrc <> 0.
mac_msg_repeat co_msg_error internal_error.
ENDIF.

*Display the log is not in background like this:
IF sy-batch IS INITIAL.
CALL FUNCTION 'MSG_ACTION'
EXPORTING
x_msg_handle = handle
x_action = co_msg_dspl
EXCEPTIONS
OTHERS = 1.
ENDIF.

*Close the log.

CALL FUNCTION 'MSG_CLOSE'
EXPORTING
x_msg_handle = handle.



*Now we're done. You should have a log which looks like the first picture.

6 comments:

abaper said...

Very nice tutorial. Not too short, not too long. Just what I need. Thanks!

Sij said...

Hey am using this macros for displaying log.
Can you tell how to pass messages with parameters into this.

Ramya k said...

Thanks for the great information, was looking for this information from long.Great blogSAP MM Training in Chennai

Fangyaya said...

ray ban sunglasses
cheap air jordans
nike blazers shoes
nike air max 90
true religion jeans
gucci handbags
gucci outlet
gucci belts
ray ban sunglasses uk
louis vuitton outlet
replica rolex watches
louis vuitton purses
true religion jeans
oakley sunglasses
ray ban sunglasses
kate spade
jordan retro 11
burberry handbags
kobe 9
oakley outlet
kevin durant shoes 7
coach outlet
louis vuitton purses
toms shoes
christian louboutin shoes
louis vuitton outlet
nike uk
nike trainers uk
nike store
nike sb janoski
20150507chenenen

sushma said...

Thanks for sharing great information in your blog. Got to learn new things from your Blog . It was very nice blog to learn about SAP BASIS.
SAP BASIS

Rahul said...

It was very nice blog to learn about SAP BASIS. Thanks for sharing.SAP basis