-4
define var num as integer label "S.No".                                                      
define var name as char label "NAME ".                                                        
define var dob as date label "DOB" format "99/99/9999". 
define var mobnum as int label "Mobile No:" format "9999999999" .

assign num = 1.                                                                   

repeat num = 1 to 3: 

  display num with frame a.

  update dob with frame a.                                                                                                                                          

  if dob >= today then do:    
                                                 
    display " enter correctly".
                                                    
    update dob with frame a.                                                                    

  end.                                                                             
  else if dob < today then do:                                                   

    update name with frame a.                                                                  

  end.
   
  update name with frame a.
  update mobnum with frame a.

  if mobnum >= 1000000000 and mobnum < 10000000000 then 
    do:

      display mobnum with frame a.

      display num column-label "S.NO" with frame b.                                                                  

      display name  column-label "NAME"                                                                        
        dob column-label "DOB" 
        mobnum column-label "mobile number"
       with frame b down.

      down with frame b.                                                              

    end.
   else
    do:

      display "enter exactly 10 digits please".

      update mobnum with frame a.

    end.

end.  

In this Code I want to validate dob to > Todays date and mobilenum not less than 9 digits and i want to display the output and in step by step process it moves to S.no, Dob,Name ,Mobile num.. But in my code when i enter mobile num it doesn't display anything in frame b. and i want to add 3 records.. but it doen't allow me to update..

please help to solve this issue

General Grievance
  • 4,555
  • 31
  • 31
  • 45
  • This is a partial duplicate of https://stackoverflow.com/questions/73477553/how-do-i-validate-phone-number-in-openedge-progress-4gl-programming , which has a few answers already. – nwahmaet Aug 24 '22 at 21:56

2 Answers2

0

Date-based validation (comparison) is reasonably simple in ABL: use the =, >, < , <>, >=, <= operators.

define var dob as date label "DOB" format "99/99/9999". 

IF dob <= TODAY THEN
    MESSAGE "Date is not in the future".

nwahmaet
  • 3,589
  • 3
  • 28
  • 35
0

You can verify dob conditions using the following expression:

DEF VAR dob AS DATE NO-UNDO FORMAT "99/99/9999".

ASSIGN dob = TODAY. 

/*   
ASSIGN dob = TODAY.   
ASSIGN dob = TODAY + 30. - always days   
ASSIGN dob = TODAY - 30. - always days   
*/

IF dob = TODAY THEN
    MESSAGE "dob is today.". 
ELSE IF dob < TODAY THEN
    MESSAGE "dob is smaller than today.". 
ELSE IF dob > TODAY THEN
    MESSAGE "dob is in the future.". 
ELSE 
    MESSAGE "dob is not assigned.".

And for the MobileNum:

You can use LENGTH(mobnum) to get the quantity of digits into the number... like:
This make possible to create separate message for each of the lengths of mobnum.

DEF VAR mobnum AS INT NO-UNDO FORMAT "9999999999" INITIAL "99999999".
DEF VAR ii     AS INT NO-UNDO.

ii = LENGTH(mobnum).

CASE ii:
//You can create a when for each of the sizes
    WHEN 9 THEN DO:
        DISPLAY "Number OK".
    END.
    OTHERWISE DO:
        DISPLAY "Number is not 9-digit long".
    END.
END CASE.

But if you want to make it simple, just use:

DEF VAR mobnum AS INT NO-UNDO FORMAT "9999999999" INITIAL "99999999".
DEF VAR ii     AS INT NO-UNDO.

ii = LENGTH(mobnum).

IF ii = 9 THEN DO:
    DISPLAY "Number correct".
END. ELSE DO:
    DISPLAY "Number incorrect".
END.
Raphael Frei
  • 361
  • 1
  • 10