DEFINITION TD_VGA1_860026288 7
DEFINITION TD_VGA2_860026288 2
DEFINITION INST_VGA_860026288 "VGA"
DEFINITION C_InstCENTVG_860026288 "CENTAUREVG"
DEFINITION C_TcentaureVG_860026288 "TcentaureVG"
DEFINITION C_Article_860026288 "Tmvt7g3dc"
DEFINITION C_InstSYMP_860026288 "SYMP"
DEFINITION C_InstFE_860026288 "FE"
DEFINITION C_InstTRAFIC_860026288 "TRAFIC"
DEFINITION C_Tsymphomvt7g3_860026288 "Tsymphomvt7g3"
DEFINITION C_Tfe_860026288 "Tfe"
DEFINITION C_Tdelta_minute_860026288 "Tdelta_minute"
DEFINITION C_Ttrafic_860026288 "Ttrafic"
DEFINITION NUMTAB_860026288 1
DEFINITION ZONEMETRO_860026288 7
DEFINITION C_instFERPV_860026288 "FERPV"
DEFINITION C_Tferpv_860026288 "Tfe_rpv"
REGISTRE ENTIER bCENTVG_860026288
REGISTRE ENTIER bREDIST_860026288
REGISTRE ENTIER bTRAFIC_860026288
REGISTRE ENTIER Buffer_INFDEDE_860026288
REGISTRE ENTIER bVGA_860026288
REGISTRE ENTIER bVGTplus_860026288
REGISTRE ENTIER CAX_860026288
REGISTRE ENTIER cfr_860026288
REGISTRE ENTIER code_errone_860026288
REGISTRE ENTIER date_locale_860026288
REGISTRE ENTIER ddebut_860026288
REGISTRE ENTIER dede_inf_860026288
REGISTRE ENTIER dede_num1_860026288
REGISTRE ENTIER dizaine_860026288
REGISTRE ENTIER DUREE_860026288
REGISTRE ENTIER EFFICACE_860026288
REGISTRE ENTIER ENVELOPPE_NOK_860026288
REGISTRE ENTIER erreur_860026288
REGISTRE ENTIER ETAP_860026288
REGISTRE ENTIER f3BPQ_OK_860026288
REGISTRE ENTIER gmt_date_860026288
REGISTRE ENTIER INF_IDAV_860026288
REGISTRE ENTIER INF_NOS_860026288
REGISTRE ENTIER instCENTAUREVG_860026288
REGISTRE ENTIER instDM_860026288
REGISTRE ENTIER instFE_860026288
REGISTRE ENTIER instSYMPHO_860026288
REGISTRE ENTIER instTRAFIC_860026288
REGISTRE ENTIER instVGA_860026288
REGISTRE ENTIER L_NDR_860026288
REGISTRE ENTIER NBCOD_860026288
REGISTRE ENTIER NUMNOS_OK_860026288
REGISTRE ENTIER res_860026288
REGISTRE ENTIER SUP_860026288
REGISTRE ENTIER T3cap1_OK_860026288
REGISTRE ENTIER T3coca_OK_860026288
REGISTRE ENTIER T3cocav_OK_860026288
REGISTRE ENTIER T3idav_OK_860026288
REGISTRE ENTIER TAXE_860026288
REGISTRE ENTIER trait_ok_860026288
REGISTRE ENTIER unite_860026288
REGISTRE ENTIER val_860026288
REGISTRE ENTIER b_CodOperVG_860026288
REGISTRE ENTIER b_OperNBE_860026288
REGISTRE ENTIER instFERPV_860026288
REGISTRE POINTEUR pt_BETA_860026288
REGISTRE POINTEUR pt_BETAV_860026288
REGISTRE POINTEUR pt_buffer_860026288
REGISTRE POINTEUR pt_C_CSV1_860026288
REGISTRE POINTEUR pt_domaine_DM_860026288
REGISTRE POINTEUR pt_ETAP2_860026288
REGISTRE POINTEUR pt_NDE_860026288
REGISTRE POINTEUR pt_NDR_860026288
REGISTRE POINTEUR pt_NUM_IDAV_860026288
REGISTRE POINTEUR pt_NUMNOS_860026288
REGISTRE POINTEUR pt_OP_CSV1_860026288
REGISTRE POINTEUR pt_LIBELREDIST_860026288
REGISTRE POINTEUR pt_InfoCompl_860026288
REGISTRE POINTEUR pt_nomECCFact_860026288
REGISTRE POINTEUR pt_OFFRE_860026288
REGISTRE POINTEUR pt_OPERA_860026288
REGISTRE POINTEUR pt_RES1_860026288
REGISTRE POINTEUR pt_SGTQS_860026288
REGISTRE POINTEUR pt_TRAF_DM_860026288
REGISTRE POINTEUR pt_VGA_OF_860026288
REGISTRE POINTEUR pt_VGA_OP_860026288
REGISTRE POINTEUR pt_VGTplus_OF_860026288
REGISTRE POINTEUR pt_VGTplus_OP_860026288
REGISTRE POINTEUR pt_temp_860026288
REGISTRE POINTEUR pt_CodOperVG_860026288
REGISTRE POINTEUR pt_TEMP1_860026288
REGISTRE POINTEUR pt_DEDE_NUM_860026288
############################################################################
#
# Fichier : Tmvt7g3dc.src
#
# Version : %version: 9.12 %
#
# Date    : %date_modified: 04/04/02 11:28 %
#
# Distribution :
#    Article detail de communication Tmvt7g3dc
#    pour l' application MVT
#
# En entree :
#    Article :Tmvt7g3dc.art
#
# En sortie :
#    TRAFIC
#    FE
#    Delta_Minute
#    ALLOFACT supprime en G3R16
#    Symphonie
#
# N.B : Le cas d'article Tmvt7g3dc est un cas restreint du cas d'article
#       Tmvt7dc ( le sous-TLV T3g4 n'est pas present). Ce pcode de distribution
#	gere donc en partie la distribution des articles au format Tmvt7dc.
#
# HISTORIQUE :
# EV164: Mise a jour des pcodes de Tmvt7dc version 4.2
# FOEX441: Gestion des champs DUREE dans les tables de duplication car DUREE est initialise a 000000 .
# 17/06/2002 - PSA - FO1510  : Encapsulation pour le stockage en errone
# 17/07/2002 - NSA - maj des alarmes , envoi en redist
# 04/11/2002 - MCH - Champ ETAP dans CSV
# 07/11/2002 - MCH - FO94 - champ DUREE pour trafic fe & dm
# 07/11/2002 - MCH - FO95 - champ DEDE_NUM pour FE et DM
# 07/11/2002 - MCH - FO96 - champ DEDE_INF pour DM
# 07/11/2002 - MCH - FO97 - champ DEDE_INF pour Trafic
# 13/11/2002 - MCH - FO107 - Correction DEDE_DIST_N / FE DM
# 04/12/2002 - MCH - FO127 - Retour de la FOEX441 / trafic fe & dm
# 11/12/2002 - NSA - FO137 - Annule le FO94
# 13/01/2003 - RBE - FO169 - CLASSDEST = 0 pour FE
# 10/02/2003 - RBE - Envoi en redistri. si pb acces fichiers de distrib.
# 28/03/2003 - RBE - FO240 : envoi a symphonie si redist.
# 10/04/2003 - RBE - FO266 - champs DEDE_INF et DEDE_NUM pour Trafic
# 18/04/2003 - RBE - FO274 : Envoi a SC si envoi a 1 appli. de facturation
# 10/04/2003 - MCH - requete distri; date gmt + calcul longueur cle
# 17/06/2003 - PSA - Envoi SC vers TallofactNodes
# 22/07/2003 - DRE - Modif calcul gmt_date
# 03/09/2003 - DRE - FO392 : Initialisation des variables Pcode
# 12/12/2003 - MCH - G2R0Ca : modif enveloppe - recup cfr pour c_libre de FE
# 08/06/2004 - NSA - G2R0Cl: integration des codes d erreurs
# 28/12/2004 - PKH - G2R0Cbb: Ajout des champs T4 CSV et NBCOD a Symphonie
# 06/01/2005 - FAL - G2R0Cbb: Allofact avec un seul CS
# 14/01/2005 - RBE - G2R0Cn : Modif. format TallofactNodes avec ajout CS1
# 26/01/2005 - FAL - G2R0Cbb  Mise en commun modif 28/12/04 06 et 14/01/05
# 18/02/2005 - RBE - FO1119 : c_csv cadre a gauche et op_csv cadre a droite
# 31/03/2005 - FAL - FO1216 CSV symphonie comme SC
# 12/04/2005 - FAL - FO1237 pas de NBCOD et CS pour symphonie si INEF
# 08/08/2005 - PKH - G2R1Cq VGA
# 06/08/2005 - PKH - G2R1CQ : MODIFICATION de spec Creation des 2 tables de distributions VGA1->table8 (pt_VGA_OFF), VGA3->table3(VGA_OPE)
# 20/09/2005 - PKH - G2R1Cq : MODIFICATION de l appel des tables VGA VGA1->table8 VGA2->table3
# 28/09/2005 - PSA - G2R1Co : fusion Cj sur Cq (prise en compte de la FO1406 sur la Cq)
# 21/10/2005 - PSA - G2R2Co : FO 1530, 1531, 1539
# 02/12/2005 - PSA - G2R2Co : FO 1609 (eligibilite VGA)
# 28/12/2005 - PKH - G2R2Ca : FO1628 Evolution eligibilite VGA
# 06/06/2006 - FAL - G2R2Cu : BNC pour typcom et Evolution eligibilite VGA VGT VGTplus
# 04/09/2006 - FAL - G2R2Cq : FO1944 evolution GVT plus
# 14/02/2007 - RHE - G3R0Ca : DC eligible VGA via le demande et le champ ETAP et non plus via le TYPCOM
# 31/12/2008 - RHE - G3R11  : Z=7 pour offre VGA
# 01/02/2010 - DRE - G3R16 Menage e-bill (Allofact)
# 10/05/2010 - PKH - G3R17lot2 Item NBE2
# 10/05/2010 - PKH - QC362 valorisation du champ SERVICE de FERPV a 8
# 12/10/2010 - PKH - G3R18Cy valorisation du champ DEDE_NUM pour fe et fe_rpv ajout par duplication dan Tfe_rpv des champs INFDDE et FILLLER
# 03/10/2011 - THE - VerifPcode
#
############################################################################
# Declarations
############################################################################


# VerifPcode


# Initialisations
bCENTVG_860026288		 = 0
bREDIST_860026288		 = 0
bTRAFIC_860026288		 = 0
Buffer_INFDEDE_860026288	 = 0
bVGA_860026288		 = 0
bVGTplus_860026288	 = 0
dede_inf_860026288	 = 0
dede_num1_860026288	 = 0
ENVELOPPE_NOK_860026288	 = -1
instCENTAUREVG_860026288	 = 0
instDM_860026288		 = 0
instFE_860026288		 = 0
instSYMPHO_860026288	 = 0
instTRAFIC_860026288	 = 0
NBCOD_860026288		 = 0
val_860026288		 = 0
b_CodOperVG_860026288	 = 0
b_OperNBE_860026288	 = 0
instFERPV_860026288	 = 0
#REF		 = 0


# Initialisation des pointeurs
pt_BETA_860026288		 = "110012345"
pt_BETAV_860026288	 = "223312345"
pt_buffer_860026288	 = "7272727272727272727272727272727272727272727272727727272727727272727"
pt_C_CSV1_860026288	 = "0012345"
pt_domaine_DM_860026288	 = "999999999999999999999999"
pt_ETAP2_860026288	 = "012345678912345"
pt_InfoCompl_860026288	 = "123412345"
pt_LIBELREDIST_860026288	 = "78901234567890123456789012345612345159784563215465874512387128"
pt_NDE_860026288		 = "123456789012345"
pt_NDR_860026288		 = "112233445512345"
pt_nomECCFact_860026288	 = "67676767676767"
pt_NUM_IDAV_860026288	 = "12345678901234567890123412345"
pt_NUMNOS_860026288	 = "123456789012345678901234567812345"
pt_OFFRE_860026288	 = "02350235023502356959552325"
pt_OP_CSV1_860026288	 = "912345678912345"
pt_OPERA_860026288	 = "69696969695218978145875814265"
pt_RES1_860026288		 = "90569019703569013549005871614"
pt_SGTQS_860026288	 = "12345678901212345"
pt_temp_860026288		 = "45454545454545454545454545454545454545454545"
pt_TRAF_DM_860026288	 = "1234567812345"
pt_VGA_OF_860026288	 = "265265265265256745825852"
pt_VGA_OP_860026288	 = "8268268826826826826826826828628"
pt_VGTplus_OF_860026288	 = "464754564754564754564"
pt_VGTplus_OP_860026288	 = "504754564754564754564"
pt_CodOperVG_860026288	 = "pt_CodOperVG979797979797979797979797979797997979799797979979797979"
pt_TEMP1_860026288	 = "pt_TEMP1191919191919191919119191919191919191911919191919191919191919191919191919191919191919119199119"
pt_DEDE_NUM_860026288	 = "pt_DEDE_NUM101010101010101010101010101010101010101010101010101101010101010101010100101010011011010101010"

i_strcpy(pt_BETA_860026288, "")
i_strcpy(pt_BETAV_860026288, "")
i_strcpy(pt_buffer_860026288, "")
i_strcpy(pt_C_CSV1_860026288, "")
i_strcpy(pt_domaine_DM_860026288, "")
i_strcpy(pt_ETAP2_860026288, "")
i_strcpy(pt_InfoCompl_860026288, "")
i_strcpy(pt_LIBELREDIST_860026288, "")
i_strcpy(pt_NDE_860026288, "")
i_strcpy(pt_NDR_860026288, "")
i_strcpy(pt_nomECCFact_860026288, "")
i_strcpy(pt_nomECCFact_860026288, "")
i_strcpy(pt_NUM_IDAV_860026288, "")
i_strcpy(pt_NUMNOS_860026288, "")
i_strcpy(pt_OFFRE_860026288, "")
i_strcpy(pt_OP_CSV1_860026288, "")
i_strcpy(pt_OPERA_860026288, "")
i_strcpy(pt_RES1_860026288, "")
i_strcpy(pt_SGTQS_860026288, "")
i_strcpy(pt_temp_860026288, "")
i_strcpy(pt_TRAF_DM_860026288, "")
i_strcpy(pt_VGA_OF_860026288, " ")
i_strcpy(pt_VGA_OP_860026288, " ")
i_strcpy(pt_VGTplus_OF_860026288, " ")
i_strcpy(pt_VGTplus_OP_860026288, " ")
i_strcpy(pt_CodOperVG_860026288,"")
i_strcpy(pt_TEMP1_860026288,"")
i_strcpy(pt_DEDE_NUM_860026288," ")


# ---------------------------------------------------
# Identification de la provenance de l'article
# ---------------------------------------------------
trait_ok_860026288 = -1
# trait_ok : nb de passage en redistribution

trait_ok_860026288 = i_LireRedistCpt()
SI (trait_ok_860026288 > 0)
ALORS
	ENVELOPPE_NOK_860026288 = 0
FINSI

############################################################################
# Variables Fonctionnelles Globales
############################################################################

# SGTQS
pt_SGTQS_860026288 = i_LireEECSGTQS(g_ieec)

# EFFICACE
SI (( i_valid_field_n(g_iartin,$T3cap1) && !(i_get_art_field(g_iartin,$TAP))) || ( i_valid_field_n(g_iartin,$T3cap2) && !(i_get_art_field(g_iartin,$TAP2)) ) )
ALORS
	EFFICACE_860026288 = 1
SINON
	EFFICACE_860026288 = 0
FINSI

# OP_CSV1 & C_CSV1
res_860026288 = i_get_art_str(g_iartin, $ETAP, pt_buffer_860026288)
SI (i_strlen(pt_buffer_860026288) == 1)
ALORS
	res_860026288 = i_format_str2(pt_ETAP2_860026288, "0%s", pt_buffer_860026288, 0)
SINON
	i_strcpy(pt_ETAP2_860026288, pt_buffer_860026288)
FINSI
pt_OP_CSV1_860026288 = OP_CSV_860026233("MV", pt_ETAP2_860026288, i_get_art_field(g_iartin, $Tmvt7g3dc::dpivot))

SI (pt_OP_CSV1_860026288 == g_inull)
ALORS
	trace("ERREUR lie a la table externe pour C_CSV => Envoi en redistribution")
	code_errone_860026288 = 0xA0A0
	code_errone_860026288 = code_errone_860026288 + EFFICACE_860026288
	erreur_860026288 = i_PlvMessEmettre(8605, 2, g_iartin, "", 3,code_errone_860026288, "Tmvt7gdc/ OP_CSV", pt_ETAP2_860026288)
	SAUT DISTRI_ERR
FINSI
pt_C_CSV1_860026288 = C_CSV_860026233("MV", pt_ETAP2_860026288, i_get_art_field(g_iartin, $Tmvt7g3dc::dpivot))

SI (pt_C_CSV1_860026288 == g_inull)
ALORS
	trace("ERREUR lie a la table externe pour C_CSV => Envoi en redistribution" )
	code_errone_860026288 = 0xA0A0
	code_errone_860026288 = code_errone_860026288 + EFFICACE_860026288
	erreur_860026288 = i_PlvMessEmettre(8605, 2, g_iartin, "", 3, code_errone_860026288, "Tmvt7gdc/C_CSV", pt_ETAP2_860026288 )
	SAUT DISTRI_ERR
FINSI

############################################################################
# Envoi requetes Table de Distribution
############################################################################

SI EFFICACE_860026288
ALORS
	ddebut_860026288= i_get_art_field(g_iartin,$ddebut)

	SI (ddebut_860026288 == -1)
	ALORS
		code_errone_860026288 = 0xA080
		code_errone_860026288 = code_errone_860026288 + EFFICACE_860026288
		erreur_860026288 = i_PlvMessEmettre(8600, 2, g_iartin, "", 3, code_errone_860026288, C_Article_860026288, "i_get_art_field/ddebut")
		SAUT DISTRI_ERR
	FINSI
	gmt_date_860026288 = i_DHgetCe2gTime(NUMTAB_860026288, ZONEMETRO_860026288, ddebut_860026288)
	L_NDR_860026288 = i_get_art_fieldlength(g_iartin, $NDR)

	SI (L_NDR_860026288 % 2 == 0)
	ALORS
		L_NDR_860026288 = L_NDR_860026288 / 2
	SINON
		L_NDR_860026288 = L_NDR_860026288 / 2 + 1
	FINSI

	#---------------------------------------------------------------------------------------
	#Appel table VGA
	#-------------------------------------------------------------------------------------------------------
	instVGA_860026288 = i_LireInstanceECC(INST_VGA_860026288)

	SI (!instVGA_860026288)
	ALORS
		#trace("Pas d'instance pour VGA1 (table 8) !")
		erreur_860026288 = i_PlvMessEmettre(8501, 2, g_iartin,  "", 3, "VGA", C_Article_860026288, g_ieec)
		SAUT DISTRI_ERR
	FINSI
	#trace1("instVGA=<%d>", instVGA)

	# appel BDC dans ce cas pour obtenir TYPCOM normalisation par Pcode
	# : VGA reste nul si appel en preselection c-a-d
	# - DEDE_INF a 0x00 -> appel vers un service en 3BPQ
	# - DEDE_INF bits AB a 10 et 1er digit de DEDE_NUM entre 1 et 6

	SI (i_valid_field_n(g_iartin, $Tmvt7g3dc::INF_DEDE))
	ALORS
		dede_inf_860026288 = i_get_art_field(g_iartin,$Tmvt7g3dc::INF_DEDE)
	FINSI

	SI (i_valid_field_n(g_iartin, $Tmvt7g3dc::NDE))
	ALORS
		dede_num1_860026288 = g_iartin.NDE[0]
	FINSI

	ETAP_860026288 = i_get_art_field(g_iartin, $ETAP)
	#trace1(" **************  dede_inf = %d",  dede_inf)
	#trace1(" **************  dede_num1 = %d",  dede_num1)
	#trace1(" **************  ETAP = 0x%x",  ETAP)
	
	# Z=7 pour offre VGA
	SI (((dede_inf_860026288 & 0x80) == 0x80) && (dede_num1_860026288 < 8) && (ETAP_860026288 != 0x09))
	ALORS
		#masque#trace("Pas d appel VGA car pas eligible")
		SAUT FIN_VGA
	FINSI

	##############################################################################
	# Envoi Requetes Table de Distribution VGA
	#############################################################################
	#trace1("__LINE__ req appel VGA table <%x>", TD_VGA1)
	#trace2("__LINE__ req appel VGA NDR   <%s>",pt_temp, "")
	#trace1("__LINE__ req appel VGA date  Ox<%x>", gmt_date)
	#trace1("__LINE__ req appel VGA L_NDR <%x>", L_NDR)

	SI (i_EnvoiReqConsTabDist(TD_VGA1_860026288, gmt_date_860026288, i_get_art_fieldptr(g_iartin, $NDR), L_NDR_860026288, 0, 1) != 0)
	ALORS
		trace("__LINE__ req Erreur i_EnvoiReqConsTabDist VGA1")
		SAUT DISTRI_ERR
	FINSI
	erreur_860026288 = i_LireReqConsTabDist()
	#trace1("__LINE__ req RETOUR i_LireReqConsTabDist VGA1, erreur=<%d>",erreur)

	SI (erreur_860026288 != 0)
	ALORS
		trace1("__LINE__ req Erreur i_LireReqConsTabDist VGA1: <%d>", erreur_860026288)
		SAUT DISTRI_ERR
	FINSI

	val_860026288 = i_LireInfoECC(instVGA_860026288, 0)
	# test redist OK apres 1ER passage SI ( res > 0 && trait_ok !=0 )
	SI (val_860026288 != 0)
	ALORS
		erreur_860026288 = i_LireChaineInfo(val_860026288, 0, 6, pt_OFFRE_860026288)
		#trace2("__LINE__ req Resultat i_LireChaineInfo pour VGA1 (table8) <%s> pt_OFFRE", pt_OFFRE, "")
		erreur_860026288 = i_format_str2(pt_temp_860026288, "%s%s", "INj", pt_OFFRE_860026288)
		#trace2("__LINE__ appel table externe Inter cle  <%s> ", pt_temp, "")
		i_strcpy(pt_RES1_860026288, i_get_tab_field("Inter", gmt_date_860026288, pt_temp_860026288))
		#trace2("__LINE__ ... valeur <%s> pt_RES1", pt_RES1, "")

		SI (i_strcmp(pt_RES1_860026288, "VGT+") == 0)
		ALORS
			bVGTplus_860026288 = 1
			bVGA_860026288 = 0
			i_strcpy(pt_VGTplus_OF_860026288,  pt_OFFRE_860026288)
		SINON
			SI (i_strcmp(pt_RES1_860026288,"VGA") == 0)
			ALORS
				bVGA_860026288 = 1
				i_strcpy(pt_VGA_OF_860026288, pt_OFFRE_860026288)
			FINSI
		FINSI
	FINSI
#debut
	SI (i_EnvoiReqConsTabDist( TD_VGA2_860026288,gmt_date_860026288,i_get_art_fieldptr(g_iartin,$NDR),L_NDR_860026288,0,1) != 0)
	ALORS
		trace("__LINE__ req Erreur i_EnvoiReqConsTabDist VGA2")
		SAUT DISTRI_ERR
	FINSI
	erreur_860026288 = i_LireReqConsTabDist()
	#trace1("__LINE__ req RETOUR i_LireReqConsTabDist retour requette VGA2, erreur=<%d>",erreur)

	SI (erreur_860026288 != 0)
	ALORS
		trace1( "__LINE__ req Erreur i_LireReqConsTabDist VGA2: <%d>", erreur_860026288)
		SAUT DISTRI_ERR
	FINSI
	val_860026288= 0
	val_860026288 = i_LireInfoECC(instVGA_860026288, 0)
	#trace1("__LINE__ req RETOUR i_LireInfoECC requette VGA2, <%d>", val)

	SI (val_860026288 != 0)
	ALORS
		erreur_860026288 = i_LireChaineInfo(val_860026288, 0, 6, pt_OPERA_860026288)
		#trace2("__LINE__ req Resultat i_LireChaineInfo pour VGA2 (table3) <%s> pt_OPERA", pt_OPERA, "")
		SI (i_strcmp(pt_OPERA_860026288, g_inull))
		ALORS
			i_strcpy(pt_CodOperVG_860026288, pt_OPERA_860026288)
			b_CodOperVG_860026288 = 1
			SI ((bVGA_860026288 == 1) || (bVGTplus_860026288 == 1))
			ALORS
				SI (bVGTplus_860026288 == 1)
				ALORS
					i_strcpy(pt_VGTplus_OP_860026288, pt_OPERA_860026288)
				SINON
					i_strcpy(pt_VGA_OP_860026288, pt_OPERA_860026288)
				FINSI
			FINSI
		FINSI
	FINSI

	SI (b_CodOperVG_860026288)
	ALORS
		i_strcpy(pt_TEMP1_860026288,"")
		erreur_860026288 = i_format_str2( pt_TEMP1_860026288, "%s%s", "INm", pt_CodOperVG_860026288)
		SI ( i_strcmp( i_get_tab_field("Inter", gmt_date_860026288, pt_TEMP1_860026288),g_inull) != 0 )
		ALORS
			b_OperNBE_860026288 = 1
		FINSI
	FINSI

	POINT FIN_VGA

	res_860026288 = i_EnvoiReqConsTabDistDouble(TD_Fixe, TD_Inter, gmt_date_860026288, i_get_art_fieldptr(g_iartin, $NDR), L_NDR_860026288, L_NDR_860026288, 1, 0, 1)

	SI (res_860026288 !=0)
	ALORS
		#trace1("Erreur i_EnvoiReqConsTabDistDouble %d", res)
		bREDIST_860026288 = 1
		i_strcpy(pt_LIBELREDIST_860026288, "i_EnvoiReqConsTabDistDouble")
	FINSI
FINSI

############################################################################
# Recherche Instances des ECC
############################################################################

# SYMPHONIE
instSYMPHO_860026288= i_LireInstanceECC(C_InstSYMP_860026288)
SI !(instSYMPHO_860026288 > 0)
ALORS
	code_errone_860026288 = 0xA0B0
	code_errone_860026288 = code_errone_860026288 + EFFICACE_860026288
	erreur_860026288 = i_PlvMessEmettre(8601, 2, g_iartin, "", 3, code_errone_860026288, C_InstSYMP_860026288, C_Article_860026288)
	SAUT DISTRI_ERR
FINSI

SI (EFFICACE_860026288 && !bREDIST_860026288)
ALORS
	# FE
	instFE_860026288= i_LireInstanceECC(C_InstFE_860026288)
	SI !(instFE_860026288 > 0)
	ALORS
		code_errone_860026288 = 0xA0B0
		code_errone_860026288 = code_errone_860026288 + EFFICACE_860026288
		erreur_860026288 = i_PlvMessEmettre(8601, 2, g_iartin, "", 3, code_errone_860026288, C_InstFE_860026288, C_Article_860026288)
		SAUT DISTRI_ERR
	FINSI

	# TRAFIC
	instTRAFIC_860026288= i_LireInstanceECC(C_InstTRAFIC_860026288)
	SI !(instTRAFIC_860026288 > 0)
	ALORS
		code_errone_860026288 = 0xA0B0
		code_errone_860026288 = code_errone_860026288 + EFFICACE_860026288
		erreur_860026288 = i_PlvMessEmettre(8601, 2, g_iartin, "", 3, code_errone_860026288, C_InstTRAFIC_860026288, C_Article_860026288)
		SAUT DISTRI_ERR
	FINSI

# G3R16 suppression ECC : ALLOFACT

#----------------------------
# ajout ECC  FERPV
#----------------------------

	instFERPV_860026288 = i_LireInstanceECC(C_instFERPV_860026288)
	SI (!instFERPV_860026288)
	ALORS
		code_errone_860026288 = 0xA0B0
		code_errone_860026288 = code_errone_860026288 + EFFICACE_860026288
		erreur_860026288 = i_PlvMessEmettre(8601, 2, g_iartin, "", 3, code_errone_860026288, C_instFERPV_860026288, C_Article_860026288)
		SAUT DISTRI_ERR
	FINSI
FINSI

# CENTAUREVG
SI (bVGA_860026288 || bVGTplus_860026288)
ALORS
	instCENTAUREVG_860026288= i_LireInstanceECC(C_InstCENTVG_860026288)
	#trace1("__LINE__ distri instCENTAUREVG=<%d>",instCENTAUREVG)
	SI (!instCENTAUREVG_860026288)
	ALORS
		trace("Pas d'instance pour CENTAUREVG!")
		bCENTVG_860026288 = 0
		code_errone_860026288 = 0xA0B0
		code_errone_860026288 = code_errone_860026288 + EFFICACE_860026288
		erreur_860026288 = i_PlvMessEmettre(8601, 2, g_iartin, "", 3, code_errone_860026288, C_InstCENTVG_860026288, C_Article_860026288)
		SAUT DISTRI_ERR
	SINON
		bCENTVG_860026288 = 1
	FINSI
FINSI

############################################################################
# Duplication Symphonie
############################################################################

SI (i_dup_art_id(g_iartin, g_iartout))
ALORS
	code_errone_860026288 = 0xA0D0
	code_errone_860026288 = code_errone_860026288 + EFFICACE_860026288
	erreur_860026288 = i_PlvMessEmettre(8602, 2, g_iartin, "",  3,code_errone_860026288, C_Tsymphomvt7g3_860026288, C_Article_860026288)
	SAUT DISTRI_ERR
FINSI

res_860026288 = i_rename_art(g_iartout, C_Tsymphomvt7g3_860026288)

# CCD
res_860026288 = i_ajoutChampNum(g_iartout, $Tsymphomvt7g3::T4ccd, $Tsymphomvt7g3::CCD, 0)

# SGTQS
res_860026288 = i_ajoutChampNum(g_iartout, $Tsymphomvt7g3::T4sgtqs, $Tsymphomvt7g3::SGTQS, 0)

# ECC_FACT
res_860026288 = i_ajoutChampNum(g_iartout, $Tsymphomvt7g3::T4eccfact, $Tsymphomvt7g3::ECC_FACT, 0)

SI (EFFICACE_860026288 == 1 )
ALORS
	#NBCOD
	res_860026288 = i_ajoutChampNum(g_iartout,$Tsymphomvt7g3::T4NBCOD, $Tsymphomvt7g3::NBCOD, 0)

	#CSV
	res_860026288 = i_ajoutChampNum(g_iartout, $Tsymphomvt7g3::T4CSV,$Tsymphomvt7g3::CSV, 0)
FINSI

############################################################################
# Attente requetes Table de Distribution
############################################################################

SI (EFFICACE_860026288 && !bREDIST_860026288)
ALORS
	res_860026288 = i_LireReqConsTabDist()

	#trace1("RETOUR i_LireReqConsTabDist, erreur=<%d>",res)
	SI (res_860026288 != 0)
	ALORS
		i_strcpy(pt_LIBELREDIST_860026288, "i_LireReqConsTabDist")
		bREDIST_860026288 = 1
	FINSI
FINSI

############################################################################
# Critere de distribution
############################################################################

# ajout de l'EEC SYMPHONIE a la liste courante des EEC
res_860026288 = i_AjouterCouranteECC(instSYMPHO_860026288)

#---------------------------------------------------------------------------
# Criteres communs
#---------------------------------------------------------------------------

SI EFFICACE_860026288 && !bREDIST_860026288
ALORS
	#-------------------------------------------------------------
	# FE
	#-------------------------------------------------------------
	res_860026288 = i_LireInfoECC(instFE_860026288, 0)
	SI (res_860026288 != 0) && !bVGA_860026288 && !bVGTplus_860026288
	ALORS
		res_860026288 = i_AjouterCouranteECC(instFE_860026288)
		#-----------------------------------------------------
		# DM
		#-----------------------------------------------------
		res_860026288 = i_LireInfoECC(instTRAFIC_860026288, 0)
		SI (res_860026288 != 0)
		ALORS
			erreur_860026288 = i_LireChaineInfo(res_860026288, 0, 3, pt_InfoCompl_860026288)
			erreur_860026288 = i_format_str2(pt_TRAF_DM_860026288, "DM%s", pt_InfoCompl_860026288, 0)
			instDM_860026288 = i_LireInstanceECC(pt_TRAF_DM_860026288)
			SI (!instDM_860026288)
			ALORS
				code_errone_860026288 = 0xA0B0
				code_errone_860026288 = code_errone_860026288 + EFFICACE_860026288
				erreur_860026288 = i_PlvMessEmettre(8601, 2, g_iartin, "", 3, code_errone_860026288, pt_TRAF_DM_860026288, C_Article_860026288)
				SAUT DISTRI_ERR
			FINSI
			dizaine_860026288 = i_LireEntierInfo(res_860026288, 0, 1)
			unite_860026288 = i_LireEntierInfo(res_860026288, 1, 1)
			cfr_860026288 = (dizaine_860026288 & 0x0F) * 10 + (unite_860026288 & 0x0F)
			SI (ENVELOPPE_NOK_860026288)
			ALORS
				#trace("__FILE__:__LINE__ ======> Creation enveloppe CFR/FE")
				ENVELOPPE_NOK_860026288 = i_add_opt("E_Tmvt7g3dc")
				# mise en conformite de la gestion de l'enveloppe
			FINSI
			res_860026288 = i_set_attr_val_n($E_Tmvt7g3dc::CFR, cfr_860026288)
			#trace1("__FILE__:__LINE__ ======> code CFR : <%d> ", cfr)
			#trace1("__FILE__:__LINE__ ======> ENVELOPPE_NOK : <%d> ", ENVELOPPE_NOK)
			res_860026288 = i_AjouterCouranteECC(instDM_860026288)
		SINON
			trace("Envoi en redistribution")
			i_strcpy(pt_LIBELREDIST_860026288,  "Indicatif inconnu de MAJ2G")
			bREDIST_860026288 = 1
			SAUT AVANT_REDIST
		FINSI
	SINON
		#-------------------------------------------------------
		# TRAFIC
		#-------------------------------------------------------
		res_860026288 = i_LireInfoECC(instTRAFIC_860026288, 0)
		SI (res_860026288 != 0)
		ALORS
			res_860026288 = i_LireChaineInfo(res_860026288, 0, 3, pt_InfoCompl_860026288)
			res_860026288 = i_format_str2(pt_TRAF_DM_860026288, "TRAF%s", pt_InfoCompl_860026288, 0)
			instTRAFIC_860026288= i_LireInstanceECC(pt_TRAF_DM_860026288)
			SI (!instTRAFIC_860026288)
			ALORS
				code_errone_860026288 = 0xA0B0
				code_errone_860026288 = code_errone_860026288 + EFFICACE_860026288
				erreur_860026288 = i_PlvMessEmettre(8601, 2, g_iartin, "", 3, code_errone_860026288, pt_TRAF_DM_860026288, C_Article_860026288)
				SAUT DISTRI_ERR
			FINSI
			res_860026288 = i_AjouterCouranteECC(instTRAFIC_860026288)
			bTRAFIC_860026288 = 1
		SINON
			trace("Envoi en redistribution")
			i_strcpy(pt_LIBELREDIST_860026288,  "Indicatif inconnu de MAJ2G")
			bREDIST_860026288 = 1
			SAUT AVANT_REDIST
		FINSI
	FINSI

	# G3R16 suppression ECC : ALLOFACT

	#----------------------------------------------------------------------------
	# Ajout de CENTAUREVG
	#----------------------------------------------------------------------------

	SI (((bVGTplus_860026288 == 1) || (bVGA_860026288 == 1)) && bTRAFIC_860026288 == 1)
	ALORS
		SI (i_AjouterCouranteECC(instCENTAUREVG_860026288) < 0)
		ALORS
			trace("Retour de i_AjouterCouranteECC en erreur pour CENTAUREVG!")
			SAUT DISTRI_ERR
		FINSI
	FINSI

	#--------------------------
	# FERPV
	#-------------------------
	SI (bTRAFIC_860026288 == 1 && b_OperNBE_860026288 == 1 && bVGTplus_860026288 == 1)
	ALORS

		erreur_860026288 = i_AjouterCouranteECC(instFERPV_860026288)
		#trace(">>>__LINE__>>>AjouterCouranteECC instFERPV")
	FINSI
FINSI

############################################################################
# Validation de la liste des ECCs destinatrices
############################################################################

res_860026288 = i_ValiderListeECC(0,0,0,0)

############################################################################
# Mises au format
############################################################################

#---------------------------------------------------------------------------
# Valeurs communes
#---------------------------------------------------------------------------

SI EFFICACE_860026288 && !bREDIST_860026288
ALORS
	# date_locale
	res_860026288 = i_get_art_field(g_iartin, $DATE)

	SI (res_860026288 == -1)
	ALORS
		code_errone_860026288 = 0xA080
		code_errone_860026288 = code_errone_860026288 + EFFICACE_860026288
		erreur_860026288 = i_PlvMessEmettre(8600, 2, g_iartin, "", 3, code_errone_860026288, C_Article_860026288, "i_get_art_field/DATE")
		SAUT DISTRI_ERR
	FINSI
	date_locale_860026288= i_date_locale(g_ieec, g_iartin,res_860026288)

	SI (date_locale_860026288 == -1)
	ALORS
		code_errone_860026288 = 0xA080
		code_errone_860026288 = code_errone_860026288 + EFFICACE_860026288
		erreur_860026288 = i_PlvMessEmettre(8600, 2, g_iartin,  "", 3,code_errone_860026288, C_Article_860026288, "i_get_art_field/DATE")
		SAUT DISTRI_ERR
	FINSI

	# Initialisation des variables de presence a l etat non present
	T3cap1_OK_860026288 = 0
	NUMNOS_OK_860026288 = 0
	T3coca_OK_860026288 = 0
	T3cocav_OK_860026288 = 0
	T3idav_OK_860026288 = 0
	f3BPQ_OK_860026288 = 0

	# NDR
	res_860026288 = i_get_art_str(g_iartin, $NDR, pt_NDR_860026288)
	i_replace_str(pt_NDR_860026288, "BCDE", "AJSC", pt_NDR_860026288)

	# NDE
	res_860026288 = i_get_art_str(g_iartin, $NDE, pt_NDE_860026288)
	i_replace_str(pt_NDE_860026288, "BC", "*#", pt_NDE_860026288)
	SI (i_strlen(pt_NDE_860026288) == 10)
	ALORS
		i_get_sub_str(pt_NDE_860026288, 1, -1, pt_NDE_860026288)
	FINSI
	SI ((i_get_art_fieldtab(g_iartin, $NDE,0) == 3 ) && (i_strlen(pt_NDE_860026288) == 4))
	ALORS
		f3BPQ_OK_860026288 = 1
	FINSI

	# CAX,TAX SUP et DUREE
	SI i_valid_field_n(g_iartin, $T3cap1)
	ALORS
		T3cap1_OK_860026288 = 1
		CAX_860026288= i_get_art_field(g_iartin, $CAX)
		TAXE_860026288= i_get_art_field(g_iartin, $TAXE)
		DUREE_860026288= i_get_art_field(g_iartin, $DUREE)
	SINON
		SI i_valid_field_n(g_iartin, $T3cap2)
		ALORS
			CAX_860026288 = i_get_art_field(g_iartin, $CAX2)
			TAXE_860026288 = i_get_art_field(g_iartin, $TAXE2)
			SUP_860026288 = i_get_art_field(g_iartin, $SUP2)
			DUREE_860026288 = i_get_art_field(g_iartin, $DUREE2)
		FINSI
	FINSI

	# NUMNOS
	SI i_valid_field_n(g_iartin, $NUMNOS)
	ALORS
		NUMNOS_OK_860026288 = 1
		res_860026288 = i_get_art_str(g_iartin, $NUMNOS, pt_NUMNOS_860026288)
	FINSI

	# BETA
	SI i_valid_field_n(g_iartin, $Tmvt7g3dc::T3coca)
	ALORS
		T3coca_OK_860026288 = 1
		res_860026288 = i_get_art_str(g_iartin, $Tmvt7g3dc::BETA, pt_BETA_860026288)
	FINSI

	# BETAV
	SI i_valid_field_n(g_iartin, $Tmvt7g3dc::T3cocav)
	ALORS
		T3cocav_OK_860026288 = 1
		res_860026288 = i_get_art_str(g_iartin, $Tmvt7g3dc::BETAV, pt_BETAV_860026288)
	FINSI

	# INF_IDAV,NUM_IDAV
	SI i_valid_field_n(g_iartin, $Tmvt7g3dc::T3idav)
	ALORS
		T3idav_OK_860026288 = 1
		INF_IDAV_860026288 = i_get_art_field(g_iartin, $Tmvt7g3dc::INF_IDAV)
		res_860026288 = i_get_art_str(g_iartin, $Tmvt7g3dc::NUM_IDAV, pt_NUM_IDAV_860026288)
	FINSI
FINSI

# factorisation du calcul de DEDE_NUM pour Tfe et Tfe_rpv
SI (f3BPQ_OK_860026288 == 1)
ALORS
	SI (ETAP_860026288 == 0x09)
	ALORS
		res_860026288 = i_format_str2(pt_DEDE_NUM_860026288, "%s%s", "*76*", pt_NDE_860026288)
	SINON
		SI (ETAP_860026288 == 0x0B)
		ALORS
			res_860026288 = i_format_str2(pt_DEDE_NUM_860026288, "%s%s", "*77*", pt_NDE_860026288)
		SINON
			i_strcpy(pt_DEDE_NUM_860026288,pt_NDE_860026288)
		FINSI
	FINSI
SINON
	SI (ETAP_860026288 == 0x09)
	ALORS
		res_860026288 = i_format_str2(pt_DEDE_NUM_860026288, "%s0%s", "*76*", pt_NDE_860026288)
	SINON
		SI (ETAP_860026288 == 0x0B)
		ALORS
			res_860026288 = i_format_str2(pt_DEDE_NUM_860026288, "%s0%s", "*77*", pt_NDE_860026288)
		SINON
			res_860026288 = i_format_str2(pt_DEDE_NUM_860026288, "0%s", pt_NDE_860026288, 0)
		FINSI
	FINSI
FINSI

#---------------------------------------------------------------------------
# FE
#---------------------------------------------------------------------------

SI !(i_ChercherCouranteECC(instFE_860026288)) && !bREDIST_860026288
ALORS
	# ECC_FACT
	i_strcpy(pt_nomECCFact_860026288, "FE")

	# champ DOMAINE pour DM:
	i_strcpy(pt_domaine_DM_860026288, "05")

	# utilisation de la table de duplication
	SI (i_dup_art_dest(g_iartin, g_iartout2, C_Tfe_860026288))
	ALORS
		code_errone_860026288 = 0xA0D0
		code_errone_860026288 = code_errone_860026288 + EFFICACE_860026288
		erreur_860026288 = i_PlvMessEmettre(8602, 2, g_iartin, "", 3, code_errone_860026288, C_Tfe_860026288, C_Article_860026288)
		SAUT DISTRI_ERR
	FINSI

	# SERVICE
	res_860026288 = i_set_art_str(g_iartout2, $Tfe::SERVICE, "36")

	# IDUS_NUM
	res_860026288 = i_set_art_str(g_iartout2, $Tfe::IDUS_NUM, pt_NDR_860026288)

	# DEDE_NUM : est valorise avec pt_DEDE_NUM calcule plus haut
	res_860026288 = i_set_art_str(g_iartout2, $Tfe::DEDE_NUM, pt_DEDE_NUM_860026288)

	# DATE
	res_860026288 = i_set_art_field(g_iartout2, $Tfe::DATE, date_locale_860026288)

	# DUREE
	res_860026288 = i_set_art_field(g_iartout2, $Tfe::DUREE, DUREE_860026288)

	# CAX,TAX et SUP
	SI T3cap1_OK_860026288
	ALORS
		res_860026288 = i_memset_field_n(g_iartout2, $Tfe::SUP, 0xF0)
	SINON
		res_860026288 = i_set_art_field(g_iartout2, $Tfe::SUP, SUP_860026288)
	FINSI
	res_860026288 = i_set_art_field(g_iartout2, $Tfe::CAX, CAX_860026288)
	res_860026288 = i_set_art_field(g_iartout2, $Tfe::TAX, TAXE_860026288)

	# NDS_INF
	SI i_valid_field_n(g_iartin, $Tmvt7g3dc::T3nos)
	ALORS
		INF_NOS_860026288 = i_get_art_field(g_iartin, $Tmvt7g3dc::INFNOS)
		res_860026288 = i_set_art_field(g_iartout2, $Tfe::NDS_INF, INF_NOS_860026288)
	SINON
		res_860026288 = i_memset_field_n(g_iartout2, $Tfe::NDS_INF, 0xF0)
	FINSI

	# NDS_NUM
	SI NUMNOS_OK_860026288
	ALORS
		res_860026288 = i_set_art_str(g_iartout2, $Tfe::NDS_NUM, pt_NUMNOS_860026288)
	SINON
		res_860026288 = i_memset_field_n(g_iartout2, $Tfe::NDS_NUM, 0x40)
	FINSI

	# Nb_CSV  C_CSV1 & OP_CSV1
	res_860026288 = i_set_art_field(g_iartout2, $Tfe::NB_CSV, 1)
	res_860026288 = i_set_art_str(g_iartout2, $Tfe::C_CSV1, pt_C_CSV1_860026288)
	res_860026288 = i_set_art_str(g_iartout2, $Tfe::OP_CSV1, pt_OP_CSV1_860026288)

	# COCA
	SI T3coca_OK_860026288
	ALORS
		res_860026288 = i_set_art_str(g_iartout2, $Tfe::COCA, pt_BETA_860026288)
	FINSI

	# COCAV
	SI T3cocav_OK_860026288
	ALORS
		res_860026288 = i_set_art_str(g_iartout2, $Tfe::COCAV, pt_BETAV_860026288)
	FINSI

	# IDAV_INF et IDAV_NUM
	SI T3idav_OK_860026288
	ALORS
		res_860026288 = i_set_art_field(g_iartout2, $Tfe::IDAV_INF, INF_IDAV_860026288)
		res_860026288 = i_set_art_str(g_iartout2, $Tfe::IDAV_NUM, pt_NUM_IDAV_860026288)
	SINON
		res_860026288 = i_memset_field_n(g_iartout2, $Tfe::IDAV_INF, 0xF0)
		res_860026288 = i_memset_field_n(g_iartout2, $Tfe::IDAV_NUM, 0x40)
	FINSI
FINSI

#----------------
#FERPV
#----------------

SI ( !i_ChercherCouranteECC(instFERPV_860026288) )
ALORS
	SI (i_dup_art_dest(g_iartin,g_iartout7,C_Tferpv_860026288))
	ALORS
		#trace(">>>__LINE__>>>**********Erreur duplication Tv2oip vers FERPV")
		code_errone_860026288 = 0xA0D0
		code_errone_860026288 = code_errone_860026288 + EFFICACE_860026288
		erreur_860026288 = i_PlvMessEmettre(8602,2,g_iartin,"",3,code_errone_860026288,C_Tferpv_860026288,C_Article_860026288)
		SAUT  DISTRI_ERR
	FINSI

	# ajout et enrichissement enveloppe
	erreur_860026288 = i_add_opt("E_RPV")
	res_860026288 = i_get_art_field(g_iartin, $Tmvt7g3dc::dfin)
	erreur_860026288 = i_set_attr_val_n( $E_RPV::DATE_M, res_860026288)
	res_860026288 = i_get_art_field(g_iartin, $Tmvt7g3dc::DATE)
	erreur_860026288 = i_set_attr_val_n( $E_RPV::DATE_L, res_860026288)

	#SERVICE
	erreur_860026288 = i_set_art_str(g_iartout7, $Tfe_rpv::SERVICE, "8")

	#SOURCE
	SI (b_OperNBE_860026288 && bVGTplus_860026288)
	ALORS
		erreur_860026288 = i_set_art_str(g_iartout7, $Tfe_rpv::SOURCE, "19")
	FINSI

	#TYPCOM duplicat : ""

	#NUMDR
	erreur_860026288 = i_format_str2(pt_buffer_860026288,"%s%s","0",pt_NDR_860026288)
	erreur_860026288 = i_set_art_str(g_iartout7,$Tfe_rpv::NUMDDR,pt_buffer_860026288)

	# NUMDDE : est valorise avec pt_DEDE_NUM calcule plus haut
	res_860026288 = i_set_art_str(g_iartout7, $Tfe_rpv::NUMDDE, pt_DEDE_NUM_860026288)

	#DEDUT
	res_860026288 = i_set_art_field(g_iartout7, $Tfe_rpv::DEBUT, date_locale_860026288)

	#DUREE
	res_860026288=i_set_art_field(g_iartout7, $Tfe_rpv::DUREE,DUREE_860026288)

	#NBUT
	res_860026288 = i_set_art_field(g_iartout7, $Tfe_rpv::NBUT, TAXE_860026288)

	#MTHSTD duplicat : "0"

	#CANAL duplicat : "000"

	#C_CSV1 OP_CSV1
	res_860026288 = i_set_art_str(g_iartout7, $Tfe_rpv::C_CSV1, pt_C_CSV1_860026288)
	res_860026288 = i_set_art_str(g_iartout7, $Tfe_rpv::OP_CSV1, pt_OP_CSV1_860026288)

	# duplication des champs  INFDDE  FILLER
	#INFDEDE	000
	#Filler  (caractere espace)
FINSI

#---------------------------------------------------------------------------
# DM
#---------------------------------------------------------------------------

SI !(i_ChercherCouranteECC(instDM_860026288)) && !bREDIST_860026288
ALORS
	# utilisation de la table de duplication
	SI (i_dup_art_dest(g_iartin, g_iartout3, C_Tdelta_minute_860026288))
	ALORS
		code_errone_860026288 = 0xA0D0
		code_errone_860026288 = code_errone_860026288 + EFFICACE_860026288
		erreur_860026288 = i_PlvMessEmettre(8602, 2, g_iartin, "", 3, code_errone_860026288, C_Tdelta_minute_860026288, C_Article_860026288)
		SAUT DISTRI_ERR
	FINSI

	# DOMAINE
	res_860026288 = i_set_art_str(g_iartout3, $Tdelta_minute::DOMAINE, "05")

	# SERVICE
	res_860026288 = i_set_art_str(g_iartout3, $Tdelta_minute::SERVICE, "36")

	# IDUS_NUM
	res_860026288 = i_set_art_str(g_iartout3, $Tdelta_minute::IDUS_NUM, pt_NDR_860026288)

	# DEDE_NUM
	SI (f3BPQ_OK_860026288 == 1)
	ALORS
		SI (ETAP_860026288 == 0x09)
		ALORS
			res_860026288 = i_format_str2(pt_buffer_860026288, "%s%s", "*76*", pt_NDE_860026288)
			res_860026288 = i_set_art_str(g_iartout3, $Tdelta_minute::DEDE_NUM, pt_buffer_860026288)
		SINON
			SI (ETAP_860026288 == 0x0B)
			ALORS
				res_860026288 = i_format_str2(pt_buffer_860026288, "%s%s", "*77*", pt_NDE_860026288)
				res_860026288 = i_set_art_str(g_iartout3, $Tdelta_minute::DEDE_NUM, pt_buffer_860026288)
			SINON
				res_860026288 = i_set_art_str(g_iartout3, $Tdelta_minute::DEDE_NUM, pt_NDE_860026288)
			FINSI
		FINSI
	SINON
		SI (ETAP_860026288 == 0x09)
		ALORS
			res_860026288 = i_format_str2(pt_buffer_860026288, "%s0%s", "*76*", pt_NDE_860026288)
			res_860026288 = i_set_art_str(g_iartout3, $Tdelta_minute::DEDE_NUM, pt_buffer_860026288)
		SINON
			SI (ETAP_860026288 == 0x0B)
			ALORS
				res_860026288 = i_format_str2(pt_buffer_860026288, "%s0%s", "*77*", pt_NDE_860026288)
				res_860026288 = i_set_art_str(g_iartout3, $Tdelta_minute::DEDE_NUM, pt_buffer_860026288)
			SINON
				res_860026288 = i_format_str2(pt_buffer_860026288, "0%s", pt_NDE_860026288, 0)
				res_860026288 = i_set_art_str(g_iartout3, $Tdelta_minute::DEDE_NUM, pt_buffer_860026288)
			FINSI
		FINSI
	FINSI

	# DATE
	res_860026288 = i_set_art_field(g_iartout3, $Tdelta_minute::DATE, date_locale_860026288)

	# DUREE
	res_860026288 = i_set_art_field(g_iartout3, $Tdelta_minute::DUREE, DUREE_860026288)

	# CAX,TAX et SUP
	SI T3cap1_OK_860026288
	ALORS
		res_860026288 = i_memset_field_n(g_iartout3, $Tdelta_minute::SUP, 0xF0)
	SINON
		res_860026288 = i_set_art_field(g_iartout3, $Tdelta_minute::SUP, SUP_860026288)
	FINSI
	res_860026288 = i_set_art_field(g_iartout3, $Tdelta_minute::CAX, CAX_860026288)
	res_860026288 = i_set_art_field(g_iartout3, $Tdelta_minute::TAX, TAXE_860026288)

	# NDS_NUM
	SI NUMNOS_OK_860026288
	ALORS
		res_860026288 = i_set_art_str(g_iartout3, $Tdelta_minute::NDS_NUM, pt_NUMNOS_860026288)
	SINON
		res_860026288 = i_memset_field_n(g_iartout3, $Tdelta_minute::NDS_NUM, 0x40)
	FINSI

	# Nb_CSV  C_CSV1 & OP_CSV1
	res_860026288 = i_set_art_field(g_iartout3, $Tdelta_minute::NB_CSV, 1)
	res_860026288 = i_set_art_str(g_iartout3, $Tdelta_minute::C_CSV1, pt_C_CSV1_860026288)
	res_860026288 = i_set_art_str(g_iartout3, $Tdelta_minute::OP_CSV1, pt_OP_CSV1_860026288)

	# STY
	res_860026288 = i_transformer_bits(g_iartin, $STY, "FV", pt_buffer_860026288)
	res_860026288 = i_set_art_str(g_iartout3, $Tdelta_minute::STY, pt_buffer_860026288)

	# COCA
	SI T3coca_OK_860026288
	ALORS
		res_860026288 = i_set_art_str(g_iartout3, $Tdelta_minute::COCA, pt_BETA_860026288)
	FINSI

	# COCAV
	SI T3cocav_OK_860026288
	ALORS
		res_860026288 = i_set_art_str(g_iartout3, $Tdelta_minute::COCAV, pt_BETAV_860026288)
	FINSI

	# IDAV_INF etIDAV_ NUM
	SI T3idav_OK_860026288
	ALORS
		res_860026288 = i_set_art_field(g_iartout3, $Tdelta_minute::IDAV_INF, INF_IDAV_860026288)
		res_860026288 = i_set_art_str(g_iartout3, $Tdelta_minute::IDAV_NUM, pt_NUM_IDAV_860026288)
	SINON
		res_860026288 = i_memset_field_n(g_iartout3, $Tdelta_minute::IDAV_INF, 0xF0)
		res_860026288 = i_memset_field_n(g_iartout3, $Tdelta_minute::IDAV_NUM, 0x40)
	FINSI

	# SGTQS
	res_860026288 = i_set_art_str(g_iartout3, $Tdelta_minute::SGTQS, pt_SGTQS_860026288)
FINSI

#---------------------------------------------------------------------------
# TRAFIC
#---------------------------------------------------------------------------

SI !(i_ChercherCouranteECC(instTRAFIC_860026288)) && !bREDIST_860026288
ALORS
	# ECC_FACT
	i_strcpy(pt_nomECCFact_860026288, pt_TRAF_DM_860026288)

	# utilisation de la table de duplication
	SI (i_dup_art_dest(g_iartin, g_iartout4, C_Ttrafic_860026288))
	ALORS
		code_errone_860026288 = 0xA0D0
		code_errone_860026288 = code_errone_860026288 + EFFICACE_860026288
		erreur_860026288 = i_PlvMessEmettre(8602, 2, g_iartin, "", 3, code_errone_860026288, C_Ttrafic_860026288, C_Article_860026288)
	FINSI

	# DOMAINE
	res_860026288 = i_set_art_str(g_iartout4, $Ttrafic::DOMAINE, "05")

	# SERVICE
	res_860026288 = i_set_art_str(g_iartout4, $Ttrafic::SERVICE, "36")

	# IDUS_NUM
	res_860026288 = i_set_art_str(g_iartout4, $Ttrafic::IDUS_NUM, pt_NDR_860026288)

	# DEDE_INF
	SI ((f3BPQ_OK_860026288 == 1) || (ETAP_860026288 == 0x09) || (ETAP_860026288 == 0x0B))
	ALORS
		res_860026288 = i_memset_field_n(g_iartout4, $Ttrafic::DEDE_INF, 0xF0)
	FINSI

	# DEDE_NUM
	SI (ETAP_860026288 == 0x09)
	ALORS
		res_860026288 = i_format_str2(pt_buffer_860026288, "%s%s", "*76*0", pt_NDE_860026288)
		res_860026288 = i_set_art_str(g_iartout4, $Ttrafic::DEDE_NUM, pt_buffer_860026288)
	FINSI
	SI (ETAP_860026288 == 0x0B)
	ALORS
		res_860026288 = i_format_str2(pt_buffer_860026288, "%s%s", "*77*0", pt_NDE_860026288)
		res_860026288 = i_set_art_str(g_iartout4, $Ttrafic::DEDE_NUM, pt_buffer_860026288)
	FINSI
	SI ((ETAP_860026288 != 0x09)&&(ETAP_860026288 != 0x0B))
	ALORS
		res_860026288 = i_set_art_str(g_iartout4, $Ttrafic::DEDE_NUM, pt_NDE_860026288)
	FINSI

	# DATE
	res_860026288 = i_set_art_field(g_iartout4, $Ttrafic::DATE, date_locale_860026288)

	# DUREE
	res_860026288 = i_set_art_field(g_iartout4, $Ttrafic::DUREE, DUREE_860026288)

	# CAX,TAX et SUP
	SI T3cap1_OK_860026288
	ALORS
		res_860026288 = i_memset_field_n(g_iartout4, $Ttrafic::SUP, 0xF0)
	SINON
		res_860026288 = i_set_art_field(g_iartout4, $Ttrafic::SUP, SUP_860026288)
	FINSI
	res_860026288 = i_set_art_field(g_iartout4, $Ttrafic::CAX, CAX_860026288)
	res_860026288 = i_set_art_field(g_iartout4, $Ttrafic::TAX, TAXE_860026288)

	# NDS_NUM
	SI NUMNOS_OK_860026288
	ALORS
		res_860026288 = i_set_art_str(g_iartout4, $Ttrafic::NDS_NUM, pt_NUMNOS_860026288)
	SINON
		res_860026288 = i_memset_field_n(g_iartout4, $Ttrafic::NDS_NUM, 0x40)
	FINSI

	# Nb_CSV  C_CSV1 & OP_CSV1
	res_860026288 = i_set_art_field(g_iartout4, $Ttrafic::NB_CSV, 1)
	res_860026288 = i_set_art_str(g_iartout4, $Ttrafic::C_CSV1, pt_C_CSV1_860026288)
	res_860026288 = i_set_art_str(g_iartout4, $Ttrafic::OP_CSV1, pt_OP_CSV1_860026288)

	# STY (modification : 11/05/01i by HHU)
	res_860026288 = i_transformer_bits(g_iartin,$STY, "FV", pt_buffer_860026288)
	res_860026288 = i_set_art_str(g_iartout4, $Ttrafic::STY, pt_buffer_860026288)

	# COCA
	SI T3coca_OK_860026288
	ALORS
		res_860026288 = i_set_art_str(g_iartout4, $Ttrafic::COCA, pt_BETA_860026288)
	FINSI

	# COCAV
	SI T3cocav_OK_860026288
	ALORS
		res_860026288 = i_set_art_str(g_iartout4, $Ttrafic::COCAV, pt_BETAV_860026288)
	FINSI

	# IDAV_INF IDAV_ NUM
	SI T3idav_OK_860026288
	ALORS
		res_860026288 = i_set_art_field(g_iartout4, $Ttrafic::IDAV_INF, INF_IDAV_860026288)
		res_860026288 = i_set_art_str(g_iartout4, $Ttrafic::IDAV_NUM, pt_NUM_IDAV_860026288)
	SINON
		res_860026288 = i_memset_field_n(g_iartout4, $Ttrafic::IDAV_INF, 0xF0)
		res_860026288 = i_memset_field_n(g_iartout4, $Ttrafic::IDAV_NUM, 0x40)
	FINSI

	# SGTQS
	res_860026288 = i_set_art_str(g_iartout4, $Ttrafic::SGTQS, pt_SGTQS_860026288)

	# champ OFFRE et champ OPERATEUR
	SI (bVGTplus_860026288)
	ALORS
		erreur_860026288 = i_set_art_str(g_iartout4, $Ttrafic::OFFRE, pt_VGTplus_OF_860026288)
		erreur_860026288 = i_set_art_str(g_iartout4, $Ttrafic::OPERATEUR, pt_VGTplus_OP_860026288)
	SINON
		SI (bVGA_860026288)
		ALORS
			erreur_860026288 = i_set_art_str(g_iartout4, $Ttrafic::OFFRE, pt_VGA_OF_860026288)
			erreur_860026288 = i_set_art_str(g_iartout4, $Ttrafic::OPERATEUR, pt_VGA_OP_860026288)
		FINSI
	FINSI

FINSI

#------------------------------------
#	CENTAUREVG
#------------------------------------

SI ( !i_ChercherCouranteECC(instCENTAUREVG_860026288))
ALORS
	trace("Stockage vers CENTAUREVG")

	# Duplication de l article
	#-----------------------------
	#trace("Duplication vers CENTAUREVG")
	SI (i_dup_art_dest(g_iartin, g_iartout12, C_TcentaureVG_860026288))
	ALORS
		trace("Erreur de i_dup_art_dest")
		code_errone_860026288 = 0xA0D0
		code_errone_860026288 = code_errone_860026288 + EFFICACE_860026288
		erreur_860026288 = i_PlvMessEmettre(8602, 2, g_iartin, "", 3, code_errone_860026288, C_TcentaureVG_860026288, C_Article_860026288)
		SAUT DISTRI_ERR
	FINSI

	# Mise au format
	#------------------------------
	#trace("initialisation de DOMAINE et SERVICE")

	# DOMAINE
	erreur_860026288 = i_set_art_str(g_iartout12, $TcentaureVG::DOMAINE, "05")

	# SERVICE
	erreur_860026288 = i_set_art_str(g_iartout12, $TcentaureVG::SERVICE, "36")

	# IDUS_NUM
	res_860026288 = i_set_art_str(g_iartout12, $TcentaureVG::IDUS_NUM, pt_NDR_860026288)

	# DEDE_INF
	Buffer_INFDEDE_860026288= i_get_art_field(g_iartin, $Tmvt7g3dc::INF_DEDE)
	res_860026288 = i_set_art_field(g_iartout12, $TcentaureVG::DEDE_INF, Buffer_INFDEDE_860026288)

	# DEDE_NUM
	res_860026288 = i_set_art_str(g_iartout12, $TcentaureVG::DEDE_NUM, pt_NDE_860026288)

	# DATE
	res_860026288 = i_set_art_field(g_iartout12, $TcentaureVG::ICAR, date_locale_860026288)

	# DUREE
	res_860026288 = i_set_art_field(g_iartout12, $TcentaureVG::DUR, DUREE_860026288)

	# CAX
	res_860026288 = i_set_art_field(g_iartout12, $TcentaureVG::CAX, CAX_860026288)

	# TAX
	res_860026288 = i_set_art_field(g_iartout12, $TcentaureVG::TAX, TAXE_860026288)

	# NDS_NUM
	SI NUMNOS_OK_860026288
	ALORS
		res_860026288 = i_set_art_str(g_iartout12, $TcentaureVG::NDS_NUM, pt_NUMNOS_860026288)
	SINON
		res_860026288 = i_memset_field_n(g_iartout12, $TcentaureVG::NDS_NUM, 0x20)
	FINSI

	# SUP
	SI T3cap1_OK_860026288
	ALORS
		res_860026288 = i_memset_field_n(g_iartout12, $TcentaureVG::SUP, 0x20)
	SINON
		res_860026288 = i_set_art_field(g_iartout12, $TcentaureVG::SUP, SUP_860026288)
	FINSI

	# Nb_CSV  C_CSV1 & OP_CSV1
	res_860026288 = i_set_art_field(g_iartout12, $TcentaureVG::nb_csv, 1)
	res_860026288 = i_set_art_str(g_iartout12, $TcentaureVG::C_CSV1, pt_C_CSV1_860026288)
	res_860026288 = i_set_art_str(g_iartout12, $TcentaureVG::OP_CSV1, pt_OP_CSV1_860026288)

	# STY
	res_860026288 = i_transformer_bits(g_iartin, $STY,"FV", pt_buffer_860026288)
	res_860026288 = i_set_art_str(g_iartout12, $TcentaureVG::STY, pt_buffer_860026288)

	# COCA
	SI T3coca_OK_860026288
	ALORS
		res_860026288 = i_set_art_str(g_iartout12, $TcentaureVG::COCA, pt_BETA_860026288)
	SINON
		res_860026288 = i_set_art_str(g_iartout12, $TcentaureVG::COCA, " ")
	FINSI

	# COCAV
	SI T3cocav_OK_860026288
	ALORS
		res_860026288 = i_set_art_str(g_iartout12, $TcentaureVG::COCAV, pt_BETAV_860026288)
	SINON
		res_860026288 = i_set_art_str(g_iartout12, $TcentaureVG::COCAV, " ")
	FINSI

	# IDAV_INF IDAV_ NUM
	SI T3idav_OK_860026288
	ALORS
		res_860026288 = i_set_art_field(g_iartout12, $TcentaureVG::IDAV_INF, INF_IDAV_860026288)
		res_860026288 = i_set_art_str(g_iartout12, $TcentaureVG::IDAV_NUM, pt_NUM_IDAV_860026288)
	SINON
		res_860026288 = i_memset_field_n(g_iartout12, $TcentaureVG::IDAV_INF, 0x30)
		res_860026288 = i_memset_field_n(g_iartout12, $TcentaureVG::IDAV_NUM, 0x20)
	FINSI

	# SGTQS
	res_860026288 = i_set_art_str(g_iartout12, $TcentaureVG::SGTQS, pt_SGTQS_860026288)

	# champ OFFRE et champ OPERATEUR
	SI (bVGTplus_860026288)
	ALORS
		erreur_860026288 = i_set_art_str(g_iartout12, $TcentaureVG::OFFRE, pt_VGTplus_OF_860026288)
		erreur_860026288 = i_set_art_str(g_iartout12, $TcentaureVG::OPERATEUR, pt_VGTplus_OP_860026288)
	SINON
		erreur_860026288 = i_set_art_str(g_iartout12, $TcentaureVG::OFFRE, pt_VGA_OF_860026288)
		erreur_860026288 = i_set_art_str(g_iartout12, $TcentaureVG::OPERATEUR, pt_VGA_OP_860026288)
	FINSI
FINSI

# G3R16 suppression ECC : ALLOFACT

POINT AVANT_REDIST

SI (trait_ok_860026288 == 0)
ALORS
	#---------------------------------------------------------------------
	# Complements Symphonie
	#---------------------------------------------------------------------

	# CCD
	res_860026288 = i_set_art_field(g_iartout, $Tsymphomvt7g3::CCD, 202)

	# SGTQS
	res_860026288 = i_set_art_str(g_iartout, $Tsymphomvt7g3::SGTQS, pt_SGTQS_860026288)

	# ECC_FACT
	res_860026288 = i_set_art_str(g_iartout, $Tsymphomvt7g3::ECC_FACT, pt_nomECCFact_860026288)

	SI (EFFICACE_860026288 == 1 )
	ALORS

		# NBCOD
		NBCOD_860026288 = 1
		res_860026288 = i_set_art_field(g_iartout, $Tsymphomvt7g3::NBCOD, NBCOD_860026288)

		# Champs optionnels OPE_VGA et OFF_VGA
		SI (bVGTplus_860026288)
		ALORS
			# Champ OPE_VGA
			erreur_860026288 = i_ajoutChampNum(g_iartout, $Tsymphomvt7g3::T4OPEVGA, $Tsymphomvt7g3::OPE_VGA, 0)
			erreur_860026288 = i_set_art_str(g_iartout, $Tsymphomvt7g3::OPE_VGA, pt_VGTplus_OP_860026288)

			# Champ OFF_VGA
			erreur_860026288 = i_ajoutChampNum(g_iartout, $Tsymphomvt7g3::T4OFFVGA, $Tsymphomvt7g3::OFF_VGA, 0)
			erreur_860026288 = i_set_art_str(g_iartout, $Tsymphomvt7g3::OFF_VGA, pt_VGTplus_OF_860026288)
		SINON
			SI (bVGA_860026288)
			ALORS
				# Champ OPE_VGA
				erreur_860026288 = i_ajoutChampNum(g_iartout, $Tsymphomvt7g3::T4OPEVGA, $Tsymphomvt7g3::OPE_VGA, 0)
				erreur_860026288 = i_set_art_str(g_iartout, $Tsymphomvt7g3::OPE_VGA, pt_VGA_OP_860026288)

				# Champ OFF_VGA
				erreur_860026288 = i_ajoutChampNum(g_iartout, $Tsymphomvt7g3::T4OFFVGA,$Tsymphomvt7g3::OFF_VGA, 0)
				erreur_860026288 = i_set_art_str(g_iartout, $Tsymphomvt7g3::OFF_VGA, pt_VGA_OF_860026288)
			FINSI
		FINSI

		# CSV
		erreur_860026288 = i_format_str2(pt_temp_860026288, "%s%s", pt_C_CSV1_860026288, "  ")
		i_get_sub_str(pt_temp_860026288, 0, 1, pt_temp_860026288)
		erreur_860026288 = i_format_str2(pt_buffer_860026288, "%s%s", pt_temp_860026288 , pt_OP_CSV1_860026288)
		erreur_860026288 = i_set_art_str(g_iartout, $Tsymphomvt7g3::CSV, pt_buffer_860026288)
	FINSI

	#---------------------------------------------------------------------
	# Symphonie
	#---------------------------------------------------------------------

	SI !(i_ChercherCouranteECC(instSYMPHO_860026288))
	ALORS
		res_860026288  = i_stocke_art_iecc(g_iartout, instSYMPHO_860026288)
	FINSI
FINSI

SI (bREDIST_860026288 == 1)
ALORS
	SAUT DISTRI_RDT
FINSI

############################################################################
# Envoi vers IECC
############################################################################

#---------------------------------------------------------------------------
# FE
#---------------------------------------------------------------------------

SI !(i_ChercherCouranteECC(instFE_860026288))
ALORS
	res_860026288 = i_stocke_art_iecc(g_iartout2, instFE_860026288)
FINSI

#---------------------------------------------------------------------------
# FERPV
#---------------------------------------------------------------------------

SI !(i_ChercherCouranteECC(instFERPV_860026288))
ALORS
	res_860026288 = i_stocke_art_iecc(g_iartout7, instFERPV_860026288)
FINSI

#---------------------------------------------------------------------------
# DM
#---------------------------------------------------------------------------

SI !(i_ChercherCouranteECC(instDM_860026288))
ALORS
	res_860026288 = i_stocke_art_iecc(g_iartout3, instDM_860026288)
FINSI

#---------------------------------------------------------------------------
# TRAFIC
#---------------------------------------------------------------------------

SI !(i_ChercherCouranteECC(instTRAFIC_860026288))
ALORS
	res_860026288 = i_stocke_art_iecc(g_iartout4, instTRAFIC_860026288)
FINSI

#---------------------------------------------------------------------------
# CENTAUREVG
#---------------------------------------------------------------------------

SI !(i_ChercherCouranteECC(instCENTAUREVG_860026288) )
ALORS
	res_860026288 = i_stocke_art_iecc(g_iartout12, instCENTAUREVG_860026288)
FINSI

# G3R16 suppression ECC : ALLOFACT

RETOUR TRAIT_OK

############################################################################
# Stockage en Errone
############################################################################

POINT DISTRI_ERR

res_860026288 = i_make_art_rej(g_iartin, g_iartout, code_errone_860026288)
res_860026288 = i_stocke_art(g_iartout, 0, PT_ERRONE, 0)

RETOUR TRAIT_OK

############################################################################
# Stockage en Redistribution
############################################################################

POINT DISTRI_RDT

SI (trait_ok_860026288 == 0)
ALORS
	#---------------------
	# Creation de l'ENVELOPPE Optionelle:
	# Contient le nom de l'EEC necessaire au message d'erreur de la redistribution
	SI ( ENVELOPPE_NOK_860026288 )
	ALORS
		#trace("__FILE__:__LINE__ =====> Creation enveloppe REDISTRI")
		ENVELOPPE_NOK_860026288 = i_add_opt("E_Tmvt7g3dc")
		# mise en conformite de la gestion de l'enveloppe
	FINSI
	res_860026288 = i_set_attr_str_n($E_Tmvt7g3dc::Nom_EEC, pt_SGTQS_860026288)
	res_860026288 = i_PlvMessEmettre(8503, 2, g_iartin, "", 3, pt_LIBELREDIST_860026288, "Tmvt7g3dc", pt_SGTQS_860026288)
FINSI

res_860026288 = i_stocke_art(g_iartin, 0, PT_REDIST|RD_TABLE5, 0)

RETOUR TRAIT_OK
