DEFINITION ic_T3g3_800009803 4
DEFINITION ic_T3g4_800009803 10
DEFINITION ic_STY_g3_800009803 6
DEFINITION ic_STY_g4_800009803 12
DEFINITION ic_SCT_g3_800009803 7
DEFINITION ic_SCT_g4_800009803 13
DEFINITION ic_INEF_g3_800009803 9
DEFINITION ic_INEF_g4_800009803 15
DEFINITION ic_REF_g4_800009803 16
DEFINITION ic_T3cap1_800009803 33
DEFINITION ic_CAX_cap1_800009803 35
DEFINITION ic_TAP_cap1_800009803 36
DEFINITION ic_TAX_cap1_800009803 38
DEFINITION ic_T3cap2_800009803 39
DEFINITION ic_CAX_cap2_800009803 41
DEFINITION ic_TAP_cap2_800009803 42
DEFINITION ic_TAX_cap2_800009803 44
DEFINITION ic_ETAP_etap_800009803 63
REGISTRE ENTIER code_rejet_800009803
REGISTRE ENTIER erreur_800009803
REGISTRE ENTIER CAX_800009803
REGISTRE ENTIER SCT_800009803
REGISTRE ENTIER STY_800009803
REGISTRE ENTIER INEF_800009803
REGISTRE ENTIER REF_800009803
REGISTRE ENTIER TAP_800009803
REGISTRE ENTIER TAX_800009803
REGISTRE ENTIER ETAP_800009803
REGISTRE ENTIER T3g3_800009803
REGISTRE ENTIER T3g4_800009803
REGISTRE ENTIER T3cap1_800009803
REGISTRE ENTIER T3cap2_800009803
REGISTRE ENTIER indice_date_800009803
REGISTRE ENTIER art_date_800009803
REGISTRE ENTIER type_gestion_800009803
REGISTRE ENTIER EFFICACE_800009803
####################################################################
#
#                   CE NODES : SERVICE PCV
#                     article NODESTpcv7dc
#
# En entree: 
#       Article NODESTpcv7dc 
#
# En sortie:
#       Article OK:
#               Article  NODESTpcv7dc 
#
#       Article ERRONE:
#               Article NODESTpcv7dc 
#
#	Historique
#	DRE - 18/06/02 PCV V4.3 IMPREVISTO implicite :
#				nouvelle valeur du champ ETAP
#	RBE - 07/06/2004 - G2R0Cl : MAJ des codes erreurs
#	05/10/2011 RHE VerifPcode
#
############################################################################

############################################################################
#
#			          DEFINITIONS
#
############################################################################

#
# Constante liees au fichier artobj
#


#---------------------------------------------------------------------------
# GLOBAL
#---------------------------------------------------------------------------

#---------------------------------------------------------------------------
# CHAMPS DE L'ARTICLE
#---------------------------------------------------------------------------

# gestion pour le stockage

############################################################################
# 
#				    CONTROLES
#
############################################################################


# trace( "Article NODESTpcv7dc - Service @llo CE Nodes")
type_gestion_800009803=0

# Initialisation de EFFICACE a inconnu
EFFICACE_800009803=2

#---------------------------------------------------------------------------
# TEST DE L'ARTICLE
#---------------------------------------------------------------------------
erreur_800009803 = i_test_art( g_iartin)
SI erreur_800009803
ALORS
   code_rejet_800009803 = 0x5070+EFFICACE_800009803
   erreur_800009803 = i_PlvMessEmettre( 7550, 2, g_iartin, "", 1, code_rejet_800009803, 0, 0)
# DEST_JNL | DEST_TEEC | DEST_BASE,"DC VN7: %04x Erreur syntaxique"
   SAUT STOCKE_ERRONE
FINSI

#----------------------------------------------------------------------------
# TEST 408 et 409: de presence des champs obligatoires exclusifs T3g3 et T3g4
# On en profite pour recuperer la valeur des champs existants
#----------------------------------------------------------------------------

T3g3_800009803 = i_valid_field_n( g_iartin, ic_T3g3_800009803)
T3g4_800009803 = i_valid_field_n( g_iartin, ic_T3g4_800009803)

SI T3g3_800009803 > 0
ALORS
        SI T3g4_800009803 > 0
        ALORS
                code_rejet_800009803 = 0x5070+EFFICACE_800009803
                erreur_800009803 = i_PlvMessEmettre(7581,2,g_iartin,"",1,code_rejet_800009803,0,0)
# DEST_JNL | DEST_TEEC | DEST_BASE,"DC VN7: %04x- Err. syntaxique (T3g3 et T3g4 presents)"
                SAUT STOCKE_ERRONE
        FINSI
#  *** recuperation des champs de G3 ***
        STY_800009803 = i_get_art_field( g_iartin, ic_STY_g3_800009803)
        SCT_800009803 = i_get_art_field( g_iartin, ic_SCT_g3_800009803)
	type_gestion_800009803=3
	indice_date_800009803 = i_get_field_num( g_iartin,"DATE_g3")
	art_date_800009803 = i_get_art_field (g_iartin, indice_date_800009803)
        INEF_800009803 = i_get_art_field( g_iartin, ic_INEF_g3_800009803)
# test de duplication de l article afin de controler la validite du champ DATE)
	erreur_800009803 = i_dup_art(g_iartin, "Tpcv7g3dc", g_iartout10)
	SI (erreur_800009803 != 0)
        ALORS
                code_rejet_800009803 = 0x5040+EFFICACE_800009803
                erreur_800009803 = i_PlvMessEmettre( 7593, 2, g_iartin, "", 1, code_rejet_800009803, 0, 0)
# DEST_JNL | DEST_TEEC | DEST_BASE,"DC VN7: %04x Format de date incorrect"
                SAUT STOCKE_ERRONE
        FINSI
SINON
        SI T3g4_800009803 <= 0
        ALORS
                code_rejet_800009803 = 0x5070+EFFICACE_800009803
                erreur_800009803 = i_PlvMessEmettre(7582,2,g_iartin,"",1,code_rejet_800009803,0,0)
# DEST_JNL | DEST_TEEC | DEST_BASE,"DC VN7: %04x- Err. syntaxique (T3g3 et T3g4 absents)"
                SAUT STOCKE_ERRONE
        FINSI
# *** recuperation des champs de G4***
        STY_800009803 = i_get_art_field( g_iartin, ic_STY_g4_800009803)
        SCT_800009803 = i_get_art_field( g_iartin, ic_SCT_g4_800009803)
	type_gestion_800009803=4
        indice_date_800009803 = i_get_field_num( g_iartin,"DATE_g4")
        art_date_800009803 = i_get_art_field (g_iartin, indice_date_800009803)
        INEF_800009803 = i_get_art_field( g_iartin, ic_INEF_g4_800009803)
        REF_800009803 = i_get_art_field( g_iartin, ic_REF_g4_800009803)
# test de duplication de l article afin de controler la validite du champ DATE)
        erreur_800009803 = i_dup_art(g_iartin, "Tpcv7g4dc", g_iartout10)
        SI (erreur_800009803 != 0)
        ALORS
                code_rejet_800009803 = 0x5040+EFFICACE_800009803
                erreur_800009803 = i_PlvMessEmettre( 7593, 2, g_iartin, "", 1, code_rejet_800009803, 0, 0)
# DEST_JNL | DEST_TEEC | DEST_BASE,"DC VN7: %04x Format de date incorrect"
                SAUT STOCKE_ERRONE
        FINSI
FINSI

#----------------------------------------------------------------------------
# TEST 417 : Recuperation des valeurs des champs DUR et ETAP
#----------------------------------------------------------------------------
ETAP_800009803 = i_get_art_field( g_iartin, ic_ETAP_etap_800009803)
SI ETAP_800009803 < 0
ALORS
   code_rejet_800009803 = 0x5070+EFFICACE_800009803
   erreur_800009803 = i_PlvMessEmettre(7591,2,g_iartin,"",1,code_rejet_800009803,0,0)
# DEST_JNL | DEST_TEEC | DEST_BASE,"DC VN7: %04x- Err. syntaxique (pas de champ ETAP)"
   SAUT STOCKE_ERRONE
FINSI

#----------------------------------------------------------------------------
# TEST 413 et 411: presence des champs optionnels exclusifs T3cap1 et T3cap2
# On en profite pour recuperer la valeur des champs existants
#----------------------------------------------------------------------------

T3cap1_800009803 = i_valid_field_n( g_iartin, ic_T3cap1_800009803)
T3cap2_800009803 = i_valid_field_n( g_iartin, ic_T3cap2_800009803)

SI T3cap1_800009803 > 0
ALORS
# trace("T3cap1 present")
   SI T3cap2_800009803 > 0
   ALORS
# ce cas n'est pas normal car ces 2 champs ne peuvent etre present en meme temps.
# trace("T3cap2 present")
      code_rejet_800009803 = 0x5070+EFFICACE_800009803
      erreur_800009803 = i_PlvMessEmettre(7578,2,g_iartin,"",1,code_rejet_800009803,0,0)
# DEST_JNL | DEST_TEEC | DEST_BASE,"DC VN7: %04x- Err. syntaxique (T3cap1 et T3cap2 presents)"
      SAUT STOCKE_ERRONE
   FINSI

#  *** recuperation des champs de CAP1 ***
#   trace("T3cap2 absent")
   CAX_800009803 = i_get_art_field( g_iartin, ic_CAX_cap1_800009803)
   TAP_800009803 = i_get_art_field( g_iartin, ic_TAP_cap1_800009803)
   TAX_800009803 = i_get_art_field( g_iartin, ic_TAX_cap1_800009803)
SINON
#   trace("T3cap1 absent")
   SI T3cap2_800009803 <= 0
   ALORS
# Ni CAP1 ni CAP2 ne sont present, ce n'est normalement pas possible
# trace("T3cap2 absent")
      code_rejet_800009803 = 0x5070+EFFICACE_800009803
      erreur_800009803 = i_PlvMessEmettre(7592,2,g_iartin,"",1,code_rejet_800009803,0,0)
# DEST_JNL | DEST_TEEC | DEST_BASE,"DC VN7: %04x- Err. syntaxique (T3cap1 et T3cap2 absents)"
      SAUT STOCKE_ERRONE
   FINSI
# *** recuperation des champs de CAP2***
# trace("T3cap2 present")
   CAX_800009803 = i_get_art_field( g_iartin, ic_CAX_cap2_800009803)
   TAP_800009803 = i_get_art_field( g_iartin, ic_TAP_cap2_800009803)
   TAX_800009803 = i_get_art_field( g_iartin, ic_TAX_cap2_800009803)
FINSI

#---------------------------------------------------------------------------
# DETERMINATION DES ARTICLES INEFFICACES
# Bit B du champ TAP : 0 : efficace, 1: inefficace
#----------------------------------------------------------------------------
SI ((TAP_800009803 & 0x40) == 0x40)
ALORS
   trace( "Article inefficace -> Stockage en inefficace")
   EFFICACE_800009803 = 0
SINON
   EFFICACE_800009803 = 1
FINSI


#----------------------------------------------------------------------------
# TEST 302 : on verifie que le champ CAX est egale a 0x01
#----------------------------------------------------------------------------
SI (CAX_800009803 != 0x01)
ALORS
   code_rejet_800009803 = 0x5040+EFFICACE_800009803
   erreur_800009803 = i_PlvMessEmettre(7553,2,g_iartin,"",2,code_rejet_800009803,CAX_800009803,0)
# DEST_JNL | DEST_TEEC | DEST_BASE,"DC VN7: %04x- Err. semantique (CAX = 0x%02x inconnue)"
   SAUT STOCKE_ERRONE
FINSI

#----------------------------------------------------------------------------
# TEST 307 : on verifie que le champ TAP est egale a 0x00 ou 0x40
#----------------------------------------------------------------------------
#SI ((TAP != 0x00) && (TAP != 0x40))
#ALORS
#   code_rejet = 0x5040+EFFICACE
#   erreur = i_PlvMessEmettre(7558,2,g_iartin,"",2,code_rejet,TAP,0)
# DEST_JNL | DEST_TEEC | DEST_BASE,"DC VN7: %04x- Err. semantique (TAP = 0x%02x incoherent)"
#   SAUT STOCKE_ERRONE
#FINSI

#----------------------------------------------------------------------------
# TEST 416 : on verifie que le champ TAX est egale a 0x01
#----------------------------------------------------------------------------
SI (TAX_800009803 != 0x0001)
ALORS
   code_rejet_800009803 = 0x5040+EFFICACE_800009803
   erreur_800009803 = i_PlvMessEmettre(7585,2,g_iartin,"",2,code_rejet_800009803,TAX_800009803,0)
# DEST_JNL | DEST_TEEC | DEST_BASE,"DC VN7: %04x- Err. semantique (TAX = 0x%02x inconnue)"
   SAUT STOCKE_ERRONE
FINSI

#----------------------------------------------------------------------------
# TEST 417 : on verifie que le champ ETAP est egal a 0x0E ou 0x0F ou 0x10 ou 0x11
#   (Ajout DRE 18/06/02 IMPREVISTO implicite)
#     ou 0xBC ou 0xC0 ou 0xC1 ou 0xC2 ou 0xC3 ou 0xC4 ou 0xC5 ou 0xBD ou 0xBF
#----------------------------------------------------------------------------
SI ((ETAP_800009803 != 0x0E) && (ETAP_800009803 != 0x0F) && (ETAP_800009803 != 0x10) && (ETAP_800009803 != 0x11) && (ETAP_800009803 != 0xBC) && (ETAP_800009803 != 0xC0) && (ETAP_800009803 != 0xC1) && (ETAP_800009803 != 0xC2) && (ETAP_800009803 != 0xC3) && (ETAP_800009803 != 0xC4) && (ETAP_800009803 != 0xC5) && (ETAP_800009803 != 0xBD) && (ETAP_800009803 != 0xBE) && (ETAP_800009803 != 0xBF))
ALORS
   code_rejet_800009803 = 0x5040+EFFICACE_800009803
   erreur_800009803 = i_PlvMessEmettre(7588,2,g_iartin,"",2,code_rejet_800009803,ETAP_800009803,0)
# DEST_JNL | DEST_TEEC | DEST_BASE,"DC VN7: %04x- Err. semantique (ETAP = 0x%02x incorrect)"
   SAUT STOCKE_ERRONE
FINSI

############################################################################
#
#                               STOCKAGE
#
############################################################################

#---------------------------------------------------------------------------
# STOCKAGE EN OK
#----------------------------------------------------------------------------

#   Duplication de l'article
erreur_800009803 = i_dup_art_id(g_iartin, g_iartout)

SI type_gestion_800009803 == 3
ALORS
	erreur_800009803 = i_clever_dup_art(g_iartout, "Tpcv7g3dc", g_iartout4)
#	erreur = i_fdump_art(g_iartout4)
	erreur_800009803 = i_set_art_date(g_iartout4, art_date_800009803)
#	erreur = i_fdump_art(g_iartout4)
SINON
        erreur_800009803 = i_clever_dup_art(g_iartout, "Tpcv7g4dc", g_iartout4)
#	erreur = i_fdump_art(g_iartout4)
	erreur_800009803 = i_set_art_date(g_iartout4, art_date_800009803)
        erreur_800009803 = i_set_art_field(g_iartout4, ic_STY_g3_800009803, STY_800009803)
        erreur_800009803 = i_set_art_field(g_iartout4, ic_SCT_g3_800009803, SCT_800009803)
        erreur_800009803 = i_set_art_field(g_iartout4, ic_INEF_g3_800009803, INEF_800009803)
#	erreur = i_fdump_art(g_iartout4)
FINSI

erreur_800009803 = i_stocke_art(g_iartout4,0,PT_OK,0)

# trace("Fin traitement Article NODESTpcv7dc Nodes")
RETOUR TRAIT_OK


#---------------------------------------------------------------------------
# STOCKAGE EN ERRONE
#----------------------------------------------------------------------------
POINT STOCKE_ERRONE

# trace("Stockage de l'article en ERRONE")

erreur_800009803 = i_make_art_rej( g_iartin, g_iartout, code_rejet_800009803)
erreur_800009803 = i_stocke_art( g_iartout,0,PT_ERRONE,0)

# trace("Fin traitement Article NODESTpcv7dc Nodes")
RETOUR TRAIT_OK

############################################################################
#
#                               FIN
#
############################################################################


