DEFINITION Multidistribution_Non_660004646 0
DEFINITION Multidistribution_Oui_660004646 1
DEFINITION DISTRIBUTION_AIG_IMSI_660004646 2
DEFINITION MAX_LEG_660004646 30
DEFINITION DATE_REF_660004646 0xBC191380
DEFINITION VRAI_660004646 1
DEFINITION FAUX_660004646 0
DEFINITION C_Tdpv_660004646 "Tdpvgsm"
DEFINITION C_Article_660004646 "Ttn"
DEFINITION NoLocation1_660004646 "0000"
DEFINITION NoLocation2_660004646 "000000"
DEFINITION OFFSETT2LEG_660004646 63
DEFINITION OFFSETT3P2T_660004646 11
DEFINITION NUMTAB_660004646 4
DEFINITION NUMZONE_660004646 7
DEFINITION TRAI_KO_660004646 -1
DEFINITION TRAI_REDIST_660004646 -2
REGISTRE ENTIER EFFICACE_MT_660004646
REGISTRE ENTIER GENERER_MT_660004646
REGISTRE ENTIER GENERER_MTSVC_660004646
REGISTRE ENTIER GENERER_MTSVC30_660004646
REGISTRE ENTIER GENERER_MTSVC31_660004646
REGISTRE ENTIER MO_P2T_only_660004646
REGISTRE ENTIER MT_P2T_only_660004646
REGISTRE ENTIER MT_U2P2C_duration_660004646
REGISTRE ENTIER k0_orig_660004646
REGISTRE ENTIER k3_orig_660004646
REGISTRE ENTIER k0_leg_660004646
REGISTRE ENTIER k3_leg_660004646
REGISTRE ENTIER j_660004646
REGISTRE ENTIER date_fin_660004646
REGISTRE ENTIER erreur_660004646
REGISTRE ENTIER code_errone_660004646
REGISTRE ENTIER resultat_660004646
REGISTRE ENTIER LegType_660004646
REGISTRE ENTIER ServiceType30_660004646
REGISTRE ENTIER ServiceType31_660004646
REGISTRE ENTIER NbServices_660004646
REGISTRE ENTIER NbServicesO_660004646
REGISTRE ENTIER CauseForTerm_660004646
REGISTRE ENTIER effmo_660004646
REGISTRE ENTIER indice_660004646
REGISTRE ENTIER CauseForTermO_660004646
REGISTRE ENTIER longueur_660004646
REGISTRE ENTIER index_660004646
REGISTRE ENTIER MO_location_identity_660004646
REGISTRE ENTIER MT_location_identity_660004646
REGISTRE ENTIER MO_SVC_P2T_660004646
REGISTRE ENTIER date_plat_660004646
REGISTRE ENTIER type_cra_660004646
REGISTRE POINTEUR pt_idemet_660004646
REGISTRE POINTEUR pt_location_identity_660004646 
REGISTRE POINTEUR pt_temp_660004646
################################################################
# Pcode de Distribution : Ttn_dis.src
# Service Talk Now 
# Article : TTn
################################################################
# 
# URS/PSA	23/02/06	Creation
# URS/PSA	06/04/06 	FO 165, 166, 168, 169, 170
#  		19/04/06 	FO 181 stockage en errone
#				FO 182, 185
# 12/05/06 PSA Appel fonction i_incr_redist_dist pour compteur redistribution
# URS/THEFAL	22/06/06 	G3R0CbME FO 224
# 01/09/06 JLG report FO CaME : 240, 242
# 09/08/07 PSA : G1R4 FO TT 18 et 19
# 09/08/07 Creation enveloppe optionnelle E_Redist2
# 14/12/2010 - BEA - G3R1 lot4 Verification/Correction des variables (constantes, entiers, pointeurs)
# 29/02/2012 - JLG -G3R6 QC1005 modif alarme retour aiguillage
# 02/07/2014 - JLG -G5R1 QC1405, champ eec du DPV si g_ieec > 500
################################################################



# G3R0CbME

# k0_orig : indice du T3SIRLIST_Orig dont le champ  ServType vaut 0
# k3_orig : indice du T3SIRLIST_Orig dont le champ  ServType vaut 3
# k0_leg : indice du T3SIRLIST_Leg dont le champ  ServType vaut 0
# k3_leg : indice du T3SIRLIST_Leg dont le champ  ServType vaut 0





# G3R0CbME
#EFFICACE_MO = FAUX

EFFICACE_MT_660004646 = FAUX_660004646
GENERER_MT_660004646 = FAUX_660004646
MO_P2T_only_660004646 = FAUX_660004646

resultat_660004646 = -1
ServiceType30_660004646 = -1
ServiceType31_660004646 = -1
NbServices_660004646 = -1
NbServicesO_660004646 = -1
CauseForTerm_660004646 = -1
CauseForTermO_660004646 = -1
LegType_660004646 = -1
effmo_660004646 = 0
indice_660004646 = 0
j_660004646 = 1
MO_location_identity_660004646 = 0
MT_location_identity_660004646 = 0

k0_orig_660004646 = -1
k3_orig_660004646 = -1
k0_leg_660004646 = -1
k3_leg_660004646 = -1

pt_idemet_660004646 = "pt_idemet1111111111111111111111111111111"
pt_location_identity_660004646 = "pt_location_identity0123456789"
pt_temp_660004646 = "pt_temp0123456789012345678901234567890123456789012345678901234567890123456789"

i_strcpy(pt_location_identity_660004646,"")
i_strcpy(pt_temp_660004646,"")

# FE_0028 comptabilisation des CRAs issus de la redistribution
date_fin_660004646=i_get_art_field(g_iartin,$Ttn::dfin)
erreur_660004646= i_incr_redist_dist_660004265(date_fin_660004646)

# Debut G1R4 FO REDIST
SI (i_LireRedistCpt() == 0)
ALORS
	erreur_660004646 = i_add_opt( "E_Redistri2" )
FINSI
erreur_660004646 = i_set_attr_val_n( $E_Redistri2::EnvoiRedis, 0)

# Fin G1R4 FO REDIST

######################
# NbServices OrigLeg #
# MO_P2T_only        #
######################
NbServicesO_660004646 = i_get_art_field(g_iartin,$Ttn::NumOfServO)
SI ( NbServicesO_660004646 == 0x01 )
ALORS
	MO_P2T_only_660004646 = VRAI_660004646
FINSI


#############
# AX_IDEMET #
#############
i_strcpy(pt_idemet_660004646, " ")
i_strcpy(pt_idemet_660004646, i_get_tab_field("VariableContexte", i_get_art_field(g_iartin,$Ttn::DATE), "AX_IDEMET_TN"))

# G3R0CbME
###############
# EFFICACE_MO #
###############
#resultat = i_get_art_field(g_iartin,$Ttn::DATE)
# FO TT 19	
CauseForTermO_660004646 = i_get_art_field(g_iartin,$Ttn::CauseTermO)
#SI ( CauseForTermO != 0x03 ) && ( resultat != DATE_REF ) 
#ALORS
#	EFFICACE_MO = VRAI
#SINON
#	EFFICACE_MO = FAUX
#FINSI


###########################
# MO_location_identity
###########################
erreur_660004646 = i_cree_art("Conv_URS",g_iartout10)

# Verification de la presence des champs
SI i_valid_field_n(g_iartin,$Ttn::LocationO)
ALORS
	erreur_660004646 = i_dup_chp_1val(g_iartin, g_iartout10, $Ttn::LocationO, $Conv_URS::LocationO)
SINON
	SAUT FIN_MO_location_identity
FINSI

SI i_valid_field_n(g_iartin,$Ttn::LocAreaCodO)
ALORS
	erreur_660004646 = i_dup_chp_1val(g_iartin, g_iartout10, $Ttn::LocAreaCodO, $Conv_URS::LocationAreaO)
SINON
	SAUT FIN_MO_location_identity
FINSI

SI i_valid_field_n(g_iartin,$Ttn::CellIDO)
ALORS
	erreur_660004646 = i_dup_chp_1val(g_iartin, g_iartout10, $Ttn::CellIDO, $Conv_URS::CellIDO)
SINON
	SAUT FIN_MO_location_identity
FINSI

# Verification de la valeur des champs
erreur_660004646 = i_get_art_str(g_iartout10, $Conv_URS::LocationO, pt_location_identity_660004646)
SI (i_strcmp(pt_location_identity_660004646, NoLocation2_660004646) == 0)
ALORS
	SAUT FIN_MO_location_identity	
FINSI

erreur_660004646 = i_get_art_str(g_iartout10, $Conv_URS::LocationAreaO, pt_location_identity_660004646)
SI (i_strcmp(pt_location_identity_660004646, NoLocation1_660004646) == 0)
ALORS
	SAUT FIN_MO_location_identity	
FINSI

erreur_660004646 = i_get_art_str(g_iartout10, $Conv_URS::CellIDO, pt_location_identity_660004646)
SI (i_strcmp(pt_location_identity_660004646, NoLocation1_660004646) == 0)
ALORS
	SAUT FIN_MO_location_identity	
FINSI

MO_location_identity_660004646 = 1

POINT FIN_MO_location_identity

###############
# MO_SVC_P2T
###############
SI (i_get_art_field(g_iartin,$Ttn::ServType30O) == 0x00)
ALORS
	MO_SVC_P2T_660004646 = 0
	k0_orig_660004646 = 0
	SI (MO_P2T_only_660004646 == FAUX_660004646)
	ALORS
		k3_orig_660004646 = 1
	FINSI
SINON
	SI (i_get_art_field(g_iartin,$Ttn::ServType31O) == 0x00)
	ALORS
		MO_SVC_P2T_660004646 = 1
		k0_orig_660004646 = 1
# Si on arrive ici et que ServType31O contient 0, alors forcement ServType30O contient 3
		k3_orig_660004646 = 0
	FINSI
FINSI

################################################################################################
# Calcul de effmo
# On s'arrete au 1er MT efficace
# Remarque : il y a forcement un MT efficace (test realise en traitement)
################################################################################################

indice_660004646 = 1

POINT DEBUT_RECHERCHE_effmo

SI i_valid_field_n(g_iartin,$Ttn::CauseTerm1 + (OFFSETT2LEG_660004646 * (indice_660004646 - 1)))
ALORS
	resultat_660004646 = i_get_art_field(g_iartin,$Ttn::AnswerTime1 + (OFFSETT2LEG_660004646 * (indice_660004646 - 1)))
	CauseForTerm_660004646 = i_get_art_field(g_iartin,$Ttn::CauseTerm1 + (OFFSETT2LEG_660004646 * (indice_660004646 - 1)))
	SI ( CauseForTerm_660004646 != 0x03 ) && (resultat_660004646 != DATE_REF_660004646)
	ALORS
		effmo_660004646 = indice_660004646
		EFFICACE_MT_660004646 = VRAI_660004646
		SAUT FIN_RECHERCHE_effmo
	SINON
		indice_660004646 = indice_660004646 + 1
		SAUT DEBUT_RECHERCHE_effmo
	FINSI
SINON
	indice_660004646 = indice_660004646 + 1
	SAUT DEBUT_RECHERCHE_effmo
FINSI

POINT FIN_RECHERCHE_effmo


################################################################################################
# A revoir eventuellement : a mettre sous forme de fonction ?
# Ajouter les tests croises ?
# GENERERMT[effmo]
################################################################################################

GENERER_MT_660004646 = FAUX_660004646

LegType_660004646 = i_get_art_field(g_iartin,$Ttn::LegType1 + (OFFSETT2LEG_660004646 * (effmo_660004646 - 1)))
SI ( LegType_660004646 != 0x01 )
ALORS
	SAUT FIN_GENERER_MT_effmo
FINSI

NbServices_660004646 = i_get_art_field(g_iartin,$Ttn::NumOfServ1 + (OFFSETT2LEG_660004646 * (effmo_660004646 - 1)))
SI ( ( NbServices_660004646 != 0x01 ) && ( NbServices_660004646 != 0x02 ) )
ALORS 
	SAUT FIN_GENERER_MT_effmo
FINSI

CauseForTerm_660004646 = i_get_art_field(g_iartin,$Ttn::CauseTerm1 + (OFFSETT2LEG_660004646 * (effmo_660004646 - 1)))
SI ( ( CauseForTerm_660004646 < 0x00 ) || ( CauseForTerm_660004646 > 0x04 ) )
ALORS
	SAUT FIN_GENERER_MT_effmo
FINSI	

GENERER_MT_660004646 = VRAI_660004646

POINT FIN_GENERER_MT_effmo



################################################################################################
# Generation du MO P2T pur
################################################################################################
#SI ( EFFICACE_MO == VRAI ) && ( EFFICACE_MT == VRAI ) && ( GENERER_MT == VRAI )
# G3R0CbME
#SI ( EFFICACE_MO == VRAI ) && ( EFFICACE_MT == VRAI )
SI ( EFFICACE_MT_660004646 == VRAI_660004646 )
ALORS
	
	SI (i_dup_art_tab( g_iartin, g_iartout, C_Tdpv_660004646))
	ALORS
		#trace("ERREUR de duplication")
		code_errone_660004646 = 0xA0D1
		erreur_660004646 = i_PlvMessEmettre(6503,2,g_iartin,"",2,code_errone_660004646,C_Tdpv_660004646,0)
		SAUT STOCKE_ERRONE
	FINSI	
SINON
	SAUT FIN_GENERATION_MOP2T_pur
FINSI

	
# V3t1.3 idemet (defaut table dup)
SI (i_strcmp(pt_idemet_660004646,g_inull)) != 0
ALORS
	longueur_660004646= 0
	longueur_660004646=i_strlen(pt_idemet_660004646)
	erreur_660004646 = i_set_art_str(g_iartout10,$Conv_URS::recipAddAlp, pt_idemet_660004646)
	index_660004646=0
	POINT BOUCLE0
	SI (index_660004646 < longueur_660004646)
	ALORS
		SI (g_iartout10.recipAddHex[index_660004646] < 0x40)
		ALORS
			g_iartout.idemet[index_660004646]=g_iartout10.recipAddHex[index_660004646] - 0x30
		SINON
			g_iartout.idemet[index_660004646]=g_iartout10.recipAddHex[index_660004646] - 0x37
		FINSI
#		trace1("index=%d",index)
#		trace1("g_iartin.ax_idemet=%x",g_iartout10.recipAddHex[index] - 0x30)
		index_660004646=index_660004646+1
		SAUT BOUCLE0
	FINSI

SINON
	#i_strcpy(pt_idemet,"33010000000FFFFFFF")
	longueur_660004646 = g_iartout.idemet!NELEM
	g_iartout.idemet[0]= 0x3
	g_iartout.idemet[1]= 0x3
	g_iartout.idemet[2]= 0x0
	g_iartout.idemet[3]= 0x3
	index_660004646 = 4
	POINT BOUCLE
	SI index_660004646 < 11
	ALORS
		g_iartout.idemet[index_660004646]= 0x0
		index_660004646 = index_660004646 + 1
		SAUT BOUCLE
	FINSI
FINSI

# V3t1.4 IMSI
SI i_valid_field_n(g_iartin,$Ttn::ConnectIMSIO)
ALORS
	erreur_660004646 = i_dup_chp_1val(g_iartin, g_iartout, $Ttn::ConnectIMSIO, $Tdpvgsm::IMSI)
SINON
	index_660004646=0
	POINT BOUCLE1
	SI index_660004646 < 15
	ALORS
		g_iartout.IMSI[index_660004646]= 0x9
		index_660004646 = index_660004646 + 1
		#trace1(" index : %d",index)
		SAUT BOUCLE1
	FINSI
FINSI

# V3t1.6 DUREE
SI ( MO_P2T_only_660004646 == VRAI_660004646 )
ALORS
	resultat_660004646 = i_get_art_field(g_iartin,$Ttn::DUREE)
SINON
	SI i_valid_field_n(g_iartin,$Ttn::Up2P2CtimeO)
	ALORS
		resultat_660004646 = i_get_art_field(g_iartin,$Ttn::Up2P2CtimeO) - i_get_art_field(g_iartin,$Ttn::DATE)
	SINON
		resultat_660004646 = 0
	FINSI
FINSI
erreur_660004646 = i_set_art_field(g_iartout, $Tdpvgsm::DUREE, resultat_660004646)

# V3t1.12 origine 
SI i_valid_field_n(g_iartin, $Ttn::LocationO)
ALORS
	SI (g_iartin.LocationO[0] == 0x2) && (g_iartin.LocationO[1] == 0x0) && (g_iartin.LocationO[2] == 0x8)
	ALORS	
		resultat_660004646 = 0
	SINON
		resultat_660004646 = 1
	FINSI
SINON
	resultat_660004646 = 0
FINSI
erreur_660004646 = i_set_art_field(g_iartout, $Tdpvgsm::origine, resultat_660004646)

# V3t1.13 indeff
SI ( NbServicesO_660004646 == 0x2 )
ALORS
	resultat_660004646 = 0
SINON
	SI ( CauseForTermO_660004646 >= 0x0 ) && ( CauseForTermO_660004646 <= 0x2 )
	ALORS
		resultat_660004646 = 0
	SINON
		resultat_660004646 = 1
	FINSI
FINSI
erreur_660004646 = i_set_art_field(g_iartout, $Tdpvgsm::indeff, resultat_660004646)

# V3t1.14 tterm
SI ( resultat_660004646 != 0x0 )
ALORS
	resultat_660004646 = CauseForTermO_660004646
FINSI
erreur_660004646 = i_set_art_field(g_iartout, $Tdpvgsm::tterm, resultat_660004646)

# V3t2 idpart
SI ( i_valid_field_n(g_iartin,$Ttn::ConnectNum1 + (OFFSETT2LEG_660004646 * (effmo_660004646 - 1))))
ALORS
	erreur_660004646 = i_dup_chp_rnisGSM(g_iartin, g_iartout, $Ttn::ConnectNum1 + (OFFSETT2LEG_660004646 * (effmo_660004646 - 1)), $Tdpvgsm::idpart,-$NORM:TALK_NOW,0)
SINON
	erreur_660004646 = i_supprChamp(g_iartout, "T3t2")
FINSI

#erreur = i_normal(g_iartin, $Ttn::ConnectNum1 + (OFFSETT2LEG * (effmo - 1)),$Ttn::ConnectNum1 + (OFFSETT2LEG * (effmo - 1)), g_icopo, $Tcopo::NDR, $Tcopo::NDE , 1, "TALK_NOW", "TALK_NOW")
#erreur = i_resize_tlv(g_iartout, "T3t2", "idpart",152)
#indice_idpart = 0

#POINT BOUCLE_IDPART_effmo
#resultat = i_get_art_fieldtab(g_icopo, $Tcopo::NDR, indice_idpart)
#        trace1(" element : %x",res)

#SI (resultat != 00) && (indice_idpart < 19)
#ALORS

# Cas particuliers : * (2A en ASCII) et # (23 en ASCII)

#	SI (resultat == 0x2a)
#	ALORS
#		erreur = i_set_art_fieldtab(g_iartout, $Tdpvgsm::idpart, indice_idpart, 0xB)
#		indice_idpart = indice_idpart + 1
#		SAUT BOUCLE_IDPART_effmo
#	FINSI

#	SI (resultat == 0x23)
#	ALORS
#		erreur = i_set_art_fieldtab(g_iartout, $Tdpvgsm::idpart, indice_idpart, 0xC)
#		indice_idpart = indice_idpart + 1
#		SAUT BOUCLE_IDPART_effmo
#	FINSI

# Cas generique
#	erreur = i_set_art_fieldtab(g_iartout, $Tdpvgsm::idpart, indice_idpart, resultat-0x30)
#	indice_idpart = indice_idpart + 1
#	SAUT BOUCLE_IDPART_effmo
#FINSI
#longueur= indice_idpart%2
#SI indice_idpart == 19
#ALORS
#	erreur = i_set_art_fieldtab(g_iartout, $Tdpvgsm::idpart, indice_idpart, resultat-0x30)
#SINON
#	SI indice_idpart == 0
#	ALORS
#		erreur = i_set_art_fieldtab(g_iartout, $Tdpvgsm::idpart, indice_idpart, 0xF)
#	SINON
#		SI longueur!=0
#		ALORS
#			erreur = i_set_art_fieldtab(g_iartout, $Tdpvgsm::idpart, indice_idpart, 0xF)
#			indice_idpart = indice_idpart*4+4
#		SINON
#			indice_idpart = indice_idpart*4
#		FINSI
#		erreur = i_resize_tlv(g_iartout, "T3t2", "idpart",indice_idpart)
#	FINSI
#FINSI

# V3t3 local
SI (MO_location_identity_660004646 != 0x00)
ALORS
	erreur_660004646 = i_dup_chp_1val(g_iartout10, g_iartout, $Conv_URS::LocationIDO, $Tdpvgsm::local)
SINON
	erreur_660004646 = i_supprChamp(g_iartout, "T3t3")
FINSI

# V3t4 MSISDN
# Normalisation faite en duplication

# V3t7 estalloc
resultat_660004646 = i_get_art_field(g_iartin, $Ttn::SeizTimeO)
erreur_660004646 = i_set_art_field(g_iartout, $Tdpvgsm::estalloc, resultat_660004646)

# V4t35.1 duration
resultat_660004646 = i_get_art_field(g_iartin, $Ttn::DUREE)
erreur_660004646 = i_set_art_field(g_iartout, $Tdpvgsm::duration, resultat_660004646)

# V4t35.2 occurenceNb
erreur_660004646 = i_set_art_field(g_iartout, $Tdpvgsm::occurenceNb, 1)

# V4t35.3 participantsNb
erreur_660004646 = i_set_art_field(g_iartout, $Tdpvgsm::participantsNb, effmo_660004646)

# V3t52
SI i_valid_field_n(g_iartin,$Ttn::Location1)
ALORS
	erreur_660004646 = i_dup_chp_1val(g_iartin, g_iartout10, $Ttn::Location1, $Conv_URS::Location)
SINON
	SAUT FIN_MT1_location_identity
FINSI

SI i_valid_field_n(g_iartin,$Ttn::LocAreaCod1)
ALORS
	erreur_660004646 = i_dup_chp_1val(g_iartin, g_iartout10, $Ttn::LocAreaCod1, $Conv_URS::LocationArea)
SINON
	SAUT FIN_MT1_location_identity
FINSI

SI i_valid_field_n(g_iartin,$Ttn::CellID1)
ALORS
	erreur_660004646 = i_dup_chp_1val(g_iartin, g_iartout10, $Ttn::CellID1, $Conv_URS::CellID)
SINON
	SAUT FIN_MT1_location_identity
FINSI

# Verification de la valeur des champs
erreur_660004646 = i_get_art_str(g_iartout10, $Conv_URS::Location, pt_location_identity_660004646)
SI (i_strcmp(pt_location_identity_660004646, NoLocation2_660004646) == 0)
ALORS
	SAUT FIN_MT1_location_identity	
FINSI

erreur_660004646 = i_get_art_str(g_iartout10, $Conv_URS::LocationArea, pt_location_identity_660004646)
SI (i_strcmp(pt_location_identity_660004646, NoLocation1_660004646) == 0)
ALORS
	SAUT FIN_MT1_location_identity	
FINSI

erreur_660004646 = i_get_art_str(g_iartout10, $Conv_URS::CellID, pt_location_identity_660004646)
SI (i_strcmp(pt_location_identity_660004646, NoLocation1_660004646) == 0)
ALORS
	SAUT FIN_MT1_location_identity	
FINSI

MT_location_identity_660004646 = 1

POINT FIN_MT1_location_identity

SI (MO_location_identity_660004646 == 0x00) && (MT_location_identity_660004646 == 0x00)
ALORS
	erreur_660004646 = i_supprChamp(g_iartout, "T3t52")
	SAUT FIN_T3t52
FINSI

# V4t52.1 callingLocation
SI (MO_location_identity_660004646 != 0x00)
ALORS
	erreur_660004646 = i_dup_chp_1val(g_iartout10, g_iartout, $Conv_URS::LocationIDOH, $Tdpvgsm::callingLocation)
SINON
	erreur_660004646 = i_supprChamp(g_iartout, "T4t52.1")
FINSI

# V4t52.2 callingLocation
SI (MT_location_identity_660004646 != 0x00)
ALORS
	erreur_660004646 = i_dup_chp_1val(g_iartout10, g_iartout, $Conv_URS::LocationIDH, $Tdpvgsm::calledLocation)
SINON
	erreur_660004646 = i_supprChamp(g_iartout, "T4t52.2")
FINSI

POINT FIN_T3t52

# V4t61.1 calledPart
# Rq : champ d'entree obligatoire donc pas de test de presence
erreur_660004646 = i_dup_chp_1val(g_iartin, g_iartout, $Ttn::NumAttLegs, $Tdpvgsm::calledPart)

# V4t61.2 effectivePart
# Rq : champ d'entree obligatoire donc pas de test de presence
erreur_660004646 = i_dup_chp_1val(g_iartin, g_iartout, $Ttn::NumConLegs, $Tdpvgsm::effectivePart)

# V4t61.3 platRecCode
longueur_660004646 = g_iartin.RecordingEnt!NELEM
SI ( g_iartin.RecordingEnt[longueur_660004646-1] == 0xF )
ALORS
	longueur_660004646 = longueur_660004646 - 1
FINSI
erreur_660004646 = i_resize_tlv(g_iartout, "T4t61.3", "platRecCode", longueur_660004646)

erreur_660004646 = i_get_art_str(g_iartin, $Ttn::RecordingEnt, pt_temp_660004646)
erreur_660004646 = i_set_art_str(g_iartout, $Tdpvgsm::platRecCode, pt_temp_660004646)


# V4t61.4
# Rq (13/03/06) : la notation $Tdpvgsm::T4t61.4 semble ne pas fonctionner a cause du point
SI (i_get_art_field(g_iartin,$Ttn::NumConLegs) == 0x01)
ALORS
	erreur_660004646 = i_set_art_field(g_iartout, $Tdpvgsm::T3t61+13, 0x00)
SINON
	erreur_660004646 = i_set_art_field(g_iartout, $Tdpvgsm::T3t61+13, 0x01)
FINSI

# V4t61.7 GroupID
# Bourrage a 0 du premier octet + recuperation des 3 derniers octets du champ d'entree
#g_iartout.GroupID[0] = 0x0
#g_iartout.GroupID[1] = 0x0
g_iartout.GroupID[2] = g_iartin.GroupID[6]
g_iartout.GroupID[3] = g_iartin.GroupID[7]
g_iartout.GroupID[4] = g_iartin.GroupID[8]
g_iartout.GroupID[5] = g_iartin.GroupID[9]
g_iartout.GroupID[6] = g_iartin.GroupID[10]
g_iartout.GroupID[7] = g_iartin.GroupID[11]

# V4t61.8 usrSpeechDur
SI (i_get_art_field(g_iartin, $Ttn::Bursts30O + (MO_SVC_P2T_660004646 * OFFSETT3P2T_660004646)) == 0x00)
ALORS
	erreur_660004646 = i_set_art_field(g_iartout, $Tdpvgsm::usrSpeechDur, 0)
SINON
	erreur_660004646 = i_set_art_field(g_iartout, $Tdpvgsm::usrSpeechDur, i_get_art_field(g_iartin, $Ttn::Duration30O + (MO_SVC_P2T_660004646 * OFFSETT3P2T_660004646)))
FINSI

# V4t61.9 speechBurstNb
erreur_660004646 = i_dup_chp_1val(g_iartin, g_iartout, $Ttn::Bursts30O + (MO_SVC_P2T_660004646 * OFFSETT3P2T_660004646), $Tdpvgsm::speechBurstNb)

###### T4t30.1 timeInCE 
###### date_plat
date_plat_660004646 = i_DHgetLocalTime(NUMTAB_660004646, NUMZONE_660004646, i_date_audit())
erreur_660004646 = i_set_art_field(g_iartout, $Tdpvgsm::timeInCE,date_plat_660004646)

###### T4t30.2 eec :MSET :00:1
# QC1405
SI (g_ieec > 500)
ALORS
  erreur_660004646 = i_set_art_field(g_iartout, $Tdpvgsm::eec, g_ieec - 500)
SINON
  erreur_660004646 = i_set_art_field(g_iartout, $Tdpvgsm::eec, g_ieec)
FINSI
#/QC1405

################################################
# Appel fonction distribution pour MOP2T_pur
################################################
erreur_660004646 = aiguillage2_660004590 (g_iartin, g_iartout, DISTRIBUTION_AIG_IMSI_660004646, Multidistribution_Non_660004646)
SI (erreur_660004646 == TRAI_KO_660004646)
ALORS
# QC1005
	trace("<<<__LINE__<<<__FILE__<<< Erreur retour fonction aiguillage2")
#	code_errone = 0xA0B1
#	type_cra=i_get_art_field(g_iartout,$Tdpvgsm::type)
#	erreur = i_PlvMessEmettre(7500,2,g_iartin,"",3,code_errone,C_Article,type_cra)
	SAUT STOCKE_ERRONE
SINON
	SI (erreur_660004646 == TRAI_REDIST_660004646) && (i_LireRedistCpt() != 0)
	ALORS
		SAUT FIN_DISTRIBUTION
	FINSI
FINSI
j_660004646 = j_660004646 + 1
POINT FIN_GENERATION_MOP2T_pur

indice_660004646 = effmo_660004646 - 1

	
##############################################################################
# Generation MO + MT
##############################################################################
POINT DEBUT_GENERATION_MO_MT

indice_660004646 = indice_660004646 + 1

##############################################################################
# Calcul de EFFICACE_MT[i]
##############################################################################
EFFICACE_MT_660004646 = FAUX_660004646
POINT DEBUT_RECHERCHE_EFFICACE_MT
SI i_valid_field_n(g_iartin,$Ttn::CauseTerm1 + (OFFSETT2LEG_660004646 * (indice_660004646 - 1)))
ALORS
	resultat_660004646 = i_get_art_field(g_iartin,$Ttn::AnswerTime1 + (OFFSETT2LEG_660004646 * (indice_660004646 - 1)))
	CauseForTerm_660004646 = i_get_art_field(g_iartin,$Ttn::CauseTerm1 + (OFFSETT2LEG_660004646 * (indice_660004646 - 1)))
	SI ( CauseForTerm_660004646 != 0x03 ) && (resultat_660004646 != DATE_REF_660004646)
	ALORS
		EFFICACE_MT_660004646 = VRAI_660004646
		SAUT FIN_RECHERCHE_EFFICACE_MT
	SINON
		indice_660004646 = indice_660004646 + 1
		SAUT DEBUT_RECHERCHE_EFFICACE_MT
	FINSI
SINON
	SI ( indice_660004646 < MAX_LEG_660004646 + 1)
	ALORS
		indice_660004646 = indice_660004646 + 1
		SAUT DEBUT_RECHERCHE_EFFICACE_MT
	SINON		
		SAUT FIN_DISTRIBUTION
	FINSI
FINSI

POINT FIN_RECHERCHE_EFFICACE_MT



################################################################################################
# calcul de GENERERMT[i]
################################################################################################

GENERER_MTSVC_660004646 = FAUX_660004646
GENERER_MTSVC30_660004646 = VRAI_660004646
GENERER_MTSVC31_660004646 = VRAI_660004646

#
# LegType 
#
SI i_valid_field_n(g_iartin,$Ttn::LegType1 + (OFFSETT2LEG_660004646 * (indice_660004646 - 1)))
ALORS
	LegType_660004646 = i_get_art_field(g_iartin,$Ttn::LegType1 + (OFFSETT2LEG_660004646 * (indice_660004646 - 1)))
	SI ( LegType_660004646 != 0x01 )
	ALORS
		SAUT FIN_GENERER_MT_I
	FINSI
SINON
	SAUT FIN_GENERER_MT_I
FINSI

#
# ConnectedNumber
#
SI !i_valid_field_n(g_iartin,$Ttn::ConnectNum1 + (OFFSETT2LEG_660004646 * (indice_660004646 - 1)))
ALORS
	SAUT FIN_GENERER_MT_I
FINSI

#
# SeizureTime
#
SI !i_valid_field_n(g_iartin,$Ttn::SeizTime1 + (OFFSETT2LEG_660004646 * (indice_660004646 - 1)))
ALORS
	SAUT FIN_GENERER_MT_I
FINSI

#
# AnswerTime
#
SI !i_valid_field_n(g_iartin,$Ttn::AnswerTime1 + (OFFSETT2LEG_660004646 * (indice_660004646 - 1)))
ALORS
	SAUT FIN_GENERER_MT_I
FINSI

#
# CallDuration
#
SI !i_valid_field_n(g_iartin,$Ttn::CallDur1 + (OFFSETT2LEG_660004646 * (indice_660004646 - 1)))
ALORS
	SAUT FIN_GENERER_MT_I
FINSI

#
# CauseForTerm 
#
SI i_valid_field_n(g_iartin,$Ttn::CauseTerm1 + (OFFSETT2LEG_660004646 * (indice_660004646 - 1)))
ALORS
	CauseForTerm_660004646 = i_get_art_field(g_iartin,$Ttn::CauseTerm1 + (OFFSETT2LEG_660004646 * (indice_660004646 - 1)))
	SI ( ( CauseForTerm_660004646 < 0x00 ) || ( CauseForTerm_660004646 > 0x04 ) )
	ALORS
		SAUT FIN_GENERER_MT_I
	FINSI
SINON
	SAUT FIN_GENERER_MT_I
FINSI

#
# NbServices 
#
SI i_valid_field_n(g_iartin,$Ttn::NumOfServ1 + (OFFSETT2LEG_660004646 * (indice_660004646 - 1)))
ALORS
	NbServices_660004646 = i_get_art_field(g_iartin,$Ttn::NumOfServ1 + (OFFSETT2LEG_660004646 * (indice_660004646 - 1)))
	SI ( ( NbServices_660004646 != 0x01 ) && ( NbServices_660004646 != 0x02 ) )
	ALORS
		SAUT FIN_GENERER_MT_I
	FINSI
SINON
	SAUT FIN_GENERER_MT_I
FINSI

#
# ServiceType 
#
SI i_valid_field_n(g_iartin,$Ttn::ServType301 + (OFFSETT2LEG_660004646 * (indice_660004646 - 1)))
ALORS
	ServiceType30_660004646 = i_get_art_field(g_iartin,$Ttn::ServType301 + (OFFSETT2LEG_660004646 * (indice_660004646 - 1)))
	SI ( ( ServiceType30_660004646 != 0x00 ) && ( ServiceType30_660004646 != 0x03 ) )
	ALORS
		GENERER_MTSVC30_660004646 = FAUX_660004646
	FINSI
	
	SI !i_valid_field_n(g_iartin,$Ttn::Duration301 + (OFFSETT2LEG_660004646 * (indice_660004646 - 1)))
	ALORS
		GENERER_MTSVC30_660004646 = FAUX_660004646
	FINSI
	
	SI !i_valid_field_n(g_iartin,$Ttn::Bursts301 + (OFFSETT2LEG_660004646 * (indice_660004646 - 1)))
	ALORS
		GENERER_MTSVC30_660004646 = FAUX_660004646
	FINSI	
	
SINON
	GENERER_MTSVC30_660004646 = FAUX_660004646
FINSI	

SI i_valid_field_n(g_iartin,$Ttn::ServType311 + (OFFSETT2LEG_660004646 * (indice_660004646 - 1)))
ALORS
	ServiceType31_660004646 = i_get_art_field(g_iartin,$Ttn::ServType311 + (OFFSETT2LEG_660004646 * (indice_660004646 - 1)))
	SI ( ( ServiceType31_660004646 != 0x00 ) && ( ServiceType31_660004646 != 0x03 ) )
	ALORS
		GENERER_MTSVC31_660004646 = FAUX_660004646
	FINSI
		
	SI !i_valid_field_n(g_iartin,$Ttn::Duration311 + (OFFSETT2LEG_660004646 * (indice_660004646 - 1)))
	ALORS
		GENERER_MTSVC31_660004646 = FAUX_660004646
	FINSI
	
	SI !i_valid_field_n(g_iartin,$Ttn::Bursts311 + (OFFSETT2LEG_660004646 * (indice_660004646 - 1)))
	ALORS
		GENERER_MTSVC31_660004646 = FAUX_660004646
	FINSI	
SINON
	GENERER_MTSVC31_660004646 = FAUX_660004646
	ServiceType31_660004646 = -1
FINSI

# si les 2 services ne sont pas generables, on passe au MT suivant
SI ( GENERER_MTSVC30_660004646 == FAUX_660004646 ) && ( GENERER_MTSVC31_660004646 == FAUX_660004646 )
ALORS
	SAUT FIN_GENERER_MT_I
FINSI


#
# Controles croises entre les champs
#

#
# ORIG/NbServices
# TERMLEG/NbServices
#
SI (NbServicesO_660004646 == 0x01)
ALORS
	SI  ( NbServices_660004646 != 0x01 )
	ALORS 
		SAUT FIN_GENERER_MT_I
	FINSI
FINSI

SI (NbServicesO_660004646 == 0x02)
ALORS
	SI ( ( NbServices_660004646 != 0x01 ) && ( NbServices_660004646 != 0x02 ) )
	ALORS 
		SAUT FIN_GENERER_MT_I
	FINSI
FINSI


#
# TERMLEG/NbServices
# TERMLEG/SIRLIST 30/ServiceType
# TERMLEG/SIRLIST 31/ServiceType
#
SI ( NbServices_660004646 == 0x01 )
ALORS
	MT_P2T_only_660004646 = VRAI_660004646	
	SI (ServiceType30_660004646 == 0x00) && (ServiceType31_660004646 == 0x00)
	ALORS
		SAUT FIN_GENERER_MT_I
	FINSI
	
	SI (ServiceType30_660004646 != 0x00) && (ServiceType31_660004646 != 0x00)
	ALORS
		SAUT FIN_GENERER_MT_I
	FINSI
	k0_leg_660004646 = 0
FINSI

SI ( NbServices_660004646 == 0x02 )
ALORS
	MT_P2T_only_660004646 = FAUX_660004646
	SI !( ((ServiceType30_660004646 == 0x00) && (ServiceType31_660004646 == 0x03)) || ((ServiceType30_660004646 == 0x03) && (ServiceType31_660004646 == 0x00)) )
	ALORS
		SAUT FIN_GENERER_MT_I
	FINSI
	
	SI (ServiceType30_660004646 == 0x00)
	ALORS
		k0_leg_660004646 = 0
		k3_leg_660004646 = 1
	SINON
		k0_leg_660004646 = 1
		k3_leg_660004646 = 0
	FINSI
	
	MT_U2P2C_duration_660004646 = i_get_art_field(g_iartin,$Ttn::Duration301 + (OFFSETT2LEG_660004646 * (indice_660004646 - 1) + (k3_leg_660004646 * OFFSETT3P2T_660004646)))
FINSI

GENERER_MTSVC_660004646 = VRAI_660004646

POINT FIN_GENERER_MT_I


##############################################################################
# Generation d'un DPV MO+MT pour le MT en cours ?
##############################################################################
SI !((EFFICACE_MT_660004646 == VRAI_660004646) && (GENERER_MTSVC_660004646 == VRAI_660004646))
ALORS
	SAUT DEBUT_GENERATION_MO_MT
FINSI

##############################################################################
# Initialisations diverses pour la production du DPV MO+MT
##############################################################################


##############################################################################
# A verifier : si NbServices = 1, on genere un DC (avec le T3 30)
#			si NbServices = 2, on genere un DC (avec les T3 30 et 31)
##############################################################################

POINT DEBUT_PRODUCTION_MO_MT

#
# Principe : on traite en premier le MTP2T (c-a-d termLegList[i].SIRList[k].ServiceType = 0x00)
# Ensuite si besoin est, on repart de cet article produit pour generer le MT U2P2C (c-a-d termLegList[i].SIRList[k].ServiceType = 0x03) en ne modifiant que quelques champs
# On travaille toujours sur g_iartout pour ne pas modifier la fonction d'aiguillage

########################################################
# Mise au format pour MO_MT partie MTP2T
########################################################

# V3t1.5 DATE
# V3t7 estalloc
resultat_660004646 = i_get_art_field(g_iartin,$Ttn::DATE) + j_660004646
erreur_660004646 = i_set_art_field(g_iartout, $Tdpvgsm::DATE, resultat_660004646)
erreur_660004646 = i_set_art_field(g_iartout, $Tdpvgsm::estalloc, resultat_660004646)

# V3t1.6 DUREE
SI (MT_P2T_only_660004646 == VRAI_660004646)
ALORS
	resultat_660004646 = i_get_art_field(g_iartin,$Ttn::CallDur1 + (OFFSETT2LEG_660004646 * (indice_660004646 - 1)))
SINON
	resultat_660004646 = i_get_art_field(g_iartin,$Ttn::CallDur1 + (OFFSETT2LEG_660004646 * (indice_660004646 - 1))) - MT_U2P2C_duration_660004646
FINSI
erreur_660004646 = i_set_art_field(g_iartout, $Tdpvgsm::DUREE, resultat_660004646)

# V3t1.13 indeff
SI ( NbServices_660004646 == 0x02 )
ALORS
	resultat_660004646 = 0
SINON
	SI ( CauseForTerm_660004646 >= 0x0 ) && ( CauseForTerm_660004646 <= 0x2 )
	ALORS
		resultat_660004646 = 0
	SINON
		resultat_660004646 = 1
	FINSI
FINSI
erreur_660004646 = i_set_art_field(g_iartout, $Tdpvgsm::indeff, resultat_660004646)

# V3t1.14 tterm
SI ( resultat_660004646 != 0x0 )
ALORS
	resultat_660004646 = CauseForTerm_660004646
FINSI
erreur_660004646 = i_set_art_field(g_iartout, $Tdpvgsm::tterm, resultat_660004646)

# V3t2 idpart

SI (i_valid_field_n(g_iartin,$Ttn::ConnectNum1 + (OFFSETT2LEG_660004646 * (indice_660004646 - 1))))
ALORS
	erreur_660004646 = i_dup_chp_rnisGSM(g_iartin, g_iartout, $Ttn::ConnectNum1 + (OFFSETT2LEG_660004646 * (indice_660004646 - 1)), $Tdpvgsm::idpart,-$NORM:TALK_NOW,0)
SINON
	erreur_660004646 = i_supprChamp(g_iartout, "T3t2")
FINSI

#erreur = i_normal(g_iartin, $Ttn::ConnectNum1 + (OFFSETT2LEG * (indice - 1)),$Ttn::ConnectNum1 + (OFFSETT2LEG * (indice - 1)), g_icopo, $Tcopo::NDR, $Tcopo::NDE , 1, "TALK_NOW", "TALK_NOW")
#indice_idpart = 0

#POINT BOUCLE_IDPART
#resultat = i_get_art_fieldtab(g_icopo, $Tcopo::NDR, indice_idpart)
#        trace1(" element : %x",res)

#SI (resultat != 00) && (indice_idpart < 19)
#ALORS

# Cas particuliers : * (2A en ASCII) et # (23 en ASCII)

#	SI (resultat == 0x2a)
#	ALORS
#		erreur = i_set_art_fieldtab(g_iartout, $Tdpvgsm::idpart, indice_idpart, 0xB)
#		indice_idpart = indice_idpart + 1
#		SAUT BOUCLE_IDPART
#	FINSI

#	SI (resultat == 0x23)
#	ALORS
#		erreur = i_set_art_fieldtab(g_iartout, $Tdpvgsm::idpart, indice_idpart, 0xC)
#		indice_idpart = indice_idpart + 1
#		SAUT BOUCLE_IDPART
#	FINSI

# Cas generique
#	erreur = i_set_art_fieldtab(g_iartout, $Tdpvgsm::idpart, indice_idpart, resultat-0x30)
#	indice_idpart = indice_idpart + 1
#	SAUT BOUCLE_IDPART
#FINSI




# V4t35.1 duration
resultat_660004646 = i_get_art_field(g_iartin, $Ttn::CallDur1 + (OFFSETT2LEG_660004646 * (indice_660004646 - 1)))
erreur_660004646 = i_set_art_field(g_iartout, $Tdpvgsm::duration, resultat_660004646)

# V4t35.2 occurenceNb
erreur_660004646 = i_set_art_field(g_iartout, $Tdpvgsm::occurenceNb, j_660004646)

# V4t35.3 participantsNb
erreur_660004646 = i_set_art_field(g_iartout, $Tdpvgsm::participantsNb, indice_660004646)

# V3t52 
SI i_valid_field_n(g_iartin,$Ttn::Location1+ (OFFSETT2LEG_660004646 * (indice_660004646 - 1)))
ALORS
	erreur_660004646 = i_dup_chp_1val(g_iartin, g_iartout10, $Ttn::Location1+ (OFFSETT2LEG_660004646 * (indice_660004646 - 1)), $Conv_URS::Location)
SINON
	SAUT FIN_MTI_location_identity
FINSI

SI i_valid_field_n(g_iartin,$Ttn::LocAreaCod1+ (OFFSETT2LEG_660004646 * (indice_660004646 - 1)))
ALORS
	erreur_660004646 = i_dup_chp_1val(g_iartin, g_iartout10, $Ttn::LocAreaCod1+ (OFFSETT2LEG_660004646 * (indice_660004646 - 1)), $Conv_URS::LocationArea)
SINON
	SAUT FIN_MTI_location_identity
FINSI

SI i_valid_field_n(g_iartin,$Ttn::CellID1+ (OFFSETT2LEG_660004646 * (indice_660004646 - 1)))
ALORS
	erreur_660004646 = i_dup_chp_1val(g_iartin, g_iartout10, $Ttn::CellID1+ (OFFSETT2LEG_660004646 * (indice_660004646 - 1)), $Conv_URS::CellID)
SINON
	SAUT FIN_MTI_location_identity
FINSI

# Verification de la valeur des champs
erreur_660004646 = i_get_art_str(g_iartout10, $Conv_URS::Location, pt_location_identity_660004646)
SI (i_strcmp(pt_location_identity_660004646, NoLocation2_660004646) == 0)
ALORS
	SAUT FIN_MTI_location_identity	
FINSI

erreur_660004646 = i_get_art_str(g_iartout10, $Conv_URS::LocationArea, pt_location_identity_660004646)
SI (i_strcmp(pt_location_identity_660004646, NoLocation1_660004646) == 0)
ALORS
	SAUT FIN_MTI_location_identity	
FINSI

erreur_660004646 = i_get_art_str(g_iartout10, $Conv_URS::CellID, pt_location_identity_660004646)
SI (i_strcmp(pt_location_identity_660004646, NoLocation1_660004646) == 0)
ALORS
	SAUT FIN_MTI_location_identity	
FINSI

MT_location_identity_660004646 = 1

POINT FIN_MTI_location_identity

SI (MO_location_identity_660004646 == 0x00) && (MT_location_identity_660004646 == 0x00)
ALORS
	SI i_valid_field_n(g_iartout, $Tdpvgsm::T3t52)
	ALORS
		erreur_660004646 = i_supprChamp(g_iartout, "T3t52")
		SAUT FIN_T3t52I
	FINSI
SINON
	SI !i_valid_field_n(g_iartout, $Tdpvgsm::T3t52)
	ALORS
		erreur_660004646 =  i_ajoutChampNum(g_iartout, $Tdpvgsm::T3t52, $Tdpvgsm::callingLocation, 6)
	FINSI
FINSI

# V4t52.1 callingLocation
SI (MO_location_identity_660004646 != 0x00)
ALORS
	erreur_660004646 = i_dup_chp_1val(g_iartout10, g_iartout, $Conv_URS::LocationIDO, $Tdpvgsm::callingLocation)
SINON
	erreur_660004646 = i_supprChamp(g_iartout, "T4t52.1")
FINSI
	
# V4t52.2 callingLocation
SI (MT_location_identity_660004646 != 0x00)
ALORS
	erreur_660004646 = i_dup_chp_1val(g_iartout10, g_iartout, $Conv_URS::LocationID, $Tdpvgsm::calledLocation)
SINON
	erreur_660004646 = i_supprChamp(g_iartout, "T4t52.2")
FINSI

POINT FIN_T3t52I

# V4t61.5
resultat_660004646 = i_get_art_field(g_iartin,$Ttn::ServType301 + (OFFSETT2LEG_660004646 * (indice_660004646 - 1)) + (k0_leg_660004646 * OFFSETT3P2T_660004646))
erreur_660004646 = i_set_art_field(g_iartout, $Tdpvgsm::T3t61+16, resultat_660004646)

# V4t61.8 usrSpeechDur
SI (i_get_art_field(g_iartin, $Ttn::Bursts301 + (OFFSETT2LEG_660004646 * (indice_660004646 - 1)) + (k0_leg_660004646 * OFFSETT3P2T_660004646)) == 0x00)
ALORS
	erreur_660004646 = i_set_art_field(g_iartout, $Tdpvgsm::usrSpeechDur, 0)
SINON
	erreur_660004646 = i_set_art_field(g_iartout, $Tdpvgsm::usrSpeechDur, i_get_art_field(g_iartin, $Ttn::Duration301 + (OFFSETT2LEG_660004646 * (indice_660004646 - 1)) + (k0_leg_660004646 * OFFSETT3P2T_660004646)))
FINSI

# V4t61.9 speechBurstNb
SI !i_valid_field_n(g_iartout, $Tdpvgsm::speechBurstNb)
ALORS
	erreur_660004646 =  i_ajoutChampNum(g_iartout, $Tdpvgsm::T3t61+26, $Tdpvgsm::speechBurstNb, 1)
FINSI
erreur_660004646 = i_dup_chp_1val(g_iartin, g_iartout, $Ttn::Bursts301 + (OFFSETT2LEG_660004646 * (indice_660004646 - 1)) + (k0_leg_660004646 * OFFSETT3P2T_660004646), $Tdpvgsm::speechBurstNb)


######################################################################################################
# Appel fonction distribution pour MO_MT partie MTP2T
# FO 186 : on genere ce service seulement si les controles du GENERERMTSVC correspondant ont ete OK 
######################################################################################################
SI (( k0_leg_660004646 == 0) && ( GENERER_MTSVC30_660004646 == FAUX_660004646 )) || (( k0_leg_660004646 == 1) && ( GENERER_MTSVC31_660004646 == FAUX_660004646 ))
ALORS
	SAUT FIN_MO_MT_MTP2T
SINON
	erreur_660004646 = aiguillage2_660004590 (g_iartin, g_iartout, DISTRIBUTION_AIG_IMSI_660004646, Multidistribution_Oui_660004646)
	SI (erreur_660004646 == TRAI_KO_660004646)
	ALORS
#		QC1005
		trace("<<<__LINE__<<<__FILE__<<< Erreur retour fonction aiguillage2")
#		code_errone = 0xA0B1
#		type_cra=i_get_art_field(g_iartout,$Tdpvgsm::type)
#		erreur = i_PlvMessEmettre(7500,2,g_iartin,"",3,code_errone,C_Article,type_cra)
		SAUT STOCKE_ERRONE
	SINON
		SI (erreur_660004646 == TRAI_REDIST_660004646) && (i_LireRedistCpt() != 0)
		ALORS
			SAUT FIN_DISTRIBUTION
		FINSI
	FINSI
	j_660004646 = j_660004646 + 1
FINSI

POINT FIN_MO_MT_MTP2T

SI (MT_P2T_only_660004646 == VRAI_660004646)
ALORS
	SAUT DEBUT_GENERATION_MO_MT
FINSI


########################################################
# Mise au format pour MO_MT partie MTU2P2C
########################################################
# V3t1.5 DATE
# V3t7 estalloc
resultat_660004646 = i_get_art_field(g_iartin,$Ttn::Up2P2CtimeO) + j_660004646
erreur_660004646 = i_set_art_field(g_iartout, $Tdpvgsm::DATE, resultat_660004646)
erreur_660004646 = i_set_art_field(g_iartout, $Tdpvgsm::estalloc, resultat_660004646)

# V3t1.6 DUREE
resultat_660004646 = i_get_art_field(g_iartin,$Ttn::Duration301 + (OFFSETT2LEG_660004646 * (indice_660004646 - 1)) + (k3_leg_660004646 * OFFSETT3P2T_660004646))
erreur_660004646 = i_set_art_field(g_iartout, $Tdpvgsm::DUREE, resultat_660004646)

# V4t35.2 occurenceNb
erreur_660004646 = i_set_art_field(g_iartout, $Tdpvgsm::occurenceNb, j_660004646)

# V4t61.5
resultat_660004646 = i_get_art_field(g_iartin,$Ttn::ServType301 + (OFFSETT2LEG_660004646 * (indice_660004646 - 1)) + (k3_leg_660004646 * OFFSETT3P2T_660004646))
erreur_660004646 = i_set_art_field(g_iartout, $Tdpvgsm::T3t61+16, resultat_660004646)

# V4t61.8 usrSpeechDur
erreur_660004646 = i_set_art_field(g_iartout, $Tdpvgsm::usrSpeechDur, i_get_art_field(g_iartin, $Ttn::Duration301 + (OFFSETT2LEG_660004646 * (indice_660004646 - 1)) + (k3_leg_660004646 * OFFSETT3P2T_660004646)))

# V4t61.9 speechBurstNb
SI i_valid_field_n(g_iartout, $Tdpvgsm::speechBurstNb)
ALORS
	erreur_660004646 = i_supprChamp(g_iartout, "T4t61.9")
FINSI

#####################################################################################################
# Appel fonction distribution pour MO_MT partie MTU2P2C
# FO 186 : on genere ce service seulement si les controles du GENERERMTSVC correspondant ont ete OK 
#####################################################################################################
SI (( k3_leg_660004646 == 0) && ( GENERER_MTSVC30_660004646 == FAUX_660004646 )) || (( k3_leg_660004646 == 1) && ( GENERER_MTSVC31_660004646 == FAUX_660004646 ))
ALORS
	SAUT FIN_MO_MT_MTU2P2C
SINON
	erreur_660004646 = aiguillage2_660004590 (g_iartin, g_iartout, DISTRIBUTION_AIG_IMSI_660004646, Multidistribution_Oui_660004646)
	SI (erreur_660004646 == TRAI_KO_660004646)
	ALORS
#		QC1005
		trace("<<<__LINE__<<<__FILE__<<< Erreur retour fonction aiguillage2")
#		code_errone = 0xA0B1
#		type_cra=i_get_art_field(g_iartout,$Tdpvgsm::type)
#		erreur = i_PlvMessEmettre(7500,2,g_iartin,"",3,code_errone,C_Article,type_cra)
		SAUT STOCKE_ERRONE
	SINON
		SI (erreur_660004646 == TRAI_REDIST_660004646) && (i_LireRedistCpt() != 0)
		ALORS
			SAUT FIN_DISTRIBUTION
		FINSI
	FINSI
	j_660004646 = j_660004646 + 1
FINSI

POINT FIN_MO_MT_MTU2P2C
SAUT DEBUT_GENERATION_MO_MT


POINT FIN_DISTRIBUTION
RETOUR TRAIT_OK

#####################################################################
# POINT de branchement : stockage PT_ERRONE
#	       correspond au cas d'erreur syntaxiques et semantiques
#####################################################################

POINT STOCKE_ERRONE

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

erreur_660004646 = i_make_art_rej(g_iartin, g_iartout, 0)
erreur_660004646 = i_stocke_art(g_iartout, 0, PT_ERRONE, 0)

trace("Fin traitement Ttn")
RETOUR TRAIT_OK


###########################################################################
# Stockage en elimine
###########################################################################

POINT STOCKE_DIV
#IFDEF trace_niv1 = 1
trace( "Fin du Pcode de traitement talknow : Stockage en ELIMINE" )
#ENDIF
erreur_660004646 = i_stocke_art( g_iartin, 0, PT_DIVERS, 0 )

RETOUR TRAIT_OK
#------------------------- Fin Ttn_dis.src ------------------------------------------
