Cover V09, I07
Article
Figure 1
Listing 1

jul2000.tar


Listing 1: Trigger procedure for write of pick-file

TRIGGER PROCEDURE FOR WRITE OF pick-file. 

/*******************************************************************/
/*                                                                 */
/* Work Unit:  wu439                                               */
/*                                                                 */
/* Module Name: write-trig.p                                       */
/*                                                                 */
/* Developed By:  Doug Rusk                                        */
/*                                                                 */
/* Originating Date:  03.03.2000                                   */
/*                                                                 */
/* Originating Description:                                        */
/* Source Code for Sales Order Barcodes:                           */
/*                                                                 */
/* Inputs:                                                         */
/*                                                                 */
/* Outputs:                                                        */
/*                                                                 */
/*******************************************************************/
/***************************** CHARACTER  **************************/
/*****************************  INTEGER   **************************/
DEF VAR line-var AS INT NO-UNDO.

/*****************************  DECIMAL   **************************/
/*****************************  LOGICAL   **************************/
/*****************************   DATE     **************************/
/***************************** TEMP TABLE **************************/
/*****************************   BUFFER   **************************/
/*****************************   STREAM   **************************/
/*******************************************************************/
/*** Forms ***/

/*** Processing ***/ 

IF program-name(2) MATCHES "Pick/SETPICK*" THEN DO:

   FIND FIRST ordh-file EXCLUSIVE-LOCK WHERE
      ordh-file.ordref = pick-file.ordref 
   NO-ERROR.

   IF NOT AVAILABLE ordh-file THEN DO:

      MESSAGE "NO SUCH ORDER: " pick-file.ordref " SEE MANAGER"
      RETURN.
   END. /* IF NOT AVAILABLE ordh-file */

   /* IF THE PICK WAS CANCELLED THIS CODE WILL "REFRESH"        */
   /* THE PICK COMMENT                                          */
   /* WITH THE NEW PICK NUMBER DLR 03.08.2000                   */

   FIND FIRST remark-file EXCLUSIVE-LOCK WHERE
      remark-file.remnum = pick-file.ordref AND
      remark-file.data  MATCHES "*PICK NUMBER*"
   NO-ERROR.

   IF AVAILABLE remark-file THEN DO:
      remark-file.data   = "PICK NUMBER:  \~" + pick-file.picknum .
      RETURN. /* OTHER COMMENTS ALREAD EXIST */
   END. /* IF AVAILABLE remark-file */

   /* DETERMINE IF OTHER REMARKS ALREADY EXIST FOR THIS ORDER,  */
   /* IF THEY DO THEN POSITION THESE COMMENTS AFTER THEM.       */

   FIND LAST remark-file NO-LOCK WHERE
      remark-file.remnum = pick-file.ordref
   NO-ERROR.

   IF AVAILABLE remark-file THEN
      line-var = remark-file.linenum + 1.

   ELSE line-var = 1.

   DO i = 1 TO 3:
      CREATE remark-file.
      ASSIGN
         ordh-file.rem = (IF i = 1 THEN "Y" ELSE ORDH-FILE.REM)
         remark-file.date-stamp = TODAY
         remark-file.time-stamp = TIME  
         remark-file.linenum    = line-var 
         remark-file.type   = "RE" /* EXTERNAL COMMENT */
         remark-file.remnum = pick-file.ordref
         
         remark-file.data = /* THIS IS THE TEXT OF THE COMMENT */ 
            (     IF i = 1 THEN "PICK NUMBER:\~" + pick-file.picknum  
             ELSE IF i = 2 THEN " ORDER NUMBER:\~" + pick-file.ordref 
             ELSE               "CUST  NUMBER: \~" + 
                (IF ordh-file.userchr3 = "" THEN pick-file.code ELSE
                   /* CUST SPECIFIC FIELD CODE DESIGNATION */
                   SUBSTRING(ordh-file.userchr3,1,
                             INDEX(ordh-file.userchr3,"\~") - 1))) 
         line-var = line-var + 1.       
   END. /* DO i = 1 TO 3 */ 
END. /* IF program-name.... */
ELSE RETURN. /* NOT CORRECT CALLING PROGRAM */

/****************************** End of Program *****************/