REPORT ZEXAMPLE.

TABLES: TBIST, TBIER.

DATA: BEGIN OF I_TJOBS OCCURS 0.

INCLUDE STRUCTURE TBIER_S.

DATA: END OF I_TJOBS.

DATA: I_TBIZU LIKE TBIZU OCCURS 0 WITH HEADER LINE.

DATA: ABORTED,FINISHED,PRELIMINARY,READY,RUNNING,SCHEDULED.

* JOB NAMES

SELECT * FROM TBIZU INTO TABLE I_TBIZU.

* CURRENT JOBS

SELECT * FROM TBIST.

MOVE-CORRESPONDING TBIST TO I_TJOBS.

I_TJOBS-JOBID = TBIST-JOBNAME.

APPEND I_TJOBS.

ENDSELECT.

* COMPLETED JOBS

SELECT * FROM TBIER.

MOVE-CORRESPONDING TBIER TO I_TJOBS.

I_TJOBS-JOBID = TBIER-JOBNAME.

APPEND I_TJOBS.

ENDSELECT.

LOOP AT I_TJOBS.

READ TABLE I_TBIZU WITH KEY JOBID = I_TJOBS-JOBID BINARY SEARCH.

IF SY-SUBRC = 0.

I_TJOBS-JOBTEXT = I_TBIZU-JOBTEXT.

I_TJOBS-BTCJOB = I_TBIZU-BTCJOB.

ENDIF.

CALL FUNCTION 'SHOW_JOBSTATE'

EXPORTING

JOBCOUNT = I_TJOBS-JOBCOUNT

JOBNAME = I_TJOBS-BTCJOB

IMPORTING

ABORTED = ABORTED

FINISHED = FINISHED

PRELIMINARY = PRELIMINARY

READY = READY

RUNNING = RUNNING

SCHEDULED = SCHEDULED

EXCEPTIONS

JOBCOUNT_MISSING = 01

JOBNAME_MISSING = 02

JOB_NOTEX = 03

OTHERS = 99.

IF SY-SUBRC <> 0.

I_TJOBS-STATUSTEXT = 'ERROR IN FUNCTION CALL'.

ELSE.

IF ABORTED = 'X'.

I_TJOBS-STATUSTEXT = 'JOB ABORTED'.

ELSEIF FINISHED = 'X'.

I_TJOBS-STATUSTEXT = 'JOB FINISHED'.

ELSEIF SCHEDULED = 'X'.

I_TJOBS-STATUSTEXT = 'JOB SCHEDULED'.

ELSEIF RUNNING = 'X'.

I_TJOBS-STATUSTEXT = 'JOB RUNNING'.

ELSEIF READY = 'X'.

I_TJOBS-STATUSTEXT = 'JOB READY'.

ELSE.

I_TJOBS-STATUSTEXT = 'JOB UNKNOWN'.

ENDIF.

MODIFY I_TJOBS.

ENDIF.

ENDLOOP.

WRITE:/'JOB ID', 10 'JOB STATUS'.

LOOP AT I_TJOBS.

WRITE:/ I_TJOBS-JOBID,

I_TJOBS-STATUSTEXT.

ENDLOOP.