Submit program RFBIBL00 and display protocol from your ABAP

If you are going to develop automatic FI posting, it's quite nice to use RFBIBL00 program. Using it you are independent from screen numbers, field names and other static dynpro stuff.

The example below shows, how you can submit program RFBIBL00 from you ABAP, wait until it's finished and display protocol of the map generation.
See also my other example to displaying a protocol of map processing.
*&---------------------------------------------------------------------*
*&      Form  rfbibl00_submit
*&---------------------------------------------------------------------*
FORM rfbibl00_submit USING pi_filename TYPE rlgrap-filename.

  DATA:
    lv_jobcount          TYPE tbtcjob-jobcount,
    lv_jobname           TYPE tbtcjob-jobname VALUE 'RFBIBL00',
    lv_realm             TYPE c VALUE 'X',
    ls_job_read_jobhead  TYPE tbtcjob,
    ls_joblog_attributes TYPE bapixmjoblog,
    lt_joblogtbl         TYPE TABLE OF tbtc5,
    ls_joblogtbl         TYPE tbtc5.

* Define background job
  CALL FUNCTION 'JOB_OPEN'
    EXPORTING
      jobname          = lv_jobname
    IMPORTING
      jobcount         = lv_jobcount
    EXCEPTIONS
      cant_create_job  = 1
      invalid_job_data = 2
      jobname_missing  = 3
      OTHERS           = 4.

* with program RFBIBL00
  SUBMIT rfbibl00
    WITH ds_name  = pi_filename
    WITH fl_check = ' '
    WITH callmode = 'B'
    WITH max_comm = 1000
    WITH pa_xprot = ' '
*   WITH ANZ_MODE = 'N'
*   WITH UPDATE   = 'A'
    WITH xpop     = ' '
    WITH xlog     = 'X'
    WITH xinf     = ' '
  VIA JOB lv_jobname NUMBER lv_jobcount
  AND RETURN.

* Release the job
  CALL FUNCTION 'JOB_CLOSE'
    EXPORTING
      jobcount             = lv_jobcount
      jobname              = lv_jobname
      strtimmed            = 'X'
    EXCEPTIONS
      cant_start_immediate = 1
      invalid_startdate    = 2
      jobname_missing      = 3
      job_close_failed     = 4
      job_nosteps          = 5
      job_notex            = 6
      lock_failed          = 7
      OTHERS               = 8.

* Wait on for end of the job
  WHILE ls_job_read_jobhead-status <> 'F'
    AND ls_job_read_jobhead-status <> 'A'.

    CALL FUNCTION 'BP_JOB_READ'
      EXPORTING
        job_read_jobcount     = lv_jobcount
        job_read_jobname      = lv_jobname
        job_read_opcode       = '37'
      IMPORTING
        job_read_jobhead      = ls_job_read_jobhead
        joblog_attributes     = ls_joblog_attributes
      EXCEPTIONS
        invalid_opcode        = 1
        job_doesnt_exist      = 2
        job_doesnt_have_steps = 3
        OTHERS                = 4.

    ASSERT sy-subrc = 0.

    WAIT UP TO 1 SECONDS.
  ENDWHILE.

* Read protocol
  CALL FUNCTION 'BP_JOBLOG_READ'
    EXPORTING
      client                = sy-mandt
      jobcount              = lv_jobcount
      joblog                = ls_joblog_attributes-tmsname
      jobname               = lv_jobname
    TABLES
      joblogtbl             = lt_joblogtbl
    EXCEPTIONS
      cant_read_joblog      = 1
      jobcount_missing      = 2
      joblog_does_not_exist = 3
      joblog_is_empty       = 4
      joblog_name_missing   = 5
      jobname_missing       = 6
      job_does_not_exist    = 7
      OTHERS                = 8.

    ASSERT sy-subrc = 0.

* Display protocol
  SKIP.
  WRITE: / 'Protocol of program RFBIBL00:'.
  LOOP AT lt_joblogtbl INTO ls_joblogtbl
    WHERE msgid <> '00'.

    WRITE: / ls_joblogtbl-text.
  ENDLOOP.
ENDFORM.                    "rfbibl00_submit
See other related notes in my infodepot:
Background job - ensure sequential processing Display protocol of batch input processing - transaction SM35
Full list of examples in my infodepot

If you have a question, have found an error or just want to contact me, please use this form.

Copyright (C) 2011 http://www.kerum.pl/infodepot/

Disclaimer: I am not affiliated or related to any division or subsidiary of SAP AG.
Trademarks or registered trademarks of any products or companies referred to on this site belong to those companies.
Anyone using the given solutions, is doing it under his/her own responsibility and at own risk.