<?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: Unable to perform validation properly in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/unable-to-perform-validation-properly/m-p/5376907#M1236803</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use:-&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
PROCESS AFTER INPUT.
*  MODULE user_coomand_8001.

  LOOP WITH CONTROL tab_ctrl.
    MODULE modify_data.
  ENDLOOP.

  MODULE validate_data.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In PAI,&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
MODULE modify_data.
  MODIFY it_mara FROM wa_mara INDEX tab_ctrl-current_line.
  "modify the contents into internal table from table control
ENDMODULE.

MODULE validate_data.
  CASE sy-ucomm.
    WHEN 'CHECK'.
      REFRESH it_temp.
      REFRESH it_temp1.
      CLEAR it_temp.
      CLEAR it_temp1.
     "take another internal table it_temp and same as it_mara
      it_temp = it_mara.
      READ TABLE it_temp INTO wa_temp WITH KEY zzselect = 'X'.

      IF sy-subrc ne 0.
        MESSAGE E008. "Select a record

      ELSE.
        IF WA_MARA-MATNR IS INITIAL.
          MESSAGE E006. "enter value using F4 
        ELSE.
          "take another internal table it_temp1 and same as it_mara
          it_temp1 = it_mara.
          DELETE it_temp1 WHERE matnr = wa_temp-matnr.
          IF sy-subrc = 0.
            IF sy-dbcnt &amp;gt; 1.
              MESSAGE E005. " entry repeated 
            ELSEIF sy-dbcnt = 1.
              MESSAGE E009. " proper data
            ENDIF.
          ENDIF.
      ENDIF.
  ENDCASE.
ENDMODULE.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Tarun&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 24 Mar 2009 06:40:18 GMT</pubDate>
    <dc:creator>I355602</dc:creator>
    <dc:date>2009-03-24T06:40:18Z</dc:date>
    <item>
      <title>Unable to perform validation properly</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/unable-to-perform-validation-properly/m-p/5376901#M1236797</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;Please help me out. I am having a scenario in a dialog prog where i have a screen in which a table control is there.1st coloum is a check box (screen name is WA_MARA-ZZSELECT), 2nd coloum is MATNR where a F4 help is used for Input.As the Input is given using F4 help, value of corresponding MATKL should come in coloum 3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For validation one needs to select a record/records by marking the check box and click on a push button- CHECK.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now i need to validate the input as follows:&lt;/P&gt;&lt;P&gt;1) if a user doesnt select any record and clicks on CHECK, he should get a msg saying "Select a record first".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) If a user doesnt give any input and select a record and click CHECK, he should get a msg saying "enter value using F4."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3)If a user enters two same MATNR as input by F4 and then select any one of  the records and click on CHECK he should get a msg- "Entry repeated".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4) If none of the above happens then he should get a msg - "Proper Data".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code i have developed (though not working perfectly) is:  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;For Validation&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  CASE OK_CODE.&lt;/P&gt;&lt;P&gt;      WHEN 'CHECK'.&lt;/P&gt;&lt;P&gt;        IF WA_MARA-ZZSELECT = ' '.&lt;/P&gt;&lt;P&gt;          MESSAGE E008.                       "Select a record first&lt;/P&gt;&lt;P&gt;       ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        IF WA_MARA-ZZSELECT = 'X'.&lt;/P&gt;&lt;P&gt;            IF WA_MARA-MATNR IS INITIAL.&lt;/P&gt;&lt;P&gt;              MESSAGE E006.                   "Enter value using F4                  &lt;/P&gt;&lt;P&gt;            ELSE.&lt;/P&gt;&lt;P&gt;              &lt;/P&gt;&lt;P&gt;            READ TABLE I_MARA INTO WA_MARA WITH KEY WA_MARA-MATNR.&lt;/P&gt;&lt;P&gt;              IF SY-SUBRC = 0.&lt;/P&gt;&lt;P&gt;                MESSAGE E005.                  " Entry repeated        &lt;/P&gt;&lt;P&gt;            ELSE.&lt;/P&gt;&lt;P&gt;                MESSAGE E009.                  " Proper data&lt;/P&gt;&lt;P&gt;              ENDIF.&lt;/P&gt;&lt;P&gt;            ENDIF.&lt;/P&gt;&lt;P&gt;        ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    ENDCASE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please guys help me with the correct logic.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Mar 2009 13:41:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/unable-to-perform-validation-properly/m-p/5376901#M1236797</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-23T13:41:56Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to perform validation properly</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/unable-to-perform-validation-properly/m-p/5376902#M1236798</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try using this way:-&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
MODULE validate_data.
  CASE sy-ucomm.
    WHEN 'CHECK'.
      IF WA_MARA-ZZSELECT = ' '.
        MESSAGE E008. "Select a record
      ENDIF.

      IF WA_MARA-ZZSELECT = 'X'.
        IF WA_MARA-MATNR IS INITIAL.
          MESSAGE E006. "enter value using F4 
        ENDIF.
      ELSE.
        "take another internal table it_temp and same as it_mara
         it_temp = it_mara.
         SORT it_temp BY matnr.
         DELETE ADJACENT DUPLICATES FROM it_temp COMPARING matnr.
         IF sy-subrc = 0.
           MESSAGE E005. " entry repeated 
         ELSE.
           MESSAGE E009. " proper data
         ENDIF.
      ENDIF.
  ENDCASE.
ENDMODULE.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Tarun&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Tarun Gambhir on Mar 24, 2009 10:39 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Mar 2009 05:07:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/unable-to-perform-validation-properly/m-p/5376902#M1236798</guid>
      <dc:creator>I355602</dc:creator>
      <dc:date>2009-03-24T05:07:29Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to perform validation properly</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/unable-to-perform-validation-properly/m-p/5376903#M1236799</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. First Check for the Record is selected or not&lt;/P&gt;&lt;P&gt;2. Checkl for the matnr entered or not by checking for initial values.&lt;/P&gt;&lt;P&gt;3. If value is entered is repeated or not .&lt;/P&gt;&lt;P&gt;4. if every this is ok continue your process.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
Copy the Old data to one internal table in PBO to check for the dulpicate entries

IF WA_MARA-ZZSELECT = 'X'.
  IF WA_MARA-MATNR IS INITIAL.
      MESSAGE E006. "Enter value using F4 
 ELSE.
     READ TABLE I_MARA_OLD INTO WA_MARA1 WITH KEY MATNR = WA_MARA-MATNR.
     IF SY-SUBRC = 0.
        MESSAGE E005. " Entry repeated 
      ELSE.
         APPEND WA_MARA1 TO I_MARA.
         MESSAGE S009. " Proper data
      ENDIF.
 ENDIF.
ELSE.
   MESSAGE E008. "Select a record first
ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Mar 2009 05:07:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/unable-to-perform-validation-properly/m-p/5376903#M1236799</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-24T05:07:57Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to perform validation properly</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/unable-to-perform-validation-properly/m-p/5376904#M1236800</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tarun,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tried implementing your code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem i am facing is whatever selection i make, irrespective of that i get one fixed message - SELECT A RECORD.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried to debug the code..Even if i give two similar inputs and then select one the records and click on CHECK, then also i am having the same message- SELECT A RECORD.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would appreciate your help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Mar 2009 06:24:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/unable-to-perform-validation-properly/m-p/5376904#M1236800</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-24T06:24:30Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to perform validation properly</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/unable-to-perform-validation-properly/m-p/5376905#M1236801</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Avinash,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tried implementing your code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem i am facing is whatever selection i make, irrespective of that i get one fixed message - SELECT A RECORD.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried to debug the code..Even if i give two similar inputs and then select one the records and click on CHECK, then also i am having the same message- SELECT A RECORD.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would appreciate your help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Mar 2009 06:25:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/unable-to-perform-validation-properly/m-p/5376905#M1236801</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-24T06:25:18Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to perform validation properly</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/unable-to-perform-validation-properly/m-p/5376906#M1236802</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check wether you flag for the selected record is getting populated or not.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Mar 2009 06:33:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/unable-to-perform-validation-properly/m-p/5376906#M1236802</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-24T06:33:52Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to perform validation properly</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/unable-to-perform-validation-properly/m-p/5376907#M1236803</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use:-&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
PROCESS AFTER INPUT.
*  MODULE user_coomand_8001.

  LOOP WITH CONTROL tab_ctrl.
    MODULE modify_data.
  ENDLOOP.

  MODULE validate_data.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In PAI,&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
MODULE modify_data.
  MODIFY it_mara FROM wa_mara INDEX tab_ctrl-current_line.
  "modify the contents into internal table from table control
ENDMODULE.

MODULE validate_data.
  CASE sy-ucomm.
    WHEN 'CHECK'.
      REFRESH it_temp.
      REFRESH it_temp1.
      CLEAR it_temp.
      CLEAR it_temp1.
     "take another internal table it_temp and same as it_mara
      it_temp = it_mara.
      READ TABLE it_temp INTO wa_temp WITH KEY zzselect = 'X'.

      IF sy-subrc ne 0.
        MESSAGE E008. "Select a record

      ELSE.
        IF WA_MARA-MATNR IS INITIAL.
          MESSAGE E006. "enter value using F4 
        ELSE.
          "take another internal table it_temp1 and same as it_mara
          it_temp1 = it_mara.
          DELETE it_temp1 WHERE matnr = wa_temp-matnr.
          IF sy-subrc = 0.
            IF sy-dbcnt &amp;gt; 1.
              MESSAGE E005. " entry repeated 
            ELSEIF sy-dbcnt = 1.
              MESSAGE E009. " proper data
            ENDIF.
          ENDIF.
      ENDIF.
  ENDCASE.
ENDMODULE.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Tarun&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Mar 2009 06:40:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/unable-to-perform-validation-properly/m-p/5376907#M1236803</guid>
      <dc:creator>I355602</dc:creator>
      <dc:date>2009-03-24T06:40:18Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to perform validation properly</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/unable-to-perform-validation-properly/m-p/5376908#M1236804</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot gentlemen for your help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tarun-  Little changes in your logic have helped me to solve the problem.&lt;/P&gt;&lt;P&gt;Keep the good work on.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Mar 2009 08:58:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/unable-to-perform-validation-properly/m-p/5376908#M1236804</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-24T08:58:09Z</dc:date>
    </item>
  </channel>
</rss>

