Skip to Content
Author's profile photo Former Member

Tracking a background Job Via Spool Generation and use of CDHDR table

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:



Signifies print authorization, Default for ‘authorization’.



Signifies number of copies generated in spool



Output value for cover sheet



Name of the spool file



Department on cover page



Spool output device



Spool retention period



Print immediately in spool



New spool request



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



Signifies user name

IMPORTING parameters:      



Defines value to be passed to out_parameters



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.

·         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:

                   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
                   out_parameters                 = wa_pri_params
                   valid                                = lv_valid
                   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.
          PARAMETERS wa_pripar
          NO DIALOG.
          WRITE :/ g_counter, ‘ Number of records processed’.

  1. ELSE.
              CLEAR lv_counter.

·         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


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


Display Spool request by selecting icons under TYPE column.


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:




Structure of CDHDR table:


Sample data


Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo nabheet madan
      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?



      Author's profile photo Former Member
      Former Member
      Blog 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 .


      Ravi Thacker

      Author's profile photo nabheet madan
      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.


      Author's profile photo Former Member
      Former Member
      Blog Post Author

      @nabheet : They specifically wanted spool and were not convinced with just the write statement solution !!