The aim of the chapter is to illustrate which parts of the template are to be modified and how.
This template can be found in the package /DVD/FS_TEMP, program /DVD/FS_TEMP_TASK_EXECUTION.
All the parts that require customization are shaded with yellow.
It is assumed that:
/dvd/fs_temp_cus is custom object header table
/dvd/fs_temp_col is custom object line table
/dvd/fs_temp_custid is CustomerID data element (key between header and line tables)
&--------------------------------------------------------------------- *& Report /DVD/FS_TEMP_TASK_EXECUTION *& &--------------------------------------------------------------------- *& *& &--------------------------------------------------------------------- REPORT /dvd/fs_temp_task_execution. " mandatory include for connection to OutBoard for Housekeeping framework INCLUDE /dvd/fs_framework.
* selection screen reflects the criteria of custom object selectionDATA: gv_custid TYPE /dvd/fs_temp_custid. SELECT-OPTIONS so_id FOR gv_custid. START-OF-SELECTION. PERFORM start_processing.
&--------------------------------------------------------------------- *& Form start_processing &--------------------------------------------------------------------- * text ---------------------------------------------------------------------- * -->IT_PARAMS text ---------------------------------------------------------------------- FORM start_processing. DATA: lv_tabname TYPE tabname, lv_retent TYPE /dvd/fs_rettime, ls_recb_obj TYPE /dvd/fs_recb_obj, lt_cust TYPE TABLE OF /dvd/fs_temp_cus, lt_cust_id TYPE TABLE OF /dvd/fs_temp_cus, ls_cust_id TYPE /dvd/fs_temp_cus, lt_coll TYPE TABLE OF /dvd/fs_temp_col, lt_object TYPE /dvd/fs_t_recb_obj, ls_object TYPE /dvd/fs_recb_obj, lv_str TYPE string. * read header table of object SELECT * FROM /dvd/fs_temp_cus INTO TABLE lt_cust_id WHERE custid IN so_id. IF sy-subrc = 0. lv_tabname = '/DVD/FS_TEMP_CUS'. * Registration of tables that will be needed to process – once for * each custom object table CALL FUNCTION '/DVD/FS_RECBIN_REG_TABLE' EXPORTING iv_taskgroup = p_tskgp iv_taskname = p_task iv_runid = p_runid iv_tabname = lv_tabname iv_retention_time = p_retime EXCEPTIONS no_run = 1 already_registred = 2 OTHERS = 3. IF sy-subrc <> 0. "error handling WRITE: / 'Cannot register table '(001), lv_tabname. EXIT. ENDIF. WRITE: / 'Table'(002), lv_tabname, 'was registered.'(003).
lv_tabname = '/DVD/FS_TEMP_COL'. CALL FUNCTION '/DVD/FS_RECBIN_REG_TABLE' EXPORTING iv_taskgroup = p_tskgp iv_taskname = p_task iv_runid = p_runid iv_tabname = lv_tabname iv_retention_time = p_retime EXCEPTIONS no_run = 1 already_registred = 2 OTHERS = 3. IF sy-subrc <> 0. "error handling WRITE: / 'Cannot register table '(001), lv_tabname. EXIT. ENDIF. WRITE: / 'Table'(002), lv_tabname, 'was registered.'(003). LOOP AT lt_cust_id INTO ls_cust_id. * Registration of each particular object in a selection lv_str = ls_cust_id-custid. " conversion for spaces ls_recb_obj-object_name = lv_str. " object unique identifier ls_recb_obj-description = ls_cust_id-custname. " object description ls_recb_obj-icon = ''. " object-specific icon CALL FUNCTION '/DVD/FS_RECBIN_REG_OBJECT' EXPORTING iv_taskgroup = p_tskgp iv_taskname = p_task iv_runid = p_runid iv_object_ch = ls_recb_obj-object_name iv_description = ls_recb_obj-description iv_icon = ls_recb_obj-icon IMPORTING es_object = ls_recb_obj EXCEPTIONS already_registred = 1 OTHERS = 2. IF sy-subrc <> 0. WRITE: / 'Unable to register object '(004), ls_recb_obj-object_name. EXIT. ENDIF. lv_tabname = '/DVD/FS_TEMP_CUS'. CLEAR lt_cust. APPEND ls_cust_id TO lt_cust. CALL FUNCTION '/DVD/FS_RECBIN_PUT_DATA' EXPORTING iv_taskgroup = p_tskgp iv_taskname = p_task iv_runid = p_runid iv_tabname = lv_tabname it_data = lt_cust iv_object = ls_recb_obj-object EXCEPTIONS table_not_registred = 1 insert_error = 2 OTHERS = 3. IF sy-subrc <> 0. WRITE: / 'Insert error, object: '(005), ls_recb_obj-object_name, ' table: '(006), lv_tabname. EXIT. ENDIF. WRITE: / 'Object'(007), ls_object-object_name, 'was registered'(003). lv_tabname = '/DVD/FS_TEMP_COL'. CLEAR lt_coll.
* Business logic – relation between header and line table – is implemented here SELECT * FROM /DVD/FS_TEMP_COL INTO TABLE lt_coll WHERE custid = ls_cust_id-custid. CALL FUNCTION '/DVD/FS_RECBIN_PUT_DATA' EXPORTING iv_taskgroup = p_tskgp iv_taskname = p_task iv_runid = p_runid iv_tabname = lv_tabname it_data = lt_coll iv_object = ls_recb_obj-object EXCEPTIONS table_not_registred = 1 insert_error = 2 OTHERS = 3. IF sy-subrc <> 0. WRITE: / 'Insert error, object: '(005), ls_recb_obj-object_name, ' table: '(006), lv_tabname. EXIT. ENDIF. * Close object CALL FUNCTION '/DVD/FS_RECBIN_UNREG_OBJECT' EXPORTING iv_taskgroup = p_tskgp iv_taskname = p_task iv_runid = p_runid iv_object = ls_recb_obj-object EXCEPTIONS not_registred = 1 OTHERS = 2. IF sy-subrc <> 0. WRITE: / 'Unable to close object '(007), ls_recb_obj-object_name. EXIT. ENDIF. APPEND ls_recb_obj TO lt_object. ENDLOOP. * Close registered tables lv_tabname = '/DVD/FS_TEMP_COL'. CALL FUNCTION '/DVD/FS_RECBIN_UNREG_TABLE' EXPORTING iv_taskgroup = p_tskgp iv_taskname = p_task iv_runid = p_runid iv_tabname = lv_tabname ib_dont_update_stat = space EXCEPTIONS no_run = 1 not_registred = 2 OTHERS = 3. IF sy-subrc <> 0. WRITE: / 'Unable to close table '(008), lv_tabname. EXIT. ENDIF. lv_tabname = '/DVD/FS_TEMP_CUS'. CALL FUNCTION '/DVD/FS_RECBIN_UNREG_TABLE' EXPORTING iv_taskgroup = p_tskgp iv_taskname = p_task iv_runid = p_runid iv_tabname = lv_tabname ib_dont_update_stat = space EXCEPTIONS no_run = 1 not_registred = 2 OTHERS = 3. IF sy-subrc <> 0. WRITE: / 'Unable to close table '(009), lv_tabname. EXIT. ENDIF. * Delete db tables based on object data LOOP AT lt_object INTO ls_object. CALL FUNCTION '/DVD/FS_RECBIN_DEL_SOURCE_OBJ' EXPORTING iv_taskgroup = p_tskgp iv_taskname = p_task iv_runid = p_runid iv_object = ls_object-object EXCEPTIONS object_is_locked = 1 object_not_found = 2 table_not_found = 3 mapping_is_missing = 4 no_data = 5 inconsistency_error = 6 general_error = 7 deletion_error = 8 records_count_error = 9 empty_object = 10 OTHERS = 11. IF sy-subrc <> 0. WRITE: / 'Unable to delete data from database for object '(010), ls_object-object_name. ELSE. WRITE: / 'Object'(007), ls_object-object_name, 'was deleted from database.'(011). ENDIF. ENDLOOP. ELSE. WRITE: / 'No object to process.'(012). ENDIF. ENDFORM. "start_processing