1.            Introduction

Why to monitor background jobs ?

Many a times we schedule background jobs where the data is processed. In the development environment the number of records are less hence the time taken is manageable. When it comes to production environment, the number of record can fall in the range of hundreds of thousands. In such cases, it may be required to generate a spool request everytime a fixed number of records is processed so that the job is monitored in real time and the user has a general idea on the status of job.

What is CDHDR table ?

Also sometimes it is required to retireve the historical data of the changes made to an object, CDHDR table can be used in this case to trace the changes made at the header level.  

  

2.            Monitor a background job by spool generation:

FM used to generate spool “GET_PRINT_PARAMETERS” : Read, determine, change spool print parameters and archive parameters.

Exporting parameters:

authority

:

Signifies print authorization, Default for ‘authorization’.

copies

:

Signifies number of copies generated in spool

cover_page

:

Output value for cover sheet

data_set

:

Name of the spool file

department

:

Department on cover page

destination

:

Spool output device

expiration     

:

Spool retention period

immediately

:

Print immediately in spool

new_list_id

:

New spool request

no_dialog

:

If you select no_dialog, a dialog will appears allows user to change print parameters. Use space to suppress dialog.

user

:

Signifies user name

IMPORTING parameters:      

out_parameters

:

Defines value to be passed to out_parameters

valid

:

Has the value BLANK, if the user cancelled the print screen.

You should query against the value VALID, its has only two value either TRUE or FALSE.

IF VALID = FALSE, either the print dialog has been canceled by user or wrong value is passed to function module parameters to print properly, for e.g. printing in the background in a forefront printer.

  

3.            Steps to generate spool:

·         Spool generation is done only when the record is processed.

·         Once the records are processed, FM to commit the changes is called.
CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT’.

·         Once the changes are saved in database and a fixed number of records are processed or when all the records are processed,call is made to the FM ‘GET_PRINT_PARAMETERS’ as follows:

CALL FUNCTION ‘GET_PRINT_PARAMETERS’
          EXPORTING
                   authority                           = space
                   copies                              = ‘1’
                   cover_page                       = space
                   data_set                           = space
                   department                       = space
                   destination                        = space
                   expiration                         = ‘1’
                   immediately                      = space
                   new_list_id                        = ‘X’
                   no_dialog                          = ‘X’
                   user                                 = sy-uname
          IMPORTING
                   out_parameters                 = wa_pri_params
                   valid                                = lv_valid
          EXCEPTIONS
                   archive_info_not_found       = 1
                   invalid_print_params           = 2
                   invalid_archive_params       = 3
                   OTHERS                            = 4.

IF lv_valid <> space AND sy-subrc = 0.
          wa_pri_params-prrel = space.
          wa_pri_params-primm = space.
          NEW-PAGE PRINT ON
          NEW-SECTION
          PARAMETERS wa_pripar
          NO DIALOG.
          WRITE :/ g_counter, ‘ Number of records processed’.

  1. ELSE.
              CLEAR lv_counter.
    ENDIF.

·         Here in this case, we have to create new spool after processing of every 5000 records.

·         This generates the spool as follows with ‘G_COUNTER’ containing the count of the number of records processed.

·         NEW-PAGE PRINT ON statement is used to print new spool.

·         To check the spool GO to TCODE ‘SP01’ -> search the spool generated -> click on the spool to see the output generated.

Output when G_COUNTER is set to ‘5000’ i.e spool after every 5000 records processed.

Spool request selection screen:

Transaction: SP01

/wp-content/uploads/2013/10/1_299774.png

You can also select spool request by entering Spool request Number.

/wp-content/uploads/2013/10/2_299775.png

Display Spool request by selecting icons under TYPE column.

/wp-content/uploads/2013/10/3_299776.png

Another spool request is created after processing of next 5000 records, depending upon conditions./wp-content/uploads/2013/10/4_299780.png

4.            Retrieving Service order historical data from CDHDR table:

CDHDR Table:

The data from the CDHDR table can be retrieved by passing the object class and object id as required. The field required can be entered in the select query and the required details based on the date, time, user id can be used as per the requirement.

Example of the select query:

OBJECT CLASS: CRM_ORDER

OBJECT ID: GUID OF THE SERVICE ORDER

/wp-content/uploads/2013/10/5_299781.png

Structure of CDHDR table:

/wp-content/uploads/2013/10/6_299782.png

Sample data

/wp-content/uploads/2013/10/7_299786.png

To report this post you need to login first.

4 Comments

You must be Logged on to comment or reply to a post.

  1. nabheet madan

    Hi Ravi

    Thanks for writing but i am not able to still understand the purpose of the document. Can you please summarize what exact value/knowledge it adds for all the community members?

    Thanks

    Nabheet

    (0) 
    1. Ravi Thacker Post author

      Hi Nabheet ,

      We had business requirement where they had to close all the follow up associated with a service order which was already closed . So we made a custom abap report to acheive that . Now since the dev. system had very few records it worked all fine but when the program was run in quality and prod. environment it took a lot of time and had production issue . Thats when they asked for a counter and spool updation so that they can track this dynamicall that if they upload a total of say 100000 lakh record to be closed an hour back how much of those has been processed and how much is still left giving them approximate time left . In such scenario spools are generated and hence the processing can b monitored during runtime .

      The Second part can be used when ever historical changes is required to be retrieved .

      I hope i am able to convey my requirement . Thanks for your question and time .

      Regards,

      Ravi Thacker

      (0) 
      1. nabheet madan

        Hi Ravi

        Thanks for the explanation you could have simply used write statement and they would have know how many are processed till that time.

        Anyways thanks for explaining the reason.

        Nabheet

        (0) 

Leave a Reply