DEFINITION C_Tdpv_660004657 "Tdpvgsm"
DEFINITION ERR_DUPL_660004657 0x0D0
DEFINITION MODULE_660004657 0xA000
DEFINITION ERR_DISTR_660004657 0x110
DEFINITION ERR_CONV_660004657 0x0E0
DEFINITION Multidistribution_Non_660004657 0
DEFINITION DISTRIBUTION_SPECIALE_660004657 0
DEFINITION NUMTAB_660004657 4
DEFINITION TRAI_KO_660004657 -1
REGISTRE ENTIER EFFICACE_660004657
REGISTRE ENTIER date_fin_660004657
REGISTRE ENTIER sessionTerm_660004657
REGISTRE ENTIER val_sessTerm_660004657
REGISTRE ENTIER TransSessTerm_660004657
REGISTRE ENTIER Node_660004657
REGISTRE ENTIER type_cra_660004657
REGISTRE ENTIER longueur_660004657
REGISTRE ENTIER index_660004657
REGISTRE ENTIER long_MSISDN_660004657
REGISTRE ENTIER ele0_660004657
REGISTRE ENTIER ele1_660004657
REGISTRE ENTIER ele2_660004657
REGISTRE ENTIER date_audit_gmt_660004657
REGISTRE ENTIER date_audit_660004657
REGISTRE ENTIER Start_Date_660004657
REGISTRE ENTIER Date_Debut_660004657
REGISTRE ENTIER Request_Time_660004657
REGISTRE ENTIER Request_660004657
REGISTRE ENTIER Date_Fin_660004657
REGISTRE ENTIER End_Time_660004657
REGISTRE ENTIER erreur_660004657
REGISTRE ENTIER ERREUR_660004657
REGISTRE ENTIER code_rejet_660004657
REGISTRE ENTIER Duree_660004657
REGISTRE ENTIER status_660004657
REGISTRE ENTIER res_660004657
REGISTRE ENTIER CORLStatus_660004657
REGISTRE ENTIER flag_rdt_660004657
REGISTRE ENTIER val_recordSeqNb_660004657
REGISTRE ENTIER val_SigVolum_660004657
REGISTRE ENTIER val_ExtBearVolum_660004657
REGISTRE ENTIER val_TotalVolum_660004657
REGISTRE ENTIER val_CauseClose_660004657
REGISTRE ENTIER val_sessionTerm_660004657
REGISTRE ENTIER index2_660004657
REGISTRE ENTIER unite_660004657
REGISTRE ENTIER dizaine_660004657
REGISTRE ENTIER resultat_660004657
REGISTRE ENTIER cpteur_660004657
REGISTRE POINTEUR ptr_AX_IDEMET_IMS_660004657
REGISTRE POINTEUR ptr_val_sessTerm_660004657
REGISTRE POINTEUR ptr_TransSessTerm_660004657
REGISTRE POINTEUR ptr_call_660004657
REGISTRE POINTEUR ptr_calling_660004657
REGISTRE POINTEUR ptr_calling_DCB_660004657
REGISTRE POINTEUR ptr_motif_660004657
REGISTRE POINTEUR ptr_Dialled_660004657
REGISTRE POINTEUR ptr_Dialled_DCB_660004657
REGISTRE POINTEUR ptr_Dial_660004657
REGISTRE POINTEUR ptr_IMSI_660004657
REGISTRE POINTEUR ptr_IMSI_DCB_660004657
REGISTRE POINTEUR ptr_ggsnAddr_660004657
REGISTRE POINTEUR ptr_SgsnAddr_660004657
REGISTRE POINTEUR ptr_valeurIN_660004657
REGISTRE POINTEUR ptr_networkInfo_660004657
REGISTRE POINTEUR ptr_localisation_660004657
REGISTRE POINTEUR ptr_ComputedInf07_660004657
REGISTRE POINTEUR ptr_localisation_DCB_660004657
REGISTRE POINTEUR ptr_SubRecordType_660004657
################################################################################
#
#Pcode de distribution PRIMS : Tprims_dis.src
#
# history :
# 		Creation le 07/12/10
#
# 25/01/2011 PKH QC795 Correction de l'alarme 7500
# 25/01/2011 PKH QC795 Suppression de la structure T4t66.1 si aucune valeur l'alimente
# 31/01/2011 PKH QC801 Modification de specif tronquer IMSI  15 octets au lieu de 8 octets et correction valorisation du champ local
# 08/02/2011 PKH G3R2 QC795 Correction valorisation a 0 du champ DURREE dans le cas ou callDuration est absent
# 08/02/2011 PKH G3R2 QC795 Correction valorisation a 0xff pour tterm quand sessionTerm est absent
# 08/02/2011 PKH G3R2 QC795 Correction T3t7 (estalloc) non present si srvRequesTime absent
# 08/02/2011 PKH G3R2 QC805 Correction valorisation des champs SgsnAddr et GGSNAddr
# 10/02/2011 PKH G3R2 QC795 Ajout du champ T3t30 Date audit et Code Plateforme emettrice
# 10/02/2011 PKH G3R2 QC808 deconstruire le mapping du T3t33 MSISDN non transmis en entree
# 16/02/2011 PKH G3R2 QC814 les champs local SgsnAddr et GGSNAddr ne doivent pas apparaitre dans si absents en entree
# 10/03/2011 JLG G3R2C4 verification pointeurs et variables
# 16/06/2011 JLG G3R3C9 QC Sdate Platine
# 14/12/2011 JLG G3R5 QC978 (modif fct NORMA_PRIMS) Valorisation V3t4 MSISDN bloquant pour SCOT
# 29/02/2012 - JLG -G3R6 QC1005 modif alarme retour aiguillage
# 02/07/2014 - JLG -G5R1 QC1405, champ eec du DPV si g_ieec > 500
# 18/09/2014 - JLG - report G5R1C6 Remplacement de la fonction CONV_DCB_ASCII par i_get_art_str
# 08/10/2014 - JLG - report G5R1C6  test longueur pour memcpy
################################################################################


val_sessTerm_660004657 = 0
sessionTerm_660004657 = 0
date_fin_660004657 = 0
Node_660004657 = -1
type_cra_660004657 = 0
EFFICACE_660004657 = 1
longueur_660004657 = -1
index_660004657 = 0
ele0_660004657 = 0
ele1_660004657 = 0
ele2_660004657 = 0
long_MSISDN_660004657 = 0
Start_Date_660004657 = 0
Date_Debut_660004657 = -1
erreur_660004657 = -1
code_rejet_660004657 = 0
Duree_660004657 = 0
status_660004657 = 0
res_660004657	= 0
CORLStatus_660004657 = -1
Request_Time_660004657 = 0
Request_660004657 = -1
Date_Fin_660004657 = -1
End_Time_660004657 = 0
flag_rdt_660004657 = 0
val_recordSeqNb_660004657 = 0
val_SigVolum_660004657 = 0
val_ExtBearVolum_660004657 = 0
val_TotalVolum_660004657 = 0
val_CauseClose_660004657 = 0
val_sessionTerm_660004657 = 0
index2_660004657 = 0
unite_660004657 = 0
dizaine_660004657 = 0
resultat_660004657 = 0
cpteur_660004657 = 0
ptr_AX_IDEMET_IMS_660004657 ="ptr_AX_IDEMET_IMS111111111111111111111111111111111111111111111111111111111"
ptr_val_sessTerm_660004657 = "ptr_val_sessTerm231231231231231231232232231231231321231231231231231231231231"
ptr_TransSessTerm_660004657 = "ptr_TransSessTerm99999999999999999999999999999999999999999999999999999999"
ptr_call_660004657 = "ptr_call767676767676767676767676766767676767676767676767676767676767676767676767676767676776767677676767676761111111111111111111"
ptr_calling_660004657 = "ptr_calling383838383838383838383838383838383838383838383838838383838383838383883838383838383883838383838383111111111111111111111"
ptr_calling_DCB_660004657 = "ptr_calling_DCB3333333333333333333333333333333333333333333333333333333"
ptr_Dialled_660004657 = "ptr_Dialled252525252525252525252525252525252525252525255252525252525252525252525252525252525252525252525252511111111111111111111"
ptr_Dialled_DCB_660004657 = "ptr_Dialled_DCB2222222222222222222222222222222222222222222222222221111"
ptr_Dial_660004657    = "ptr_Dial292929292929292929292929292929292922929292929292292929292929292929292929292992292929929292922992929111111111111111111111"
ptr_IMSI_660004657 = "ptr_IMSI_DCB75757575757575775757575757575757575757575757575575757577557755775757575575757755775577575577575755711111111111111111"
ptr_IMSI_DCB_660004657 = "ptr_IMSI85858585858585858585858585858585858585858588558585858585858585"
ptr_ggsnAddr_660004657 = "ptr_ggsnAddr31431431431431434134134134314314131413413143141341311413141314131413411314131413141314134113141314131411111111111111"
ptr_SgsnAddr_660004657 = "ptr_SgsnAddr72172172172172172172172127127127127127127172172712712717271272717271727127172712717271277717712721727111111111111111"
ptr_valeurIN_660004657 = "ptr_valeurIN0909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909099090909090909099099"
ptr_networkInfo_660004657 = "ptr_networkInfo72172712717127712771727176272172172771727172771762717217271772717271277127712771271721727787771721772172672262726"
ptr_motif_660004657 = "ptr_motif31313131331313311313131313131313131313313313313131133131313131133313131313131131331311313313313131313311333311331313333131131333131313313113"
ptr_localisation_660004657 = "ptr_localisation515151515151515151515151515515151515111111111111111111111111111111111111111111111111111111111111111111111111"
ptr_ComputedInf07_660004657 = "ptr_ComputedInf0"
ptr_localisation_DCB_660004657 = "ptr_localisation_DCB37837837837837837837837837387383783783738371138373"
ptr_SubRecordType_660004657 = "ptr_SubRecordType808080808080808080808880880808808808080808080808808111080808080808080808080808080808080080880808080808080808080"
i_strcpy(ptr_AX_IDEMET_IMS_660004657,"")
i_strcpy(ptr_val_sessTerm_660004657,"")
i_strcpy(ptr_TransSessTerm_660004657,"")
i_strcpy(ptr_call_660004657,"")
i_strcpy(ptr_calling_660004657,"")
i_strcpy(ptr_Dialled_660004657,"")
i_strcpy(ptr_Dial_660004657,"")
i_strcpy(ptr_Dialled_DCB_660004657,"")
i_strcpy(ptr_calling_DCB_660004657,"")
i_strcpy(ptr_IMSI_DCB_660004657,"")
i_strcpy(ptr_IMSI_660004657,"")
i_strcpy(ptr_ggsnAddr_660004657,"")
i_strcpy(ptr_SgsnAddr_660004657,"")
i_strcpy(ptr_valeurIN_660004657,"")
i_strcpy(ptr_networkInfo_660004657,"")
i_strcpy(ptr_motif_660004657,"")
i_strcpy(ptr_localisation_660004657,"")
i_strcpy(ptr_ComputedInf07_660004657,"")
i_strcpy(ptr_localisation_DCB_660004657,"")
i_strcpy(ptr_SubRecordType_660004657,"")

trace ("---------------------------------")
trace ("	PRIMS_CSCF Distribution		 ")
trace ("---------------------------------")

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

SI (flag_rdt_660004657 == 0)
ALORS
	erreur_660004657 = i_add_opt( "E_Redistri2" )
FINSI
erreur_660004657 = i_set_attr_val_n( $E_Redistri2::EnvoiRedis, 0)

########################################################
# Cpt applicatif CPT_RDT=1509 (REDISTRIBUTION)
########################################################
date_fin_660004657 = i_get_art_field(g_iartin,$Tprims::dfin)
erreur_660004657 = i_incr_redist_dist_660004265(date_fin_660004657)

erreur_660004657 = i_cree_art("Conv_URS",g_iartout10)

#-------------#
#AX_IDEMET
#-------------#
# QC Sdate Platine
#i_strcpy(ptr_AX_IDEMET_IMS, i_get_tab_field("VariableContexte",i_get_art_field(g_iartin,$Tprims::callStartTime),"AX_IDEMET_PRIMS"))
i_strcpy(ptr_AX_IDEMET_IMS_660004657, i_get_tab_field("VariableContexte",i_get_art_field(g_iartin,$Tprims::StartTime_SDATE),"AX_IDEMET_PRIMS"))

#-----------------------------#
# Calcul de TransSessTerm
#-----------------------------#

#TransSessTerm = 0xFF
SI (i_valid_field_n(g_iartin, $Tprims::sessionTerm))
ALORS
	sessionTerm_660004657 = i_get_art_field(g_iartin, $Tprims::sessionTerm)
	# Recuperation de la valeur absolue
	SI sessionTerm_660004657 < 0
	ALORS
		val_sessTerm_660004657 = sessionTerm_660004657 - (2 * sessionTerm_660004657)
	SINON
		val_sessTerm_660004657 = sessionTerm_660004657
	FINSI

	# Utilisation du champ chgcar de CONV_URS car il presente la structure souhaitee (tableau DCB de 4 elements)
	# Remplissage du champ en transformant la valeur en hexa : 100 en decimal -> 100 en hexa

	g_iartout10.chgcarDCB[0] = 0
	g_iartout10.chgcarDCB[1] = val_sessTerm_660004657/100
	g_iartout10.chgcarDCB[2] = (val_sessTerm_660004657 - (g_iartout10.chgcarDCB[1]*100)) /10
	g_iartout10.chgcarDCB[3] = val_sessTerm_660004657 - (g_iartout10.chgcarDCB[1]*100) - (g_iartout10.chgcarDCB[2]*10)
        # G5R1C5 Remplacement de la fonction CONV_DCB_ASCII par i_get_art_str
	# Conversion en ASCII pour appel a la table externe
	# On considere avoir uniquement des valeurs comprises entre 100 et 999 :
	# il faut donc retirer le 0 de bourrage a gauche
        erreur_660004657 = i_get_art_str(g_iartout10, $Conv_URS::chgcarDCB, ptr_val_sessTerm_660004657)
	i_get_sub_str(ptr_val_sessTerm_660004657, 1, 3, ptr_val_sessTerm_660004657)

	i_strcpy(ptr_TransSessTerm_660004657, i_get_tab_field("SCSCFRecordClosing", date_fin_660004657, ptr_val_sessTerm_660004657))

	SI (i_strcmp(ptr_TransSessTerm_660004657, g_inull)) != 0
	ALORS
		TransSessTerm_660004657 = CONV_ASCIINUMHEX_INT_660004265(ptr_TransSessTerm_660004657)
	SINON
		TransSessTerm_660004657 = 0xFF
	FINSI
FINSI

#--------------------------#
#Localisation
#--------------------------#
#QC801 correction recherche du code postal pour valorisation du champ local
SI (i_valid_field_n(g_iartin, $Tprims::networkInfo))
ALORS
	erreur_660004657 = i_get_art_str(g_iartin, $Tprims::networkInfo, ptr_networkInfo_660004657)
	erreur_660004657 = i_format_str2(ptr_valeurIN_660004657,"%s%s",ptr_networkInfo_660004657,";")
	trace("<<__LINE__>> networkInfo present ")
	#i_strcpy(ptr_valeurIN,ptr_networkInfo)

#recherche du motif au debut de la chaine
	SI !(i_strplcmp(ptr_valeurIN_660004657,"lac=",0,4))
	ALORS
		erreur_660004657 = i_recupererValeur(ptr_valeurIN_660004657,ptr_motif_660004657,longueur_660004657 - 1,';')
		i_get_sub_str(ptr_valeurIN_660004657,4,-1,ptr_localisation_660004657)
		longueur_660004657 = i_strlen(ptr_localisation_660004657)
		SI (longueur_660004657 > 5)
		ALORS
			i_get_sub_str(ptr_localisation_660004657,0,4,ptr_localisation_660004657)
		FINSI
		SAUT BOUCLE_FIN
	FINSI

#recherche du motif non au debut de la chaine
	longueur_660004657 = i_strlen(ptr_valeurIN_660004657)
	cpteur_660004657 = 0
	POINT BOUCLE_RECHERCHE
	SI (cpteur_660004657 <= longueur_660004657)
	ALORS
		erreur_660004657 = i_recupererValeur(ptr_valeurIN_660004657,ptr_motif_660004657,longueur_660004657 - 1,';')
		SI !(i_strplcmp(ptr_motif_660004657,"lac=",0,4))
		ALORS
			i_get_sub_str(ptr_motif_660004657,4,-1,ptr_localisation_660004657)
			longueur_660004657 = i_strlen(ptr_localisation_660004657)

			SI (longueur_660004657 > 5)
			ALORS
				i_get_sub_str(ptr_localisation_660004657,0,4,ptr_localisation_660004657)
			FINSI
			SAUT BOUCLE_FIN
		SINON
			cpteur_660004657 = cpteur_660004657 + 1
			longueur_660004657 = i_strlen(ptr_valeurIN_660004657)
			SAUT BOUCLE_RECHERCHE
		FINSI
	FINSI
FINSI
POINT BOUCLE_FIN

#-----------------------------------#
#	Normalisation et troncature
#-----------------------------------#

# ------------1er phase de normalisation-------------------------#
#	suppression des prefixe: tel: et sip:
#   suppression si le 1er digit est +
#   suppresion des caracteres DTMF
#   suppression si les 2 premiers digits valent 00
#   suppression des suffixes ? partir du caracteres @
#   T3_callingNb,T3_DialledDigits
#   Ces traitements sont realis?s par la fonction NORMA_PRIMS
#----------------------------------------------------------------#

#----------------------------------------------------------------#
#		T3_callingNb/CallPrtAdr2Dat (Demandeur)
#----------------------------------------------------------------#
SI (i_valid_field_n(g_iartin, $Tprims::CallPrtAdr2Dat))
ALORS
	erreur_660004657 = i_get_art_str(g_iartin, $Tprims::CallPrtAdr2Dat, ptr_call_660004657)
	i_strcpy (ptr_calling_660004657,NORMA_PRIMS_660004265(ptr_call_660004657))

	trace2("=====Normalisation CallPrtAdr2Dat %s",ptr_calling_660004657,"")
FINSI

#----------------------------------------------------------------------------#
#		T3_DialledDigits/DialledDigits (Demande)
#----------------------------------------------------------------------------#
SI (i_valid_field_n(g_iartin, $Tprims::DialledDigits))
ALORS
	erreur_660004657 = i_get_art_str(g_iartin, $Tprims::DialledDigits, ptr_Dial_660004657)
	i_strcpy(ptr_Dialled_660004657, NORMA_PRIMS_660004265(ptr_Dial_660004657))
	trace2 ("=====Normalisation DialledDigits = %s", ptr_Dialled_660004657,"")
FINSI

#-------------------
# Type d'appel RoleofNode
#--------------------
Node_660004657 = i_get_art_field(g_iartin, $Tprims::roleOfNode)
SI (Node_660004657 == 0)
ALORS
	type_cra_660004657 = 0xB1
SINON
	SI (Node_660004657 == 1)
	ALORS
		type_cra_660004657= 0xB2
	FINSI
FINSI

#-----------------------------------#
# Duplication Tdpvgsm (g_iartout)
#-----------------------------------#

SI (i_dup_art_tab( g_iartin, g_iartout, C_Tdpv_660004657))
ALORS
	trace("ERREUR de duplication")
	ERREUR_660004657 = ERR_DUPL_660004657
	code_rejet_660004657 = MODULE_660004657 + ERREUR_660004657   + EFFICACE_660004657
	erreur_660004657 = i_PlvMessEmettre(6653,2,g_iartin,"",2,code_rejet_660004657,"Tdpvgsm", 0)
	SAUT DISTR_ERR
FINSI

############################################################################
# Mises au format DPV40,
############################################################################

#T3t1
#T3t1.1type
erreur_660004657 = i_set_art_field(g_iartout, $Tdpvgsm::type,type_cra_660004657)

#T3t1.3 idemet
SI (i_strcmp(ptr_AX_IDEMET_IMS_660004657,g_inull)) != 0
ALORS
	longueur_660004657= 0
	longueur_660004657=i_strlen(ptr_AX_IDEMET_IMS_660004657)
	erreur_660004657 = i_set_art_str(g_iartout10,$Conv_URS::recipAddAlp, ptr_AX_IDEMET_IMS_660004657)
	index_660004657=0
	POINT BOUCLE1
	SI (index_660004657 < longueur_660004657)
	ALORS
		SI (g_iartout10.recipAddHex[index_660004657] < 0x40)
		ALORS
			g_iartout.idemet[index_660004657]=g_iartout10.recipAddHex[index_660004657] - 0x30
		SINON
			g_iartout.idemet[index_660004657]=g_iartout10.recipAddHex[index_660004657] - 0x37
		FINSI
		index_660004657=index_660004657+1
		SAUT BOUCLE1
	FINSI
SINON
	#i_strcpy(pt_IDEMET_IMS,"33009000000FFFFFFF")
	#longueur = g_iartout.idemet!NELEM
	g_iartout.idemet[0]= 0x3
	g_iartout.idemet[1]= 0x3
	g_iartout.idemet[2]= 0x0
	g_iartout.idemet[3]= 0x0
	g_iartout.idemet[4]= 0x9
	index_660004657 = 5
	POINT BOUCLE
	SI index_660004657 < 11
	ALORS
		g_iartout.idemet[index_660004657]= 0x0
		index_660004657 = index_660004657 + 1
		SAUT BOUCLE
	FINSI
FINSI


#T3t2 idpart
#0xB1
SI (type_cra_660004657 == 0xB1)
ALORS
	#QC978
	SI (i_strplcmp (ptr_Dialled_660004657," ",0,1) != 0)
	ALORS
		longueur_660004657=i_conv_ascii_dcb(ptr_Dialled_660004657,ptr_Dialled_DCB_660004657)
		# test longueur pour memcpy
		SI (longueur_660004657 > 19)
		ALORS
			longueur_660004657 = 19
		FINSI
		erreur_660004657 = i_resize_tlv(g_iartout,"T3t2","idpart",longueur_660004657*8)
		erreur_660004657 = i_memcpy_art_field_n(g_iartout,$Tdpvgsm::idpart,ptr_Dialled_DCB_660004657,longueur_660004657)
	SINON
		longueur_660004657=i_strlen(ptr_Dialled_660004657)
		SI (longueur_660004657 > 19)
		ALORS
			longueur_660004657 = 19
		FINSI
		erreur_660004657 = i_resize_tlv(g_iartout,"T3t2","idpart",longueur_660004657*8)
		erreur_660004657 = i_memcpy_art_field_n(g_iartout,$Tdpvgsm::idpart,ptr_Dialled_660004657,longueur_660004657)
		erreur_660004657 = i_set_art_fieldtab(g_iartout, $Tdpvgsm::idpart, 0, 0x00)
	FINSI
SINON
	#0xB2
	SI (type_cra_660004657 == 0xB2)
	ALORS
		#QC978
		SI (i_strplcmp (ptr_calling_660004657," ",0,1) != 0)
		ALORS
			longueur_660004657=i_conv_ascii_dcb(ptr_calling_660004657,ptr_calling_DCB_660004657)
		# test longueur pour memcpy
		SI (longueur_660004657 > 19)
		ALORS
			longueur_660004657 = 19
		FINSI
			erreur_660004657 = i_resize_tlv(g_iartout,"T3t2","idpart",longueur_660004657*8)
			erreur_660004657 = i_memcpy_art_field_n(g_iartout,$Tdpvgsm::idpart,ptr_calling_DCB_660004657,longueur_660004657)
		SINON
			longueur_660004657=i_strlen(ptr_calling_660004657)
			SI (longueur_660004657 > 19)
			ALORS
				longueur_660004657 = 19
			FINSI
			erreur_660004657 = i_resize_tlv(g_iartout,"T3t2","idpart",longueur_660004657*8)
			erreur_660004657 = i_memcpy_art_field_n(g_iartout,$Tdpvgsm::idpart,ptr_calling_660004657,longueur_660004657)
			erreur_660004657 = i_set_art_fieldtab(g_iartout, $Tdpvgsm::idpart, 0, 0x00)
		FINSI
	FINSI
FINSI

#T3t3 local
SI (i_valid_field_n(g_iartin, $Tprims::networkInfo))
ALORS
	longueur_660004657 = i_conv_ascii_dcb(ptr_localisation_660004657,ptr_localisation_DCB_660004657)
	# test longueur pour memcpy
	SI (longueur_660004657 > 9)
	ALORS
		longueur_660004657 = 9
	FINSI
	erreur_660004657 = i_resize_tlv(g_iartout,"T3t3","local",longueur_660004657*8)
	erreur_660004657 = i_memcpy_art_field_n(g_iartout,$Tdpvgsm::local,ptr_localisation_DCB_660004657,longueur_660004657)
SINON
	erreur_660004657 = i_supprChamp(g_iartout, "T3t3")
FINSI

#T3t4 MSISDN
#0xB1
SI (type_cra_660004657 == 0xB1)
ALORS
	#QC978
	SI (i_strplcmp (ptr_calling_660004657," ",0,1) != 0)
	ALORS
		longueur_660004657=i_conv_ascii_dcb(ptr_calling_660004657,ptr_calling_DCB_660004657)
		# test longueur pour memcpy
		SI (longueur_660004657 > 19)
		ALORS
			longueur_660004657 = 19
		FINSI
		erreur_660004657 = i_resize_tlv(g_iartout,"T3t4","MSISDN",longueur_660004657*8)
		erreur_660004657 = i_memcpy_art_field_n(g_iartout,$Tdpvgsm::MSISDN,ptr_calling_DCB_660004657,longueur_660004657)
	SINON
		longueur_660004657=i_strlen(ptr_calling_660004657)
		SI (longueur_660004657 > 19)
		ALORS
			longueur_660004657 = 19
		FINSI
		erreur_660004657 = i_resize_tlv(g_iartout,"T3t4","MSISDN",longueur_660004657*8)
		erreur_660004657 = i_memcpy_art_field_n(g_iartout,$Tdpvgsm::MSISDN,ptr_calling_660004657,longueur_660004657)
		erreur_660004657 = i_set_art_fieldtab(g_iartout, $Tdpvgsm::MSISDN, 0, 0x00)
	FINSI
SINON
	#0xB2
	SI (type_cra_660004657 == 0xB2)
	ALORS
		#QC978
		SI (i_strplcmp (ptr_Dialled_660004657," ",0,1) != 0)
		ALORS
			longueur_660004657=i_conv_ascii_dcb(ptr_Dialled_660004657,ptr_Dialled_DCB_660004657)
			# test longueur pour memcpy
			SI (longueur_660004657 > 19)
			ALORS
				longueur_660004657 = 19
			FINSI
			erreur_660004657 = i_resize_tlv(g_iartout,"T3t4","MSISDN",longueur_660004657*8)
			erreur_660004657 = i_memcpy_art_field_n(g_iartout,$Tdpvgsm::MSISDN,ptr_Dialled_DCB_660004657,longueur_660004657)
		SINON
			longueur_660004657=i_strlen(ptr_Dialled_660004657)
			SI (longueur_660004657 > 19)
			ALORS
				longueur_660004657 = 19
			FINSI
			erreur_660004657 = i_resize_tlv(g_iartout,"T3t4","MSISDN",longueur_660004657*8)
			erreur_660004657 = i_memcpy_art_field_n(g_iartout,$Tdpvgsm::MSISDN,ptr_Dialled_660004657,longueur_660004657)
			erreur_660004657 = i_set_art_fieldtab(g_iartout, $Tdpvgsm::MSISDN, 0, 0x00)
		FINSI
	FINSI
FINSI

#QC801 tronquer a 15 octets et non a 8 octets
#T3t1.4  IMSI
#QC424, QC498 (suppression de "resize")
SI (i_valid_field_n(g_iartin, $Tprims::IMSI))
ALORS
	erreur_660004657 = i_get_art_str(g_iartin, $Tprims::IMSI, ptr_IMSI_660004657)
	i_get_sub_str (ptr_IMSI_660004657,0,14,ptr_IMSI_660004657)
	longueur_660004657=i_conv_ascii_dcb(ptr_IMSI_660004657,ptr_IMSI_DCB_660004657)
	erreur_660004657 = i_memcpy_art_field_n(g_iartout,$Tdpvgsm::IMSI,ptr_IMSI_DCB_660004657,longueur_660004657)
SINON
	long_MSISDN_660004657 = i_get_art_field(g_iartout, $Tdpvgsm::MSISDN - 1)
	ele0_660004657=i_get_art_fieldtab(g_iartout, $Tdpvgsm::MSISDN,0)
	ele1_660004657=i_get_art_fieldtab(g_iartout, $Tdpvgsm::MSISDN,1)
	ele2_660004657=i_get_art_fieldtab(g_iartout, $Tdpvgsm::MSISDN,2)
	SI (long_MSISDN_660004657 == 6 && ele0_660004657 ==3 && ele1_660004657 ==3 && (ele2_660004657 != 6 && ele2_660004657 != 7))
	ALORS
		erreur_660004657=affectation_tab_660004265(g_iartout,$Tdpvgsm::IMSI,"777777777777777F")
	SINON
		erreur_660004657=affectation_tab_660004265(g_iartout,$Tdpvgsm::IMSI,"999999999999999F")
	FINSI
FINSI

#T3t1.5 DATE
#QC Sdate Platine
Start_Date_660004657=i_get_art_field(g_iartin,$Tprims::StartTime_SDATE)
Date_Debut_660004657 = i_DHgetLocalTime(NUMTAB_660004657, 7, Start_Date_660004657)
SI ( Date_Debut_660004657 == 0)
ALORS
	trace ("erreur conversion date StartTime_SDATE")
	ERREUR_660004657 = ERR_CONV_660004657
	code_rejet_660004657 = MODULE_660004657 + ERREUR_660004657   + EFFICACE_660004657
	erreur_660004657 = i_PlvMessEmettre(6654,2,g_iartin,"",2,code_rejet_660004657,"callStartTime", 0)
	SAUT DISTR_ERR
SINON
	erreur_660004657=i_set_art_field(g_iartout,$Tdpvgsm::DATE,Date_Debut_660004657)
FINSI

#T3t1.6 DUREE
SI (i_valid_field_n(g_iartin, $Tprims::callDuration))
ALORS
	Duree_660004657=i_get_art_field(g_iartin,$Tprims::callDuration)
	erreur_660004657=i_set_art_field(g_iartout,$Tdpvgsm::DUREE,Duree_660004657)
SINON
	erreur_660004657=i_set_art_field(g_iartout,$Tdpvgsm::DUREE,0)
FINSI

#T3t1.13 indeff
SI(i_valid_field_n(g_iartin,$Tprims::callStatus))
ALORS
	status_660004657 = i_get_art_field(g_iartin, $Tprims::callStatus)
	erreur_660004657=i_set_art_field(g_iartout,$Tdpvgsm::indeff,status_660004657)
FINSI

#T3t1.14 tterm
SI (i_valid_field_n(g_iartin, $Tprims::sessionTerm))
ALORS
	erreur_660004657=i_set_art_field(g_iartout,$Tdpvgsm::tterm,TransSessTerm_660004657)
FINSI

#T3t7 estalloc
# QC Sdate Platine
SI (i_valid_field_n(g_iartin, $Tprims::srvRequesTime))
ALORS
	erreur_660004657 = i_ajoutChamp(g_iartout, "T3t7", "estalloc", 0x01)
	Request_Time_660004657=i_get_art_field(g_iartin,$Tprims::srvRequesTime) + 86400
	Request_660004657 = i_DHgetLocalTime(NUMTAB_660004657, 7, Request_Time_660004657)
	erreur_660004657=i_set_art_field(g_iartout,$Tdpvgsm::estalloc,Request_660004657)
FINSI


#T3t23 Mailldpart
SI (i_valid_field_n(g_iartin, $Tprims::DialledDigits) && type_cra_660004657 == 0xB1)
ALORS
	longueur_660004657 = i_strlen(ptr_Dial_660004657)
	erreur_660004657 = i_resize_tlv(g_iartout,"T3t23","MailIdpart",longueur_660004657)
	erreur_660004657 = i_set_art_str(g_iartout, $Tdpvgsm::MailIdpart, ptr_Dial_660004657)
SINON
	SI (i_valid_field_n(g_iartin, $Tprims::CallPrtAdr2Dat)	&& 	type_cra_660004657 == 0xB2)
	ALORS
		longueur_660004657 = i_strlen(ptr_call_660004657)
		erreur_660004657 = i_resize_tlv(g_iartout,"T3t23","MailIdpart",longueur_660004657)
		erreur_660004657 = i_set_art_str(g_iartout, $Tdpvgsm::MailIdpart, ptr_call_660004657)
	FINSI
FINSI

#T2t24 MailMsOrEntity
SI (i_valid_field_n(g_iartin, $Tprims::CallPrtAdr2Dat) && type_cra_660004657 == 0xB1)
ALORS
	longueur_660004657 = i_strlen(ptr_call_660004657)
	erreur_660004657 = i_resize_tlv(g_iartout,"T3t24","MailMsOrEntity",longueur_660004657)
	erreur_660004657 = i_set_art_str(g_iartout, $Tdpvgsm::MailMsOrEntity, ptr_call_660004657)
SINON
	SI (i_valid_field_n(g_iartin, $Tprims::DialledDigits)	&& 	type_cra_660004657 == 0xB2)
	ALORS
		longueur_660004657 = i_strlen(ptr_Dial_660004657)
		erreur_660004657 = i_resize_tlv(g_iartout,"T3t24","MailMsOrEntity",longueur_660004657)
		erreur_660004657 = i_set_art_str(g_iartout, $Tdpvgsm::MailMsOrEntity, ptr_Dial_660004657)
	FINSI
FINSI

#T3t30
#T4t30.1
date_audit_gmt_660004657 = i_date_audit()
date_audit_660004657 = i_DHgetLocalTime(NUMTAB_660004657, 7, date_audit_gmt_660004657)
erreur_660004657 = i_set_art_field(g_iartout, $Tdpvgsm::timeInCE,date_audit_660004657)

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

#QC808 deconstruire le mapping du T3t33 MSISDN non transmis en entree
#T3t33 SMSrecepMSISDN
#T3t43 (V4t43.3) dupl

#V4T66.1.1 RecSeqNumber
SI (i_valid_field_n(g_iartin, $Tprims::recordSeqNb))
ALORS
	val_recordSeqNb_660004657 = i_get_art_field(g_iartin, $Tprims::recordSeqNb)
	erreur_660004657=i_set_art_field(g_iartout,$Tdpvgsm::RecSeqNumber,val_recordSeqNb_660004657)
FINSI

#V4T66.1.2 SigVolum
SI (i_valid_field_n(g_iartin, $Tprims::SigVolum))
ALORS
	val_SigVolum_660004657 = i_get_art_field(g_iartin, $Tprims::SigVolum)
	erreur_660004657=i_set_art_field(g_iartout,$Tdpvgsm::SigVolum,val_SigVolum_660004657)
FINSI

#V4T66.1.3 	ExtBearVolum
SI (i_valid_field_n(g_iartin, $Tprims::ExtBearVolum))
ALORS
	val_ExtBearVolum_660004657 = i_get_art_field(g_iartin, $Tprims::ExtBearVolum)
	erreur_660004657=i_set_art_field(g_iartout,$Tdpvgsm::ExtBearVolum,val_ExtBearVolum_660004657)
FINSI

#V4T66.1.4 TotalVolum
SI (i_valid_field_n(g_iartin, $Tprims::TotalVolum))
ALORS
	val_TotalVolum_660004657 = i_get_art_field(g_iartin, $Tprims::TotalVolum)
	erreur_660004657=i_set_art_field(g_iartout,$Tdpvgsm::TotalVolum,val_TotalVolum_660004657)
FINSI

#V4T66.1.5 CallEndTStamp
#QC Sdate Platine
SI (i_valid_field_n(g_iartin, $Tprims::callEndTime))
ALORS
	End_Time_660004657=i_get_art_field(g_iartin,$Tprims::callEndTime) + 86400
	Date_Fin_660004657 = i_DHgetLocalTime(NUMTAB_660004657, 7, End_Time_660004657)
	erreur_660004657=i_set_art_field(g_iartout,$Tdpvgsm::CallEndTStamp,Date_Fin_660004657)
FINSI

#V4t66.1.6 CauseRecClose
SI (i_valid_field_n(g_iartin, $Tprims::CausForRecClos))
ALORS
	val_CauseClose_660004657 = i_get_art_field(g_iartin, $Tprims::CausForRecClos)
	erreur_660004657=i_set_art_field(g_iartout,$Tdpvgsm::CauseRecClose, val_CauseClose_660004657)
FINSI

#V4T66.1.7 SessionTerm
SI (i_valid_field_n(g_iartin, $Tprims::sessionTerm))
ALORS
	val_sessionTerm_660004657 = i_get_art_field(g_iartin, $Tprims::sessionTerm)
	erreur_660004657 = i_set_art_field(g_iartout,$Tdpvgsm::SessionTerm,val_sessionTerm_660004657)
FINSI
#V4T66.7.8--------A REVOIR------------

#V4T66.1.8 CORLStatus
SI (i_valid_field_n(g_iartin, $Tprims::ComputedInf07))
ALORS
	erreur_660004657 = i_get_art_str(g_iartin, $Tprims::ComputedInf07, ptr_ComputedInf07_660004657)
	CORLStatus_660004657 = CONV_ASCIINUMDEC_INT_660004265(ptr_ComputedInf07_660004657)
	SI  (CORLStatus_660004657 == -1)
	ALORS
		trace ( "[Tprims DISTR]  -- ERREUR conversion champ CORLStatus---")
	SINON
		erreur_660004657=i_set_art_field(g_iartout,$Tdpvgsm::CORLStatus,CORLStatus_660004657)
	FINSI
FINSI

#V4T66.2 SgsnAddr
SI (i_valid_field_n(g_iartin, $Tprims::SgsnAddr))
ALORS
	longueur_660004657= 0
	erreur_660004657 = i_get_art_str(g_iartin, $Tprims::SgsnAddr, ptr_SgsnAddr_660004657)
	i_get_sub_str (ptr_SgsnAddr_660004657,0,15,ptr_SgsnAddr_660004657)
	longueur_660004657=i_strlen(ptr_SgsnAddr_660004657)
	erreur_660004657 = i_set_art_str(g_iartout10,$Conv_URS::AddrAsc, ptr_SgsnAddr_660004657)
	index_660004657=0
	index2_660004657 = 0
	erreur_660004657 = i_resize_tlv(g_iartout,"T4t66.2","SgsnAddr",16)
	POINT BOUCLE2
	SI (index_660004657 < longueur_660004657)
	ALORS
		SI (g_iartout10.AddrHex[index_660004657] < 0x40)
		ALORS
			dizaine_660004657 = g_iartout10.AddrHex[index_660004657] - 0x30
			unite_660004657 = g_iartout10.AddrHex[index_660004657 + 1] - 0x30
			resultat_660004657 = (dizaine_660004657*0x10) + unite_660004657
			g_iartout.SgsnAddr[index2_660004657]=resultat_660004657
		FINSI
		index2_660004657=index2_660004657 + 1
		index_660004657 = index_660004657 + 2
		SAUT BOUCLE2
	FINSI
SINON
	erreur_660004657 = i_supprChamp(g_iartout, "T4t66.2")
FINSI

#V4T66.3 GGSNAddr
SI (i_valid_field_n(g_iartin, $Tprims::ggsnAddr))
ALORS
	longueur_660004657= 0
	erreur_660004657 = i_get_art_str(g_iartin, $Tprims::ggsnAddr, ptr_ggsnAddr_660004657)
	i_get_sub_str (ptr_ggsnAddr_660004657,0,15,ptr_ggsnAddr_660004657)
	longueur_660004657=i_strlen(ptr_ggsnAddr_660004657)
	erreur_660004657 = i_set_art_str(g_iartout10,$Conv_URS::AddrAsc, ptr_ggsnAddr_660004657)
	index_660004657=0
	index2_660004657=0
	erreur_660004657 = i_resize_tlv(g_iartout,"T4t66.3","GGSNAddr",16)
	POINT BOUCLE3
	SI (index_660004657 < longueur_660004657)
	ALORS
		SI (g_iartout10.AddrHex[index_660004657] < 0x40)
		ALORS
			dizaine_660004657 = g_iartout10.AddrHex[index_660004657] - 0x30
			unite_660004657 = g_iartout10.AddrHex[index_660004657 + 1] - 0x30
			resultat_660004657 = (dizaine_660004657*0x10) + unite_660004657
			g_iartout.GGSNAddr[index2_660004657]=resultat_660004657
		FINSI
		index2_660004657 = index2_660004657 + 1
		index_660004657 = index_660004657 + 2
		SAUT BOUCLE3
	FINSI
SINON
	erreur_660004657 = i_supprChamp(g_iartout, "T4t66.3")
FINSI

#V4t66.4 a V4t66.13 (dupl)
#V4t66.4 SubRecordType
SI (i_valid_field_n(g_iartin, $Tprims::SubRecordType))
ALORS
	erreur_660004657 = i_get_art_str(g_iartin, $Tprims::SubRecordType,ptr_SubRecordType_660004657)
	erreur_660004657 = i_set_art_str(g_iartout,$Tdpvgsm::SubRecordType,ptr_SubRecordType_660004657)
FINSI

#V4t66.5 TransCalledNum
#V4t66.6 OriginatingIOI
#V4t66.7 TerminatingIOI
#V4t66.8 AccessNetInfo
#V4t66.9 SessionId
#V4t66.10 NodeIdentifier
#V4t66.11 AppliServerId
#V4t66.12 SIPMethod
#V4t66.13 PrivateUserId

#QC795 Suppression de la structure T4t66.1 si aucune valeur l'alimente
SI (
	(i_valid_field_n(g_iartin, $Tprims::recordSeqNb))
	+ (i_valid_field_n(g_iartin, $Tprims::SigVolum))
	+ (i_valid_field_n(g_iartin, $Tprims::ExtBearVolum))
	+ (i_valid_field_n(g_iartin, $Tprims::TotalVolum))
	+ (i_valid_field_n(g_iartin, $Tprims::callEndTime))
	+ (i_valid_field_n(g_iartin, $Tprims::CausForRecClos))
	+ (i_valid_field_n(g_iartin, $Tprims::sessionTerm))
	+ (i_valid_field_n(g_iartin, $Tprims::ComputedInf07))
	) == 0
ALORS
	erreur_660004657 = i_supprChamp(g_iartout, "T4t66.1")
FINSI

#QC795 Suppression du T3t66

SI (i_get_art_field(g_iartout, $Tdpvgsm::L3t66) == 0)
ALORS
	erreur_660004657 = i_supprChamp(g_iartout, "T3t66")
FINSI

#Fin QC795

##V4t68.2 a V4t68.13 (dupl)
##V4t68.1.1 TMediaChange
##V4T69.1.1 	TMediaChange2
##V4t69.1.2
##V4t69.2 et .3
##V4T70.1.1 	TMediaChange3
##V4t70.1.2
##V4t70.2 et .3
##V4t71
##V4T71.1.1 	TMediaChange4
##V4T72.1.1 	TMediaChange5

#-------------------------------
# Appel fonction aiguillage
#-------------------------------
erreur_660004657 = aiguillage2_660004590 (g_iartin, g_iartout, DISTRIBUTION_SPECIALE_660004657, Multidistribution_Non_660004657)
SI (erreur_660004657 == TRAI_KO_660004657)
ALORS
# QC1005
	trace("<<<__LINE__<<<__FILE__<<< Erreur retour fonction aiguillage2")
#	erreur = ERR_DISTR
#	code_rejet = erreur + EFFICACE
#	type_cra=i_get_art_field(g_iartout,$Tdpvgsm::type)
##QC795 Correction alarme 7500 args nb de parametres 1 -> 3
#	erreur=i_PlvMessEmettre(7500, 2, g_iartin, "", 3, code_rejet,"Tprims",type_cra)
	SAUT DISTR_ERR
FINSI
RETOUR TRAIT_OK

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

POINT DISTR_ERR

trace( "Stockage en errone de distribution")
res_660004657 = i_make_art_rej(g_iartin, g_iartout8, 0)
res_660004657 = i_stocke_art( g_iartout8, 0, PT_ERRONE, 0)

RETOUR TRAIT_OK
#--------------------------------- fin Tprims_dist.src ---------------------------
