Creation of Maintenance View Cluster – 2
Hi all, Welcome to the second blog in this two part series on maintenance view clusters. In the previous post we created the database tables and the maintenance views on the database tables. Now let us generate the table maintenence for these views. We need a function group which will be the placeholder for the maintenance dialogs. Go se80 screen and choose function group; type in zfngrp and say create the function group. Activate the function group once it is created.
Now select the se54 transaction, type in the first view’s name, v_tab1 and click on the second radio button “Generated Objects”; click on create/change button.
Provide the Authorization group as “&NC&” which is without authorisation group. Provide the function group which we just created. In the maintenance screens choose single screen and provide a maintenance screen number. Provide the Compare flag as “Automatically Adjustable”.
Click on the create button to create the screen. Now let us do some event handling for this view.
We can handle all these events for the view.
Some of the events that I have handled for this view are 1> Set Deletion Indicator – When the user saves the entries done in the first view, we check if any entry is marked for delete and set the deletion indicator for that entry and let it remain in the database. The code written for this is
FORM set_del_ind. DATA:ls_total TYPE ztab1, lv_index LIKE sy-index. LOOP AT total. lv_index = sy-tabix. IF <action> = geloescht. READ TABLE extract WITH KEY <vim_xtotal_key>. ls_total = total. ls_total-del_ind = 'X'. total = ls_total. <action> = aendern. MODIFY total FROM total. extract = total. INSERT extract INDEX lv_index. ENDIF. ENDLOOP. sy-subrc = 0. ENDFORM.
The second event that I have handled for this view is 2> Set Common Id – When the user enters the indicators and the text for that indicator, we generate an ID for this entry. The code for this is
FORM set_common_id. DATA:lv_common_id TYPE z_common_id, lv_count TYPE integer, lv_str2 TYPE z_common_id, lv_max TYPE integer. FIELD-SYMBOLS:<lv_id> TYPE z_common_id, <ls_str> TYPE any. ASSIGN COMPONENT 'COMMON_ID' OF STRUCTURE <table1> TO <lv_id>. lv_count = lines( total ). READ TABLE total ASSIGNING <ls_str> INDEX lv_count. IF <ls_str> IS ASSIGNED. lv_str2 = <ls_str>+3(3). CONDENSE lv_str2 NO-GAPS. lv_count = lv_str2. lv_common_id = lv_count + 1. CONDENSE lv_common_id NO-GAPS. <lv_id> = lv_common_id. ELSE. IF lv_count EQ 0. lv_common_id = 1. CONDENSE lv_common_id NO-GAPS. <lv_id> = lv_common_id. ENDIF. ENDIF. ENDFORM.
The thid event that I have handled for this view is hiding the deleted entries from appearing in the view. 3> Hide Deleted Entries – here all the entries are parsed and checked for deletion indicator being set. If the indicator is set it is not displayed on the screen. The code for this is.
FORM hide_deleted. PERFORM vim_fill_wheretab. *.read data from database.............................................* REFRESH total. CLEAR total. SELECT * FROM ztab1 WHERE (vim_wheretab) AND del_ind <> 'X' . CLEAR v_tab1 . v_tab1-mandt = ztab1-mandt . v_tab1-common_id = ztab1-common_id . v_tab1-c_ind = ztab1-c_ind . v_tab1-cpp_ind = ztab1-cpp_ind . v_tab1-java_ind = ztab1-java_ind . v_tab1-abap_ind = ztab1-abap_ind . v_tab1-description = ztab1-description . v_tab1-del_ind = ztab1-del_ind . <vim_total_struc> = v_tab1. APPEND total. ENDSELECT. SORT total BY <vim_xtotal_key>. <status>-alr_sorted = 'R'. *.check dynamic selectoptions (not in DDIC)...........................* IF x_header-selection NE space. PERFORM check_dynamic_select_options. ELSEIF x_header-delmdtflag NE space. PERFORM build_mainkey_tab. ENDIF. REFRESH extract. ENDFORM.
Once these events are created, let us see how to set the description field as a mandatory input field. This is done through screen programming. Click on the screen number and we will see some PAI and PBO logic. In that screen choose the layout button and go to the screen painter wizard. We choose the description field and mark its input field as “recommended”. This will mark is at mandatory and user has to mention an entry for it.
Now the first maintenance view is generated. We can test it by clicking on the test button.
Click on maintain in this screen
We can add and delete some entries and see it reflected in the DB.
Now let us create the second table maintenance in the same way that we created for the first table
Let us create the view cluster. In the se54 screen, choose “Edit View Cluster” button and give a name for view cluster “vc_tab12”
Click on Create/Change; provide a short text and click on the Object Structure in the left window pane.
In the Object Structure provide the two maintenance views and set the predcessor, Dependency and position for the views
Lead select the first entry and provide field dependence. Lead select the second entry and provide the foreign key as the field dependence.
Now choose the header entry in the left window pane and click on activate the view cluster. The view cluster is ready to use. Here is a short video on the usage of this view cluster.
We can see that the language entries are maintained correctly based on the LAISO entries.
Hope this blog post has halped you. Special thanks to Amey and Vinod for the support in helping me learn this concept for the project I was working on. Thanks you guys. Thank you for reading.