1

In this program if you select item code it will display 3 fields and asks for update if you update it will update the records. Up to this program was fine.

I added one condition if user press Ctrl+D it asks for delete question yes or no, it it is yes what you updated that fields should be blank otherwise do nothing it tried something but I am not able to do so.

/*Sample Item master Maintenance Program*/                                      
/* DISPLAY TITLE */   
{us/mf/mfdtitle.i "3+ "}
def var l_qad like pt__qad13.
def var l_draw like pt_draw.
def var l_group like pt_group.
def var ans as logical no-undo. 
form
    pt_part colon 25
    with frame a side-labels width 80.
/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

form
   "Enter the Value of" l_qad colon 30 skip(1)
   "Enter the Value of" l_draw   colon 30 skip(1)
   "Enter the Value of" l_group  colon 30 skip(1)
    with frame b side-labels width 80.
setFrameLabels(frame b:handle).
view frame a.                                                                   
repeat with frame a:                                                            
      prompt-for pt_part                                                           
       editing:                                                                  
      /* FIND NEXT/PREVIOUS RECORD */                                     
        {us/mf/mfnp.i pt_mstr pt_part "pt_mstr.pt_domain = global_domain and pt_part" pt_part pt_part pt_part }                            
        if recno <> ? then                                                        
             do:                                                                   
              display pt_part.  
          end.
        end.
        for first pt_mstr exclusive-lock where pt_domain = global_domain and pt_part = input pt_part:
        assign l_qad= pt__qad13
              l_draw= pt_draw
            l_group= pt_group.
        disp l_qad l_draw l_group with frame b.
        update l_qad l_draw l_group with frame b.
            assign pt__qad13 = input l_qad
                   pt_draw = input l_draw
                   pt_group = input l_group.

        end.
        hide frame b.
        on CTRL-D ANYWHERE
        do:
        message "Please confirm delete" view-as alert-box question buttons yes-no update ans as logical.
        if ans= true then 
            message "yes".
            assign pt__qad13 = ""
                   pt_draw = ""
                   pt_group = "".

        else
            message "no".
        end.    
end.
Fabrizio
  • 7,603
  • 6
  • 44
  • 104
Lovely Bobby
  • 43
  • 1
  • 6

1 Answers1

1

Your trigger need to be placed earlier in your code.

Look at this basic example, you can try to comment/uncomment the two triggers to see what happens:

DEFINE VARIABLE cUpdate AS CHARACTER   NO-UNDO.

/* Placing the trigger here works! */
ON 'ctrl-d':U ANYWHERE DO:
    MESSAGE "You rang sir?" VIEW-AS ALERT-BOX INFORMATION TITLE "Early trigger".
    RETURN.
END.


UPDATE cUpdate.

/* Placing the trigger here wont work! */
/*
ON 'ctrl-d':U ANYWHERE DO:
    MESSAGE "You rang sir?" VIEW-AS ALERT-BOX INFORMATION TITLE "Late trigger".    
    RETURN.
END.
*/

Progress only passes the code once when compiling. Thus it will never know about anything "ahead" of where you are now (with FUNCTIONS declared FORWARD being an exception).

Jensd
  • 7,886
  • 2
  • 28
  • 37