*&---------------------------------------------------------------------* *& Report ZSAP_SCI_DELTA *& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* REPORT zsap_sci_delta. TYPES: lt_t_result_hd TYPE STANDARD TABLE OF scirest_hd, lt_t_result_ps TYPE STANDARD TABLE OF scirest_ps. SELECTION-SCREEN BEGIN OF BLOCK pre WITH FRAME TITLE box_pre. PARAMETERS: insp_pre TYPE sci_insp, vers_pre TYPE sci_vers, user_pre TYPE sci_user. SELECTION-SCREEN END OF BLOCK pre. SELECTION-SCREEN BEGIN OF BLOCK pst WITH FRAME TITLE box_pst. PARAMETERS: insp_pst TYPE sci_insp, vers_pst TYPE sci_vers, user_pst TYPE sci_user. SELECTION-SCREEN END OF BLOCK pst. SELECTION-SCREEN BEGIN OF BLOCK new WITH FRAME TITLE box_new. PARAMETERS: vers_new TYPE sci_vers. SELECTION-SCREEN END OF BLOCK new. INITIALIZATION. box_pre = 'Inspection before upgrade'. box_pst = 'Inspection after upgrade'. box_new = 'New Version'. AT SELECTION-SCREEN ON VALUE-REQUEST FOR insp_pre. PERFORM valuehelp USING 'VERS_PRE' 'USER_PRE' CHANGING insp_pre. AT SELECTION-SCREEN ON VALUE-REQUEST FOR insp_pst. PERFORM valuehelp USING 'VERS_PST' 'USER_PST' CHANGING insp_pst. START-OF-SELECTION. DATA: l_t_result_hd TYPE STANDARD TABLE OF scirest_hd, l_t_result_ps TYPE STANDARD TABLE OF scirest_ps. DATA: l_s_insp_pre TYPE sciins_inf, l_s_insp_pst TYPE sciins_inf, l_s_insp_new TYPE sciins_inf. PERFORM check_input CHANGING l_s_insp_pre l_s_insp_pst. PERFORM select_data USING l_s_insp_pre l_s_insp_pst CHANGING l_t_result_hd l_t_result_ps. * create new version l_s_insp_new = l_s_insp_pst. CONCATENATE 'Difference:' l_s_insp_pst-text 'minus' l_s_insp_pre-text INTO l_s_insp_new-text SEPARATED BY space. l_s_insp_new-inspecvers = vers_new. l_s_insp_new-execdate = sy-datum. DATA: l_s_result_hd TYPE scirest_hd. l_s_result_hd-inspecvers = l_s_insp_new-inspecvers. MODIFY l_t_result_hd FROM l_s_result_hd TRANSPORTING inspecvers WHERE inspecvers <> l_s_result_hd-inspecvers. DATA: l_s_result_ps TYPE scirest_ps. l_s_result_ps-inspecvers = l_s_insp_new-inspecvers. MODIFY l_t_result_ps FROM l_s_result_ps TRANSPORTING inspecvers WHERE inspecvers <> l_s_result_hd-inspecvers. PERFORM save_data USING l_s_insp_new l_t_result_hd l_t_result_ps l_s_insp_pst-inspecvers. MESSAGE s000(r7) WITH 'New version' l_s_insp_new-inspecvers 'created'. *&---------------------------------------------------------------------* *& Form valuehelp *&---------------------------------------------------------------------* FORM valuehelp USING i_dynnm_vers TYPE string i_dynnm_user TYPE string CHANGING c_insp TYPE sci_insp. DATA: l_t_insp TYPE STANDARD TABLE OF sciins_inf, l_t_return TYPE STANDARD TABLE OF ddshretval, l_s_return TYPE ddshretval, l_t_map TYPE STANDARD TABLE OF dselc, l_s_map TYPE dselc, l_repid TYPE sy-repid, l_t_dyn TYPE STANDARD TABLE OF dynpread, l_s_dyn TYPE dynpread. SELECT * FROM sciins_inf INTO TABLE l_t_insp. CHECK l_t_insp IS NOT INITIAL. l_s_map-dyfldname = i_dynnm_vers. l_s_map-fldname = 'INSPECVERS'. APPEND l_s_map TO l_t_map. l_s_map-dyfldname = i_dynnm_user. l_s_map-fldname = 'CIUSER'. APPEND l_s_map TO l_t_map. CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST' EXPORTING ddic_structure = 'SCIINS_INF' retfield = 'INSPECNAME' value_org = 'S' TABLES value_tab = l_t_insp * FIELD_TAB = return_tab = l_t_return dynpfld_mapping = l_t_map EXCEPTIONS parameter_error = 1 no_values_found = 2 OTHERS = 3. IF sy-subrc <> 0. RETURN. ENDIF. LOOP AT l_t_return INTO l_s_return. CLEAR l_s_dyn. IF l_s_return-fieldname = 'INSPECNAME'. c_insp = l_s_return-fieldval. ELSE. l_s_dyn-fieldname = l_s_return-retfield. l_s_dyn-fieldvalue = l_s_return-fieldval. APPEND l_s_dyn TO l_t_dyn. ENDIF. ENDLOOP. l_repid = sy-repid. CALL FUNCTION 'DYNP_VALUES_UPDATE' EXPORTING dyname = l_repid dynumb = '1000' TABLES dynpfields = l_t_dyn. ENDFORM. "valuehelp *&---------------------------------------------------------------------* *& Form CHECK_INPUT *&---------------------------------------------------------------------* FORM check_input CHANGING e_s_insp_pre TYPE sciins_inf e_s_insp_pst TYPE sciins_inf. DATA: l_s_insp TYPE sciins_inf, l_subrc TYPE sy-subrc. PERFORM select_inf USING insp_pre vers_pre user_pre CHANGING e_s_insp_pre l_subrc. IF l_subrc <> 0. MESSAGE e000(r7) WITH 'Inspection' e_s_insp_pre-text 'not available'. ENDIF. PERFORM select_inf USING insp_pst vers_pst user_pst CHANGING e_s_insp_pst l_subrc. IF l_subrc <> 0. MESSAGE e000(r7) WITH 'Inspection' e_s_insp_pst-text 'not available'. ENDIF. IF vers_new IS INITIAL. MESSAGE e000(r7) WITH 'New version is initial'. ENDIF. PERFORM select_inf USING insp_pre vers_new user_pre CHANGING l_s_insp l_subrc. IF l_subrc = 0. MESSAGE e000(r7) WITH 'Inspection' l_s_insp-text 'already exists'. ENDIF. ENDFORM. " CHECK_INPUT *&---------------------------------------------------------------------* *& Form select_inf *&---------------------------------------------------------------------* FORM select_inf USING i_insp TYPE sci_insp i_vers TYPE sci_vers i_user TYPE sci_user CHANGING e_s_insp TYPE sciins_inf e_subrc TYPE sy-subrc. CLEAR: e_subrc, e_s_insp. SELECT SINGLE * FROM sciins_inf INTO e_s_insp WHERE inspecvers = i_vers AND ciuser = i_user AND inspecname = i_insp. e_subrc = sy-subrc. e_s_insp-text = i_insp && '/' && i_vers && '/' && i_user. ENDFORM. "select_inf *&---------------------------------------------------------------------* *& Form select_data *&---------------------------------------------------------------------* FORM select_data USING i_s_insp_pre TYPE sciins_inf i_s_insp_pst TYPE sciins_inf CHANGING e_t_result_hd TYPE lt_t_result_hd e_t_result_ps TYPE lt_t_result_ps. DATA: l_t_result_ps_tmp TYPE lt_t_result_ps. SELECT * FROM scirest_ps AS ps INTO TABLE l_t_result_ps_tmp WHERE inspecid = i_s_insp_pst-inspecid AND inspecvers = i_s_insp_pst-inspecvers AND ciuser = i_s_insp_pst-ciuser AND conseccnt = 1 AND NOT EXISTS ( SELECT * FROM scirest_ps WHERE inspecid = i_s_insp_pre-inspecid AND inspecvers = i_s_insp_pre-inspecvers AND ciuser = i_s_insp_pre-ciuser AND objtype = ps~objtype AND objname = ps~objname AND test = ps~test AND sobjtype = ps~sobjtype AND sobjname = ps~sobjname AND code = ps~code AND conseccnt = 1 ). CHECK l_t_result_ps_tmp IS NOT INITIAL. SELECT * FROM scirest_ps INTO TABLE e_t_result_ps FOR ALL ENTRIES IN l_t_result_ps_tmp WHERE inspecid = l_t_result_ps_tmp-inspecid AND inspecvers = l_t_result_ps_tmp-inspecvers AND ciuser = l_t_result_ps_tmp-ciuser AND objtype = l_t_result_ps_tmp-objtype AND objname = l_t_result_ps_tmp-objname AND errcnt = l_t_result_ps_tmp-errcnt. SELECT * FROM scirest_hd INTO TABLE e_t_result_hd FOR ALL ENTRIES IN e_t_result_ps WHERE inspecid = e_t_result_ps-inspecid AND inspecvers = e_t_result_ps-inspecvers AND ciuser = e_t_result_ps-ciuser AND objtype = e_t_result_ps-objtype AND objname = e_t_result_ps-objname. ENDFORM. " SELECT_DATA *&---------------------------------------------------------------------* *& Form SAVE_DATA *&---------------------------------------------------------------------* FORM save_data USING i_s_insp TYPE sciins_inf i_t_result_hd TYPE lt_t_result_hd i_t_result_ps TYPE lt_t_result_ps i_vers_pst TYPE sci_vers. DATA: l_key_new TYPE sci_inkey, l_key_old TYPE sci_inkey. INSERT sciins_inf FROM i_s_insp. INSERT scirest_hd FROM TABLE i_t_result_hd. INSERT scirest_ps FROM TABLE i_t_result_ps. CONCATENATE i_s_insp-inspecid '_' i_s_insp-inspecvers '_' i_s_insp-ciuser INTO l_key_new. CONCATENATE i_s_insp-inspecid '_' i_vers_pst '_' i_s_insp-ciuser INTO l_key_old. DATA: l_chkvinf TYPE scichkv_hd, l_text TYPE sci_text, l_variant TYPE sci_tstvar. IMPORT chkvinf = l_chkvinf text = l_text variant = l_variant FROM DATABASE sciins_var(ar) ID l_key_old. EXPORT chkvinf = l_chkvinf text = l_text variant = l_variant TO DATABASE sciins_var(ar) ID l_key_new. DATA: l_iclass TYPE scisclass, l_iddics TYPE scisddics, l_iextrct TYPE scisextrct, l_ifugrs TYPE scisfugrs, l_ikorr TYPE sciskorr, l_irepos TYPE scisrepos, l_irest TYPE scisrest, l_itadir TYPE scistadir, l_itypps TYPE scistypps, l_ianyos TYPE scisanyos, l_objectname TYPE sobj_name, l_objectsinf TYPE sciobj_inf, l_objectstype TYPE trobjtype, l_iwdyns TYPE sciswdyns. IMPORT iclass = l_iclass iddics = l_iddics iextrct = l_iextrct ifugrs = l_ifugrs irepos = l_irepos ikorr = l_ikorr irest = l_irest itadir = l_itadir itypps = l_itypps ianyos = l_ianyos objectname = l_objectname objectsinf = l_objectsinf objectstype = l_objectstype iwdyns = l_iwdyns FROM DATABASE sciins_obj(ar) ID l_key_old. EXPORT iclass = l_iclass iddics = l_iddics iextrct = l_iextrct ifugrs = l_ifugrs irepos = l_irepos ikorr = l_ikorr irest = l_irest itadir = l_itadir itypps = l_itypps ianyos = l_ianyos objectname = l_objectname objectsinf = l_objectsinf objectstype = l_objectstype iwdyns = l_iwdyns TO DATABASE sciins_obj(ar) ID l_key_new. ENDFORM. " SAVE_DATA