DEFINITION C_Tdpv_660004637 "Tdpvgsm"
DEFINITION C_Article_660004637 "Tsgwcdr"
DEFINITION Multidistribution_Non_660004637 0
DEFINITION TRAI_KO_660004637 -1
DEFINITION DISTRIBUTION_SPECIALE_660004637 0
DEFINITION DISTRIBUTION_INCONNU_660004637 1
DEFINITION MODULE_DISTR_660004637 0xA000
DEFINITION ERR_NORM_660004637 0x010
DEFINITION ERR_VALO_660004637 0x020
DEFINITION ERR_DUPL_660004637 0x0D0
DEFINITION ERR_DISTR_660004637 0x110
DEFINITION ERR_TAB_660004637 0x0A0
DEFINITION EFFICACE_660004637 1
DEFINITION NUMTAB_660004637 4
REGISTRE ENTIER erreur_660004637
REGISTRE ENTIER code_rejet_660004637
REGISTRE ENTIER ERREUR_660004637
REGISTRE ENTIER res_660004637
REGISTRE ENTIER v_cause_660004637
REGISTRE ENTIER flag_rdt_660004637
REGISTRE ENTIER date_cra_660004637
REGISTRE ENTIER date_fin_660004637
REGISTRE ENTIER date_audit_660004637
REGISTRE ENTIER b_VOLUME_NUL_660004637
REGISTRE ENTIER b_ACTIV_VOL_NUL_660004637
REGISTRE ENTIER b_RoamingIn_660004637
REGISTRE ENTIER flag_KeyTADIC_660004637
REGISTRE ENTIER b_T3t71_660004637
REGISTRE ENTIER b_ratType_660004637          
REGISTRE POINTEUR pt_AX_IDEMET_660004637
REGISTRE POINTEUR pt_1_660004637
REGISTRE POINTEUR pt_2_660004637
REGISTRE POINTEUR pt_IdPLMN_660004637
REGISTRE POINTEUR pt_cleIdPLMN_660004637
REGISTRE POINTEUR pt_InfoLocal_660004637
REGISTRE POINTEUR pt_TADIG_660004637
REGISTRE POINTEUR pt_MCCMNC_660004637
REGISTRE POINTEUR pt_MCCMNC_DCB_660004637
REGISTRE POINTEUR pt_servedIMSI_660004637
REGISTRE POINTEUR pt_CleServedIMSI_660004637

####################################################################
#				cas d'article Tsgwcdr
####################################################################
#       article CRA SGWCDR ASN1 => type DPV TLV = 00
#
# 11/06/2012	Creation
# 03/08/2012 PKH QC1079  Correction Valorisation du Dpvgsm V3t1.10(systype) quand V3t19(ratType) present sinon 0x01
# 03/08/2012 PKH QC1079  Correction Valorisation du Dpvgsm V3t1.3(idemet) valeur par defaut 0x33601000000FFFFFFF
# 06/08/2012 PKH QC1079 Correction utiliser le champ T3t3/servedIMSI et non le champ IdPLMN pour interroger table ext MCCMNC_TADIG
# 10/08/2012 PKH QC1079 Correction oublie Valorisation du Dpvgsm V3t1.3(idemet) valeur par defaut 0x33601000000FFFFFFF
# 20/08/2012 JLG QC1079 V3t1.3(idemet) valeur par defaut 33601000000FFFFFFF
# 22/08/2012 JLG verif des pointeurs
# 22/08/2012 JLG controle longueur pour champ Tdpvgsm : PrefixIMSIclt afin d'eviter l'alarme 1444
# 05/09/2012 RHE QC1095 champ V3t1.10 : si T3t19/ratType = 0x02, restituer la valeur par defaut : 0x01
# 07/09/2012 RHE QC1093 Suppression de l'appel de l'automate ASR5K2, mappage de T3t15/servedMSISDN dans V3t4
# 11/09/2012 RHE QC1095 champ V3t1.10 : si T3t19/ratType = 0x02, restituer la valeur : 0x00
# 31/10/2012 PKH QC1107 champ systype T3t1.10 a valorise a 6 lorsque le champ ratType est absent
# 02/07/2014 - JLG -G5R1 QC1405, champ eec du DPV si g_ieec > 500
####################################################################





pt_AX_IDEMET_660004637 = "pt_AX_IDEMET11111111"
pt_1_660004637 = "pt_1_11111111111111111111111"
pt_2_660004637 = "pt_2_22222222222222222222222"
#pt_3 = "pt_3_33333333333333333333333"
#pt_Date_Tac = "pt_Date_Tac_918273645463728191"
pt_IdPLMN_660004637= "pt_IdPLMN999999999"
pt_cleIdPLMN_660004637= "pt_cleIdPLMN999999"
pt_InfoLocal_660004637= "pt_InfoLocal999999"
#pt_APN= "pt_APN444444444"
pt_TADIG_660004637 = "pt_TADIG3333333333"
pt_MCCMNC_660004637 = "pt_MCCMNC111111111"
pt_MCCMNC_DCB_660004637 = "pt_MCCMNC_DCB12345"
pt_servedIMSI_660004637 = "pt_servedIMSI9999999999999999"
pt_CleServedIMSI_660004637 = "pt_CleServedIMSI7575757575"




trace("Tsgwcdr : Debut DISTRIBUTION")


date_cra_660004637 = i_get_art_field(g_iartin, $Tsgwcdr::ddebut)
date_fin_660004637 = i_get_art_field(g_iartin, $Tsgwcdr::dfin)
date_audit_660004637 = i_DHgetLocalTime(NUMTAB_660004637, 7, i_date_audit())


# ==================================
# copie du CRA original dans le g_iartout12
erreur_660004637 = i_dup_art_id(g_iartin, g_iartout12)

# Initialisations
ERREUR_660004637 = 0
code_rejet_660004637 = 0
b_ratType_660004637 = 0

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

SI (flag_rdt_660004637 == 0)
ALORS
	erreur_660004637 = i_add_opt( "E_Redistri2" )
FINSI
erreur_660004637 = i_set_attr_val_n( $E_Redistri2::EnvoiRedis, 0)

########################################################
# Cpt applicatif CPT_RDT=1509 (REDISTRIBUTION)
########################################################
# comptabilisation des CRAs issus de la redistribution
erreur_660004637= i_incr_redist_dist_660004265(date_fin_660004637)

############################################################################
# Variables fonctionnelles
############################################################################

########### Creation article conversion Conv_URS (g_iartout9)
erreur_660004637 = i_cree_art("Conv_URS",g_iartout9)

# b_VOLUME_NUL
b_VOLUME_NUL_660004637 = 1
SI (i_valid_field_n( g_iartin, $Tsgwcdr::DataVolUp))
ALORS
	SI (i_get_art_field(g_iartin,$Tsgwcdr::DataVolUp) > 0)
	ALORS
		b_VOLUME_NUL_660004637 = 0
	FINSI
FINSI
SI b_VOLUME_NUL_660004637
ALORS
	SI (i_valid_field_n( g_iartin, $Tsgwcdr::DataVolDown))
	ALORS
		SI i_get_art_field(g_iartin,$Tsgwcdr::DataVolDown) > 0
		ALORS
			b_VOLUME_NUL_660004637 = 0
		FINSI
	FINSI
FINSI

# b_ACTIV_VOL_NUL
b_ACTIV_VOL_NUL_660004637 = 0
SI ( i_get_tab_field("VariableContexte",date_cra_660004637,"FILT_GPRS_NUL") != g_inull )
ALORS
	b_ACTIV_VOL_NUL_660004637 = 1
FINSI

# AX_IDEMET
i_strcpy(pt_AX_IDEMET_660004637, "")
i_strcpy(pt_1_660004637, "")
erreur_660004637 = i_format_str2( pt_1_660004637, "%s%s", "AX_IDEMET_", i_LireEECSGTQS(g_ieec))
i_strcpy(pt_AX_IDEMET_660004637, i_get_tab_field("VariableContexte", date_cra_660004637, pt_1_660004637))

# Duree
#Duree = i_get_art_field(g_iartin, $Tsgwcdr::dduree)


# Date_Tac (conversion avec T2_date (DATE, DATEN) de l'article Conv_URS)
#i_strcpy(pt_Date_Tac, i_get_tab_field("VariableContexte", date_cra, "DATE_TAC"))
#i_get_sub_str(pt_Date_Tac,2,-1,pt_1)
#erreur = i_set_art_str (g_iartout9,$Conv_URS::DATE,pt_1)
#Date_Tac = i_get_art_field(g_iartout9, $Conv_URS::DATEN)


# InfoLocal (pt_InfoLocal) plus de parametre TAC
# Tsgwcdr::UserLoc
#  1   2   3   4   5    6     7     8     9     10    11    12    13
#  0   1   2   3   4    5     6     7     8     9     10    11    12
# 0-1 2-3 4-5 6-7 8-9 10-11 12-13 14-15 16-17 18-19 20-21 22-23 24-25
i_strcpy(pt_InfoLocal_660004637, "")
SI (i_valid_field_n( g_iartin, $Tsgwcdr::UserLoc))
ALORS
	i_strcpy(pt_1_660004637, "")
	erreur_660004637 = i_get_art_str (g_iartin, $Tsgwcdr::UserLoc, pt_1_660004637)
	# Si (   L4t10.3 = 0x0D (13 octets)  et 1er octet de V4t10.3/UserLoc vaut 0x18 (TAI+ECGI) )
	# pt_1 en ascii donc lg x 2, 26 au lieu de 13
	SI (i_strlen(pt_1_660004637) == 26 && i_strplcmp ( pt_1_660004637, "18", 0, 2) == 0)
	ALORS
		# prendre 2eme digit du 10eme octet jusqu'a la fin de V4t10.3/UserLoc (ECI de ECGI)
		#19 20-21 22-23 24-25
		i_get_sub_str(pt_1_660004637, 19, 25, pt_InfoLocal_660004637)
	SINON
		# pt_1 en ascii donc lg x 2, 16 au lieu de 8 (CGI, SAI ou RAI)
		SI (i_strlen(pt_1_660004637) == 16)
		ALORS
			# octet 5 a 8 donc 8 a 15
			i_get_sub_str(pt_1_660004637, 8, 15, pt_InfoLocal_660004637)
		FINSI
	FINSI
SINON
	SI (i_valid_field_n( g_iartin, $Tsgwcdr::userLocationInf))
	ALORS
		i_strcpy(pt_1_660004637, "")
		erreur_660004637 = i_get_art_str (g_iartin, $Tsgwcdr::userLocationInf, pt_1_660004637)
		# pt_1 en ascii donc lg x 2, 26 au lieu de 13
		SI (i_strlen(pt_1_660004637) == 26 && i_strplcmp ( pt_1_660004637, "18", 0, 2) == 0)
		ALORS
			i_get_sub_str(pt_1_660004637, 19, 25, pt_InfoLocal_660004637)
		SINON
			# pt_1 en ascii donc lg x 2, 16 au lieu de 8 (CGI, SAI ou RAI)
			SI (i_strlen(pt_1_660004637) == 16)
			ALORS
				i_get_sub_str(pt_1_660004637, 8, 15, pt_InfoLocal_660004637)
			FINSI
		FINSI
	FINSI
FINSI


# b_RoamingIn
b_RoamingIn_660004637 = 0
SI (i_valid_field_n( g_iartin, $Tsgwcdr::servedIMSI))
ALORS
	i_strcpy(pt_1_660004637,"")
	erreur_660004637 = i_get_art_str (g_iartin, $Tsgwcdr::servedIMSI, pt_1_660004637)
	#Si (   T3t3/servedIMSI renseigne  et <> 208* )
	SI  (i_strplcmp( pt_1_660004637, "208", 0, 3) !=0)
	ALORS
		b_RoamingIn_660004637 = 1
	FINSI
FINSI


# IdPLMN
# Ex de valeurs : 123576->123765 268F03->26803 348057->348570 208576->208765, 20801F->20801
i_strcpy(pt_IdPLMN_660004637, "FF")
SI (i_valid_field_n( g_iartin, $Tsgwcdr::pLMNId))
ALORS
	erreur_660004637 = i_get_art_str (g_iartin,$Tsgwcdr::pLMNId,pt_IdPLMN_660004637)
	# on enleve le dernier digit si = F
	SI (i_strlen(pt_IdPLMN_660004637)==6)
	ALORS
		SI (i_strplcmp (pt_IdPLMN_660004637, "F", 5, 1) == 0)
		ALORS
			i_get_sub_str(pt_IdPLMN_660004637, 0, 4, pt_IdPLMN_660004637)
		FINSI
	FINSI
	# Test format MAP
	i_get_sub_str(pt_IdPLMN_660004637, 0, 2, pt_1_660004637)
	i_get_sub_str(pt_IdPLMN_660004637, 4, 5, pt_2_660004637)
	# si 4 eme octet = F
	erreur_660004637 = i_format_str2(pt_cleIdPLMN_660004637, "%s%s", pt_1_660004637, pt_2_660004637)
	SI  (i_strplcmp ( pt_IdPLMN_660004637, "F", 3, 1) != 0)
	ALORS
		i_strcpy(pt_1_660004637, pt_cleIdPLMN_660004637)
		i_get_sub_str(pt_IdPLMN_660004637, 3, 3, pt_2_660004637)
		# si 4 eme octet != F
		erreur_660004637 = i_format_str2(pt_cleIdPLMN_660004637, "%s%s", pt_1_660004637, pt_2_660004637)
	FINSI
	i_strcpy(pt_IdPLMN_660004637, pt_cleIdPLMN_660004637)
FINSI

# TADIG, MCCMNC
#QC1079 Debut
i_strcpy(pt_servedIMSI_660004637, "")
i_strcpy(pt_CleServedIMSI_660004637,"")
i_strcpy(pt_MCCMNC_660004637, "")
i_strcpy(pt_TADIG_660004637, "")

flag_KeyTADIC_660004637 = 0
SI b_RoamingIn_660004637
ALORS
	erreur_660004637 = i_get_art_str (g_iartin,$Tsgwcdr::servedIMSI,pt_servedIMSI_660004637) 
	i_get_sub_str(pt_servedIMSI_660004637, 0, 5, pt_CleServedIMSI_660004637)
	trace2("<<__LINE__>>-------------pt_CleServedIMSI=%s------------------",pt_CleServedIMSI_660004637,"")
	i_strcpy(pt_MCCMNC_660004637,i_get_tab_field("MCCMNC_TADIG", date_cra_660004637, pt_CleServedIMSI_660004637))
	SI (i_strcmp( pt_MCCMNC_660004637, g_inull) == 0)
	ALORS	
		i_get_sub_str(pt_servedIMSI_660004637, 0, 4, pt_CleServedIMSI_660004637)
		i_strcpy(pt_MCCMNC_660004637,i_get_tab_field("MCCMNC_TADIG", date_cra_660004637, pt_CleServedIMSI_660004637))
		SI (i_strcmp( pt_MCCMNC_660004637, g_inull) == 0) 
		ALORS
			trace ("<<__LINE__>> ----------- cle non trouve dans MCCMNC_TADIG ---------------")
			SAUT FIN_TADIGMCCMNC
		FINSI
	FINSI
	flag_KeyTADIC_660004637 = 1
    erreur_660004637 = i_recupererValeur(pt_MCCMNC_660004637,pt_TADIG_660004637,5,'-')   
    SI (i_strcmp(pt_MCCMNC_660004637,g_inull) == 0)
    ALORS
         i_strcpy(pt_MCCMNC_660004637,pt_CleServedIMSI_660004637)
    FINSI  

#	# pt_MCCMNC contiendra la valeur de retour TADIG_MCCMNC
#	# 1ere interrogation
#	i_strcpy(pt_MCCMNC,i_get_tab_field("MCCMNC_TADIG", date_cra, pt_cleIdPLMN))
#	SI (i_strcmp( pt_MCCMNC, g_inull)  != 0)
#	ALORS
#		flag_KeyTADIC = 1
#		erreur = i_recupererValeur(pt_MCCMNC,pt_TADIG,5,'-')
#		SI (i_strcmp (pt_MCCMNC,g_inull) == 0)
#		ALORS
#			# si retour MCCMNC null (fictive) alors = cle (pt_cleIdPLMN)
#			i_strcpy(pt_MCCMNC, pt_cleIdPLMN)
#		FINSI
#		SAUT FIN_TADIGMCCMNC
#	SINON
#		SI (i_strlen(pt_cleIdPLMN)==6)
#		ALORS
#			# 2eme interrogation si echec de la 1ere avec taille clef = 6
#			i_get_sub_str(pt_cleIdPLMN, 0, 4, pt_1)
#			# 2eme interrogation avec clef reduite a 5 digits
#			i_strcpy(pt_MCCMNC,i_get_tab_field("MCCMNC_TADIG", date_cra, pt_1))
#			SI (i_strcmp( pt_MCCMNC, g_inull)  != 0)
#			ALORS
#				flag_KeyTADIC = 1
#				erreur = i_recupererValeur(pt_MCCMNC,pt_TADIG,5,'-')
#				SI (i_strcmp (pt_MCCMNC,g_inull) == 0)
#				ALORS
#					# si retour MCCMNC null (fictive) alors = cle (pt_cleIdPLMN)
#					i_strcpy(pt_MCCMNC, pt_cleIdPLMN)
#				FINSI
#				SAUT FIN_TADIGMCCMNC
#			FINSI
#		FINSI
#	FINSI
#	i_strcpy(pt_MCCMNC, pt_cleIdPLMN)
FINSI
POINT FIN_TADIGMCCMNC
trace2("<<__LINE__>> ---------------pt_MCCMNC = %s-------------",pt_MCCMNC_660004637,"") 
trace2("<<__LINE__>> ---------------pt_TADIG = %s-------------",pt_TADIG_660004637,"")
trace1("<<__LINE__>>---------------flag_KeyTADIC=%d---------------------------",flag_KeyTADIC_660004637)
#Fin QC1079
############################################################################
# Duplication Tdpvgsm (g_iartout = dpv pivot)
############################################################################
#Duplication article d entree vers DPV TLV

SI (i_dup_art_tab( g_iartin, g_iartout, C_Tdpv_660004637))
ALORS
	trace("Tsgwcdr, ERREUR de duplication tab")
	ERREUR_660004637 = ERR_DUPL_660004637
	code_rejet_660004637 = MODULE_DISTR_660004637 + ERREUR_660004637 + EFFICACE_660004637
	erreur_660004637 = i_PlvMessEmettre(7502, 2, g_iartin, "", 2, code_rejet_660004637, C_Article_660004637, 0)
	SAUT STOCKE_ERRONE
FINSI

############################################################################
# Mises au format DPV33, FO 1582
############################################################################

############################################################################
# Mises au format DPV33, FO 1582
############################################################################


#T3t1
#V3t1.1 type		:-	:-	:MSET :90:1

#V3t1.2 tentite		:-	:-	:MSET :18:1

#V3t1.3 idemet		:-	:-	:MSET :FF

#QC1079 point 1 corrigee
SI (i_strcmp(pt_AX_IDEMET_660004637,"") != 0)
ALORS
	erreur_660004637 = affectation_tab_660004265(g_iartout,$Tdpvgsm::idemet,pt_AX_IDEMET_660004637)
SINON
	erreur_660004637 = affectation_tab_660004265(g_iartout,$Tdpvgsm::idemet,"33601000000FFFFFFF")
FINSI


#V3t1.4 IMSI		:-	:-	:1VAL :servedIMSI

#V3t1.5 DATE		:-	:-	:1VAL :recOpenTime

#V3t1.6 DUREE		:-	:-	:1VAL :dduree

#V3t1.7 svcsup		:D	:-	:MSET :C0

#V3t1.8 tlserv		:-	:-	:MSET :FF:1

#V3t1.9 support1	:-	:-	:MSET :FF:1

#V3t1.10 systype		:-	:-	:MSET :00:1

#QC1079
SI (i_valid_field_n( g_iartin, $Tsgwcdr::ratType))
ALORS
	b_ratType_660004637 = i_get_art_field(g_iartin, $Tsgwcdr::ratType)
	#QC1095
	SI ( b_ratType_660004637 == 2)
	ALORS
		b_ratType_660004637 = 0
	FINSI
	erreur_660004637 = i_set_art_field(g_iartout,$Tdpvgsm::systype, b_ratType_660004637)
SINON
	#QC1107
	#erreur = i_set_art_field(g_iartout,$Tdpvgsm::systype, 1)
	erreur_660004637 = i_set_art_field(g_iartout,$Tdpvgsm::systype, 6)

FINSI


#V3t1.11 reserve2	:-	:-	:MSET :FF:1

#V3t1.12 origine		:-	:-	:MSET :FF:1
SI (i_strplcmp(pt_IdPLMN_660004637, "208", 0, 3) != 0 && i_strplcmp(pt_IdPLMN_660004637, "FF", 0, 2) != 0)
ALORS
	erreur_660004637 = i_set_art_field(g_iartout,$Tdpvgsm::origine, 1)
SINON
	SI (i_strplcmp(pt_IdPLMN_660004637, "208", 0, 3) == 0)
	ALORS
		erreur_660004637 = i_set_art_field(g_iartout,$Tdpvgsm::origine, 0)
	FINSI
FINSI


#V3t1.13 indeff		:-	:-	:MSET :00:1

#V3t1.14 tterm		:-	:-	:MSET :FF:1
res_660004637=-1
v_cause_660004637 = i_get_art_field(g_iartin, $Tsgwcdr::cause)
SI v_cause_660004637 == 0
ALORS
	erreur_660004637 = i_set_art_field(g_iartout,$Tdpvgsm::tterm, 0x00)
SINON
	SI v_cause_660004637 == 4
	ALORS
		erreur_660004637 = i_set_art_field(g_iartout,$Tdpvgsm::tterm, 0x10)
	SINON
		SI v_cause_660004637 == 16
		ALORS
			erreur_660004637 = i_set_art_field(g_iartout,$Tdpvgsm::tterm, 0x0B)
		SINON
			SI v_cause_660004637 == 17
			ALORS
				erreur_660004637 = i_set_art_field(g_iartout,$Tdpvgsm::tterm, 0x0C)
			SINON
				SI v_cause_660004637 == 18
				ALORS
					erreur_660004637 = i_set_art_field(g_iartout,$Tdpvgsm::tterm, 0x0D)
				SINON
					SI v_cause_660004637 == 19
					ALORS
						erreur_660004637 = i_set_art_field(g_iartout,$Tdpvgsm::tterm, 0x0E)
					SINON
						SI v_cause_660004637 == 20
						ALORS
							erreur_660004637 = i_set_art_field(g_iartout,$Tdpvgsm::tterm, 0x0F)
						SINON
							SI v_cause_660004637 == 22
							ALORS
								erreur_660004637 = i_set_art_field(g_iartout,$Tdpvgsm::tterm, 0x1B)
							SINON
								SI v_cause_660004637 == 23
								ALORS
									erreur_660004637 = i_set_art_field(g_iartout,$Tdpvgsm::tterm, 0x1C)
								SINON
									SI v_cause_660004637 == 24
									ALORS
										erreur_660004637 = i_set_art_field(g_iartout,$Tdpvgsm::tterm, 0x1D)
									FINSI
								FINSI
							FINSI
						FINSI
					FINSI
				FINSI
			FINSI
		FINSI
	FINSI
FINSI


#V3t1.15 indtax		:-	:-	:MSET :FF:1

#V3t1.16 nbUT		:-	:-	:MSET :FF:4

#V3t1.17 chgcar		:D	:-	:1VAL :chargingCharac

#V3t1.18 couleur		:-	:-	:MSET :FF:1

#T3t3
#local		:-      :-      :MSET :FF
SI  (i_strcmp(pt_IdPLMN_660004637,"FF") != 0)
ALORS
	erreur_660004637 = i_format_str2( pt_1_660004637, "%s%s", pt_IdPLMN_660004637, pt_InfoLocal_660004637)
	res_660004637= i_conv_ascii_dcb (pt_1_660004637, pt_2_660004637)
	SI res_660004637 > 9
	ALORS
		res_660004637 = 9
	FINSI
	erreur_660004637 = i_resize_tlv(g_iartout, "T3t3", "local", res_660004637 * 8)
	erreur_660004637 = i_memcpy_art_field_n(g_iartout, $Tdpvgsm::local, pt_2_660004637, res_660004637)
SINON
	erreur_660004637 = i_supprChamp(g_iartout, "T3t3")
FINSI

#QC1093 mappage de T3t15/servedMSISDN dans V3t4
# T3t4
# MSISDN		:-	:-	:1VAL :servedMSISDN

#MSISDN		:-      :-	:MSET :FF
# T3t15/ServedMSISDN Normalisation (automate ASR5K)
#erreur = i_dup_chp_rnisGSM(g_iartin, g_iartout, $Tsgwcdr::servedMSISDN, $Tdpvgsm::MSISDN, -$NORM:ASR5K2, 0)
#SI (erreur != 0)
#ALORS
#	trace("Tsgwcdr : Erreur duplication champ servedMSISDN vers MSISDN du Tdpvgsm")
#	code_rejet = MODULE_DISTR + ERR_DUPL + EFFICACE
#	erreur=i_PlvMessEmettre(7009, 2, g_iartin, "", 2, code_rejet, "servedMSISDN", 0)
#	SAUT STOCKE_ERRONE
#FINSI

#T3t5
#IMEI		:-      :-	:1VAL :iMEI

#T3t7
#estalloc	:-      :-	:1VAL :recOpenTime

#T3t20
#T4t20.1
#PDPaddr		:-	:-	:MSET :FF
SI (i_valid_field_n(g_iartin, $Tsgwcdr::PdpiPBinV4Ad))
ALORS
	erreur_660004637 = i_dup_chp_1val(g_iartin, g_iartout, $Tsgwcdr::PdpiPBinV4Ad, $Tdpvgsm::PDPaddr)
SINON
	SI (i_valid_field_n(g_iartin, $Tsgwcdr::PdpiPBinV6Ad))
	ALORS
		erreur_660004637 = i_dup_chp_1val(g_iartin, g_iartout, $Tsgwcdr::PdpiPBinV6Ad, $Tdpvgsm::PDPaddr)
	SINON
		erreur_660004637 = i_supprChamp(g_iartout, "T4t20.1")
	FINSI
FINSI


#T4t20.2
#accPointName3	:-	:-	:1VAL :accessPtNameNI

#T4t20.4
#chargingID	:-	:-	:1VAL :chargingID

#T4t20.5
#SeqNum		:-	:-	:MSET :FF
SI (i_valid_field_n(g_iartin, $Tsgwcdr::RecSeqNum))
ALORS
	erreur_660004637 = i_set_art_field(g_iartout, $Tdpvgsm::SeqNum, i_get_art_field(g_iartin, $Tsgwcdr::RecSeqNum))
SINON
	erreur_660004637 = i_set_art_field(g_iartout, $Tdpvgsm::SeqNum, 0x01)
FINSI

#T4t20.6
#PartialType	:-	:-	:MSET :02
SI (v_cause_660004637==0 || v_cause_660004637==4 || v_cause_660004637==5 || v_cause_660004637==19 || v_cause_660004637==20)
ALORS
	erreur_660004637=i_set_art_field(g_iartout, $Tdpvgsm::PartialType, 0x03)
SINON
	res_660004637=i_get_art_field(g_iartin, $Tsgwcdr::RecSeqNum)
	SI ((res_660004637 == -1 || res_660004637 == 0x01) && !i_valid_field_n(g_iartin, $Tsgwcdr::sGWchange))
	ALORS
		erreur_660004637=i_set_art_field(g_iartout, $Tdpvgsm::PartialType, 0x01)
#	SINON
#		erreur=i_set_art_field(g_iartout, $Tdpvgsm::PartialType, 0x02)
	FINSI
FINSI

#T4t20.7
#RecEntId1	:-	:-	:MSET :FF
SI (i_valid_field_n( g_iartin, $Tsgwcdr::PgWiPBinV4Ad))
ALORS
	erreur_660004637 = i_dup_chp_1val(g_iartin, g_iartout, $Tsgwcdr::PgWiPBinV4Ad, $Tdpvgsm::RecEntId1)
SINON
	SI (i_valid_field_n( g_iartin, $Tsgwcdr::PgWiPBinV6Ad))
	ALORS
		erreur_660004637 = i_dup_chp_1val(g_iartin, g_iartout, $Tsgwcdr::PgWiPBinV6Ad, $Tdpvgsm::RecEntId1)
	SINON
		erreur_660004637 = i_supprChamp(g_iartout, "T4t20.7")
	FINSI
FINSI


#T4t20.8
#RecEntId2	:-	:-	:MSET :FF
SI (i_valid_field_n( g_iartin, $Tsgwcdr::sGWiPBinV4Ad))
ALORS
	erreur_660004637 = i_dup_chp_1val(g_iartin, g_iartout, $Tsgwcdr::sGWiPBinV4Ad, $Tdpvgsm::RecEntId2)
SINON
	SI (i_valid_field_n( g_iartin, $Tsgwcdr::sGWiPBinV6Ad))
	ALORS
		erreur_660004637 = i_dup_chp_1val(g_iartin, g_iartout, $Tsgwcdr::sGWiPBinV6Ad, $Tdpvgsm::RecEntId2)
	SINON
		erreur_660004637 = i_supprChamp(g_iartout, "T4t20.8")
	FINSI
FINSI


#T4t20.10
#totVolOut	:-	:-	:MSET :00
SI (i_valid_field_n( g_iartin, $Tsgwcdr::DataVolUp))
ALORS
	erreur_660004637 = i_set_art_field(g_iartout9,$Conv_URS::DataVolumexx,i_get_art_field(g_iartin,$Tsgwcdr::DataVolUp))
	erreur_660004637 = i_dup_chp_1val(g_iartout9, g_iartout,$Conv_URS::totVolxx, $Tdpvgsm::totVolOut)
FINSI

#totVolIn	:-	:-	:MSET :00
SI (i_valid_field_n( g_iartin, $Tsgwcdr::DataVolDown))
ALORS
	erreur_660004637 = i_set_art_field(g_iartout9,$Conv_URS::DataVolumexx,i_get_art_field(g_iartin,$Tsgwcdr::DataVolDown))
	erreur_660004637 = i_dup_chp_1val(g_iartout9, g_iartout,$Conv_URS::totVolxx, $Tdpvgsm::totVolIn)
FINSI


#T3t30
#T4t30.1
#timeInCE	:-	:-	:1VAL :recOpenTime
erreur_660004637 = i_set_art_field(g_iartout, $Tdpvgsm::timeInCE, date_audit_660004637)


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


#T3t42
#PDPType		:-	:-	:1VAL :PDPTyp

#T3t59
#V3t59.1 PrefixIMSIpart	:-	:-	:MSET :FF
#V3t59.2 LocalTADIG	:-	:-	:MSET :20
#V3t59.3 PrefixIMSIclt	:-	:-	:MSET :FF
SI (b_RoamingIn_660004637 && flag_KeyTADIC_660004637)
ALORS
	res_660004637 = i_conv_ascii_dcb (pt_MCCMNC_660004637, pt_MCCMNC_DCB_660004637)
	SI (res_660004637 > 3)
	ALORS
		res_660004637 = 3
	FINSI
	erreur_660004637 = i_memcpy_art_field_n(g_iartout,$Tdpvgsm::PrefixIMSIclt,pt_MCCMNC_DCB_660004637, res_660004637)
SINON
	erreur_660004637 = i_supprChamp(g_iartout, "T3t59")
FINSI

#T3t71
b_T3t71_660004637 = 0

#T4t71.1
#QoSClassId	:-	:-	:MSET :FF
SI (i_valid_field_n( g_iartin, $Tsgwcdr::QCI))
ALORS
	b_T3t71_660004637 = 1
	erreur_660004637 = i_set_art_field(g_iartout, $Tdpvgsm::QoSClassId, i_get_art_field(g_iartin, $Tsgwcdr::QCI))
SINON
	erreur_660004637 = i_supprChamp(g_iartout, "T4t71.1")
FINSI

#T4t71.2
#maxReqBandUp	:-	:-	:MSET :FF
SI (i_valid_field_n( g_iartin, $Tsgwcdr::UplnkMBR))
ALORS
	b_T3t71_660004637 = 1
	erreur_660004637 = i_set_art_field(g_iartout, $Tdpvgsm::maxReqBandUp, i_get_art_field(g_iartin, $Tsgwcdr::UplnkMBR))
SINON
	erreur_660004637 = i_supprChamp(g_iartout, "T4t71.2")
FINSI

#T4t71.3
#maxReqBandDown	:-	:-	:MSET :FF
SI (i_valid_field_n( g_iartin, $Tsgwcdr::DnlnkMBR))
ALORS
	b_T3t71_660004637 = 1
	erreur_660004637 = i_set_art_field(g_iartout, $Tdpvgsm::maxReqBandDown, i_get_art_field(g_iartin, $Tsgwcdr::DnlnkMBR))
SINON
	erreur_660004637 = i_supprChamp(g_iartout, "T4t71.3")
FINSI

#T4t71.4
#garBitrateUp	:-	:-	:MSET :FF
SI (i_valid_field_n( g_iartin, $Tsgwcdr::UplnkGB))
ALORS
	b_T3t71_660004637 = 1
	erreur_660004637 = i_set_art_field(g_iartout, $Tdpvgsm::garBitrateUp, i_get_art_field(g_iartin, $Tsgwcdr::UplnkGB))
SINON
	erreur_660004637 = i_supprChamp(g_iartout, "T4t71.4")
FINSI

#T4t71.5
#garBitrateDown	:-	:-	:MSET :FF
SI (i_valid_field_n( g_iartin, $Tsgwcdr::DnlnkGB))
ALORS
	b_T3t71_660004637 = 1
	erreur_660004637 = i_set_art_field(g_iartout, $Tdpvgsm::garBitrateDown, i_get_art_field(g_iartin, $Tsgwcdr::DnlnkGB))
SINON
	erreur_660004637 = i_supprChamp(g_iartout, "T4t71.5")
FINSI

#T4t71.6
#RetentionPrior	:-	:-	:MSET :FF
SI (i_valid_field_n( g_iartin, $Tsgwcdr::aRP))
ALORS
	b_T3t71_660004637 = 1
	erreur_660004637 = i_set_art_field(g_iartout, $Tdpvgsm::RetentionPrior, i_get_art_field(g_iartin, $Tsgwcdr::aRP))
SINON
	erreur_660004637 = i_supprChamp(g_iartout, "T4t71.5")
FINSI

#T3t71
SI !b_T3t71_660004637
ALORS
	erreur_660004637 = i_supprChamp(g_iartout, "T3t71")
FINSI

####### FIN creation DPV pivot, Tdpvgsm ###############

erreur_660004637 = aiguillage2_660004590 (g_iartin, g_iartout, DISTRIBUTION_INCONNU_660004637, Multidistribution_Non_660004637)
SI (erreur_660004637 == TRAI_KO_660004637)
ALORS
	trace("<<<__LINE__<<<__FILE__<<< Erreur retour fonction aiguillage2")
	SAUT STOCKE_ERRONE
FINSI

trace("<<<__LINE__<<<__FILE__<<< : Fin Distribution OK")
RETOUR TRAIT_OK





POINT STOCKE_ERRONE
trace( "Tsgwcdr : fin Distribution Stockage de l'article en ERRONE" )
erreur_660004637 = i_make_art_rej(g_iartin, g_iartout11, code_rejet_660004637)
erreur_660004637 = i_stocke_art(g_iartout11,	0, PT_ERRONE, 0)
RETOUR TRAIT_OK

#---------------------------------------FIN Tsgwcdr_dis.src-------------------
