‎2007 Sep 23 2:20 PM
Hi all,
As I was asking in my previous thread about input validation,I would like to put my words here:
Employer id duplication:once the user presses enter in this field,if id already exists error message should be displayed.For this task,can I code like this:
PROCESS BEFORE OUTPUT.
Module init_screen_100.
PROCESS AFTER INPUT.
Field er_id MODULE M1.
MODULE EXECUTION.
In ABAP program:
Module init screen_screen_100 OUTPUT.
clear : er_id,er_name.
endmodule.
Module m1 INPUT.
select * from zemployer where er_id = er_id.
if sy-dbcnt <> 0.
message 001.
leave program.
endif.
endmodule.
My questions:
1)Why do we need 'module init screen'?
2)What module execution do?
3)Does message 001 execute and the program terimates?
4)What does chain..endchain do?
Thanks a lot in advance.You guys are helping others a lot.Keep it up.
‎2007 Sep 23 2:37 PM
<b>1)Why do we need 'module init screen'?</b>
Not 100% needed in test program - in real program would set gui status, title bar, load defaults, check authorisation and do 1000 other things you want to happen before screen displays
<b>2)What module execution do?</b>
Module M1 only runs if field er_id changed - module execution runs every time after screen - use it to evaluate user command (eg button pressed), save data, any other after display actions.
<b>3)Does message 001 execute and the program terimates?</b>
You should not leave program after the error - leave screen will re-display screen with message for user to fix. Can get lots more complicated here with message passed back to PBO module for display in some circumstances
<b>4)What does chain..endchain do?</b>
groups a set of fields so that module executes if any field changes.
Andrew
‎2007 Sep 23 2:37 PM
<b>1)Why do we need 'module init screen'?</b>
Not 100% needed in test program - in real program would set gui status, title bar, load defaults, check authorisation and do 1000 other things you want to happen before screen displays
<b>2)What module execution do?</b>
Module M1 only runs if field er_id changed - module execution runs every time after screen - use it to evaluate user command (eg button pressed), save data, any other after display actions.
<b>3)Does message 001 execute and the program terimates?</b>
You should not leave program after the error - leave screen will re-display screen with message for user to fix. Can get lots more complicated here with message passed back to PBO module for display in some circumstances
<b>4)What does chain..endchain do?</b>
groups a set of fields so that module executes if any field changes.
Andrew
‎2007 Sep 24 2:55 AM
To add a little bit to Andrew's fine response:
Q1) In that 1000 other things mentioned, you will often find logic to lock / hide screen fields prior to the dynpro being displayed to the user.
Q2) You would probably not normally have user_command checked inside a module that is only triggered for a change of value.
Q3) "message 000" is syntactically wrong - you'll need "E" or "S" or "I" (or A!) in front of it to tell SAP how to issue the message... typically "E" for a validation where you want the user to proceed no further. You might find it clearer for future programs to include the message class in the code too, as well as a comment that explains what the error text is... plus put the cursor on the error field e.g.
if not sy-subrc is initial.
set cursor field 'ER_ID'.
message e000(zz). "no records matched criteria.
endif.Q4) The "chain .. endchain" also allows you to have several fields that remain open for input when an "E" message is issued.
For more learning, spend some time looking through the examples in the ABAPDOCU transaction.
Jonathan