<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Input field validation in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/input-field-validation/m-p/2849144#M667569</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To add a little bit to Andrew's fine response:&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;Q2) You would probably not normally have user_command checked inside a module that is only triggered for a change of value.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;if not sy-subrc is initial.
  set cursor field 'ER_ID'.
  message e000(zz).     "no records matched criteria.
endif.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Q4) The "chain .. endchain" also allows you to have several fields that remain open for input when an "E" message is issued.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For more learning, spend some time looking through the examples in the ABAPDOCU transaction.&lt;/P&gt;&lt;P&gt;Jonathan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 24 Sep 2007 01:55:54 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-09-24T01:55:54Z</dc:date>
    <item>
      <title>Input field validation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/input-field-validation/m-p/2849142#M667567</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As I was asking in my previous thread about input validation,I would like to put my words here:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROCESS BEFORE OUTPUT.&lt;/P&gt;&lt;P&gt;Module init_screen_100.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROCESS AFTER INPUT.&lt;/P&gt;&lt;P&gt;Field er_id MODULE M1.&lt;/P&gt;&lt;P&gt;MODULE EXECUTION.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In ABAP program:&lt;/P&gt;&lt;P&gt;Module init screen_screen_100 OUTPUT.&lt;/P&gt;&lt;P&gt;clear : er_id,er_name.&lt;/P&gt;&lt;P&gt;endmodule.&lt;/P&gt;&lt;P&gt;Module m1 INPUT.&lt;/P&gt;&lt;P&gt;select * from zemployer where er_id  = er_id.&lt;/P&gt;&lt;P&gt;if sy-dbcnt &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;message 001.&lt;/P&gt;&lt;P&gt;leave program.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;endmodule.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My questions:&lt;/P&gt;&lt;P&gt;1)Why do we need 'module init screen'?&lt;/P&gt;&lt;P&gt;2)What module execution do?&lt;/P&gt;&lt;P&gt;3)Does message 001 execute and the program terimates?&lt;/P&gt;&lt;P&gt;4)What does chain..endchain do?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot in advance.You guys are helping others a lot.Keep it up.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 23 Sep 2007 13:20:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/input-field-validation/m-p/2849142#M667567</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-23T13:20:21Z</dc:date>
    </item>
    <item>
      <title>Re: Input field validation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/input-field-validation/m-p/2849143#M667568</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;lt;b&amp;gt;1)Why do we need 'module init screen'?&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;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&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;2)What module execution do?&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;3)Does message 001 execute and the program terimates?&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;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&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;4)What does chain..endchain do?&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;groups a set of fields so that module executes if any field changes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Andrew&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 23 Sep 2007 13:37:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/input-field-validation/m-p/2849143#M667568</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-23T13:37:45Z</dc:date>
    </item>
    <item>
      <title>Re: Input field validation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/input-field-validation/m-p/2849144#M667569</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To add a little bit to Andrew's fine response:&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;Q2) You would probably not normally have user_command checked inside a module that is only triggered for a change of value.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;if not sy-subrc is initial.
  set cursor field 'ER_ID'.
  message e000(zz).     "no records matched criteria.
endif.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Q4) The "chain .. endchain" also allows you to have several fields that remain open for input when an "E" message is issued.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For more learning, spend some time looking through the examples in the ABAPDOCU transaction.&lt;/P&gt;&lt;P&gt;Jonathan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Sep 2007 01:55:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/input-field-validation/m-p/2849144#M667569</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-24T01:55:54Z</dc:date>
    </item>
  </channel>
</rss>

