&ANALYZE-SUSPEND _VERSION-NUMBER AB_v9r12
/* Procedure Description
"Data Logic Procedure Template
 
Use this template to create  a Data Logic Procedure."
*/
&ANALYZE-RESUME
{adecomm/appserv.i}
DEFINE VARIABLE h_Astra                    AS HANDLE          NO-UNDO.
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _XFTR "Check Version Notes Wizard" DataLogicProcedure _INLINE
/* Actions: af/cod/aftemwizcw.w ? ? ? ? */
/* MIP Update Version Notes Wizard
Check object version notes.
af/cod/aftemwizpw.w
*/
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _XFTR "Update-Object-Version" DataLogicProcedure _INLINE
/* Actions: ? ? ? ? af/sup/afverxftrp.p */
/* This has to go above the definitions sections, as that is what it modifies.
   If its not, then the definitions section will have been saved before the
   XFTR code kicks in and changes it */
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _XFTR "Definition Comments Wizard" DataLogicProcedure _INLINE
/* Actions: ? af/cod/aftemwizcw.w ? ? ? */
/* Program Definition Comment Block Wizard
Welcome to the Program Definition Comment Block Wizard. Press Next to proceed.
af/cod/aftemwizpw.w
*/
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS DataLogicProcedure 
/*********************************************************************
* Copyright (C) 2000 by Progress Software Corporation ("PSC"),       *
* 14 Oak Park, Bedford, MA 01730, and other contributors as listed   *
* below.  All Rights Reserved.                                       *
*                                                                    *
* The Initial Developer of the Original Code is PSC.  The Original   *
* Code is Progress IDE code released to open source December 1, 2000.*
*                                                                    *
* The contents of this file are subject to the Possenet Public       *
* License Version 1.0 (the "License"); you may not use this file     *
* except in compliance with the License.  A copy of the License is   *
* available as of the date of this notice at                         *
* http://www.possenet.org/license.html                               *
*                                                                    *
* Software distributed under the License is distributed on an "AS IS"*
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. You*
* should refer to the License for the specific language governing    *
* rights and limitations under the License.                          *
*                                                                    *
* Contributors:                                                      *
*                                                                    *
*********************************************************************/
/*---------------------------------------------------------------------------------
  File: gsmfilogcp.p
 
  Description:  gsm_filter_set Data Logic Procedure Library Template
 
  Purpose:      A procedure library (PLIP) to support the maintenance of the gsm_filter_set table
                The following internal procedures may be added or modified
                to act as validation to creation, modification, or deletion of
                records in the database table
 
                Client-side:
                rowObjectValidate***
 
                Server-side upon create:
                createPreTransValidate***
                createBeginTransValidate
                createEndTransValidate
                createPostTransValidate
 
                Server-side upon write (create and modify):
                writePreTransValidate***
                writeBeginTransValidate
                writeEndTransValidate
                writePostTransValidate
 
                Server-side upon delete:
                deletePreTransValidate
                deleteBeginTransValidate
                deleteEndTransValidate
                deletePostTransValidate
 
                *** The rowObjectValidate, createPreTransValidate and writePreTransValidate
                internal procedures are automatically generated by the SDO generator
 
  Parameters:
 
  History:
  --------
  (v:010000)    Task:   101000047   UserRef:    
                Date:   09/28/2001  Author:     Johan Meyer
 
  Update Notes: Added function isFieldBlank to template of SDO Logic Procedure
 
  (v:010001)    Task:    90000119   UserRef:    posse
                Date:   06/05/2001  Author:     Haavard Danielsen
 
  Update Notes: Point to src/adm2/logic.i
 
---------------------------------------------------------------------------------*/
/*                   This .W file was created with the Progress UIB.             */
/*-------------------------------------------------------------------------------*/
 
/* ***************************  Definitions  ************************** */
/* MIP-GET-OBJECT-VERSION pre-processors
   The following pre-processors are maintained automatically when the object is
   saved. They pull the object and version from Roundtable if possible so that it
   can be displayed in the about window of the container */
 
&scop object-name       gsmfilogcp.p
DEFINE VARIABLE lv_this_object_name AS CHARACTER INITIAL "{&object-name}":U NO-UNDO.
&scop object-version    000000
 
/* object identifying preprocessor */
&glob   AstraPlip    yes
 
DEFINE VARIABLE cObjectName         AS CHARACTER NO-UNDO.
 
ASSIGN cObjectName = "{&object-name}":U.
 
&scop   mip-notify-user-on-plip-close   NO
 
 
/* Data Preprocessor Definitions */
&GLOB DATA-LOGIC-TABLE gsm_filter_set
&GLOB DATA-FIELD-DEFS  "af/obj2/gsmfifullo.i"
 
/* Error handling definitions */
{checkerr.i &define-only = YES}

DEFINE VARIABLE gdCopyFilterSetObj  AS DECIMAL    NO-UNDO.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK 

/* ********************  Preprocessor Definitions  ******************** */

&Scoped-define PROCEDURE-TYPE DataLogicProcedure
&Scoped-define DB-AWARE yes


/* Db-Required definitions. */
&IF DEFINED(DB-REQUIRED) = 0 &THEN
    &GLOBAL-DEFINE DB-REQUIRED TRUE
&ENDIF
&GLOBAL-DEFINE DB-REQUIRED-START   &IF {&DB-REQUIRED} &THEN
&GLOBAL-DEFINE DB-REQUIRED-END     &ENDIF





/* _UIB-PREPROCESSOR-BLOCK-END */
&ANALYZE-RESUME


/* ************************  Function Prototypes ********************** */

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD isFieldBlank DataLogicProcedure 
FUNCTION isFieldBlank RETURNS LOGICAL
  ( INPUT pcFieldValue AS CHARACTER )  FORWARD.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


/* *********************** Procedure Settings ************************ */

&ANALYZE-SUSPEND _PROCEDURE-SETTINGS
/* Settings for THIS-PROCEDURE
   Type: DataLogicProcedure
   Allow: 
   Frames: 0
   Add Fields to: Neither
   Other Settings: CODE-ONLY COMPILE APPSERVER DB-AWARE
 */
&ANALYZE-RESUME _END-PROCEDURE-SETTINGS

/* *************************  Create Window  ************************** */

&ANALYZE-SUSPEND _CREATE-WINDOW
/* DESIGN Window definition (used by the UIB) 
  CREATE WINDOW DataLogicProcedure ASSIGN
         HEIGHT             = 8.43
         WIDTH              = 55.6.
/* END WINDOW DEFINITION */
                                                                        */
&ANALYZE-RESUME

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB DataLogicProcedure 
/* ************************* Included-Libraries *********************** */
 
{src/adm2/logic.i}

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


 


&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK DataLogicProcedure 


/* ***************************  Main Block  ******************************* */
 
{ry/app/ryplipmain.i}

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


/* **********************  Internal Procedures  *********************** */

{&DB-REQUIRED-START}

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE createPreTransValidate DataLogicProcedure  _DB-REQUIRED
PROCEDURE createPreTransValidate :
/*------------------------------------------------------------------------------
  Purpose:     Procedure used to validate records server-side before the transaction scope upon create
  Parameters:  <none>
  Notes:       
------------------------------------------------------------------------------*/
 
  DEFINE VARIABLE cMessageList    AS CHARACTER    NO-UNDO.
  DEFINE VARIABLE cValueList      AS CHARACTER    NO-UNDO.
 
 
  ASSIGN
    ERROR-STATUS:ERROR = NO.
  RETURN cMessageList.
 
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME

{&DB-REQUIRED-END}

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE killPlip DataLogicProcedure 
PROCEDURE killPlip :
/*------------------------------------------------------------------------------
  Purpose:     entry point to instantly kill the plip if it should get lost in memory
  Parameters:  <none>
  Notes:       
------------------------------------------------------------------------------*/
 
  {ry/app/ryplipkill.i}
 
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE objectDescription DataLogicProcedure 
PROCEDURE objectDescription :
/*------------------------------------------------------------------------------
  Purpose:     Pass out a description of the PLIP, used in Plip temp-table
  Parameters:  <none>
  Notes:       This should be changed manually for each plip
------------------------------------------------------------------------------*/
 
  DEFINE OUTPUT PARAMETER cDescription AS CHARACTER NO-UNDO.
 
  ASSIGN cDescription = "Template PLIP".
 
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE plipSetup DataLogicProcedure 
PROCEDURE plipSetup :
/*------------------------------------------------------------------------------
  Purpose:    Run by main-block of PLIP at startup of PLIP
  Parameters: <none>
  Notes:       
------------------------------------------------------------------------------*/
 
  {ry/app/ryplipsetu.i}  
 
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE plipShutdown DataLogicProcedure 
PROCEDURE plipShutdown :
/*------------------------------------------------------------------------------
  Purpose:     This procedure will be run just before the calling program 
               terminates
  Parameters:  <none>
  Notes:       
------------------------------------------------------------------------------*/
 
  {ry/app/ryplipshut.i}
 
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE rowObjectValidate DataLogicProcedure 
PROCEDURE rowObjectValidate :
/*------------------------------------------------------------------------------
  Purpose:     Procedure used to validate RowObject record client-side
  Parameters:  <none>
  Notes:       
------------------------------------------------------------------------------*/
  DEFINE VARIABLE cMessageList    AS CHARACTER    NO-UNDO.
  DEFINE VARIABLE cValueList      AS CHARACTER    NO-UNDO.
 
  IF isFieldBlank(b_gsm_filter_set.filter_set_code) THEN
    ASSIGN
        cMessageList = cMessageList + (IF NUM-ENTRIES(cMessageList,CHR(3)) > 0 THEN CHR(3) ELSE '':U)
                     + {aferrortxt.i 'AF' '1' 'gsm_filter_set' 'filter_set_code' "'Filter set code'"}.

  ERROR-STATUS:ERROR = NO.

  RETURN cMessageList.
 
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME

{&DB-REQUIRED-START}

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE writeEndTransValidate DataLogicProcedure  _DB-REQUIRED
PROCEDURE writeEndTransValidate :
/*------------------------------------------------------------------------------
  Purpose:     Procedure used to validate records server-side after the transaction scope upon write
  Parameters:  <none>
  Notes:       
------------------------------------------------------------------------------*/
  DEFINE VARIABLE cMessageList    AS CHARACTER    NO-UNDO.
  DEFINE VARIABLE cValueList      AS CHARACTER    NO-UNDO.

  DEFINE BUFFER o_gsm_filter_data FOR gsm_filter_data.  /* Original */
  DEFINE BUFFER n_gsm_filter_data FOR gsm_filter_data.  /* New */

  /* Check if we need to copy any child records */
  IF b_gsm_filter_set.rowMod = "C":U THEN
  DO:
    /* Read through all child records of the filter set we are copying from */
    copy_blk:
    FOR EACH o_gsm_filter_data NO-LOCK
       WHERE o_gsm_filter_data.filter_set_obj = gdCopyFilterSetObj:

      /* Create the new filter data record */
      CREATE n_gsm_filter_data NO-ERROR.

      /* Check if the CREATE trigger returned any errors */
      IF ERROR-STATUS:ERROR THEN
      DO:
        cMessageList = (IF RETURN-VALUE <> "":U AND RETURN-VALUE <> ? THEN RETURN-VALUE ELSE ERROR-STATUS:GET-MESSAGE(1)).

        LEAVE copy_blk.
      END.

      /* If we did not get any errors, copy the data across */
      BUFFER-COPY o_gsm_filter_data
           EXCEPT o_gsm_filter_data.filter_data_obj
                  o_gsm_filter_data.filter_set_obj
               TO n_gsm_filter_data
           ASSIGN n_gsm_filter_data.filter_set_obj = b_gsm_filter_set.filter_set_obj NO-ERROR.

      /* Check if the ASSIGN returned any errors */
      IF ERROR-STATUS:ERROR THEN
      DO:
        cMessageList = (IF RETURN-VALUE <> "":U AND RETURN-VALUE <> ? THEN RETURN-VALUE ELSE ERROR-STATUS:GET-MESSAGE(1)).

        LEAVE copy_blk.
      END.

      VALIDATE n_gsm_filter_data NO-ERROR.

      /* Check if the ASSIGN trigger returned any errors */
      IF ERROR-STATUS:ERROR THEN
      DO:
        cMessageList = (IF RETURN-VALUE <> "":U AND RETURN-VALUE <> ? THEN RETURN-VALUE ELSE ERROR-STATUS:GET-MESSAGE(1)).

        LEAVE copy_blk.
      END.
    END. /* FOR EACH o_gsm_filter_data */
  END.

  ERROR-STATUS:ERROR = NO.

  RETURN cMessageList.

END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME

{&DB-REQUIRED-END}

{&DB-REQUIRED-START}

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE writePreTransValidate DataLogicProcedure  _DB-REQUIRED
PROCEDURE writePreTransValidate :
/*------------------------------------------------------------------------------
  Purpose:     Procedure used to validate records server-side before the transaction scope upon write
  Parameters:  <none>
  Notes:       
------------------------------------------------------------------------------*/
  DEFINE VARIABLE cMessageList    AS CHARACTER    NO-UNDO.
  DEFINE VARIABLE cValueList      AS CHARACTER    NO-UNDO.

  /* Check that we don't create duplicates when copying, adding or updating */
  IF (LOOKUP(b_gsm_filter_set.rowMod, "A,C":U) <> 0                                                   AND
      CAN-FIND(FIRST gsm_filter_set NO-LOCK
               WHERE gsm_filter_set.filter_set_code = b_gsm_filter_set.filter_set_code))
  OR (b_gsm_filter_set.rowMod = "U":U                                                                  AND
      CAN-FIND(FIRST gsm_filter_set NO-LOCK
               WHERE gsm_filter_set.filter_set_code = b_gsm_filter_set.filter_set_code
                 AND ROWID(gsm_filter_set)         <> TO-ROWID(ENTRY(1, b_gsm_filter_set.rowIdent)))) THEN
    ASSIGN
        cMessageList = cMessageList + (IF NUM-ENTRIES(cMessageList,CHR(3)) > 0 THEN CHR(3) ELSE '':U)
                     + {aferrortxt.i 'AF' '8' 'gsm_filter_set' 'filter_set_code' "'Filter set code'" QUOTER(b_gsm_filter_set.filter_set_code)}.

  /* This object number is required when copying to copy all the child records. At this point, the buffer does not have the new obj yet */
  IF b_gsm_filter_set.rowMod = "C":U THEN
    gdCopyFilterSetObj = b_gsm_filter_set.filter_set_obj.
  
  ERROR-STATUS:ERROR = NO.

  RETURN cMessageList.
 
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME

{&DB-REQUIRED-END}

/* ************************  Function Implementations ***************** */

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION isFieldBlank DataLogicProcedure 
FUNCTION isFieldBlank RETURNS LOGICAL
  ( INPUT pcFieldValue AS CHARACTER ) :
/*------------------------------------------------------------------------------
  Purpose:  Checks whether a character field is blank
    Notes:  
------------------------------------------------------------------------------*/
 
  IF LENGTH(TRIM(pcFieldValue)) = 0 OR LENGTH(TRIM(pcFieldValue)) = ? THEN
    RETURN TRUE.
  ELSE
    RETURN FALSE.   /* Function return value. */
 
END FUNCTION.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME

