DEFINITION Multidistribution_Non_660004639 0
DEFINITION DISTRIBUTION_INCONNU_660004639 1
DEFINITION TRAI_KO_660004639 -1
DEFINITION MODULE_DISTR_660004639 0xA000
DEFINITION ERR_DUPL_660004639 0x0D0
DEFINITION ERR_CONV_660004639 0x0E0
DEFINITION ERR_DISTR_660004639 0x110
REGISTRE ENTIER erreur_660004639
REGISTRE ENTIER flag_rdt_660004639
REGISTRE ENTIER taille_sender_660004639
REGISTRE ENTIER taille_callRefNb_660004639
REGISTRE ENTIER taille_mscAddress_660004639
REGISTRE ENTIER taille_mscAddr_660004639
REGISTRE ENTIER taille_serverAddr_660004639
REGISTRE ENTIER taille_srvAddr_660004639
REGISTRE ENTIER taille_DestNumber_660004639
REGISTRE ENTIER taille_DestNum_660004639
REGISTRE ENTIER taille_CseInfo_660004639
REGISTRE ENTIER indice_octet_660004639
REGISTRE ENTIER val_recEntityCode_660004639
REGISTRE ENTIER recmsisdn_present_660004639
REGISTRE ENTIER val_bearerCode_660004639
REGISTRE ENTIER bearerCode_660004639
REGISTRE ENTIER caract_660004639
REGISTRE ENTIER L_dcb_msisdn_660004639
REGISTRE ENTIER date_fin_660004639
REGISTRE POINTEUR pt_str_660004639
REGISTRE POINTEUR pt_recmsisdn_660004639
REGISTRE POINTEUR pt_msisdn_660004639
REGISTRE POINTEUR pt_dcb_msisdn_660004639
REGISTRE ENTIER code_rejet_660004639
REGISTRE ENTIER EFFICACE_660004639
REGISTRE ENTIER MODULE_660004639
REGISTRE ENTIER ERREUR_660004639
####################################################################
# Distribution Ttap310ZB_E_dis.src, Article EDS Zones Blanches Entrant (TAP 3.10)
#
#	Creation : 15/09/05 Par : AE
#	11/06/2010 - JLG - G2R6C800 : appel fonction aiguillage2, creation enveloppe E_Redistri2,
#					ajout champ T3t55 (GFlag2) et T3t56 (GValue)
#	07/12/2010 - BEA - G3R1 lot4 Verification/Correction des variables (constantes, entiers, pointeurs) !!! ATTENTION conv_Tap310ZB_GPRS_A5.0.doc champs de 5000 octets, seuls 2000 sont reserves dans pt_recmsisdn pour accueil de T3t3 recmsisdn !!!
# 31/01/2011 - modifification pointeur pt_codetype de 2000 a 1000 (evolution spec)
# 14/03/2011 - JLG - G3R2C4 fusion G3R2C3 avec G3R1C600 (ajout champ T3t99), QC821 modifification pointeur pt_recmsisdn de 2000 (evolution spec)
# 29/02/2012 - JLG -G3R6 QC1005 modif alarme retour aiguillage
# 11/02/2014 - JLG -G5R1 QC1331, Built 3 : Changement Marque Audit
# 02/07/2014 - JLG -G5R1 QC1405, champ eec du DPV si g_ieec > 500
####################################################################




trace("Ttap310ZB_E : Debut Distribution")

pt_str_660004639 = "12345678912345678912345678932145698745632145885996322214588752356"
pt_recmsisdn_660004639 = "pt_recmsisdn1212121212121212120123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789pt_recmsisdn1212121212121212120123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
pt_msisdn_660004639= "123456789123456789"
pt_dcb_msisdn_660004639 = "1234567812345678912345678912345678912355"

EFFICACE_660004639 = 1
MODULE_660004639 = MODULE_DISTR_660004639
ERREUR_660004639 = 0

i_strcpy(pt_str_660004639,"")
i_strcpy(pt_recmsisdn_660004639,"")
i_strcpy(pt_msisdn_660004639,"")
i_strcpy(pt_dcb_msisdn_660004639,"")

code_rejet_660004639 = 0

# FE_0028 comptabilisation des CRAs issus de la redistribution
date_fin_660004639=i_get_art_field(g_iartin,$Ttap310ZB_E::dfin)
erreur_660004639= i_incr_redist_dist_660004265(date_fin_660004639)

##################################################################################
# Identification de la provenance de l'article
# flag_rdt : nb de passage en redistribution (lecture de l'enveloppe obligatoire)
##################################################################################
flag_rdt_660004639 = -1
flag_rdt_660004639 = i_LireRedistCpt()

SI (flag_rdt_660004639 == 0)
ALORS
	erreur_660004639 = i_add_opt( "E_Redistri2" )
FINSI
erreur_660004639 = i_set_attr_val_n( $E_Redistri2::EnvoiRedis, 0)
erreur_660004639 = i_get_field_str(g_iartin,"sender",pt_str_660004639)

#####################################################################
# Creation DPV
# Duplication en DPV TLV
#####################################################################
erreur_660004639 = i_dup_art_tab(g_iartin,g_iartout,"Tdpvgsm")

SI (erreur_660004639 != 0)
ALORS
	trace("Ttap310ZB_E : Creation DPV impossible => ERRONE")
	ERREUR_660004639 = ERR_DUPL_660004639
	code_rejet_660004639 = MODULE_660004639 + ERREUR_660004639 + EFFICACE_660004639
	erreur_660004639=i_PlvMessEmettre(8068, 2, g_iartin ,"" , 2, code_rejet_660004639, "Tdpvgsm", 0)
	SAUT STOCKE_ERRONE
FINSI

#####################################################################
#		Complement de duplication hors table
#####################################################################

#####################################################################
# Mise a jour du champ idemet (V3t1.3)
#####################################################################

#-- Appel a la fonction getMsisdn
recmsisdn_present_660004639 = i_valid_field_n(g_iartin,$Ttap310ZB_E::recmsisdn)

SI(recmsisdn_present_660004639)
ALORS

#	extraire le msisdn corrspondant a l entree recEntityCode=recEntityCodeCDR
	val_recEntityCode_660004639=i_get_art_field(g_iartin,$Ttap310ZB_E::recEntityCode)
	erreur_660004639=i_get_field_str(g_iartin,"recmsisdn",pt_recmsisdn_660004639)
	erreur_660004639=getMsisdn_660004265(pt_recmsisdn_660004639,val_recEntityCode_660004639,pt_msisdn_660004639)

	SI(erreur_660004639==1)
	ALORS
#		msisdn est present
		erreur_660004639=test_str_RNIS_660004265(pt_msisdn_660004639)
		SI(erreur_660004639==1)
		ALORS
			trace("Tap310 ZB msisdn present et de format RNIS")
			L_dcb_msisdn_660004639 = i_conv_ascii_dcb(pt_msisdn_660004639, pt_dcb_msisdn_660004639)
			SI(L_dcb_msisdn_660004639 == 0)
			ALORS
				trace("tap310ZB_E : Pb de retour de la fonction i_conv_ascii_dcb")
				ERREUR_660004639 = ERR_CONV_660004639
				code_rejet_660004639 = MODULE_660004639 + ERREUR_660004639 + EFFICACE_660004639
				erreur_660004639=i_PlvMessEmettre(8069, 2, g_iartin ,"" , 3, code_rejet_660004639, "MSISDN", "DCB")
				SAUT STOCKE_ERRONE
			FINSI
			erreur_660004639 = i_memcpy_art_field_n(g_iartout,$Tdpvgsm::idemet,pt_dcb_msisdn_660004639, L_dcb_msisdn_660004639)
		SINON
			trace("Tap310 ZB msisdn est present et de format non RNIS")
			L_dcb_msisdn_660004639 = i_conv_ascii_dcb("339999999999999999", pt_dcb_msisdn_660004639)
			SI(L_dcb_msisdn_660004639 == 0)
			ALORS
				trace("tap310ZB_E : Probleme de retour de la fonction i_conv_ascii_dcb")

				ERREUR_660004639 = ERR_CONV_660004639
				code_rejet_660004639 = MODULE_660004639 + ERREUR_660004639 + EFFICACE_660004639

				erreur_660004639=i_PlvMessEmettre(8069, 2, g_iartin ,"" , 3, code_rejet_660004639, "MSISDN:3399..9", "DCB")
				SAUT STOCKE_ERRONE
			FINSI
			erreur_660004639 = i_memcpy_art_field_n(g_iartout,$Tdpvgsm::idemet,pt_dcb_msisdn_660004639, L_dcb_msisdn_660004639)
		FINSI
	SINON
# FO OGA 149 Par SDX le 05/05/06
# Cas du msisdn non trouve dans la liste recmsisdn
		trace("Tap310ZB msisdn absent dans la liste du T3 cumulatif")
		L_dcb_msisdn_660004639 = i_conv_ascii_dcb("339999999999999999", pt_dcb_msisdn_660004639)
		SI(L_dcb_msisdn_660004639 == 0)
		ALORS
			trace("tap310ZB_E : Probleme de retour de la fonction i_conv_ascii_dcb")

			ERREUR_660004639 = ERR_CONV_660004639
			code_rejet_660004639 = MODULE_660004639 + ERREUR_660004639 + EFFICACE_660004639

			erreur_660004639=i_PlvMessEmettre(8069, 2, g_iartin ,"" , 3, code_rejet_660004639, "MSISDN:3399..9", "DCB")
			SAUT STOCKE_ERRONE
		FINSI
		erreur_660004639 = i_memcpy_art_field_n(g_iartout,$Tdpvgsm::idemet,pt_dcb_msisdn_660004639, L_dcb_msisdn_660004639)
	FINSI
SINON
	trace("Tap310ZB recmsisdn est absent")
	L_dcb_msisdn_660004639 = i_conv_ascii_dcb("339999999999999999", pt_dcb_msisdn_660004639)
	SI(L_dcb_msisdn_660004639 == 0)
	ALORS
		trace("tap310ZB_E : Probleme de retour de la fonction i_conv_ascii_dcb")
		ERREUR_660004639 = ERR_CONV_660004639
		code_rejet_660004639 = MODULE_660004639 + ERREUR_660004639 + EFFICACE_660004639
		erreur_660004639=i_PlvMessEmettre(8069, 2, g_iartin ,"" , 3, code_rejet_660004639, "MSISDN:3399..9", "DCB")
		SAUT STOCKE_ERRONE
	FINSI
	erreur_660004639 = i_memcpy_art_field_n(g_iartout,$Tdpvgsm::idemet,pt_dcb_msisdn_660004639, L_dcb_msisdn_660004639)
FINSI


#####################################################################
# Mise a jour du champ svcsup (V3t1.7)
#####################################################################

SI (i_valid_field_n(g_iartin,$Ttap310ZB_E::bearerCode))
ALORS
	val_bearerCode_660004639 = i_get_art_field(g_iartin,$Ttap310ZB_E::bearerCode)
	#val_bearerCode = i_get_field_char_num(g_iartin,$Ttap310ZB_E::bearerCode)
	SI (val_bearerCode_660004639==0x21)
	ALORS
		bearerCode_660004639 = 0x11
	SINON
		SI (val_bearerCode_660004639==0x22)
		ALORS
			bearerCode_660004639 = 0x12
		SINON
			SI (val_bearerCode_660004639==0x24)
			ALORS
				bearerCode_660004639 = 0x14
			SINON
				SI (val_bearerCode_660004639==0x25)
				ALORS
					bearerCode_660004639 = 0x15
				SINON
					SI (val_bearerCode_660004639==0x26)
					ALORS
						bearerCode_660004639 = 0x16
					SINON
						SI (val_bearerCode_660004639==0x32)
						ALORS
							bearerCode_660004639 = 0x1A
						SINON
							SI (val_bearerCode_660004639==0x34)
							ALORS
								bearerCode_660004639 = 0x1C
							SINON
								SI (val_bearerCode_660004639==0x35)
								ALORS
									bearerCode_660004639 = 0x1D
								SINON
									SI (val_bearerCode_660004639==0x36)
									ALORS
										bearerCode_660004639 = 0x1E
									SINON
										bearerCode_660004639 = 0x16
									FINSI
								FINSI
							FINSI
						FINSI
					FINSI
				FINSI
			FINSI
		FINSI
	FINSI
	erreur_660004639 = i_set_art_field(g_iartout, $Tdpvgsm::svcsup, bearerCode_660004639)
SINON
	erreur_660004639 = i_set_art_field(g_iartout, $Tdpvgsm::svcsup, 0xFF)
FINSI

#####################################################################
# Mise a jour du champ DUREE (V3t1.6)
#####################################################################

SI (i_valid_field_n(g_iartin,$Ttap310ZB_E::tlservCode) && i_valid_field_n(g_iartin,$Ttap310ZB_E::chargedItem))
ALORS
	SI ((i_get_art_field(g_iartin,$Ttap310ZB_E::tlservCode)==0x21) || (i_get_art_field(g_iartin,$Ttap310ZB_E::tlservCode)==0x22))
	ALORS
		SI (i_get_fieldtab_char_660004265(g_iartin,$Ttap310ZB_E::chargedItem,0) == 'E')
		ALORS
			erreur_660004639 = i_set_art_field(g_iartout, $Tdpvgsm::DUREE, 0x00000001)
		SINON
			SI (! i_valid_field_n(g_iartin,$Ttap310ZB_E::chargeabUnits))
			ALORS
				SI (i_get_fieldtab_char_660004265(g_iartin,$Ttap310ZB_E::chargedItem,0) == 'N')
				ALORS
					erreur_660004639 = i_set_art_field(g_iartout, $Tdpvgsm::DUREE, 0x00000000)
				SINON
					trace("Ttap310ZB_E :Erreur duplication champ DUREE")
					ERREUR_660004639 = ERR_DUPL_660004639
					code_rejet_660004639 = MODULE_660004639 + ERREUR_660004639 + EFFICACE_660004639
					erreur_660004639=i_PlvMessEmettre(8070, 2, g_iartin ,"" , 2, code_rejet_660004639, "DURRE", 0)
					SAUT STOCKE_ERRONE
				FINSI
			FINSI
		FINSI
	SINON
		SI (! i_valid_field_n(g_iartin,$Ttap310ZB_E::chargeabUnits))
		ALORS
			SI (i_get_fieldtab_char_660004265(g_iartin,$Ttap310ZB_E::chargedItem,0) == 'N')
			ALORS
				erreur_660004639 = i_set_art_field(g_iartout, $Tdpvgsm::DUREE, 0x00000000)
			FINSI
		FINSI
	FINSI
SINON
	SI (! i_valid_field_n(g_iartin,$Ttap310ZB_E::chargeabUnits))
	ALORS
		SI (i_get_fieldtab_char_660004265(g_iartin,$Ttap310ZB_E::chargedItem,0) == 'N')
		ALORS
			erreur_660004639 = i_set_art_field(g_iartout, $Tdpvgsm::DUREE, 0x00000000)
		FINSI
	FINSI
FINSI


#####################################################################
# Mise a jour du champ support1 (V3t1.9)
#####################################################################

SI (i_valid_field_n(g_iartin,$Ttap310ZB_E::radioChnlUsed))
ALORS
	SI (i_get_art_field(g_iartin,$Ttap310ZB_E::radioChnlUsed)==0x00)
	ALORS
# Cas radioChnlUsed present et valeur a 00
		erreur_660004639 = i_set_art_field(g_iartout, $Tdpvgsm::support1, 0x01)
	SINON
# Cas radioChnlUsed present et valeur a 01
		erreur_660004639 = i_set_art_field(g_iartout, $Tdpvgsm::support1, 0x00)
	FINSI
FINSI

#####################################################################
# Mise a jour du champ tterm (V3t1.14)
#####################################################################

SI (i_valid_field_n(g_iartin,$Ttap310ZB_E::causeForTerm))
ALORS
	SI (i_get_art_field(g_iartin,$Ttap310ZB_E::causeForTerm)==0x05)
	ALORS
		erreur_660004639 = i_set_art_field(g_iartout, $Tdpvgsm::tterm, 0x0A)
	SINON
		SI (i_get_art_field(g_iartin,$Ttap310ZB_E::causeForTerm)==0x04)
		ALORS
			erreur_660004639 = i_set_art_field(g_iartout, $Tdpvgsm::tterm, 0x01)
		SINON
			erreur_660004639 = i_set_art_field(g_iartout, $Tdpvgsm::tterm, 0xFF)
		FINSI
	FINSI
SINON
	erreur_660004639 = i_set_art_field(g_iartout, $Tdpvgsm::tterm, 0x00)
FINSI

#####################################################################
# Mise a jour du champ local (V3t3)
#####################################################################

erreur_660004639 = i_ajout_tlv(g_iartout, "T3t3", "")
erreur_660004639 = i_resize_tlv(g_iartout,"T3t3","local",7*8)

SI ( (!i_valid_field_n(g_iartin,$Ttap310ZB_E::locationArea)) || (!i_valid_field_n(g_iartin,$Ttap310ZB_E::cellId)) )
ALORS
# Cas locationArea et cellId absents
	SI (! i_strcmp(pt_str_660004639,"FRAF2"))
	ALORS
# --- Cas sender FRAF2 (cas SFR)
#		erreur = i_fill_field_hexastr(g_iartout,$Tdpvgsm::local,"2081300000000F")
		erreur_660004639 = affectation_tab_660004265(g_iartout,$Tdpvgsm::local,"2081300000000F")
	SINON
# --- Cas sender FRAF3 (cas BOUYGUES)
#		erreur = i_fill_field_hexastr(g_iartout,$Tdpvgsm::local,"2088800000000F")
		erreur_660004639 = affectation_tab_660004265(g_iartout,$Tdpvgsm::local,"2088800000000F")
	FINSI
SINON
# Cas locationArea et cellId presents
	erreur_660004639 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local , 0, 2)
	erreur_660004639 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local , 1, 0)
	erreur_660004639 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local , 2, 8)

	SI (! i_strcmp(pt_str_660004639,"FRAF2"))
	ALORS
# --- Cas sender FRAF2 (cas SFR)
		erreur_660004639 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local , 3, 1)
		erreur_660004639 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local , 4, 3)
	SINON
# --- Cas sender FRAF3 (cas BOUYGUES)
		erreur_660004639 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local , 3, 8)
		erreur_660004639 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local , 4, 8)
	FINSI

	erreur_660004639 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local , 5, (i_get_art_field(g_iartin,$Ttap310ZB_E::locationArea) >> 12) & 0xf)
	erreur_660004639 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local , 6, (i_get_art_field(g_iartin,$Ttap310ZB_E::locationArea) >> 8) & 0xf)
	erreur_660004639 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local , 7, (i_get_art_field(g_iartin,$Ttap310ZB_E::locationArea) >> 4) & 0xf)
	erreur_660004639 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local , 8, (i_get_art_field(g_iartin,$Ttap310ZB_E::locationArea) & 0xf))
	erreur_660004639 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local , 9, (i_get_art_field(g_iartin,$Ttap310ZB_E::cellId) >> 12) & 0xf)
	erreur_660004639 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local , 10, (i_get_art_field(g_iartin,$Ttap310ZB_E::cellId) >> 8) & 0xf)
	erreur_660004639 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local , 11, (i_get_art_field(g_iartin,$Ttap310ZB_E::cellId) >> 4) & 0xf)
	erreur_660004639 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local , 12, (i_get_art_field(g_iartin,$Ttap310ZB_E::cellId) & 0xf))
	erreur_660004639 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local , 13, 0xf)
FINSI


#####################################################################
# Traitement du champs transporteurs entrant (V3t17)
#####################################################################

taille_sender_660004639 = i_get_art_field(g_iartin,$Ttap310ZB_E::sender-1)
erreur_660004639 = i_ajout_tlv(g_iartout,"T3t17","")
erreur_660004639 = i_resize_tlv(g_iartout,"T3t17","TrEntrant",taille_sender_660004639)
erreur_660004639 = i_memcpy_art_field_n(g_iartout,$Tdpvgsm::TrEntrant,g_iartin.sender[],taille_sender_660004639)

#####################################################################
# Traitement des champs CAMEL
#
#####################################################################

# Les champs Camel ne sont present que si servicekey et callRefNb sont present
# Sinon article OK mais champs CAMEL absents

SI ( (i_valid_field_n(g_iartin,$Ttap310ZB_E::callRefNb)) && (i_valid_field_n(g_iartin,$Ttap310ZB_E::C_serviceKey)) )
ALORS
#	taille_callRefNb = i_get_field_osize(g_iartin,$Ttap310ZB_E::callRefNb)
	taille_callRefNb_660004639 = i_get_art_field(g_iartin,$Ttap310ZB_E::callRefNb-1)

	erreur_660004639 = i_ajout_tlv(g_iartout,"T4t18.1","")
	erreur_660004639 = i_resize_tlv(g_iartout,"T4t18.1","C_CallRefNum",(taille_callRefNb_660004639/2)*8)
	indice_octet_660004639 = 0

	POINT BOUCLE_CALLREFNB
	SI (indice_octet_660004639 < taille_callRefNb_660004639)
	ALORS
		caract_660004639 = i_get_fieldtab_char_660004265(g_iartin,$Ttap310ZB_E::callRefNb,indice_octet_660004639)
		#caract = i_get_art_fieldtab(g_iartin,$Ttap310ZB_E::callRefNb,indice_octet)
		SI ((caract_660004639 >= 0x30) && (caract_660004639 <= 0x39))
		ALORS
			erreur_660004639 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::C_CallRefNum,indice_octet_660004639,caract_660004639-0x30)
		SINON
			SI ((caract_660004639 >= 0x61) && (caract_660004639 <= 0x66))
			ALORS
				erreur_660004639 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::C_CallRefNum,indice_octet_660004639,caract_660004639-0x61+0xA)
			SINON
				SI ((caract_660004639 >= 0x41) && (caract_660004639 <= 0x46))
				ALORS
					erreur_660004639 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::C_CallRefNum,indice_octet_660004639,caract_660004639-0x41+0xA)
				SINON
					trace("Ttap310ZB_E :Erreur duplication champ C_CallRefNum digit incorrect")
					ERREUR_660004639 = ERR_DUPL_660004639
					code_rejet_660004639 = MODULE_660004639 + ERREUR_660004639 + EFFICACE_660004639
					erreur_660004639=i_PlvMessEmettre(8070, 2, g_iartin ,"" , 2, code_rejet_660004639, "C_CallRefNum", 0)
					SAUT STOCKE_ERRONE
				FINSI
			FINSI
		FINSI
		indice_octet_660004639 = indice_octet_660004639 + 1
		SAUT BOUCLE_CALLREFNB
	FINSI

	SI ( erreur_660004639 != 0)
	ALORS
		trace("Ttap310ZB_E :Erreur duplication champ callRefNb")
		ERREUR_660004639 = ERR_DUPL_660004639
		code_rejet_660004639 = MODULE_660004639 + ERREUR_660004639 + EFFICACE_660004639
		erreur_660004639=i_PlvMessEmettre(8070, 2, g_iartin ,"" , 2, code_rejet_660004639, "C_CallRefNum", 0)
		SAUT STOCKE_ERRONE
	FINSI

	SI (i_valid_field_n(g_iartin,$Ttap310ZB_E::mscAddress))
	ALORS
#               taille_mscAddr = i_get_field_osize(g_iartin,$Ttap310ZB_E::mscAddress)
		taille_mscAddr_660004639 = i_get_art_field(g_iartin,$Ttap310ZB_E::mscAddress-1)

		SI (taille_mscAddr_660004639 < 9)
		ALORS
			taille_mscAddress_660004639 = taille_mscAddr_660004639
		SINON
			taille_mscAddress_660004639 = 9
		FINSI

		erreur_660004639 = i_ajout_tlv(g_iartout,"T4t18.2","")
		erreur_660004639 = i_resize_tlv(g_iartout,"T4t18.2","C_MSCAddress",taille_mscAddress_660004639*8)
		erreur_660004639 = i_memcpy_art_field_n(g_iartout,$Tdpvgsm::C_MSCAddress,g_iartin.mscAddress[],taille_mscAddress_660004639)

		SI ( erreur_660004639 != 0)
		ALORS
			trace("Ttap310ZB_E :Erreur duplication champ mscAddress")
			ERREUR_660004639 = ERR_DUPL_660004639
			code_rejet_660004639 = MODULE_660004639 + ERREUR_660004639 + EFFICACE_660004639
			erreur_660004639=i_PlvMessEmettre(8070, 2, g_iartin ,"" , 2, code_rejet_660004639, "mscAddress", 0)
			SAUT STOCKE_ERRONE
		FINSI
	FINSI

	SI (i_valid_field_n(g_iartin,$Ttap310ZB_E::C_serverAddr))
	ALORS
#		taille_srvAddr = i_get_field_osize(g_iartin,$Ttap310ZB_E::C_serverAddr)
		taille_srvAddr_660004639 = i_get_art_field(g_iartin,$Ttap310ZB_E::C_serverAddr-1)

		SI (taille_srvAddr_660004639 < 9)
		ALORS
			taille_serverAddr_660004639 = taille_srvAddr_660004639
		SINON
			taille_serverAddr_660004639 = 9
		FINSI

		erreur_660004639 = i_ajout_tlv(g_iartout,"T4t18.3","")
		erreur_660004639 = i_resize_tlv(g_iartout,"T4t18.3","C_SrvAddress1",taille_serverAddr_660004639*8)
		erreur_660004639 = i_memcpy_art_field_n(g_iartout,$Tdpvgsm::C_SrvAddress1,g_iartin.C_serverAddr[],taille_serverAddr_660004639)

		SI ( erreur_660004639 != 0)
		ALORS
			trace("Ttap310ZB_E :Erreur duplication champ C_serverAddr")
			ERREUR_660004639 = ERR_DUPL_660004639
			code_rejet_660004639 = MODULE_660004639 + ERREUR_660004639 + EFFICACE_660004639
			erreur_660004639=i_PlvMessEmettre(8070, 2, g_iartin ,"" , 2, code_rejet_660004639, "C_serverAddr", 0)
			SAUT STOCKE_ERRONE
		FINSI
	FINSI

	SI (i_valid_field_n(g_iartin,$Ttap310ZB_E::C_DestNumber))
	ALORS
#		taille_DestNum = i_get_field_osize(g_iartin,$Ttap310ZB_E::C_DestNumber)
		taille_DestNum_660004639 = i_get_art_field(g_iartin,$Ttap310ZB_E::C_DestNumber-1)

		SI (taille_DestNum_660004639 < 9)
		ALORS
			taille_DestNumber_660004639 = taille_DestNum_660004639
		SINON
			taille_DestNumber_660004639 = 9
		FINSI

		erreur_660004639 = i_ajout_tlv(g_iartout,"T4t18.4","")
		erreur_660004639 = i_resize_tlv(g_iartout,"T4t18.4","C_DestNum1",taille_DestNumber_660004639*8)
		erreur_660004639 = i_memcpy_art_field_n(g_iartout,$Tdpvgsm::C_DestNum1,g_iartin.C_DestNumber[],taille_DestNumber_660004639)

		SI ( erreur_660004639 != 0)
		ALORS
			trace("Ttap310ZB_E :Erreur duplication champ C_DestNumber")
			ERREUR_660004639 = ERR_DUPL_660004639
			code_rejet_660004639 = MODULE_660004639 + ERREUR_660004639 + EFFICACE_660004639
			erreur_660004639=i_PlvMessEmettre(8070, 2, g_iartin ,"" , 2, code_rejet_660004639, "C_DestNum1", 0)
			SAUT STOCKE_ERRONE
		FINSI
	FINSI

	erreur_660004639 = i_ajout_tlv(g_iartout,"T4t18.5","")

	erreur_660004639 = i_set_art_field(g_iartout,$Tdpvgsm::C_Key1,i_get_art_field(g_iartin,$Ttap310ZB_E::C_serviceKey))
	SI (i_valid_field_n(g_iartin,$Ttap310ZB_E::C_servLevel))
	ALORS
		erreur_660004639 = i_set_art_field(g_iartout,$Tdpvgsm::C_Level1,i_get_art_field(g_iartin,$Ttap310ZB_E::C_servLevel))
	SINON
		erreur_660004639 = i_set_art_field(g_iartout,$Tdpvgsm::C_Level1,0xF)
	FINSI
	SI (i_valid_field_n(g_iartin,$Ttap310ZB_E::C_initCFInd))
	ALORS
		erreur_660004639 = i_set_art_field(g_iartout,$Tdpvgsm::C_InitCfInd1,i_get_art_field(g_iartin,$Ttap310ZB_E::C_initCFInd))
	SINON
		erreur_660004639 = i_set_art_field(g_iartout,$Tdpvgsm::C_InitCfInd1,0xF)
	FINSI
	SI (i_valid_field_n(g_iartin,$Ttap310ZB_E::defCallHand))
	ALORS
		erreur_660004639 = i_set_art_field(g_iartout,$Tdpvgsm::C_DefChInd1,i_get_art_field(g_iartin,$Ttap310ZB_E::defCallHand))
	SINON
		erreur_660004639 = i_set_art_field(g_iartout,$Tdpvgsm::C_DefChInd1,0xF)
	FINSI
	SI (i_valid_field_n(g_iartin,$Ttap310ZB_E::C_modifList))
	ALORS
		erreur_660004639 = i_set_art_field(g_iartout,$Tdpvgsm::C_Modif1,i_get_art_field(g_iartin,$Ttap310ZB_E::C_modifList))
	SINON
		erreur_660004639 = i_set_art_field(g_iartout,$Tdpvgsm::C_Modif1,0xF)
	FINSI

	SI ( erreur_660004639 != 0)
	ALORS
		trace("Ttap310ZB_E :Erreur duplication champs Camels")
		ERREUR_660004639 = ERR_DUPL_660004639
		code_rejet_660004639 = MODULE_660004639 + ERREUR_660004639 + EFFICACE_660004639
		erreur_660004639=i_PlvMessEmettre(8070, 2, g_iartin ,"" , 2, code_rejet_660004639, "C_Modif1", 0)
		SAUT STOCKE_ERRONE
	FINSI

	SI (i_valid_field_n(g_iartin,$Ttap310ZB_E::CseInfo))
	ALORS
		taille_CseInfo_660004639 = i_get_art_field(g_iartin,$Ttap310ZB_E::CseInfo-1)
		taille_CseInfo_660004639=taille_CseInfo_660004639*2
		erreur_660004639 = i_ajout_tlv(g_iartout,"T4t18.6","")
		erreur_660004639 = i_resize_tlv(g_iartout,"T4t18.6","C_CSEInfo1",taille_CseInfo_660004639)
		erreur_660004639 = i_memcpy_art_field_n(g_iartout,$Tdpvgsm::C_CSEInfo1,g_iartin.CseInfo[],taille_CseInfo_660004639)

		SI ( erreur_660004639 != 0)
		ALORS
			trace("Ttap310ZB_E :Erreur duplication champs CseInfo")
			ERREUR_660004639 = ERR_DUPL_660004639
			code_rejet_660004639 = MODULE_660004639 + ERREUR_660004639 + EFFICACE_660004639
			erreur_660004639=i_PlvMessEmettre(8070, 2, g_iartin ,"" , 2, code_rejet_660004639, "CseInfo", 0)
			SAUT STOCKE_ERRONE
		FINSI
	FINSI
FINSI

#####################################################################
# Fin de MAJ des champs CAMEL V4t18.1 a V4t18.6
#####################################################################

erreur_660004639 = i_maj_ila(g_iartout)

#####################################################################
# Mise a jour 'date d'entree dans le CE' + 'EEC'
# g_ibloc_date mis a jour dans Pcode Txxha ou trait_pla_file_bloc()
#####################################################################
# QC1331
#erreur=set_timeInCE_EEC(0)
########### Date_Audit
erreur_660004639 = i_set_art_field(g_iartout, $Tdpvgsm::timeInCE,  i_DHgetLocalTime(4, 7, i_date_audit()))
########### eec
# QC1405
SI (g_ieec > 500)
ALORS
  erreur_660004639 = i_set_art_field(g_iartout, $Tdpvgsm::eec, g_ieec - 500)
SINON
  erreur_660004639 = i_set_art_field(g_iartout, $Tdpvgsm::eec, g_ieec)
FINSI
#/QC1405

# Ajout des T3t55 et T3t56
SI !(i_valid_field_n(g_iartout, $Tdpvgsm::GFlag2))
ALORS
	erreur_660004639 = i_ajout_tlv(g_iartout,"T3t55","")
FINSI

SI !(i_valid_field_n(g_iartout, $Tdpvgsm::GValue))
ALORS
	erreur_660004639 = i_ajout_tlv(g_iartout,"T3t56","")
FINSI

SI !(i_valid_field_n(g_iartout, $Tdpvgsm::GretaTag))
ALORS
	erreur_660004639 = i_ajout_tlv(g_iartout,"T3t99","")
FINSI

erreur_660004639 = aiguillage2_660004590 (g_iartin, g_iartout, DISTRIBUTION_INCONNU_660004639, Multidistribution_Non_660004639)
SI (erreur_660004639 == TRAI_KO_660004639)
ALORS
# QC1005
	trace("<<<__LINE__<<<__FILE__<<< Erreur retour fonction aiguillage2")
#	ERREUR = ERR_DISTR
#	code_rejet = MODULE + ERREUR + EFFICACE
#	erreur=i_PlvMessEmettre(8071, 2, g_iartin ,"" , 1, code_rejet, 0, 0)
	SAUT STOCKE_ERRONE
FINSI


trace("Ttap310ZB_E : Fin Distribution OK")
RETOUR TRAIT_OK

POINT STOCKE_ERRONE
trace( "Fin Distribution Stockage de l'article en ERRONE" )
erreur_660004639 = i_make_art_rej(g_iartin, g_iartout11, code_rejet_660004639)
erreur_660004639 = i_stocke_art(g_iartout11, 0, PT_ERRONE, 0)
RETOUR TRAIT_OK
#------------------------------ Ttap310ZB_E_dis.src ---------------------------------------
