09-10-2007 12:11 AM
HI All,
I have to write a program which should be run daily and it returns the list of error messages for unsuccessfull records. Will the messages be stored and written to spool based on the settings in SM37. Or will i have to write the code in my program to send the messages to the spool.
09-10-2007 12:17 AM
Setting up the job in SM36 is enough.. no need to code in the program..
Regards,
Arya
09-10-2007 12:17 AM
Setting up the job in SM36 is enough.. no need to code in the program..
Regards,
Arya
09-10-2007 12:19 AM
You have at least a couple of choices... any "write" statements will build a report and that will be visible in SP01 and SM37. You could also use "message s398(00 )with xxx xxx xxx xxx." type syntax to write info into the job log.
However both of these are transient stores i.e. Basis normally runs jobs to clean up jobs older than, say, 10 days. If you need to keep the info longer consider wrting it to a database table or a dataset. You could also look to define the job to send the report to spool recipients via email. Or write the fails into a BDC session (depending on what they are for of course!).
Jonathan
09-10-2007 5:56 AM
Hiii ,
Following is a simple code to check the background jobs status.But the standard transactions provided r sufficient for your requirement.
tables : TBTCO.
TYPE-POOLS slis.
data: progid like sy-repid.
DATA : BEGIN OF ITAB OCCURS 0,
JOBNAME LIKE TBTCO-JOBNAME,
JOBCOUNT LIKE TBTCO-JOBCOUNT,
SDLSTRTDT LIKE TBTCO-SDLSTRTDT,
STATUS LIKE TBTCO-STATUS,
TEXT(25) TYPE C,
END OF ITAB.
*data declaration
DATA : sl_layout TYPE slis_layout_alv OCCURS 0 WITH HEADER LINE,
sl_list_top_of_page TYPE slis_t_listheader,
sl_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
sl_events TYPE slis_t_event,
sl_tpage TYPE slis_t_listheader.
SELECTION-SCREEN : BEGIN OF BLOCK BLOCK WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS : LV_SDLDT FOR TBTCO-SDLSTRTDT. "START DATE
SELECT-OPTIONS : L_JOBNAM FOR TBTCO-JOBNAME . "NAME OF PROGRAM.
SELECTION-SCREEN END OF BLOCK BLOCK.
SELECT * FROM TBTCO INTO CORRESPONDING FIELDS OF TABLE ITAB WHERE JOBNAME IN L_JOBNAM
AND SDLSTRTDT IN LV_SDLDT.
LOOP AT ITAB .
CASE ITAB-STATUS.
WHEN 'P'.
ITAB-TEXT = 'PRELIMINARY'.
WHEN 'S'.
ITAB-TEXT = 'SCHEDULED'.
WHEN 'Y'.
ITAB-TEXT = 'READY'.
WHEN 'R'.
ITAB-TEXT = 'RUNNING'.
WHEN 'F'.
ITAB-TEXT = ' FINISHED'.
WHEN 'A'.
ITAB-TEXT = 'ABORTED'.
ENDCASE.
MODIFY ITAB TRANSPORTING TEXT.
CLEAR ITAB-TEXT.
ENDLOOP.
PERFORM build_catlog.
PERFORM display_cogs .
FORM build_catlog .
sl_fieldcat-fieldname = 'JOBNAME'.
sl_fieldcat-tabname = 'ITAB'.
sl_fieldcat-seltext_l = 'JOBNAME'.
APPEND sl_fieldcat.
CLEAR sl_fieldcat.
sl_fieldcat-fieldname = 'JOBCOUNT'.
sl_fieldcat-tabname = 'ITAB'.
sl_fieldcat-seltext_l = 'JOBCOUNT'.
APPEND sl_fieldcat.
CLEAR sl_fieldcat.
sl_fieldcat-fieldname = 'SDLSTRTDT'.
sl_fieldcat-tabname = 'ITAB'.
sl_fieldcat-seltext_l = 'DATE'.
APPEND sl_fieldcat.
CLEAR sl_fieldcat.
sl_fieldcat-fieldname = 'STATUS'.
sl_fieldcat-tabname = 'ITAB'.
sl_fieldcat-seltext_l = 'JOB STATUS'.
APPEND sl_fieldcat.
CLEAR sl_fieldcat.
sl_fieldcat-fieldname = 'TEXT'.
sl_fieldcat-tabname = 'ITAB'.
sl_fieldcat-seltext_l = 'STATUS TEXT'.
APPEND sl_fieldcat.
CLEAR sl_fieldcat.
ENDFORM.
&----
*& Form TOP-OF-PAGE
&----
text
----
FORM top-of-page.
DATA: t_header TYPE slis_t_listheader,
wa_header TYPE slis_listheader.
WA_HEADER-TYP = 'S'.
WA_HEADER-INFO = 'BACKGROUND JOB STATUS'.
APPEND WA_HEADER TO T_HEADER.
CLEAR WA_HEADER.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = T_HEADER.
ENDFORM. "TOP-OF-PAGE
&----
*& Form DISPLAY_COGS
&----
text
----
--> p1 text
<-- p2 text
----
FORM display_cogs .
progid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = progid
i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
is_layout = sl_layout
it_fieldcat = sl_fieldcat[]
TABLES
t_outtab = ITAB
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM. " DISPLAY_COGS
Reward if helpful,
Regards ,
Rupa