REGISTRE ENTIER code_rejet_800009799
REGISTRE ENTIER erreur_800009799
REGISTRE ENTIER CAX_800009799
REGISTRE ENTIER SCT_800009799
REGISTRE ENTIER STY_800009799
REGISTRE ENTIER INEF_800009799
REGISTRE ENTIER TAP_800009799
REGISTRE ENTIER DUR_800009799
REGISTRE ENTIER ETAP_800009799
REGISTRE ENTIER T3g3_800009799
REGISTRE ENTIER T3g4_800009799
REGISTRE ENTIER T3cap1_800009799
REGISTRE ENTIER T3cap2_800009799
REGISTRE ENTIER indice_date_800009799
REGISTRE ENTIER art_date_800009799
REGISTRE ENTIER type_gestion_800009799
REGISTRE ENTIER EFFICACE_800009799
####################################################################
#
#                   CE NODES : SERVICE MVT
#
#                     article Tmvt7dc
#
# En entree: 
#       Article Tmvt7dc (domaine ILA=Ltm)
#       Domaine article: Dmvt
#
# En sortie:
#       Article OK:
#               Article  Tmvt7dc (domaine ILA=Ltms)
#               Domaine article: Dtms
#
#       Article ERRONE:
#               Article Tmvt7dc (domaine ILA=Ltm)
#               Domaine article: Dtms
#
#       Article duplique inef :
#               Article Tmvt7dc (domaine ILA=Linef)
#               Domaine article: Dtms
#       04/11/2002 - MCH - Champ ETAP dans CSV
#	31/03/2003 - RBE - FO250 : modif. du chp DATE en heure de debut
#	07/06/2004 - RBE - G2R0Cl : MAJ des codes erreurs
#	04/10/2011 RHE VerifPcode
#
############################################################################

############################################################################
#
#			          DEFINITIONS
#
############################################################################
#---------------------------------------------------------------------------
# GLOBAL
#---------------------------------------------------------------------------

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

# gestion pour le stockage

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


# trace( "Article Tmvt7dc - Service @llo CE Nodes")
type_gestion_800009799=0
EFFICACE_800009799=2

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

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

T3g3_800009799 = i_valid_field_n( g_iartin, $Tmvt7dc::T3g3)
T3g4_800009799 = i_valid_field_n( g_iartin, $Tmvt7dc::T3g4)


T3cap1_800009799 = i_valid_field_n( g_iartin, $Tmvt7dc::T3cap1)
T3cap2_800009799 = i_valid_field_n( g_iartin, $Tmvt7dc::T3cap2)

SI T3cap1_800009799 > 0
ALORS
   DUR_800009799 = i_get_art_field( g_iartin, $Tmvt7dc::DUREE)
SINON
   DUR_800009799 = i_get_art_field( g_iartin, $Tmvt7dc::DUREE2)
FINSI

SI T3g3_800009799 > 0
ALORS
        trace("T3g3 present")
        SI T3g4_800009799 > 0
        ALORS
                trace("T3g4 present")
                code_rejet_800009799 = 0x5070+EFFICACE_800009799
                erreur_800009799 = i_PlvMessEmettre(7581,2,g_iartin,"",1,code_rejet_800009799,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_800009799 = i_get_art_field( g_iartin, $Tmvt7dc::STY:0)
        SCT_800009799 = i_get_art_field( g_iartin, $Tmvt7dc::SCT:0)
	type_gestion_800009799=3
	indice_date_800009799 = i_get_field_num( g_iartin,"DATE_g3")
	art_date_800009799 = i_get_art_field (g_iartin, indice_date_800009799)
        INEF_800009799 = i_get_art_field( g_iartin, $Tmvt7dc::INEF:0)
# test de duplication de l article afin de controler la validite du champ DATE)
        erreur_800009799 = i_dup_art(g_iartin, "Tmvt7g3dc", g_iartout10)
        SI (erreur_800009799 != 0)
        ALORS
                code_rejet_800009799 = 0x5040+EFFICACE_800009799
                erreur_800009799 = i_PlvMessEmettre( 7593, 2, g_iartin, "", 1, code_rejet_800009799, 0, 0)
# DEST_JNL | DEST_TEEC | DEST_BASE,"DC VN7: %04x Format de date incorrect"
                SAUT STOCKE_ERRONE
        FINSI
        SI ( (SCT_800009799 & 0x60) == 0x00)
        ALORS
                #trace("DATE = heure de fin de comm : conversion en debut de comm")
                art_date_800009799 = art_date_800009799 - DUR_800009799
                erreur_800009799 = i_set_art_field(g_iartin, $Tmvt7dc::DATE_g3, art_date_800009799)
                g_iartin.SCT = (SCT_800009799 | 0x20)
		SCT_800009799 = SCT_800009799 | 0x20
        FINSI
	
SINON
        trace("T3g3 absent")
        SI T3g4_800009799 <= 0
        ALORS
                trace("T3g4 absent")
                code_rejet_800009799 = 0x5070+EFFICACE_800009799
                erreur_800009799 = i_PlvMessEmettre(7582,2,g_iartin,"",1,code_rejet_800009799,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***
        trace("T3g4 present")
        STY_800009799 = i_get_art_field( g_iartin, $Tmvt7dc::STY:1)
        SCT_800009799 = i_get_art_field( g_iartin, $Tmvt7dc::SCT:1)
	type_gestion_800009799=4
        indice_date_800009799 = i_get_field_num( g_iartin,"DATE_g4")
        art_date_800009799 = i_get_art_field (g_iartin, indice_date_800009799)
        INEF_800009799 = i_get_art_field( g_iartin, $Tmvt7dc::INEF:1)
        # VerifPcode - RHE # REF = i_get_art_field( g_iartin, $Tmvt7dc::REF:1)
# test de duplication de l article afin de controler la validite du champ DATE)
        erreur_800009799 = i_dup_art(g_iartin, "Tmvt7g4dc", g_iartout10)
        SI (erreur_800009799 != 0)
        ALORS
                code_rejet_800009799 = 0x5040+EFFICACE_800009799
                erreur_800009799 = i_PlvMessEmettre( 7593, 2, g_iartin, "", 1, code_rejet_800009799, 0, 0)
# DEST_JNL | DEST_TEEC | DEST_BASE,"DC VN7: %04x Format de date incorrect"
                SAUT STOCKE_ERRONE
        FINSI
        SI ( (SCT_800009799 & 0x60) == 0x00)
        ALORS
                trace("DATE = heure de fin de comm : conversion en debut de comm")
                art_date_800009799 = art_date_800009799 - DUR_800009799
                erreur_800009799 = i_set_art_field(g_iartin, $Tmvt7dc::DATE_g4, art_date_800009799)
                g_iartin.SCT = (SCT_800009799 | 0x20)
		SCT_800009799 = SCT_800009799 | 0x20
        FINSI
FINSI

#----------------------------------------------------------------------------
# Recuperation des valeurs des champs DUR et ETAP
#----------------------------------------------------------------------------
ETAP_800009799 = i_get_art_field( g_iartin, $Tmvt7dc::ETAP)
SI ETAP_800009799 < 0
ALORS
# ************
# * TEST 410 *
# ************
   code_rejet_800009799 = 0x5070+EFFICACE_800009799
   erreur_800009799 = i_PlvMessEmettre(7591,2,g_iartin,"",1,code_rejet_800009799,0,0)
# DEST_JNL | DEST_TEEC | DEST_BASE,"DC VN7: %04x- Err. syntaxique (pas de champ ETAP)"
   SAUT STOCKE_ERRONE
FINSI

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

SI T3cap1_800009799 > 0
ALORS
# trace("T3cap1 present")
   SI T3cap2_800009799 > 0
   ALORS
# ************
# * TEST ??? *
# ************
# ce cas n'est pas normal car ces 2 champs ne peuvent etre present en meme temps.
# trace("T3cap2 present")
      code_rejet_800009799 = 0x5070+EFFICACE_800009799
      erreur_800009799 = i_PlvMessEmettre(7551,2,g_iartin,"",1,code_rejet_800009799,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_800009799 = i_get_art_field( g_iartin, $Tmvt7dc::CAX)
   TAP_800009799 = i_get_art_field( g_iartin, $Tmvt7dc::TAP)
 
SINON
#   trace("T3cap1 absent")
   SI T3cap2_800009799 <= 0
   ALORS
# ************
# * TEST ??? *
# ************
# Ni CAP1 ni CAP2 ne sont present, ce n'est normalement pas possible
# trace("T3cap2 absent")
      code_rejet_800009799 = 0x5070+EFFICACE_800009799
      erreur_800009799 = i_PlvMessEmettre(7592,2,g_iartin,"",1,code_rejet_800009799,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_800009799 = i_get_art_field( g_iartin, $Tmvt7dc::CAX2)
   TAP_800009799 = i_get_art_field( g_iartin, $Tmvt7dc::TAP2)
  
FINSI

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




#----------------------------------------------------------------------------
# On controle l'existance du champ STY
#----------------------------------------------------------------------------
SI STY_800009799 < 0
ALORS
# ************
# * TEST 408 *
# ************
   code_rejet_800009799 = 0x5070+EFFICACE_800009799
   erreur_800009799 = i_PlvMessEmettre(7556,2,g_iartin,"",1,code_rejet_800009799,0,0)
# DEST_JNL | DEST_TEEC | DEST_BASE,"DC VN7: %04x- Err. syntaxique (pas de champ STY)"
   SAUT STOCKE_ERRONE
FINSI

#----------------------------------------------------------------------------
# on verifie que le champ STY est egal a 0x0
#----------------------------------------------------------------------------
SI (STY_800009799 != 0x0)
ALORS
# ************
# * TEST 408 *
# ************
   code_rejet_800009799 = 0x5040+EFFICACE_800009799
   erreur_800009799 = i_PlvMessEmettre(7557,2,g_iartin,"",2,code_rejet_800009799,STY_800009799,0)
# DEST_JNL | DEST_TEEC | DEST_BASE,"DC VN7: %04x- Err. syntaxique (STY = 0x%02x incorrect)"
   SAUT STOCKE_ERRONE
FINSI

#----------------------------------------------------------------------------
# On controle l'existance du champ DUR
#----------------------------------------------------------------------------
SI DUR_800009799 < 0
ALORS
# ************
# * TEST 409 *
# ************
   code_rejet_800009799 = 0x5070+EFFICACE_800009799
   erreur_800009799 = i_PlvMessEmettre(7590,2,g_iartin,"",1,code_rejet_800009799,0,0)
# DEST_JNL | DEST_TEEC | DEST_BASE,"DC VN7: %04x- Err. syntaxique (pas de champ DUREE)"
   SAUT STOCKE_ERRONE
FINSI

#----------------------------------------------------------------------------
# on verifie que le champ DUR est superieur a 0x0
#----------------------------------------------------------------------------
SI (DUR_800009799 <= 0x0)
ALORS
# ************
# * TEST 409 *
# ************
   code_rejet_800009799 = 0x5040+EFFICACE_800009799
   erreur_800009799 = i_PlvMessEmettre(7589,2,g_iartin,"",2,code_rejet_800009799,DUR_800009799,0)
# DEST_JNL | DEST_TEEC | DEST_BASE,"DC VN7: %04x- Err. syntaxique (DUR = 0x0 incorrect)"
   SAUT STOCKE_ERRONE
FINSI

#----------------------------------------------------------------------------
# on verifie que le champ ETAP est egale a 0x09 0x0B 
# fait dans le pcode de distri a partir de le G1R2C5
#----------------------------------------------------------------------------
# SI ((ETAP < 0x06) || (ETAP > 0x0D))
# ALORS
# ************
# * TEST 410 *
# ************
#    code_rejet = 0x5040+EFFICACE
#    erreur = i_PlvMessEmettre(7588,2,g_iartin,"",2,code_rejet,ETAP,0)
# DEST_JNL | DEST_TEEC | DEST_BASE,"DC VN7: %04x- Err. syntaxique (ETAP = 0x%02x incorrect)"
#    SAUT STOCKE_ERRONE
# FINSI

############################################################################
#
#                              TRAITEMENTS
#
############################################################################

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

#---------------------------------------------------------------------------
# STOCKAGE EN EFFICACE
#----------------------------------------------------------------------------

trace( "Stockage de l'article en Dtms")
#   Duplication de l'article
erreur_800009799 = i_dup_art_id(g_iartin, g_iartout)


SI type_gestion_800009799 == 3
ALORS
	erreur_800009799 = i_clever_dup_art(g_iartout, "Tmvt7g3dc", g_iartout4)
#	erreur = i_fdump_art(g_iartout4)
	erreur_800009799 = i_set_art_date(g_iartout4, art_date_800009799)
#	erreur = i_fdump_art(g_iartout4)
SINON
	erreur_800009799 = i_clever_dup_art(g_iartout, "Tmvt7g4dc", g_iartout4)
#	erreur = i_fdump_art(g_iartout4)
	erreur_800009799 = i_set_art_date(g_iartout4, art_date_800009799)
        erreur_800009799 = i_set_art_field(g_iartout4, $Tmvt7g4dc::STY, STY_800009799)
        erreur_800009799 = i_set_art_field(g_iartout4, $Tmvt7g4dc::SCT, SCT_800009799)
        erreur_800009799 = i_set_art_field(g_iartout4, $Tmvt7g4dc::INEF, INEF_800009799)
#	erreur = i_fdump_art(g_iartout4)
FINSI

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

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


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

# trace("Stockage de l'article en ERRONE")
erreur_800009799 = i_make_art_rej( g_iartin, g_iartout, code_rejet_800009799)
erreur_800009799 = i_stocke_art( g_iartout, 0, PT_ERRONE, 0)

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

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






