‎2009 Jul 27 4:15 AM
Hi,
I have a maintenance view that allow user to insert / update.
Let's say, z_my_table is my table
key1
key2
field1
field2
field3
I want to validate whether field1, field2, field3 whether exist in my table before insert / update.
However, due to some restriction, I cannot make it as part of the key.
My question is, how can I capture OR validate it before the data get inserted into the table ?
I checked some online help, and found that suggestion is to write a function module OR enhancement point.
Just wonder what is the common practice and how should I do it ? Thanks.
‎2009 Jul 27 4:41 AM
I don't agree with the design but if you want to do it anyway it can be done using Events in the Maintenance View.
After you've generated the Maintenance View of your Z table, within SE11 pull out menubar Utilities->Table Maintenance Generator, then menubar Environment->Modifcation->Events. Create New Entries and I think for your requirement you would need 2 entries - one at event 05 and another at event 18. Input the name of your routine and write the code by clicking its corresponding button.
The following is an example of a scenario where text of an object is retrieved and filled into the view display-only column according to user input of its related object id - for your requirement you would validate the user input after checking the input values in your existing table:
form fill_text_05.
data begin of w_total.
include structure zfv_fbt_acct_rel.
data: action,
mark,
end of w_total.
data: w_extract type zfv_fbt_acct_rel.
clear: zfv_fbt_acct_rel-fbt_rel_acc_txt,
zfv_fbt_acct_rel-fbt_cost_grp_txt.
* populate GL a/c text
select txt50 up to 1 rows
from skat
into zfv_fbt_acct_rel-fbt_rel_acc_txt
where spras = sy-langu
and saknr = zfv_fbt_acct_rel-fbt_rel_acc.
endselect.
* populate Cost Group text
select single fbt_cost_grp_txt
from zft_fbt_cost_grp
into zfv_fbt_acct_rel-fbt_cost_grp_txt
where company_code = zfv_fbt_acct_rel-company_code
and fbt_cost_grp = zfv_fbt_acct_rel-fbt_cost_grp.
if sy-subrc <> 0.
message e074(zf_enhancements) with zfv_fbt_acct_rel-company_code.
endif.
endform. "fill_text_05
Hope this helps.
Cheers,
Sougata.
‎2009 Jul 27 5:12 AM
Thanks ... I will try it out and let you know.
My initial thought is, if i do it in enhancement point, my code will be gone once I generated the objects.
‎2009 Jul 27 7:23 AM
I got an information like :
Do Not Make Any Changes ( SAP data )
I press Ok and presented a screen like ALV with 3 columns.
FORM routines to be called from view maintenance
T , FORM routine, Editor.
When I press the drop down for T, I saw what you mean by 05. It is an event for - Creating New Entry.
I pressed the Editor and presented a list of options for INCLUDE to create the SUBROUTINE.
Do I need that ?