06-01-2013 4:21 PM
Hi all,
How to add some validation logic into maintenance view when user inputs some data in table control then press enter or click save ?
I need to throw up an error message when data in one column duplicates, but I do not know where to add custom code into the auto-generated code by table maintenance generator.
I tried the event 01 and 05, in them I throw a message , however I do not see it, am I use it in the incorrect way?
Thank you very much.
Best regards,
Xu Chris
06-01-2013 4:27 PM
Hi
In the screen layout - flow logic tab,
You will see a auto generated code as
LOOP at <your internal table>
CHAIN
......
FIELD ........
FIELD .............
.....
ENDCHAIN
ENDLOOP
at end of the FIELD statement -- Add a statement as MODULE <your_validation_function_name>.
Example:
In the main program
MODULE <your_validation_function_name>
****wRITE HERE YOUR LOGIC TO VALIDATE
ENDMODULE
Regards,
Venkat
06-01-2013 4:29 PM
01 should work for while pressing save...
try putting a break point and see whether the form triggers .... when you press save.
06-01-2013 4:51 PM
Hi
In PAI of the screen .use the field in CHAIN and ENDCHAIN and add module to that field .
PAI
CHAIN
FIELD <filed1> module <module name >.
ENDCHAIN
Add module code . So when press enter or save code inmodule will trigger automatially
Thanks
06-01-2013 10:52 PM
Hi Chris,
I have implemented a similar kind of requirement by using the event 01 only.
Create a form routine for the event 01 and inside it write your logic and display an error message.
MESSAGE 'Duplicate Data' TYPE 'E'.
Regards,
Sanjeev Kotwal.
06-02-2013 4:22 PM
Hi,
Go to the Functional Pool where in you have saved the Table maintenance generator.
Search for the screen number of your corresponding view.
In the PAI event, inside the CHAIN END CHAIN event create a MODULE with ON CHAIN event and write the validations there.
Hope this helps
06-02-2013 7:00 PM
Hi Chris,
I have tried some validation in event 05 (New entry) and it is working fine too. Here is some sample code I have tried.
*----------------------------------------------------------------------*
***INCLUDE LZTEST1F01 .
*----------------------------------------------------------------------*
FORM NEW_ENTRY.
DATA : LT_TAB TYPE STANDARD TABLE OF YTEST_EMP,
LS_TAB TYPE YTEST_EMP.
SELECT * FROM YTEST_EMP INTO TABLE LT_TAB.
IF SY-SUBRC EQ 0.
LOOP AT LT_TAB INTO LS_TAB.
IF LS_TAB-EMPNAME EQ 'VIJAY'.
MESSAGE E000(ZMESSAGES) WITH 'RECORD ALREADY FOUND'.
ENDIF.
ENDLOOP.
ENDIF.
ENDFORM.
After all activating your Include activate your function group too.
Hope this helps.
06-03-2013 4:33 AM
HI Vijay ,
in your code where you are checking the duplicate entries ? , am i missing anything?
Hi Chris ,
i think events 01,05 should work in you case ,i think something wrong with the codee , so better to paste ur code here to check...
Prabhu
06-03-2013 7:00 AM
Hi Prabhu,
I have not checked for duplicate entries, I just tested whether the validation is possible or not and throwing an error message at event 5 or 1. And if the duplicates is the case, in my code after "SELECT" statement read the Itab with the current entered key like,
SELECT * FROM YTEST_EMP INTO TABLE LT_TAB. "Here we get entries maintained so far.
READ TABLE LT_TAB WITH KEY <field_to_compare> = <key>.
IF SY-SUBRC NE 0.
MESSAGE E.
ENDIF.
Note :: YTEST_EMP is the table on which we are maintaining view.
As you said, event 01 and 05 should workout actually.
--Vijay
06-03-2013 7:39 AM
Hi Vijay , in those events internal tables TOTAL & EXTRACT will hold the latest data.so any validations on the data then you need to consider these table only bcos data havent saved.
HI Chris ,
do u wanna put validations on non-key fields ?
regards
Prabhu
06-03-2013 8:09 AM
Hi Prabhu,
I think Mr.Chris wants to validate the current entry with all the data available in the table not only with the latest data that hold in TOTAL or EXTRACT tables. If we use the SELECT statement as I mentioned above we can get the data including data saved in the current session too.
Hi Chris,
As Mr.Prabhu mentioned, better to paste your code here.
--Vijay
06-03-2013 8:40 AM
Hi Vijay ,
no need of any addditional selections , internal table TOTAL & EXTRACT will hold the required data i.e old and new. if you have any doubts then check in your table events code.
Prabhu
06-03-2013 2:58 PM
Hi Prabhu,
Sorry, I didn't get this first. And even I don't know this. Thanks for the info.
-- Vijay