DEFINITION LIGNE_METROPOLE_860026282 7
DEFINITION NUMTAB_860026282 1
DEFINITION NUMTABSEL_860026282 1
DEFINITION C_InstCOMPTI_860026282 "COMPTI"
DEFINITION C_Inst16X_860026282 "16X"
DEFINITION C_InstSYMPH_860026282 "SYMP"
DEFINITION C_Article_860026282 "Tindc1r"
DEFINITION C_T16xin_860026282 "T16xin"
DEFINITION C_TcomptiBD_860026282 "TcomptiBD"
DEFINITION C_TSymTindc1r_860026282 "TsymTindc1r"
REGISTRE ENTIER EFFICACE_860026282
REGISTRE ENTIER DUREE_ABER_860026282
REGISTRE ENTIER TAPPEL_860026282
REGISTRE ENTIER INEF_860026282
REGISTRE ENTIER CAP4_DUR_860026282
REGISTRE ENTIER DISC_860026282
REGISTRE ENTIER IDUS_INF_860026282
REGISTRE ENTIER b16X_860026282
REGISTRE ENTIER date_metropole_860026282
REGISTRE ENTIER date_locale_860026282
REGISTRE ENTIER date_locale_fin_860026282
REGISTRE ENTIER date_locale_SIP_860026282
REGISTRE ENTIER date_pivot_860026282
REGISTRE ENTIER SIP_ICAR_860026282
REGISTRE ENTIER ICAR_UTC_860026282
REGISTRE ENTIER inst16X_860026282
REGISTRE ENTIER instCOMPTI_860026282
REGISTRE ENTIER instSYMPH_860026282
REGISTRE ENTIER erreur_860026282
REGISTRE ENTIER res_860026282
REGISTRE ENTIER code_errone_860026282
REGISTRE ENTIER icar_860026282
REGISTRE ENTIER PSTIME_860026282
REGISTRE ENTIER DUREM_860026282
REGISTRE ENTIER DUR_860026282
REGISTRE ENTIER TAP_IP_860026282
REGISTRE ENTIER sran_860026282
REGISTRE ENTIER typort_860026282
REGISTRE ENTIER taille_idus_860026282
REGISTRE ENTIER taille_nde_860026282
REGISTRE ENTIER ZONE1_860026282
REGISTRE ENTIER taille_max_860026282
REGISTRE ENTIER indice_860026282
REGISTRE ENTIER valeur_860026282
REGISTRE ENTIER valeur1_860026282
REGISTRE ENTIER valeur2_860026282
REGISTRE ENTIER diviseur_860026282
REGISTRE ENTIER l_resul_860026282
REGISTRE ENTIER stopinfo_connect_860026282
REGISTRE ENTIER stopinfo_disc_860026282
REGISTRE ENTIER auth_860026282
REGISTRE ENTIER IDUS_PRESENT_860026282
REGISTRE ENTIER taille_champ_860026282
REGISTRE POINTEUR pt_dig1_IDUS_860026282
REGISTRE POINTEUR pt_IDUS_N_860026282
REGISTRE POINTEUR pt_DEDE_N_860026282
REGISTRE POINTEUR pt_DEDE_NUM_860026282
REGISTRE POINTEUR pt_sgtqs_860026282
REGISTRE POINTEUR pt_BUF_860026282
REGISTRE POINTEUR pt_temp_860026282
REGISTRE POINTEUR pt_inef_860026282
REGISTRE POINTEUR pt_TAP_GH_860026282
REGISTRE POINTEUR pt_idus_num_860026282
REGISTRE POINTEUR pt_idus_fin_860026282
REGISTRE POINTEUR pt_dede_fin_860026282
REGISTRE POINTEUR pt_dede_num_860026282
REGISTRE POINTEUR pt_CLE_860026282
REGISTRE POINTEUR pt_PRNAME_860026282
REGISTRE POINTEUR pt_resul_860026282
REGISTRE POINTEUR pt_auth_860026282
REGISTRE POINTEUR pt_ECC_FACT_860026282
############################################################################
#
# Fichier : Tindc1r.src
#
#
#
# Distribution :  DC Internet IPADSL bas debit
#
#
# En sortie :
#    16X - T16xin - g_iartout2
#    COMPTISSIMO - TcomptiBD - g_iartout5
#    SYMPHONIE - TsymTindc1r - g_iartout6
#
# HISTORIQUE :
#	27/08/03 - NSA creation
#	10/10/03 - NSA FO 438 si retour CleIp mauvais l'envoi se fait tout de mjme vers FOR
#	17/10/03 - NSA NDR passe en ASCII. modif date_locale
#	05/11/03 - NSA FO460:LOGIN en dcb,FO465:ajout T3pas
#	10/11/03 - NSA Evol spec. passage des champs DUR,DISC,UNAME,TYPORT,IBYTES,OBYTES en optionnels
#	26/11/03 - NSA 	FO498: suppression de champs dans TcomptiBD
#			FO502: bourrage de LOGIN pour 16X
#			FO500: TcomptiBD champs INPACTVSA et OUTPACTVSA
#	28/01/04 - NSA Ajout de l'envoi vers Symphonie
#	01/04/04 - NSA 	Mise ` jour des codes errones,FO594: correction IDUS_N
#	16/04/04 - NSA FO587: taille superieur a 1000 octets
#	29/04/04 - NSA FO647: champ NDR devient optionnel
#		Utilisation du verbe pcode i_IntToIpAddr pour convertir adresse IP
#	12/05/04 - NSA Si IDUS absent envoi vers symphonie des T3idus et T3clientid avec L=0
#	18/06/04 - NSA FO718: envoi a tord vers FOR
#	12/07/04 - NSA FO742: pb configuration platine sur alarme 7621 envoi de g_iartout2 au lieu de g_iartin
#	12/07/04 - NSA FO754: supression de l'envoi a FOR et NOFOR
#	12/07/04 - NSA FO743: mise en commentaires de l'alarme 7621 vers INc
#	03/11/04 - DRE - FO 933 Champ VPN_NAME pour Internet RTC et ADSL
#	14/01/05 - DRE - FO 1052 distribution a Comptissimo de ADIP
#	26/01/05 - FAL - supression marques de compilation _65000xxxx
#	19/05/05 - DRE - (G2R1CaNG) ajout champ RAN_NAME et ACC_SESSION_ID pour 16X
#	08/06/05 - DRE - FO 1345 ajout champ Acc_Session_Id pour Comptissimo
#	15/09/05 - PSA - FO 1457 champ DUR non ajoute pour Comptissimo si absent en entree
#	13/10/05 - DRE - FO 1498 Ajouter le champ DUR avec pour valeur FFFFFFFF si le champ DUR est absent en entree
#	28/10/05 - DRE - FO 1544 pt_PRNAME doit etre augmentee pour etre superieure a 2*253 = 506
#	15/06/06 - PKH - FO 1826 pour Symphonie alimentation du champ DATE_LOCALE par les DCs metropoles
#	23/06/06 - PKH - FO 1847 Correction pour symponie des champs NDR et CLIENTID
#	12/02/07 - FAL - G2R2CkNS FO2110 i_optimArtTLV adaptation au patch P6
#	26/12/08 - PSA - G3R11Cy Prise en compte Z=7
#	13/08/10 - THE - G3R18 QC 407
#	30/09/11 - THE - VerifPcode
#
############################################################################
#
#
############################################################################
# Declarations
############################################################################

# VerifPcode

# VerifPcode

# Pointeurs
# VerifPcode


#---------------------------------------------------------------------------
# INITIALISATION
#---------------------------------------------------------------------------

b16X_860026282 = 0
TAP_IP_860026282=0
ZONE1_860026282 = -1
inst16X_860026282 = 0
instCOMPTI_860026282 = 0
instSYMPH_860026282 = 0
code_errone_860026282=0
#ZTS = 0
indice_860026282=0
taille_max_860026282=0
#taille_auth=0
valeur_860026282=0
l_resul_860026282=0
stopinfo_connect_860026282=0
stopinfo_disc_860026282=0
auth_860026282=0
IDUS_PRESENT_860026282=0
taille_champ_860026282=0

# Allocation
pt_BUF_860026282		 = "123456789123456789123456123451234567891234567891234561234512345678912345678912345612345123456789123456789123456123451234567891234567891234561234512345678912345678912345612345123456789123456789123456123451234567891234567891234561234512345678912345678912345612345"
pt_temp_860026282		 = "999912345999999999123459999123459999999991234599991234599999999912345999912345999999999123459999123459999999991234599991234599999999912345999912345999999999123459999123459999999991234599991234599999999912345999912345999999999123459999123459999999991234599991234"
pt_auth_860026282		 = "987654325999999999123459999123459999999991234599991234599999999912345999912345999999999123459999123459999999991234599991234599999999912345999912345999999999123459999123459999999991234599991234599999999912345999912345999999999123459999123459999999991234599991234\
99991234599999999912345999912345999999999123459999123459999999991234599991234599999999912345999912345999999999123459999123459999999991234599991234599999999912345999912345999999999123459999123459999999991234599991234599999999912345999912345999999999123459999123555555554"
pt_idus_num_860026282	 = "44444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444"
pt_idus_fin_860026282	 = "555555555"
pt_dede_fin_860026282	 = "666666666"
pt_dig1_IDUS_860026282	 ="7777"
pt_IDUS_N_860026282		 ="88888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888"
pt_dede_num_860026282	 = "01010101010100101010101010101010101010101010101010101001010101010101010101010101010101010101010010101010101010101010101010101010101010100101010101010101010101010101010101010101001010101010101010101010101010101010101010010101010101010101010101010101010101010101"
pt_DEDE_N_860026282		 = "03030303030303030303030303030303030303003030303030303030303030303030303030303003030303030303030303030303030303030303003030303030303030303030303030303030303003030303030303030303030303030303030303003030303030303030303030303030303030303003030303030303030303030303"
pt_DEDE_NUM_860026282	 = "04040404040404040404040404040404040404004040404040404040404040404040404040404004040404040404040404040404040404040404004040404040404040404040404040404040404004040404040404040404040404040404040404004040404040404040404040404040404040404004040404040404040404040404"
#DEDE_NORM	 ="020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020"
pt_sgtqs_860026282	 ="1111111111111111111111"
pt_inef_860026282		 ="22222222222222222222222"
pt_TAP_GH_860026282	 = "012312345012312345"
#pt_TAP_IP	 = "333333333333333333"
pt_CLE_860026282		 ="06060606060606060606"
#pt_InfoCompl	 ="333312345333312345"
pt_PRNAME_860026282	 ="05050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505\
05050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505"
pt_resul_860026282	 ="0808080808080080808080808080808080808080808080"
pt_ECC_FACT_860026282	 = "88888888888888888888"
#pt_PRNAME	 = "pt_PRNAME01234567890123456789"
#pt_auth		 = "pt_auth98765432109876543210"

i_strcpy(pt_ECC_FACT_860026282," ")
# VerifPcode
i_strcpy(pt_sgtqs_860026282,"")
i_strcpy(pt_BUF_860026282,"")
i_strcpy(pt_temp_860026282,"")
i_strcpy(pt_inef_860026282,"")
i_strcpy(pt_TAP_GH_860026282,"")
i_strcpy(pt_idus_num_860026282,"")
i_strcpy(pt_idus_fin_860026282,"")
i_strcpy(pt_dede_fin_860026282,"")
i_strcpy(pt_dede_num_860026282,"")
i_strcpy(pt_dig1_IDUS_860026282,"")
i_strcpy(pt_IDUS_N_860026282,"")
i_strcpy(pt_CLE_860026282,"")
i_strcpy(pt_DEDE_N_860026282,"")
i_strcpy(pt_DEDE_NUM_860026282,"")
i_strcpy(pt_PRNAME_860026282,"")
i_strcpy(pt_resul_860026282,"")
i_strcpy(pt_auth_860026282,"")

#trace("DISTRIBUTION - Tindc1r - DC IPADSL bas debit")

############################################################################
# Variables Fonctionnelles Globales
############################################################################
#---------------------------------------------------------------------------
# Test de presence de IDUS
#---------------------------------------------------------------------------

SI( i_valid_field_n(g_iartin,$Tindc1r::NDR))
ALORS
	IDUS_PRESENT_860026282=1
FINSI

#---------------------------------------------------------------------------
# PSTIME, DUREM et DUR
#---------------------------------------------------------------------------

SI( i_valid_field_n(g_iartin,$Tindc1r::PSTIME))
ALORS
	PSTIME_860026282= i_get_art_field (g_iartin, $PSTIME)
SINON
	PSTIME_860026282=0
FINSI

SI( i_valid_field_n(g_iartin,$Tindc1r::DUREM))
ALORS
	DUREM_860026282= i_get_art_field (g_iartin, $DUREM)
SINON
	DUREM_860026282=0
FINSI

SI( i_valid_field_n(g_iartin,$Tindc1r::DUR))
ALORS
	DUR_860026282= i_get_art_field (g_iartin, $DUR)
SINON
	DUR_860026282=0
FINSI

#----------------------------------------------------------------------------
# INEF et EFFICACE
#----------------------------------------------------------------------------

SI( i_valid_field_n(g_iartin,$Tindc1r::DISC) )
ALORS
	DISC_860026282=i_get_art_field(g_iartin,$DISC)
	stopinfo_disc_860026282=DISC_860026282

	SI(DISC_860026282==0)
	ALORS
		#champ present mais nul
		EFFICACE_860026282=0
		INEF_860026282=0xFFFF
	SINON
		INEF_860026282 = DISC_860026282
		erreur_860026282 = i_get_art_str( g_iartin, $DISC, pt_inef_860026282 )
		i_strcpy(pt_temp_860026282,EfficaceIP_860026233( "INa", pt_inef_860026282, i_get_art_field( g_iartin, $dpivot )))
		trace2("********* VALEUR du code efficace = <%s>", pt_temp_860026282, "")
		SI (!i_strcmp(pt_temp_860026282,"E"))
		ALORS
			EFFICACE_860026282 = 1
		SINON
			EFFICACE_860026282 = 0
		FINSI
	FINSI
SINON
	#champ non present
	EFFICACE_860026282=0
	INEF_860026282=0xFFFF
	stopinfo_disc_860026282=0
FINSI

#---------------------------------------------------------------------------
# DATE
#---------------------------------------------------------------------------

icar_860026282 = i_get_art_field(g_iartin, $Tindc1r::DATE)

SI (icar_860026282==-1)
ALORS
	code_errone_860026282 = 0xA080
	code_errone_860026282 = code_errone_860026282 + EFFICACE_860026282
	erreur_860026282 = i_PlvMessEmettre(8600,2,g_iartin,"",3,code_errone_860026282,"Tindc1r/Pas de DATE","i_get_art_field")
	SAUT DISTRI_ERR
FINSI

#----------------------------------------------------------------------------
# ICAR_UTC (date de debut)
#----------------------------------------------------------------------------

ICAR_UTC_860026282= icar_860026282-DUREM_860026282-DUR_860026282-PSTIME_860026282

#----------------------------------------------------------------------------
# SIP_ICAR
#----------------------------------------------------------------------------

SIP_ICAR_860026282= icar_860026282-DUREM_860026282-DUR_860026282

#----------------------------------------------------------------------------
# Creation de l'article Conversion
#----------------------------------------------------------------------------

erreur_860026282 = i_cree_art("Conversion",g_iartout13)

#----------------------------------------------------------------------------
# date_locale(date de debut) , date_locale_fin et date_locale_SIP
#----------------------------------------------------------------------------

SI IDUS_PRESENT_860026282==1
ALORS
	#NDR etant en ASCII en entree il faut le mettre dans Conversion (en hexa) pour pouvoir acceder
	#au ficher de zones et calculer la date locale
	# modif G2R1CaNG (ligne remonte avant le test de condition sur IDUS_PRESENT)
	# erreur = i_cree_art("Conversion",g_iartout13)
	erreur_860026282 = i_conv_field("NDR",g_iartin,3,g_iartout13,1,0)
	ZONE1_860026282 = i_DHgetZoneID(NUMTABSEL_860026282, g_iartout13)

	SI ZONE1_860026282 >= 0
	ALORS
		#decalage UTC --> heure locale de debut
		date_locale_860026282 = i_DHgetLocalTime(NUMTAB_860026282, ZONE1_860026282, ICAR_UTC_860026282)

		SI( date_locale_860026282 == -1 )
		ALORS
			code_errone_860026282 = 0xA080
			code_errone_860026282 = code_errone_860026282 + EFFICACE_860026282
			erreur_860026282 = i_PlvMessEmettre(8600,2,g_iartin,"",3,code_errone_860026282,C_TcomptiBD_860026282,"i_DHgetLocalTime")
			SAUT DISTRI_ERR
		FINSI
		#decalage UTC --> heure locale de fin
		date_locale_fin_860026282 = i_DHgetLocalTime(NUMTAB_860026282, ZONE1_860026282, icar_860026282)

		SI( date_locale_fin_860026282 == -1 )
		ALORS
			code_errone_860026282 = 0xA080
			code_errone_860026282 = code_errone_860026282 + EFFICACE_860026282
			erreur_860026282 = i_PlvMessEmettre(8600,2,g_iartin,"",3,code_errone_860026282,C_TcomptiBD_860026282,"i_DHgetLocalTime")
			SAUT DISTRI_ERR
		FINSI
		date_locale_SIP_860026282 = i_DHgetLocalTime(NUMTAB_860026282, ZONE1_860026282, SIP_ICAR_860026282)

		SI( date_locale_SIP_860026282 == -1 )
		ALORS
			code_errone_860026282 = 0xA080
			code_errone_860026282 = code_errone_860026282 + EFFICACE_860026282
			erreur_860026282 = i_PlvMessEmettre(8600,2,g_iartin,"",3,code_errone_860026282,C_TcomptiBD_860026282,"i_DHgetLocalTime")
			SAUT DISTRI_ERR
		FINSI
	SINON
		trace("zone de decalage non trouvee")
		date_locale_860026282 = i_cur_time()
		date_locale_fin_860026282 = i_cur_time()
		date_locale_SIP_860026282 = i_cur_time()
	FINSI

	# Creation de l'enveloppe optionnelle E_IPADSL pour passage vers IECC(dlot_rel)
	#---------------------
	#  AJOUT ENVELOPPE Optionelle:
	# Ajout enveloppe optionnelle E_IPADSL
	# Contient la date locale pour la distri
	#---------------------
	# Creation de l'enveloppe
	erreur_860026282 = i_add_opt( "E_IPADSL" )

	# champ T1 (=>  0x0E pour la reconnaissance de l'enveloppe,
	# par l'arbre de reconnaissance Dopt )
	# VerifPcode
	#erreur = i_set_attr_val_n( $E_IPADSL::T1, 0x0E )

	# Champ L1 (taille champ  = 0x05 octets)
	# VerifPcode
	#erreur = i_set_attr_val_n( $E_IPADSL::L1, 0x05 )

	#---------------------
	#  Mise a jour de l'ENVELOPPE Optionelle:
	# Contient la date de fin locale necessaire pour les metachamps de distri
	# Champ DATE
	erreur_860026282 = i_set_attr_val_n( $E_IPADSL::DATE_L, date_locale_fin_860026282)
FINSI

#----------------------------------------------------------------------------
# date_pivot
#----------------------------------------------------------------------------

#DATE

#decalage UTC --> metropole
date_pivot_860026282 = i_DHgetLocalTime(1, LIGNE_METROPOLE_860026282, ICAR_UTC_860026282)

SI ( date_pivot_860026282 == -1 )
ALORS
	code_errone_860026282 = 0xA080
	code_errone_860026282 = code_errone_860026282 + EFFICACE_860026282
	erreur_860026282 = i_PlvMessEmettre(8600,2,g_iartin,"",3,code_errone_860026282,C_TcomptiBD_860026282,"i_DHgetLocalTime")
	SAUT DISTRI_ERR
FINSI

#----------------------------------------------------------------------------
# CAP4_DUR
#----------------------------------------------------------------------------

SI (DUR_860026282 + PSTIME_860026282 <= 0xFFFFFF)
ALORS
	CAP4_DUR_860026282 = DUR_860026282 + PSTIME_860026282
SINON
	CAP4_DUR_860026282=0x010B31
FINSI

#----------------------------------------------------------------------------
# DUREE_ABER
#----------------------------------------------------------------------------

SI(CAP4_DUR_860026282 >0x010B30)
ALORS
	DUREE_ABER_860026282=1
SINON
	DUREE_ABER_860026282=0
FINSI

#----------------------------------------------------------------------------
# POSITIONNEMENT DES BITS "EFGH" DE TAP_IP"
#----------------------------------------------------------------------------

# ----------

SI(INEF_860026282==0xFFFF)
ALORS
	i_strcpy(pt_TAP_GH_860026282,"UUU")
SINON
	i_strcpy(pt_TAP_GH_860026282,CodeEffIP_860026233 ( "INa", pt_inef_860026282, i_get_art_field( g_iartin, $dpivot )))
FINSI
trace2("********* VALEUR de pt_TAP_GH = <%s>", pt_TAP_GH_860026282, "")
erreur_860026282 = i_strcmp(pt_TAP_GH_860026282,"01")

SI !erreur_860026282
# Affectation de la valeur "01" aux bits "GH" de "TAP_IP
ALORS
	TAP_IP_860026282 = TAP_IP_860026282 | 0x01
FINSI
erreur_860026282 = i_strcmp(pt_TAP_GH_860026282,"10")

# Affectation de la valeur "10" aux bits "GH" de TAP_IP
SI !erreur_860026282
ALORS
	TAP_IP_860026282 = TAP_IP_860026282 | 0x02
FINSI
erreur_860026282 = i_strcmp(pt_TAP_GH_860026282,"11")

# Affectation de la valeur "11" aux bits "GH" de TAP_IP
SI !erreur_860026282
ALORS
	TAP_IP_860026282 = TAP_IP_860026282 | 0x03
FINSI
trace( "********  FIN POSITIONNEMENT DES BITS EFGH DE TAP_IP  **********")

SI IDUS_PRESENT_860026282==1
ALORS
	#----------------------------------------------------------------------------
	# IDUS_INF et POSITIONNEMENT DES BITS ABCD DE TAP_IP et maj DE TAPPEL
	#----------------------------------------------------------------------------
	erreur_860026282 = i_get_art_str( g_iartin, $NDR, pt_idus_num_860026282 )
	i_get_sub_str( pt_idus_num_860026282, -1, -1, pt_idus_fin_860026282 )
	taille_idus_860026282=i_strlen(pt_idus_num_860026282)
	i_get_sub_str( pt_idus_num_860026282, 0, 0, pt_dig1_IDUS_860026282 )

	SI ( !i_strcmp(pt_idus_fin_860026282,"F") || !i_strcmp(pt_idus_fin_860026282,"f") )
	ALORS
		taille_idus_860026282 = taille_idus_860026282 - 1
	FINSI

	SI (taille_idus_860026282 != 9) || ( (taille_idus_860026282 == 9 && ( !i_strcmp(pt_dig1_IDUS_860026282,"0") || !i_strcmp(pt_dig1_IDUS_860026282,"8") ||!i_strcmp(pt_dig1_IDUS_860026282,"9") )) )
	ALORS
		IDUS_INF_860026282 =0xC0
	SINON
		IDUS_INF_860026282 =0x80
	FINSI

	SI ( (taille_idus_860026282 == 9 && ( !i_strcmp(pt_dig1_IDUS_860026282,"0") || !i_strcmp(pt_dig1_IDUS_860026282,"8") ||!i_strcmp(pt_dig1_IDUS_860026282,"9") )) )
	ALORS
		# Appel international en provenance d un operateur tiers
		# Affectation de la valeur "1010" aux bits "ABCD" de TAP_IP
		# Affectation de la valeur "11" aux bits "AB" de IDUS_INF

		# IDUS_INF =0xC0
		TAP_IP_860026282 = TAP_IP_860026282 | 0xA0
		TAPPEL_860026282 =1
	SINON
		# Affectation de la valeur "10" aux bits "AB" de IDUS_INF
		# IDUS_INF =0x80

		SI(taille_idus_860026282 == 9 && ( !i_strcmp(pt_dig1_IDUS_860026282,"6") || !i_strcmp(pt_dig1_IDUS_860026282,"7") ) )
		ALORS
			# Appel national mobile hors roaming
			# Affectation de la valeur "0001" aux bits "ABCD" de TAP_IP
			TAP_IP_860026282 =TAP_IP_860026282 |0x10
			TAPPEL_860026282 =1
		SINON
			SI(taille_idus_860026282 == 9 && ( !i_strcmp(pt_dig1_IDUS_860026282,"1") || !i_strcmp(pt_dig1_IDUS_860026282,"2") || !i_strcmp(pt_dig1_IDUS_860026282,"3") || !i_strcmp(pt_dig1_IDUS_860026282,"4") ||!i_strcmp(pt_dig1_IDUS_860026282,"5") ))
			ALORS
				# Appel national fixe FT
				# Affectation de la valeur "0000" aux bits "ABCD" de TAP_IP
				TAP_IP_860026282 =TAP_IP_860026282 |0x00
				TAPPEL_860026282 =0
			SINON
				# Appel national inconnu
				# Affectation de la valeur "0111" aux bits "ABCD" de TAP_IP
				TAP_IP_860026282 =TAP_IP_860026282 |0x70
				TAPPEL_860026282 =0
			FINSI
		FINSI
	FINSI

	#----------------------------------------------------------------------------
	# IDUS_N
	#----------------------------------------------------------------------------
	SI (taille_idus_860026282 >8)
	ALORS
		# prendre les 8 premiers octets
		i_get_sub_str( pt_idus_num_860026282, 0, 8, pt_idus_num_860026282 )
		i_strcpy(pt_IDUS_N_860026282,pt_idus_num_860026282)
	SINON
		# IDUS_NUM avec suppression des quartets de droite qui sont ` F
		i_strcpy(pt_IDUS_N_860026282,pt_idus_num_860026282)
	FINSI
FINSI

#----------------------------------------------------------------------------
# DEDE_NUM et DEDE_N
#----------------------------------------------------------------------------

erreur_860026282 = i_get_art_str( g_iartin, $DEDE_NUM, pt_dede_num_860026282 )
i_get_sub_str( pt_dede_num_860026282, -1, -1, pt_dede_fin_860026282 )
taille_nde_860026282=i_strlen(pt_dede_num_860026282)

SI (!i_strcmp(pt_dede_fin_860026282,"F") || !i_strcmp(pt_dede_fin_860026282,"f"))
ALORS
	taille_nde_860026282 = taille_nde_860026282 - 1
FINSI

SI (taille_nde_860026282 < 10)
ALORS
	i_strcpy(pt_DEDE_NUM_860026282,pt_dede_num_860026282)
SINON
	trace("Erreur taille du champ DEDE.NUM !!")
	code_errone_860026282 = 0xA050
	code_errone_860026282 = code_errone_860026282 + EFFICACE_860026282
	erreur_860026282 = i_PlvMessEmettre(7620,2,g_iartin,"",2,code_errone_860026282,C_Article_860026282,0)
	SAUT DISTRI_ERR
FINSI

# Cas ou la longueur de DEDE_NUM est sur 9 ou 4 digits
SI ((taille_nde_860026282 != 4) && (taille_nde_860026282 != 9))
ALORS
	trace("Erreur taille du champ DEDE.NUM !!")
	code_errone_860026282 = 0xA050
	code_errone_860026282 = code_errone_860026282 + EFFICACE_860026282
	erreur_860026282 = i_PlvMessEmettre(7620,2,g_iartin,"",2,code_errone_860026282,C_Article_860026282,0)
	SAUT DISTRI_ERR
SINON
	# Test si la longueur du DEDE.NUM == 4

	SI (taille_nde_860026282 == 4)
	ALORS
		i_strcpy(pt_DEDE_N_860026282,DEDE9_860026233("INb",pt_dede_num_860026282, i_get_art_field( g_iartin, $dpivot )))
		erreur_860026282 = i_strcmp(pt_DEDE_N_860026282,"0")

		SI !erreur_860026282
		ALORS
			erreur_860026282 = i_PlvMessEmettre(7621,2,g_iartin,"",3,C_Article_860026282, pt_dede_num_860026282,"INb")
			i_strcpy(pt_CLE_860026282,"0")
			i_strcpy(pt_DEDE_N_860026282,pt_dede_num_860026282)
		FINSI
	SINON
		i_strcpy(pt_DEDE_N_860026282,pt_DEDE_NUM_860026282)
	FINSI
FINSI

SI IDUS_PRESENT_860026282==1
ALORS
	#----------------------------------------------------------------------------
	# CLE
	#----------------------------------------------------------------------------
	i_strcpy(pt_CLE_860026282,CleIP_860026233("INc",pt_DEDE_N_860026282, i_get_art_field( g_iartin, $dpivot )))
	erreur_860026282 = i_strcmp(pt_CLE_860026282,"0")

	SI !erreur_860026282
	ALORS
		#erreur = i_PlvMessEmettre(7621,2,g_iartin,"",3,C_Article,pt_dede_num,"INc")
		i_strcpy(pt_CLE_860026282,"0")
	FINSI
	erreur_860026282= i_format_str2(pt_temp_860026282,"%s%s","0",pt_CLE_860026282)
	erreur_860026282 = i_set_art_str( g_iartout13, $Conversion::CAP4_CLE, pt_temp_860026282 )
FINSI

#----------------------------------------------------------------------------
# SGTQS
#
#----------------------------------------------------------------------------

i_strcpy(pt_sgtqs_860026282,i_LireEECSGTQS( g_ieec ))

############################################################################
# Controles
############################################################################


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

#trace("----------- Recherche des instances --------------")

#---------------------------------------------------------------------------
#  16X
#---------------------------------------------------------------------------

inst16X_860026282=i_LireInstanceECC(C_Inst16X_860026282)
SI (inst16X_860026282 <= 0)
ALORS
	trace( "pas d instance 16X " )
	b16X_860026282=0
	code_errone_860026282 = 0xA0B0
	code_errone_860026282 = code_errone_860026282 + EFFICACE_860026282
	erreur_860026282 = i_PlvMessEmettre(8601,2,g_iartin,"",3,code_errone_860026282,C_Inst16X_860026282,C_Article_860026282)
	SAUT DISTRI_ERR
FINSI

#---------------------------------------------------------------------------
#  COMPTISSIMO
#---------------------------------------------------------------------------

instCOMPTI_860026282=i_LireInstanceECC(C_InstCOMPTI_860026282)
#trace1("instCOMPTI=<%d>",instCOMPTI)
SI (!instCOMPTI_860026282 )
ALORS
	trace("pas d instance COMPTISSIMO")
	code_errone_860026282 = 0xA0B0
	code_errone_860026282 = code_errone_860026282 + EFFICACE_860026282
	erreur_860026282 = i_PlvMessEmettre(8601,2,g_iartin,"",3,code_errone_860026282,C_InstCOMPTI_860026282,C_Article_860026282)
	SAUT DISTRI_ERR
FINSI

#---------------------------------------------------------------------------
#  SYMPHONIE
#---------------------------------------------------------------------------

instSYMPH_860026282=i_LireInstanceECC(C_InstSYMPH_860026282)
#trace1("instSYMPH=<%d>",instSYMPH)
SI (!instSYMPH_860026282 )
ALORS
	trace("pas d instance SYMPHONIE")
	code_errone_860026282 = 0xA0B0
	code_errone_860026282 = code_errone_860026282 + EFFICACE_860026282
	erreur_860026282 = i_PlvMessEmettre(8601,2,g_iartin,"",3,code_errone_860026282,C_InstSYMPH_860026282,C_Article_860026282)
	SAUT DISTRI_ERR
FINSI

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

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

#---------------------------------------------------------------------------
# Ajout de 16X a la liste
#---------------------------------------------------------------------------
erreur_860026282 = i_strcmp(pt_CLE_860026282,"04")
SI ( (DUREE_ABER_860026282 == 0) && (TAPPEL_860026282 == 0) && (EFFICACE_860026282 == 1) && (erreur_860026282 == 0) && (IDUS_PRESENT_860026282==1))
ALORS
	#Appels nationaux efficaces avec une duree non aberrante qui ne sont pas dans le referentiel FOR
	b16X_860026282 = 1
	erreur_860026282 = i_AjouterCouranteECC(inst16X_860026282)
FINSI

#---------------------------------------------------------------------------
# Ajout de COMPTISSIMO a la liste
#---------------------------------------------------------------------------
# Tous les appels
erreur_860026282 = i_AjouterCouranteECC(instCOMPTI_860026282)

#---------------------------------------------------------------------------
# Ajout de SYMPHONIE a la liste
#---------------------------------------------------------------------------
# Tous les appels
erreur_860026282 = i_AjouterCouranteECC(instSYMPH_860026282)

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

#---------------------------------------------------------------------------
# COMPTISSIMO
#---------------------------------------------------------------------------

SI ( !i_ChercherCouranteECC(instCOMPTI_860026282) )
ALORS
	# Duplication de l article
	#---------------------------
	#trace("Duplication vers COMPTISSIMO")

	SI ( i_dup_art(g_iartin,C_TcomptiBD_860026282,g_iartout5) )
	ALORS
		trace("Erreur de i_dup_art")
		code_errone_860026282 = 0xA0D0
		code_errone_860026282 = code_errone_860026282 + EFFICACE_860026282
		erreur_860026282 = i_PlvMessEmettre(8602,2,g_iartin,"",3,code_errone_860026282,C_TcomptiBD_860026282,C_Article_860026282)
		SAUT  DISTRI_ERR
	FINSI

	# MAJ pt_ECC_FACT
	i_strcpy(pt_ECC_FACT_860026282,"Compti")

	# Mise au format
	#------------------------------
	#ADIP
	#Le but est de tranformer une adresse IP qui est Hexa en entree, en adresse decimale
	#Exemple : pour ac15fec2, on doit avoir 172021254194
	# Le champs d'entree ADIP a ete decoupe en 4 sous champs de 1 octet (ADIP1 a 4)
	SI i_valid_field_n(g_iartin,$T3adip)
	ALORS
		erreur_860026282=i_ajoutChampNum(g_iartout5,$TcomptiBD::T3adip,$TcomptiBD::ADIP3,1)
		erreur_860026282=i_ajoutChampNum(g_iartout5,$TcomptiBD::T3adip,$TcomptiBD::ADIP4,1)
		valeur_860026282 = 0
		indice_860026282 = 0

		POINT Boucle1

		# Autant de passage que d'octets en entree (ici 4 octets)
		valeur_860026282 = valeur_860026282 + 1
		# Lecture du champs ADIP1 a 4 suivant valeur
		valeur1_860026282 = i_get_art_field(g_iartin,$Tindc1r::ADIP+valeur_860026282)
		diviseur_860026282 = 100

		POINT BoucleADIP

		# Cette boucle est effectue 3 fois (ex: 0x82 = 130 en dec)
		# Prendre chaque digit (130 = 3 digits) de valeur1 et les copier dans ADIP de sortie
		valeur2_860026282 = valeur1_860026282 / diviseur_860026282
		erreur_860026282 = i_set_art_fieldtab(g_iartout5,$TcomptiBD::ADIP,indice_860026282,valeur2_860026282)
		valeur1_860026282 = valeur1_860026282 - ( valeur2_860026282 * diviseur_860026282 )
		diviseur_860026282 = diviseur_860026282 / 10
		indice_860026282 = indice_860026282 + 1

		SI (diviseur_860026282 != 0)
		ALORS
			SAUT BoucleADIP
		FINSI

		SI (valeur_860026282 < 5)
		ALORS
			# Octet suivant (jusqu'a 4)
			SAUT Boucle1
		FINSI
		# Fin BoucleADIP
		# Fin Boucle1
	FINSI

	#DATE
	#decalage UTC --> metropole
	date_metropole_860026282 = i_DHgetLocalTime(1, LIGNE_METROPOLE_860026282, icar_860026282)

	SI ( date_metropole_860026282 == -1 )
	ALORS
		code_errone_860026282 = 0xA080
		code_errone_860026282 = code_errone_860026282 + EFFICACE_860026282
		erreur_860026282 = i_PlvMessEmettre(8600,2,g_iartin,"",3,code_errone_860026282,C_TcomptiBD_860026282,"i_DHgetLocalTime")
		SAUT DISTRI_ERR
	FINSI

	erreur_860026282 = i_set_art_field(g_iartout5, $TcomptiBD::DATE, date_metropole_860026282 )

	#DUR
	# FO1457 : Ajouter uniquement le T3DUR si le T3 est absent en entree
	SI( !i_valid_field_n(g_iartin,$Tindc1r::DUR))
	ALORS
		# FO1498 : Ajouter le champ DUR avec pour valeur FFFFFFFF si le champ DUR est absent en entree
		erreur_860026282 = i_ajoutChamp(g_iartout5, "T3dur", "DUR", 0x00)
		erreur_860026282 = i_memset_field_n(g_iartout5,$TcomptiBD::DUR,0xFF)
	FINSI

	#PAS
	erreur_860026282 = i_ajoutChamp(g_iartout5, "T3pas", "PAS", 0x01)
	erreur_860026282 = i_set_art_str( g_iartout5, $TcomptiBD::PAS,pt_sgtqs_860026282)

	#USER remplacement des caracteres ASCII < 32 et ; par -
	SI (i_valid_field_n(g_iartin, $Tindc1r::UNAME))
	ALORS
		taille_max_860026282=g_iartin.UNAME!NELEM
		indice_860026282=0
		valeur_860026282=0
		#boucle de lecture du champ
		POINT LECTURE_UNAME
		valeur_860026282=g_iartin.UNAME[indice_860026282]
		SI (indice_860026282 < taille_max_860026282)
		ALORS
			SI (valeur_860026282<0x20 || valeur_860026282==0x3b)
			ALORS
				g_iartout5.UNAME[indice_860026282]=0x2d
			SINON
				g_iartout5.UNAME[indice_860026282] = g_iartin.UNAME[indice_860026282]
			FINSI
			indice_860026282=indice_860026282+1
			SAUT LECTURE_UNAME
		FINSI
	FINSI

	#DOMAIN remplacement des caracteres ASCII < 32 et ; par -
	SI (i_valid_field_n(g_iartin, $Tindc1r::DNAME))
	ALORS
		taille_max_860026282=0
		taille_max_860026282=g_iartin.DNAME!NELEM
		indice_860026282=0
		valeur_860026282=0

		#boucle de lecture du champ

		POINT LECTURE_DNAME

		valeur_860026282=g_iartin.DNAME[indice_860026282]

		SI (indice_860026282 < taille_max_860026282)
		ALORS
			SI (valeur_860026282<0x20 || valeur_860026282==0x3b)
			ALORS
				g_iartout5.DNAME[indice_860026282] = 0x2d
			SINON
				g_iartout5.DNAME[indice_860026282] = g_iartin.DNAME[indice_860026282]
			FINSI
			indice_860026282=indice_860026282+1
			SAUT LECTURE_DNAME
		FINSI
	FINSI

	#VNAME
	SI (i_valid_field_n(g_iartin, $Tindc1r::VNAME))
	ALORS
		erreur_860026282= i_is_field_blanc(g_iartin,$VNAME)

		SI (erreur_860026282)
		ALORS
			erreur_860026282 = i_resize_tlv(g_iartout5, "T3vname", "VNAME", 5)
			erreur_860026282=i_set_art_str(g_iartout5, $TcomptiBD::VNAME,"AUTRE")
		SINON
			erreur_860026282 = i_get_art_str( g_iartin, $Tindc1r::VNAME, pt_PRNAME_860026282 )
			erreur_860026282 = i_set_art_str( g_iartout5, $TcomptiBD::VNAME, pt_PRNAME_860026282 )
		FINSI
	SINON
		erreur_860026282 = i_ajoutChamp(g_iartout5, "T3vname", "VNAME", 0x01)
		erreur_860026282 = i_resize_tlv(g_iartout5, "T3vname", "VNAME", 5)
		erreur_860026282 = i_set_art_str(g_iartout5, $TcomptiBD::VNAME,"AUTRE")
	FINSI

	#INOCTVSA
	SI (i_valid_field_n(g_iartin, $Tindc1r::IBYTES))
	ALORS
		erreur_860026282 = i_ajoutChamp(g_iartout5, "T3inoctvsa", "INOCTVSA1", 0x01)
		res_860026282 = i_get_art_field( g_iartin, $Tindc1r::IBYTES )
		erreur_860026282 = i_set_art_field( g_iartout5, $TcomptiBD::INOCTVSA2, res_860026282 )
		erreur_860026282 = i_set_art_field( g_iartout5, $TcomptiBD::INOCTVSA1, 0)
		erreur_860026282 = i_supprChamp(g_iartout5, "T3ibytes")
	FINSI

	#OUTOCTVSA
	SI (i_valid_field_n(g_iartin, $Tindc1r::OBYTES))
	ALORS

		erreur_860026282 = i_ajoutChamp(g_iartout5, "T3outoctvsa", "OUTOCTVSA1", 0x01)
		res_860026282 = i_get_art_field( g_iartin, $Tindc1r::OBYTES )
		erreur_860026282 = i_set_art_field( g_iartout5, $TcomptiBD::OUTOCTVSA2, res_860026282 )
		erreur_860026282 = i_set_art_field( g_iartout5, $TcomptiBD::OUTOCTVSA1, 0)
		erreur_860026282 = i_supprChamp(g_iartout5, "T3obytes")
	FINSI

	#INPACVSA
	SI (i_valid_field_n(g_iartin, $Tindc1r::T3inpackets))
	ALORS
		erreur_860026282 = i_ajoutChamp(g_iartout5, "T3inpacvsa", "INPACVSA1", 0x01)
		erreur_860026282 = i_set_art_field( g_iartout5, $TcomptiBD::INPACVSA1, 0)
		res_860026282 = i_get_art_field( g_iartin, $Tindc1r::INPACKETS )
		erreur_860026282 = i_set_art_field( g_iartout5, $TcomptiBD::INPACVSA2, res_860026282 )
		erreur_860026282 = i_supprChamp(g_iartout5, "T3inpackets")
	FINSI

	#OUTPACVSA
	SI (i_valid_field_n(g_iartin, $Tindc1r::T3outpackets))
	ALORS
		erreur_860026282 = i_ajoutChamp(g_iartout5, "T3outpacvsa", "", 0)
		erreur_860026282 = i_set_art_field( g_iartout5, $TcomptiBD::OUTPACVSA1, 0)
		res_860026282 = i_get_art_field( g_iartin, $Tindc1r::OUTPACKETS )
		erreur_860026282 = i_set_art_field( g_iartout5, $TcomptiBD::OUTPACVSA2, res_860026282 )
		erreur_860026282 = i_supprChamp(g_iartout5, "T3outpackets")
	FINSI

	#***********Suppression des champs T3fipnetmask,T3sessionid,T3sranid, T3nasipaddr
	SI( i_valid_field_n(g_iartout5,$TcomptiBD::T3fipnetmask))
	ALORS
		erreur_860026282 = i_supprChamp(g_iartout5, "T3fipnetmask")
	FINSI

	SI( i_valid_field_n(g_iartout5,$TcomptiBD::T3sranid))
	ALORS
		erreur_860026282 = i_supprChamp(g_iartout5, "T3sranid")
	FINSI

	SI( i_valid_field_n(g_iartout5,$TcomptiBD::T3nasipaddr))
	ALORS
		erreur_860026282 = i_supprChamp(g_iartout5, "T3nasipaddr")
	FINSI

	#***********Suppression des champs ajoutis par le convertisseur automatiquement

	SI( i_valid_field_n(g_iartout5,$TcomptiBD::T3term))
	ALORS
		erreur_860026282 = i_supprChamp(g_iartout5, "T3term")
	FINSI

	SI( i_valid_field_n(g_iartout5,$TcomptiBD::T3ingigaw))
	ALORS
		erreur_860026282 = i_supprChamp(g_iartout5, "T3ingigaw")
	FINSI

	SI( i_valid_field_n(g_iartout5,$TcomptiBD::T3outgigaw))
	ALORS
		erreur_860026282 = i_supprChamp(g_iartout5, "T3outgigaw")
	FINSI
FINSI

#---------------------------------------------------------------------------
# SYMPHONIE
#---------------------------------------------------------------------------

SI ( !i_ChercherCouranteECC(instSYMPH_860026282) )
ALORS
	# Duplication de l article
	#---------------------------
	#trace("Duplication vers SYMPHONIE")
	SI ( i_dup_art_tab(g_iartin,g_iartout6,C_TSymTindc1r_860026282) )
	ALORS
		trace("Erreur de i_dup_art")
		code_errone_860026282 = 0xA0D0
		code_errone_860026282 = code_errone_860026282 + EFFICACE_860026282
		erreur_860026282 = i_PlvMessEmettre(8602,2,g_iartin,"",3,code_errone_860026282,C_TSymTindc1r_860026282,C_Article_860026282)
		SAUT  DISTRI_ERR
	FINSI

	# Mise au format
	#------------------------------
	#*** Champs obligatoires ***

	#NDR et CLIENT_ID
	SI(IDUS_PRESENT_860026282==1)
	ALORS
		erreur_860026282=i_get_art_str(g_iartin,$NDR,pt_BUF_860026282)
		taille_champ_860026282=i_strlen(pt_BUF_860026282)
		erreur_860026282=i_resize_tlv(g_iartout6,"T3idus","NDR",taille_champ_860026282)
		erreur_860026282=i_set_art_str(g_iartout6,$TsymTindc1r::NDR,pt_BUF_860026282)
		
		# G3R18 QC 407
		SI taille_champ_860026282 >= 15
		ALORS
			i_get_sub_str( pt_BUF_860026282, 0, 15, pt_BUF_860026282 )
			erreur_860026282=i_resize_tlv(g_iartout6,"T3clientid","CLIENTID",16)
			erreur_860026282=i_set_art_str(g_iartout6,$TsymTindc1r::CLIENTID,pt_BUF_860026282)
		SINON
			erreur_860026282=i_resize_tlv(g_iartout6,"T3clientid","CLIENTID",taille_champ_860026282)
			erreur_860026282=i_set_art_str(g_iartout6,$TsymTindc1r::CLIENTID,pt_BUF_860026282)
		FINSI
		#\G3R18 QC 407
	SINON
		erreur_860026282=i_supprChamp(g_iartout6,"NDR")
		erreur_860026282=i_supprChamp(g_iartout6,"CLIENTID")
	FINSI

	#DEDE_NUM
	erreur_860026282=i_get_art_str(g_iartin,$DEDE_NUM,pt_BUF_860026282)
	taille_champ_860026282=i_strlen(pt_BUF_860026282)
	erreur_860026282=i_resize_tlv(g_iartout6,"T3dede","DEDE_NUM",taille_champ_860026282)
	erreur_860026282=i_set_art_str(g_iartout6,$TsymTindc1r::DEDE_NUM,pt_BUF_860026282)

	#SESSION_ID
	SI (i_valid_field_n(g_iartin, $Tindc1r::SESSIONID))
	ALORS
		erreur_860026282 = i_ajoutChamp(g_iartout6, "T3sessionid", "SESSIONID", 0x10)
		erreur_860026282=i_get_art_str(g_iartin,$SESSIONID,pt_BUF_860026282)
		erreur_860026282=i_set_art_str(g_iartout6,$TsymTindc1r::SESSIONID,pt_BUF_860026282)
	FINSI

	#RNAME
	erreur_860026282=i_get_art_str(g_iartin,$RNAME,pt_BUF_860026282)
	taille_champ_860026282=i_strlen(pt_BUF_860026282)
	erreur_860026282=i_resize_tlv(g_iartout6,"T3rname","RNAME",taille_champ_860026282)
	erreur_860026282=i_set_art_str(g_iartout6,$TsymTindc1r::RNAME,pt_BUF_860026282)

	#RANTYPE
	erreur_860026282=i_set_art_str(g_iartout6,$TsymTindc1r::RANTYPE,"NAS")

	#*** Champs facultatifs ***

	#PRNAME
	SI (i_valid_field_n(g_iartin, $Tindc1r::T3prname))
	ALORS
		erreur_860026282 = i_ajoutChamp(g_iartout6, "T3prname", "PRNAME", 0x10)
		erreur_860026282=i_get_art_str(g_iartin,$PRNAME,pt_BUF_860026282)
		erreur_860026282=i_set_art_str(g_iartout6,$TsymTindc1r::PRNAME,pt_BUF_860026282)
	FINSI

	#AUTH = USER + DOMAIN
	SI (i_valid_field_n(g_iartin, $Tindc1r::UNAME) || i_valid_field_n(g_iartin, $Tindc1r::DNAME))
	ALORS
		erreur_860026282 = i_ajoutChamp(g_iartout6, "T3auth", "AUTH", 0x01)
		SI (i_valid_field_n(g_iartin, $Tindc1r::UNAME))
		ALORS
			erreur_860026282=i_get_art_str(g_iartout5,$TcomptiBD::UNAME_ASCII,pt_temp_860026282)
			auth_860026282=1
			erreur_860026282= i_format_str2(pt_BUF_860026282,"%s%s",pt_temp_860026282," ")
		FINSI

		#DOMAIN
		SI (i_valid_field_n(g_iartin, $Tindc1r::DNAME))
		ALORS
			erreur_860026282=i_get_art_str(g_iartout5,$TcomptiBD::DNAME_ASCII,pt_temp_860026282)
			SI( auth_860026282==1)
			ALORS
				erreur_860026282= i_format_str2(pt_auth_860026282,"%s%s",pt_BUF_860026282,pt_temp_860026282)
			SINON
				i_strcpy(pt_auth_860026282,pt_temp_860026282)
			FINSI
			auth_860026282=2
		FINSI

		SI(auth_860026282 ==1)
		ALORS
			taille_champ_860026282=i_strlen(pt_BUF_860026282)
			erreur_860026282=i_resize_tlv(g_iartout6,"T3auth","AUTH",taille_champ_860026282)
			erreur_860026282 = i_set_art_str(g_iartout6, $TsymTindc1r::AUTH,pt_BUF_860026282)
		SINON
			taille_champ_860026282=i_strlen(pt_auth_860026282)
			erreur_860026282=i_resize_tlv(g_iartout6,"T3auth","AUTH",taille_champ_860026282)
			erreur_860026282 = i_set_art_str(g_iartout6, $TsymTindc1r::AUTH,pt_auth_860026282)
		FINSI
	FINSI

	#FAI
	SI( i_valid_field_n(g_iartin,$Tindc1r::UNAME_ASCII) )
	ALORS

		erreur_860026282=i_get_art_str(g_iartin,$UNAME_ASCII,pt_BUF_860026282)
		i_get_sub_str(pt_BUF_860026282,0,3,pt_temp_860026282)
		res_860026282=i_strcmp(pt_temp_860026282,"fti/")
		SI ( res_860026282 == 0)
		ALORS
			i_strcpy(pt_temp_860026282,"Wanadoo")
			erreur_860026282 = i_ajoutChamp(g_iartout6, "T3fai", "FAI", 0x01)
			taille_champ_860026282=i_strlen(pt_temp_860026282)
			erreur_860026282=i_resize_tlv(g_iartout6,"T3fai","FAI",taille_champ_860026282)
			erreur_860026282 = i_set_art_str(g_iartout6, $TsymTindc1r::FAI,pt_temp_860026282)
		SINON
			SI( i_valid_field_n(g_iartin,$Tindc1r::DNAME_ASCII) )
			ALORS
				erreur_860026282=i_get_art_str(g_iartout5,$TcomptiBD::DNAME_ASCII,pt_temp_860026282)
				erreur_860026282 = i_ajoutChamp(g_iartout6, "T3fai", "FAI", 0x01)
				taille_champ_860026282=i_strlen(pt_temp_860026282)
				erreur_860026282=i_resize_tlv(g_iartout6,"T3fai","FAI",taille_champ_860026282)
				erreur_860026282 = i_set_art_str(g_iartout6, $TsymTindc1r::FAI,pt_temp_860026282)
			FINSI
		FINSI

	FINSI

	#DATE ICAR_UTC
	erreur_860026282 = i_ajoutChamp(g_iartout6, "T3date", "DATE", 0x01)
	erreur_860026282 = i_set_art_field(g_iartout6, $TsymTindc1r::DATE, ICAR_UTC_860026282 )

	#STOPINFO
	SI( !i_valid_field_n(g_iartin,$Tindc1r::DISC) && !i_valid_field_n(g_iartin,$Tindc1r::CONNECT) )
	ALORS
		trace("ne pas creer le champ ")
	SINON
		erreur_860026282 = i_ajoutChamp(g_iartout6, "T3stopinfo", "", 0x01)

		SI( i_valid_field_n(g_iartin,$Tindc1r::CONNECT))
		ALORS
			stopinfo_connect_860026282= i_get_art_field (g_iartin, $CONNECT)
		SINON
			stopinfo_connect_860026282= 0
		FINSI
		erreur_860026282 = i_set_art_field( g_iartout6, $TsymTindc1r::STOPINFO_DISC, stopinfo_disc_860026282)
		erreur_860026282 = i_set_art_field( g_iartout6, $TsymTindc1r::STOPINFO_CON, stopinfo_connect_860026282)
	FINSI

	# USERADIP (octets de ADIP separes par des points)
	SI( i_valid_field_n(g_iartin,$Tindc1r::ADIP))
	ALORS
		erreur_860026282 = i_ajoutChamp(g_iartout6, "T3adip", "", 0x01)
		i_IntToIpAddr( i_get_art_field (g_iartin, $ADIP),pt_resul_860026282)
		erreur_860026282 = i_set_art_str( g_iartout6,$TsymTindc1r::ADIP,pt_resul_860026282 )
	FINSI

	# SGTQS
	erreur_860026282 = i_set_art_str(g_iartout6, $TsymTindc1r::SGTQS, pt_sgtqs_860026282)

	# ECC FACT
	erreur_860026282 = i_set_art_str(g_iartout6, $TsymTindc1r::ECC_FACT, pt_ECC_FACT_860026282)


	# DATE_LOCALE
	# Creation du champ uniquement si DOM
	#FO1826 15/06/2006 ajout des sessions Metropoles pour le champ DATE_LOCALE
	#SI(ZONE1 != 7 && IDUS_PRESENT==1)

	SI ( IDUS_PRESENT_860026282 == 1)
	ALORS
		erreur_860026282 = i_ajoutChampNum( g_iartout6, $TsymTindc1r::T4datelocale, $TsymTindc1r::DATE_LOCALE, 0 )
		erreur_860026282 = i_set_art_field(g_iartout6, $TsymTindc1r::DATE_LOCALE, date_locale_860026282 )
	FINSI

	# EFFICACITE
	erreur_860026282 = i_set_art_field(g_iartout6, $TsymTindc1r::EFFICACITE, EFFICACE_860026282 )

	# FO2110 supression des blancs de bourrage dans tous les champs
	erreur_860026282=i_optimArtTLV(g_iartout6,g_iartout6)
FINSI

#---------------------------------------------------------------------------
# 16X
#---------------------------------------------------------------------------

SI ( !i_ChercherCouranteECC(inst16X_860026282) )
ALORS
	# Duplication de l article
	#---------------------------
	#trace("Duplication vers 16X")

	SI ( i_dup_art_dest(g_iartin,g_iartout2,C_T16xin_860026282) )
	ALORS
		trace("Erreur de i_dup_art_dest")
		code_errone_860026282 = 0xA0D0
		code_errone_860026282 = code_errone_860026282 + EFFICACE_860026282
		erreur_860026282 = i_PlvMessEmettre(8602,2,g_iartin,"",3,code_errone_860026282,C_T16xin_860026282,C_Article_860026282)
		SAUT  DISTRI_ERR
	FINSI

	# Mise au format
	#------------------------------

	#champ G2_TAP_IP
	erreur_860026282 = i_set_art_field( g_iartout2, $T16xin::G2_TAP_IP, TAP_IP_860026282 )

	#champ G2_DATE
	erreur_860026282 = i_set_art_field(g_iartout2, $T16xin::G2_DATE, date_locale_860026282 )

	#champ G2-INEF
	erreur_860026282 = i_set_art_field(g_iartout2, $T16xin::G2_INEF, INEF_860026282 )

	#champ RAN
	SI( i_valid_field_n(g_iartin,$Tindc1r::SRANID))
	ALORS
		sran_860026282  = i_get_art_field( g_iartin, $Tindc1r::SRANID)
		sran_860026282= sran_860026282/0x10000
		erreur_860026282 = i_set_art_field(g_iartout2, $T16xin::RAN, sran_860026282 )
	SINON
		#trace("T3sranid absent !")
		erreur_860026282=i_memset_field_n(g_iartout2, $T16xin::RAN, 0xF0)
	FINSI

	#champ SESSION_ID
	SI (i_valid_field_n (g_iartin, $Tindc1r::SESSIONID) )
	ALORS
		erreur_860026282 = i_get_art_str( g_iartin, $Tindc1r::SESSIONID, pt_BUF_860026282 )
		i_get_sub_str(pt_BUF_860026282,-3,-1,pt_BUF_860026282)
		erreur_860026282= i_format_str2(pt_temp_860026282,"%s%s","00000",pt_BUF_860026282)
		erreur_860026282 = i_set_art_str( g_iartout13, $Conversion::SESSION_ID, pt_temp_860026282 )
		erreur_860026282 = i_conv_field("SESSION_ID",g_iartout13, 3, g_iartout2, 4,0)
	SINON
		erreur_860026282 = i_memset_field_n(g_iartout2,$T16xin::SESSION_ID,0xF0)
	FINSI

	# IDUS_INF
	erreur_860026282 = i_set_art_field(g_iartout2, $T16xin::IDUS_INF, IDUS_INF_860026282 )

	# IDUS_NUM
	i_replace_str(pt_IDUS_N_860026282,"BCDE","AJSC",pt_IDUS_N_860026282)
	erreur_860026282=i_set_art_str(g_iartout2, $T16xin::IDUS_NUM, pt_IDUS_N_860026282)

	# DEDE_NUM
	i_replace_str(pt_DEDE_N_860026282,"BC","*#",pt_DEDE_N_860026282)
	erreur_860026282=i_set_art_str(g_iartout2, $T16xin::DEDE_NUM, pt_DEDE_N_860026282)

	# CAP4_DUR
	erreur_860026282 = i_set_art_field(g_iartout2, $T16xin::CAP4_DUR, CAP4_DUR_860026282 )

	# CAP4_CLE
	erreur_860026282 = i_conv_field("CAP4_CLE",g_iartout13, 3, g_iartout2, 4,0)

	# CAP4_SUP
	SI (i_valid_field_n (g_iartin, $Tindc1r::TYPORT) )
	ALORS
		typort_860026282 = i_get_art_field( g_iartin, $TYPORT)

		SI(typort_860026282==0 || typort_860026282 > 251)
		ALORS
			erreur_860026282=i_memset_field_n(g_iartout2, $T16xin::CAP4_SUP, 0xC6)
		SINON
			typort_860026282=typort_860026282+4
			erreur_860026282 = i_set_art_field(g_iartout2, $T16xin::CAP4_SUP, typort_860026282 )
		FINSI
	SINON
		#typort absent
		erreur_860026282=i_memset_field_n(g_iartout2, $T16xin::CAP4_SUP, 0xC6)
	FINSI

	# GIP_INET/ADIP
	SI (i_valid_field_n (g_iartin, $Tindc1r::ADIP) )
	ALORS
		erreur_860026282=i_conv_field("ADIP",g_iartout6,3,g_iartout2,4,0)
	SINON
		erreur_860026282=i_memset_field_n(g_iartout2, $T16xin::ADIP, 0xF0F0F0)
	FINSI

	#GIP_ZTS
	SI (i_valid_field_n (g_iartin, $Tindc1r::PRNAME) )
	ALORS
		erreur_860026282 = i_get_art_str( g_iartin, $Tindc1r::PRNAME, pt_PRNAME_860026282 )
		erreur_860026282= i_is_field_blanc(g_iartin,$PRNAME)

		SI (erreur_860026282==0)
		ALORS
			erreur_860026282= i_format_str2(pt_temp_860026282,"%s%s","INd",pt_PRNAME_860026282)
			i_strcpy(pt_BUF_860026282,i_get_tab_field( "Inter", date_pivot_860026282, pt_temp_860026282 ))
			#ZTS= resul de la table externe inter cle d entree INdxxxxxxx
			erreur_860026282 = i_strcmp(pt_BUF_860026282,g_inull)

			SI (erreur_860026282 == 0)
			ALORS
				#trace2( "ERREUR: cle <%s> non trouvee dans la table externe Inter", pt_temp,"" )
				erreur_860026282 = i_PlvMessEmettre( 8505, 2, g_iartin,"", 3, "Tindc1r/Inter ", pt_temp_860026282, g_ieec )
				i_strcpy(pt_BUF_860026282,"000")
			FINSI
			erreur_860026282= i_format_str2(pt_temp_860026282,"%s%s","000",pt_BUF_860026282)
			i_get_sub_str(pt_temp_860026282,-3,-1,pt_temp_860026282)
			erreur_860026282 = i_set_art_str( g_iartout13, $Conversion::GIP_ZTS, pt_temp_860026282 )
			erreur_860026282 = i_conv_field("GIP_ZTS",g_iartout13, 3, g_iartout2, 4,0)
		SINON
			erreur_860026282=i_memset_field_n(g_iartout2, $T16xin::GIP_ZTS, 0xC6C6C6)
		FINSI
	SINON
		erreur_860026282=i_memset_field_n(g_iartout2, $T16xin::GIP_ZTS, 0xC6C6C6)
	FINSI

	# LOGIN
	SI (i_valid_field_n (g_iartin, $Tindc1r::UNAME) )
	ALORS
		erreur_860026282 = i_get_art_str( g_iartin, $Tindc1r::UNAME, pt_PRNAME_860026282 )
		erreur_860026282= i_is_field_blanc(g_iartin,$UNAME)
		SI (erreur_860026282 == 0)
		ALORS
			res_860026282=i_strlen(pt_PRNAME_860026282)
			SI (res_860026282 > 32)
			ALORS
				i_get_sub_str(pt_PRNAME_860026282,0,31,pt_PRNAME_860026282)
			FINSI
			l_resul_860026282= i_conv_ascii_dcb(pt_PRNAME_860026282,pt_resul_860026282)
			i_get_sub_str(pt_resul_860026282,0,l_resul_860026282-1,pt_resul_860026282)

			erreur_860026282 = i_set_art_str( g_iartout2, $T16xin::LOGIN, pt_resul_860026282 )
		SINON
			erreur_860026282 = i_memset_field_n(g_iartout2,$T16xin::LOGIN,0x40)
		FINSI
	SINON
		erreur_860026282 = i_memset_field_n(g_iartout2,$T16xin::LOGIN,0x40)
	FINSI

	#SIP_DATE
	erreur_860026282 = i_set_art_field(g_iartout2, $T16xin::SIP_DATE, date_locale_SIP_860026282 )

	# SIP_DUR
	SI(DUR_860026282==0)
	ALORS
		erreur_860026282 = i_memset_field_n(g_iartout2,$T16xin::SIP_DUR,0xF0)
	SINON
		SI (DUR_860026282 < 0xFFFFFF)
		ALORS
			erreur_860026282 = i_set_art_field(g_iartout2, $T16xin::SIP_DUR, DUR_860026282 )
		SINON
			erreur_860026282 = i_memset_field_n(g_iartout2,$T16xin::SIP_DUR,0xC6)
		FINSI
	FINSI

	#champ RAN_NAME
	erreur_860026282 = i_get_art_str( g_iartin, $Tindc1r::RNAME, pt_BUF_860026282 )
	i_get_sub_str(pt_BUF_860026282,0,7,pt_BUF_860026282)
	erreur_860026282 = i_set_art_str( g_iartout13, $Conversion::RAN_NAME, pt_BUF_860026282 )
	erreur_860026282 = i_conv_field("RAN_NAME",g_iartout13, 3, g_iartout2, 4,0)

	#champ ACC_SESSION_ID
	SI (i_valid_field_n (g_iartin, $Tindc1r::SESSIONID) )
	ALORS
		erreur_860026282 = i_get_art_str( g_iartin, $Tindc1r::SESSIONID, pt_BUF_860026282 )
		i_get_sub_str(pt_BUF_860026282,0,9,pt_BUF_860026282)
		erreur_860026282 = i_set_art_str( g_iartout13, $Conversion::ACC_SESSION_ID, pt_BUF_860026282 )
		erreur_860026282 = i_conv_field("ACC_SESSION_ID",g_iartout13, 3, g_iartout2, 4,0)
	SINON
		erreur_860026282 = i_memset_field_n(g_iartout2,$T16xin::ACC_SESSION_ID,0xF0)
	FINSI
FINSI

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

#---------------------------------------------------------------------------
# 16X
#---------------------------------------------------------------------------

SI ( !i_ChercherCouranteECC(inst16X_860026282) )
ALORS
	res_860026282 = i_stocke_art_iecc(g_iartout2, inst16X_860026282)
	trace("Emission vers 16X")
FINSI

#---------------------------------------------------------------------------
# COMPTISSIMO
#---------------------------------------------------------------------------

SI ( !i_ChercherCouranteECC(instCOMPTI_860026282) )
ALORS
	res_860026282 = i_stocke_art_iecc(g_iartout5, instCOMPTI_860026282)
	trace("Emission vers COMPTISSIMO")
FINSI

#---------------------------------------------------------------------------
# SYMPHONIE
#---------------------------------------------------------------------------

SI ( !i_ChercherCouranteECC(instSYMPH_860026282) )
ALORS
	res_860026282 = i_stocke_art_iecc(g_iartout6,instSYMPH_860026282)
	trace("Emission vers SYMPHONIE")
FINSI

SAUT DISTRI_FIN

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

POINT DISTRI_ERR

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

# Debut modif FE1510

erreur_860026282 = i_make_art_rej(g_iartin, g_iartout, code_errone_860026282)
erreur_860026282 = i_stocke_art(g_iartout,0,PT_ERRONE,0)

SAUT DISTRI_FIN

POINT DISTRI_FIN

RETOUR TRAIT_OK
