Skip to Content
0
Former Member
Apr 01, 2008 at 07:09 AM

Job scheduling

14 Views

Hi experts,

I have to schedule jobs one by one for each of the 10000 entries(given by lv_package_size) given below programatically.

After one job completes, the next one shud start automatically.

How shud i proceed?

*****************************************************************************************************************

SORT gt_cnvmbttables BY tabname.

DATA : lv_cursor TYPE cursor,

ls_result LIKE gs_result,

lt_result TYPE TABLE OF cnvtdms_02_size_structure,

lv_package_size TYPE i VALUE 10000.

  • Break the internal table into smaller parts.

IF p_btm = 'X'.

OPEN CURSOR WITH HOLD lv_cursor FOR

SELECT * FROM dd02l

WHERE as4local = 'A' AND

( tabclass = 'TRANSP' OR

tabclass = 'POOL' OR

tabclass = 'CLUSTER' ) .

DO.

FETCH NEXT CURSOR lv_cursor

INTO CORRESPONDING FIELDS OF TABLE lt_result

PACKAGE SIZE lv_package_size.

IF sy-subrc <> 0.

EXIT.

ELSE.

  • SORT gt_cnvmbttables BY tabname.

LOOP AT lt_result INTO ls_result.

READ TABLE gt_cnvmbttables INTO gs_cnvmbttables

WITH KEY tabname = ls_result-tabname

BINARY SEARCH.

IF sy-subrc <> 0

OR ( sy-subrc = 0 AND gs_cnvmbttables-no_exist = 'X' ).

DELETE lt_result.

ENDIF.

APPEND ls_result TO gt_result.

ENDLOOP.

*Build worklist

CALL FUNCTION 'CNV_TDMS_02_TABLESIZES'

EXPORTING

im_packid = p_pack

im_phase = p_phase

im_act_id = p_act_id

TABLES

t_result = lt_result

t_balmi = gt_balmi

EXCEPTIONS

analysis_not_possible = 1

database_not_found = 2

error_in_tablesize = 3

OTHERS = 4.

IF sy-subrc <> 0.

*- Size and index details could not be obtained for table &1.

LOOP AT gt_balmi INTO gs_balmi.

m_message 'CNV_TDMS_02_SIZE_A' 'E' '074'

gs_balmi-msgv1 '' '' '' '1' '1'.

ENDLOOP.

CASE sy-subrc.

WHEN '1'.

*- error in analysing tables for &1 database.

m_message 'CNV_TDMS_02_SIZE_A' 'E' '073'

'ORACLE' '' '' '' '1' '1'.

WHEN '2'.

*- Analysis cannot be done for the database &1.

m_message 'CNV_TDMS_02_SIZE_A' 'E' '061'

sy-dbsys ''

'' '' '1' '1'.

WHEN '3'.

*- Internal error &1 calling &2.

m_message 'CNV_TDMS_02_SIZE_A' 'E' '020'

sy-subrc 'CNV_TDMS_02_TABLESIZE'

'' '' '1' '1'.

WHEN OTHERS.

*- Internal error &1 calling &2.

m_message 'CNV_TDMS_02_SIZE_A' 'E' '020'

sy-subrc 'CNV_TDMS_02_TABLESIZES'

'' '' '1' '1'.

ENDCASE.

*- Update status of program to E

m_status_update p_pack p_phase p_act_id 'E' .

*- leave program

PERFORM leave_program.

ENDIF.

REFRESH lt_result.

REFRESH gt_balmi.

ENDIF.

ENDDO.

IF NOT lv_cursor IS INITIAL.

CLOSE CURSOR lv_cursor.

ENDIF.

ELSE.

OPEN CURSOR WITH HOLD lv_cursor FOR

SELECT * FROM dd02l WHERE

( as4local = 'A' AND tabclass = 'TRANSP' AND clidep = 'X' ) OR

( as4local = 'A' AND tabclass = 'POOL' AND clidep = 'X' ) OR

( as4local = 'A' AND tabclass = 'CLUSTER' AND clidep = 'X' ).

DO.

FETCH NEXT CURSOR lv_cursor

INTO CORRESPONDING FIELDS OF TABLE lt_result

PACKAGE SIZE lv_package_size.

IF sy-subrc <> 0.

EXIT.

ELSE.

LOOP AT lt_result INTO ls_result.

READ TABLE gt_cnvmbttables INTO gs_cnvmbttables

WITH KEY tabname = ls_result-tabname

BINARY SEARCH.

IF sy-subrc <> 0

OR ( sy-subrc = 0 AND gs_cnvmbttables-no_exist = 'X' ).

DELETE lt_result.

ENDIF.

APPEND ls_result TO gt_result.

ENDLOOP.

*Build worklist

CALL FUNCTION 'CNV_TDMS_02_TABLESIZES'

EXPORTING

im_packid = p_pack

im_phase = p_phase

im_act_id = p_act_id

TABLES

t_result = lt_result

t_balmi = gt_balmi

EXCEPTIONS

analysis_not_possible = 1

database_not_found = 2

error_in_tablesize = 3

OTHERS = 4.

IF sy-subrc <> 0.

*- Size and index details could not be obtained for table &1.

LOOP AT gt_balmi INTO gs_balmi.

m_message 'CNV_TDMS_02_SIZE_A' 'E' '074'

gs_balmi-msgv1 '' '' '' '1' '1'.

ENDLOOP.

CASE sy-subrc.

WHEN '1'.

*- error in analysing tables for &1 database.

m_message 'CNV_TDMS_02_SIZE_A' 'E' '073'

'ORACLE' '' '' '' '1' '1'.

WHEN '2'.

*- Analysis cannot be done for the database &1.

m_message 'CNV_TDMS_02_SIZE_A' 'E' '061'

sy-dbsys ''

'' '' '1' '1'.

WHEN '3'.

*- Internal error &1 calling &2.

m_message 'CNV_TDMS_02_SIZE_A' 'E' '020'

sy-subrc 'CNV_TDMS_02_TABLESIZE'

'' '' '1' '1'.

WHEN OTHERS.

*- Internal error &1 calling &2.

m_message 'CNV_TDMS_02_SIZE_A' 'E' '020'

sy-subrc 'CNV_TDMS_02_TABLESIZES'

'' '' '1' '1'.

ENDCASE.

*- Update status of program to E

m_status_update p_pack p_phase p_act_id 'E' .

*- leave program

PERFORM leave_program.

ENDIF.

REFRESH lt_result.

REFRESH gt_balmi.

ENDIF.

ENDDO.

IF NOT lv_cursor IS INITIAL.

CLOSE CURSOR lv_cursor.

ENDIF.

ENDIF.

SORT gt_result BY sqltab.

*****************************************************************************************************************

I will reward all the helpful answers.

Thanks,

Mohit.