DEFINITION NUMTAB_860026315 1
DEFINITION NUMTABSEL_860026315 1
DEFINITION Teletel_860026315 0
DEFINITION Audiotel_860026315 1
DEFINITION TD_VGA1_860026315 7
DEFINITION TD_VGA2_860026315 2
DEFINITION INST_VGA_860026315 "VGA"
DEFINITION C_Article_860026315 "TvxNdcs"
DEFINITION C_Inst16X_860026315 "16X"
DEFINITION C_T16x_TvxNdc_860026315 "T16x_TvxNdc"
DEFINITION C_InstSYMP_860026315 "SYMP"
DEFINITION C_T16x_860026315 "T16x"
REGISTRE ENTIER inst16x_860026315
REGISTRE ENTIER instSYMPHO_860026315
REGISTRE ENTIER Type_article_860026315
REGISTRE ENTIER res_860026315
REGISTRE ENTIER val_champ_860026315
REGISTRE ENTIER val_champ1_860026315
REGISTRE ENTIER val_champ2_860026315
REGISTRE ENTIER code_errone_860026315
REGISTRE ENTIER erreur_860026315
REGISTRE ENTIER EFFICACE_860026315
REGISTRE ENTIER NR1_860026315
REGISTRE ENTIER NR3_860026315
REGISTRE ENTIER date_locale_860026315
REGISTRE ENTIER OPT_efficace_860026315
REGISTRE ENTIER VGA_860026315
REGISTRE ENTIER val_860026315
REGISTRE ENTIER instVGA_860026315
REGISTRE ENTIER gmt_date_860026315
REGISTRE ENTIER date_860026315
REGISTRE ENTIER lg_IDUS_NUM_860026315
REGISTRE ENTIER numzone_860026315
REGISTRE ENTIER bVGTplus_860026315
REGISTRE POINTEUR pt_OFFRE_860026315
REGISTRE POINTEUR pt_OPERA_860026315
REGISTRE POINTEUR pt_VGA_OP_860026315
REGISTRE POINTEUR pt_VGA_OF_860026315
REGISTRE POINTEUR pt_RES1_860026315
REGISTRE POINTEUR pt_buffer_860026315
REGISTRE POINTEUR pt_nomECCFact_860026315
REGISTRE POINTEUR pt_VGTplus_OP_860026315
REGISTRE POINTEUR pt_VGTplus_OF_860026315
############################################################################
#
# Fichier : TvxNdcs.src
#
# Version : %version: 4.4.1.1 %
#
# Date    : %date_modified: 02/04/02 13:12 %
#
# Distribution :
#    Article detail de communication efficace DCE TvxNdce
#    pour l' application PAVI
#
# En entree :
#    Article : TvxsoNdce.art ou Tvxo1Ndce.art ou Tvxo2Ndce.art
#              ou TktsoNdce.art ou TktoNdce.art
# En sortie :
#    16x
#    Symphonie
#
# N.B :  Avant la distribution, lors du passage par le pcode de
# traitement, l'article initiallement associe au cas d'article TvxNdce ,est
# alors associe au cas d'article Tvxdcs ( ajout de nouveaux champs).
# D'ou le nom TvxNdcs.src pour le fichier associe a la distribution du
# cas d'article TvxNdce.
#
# HISTORIQUE :
# FOEX506 - EV170: recuperation du 1er octet de CPAYS pour LISTSVTR de 16X
#  LRA - 02/04/2002 .
# Modif du 24/05/2002 par URS (Nicole.S) ajout dump dans alarmes + sup de redist sur i_valider_liste
# 17/06/2002 - PSA - FO1510  : Encapsulation pour le stockage en errone
# 04/06/2004 - NSA - G2R0Cl: integration des codes d erreurs
#
# 08/08/2005 - PKH - G2R1Cq VGA Mette
# 06/08/2005 - PKH - G2R1CQ : MODIFICATION de spec Creation des 2 tables de distributions VGA1->table8 (VGA_OFF), VGA3->table3(VGA_OPE)
# 20/08/2005 - PKH - G2R1Cq : Modification de l'appel des tables VGA VGA1->table8 VGA2->table3
# 21/10/2005 - PSA - G2R2Co : FO 1530
# 27/12/2005 - PKH - G2R2Ca : FO1628 Evolution eligibilite VGA
# 27/12/2005 - FAL/THE - G2R2Cu VGTplus
# 11/07/2006 - DRE - FO 1744 passage de 8/8 en 16/16 de T1 et T2 de symphonie (modif duplication et cas d'article)
# 23/09/2011 - THE - Correction suite VerifPcode4_unix.pl
#
############################################################################

############################################################################
# Declarations
############################################################################
#Constantes pour message d alarme


# Variables entieres
# VerifPcode


# Variables pointeurs
# VerifPcode


# Allocation memoire pointeur
# VerifPcode
pt_nomECCFact_860026315="67676767676767"
#sgtqs = "576576576576576576"
pt_buffer_860026315="12345678901234567890112345"
pt_RES1_860026315 = "9087128932599001458796590147"
pt_OFFRE_860026315 = "02350235023502356959552325"
pt_VGA_OF_860026315 = "265265265265256745825852"
pt_OPERA_860026315 = "69696969695218978145875814265"
pt_VGA_OP_860026315 = "8268268826826826826826826828628"
pt_VGTplus_OP_860026315 = "504754564754564754564"
pt_VGTplus_OF_860026315 = "464754564754564754564"


# Initialisation
# VerifPcode
inst16x_860026315=0
instSYMPHO_860026315=0
EFFICACE_860026315=2
val_860026315 = 0
VGA_860026315 = 0
bVGTplus_860026315 = 0


# Initialisation pointeurs
i_strcpy(pt_RES1_860026315,"")
i_strcpy(pt_OFFRE_860026315," ")
i_strcpy(pt_OPERA_860026315," ")
i_strcpy(pt_VGA_OF_860026315," ")
i_strcpy(pt_VGA_OP_860026315," ")
i_strcpy(pt_VGTplus_OP_860026315," ")
i_strcpy(pt_VGTplus_OF_860026315," ")
i_strcpy(pt_buffer_860026315,"")
i_strcpy(pt_nomECCFact_860026315,"")


#########################################################################

#Convertion de la date en entree de platine en date gmt rajout VGA
erreur_860026315 = i_cree_art("Conversion",g_iartout13)
erreur_860026315 = i_dup_chp_1val(g_iartin, g_iartout13, $TvxNdcs::IDUSD, $Conversion::NDR)
numzone_860026315 = i_DHgetZoneID(NUMTABSEL_860026315, g_iartout13)
date_860026315=i_get_art_field(g_iartin,$TvxNdcs::DATE)
gmt_date_860026315 = i_DHgetCe2gTime(NUMTAB_860026315, numzone_860026315, date_860026315)

trace1("gmt_date=<%d>",gmt_date_860026315)

lg_IDUS_NUM_860026315 = (i_get_art_fieldlength(g_iartin, $TvxNdcs::IDUSD) + 1) / 2

############################################################################
# Envoi requetes Table de Distribution
############################################################################
#Appel table distribution VGA
instVGA_860026315 = i_LireInstanceECC(INST_VGA_860026315)

SI (!instVGA_860026315)
ALORS
	trace("Pas d'instance pour VGA1 !")
	erreur_860026315 = i_PlvMessEmettre(8501,2,g_iartin,"",3,"VGA",C_Article_860026315,g_ieec)
	SAUT DISTRI_ERR
FINSI
trace1("instVGA=<%d>",instVGA_860026315)

##############################################################################
# Envoi Requetes Table de Distribution VGA
#############################################################################
#trace1(" EnvoiReq table TD_VGA1 <%d>", TD_VGA1)
#trace1(" EnvoiReq table gmt_date <%d>", gmt_date)
#trace1(" EnvoiReq table lg_IDUS_NUM <%d>", lg_IDUS_NUM)
#trace2(" EnvoiReq table IDUS <%s>", pt_buffer,"")

SI (i_EnvoiReqConsTabDist( TD_VGA1_860026315,gmt_date_860026315,i_get_art_fieldptr(g_iartin,$TvxNdcs::IDUSD),lg_IDUS_NUM_860026315,0,1) != 0)
ALORS
	trace("Erreur i_EnvoiReqConsTa VGA1")
	SAUT DISTRI_ERR
FINSI

erreur_860026315 = i_LireReqConsTabDist()
trace1("RETOUR i_LireReqConsTabDist retour requete VGA1, =<%d>",erreur_860026315)

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

val_860026315 = i_LireInfoECC( instVGA_860026315, 0 )

trace1("WWWW val 0x<%x>", val_860026315)

# test redist OK apres 1ER passage SI ( res > 0 && trait_ok !=0 )
# Evoltion eligibilite VGA
SI ( val_860026315 != 0 )
ALORS
	erreur_860026315 = i_LireChaineInfo( val_860026315, 0, 6, pt_OFFRE_860026315 )
	#trace2(" pt_OFFRE <%s> ", pt_OFFRE,"")
	erreur_860026315 = i_format_str2( pt_buffer_860026315, "%s%s", "INj", pt_OFFRE_860026315)
	i_strcpy(pt_RES1_860026315, i_get_tab_field("Inter", gmt_date_860026315, pt_buffer_860026315))

	#trace2(" pt_RES1  <%s> ", pt_RES1,"")

	SI (i_strcmp(pt_RES1_860026315,"VGT+")==0)
	ALORS
		bVGTplus_860026315 =1
		VGA_860026315 = 0
		i_strcpy(pt_VGTplus_OF_860026315 ,pt_OFFRE_860026315)
	SINON
		SI (i_strcmp(pt_RES1_860026315,"VGA")==0)
		ALORS
			VGA_860026315 = 1
			i_strcpy(pt_VGA_OF_860026315 ,pt_OFFRE_860026315)
		FINSI
	FINSI
FINSI

trace2("  Resultat de i_LireChaineInfo pour VGA1 (table8): <%s>", pt_OFFRE_860026315, "")

SI (VGA_860026315 || bVGTplus_860026315)
ALORS
	SI (i_EnvoiReqConsTabDist( TD_VGA2_860026315,gmt_date_860026315,i_get_art_fieldptr(g_iartin,$TvxNdcs::IDUSD),lg_IDUS_NUM_860026315,0,1) != 0)
	ALORS
		trace("Erreur i_EnvoiReqConsTa VGA1")
		SAUT DISTRI_ERR
	FINSI
	erreur_860026315 = i_LireReqConsTabDist()
	#trace1("RETOUR i_LireReqConsTabDist retour requette VGA2, erreur=<%d>",erreur)

	SI ( erreur_860026315 != 0 )
	ALORS
		trace1( "Erreur i_LireReqConsTabDist VGA2: <%d>", erreur_860026315)
		SAUT DISTRI_ERR
	FINSI

	val_860026315= 0
	val_860026315 = i_LireInfoECC( instVGA_860026315, 0 )

	SI (val_860026315 != 0)
	ALORS
		erreur_860026315 = i_LireChaineInfo( val_860026315, 0, 6, pt_OPERA_860026315)
		SI (bVGTplus_860026315)
		ALORS
			SI (i_strcmp(pt_OPERA_860026315,g_inull))
			ALORS
				i_strcpy(pt_VGTplus_OP_860026315, pt_OPERA_860026315)
			FINSI
		SINON
			SI (VGA_860026315)
			ALORS
				SI (i_strcmp(pt_OPERA_860026315,g_inull))
				ALORS
					i_strcpy(pt_VGA_OP_860026315,pt_OPERA_860026315)
				FINSI
			FINSI
		FINSI
	FINSI
FINSI

trace2(" Resultat de i_LireChaineInfo pour VGA2 (table3): <%s>", pt_OPERA_860026315, "")
#trace2(" ###### NDR : <%s>", pt_buffer, "")
#trace2(" ###### pt_RES1 resultat table ext CodeOffre  <%s>", pt_RES1, "")
#trace1(" ###### bVGTplus <%d>", bVGTplus)
#trace1(" ###### VGA      <%d>", VGA)
#trace2(" ###### pt_VGTplus_OF : <%s>", pt_VGTplus_OF, "")
#trace2(" ###### pt_VGA_OF     : <%s>", pt_VGA_OF, "")
#trace2(" ###### pt_VGTplus_OP : <%s>", pt_VGTplus_OP, "")
#trace2(" ###### pt_VGA_OP     : <%s>", pt_VGA_OP, "")

################################ FIN AJOUT VGA ##############################################

############################################################################
# Controles
############################################################################
# controle metachamps

SI (i_get_art_field(g_iartin,$TvxNdcs::dduree) == -1)
ALORS
	code_errone_860026315 = 0xA080
	code_errone_860026315 = code_errone_860026315 + EFFICACE_860026315
	erreur_860026315 = i_PlvMessEmettre( 8600, 2, g_iartin,"", 3,code_errone_860026315, C_Article_860026315, "i_get_art_field/dduree" )
	SAUT DISTRI_ERR
FINSI

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

# 16x
inst16x_860026315=i_LireInstanceECC(C_Inst16X_860026315)

SI !(inst16x_860026315 > 0)
ALORS
	code_errone_860026315 = 0xA0B0
	code_errone_860026315 = code_errone_860026315 + EFFICACE_860026315
	erreur_860026315 = i_PlvMessEmettre(8601,2,g_iartin,"",3,code_errone_860026315,C_Inst16X_860026315,C_Article_860026315)
	SAUT DISTRI_ERR
FINSI

# SYMPHONIE
instSYMPHO_860026315=i_LireInstanceECC(C_InstSYMP_860026315)

SI !(instSYMPHO_860026315 > 0)
ALORS
	code_errone_860026315 = 0xA0B0
	code_errone_860026315 = code_errone_860026315 + EFFICACE_860026315
	erreur_860026315 = i_PlvMessEmettre(8601,2,g_iartin,"",3,code_errone_860026315,C_InstSYMP_860026315,C_Article_860026315)
	SAUT DISTRI_ERR
FINSI

############################################################################
# Duplication Symphonie
############################################################################
# DRE Passage de symphonie de 8/8 en 16/16

SI (i_dup_art(g_iartin,"TsymphovxNdcs",g_iartout))
ALORS
	code_errone_860026315 = 0xA0D0
	code_errone_860026315 = code_errone_860026315 + EFFICACE_860026315
	erreur_860026315 = i_PlvMessEmettre(8602,2,g_iartin,"",3,code_errone_860026315," pour Symphonie",C_Article_860026315)
	SAUT DISTRI_ERR
FINSI

res_860026315=i_rename_art(g_iartout,"TsymphovxNdcs")

# Controle du metachamp dcompteur :
SI ( i_get_art_field(g_iartout,$TsymphovxNdcs::dcompteur) == -1 )
ALORS
	code_errone_860026315 = 0xA080
	code_errone_860026315 = code_errone_860026315 + EFFICACE_860026315
	erreur_860026315 = i_PlvMessEmettre( 8600, 2, g_iartin,"", 3,code_errone_860026315, C_Article_860026315, "i_get_art_field/dcompteur" )
	SAUT DISTRI_ERR
FINSI

# retrait du TLV T3AJCE si ajoute par le traitement
SI (i_valid_field_n(g_iartin,$T3AJCE))
ALORS
	res_860026315=i_supprChamp(g_iartout,"T3AJCE")
FINSI

# CCD
res_860026315=i_ajoutChampNum(g_iartout,$TsymphovxNdcs::T4ccd,$TsymphovxNdcs::CCD,0)

# SGTQS
res_860026315=i_ajoutChampNum(g_iartout,$TsymphovxNdcs::T4sgtqs,$TsymphovxNdcs::SGTQS,0)

# ECC_FACT
res_860026315=i_ajoutChampNum(g_iartout,$TsymphovxNdcs::T4eccfact,$TsymphovxNdcs::ECC_FACT,0)

#Champ OPE_VGA et OFF_VGA
# Champs optionnels OPE_VGA et OFF_VGA
SI (VGA_860026315 || bVGTplus_860026315)
ALORS
	# Champ OPE_VGA
	erreur_860026315 = i_ajoutChampNum(g_iartout,$TsymphovxNdcs::T4OPEVGA,$TsymphovxNdcs::OPE_VGA,0)

	# Champ OFF_VGA
	erreur_860026315 = i_ajoutChampNum(g_iartout,$TsymphovxNdcs::T4OFFVGA,$TsymphovxNdcs::OFF_VGA,0)
	SI bVGTplus_860026315
	ALORS
		erreur_860026315 = i_set_art_str(g_iartout,$TsymphovxNdcs::OPE_VGA,pt_VGTplus_OP_860026315)
		erreur_860026315 = i_set_art_str(g_iartout,$TsymphovxNdcs::OFF_VGA,pt_VGTplus_OF_860026315)
	SINON
		SI VGA_860026315
		ALORS
			erreur_860026315 = i_set_art_str(g_iartout,$TsymphovxNdcs::OPE_VGA,pt_VGA_OP_860026315)
			erreur_860026315 = i_set_art_str(g_iartout,$TsymphovxNdcs::OFF_VGA,pt_VGA_OF_860026315)
		FINSI
	FINSI
FINSI

############################################################################
# Critere de distribution
############################################################################
# ajout de l'EEC SYMPHONIE a la liste courante des EEC

res_860026315=i_AjouterCouranteECC(instSYMPHO_860026315)

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

#---------------------------------------------------------------------------
# 16x
#---------------------------------------------------------------------------

res_860026315=i_AjouterCouranteECC(inst16x_860026315)

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

res_860026315=i_ValiderListeECC(0,0,0,0)

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

#---------------------------------------------------------------------------
# 16x
#---------------------------------------------------------------------------

SI !(i_ChercherCouranteECC(inst16x_860026315))
ALORS
	# ECC_FACT
	# VerifPcode
	#nomECCFact="16x"
	i_strcpy(pt_nomECCFact_860026315,"16x")
	# EV4.1: pour Teletel, le format pour 16x prend en compte le champ LISTSVTR donc creation d un nouveau cas d article T16x_TvxNdcs
	SI (i_valid_field_n(g_iartin,$T3trans1) || i_valid_field_n(g_iartin,$T3trans2) || i_valid_field_n(g_iartin,$T3trans3))
	ALORS
		# utilisation de la table de duplication
		SI (i_dup_art_dest(g_iartin,g_iartout2,C_T16x_TvxNdc_860026315))
		ALORS
			code_errone_860026315 = 0xA0D0
			code_errone_860026315 = code_errone_860026315 + EFFICACE_860026315
			erreur_860026315 = i_PlvMessEmettre(8602,2,g_iartin,"",3,code_errone_860026315,C_T16x_TvxNdc_860026315,C_Article_860026315)
			SAUT DISTRI_ERR
		FINSI

		# recuperation du champ NR commun a tout article du cas d'article Tvxdcs
		# pour lequel la table de duplication ne peut gerer la copie

		# NR1, NR2, NR3
		val_champ_860026315=i_get_art_field(g_iartin,$NR)
		NR1_860026315=(val_champ_860026315 & 0x7F00)>>8
		res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::NR1,NR1_860026315)
		NR3_860026315=(val_champ_860026315 & 0xFF)
		res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::NR3,NR3_860026315)

		SI (val_champ_860026315 & 0x8000)
		ALORS
			res_860026315=i_set_art_str(g_iartout2,$T16x_TvxNdc::NR2,"N")
		SINON
			res_860026315=i_set_art_str(g_iartout2,$T16x_TvxNdc::NR2,"O")
		FINSI

		# IDUS
		res_860026315=i_get_art_str(g_iartin,$IDUSD,pt_buffer_860026315)
		i_replace_str(pt_buffer_860026315,"BCDE","AJSC",pt_buffer_860026315)
		res_860026315=i_set_art_str(g_iartout2,$T16x_TvxNdc::IDUS,pt_buffer_860026315)

		# IDAC
		res_860026315=i_get_art_str(g_iartin,$IDAC,pt_buffer_860026315)
		res_860026315=i_set_art_str(g_iartout2,$T16x_TvxNdc::IDAC,pt_buffer_860026315)

		# ILANUM
		res_860026315=i_set_art_str(g_iartout2,$T16x_TvxNdc::ILANUM,i_LireEECSGTQS(g_ieec))

		# date_locale
		# particularite : pour recuperer la date de g_iartin et la mettre
		# dans g_iartout2, utilisation de la dup_tab et de la fonction i_set_art_field
		date_locale_860026315=i_get_art_field(g_iartin,$DATE)
		SI( date_locale_860026315 == -1 )
		ALORS
			code_errone_860026315 = 0xA080
			code_errone_860026315 = code_errone_860026315 + EFFICACE_860026315
			erreur_860026315 = i_PlvMessEmettre( 8600, 2, g_iartin,"", 3,code_errone_860026315, C_Article_860026315, "i_get_art_field/DATE" )
			SAUT DISTRI_ERR
		FINSI
		date_locale_860026315=i_date_locale( g_ieec, g_iartin, date_locale_860026315)
		SI (date_locale_860026315 == -1)
		ALORS
			code_errone_860026315 = 0xA080
			code_errone_860026315 = code_errone_860026315 + EFFICACE_860026315
			erreur_860026315 = i_PlvMessEmettre( 8600, 2, g_iartin,"", 3,code_errone_860026315, C_Article_860026315, "i_date_locale" )
			SAUT DISTRI_ERR
		FINSI
		res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::DATE,date_locale_860026315)
	SINON
		# utilisation de la table de duplication
		SI (i_dup_art_dest(g_iartin,g_iartout2,C_T16x_860026315))
		ALORS
			code_errone_860026315 = 0xA0D0
			code_errone_860026315 = code_errone_860026315 + EFFICACE_860026315
			erreur_860026315 = i_PlvMessEmettre(8602,2,g_iartin,"",3,code_errone_860026315,C_T16x_860026315,C_Article_860026315)
			SAUT DISTRI_ERR
		FINSI

		# recuperation du champ NR commun a tout article du cas d'article Tvxdcs
		# pour lequel la table de duplication ne peut gerer la copie

		# NR1, NR2, NR3
		val_champ_860026315=i_get_art_field(g_iartin,$NR)
		NR1_860026315=(val_champ_860026315 & 0x7F00)>>8
		res_860026315=i_set_art_field(g_iartout2,$T16x::NR1,NR1_860026315)
		NR3_860026315=(val_champ_860026315 & 0xFF)
		res_860026315=i_set_art_field(g_iartout2,$T16x::NR3,NR3_860026315)
		SI (val_champ_860026315 & 0x8000)
		ALORS
			res_860026315=i_set_art_str(g_iartout2,$T16x::NR2,"N")
		SINON
			res_860026315=i_set_art_str(g_iartout2,$T16x::NR2,"O")
		FINSI

		# IDUS
		res_860026315=i_get_art_str(g_iartin,$IDUSD,pt_buffer_860026315)
		i_replace_str(pt_buffer_860026315,"BCDE","AJSC",pt_buffer_860026315)
		res_860026315=i_set_art_str(g_iartout2,$T16x::IDUS,pt_buffer_860026315)

		# IDAC
		res_860026315=i_get_art_str(g_iartin,$IDAC,pt_buffer_860026315)
		res_860026315=i_set_art_str(g_iartout2,$T16x::IDAC,pt_buffer_860026315)

		# ILANUM
		res_860026315=i_set_art_str(g_iartout2,$T16x::ILANUM,i_LireEECSGTQS(g_ieec))

		# date_locale
		# particularite : pour recuperer la date de g_iartin et la mettre
		# dans g_iartout2, utilisation de la dup_tab et de la fonction i_set_art_field
		date_locale_860026315=i_get_art_field(g_iartin,$DATE)

		SI( date_locale_860026315 == -1 )
		ALORS
			code_errone_860026315 = 0xA080
			code_errone_860026315 = code_errone_860026315 + EFFICACE_860026315
			erreur_860026315 = i_PlvMessEmettre( 8600, 2, g_iartin,"", 3,code_errone_860026315, C_Article_860026315, "i_get_art_field/DATE" )
			SAUT DISTRI_ERR
		FINSI
		date_locale_860026315=i_date_locale( g_ieec, g_iartin, date_locale_860026315)

		SI (date_locale_860026315 == -1)
		ALORS
			code_errone_860026315 = 0xA080
			code_errone_860026315 = code_errone_860026315 + EFFICACE_860026315
			erreur_860026315 = i_PlvMessEmettre( 8600, 2, g_iartin,"", 3,code_errone_860026315, C_Article_860026315, "i_date_locale" )
			SAUT DISTRI_ERR
		FINSI
		res_860026315=i_set_art_field(g_iartout2,$T16x::DATE,date_locale_860026315)
	FINSI

	SI i_valid_field_n(g_iartin,$T3trans1)
	ALORS
		# Affectation de Type_article
		Type_article_860026315=Teletel_860026315

		# CPAYS
		val_champ_860026315=i_get_art_field(g_iartin,$CPAYS)
		res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::LISTSVTR,val_champ_860026315>>8)

		# T3trans1
		val_champ_860026315=i_get_art_field(g_iartin,$T3trans1)
		res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::T3,val_champ_860026315)

		# DUREE1
		val_champ_860026315=i_get_art_field(g_iartin,$DUREE1)
		res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::DUREE,val_champ_860026315)

		# NOMNDE1
		res_860026315=i_get_art_str(g_iartin,$NOMNDE1,pt_buffer_860026315)
		res_860026315=i_set_art_str(g_iartout2,$T16x_TvxNdc::NOMDE,pt_buffer_860026315)

		# NUMNDE1
		res_860026315=i_get_art_str(g_iartin,$NUMNDE1,pt_buffer_860026315)
		i_replace_str(pt_buffer_860026315,"BC","*#",pt_buffer_860026315)
		res_860026315=i_set_art_str(g_iartout2,$T16x_TvxNdc::NUMDE,pt_buffer_860026315)

		# RTAX1 -> RTAX1, RTAX2
		val_champ_860026315=i_get_art_field(g_iartin,$RTAX1)
		val_champ1_860026315=val_champ_860026315 & 0xFF
		res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::RTAX2,val_champ1_860026315)
		val_champ2_860026315=val_champ_860026315 >> 8
		res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::RTAX1,val_champ2_860026315)

		# VOL1
		val_champ_860026315=i_get_art_field(g_iartin,$VOL1)
		res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::VOL,val_champ_860026315)

		# VTT1
		val_champ_860026315= i_get_art_field(g_iartin,$VTT1)
		res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::VTT,val_champ_860026315)

		# VTI1
		val_champ_860026315= i_get_art_field(g_iartin,$VTI1)
		res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::VTI,val_champ_860026315)

		# FINS1 -> FINS1, FINS2
		val_champ_860026315=i_get_art_field(g_iartin,$FINS1)
		val_champ1_860026315=val_champ_860026315 & 0xFF
		res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::FINS2,val_champ1_860026315)
		val_champ2_860026315=val_champ_860026315 >> 8
		res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::FINS1,val_champ2_860026315)

		# DAAVS1
		val_champ_860026315=i_get_art_field(g_iartin,$DAAVS1)
		res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::DAAVS,val_champ_860026315)

		# DAAPS1
		val_champ_860026315=i_get_art_field(g_iartin,$DAAPS1)
		res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::DAAPS,val_champ_860026315)

		# VTA1
		val_champ_860026315=i_get_art_field(g_iartin,$VTA1)
		res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::VTA,val_champ_860026315)

		# TR1
		val_champ_860026315=i_get_art_field(g_iartin,$TR1)
		res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::TR,val_champ_860026315)

		# NBUT1
		val_champ_860026315=i_get_art_field(g_iartin,$NBUT1)
		res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::NBUT,val_champ_860026315)

		# ACCDDE1
		# Mis a jour ds la table de distribution,
		# mais recuperation de T1/T2/KIOSQUE_TELEPHONIQUE/ACCDE ds g_iartin,
		# pour mise a jour du champ OPT_EFFICACE de l'enveloppe pour 16X
		OPT_efficace_860026315=i_get_art_field(g_iartin,$ACCDDE1)
	SINON
		SI i_valid_field_n(g_iartin,$T3trans2)
		ALORS
			# Affectation de Type_article
			Type_article_860026315=Teletel_860026315

			# CPAYS
			val_champ_860026315=i_get_art_field(g_iartin,$CPAYS)
			res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::LISTSVTR,val_champ_860026315>>8)

			# T3trans2
			val_champ_860026315=i_get_art_field(g_iartin,$T3trans2)
			res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::T3,val_champ_860026315)

			# DUREE2
			val_champ_860026315=i_get_art_field(g_iartin,$DUREE2)
			res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::DUREE,val_champ_860026315)

			# NOMDE2
			res_860026315=i_get_art_str(g_iartin,$NOMNDE2,pt_buffer_860026315)
			res_860026315=i_set_art_str(g_iartout2,$T16x_TvxNdc::NOMDE,pt_buffer_860026315)

			# NUMNDE2
			res_860026315=i_get_art_str(g_iartin,$NUMNDE2,pt_buffer_860026315)
			i_replace_str(pt_buffer_860026315,"BC","*#",pt_buffer_860026315)
			res_860026315=i_set_art_str(g_iartout2,$T16x_TvxNdc::NUMDE,pt_buffer_860026315)

			# RTAX2 -> RTAX1, RTAX2
			val_champ_860026315=i_get_art_field(g_iartin,$RTAX2)
			val_champ1_860026315=val_champ_860026315 & 0xFF
			res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::RTAX2,val_champ1_860026315)
			val_champ2_860026315=val_champ_860026315 >> 8
			res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::RTAX1,val_champ2_860026315)

			# VOL2
			val_champ_860026315=i_get_art_field(g_iartin,$VOL2)
			res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::VOL,val_champ_860026315)

			# VTT2
			val_champ_860026315= i_get_art_field(g_iartin,$VTT2)
			res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::VTT,val_champ_860026315)

			# VTI2
			val_champ_860026315= i_get_art_field(g_iartin,$VTI2)
			res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::VTI,val_champ_860026315)

			# FINS2 -> FINSI1, FINSI2
			val_champ_860026315=i_get_art_field(g_iartin,$FINS2)
			val_champ1_860026315=val_champ_860026315 & 0xFF
			res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::FINS2,val_champ1_860026315)
			val_champ2_860026315=val_champ_860026315 >>8
			res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::FINS1,val_champ2_860026315)

			# DAAVS2
			val_champ_860026315=i_get_art_field(g_iartin,$DAAVS2)
			res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::DAAVS,val_champ_860026315)

			# DAAPS2
			val_champ_860026315=i_get_art_field(g_iartin,$DAAPS2)
			res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::DAAPS,val_champ_860026315)

			# VTA2
			val_champ_860026315=i_get_art_field(g_iartin,$VTA2)
			res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::VTA,val_champ_860026315)

			# TR2
			val_champ_860026315=i_get_art_field(g_iartin,$TR2)
			res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::TR,val_champ_860026315)

			# NBUT2
			val_champ_860026315=i_get_art_field(g_iartin,$NBUT2)
			res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::NBUT,val_champ_860026315)

			# ACCDDE2
			# Mis a jour ds la table de distribution,
			# mais recuperation de T1/T2/KIOSQUE_TELEPHONIQUE/ACCDE ds g_iartin,
			# pour mise a jour du champ OPT_EFFICACE de l'enveloppe pour 16X
			OPT_efficace_860026315=i_get_art_field(g_iartin,$ACCDDE2)
		SINON
			SI i_valid_field_n(g_iartin,$T3trans3)
			ALORS
				# Determination de Type_article
				Type_article_860026315=Teletel_860026315

				# CPAYS
				val_champ_860026315=i_get_art_field(g_iartin,$CPAYS)
				res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::LISTSVTR,val_champ_860026315>>8)

				# T3trans3
				val_champ_860026315=i_get_art_field(g_iartin,$T3trans3)
				res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::T3,val_champ_860026315)
				# DUREE3
				val_champ_860026315=i_get_art_field(g_iartin,$DUREE3)
				res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::DUREE,val_champ_860026315)

				# NOMNDE3
				res_860026315=i_get_art_str(g_iartin,$NOMNDE3,pt_buffer_860026315)
				res_860026315=i_set_art_str(g_iartout2,$T16x_TvxNdc::NOMDE,pt_buffer_860026315)

				# NUMNDE3
				res_860026315=i_get_art_str(g_iartin,$NUMNDE3,pt_buffer_860026315)
				i_replace_str(pt_buffer_860026315,"BC","*#",pt_buffer_860026315)
				res_860026315=i_set_art_str(g_iartout2,$T16x_TvxNdc::NUMDE,pt_buffer_860026315)

				# RTAX3 -> RTAX1, RTAX2
				val_champ_860026315=i_get_art_field(g_iartin,$RTAX3)
				val_champ1_860026315=val_champ_860026315 & 0xFF
				res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::RTAX2,val_champ1_860026315)
				val_champ2_860026315=val_champ_860026315 >>8
				res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::RTAX1,val_champ2_860026315)

				# VOL3
				val_champ_860026315=i_get_art_field(g_iartin,$VOL3)
				res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::VOL,val_champ_860026315)

				# VTT3
				val_champ_860026315= i_get_art_field(g_iartin,$VTT3)
				res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::VTT,val_champ_860026315)

				# VTI3
				val_champ_860026315= i_get_art_field(g_iartin,$VTI3)
				res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::VTI,val_champ_860026315)

				# FINS3 -> FINS1, FINS2
				val_champ_860026315=i_get_art_field(g_iartin,$FINS3)
				val_champ1_860026315=val_champ_860026315 & 0xFF
				res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::FINS2,val_champ1_860026315)
				val_champ2_860026315=val_champ_860026315 >>8
				res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::FINS1,val_champ2_860026315)

				# DAAVS3
				val_champ_860026315=i_get_art_field(g_iartin,$DAAVS3)
				res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::DAAVS,val_champ_860026315)

				# DAAPS3
				val_champ_860026315=i_get_art_field(g_iartin,$DAAPS3)
				res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::DAAPS,val_champ_860026315)

				# VTA3
				val_champ_860026315=i_get_art_field(g_iartin,$VTA3)
				res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::VTA,val_champ_860026315)

				# TR3
				val_champ_860026315=i_get_art_field(g_iartin,$TR3)
				res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::TR,val_champ_860026315)

				# NBUT3
				val_champ_860026315=i_get_art_field(g_iartin,$NBUT3)
				res_860026315=i_set_art_field(g_iartout2,$T16x_TvxNdc::NBUT,val_champ_860026315)

				# ACCDDE3
				# Mis a jour ds la table de distribution,
				# mais recuperation de T1/T2/KIOSQUE_TELEPHONIQUE/ACCDE ds g_iartin,
				# pour mise a jour du champ OPT_EFFICACE de l'enveloppe pour 16X
				OPT_efficace_860026315=i_get_art_field(g_iartin,$ACCDDE3)
			SINON
				SI i_valid_field_n(g_iartin,$T3trans4)
				ALORS
					# Affectation de Type_article
					Type_article_860026315=Audiotel_860026315

					# T3trans4
					val_champ_860026315=i_get_art_field(g_iartin,$T3trans4)
					res_860026315=i_set_art_field(g_iartout2,$T16x::T3,val_champ_860026315)

					# DUREE4
					val_champ_860026315=i_get_art_field(g_iartin,$DUREE4)
					res_860026315=i_set_art_field(g_iartout2,$T16x::DUREE,val_champ_860026315)

					# NOMNDE4
					res_860026315=i_get_art_str(g_iartin,$NOMNDE4,pt_buffer_860026315)
					res_860026315=i_set_art_str(g_iartout2,$T16x::NOMDE,pt_buffer_860026315)

					# NUMNDE4
					res_860026315=i_get_art_str(g_iartin,$NUMNDE4,pt_buffer_860026315)
					i_replace_str(pt_buffer_860026315,"BC","*#",pt_buffer_860026315)
					res_860026315=i_set_art_str(g_iartout2,$T16x::NUMDE,pt_buffer_860026315)

					# RTAX4 -> RTAX1, RTAX2
					val_champ_860026315=i_get_art_field(g_iartin,$RTAX4)
					val_champ1_860026315=val_champ_860026315 & 0xFF
					res_860026315=i_set_art_field(g_iartout2,$T16x::RTAX2,val_champ1_860026315)
					val_champ2_860026315=val_champ_860026315 >>8
					res_860026315=i_set_art_field(g_iartout2,$T16x::RTAX1,val_champ2_860026315)

					# VTT4
					val_champ_860026315= i_get_art_field(g_iartin,$VTT4)
					res_860026315=i_set_art_field(g_iartout2,$T16x::VTT,val_champ_860026315)

					# VTI4
					val_champ_860026315= i_get_art_field(g_iartin,$VTI4)
					res_860026315=i_set_art_field(g_iartout2,$T16x::VTI,val_champ_860026315)

					# FINS4 -> FINS1, FINS2
					val_champ_860026315=i_get_art_field(g_iartin,$FINS4)
					val_champ1_860026315=val_champ_860026315 & 0xFF
					res_860026315=i_set_art_field(g_iartout2,$T16x::FINS2,val_champ1_860026315)
					val_champ2_860026315=val_champ_860026315 >>8
					res_860026315=i_set_art_field(g_iartout2,$T16x::FINS1,val_champ2_860026315)

					# NBUT4
					val_champ_860026315=i_get_art_field(g_iartin,$NBUT4)
					res_860026315=i_set_art_field(g_iartout2,$T16x::NBUT,val_champ_860026315)

					# ACCDDE4
					# Avec recuperation de T1/T2/KIOSQUE_TELEPHONIQUE/ACCDE ds g_iartin,
					# pour mise a jour du champ OPT_EFFICACE de l'enveloppe pour 16X
					OPT_efficace_860026315=i_get_art_field(g_iartin,$ACCDDE4)
					res_860026315=i_set_art_field(g_iartout2,$T16x::ACCDDE,OPT_efficace_860026315)

					# DUREEG4
					val_champ_860026315=i_get_art_field(g_iartin,$DUREEG4)
					res_860026315=i_set_art_field(g_iartout2,$T16x::TG,val_champ_860026315)

				SINON
					SI i_valid_field_n(g_iartin,$T3trans5)
					ALORS
						# Affectation de Type_article
						Type_article_860026315=Audiotel_860026315

						# T3trans5
						val_champ_860026315=i_get_art_field(g_iartin,$T3trans5)
						res_860026315=i_set_art_field(g_iartout2,$T16x::T3,val_champ_860026315)

						# DUREE5
						val_champ_860026315=i_get_art_field(g_iartin,$DUREE5)
						res_860026315=i_set_art_field(g_iartout2,$T16x::DUREE,val_champ_860026315)

						# NOMNDE5
						res_860026315=i_get_art_str(g_iartin,$NOMNDE5,pt_buffer_860026315)
						res_860026315=i_set_art_str(g_iartout2,$T16x::NOMDE,pt_buffer_860026315)

						# NUMNDE5
						res_860026315=i_get_art_str(g_iartin,$NUMNDE5,pt_buffer_860026315)
						i_replace_str(pt_buffer_860026315,"BC","*#",pt_buffer_860026315)
						res_860026315=i_set_art_str(g_iartout2,$T16x::NUMDE,pt_buffer_860026315)

						# RTAX5 -> RTAX1, RTAX2
						val_champ_860026315=i_get_art_field(g_iartin,$RTAX5)
						val_champ1_860026315=val_champ_860026315 & 0xFF
						res_860026315=i_set_art_field(g_iartout2,$T16x::RTAX2,val_champ1_860026315)
						val_champ2_860026315=val_champ_860026315 >>8
						res_860026315=i_set_art_field(g_iartout2,$T16x::RTAX1,val_champ2_860026315)

						# VTT5
						val_champ_860026315= i_get_art_field(g_iartin,$VTT5)
						res_860026315=i_set_art_field(g_iartout2,$T16x::VTT,val_champ_860026315)

						# VTI5
						val_champ_860026315= i_get_art_field(g_iartin,$VTI5)
						res_860026315=i_set_art_field(g_iartout2,$T16x::VTI,val_champ_860026315)

						# FINS5 -> FINS1, FINS2
						val_champ_860026315=i_get_art_field(g_iartin,$FINS5)
						val_champ1_860026315=val_champ_860026315 & 0xFF
						res_860026315=i_set_art_field(g_iartout2,$T16x::FINS2,val_champ1_860026315)
						val_champ2_860026315=val_champ_860026315 >>8
						res_860026315=i_set_art_field(g_iartout2,$T16x::FINS1,val_champ2_860026315)

						# DUREEAAS5
						val_champ_860026315=i_get_art_field(g_iartin,$DUREEAAS5)
						res_860026315=i_set_art_field(g_iartout2,$T16x::DAAVS,val_champ_860026315)

						# DUREEAPS5
						val_champ_860026315=i_get_art_field(g_iartin,$DUREEAPS5)
						res_860026315=i_set_art_field(g_iartout2,$T16x::DAAPS,val_champ_860026315)

						# VTA5
						val_champ_860026315= i_get_art_field(g_iartin,$VTA5)
						res_860026315=i_set_art_field(g_iartout2,$T16x::VTA,val_champ_860026315)

						# NBUT5
						val_champ_860026315=i_get_art_field(g_iartin,$NBUT5)
						res_860026315=i_set_art_field(g_iartout2,$T16x::NBUT,val_champ_860026315)

						# ACCDDE5
						# Avec recuperation de T1/T2/KIOSQUE_TELEPHONIQUE/ACCDE ds g_iartin,
						# pour mise a jour du champ OPT_EFFICACE de l'enveloppe pour 16X
						OPT_efficace_860026315=i_get_art_field(g_iartin,$ACCDDE5)
						res_860026315=i_set_art_field(g_iartout2,$T16x::ACCDDE, OPT_efficace_860026315)

						# DUREEG5
						val_champ_860026315=i_get_art_field(g_iartin,$DUREEG5)
						res_860026315=i_set_art_field(g_iartout2,$T16x::TG,val_champ_860026315)

					FINSI
				FINSI
			FINSI
		FINSI
	FINSI

	#---------------------
	#  AJOUT ENVELOPPE Optionelle
	# (Contient les champs necessaires au calcul des metachamps de T16x_TvxNdc ou T16x)
	#---------------------
	# Creation de l'enveloppe
	res_860026315=i_add_opt( "E16xDopt" )

	# VerifPcode mise conformite enveloppe
	# champ T1 (=>  0x02 pour la reconnaissance de l'enveloppe,
	# par l'arbre de reconnaissance Dopt )
	#res=i_set_attr_val_n( $E16xDopt::T1, 0x02 )

	# Champ L1 (taille 4 octets)
	#res=i_set_attr_val_n( $E16xDopt::L1, 0x04 )

	# OPT_ORIGINE [2 octets]
	res_860026315=i_set_attr_val_n( $E16xDopt::OPT_ORIGINE, i_get_art_field(g_iartin,$vDOM) )

	# OPT_TYPE (si Teletel => 0, ou si Audiotel => 1) [1 octet]
	res_860026315=i_set_attr_val_n( $E16xDopt::OPT_TYPE, Type_article_860026315 )

	# OPT_EFFICACE [1 octet]
	res_860026315=i_set_attr_val_n( $E16xDopt::OPT_EFFICACE, OPT_efficace_860026315 )
FINSI

#---------------------------------------------------------------------------
# Complements Symphonie
#---------------------------------------------------------------------------

# CCD
res_860026315= i_set_art_field(g_iartout,$TsymphovxNdcs::CCD,7)

# SGTQS
res_860026315= i_set_art_str(g_iartout,$TsymphovxNdcs::SGTQS,i_LireEECSGTQS(g_ieec))

# ECC_FACT
# VerifPcode
res_860026315=i_set_art_str(g_iartout,$TsymphovxNdcs::ECC_FACT,pt_nomECCFact_860026315)

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

#---------------------------------------------------------------------------
# 16x
#---------------------------------------------------------------------------

SI !(i_ChercherCouranteECC(inst16x_860026315))
ALORS
	res_860026315=i_stocke_art_iecc(g_iartout2,inst16x_860026315)
FINSI

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

SI !(i_ChercherCouranteECC(instSYMPHO_860026315))
ALORS
	res_860026315=i_stocke_art_iecc(g_iartout,instSYMPHO_860026315)
FINSI

RETOUR TRAIT_OK

############################################################################
# Envoi vers Recyclage
############################################################################

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

POINT DISTRI_ERR

trace( "========== Pcode de distribution: TvxNdcs => ENVOI EN ERRONE =================")
erreur_860026315 = i_make_art_rej(g_iartin, g_iartout, code_errone_860026315)
res_860026315=i_stocke_art(g_iartout,0,PT_ERRONE,0)

RETOUR TRAIT_OK
