DEFINITION C_Tdpv_660004635 "Tdpvgsm"
DEFINITION C_Article_660004635 "Tpgwcdr"
DEFINITION Multidistribution_Non_660004635 0
DEFINITION TRAI_KO_660004635 -1
DEFINITION DISTRIBUTION_INCONNU_660004635 1
DEFINITION MODULE_DISTR_660004635 0xA000
DEFINITION ERR_NORM_660004635 0x010
DEFINITION ERR_VALO_660004635 0x020
DEFINITION ERR_DUPL_660004635 0x0D0
DEFINITION ERR_DISTR_660004635 0x110
DEFINITION ERR_TAB_660004635 0x0A0
DEFINITION EFFICACE_660004635 1
DEFINITION NUMTAB_660004635 4
REGISTRE ENTIER erreur_660004635
REGISTRE ENTIER code_rejet_660004635
REGISTRE ENTIER ERREUR_660004635
REGISTRE ENTIER res_660004635
REGISTRE ENTIER flag_rdt_660004635
REGISTRE ENTIER date_cra_660004635
REGISTRE ENTIER date_fin_660004635
REGISTRE ENTIER date_audit_660004635
REGISTRE ENTIER Duree_660004635
REGISTRE ENTIER Debut_660004635
REGISTRE ENTIER TypeRAT_660004635
REGISTRE ENTIER VOLUME_NUL_660004635
REGISTRE ENTIER ACTIV_VOL_NUL_660004635
REGISTRE ENTIER RoamingOUT_660004635
REGISTRE ENTIER APN_660004635
REGISTRE ENTIER Seqnum_660004635
REGISTRE ENTIER Partialtype_660004635
REGISTRE ENTIER T3t71present_660004635
REGISTRE ENTIER b_PseudoAPN_660004635
REGISTRE ENTIER b_CodServ_660004635
REGISTRE ENTIER CodServ_660004635
REGISTRE ENTIER nb_Entree_660004635
REGISTRE ENTIER indice_660004635
REGISTRE ENTIER long_660004635
REGISTRE ENTIER SeqnumBis_660004635
REGISTRE POINTEUR pt_AX_IDEMET_660004635
REGISTRE POINTEUR pt_1_660004635
REGISTRE POINTEUR pt_2_660004635
REGISTRE POINTEUR pt_IdPLMN_660004635
REGISTRE POINTEUR pt_cleIdPLMN_660004635
REGISTRE POINTEUR pt_InfoLocal_660004635
REGISTRE POINTEUR pt_APN_660004635
REGISTRE POINTEUR pt_TADIG_660004635
REGISTRE POINTEUR pt_MCCMNC_660004635
REGISTRE POINTEUR pt_CodServ_660004635
REGISTRE POINTEUR pt_couple_660004635
REGISTRE POINTEUR pt_cle_660004635
####################################################################
#				Appel Sortant MET NSS9, cas d'article Tpgwcdr
####################################################################
#       article CRA MET ASN1 => type DPV TLV = 00
#
# 11/07/2012 RHEN Creation
# 26/07/2012 JLG G3R7 QC1069
# 26/07/2012 PKH QC1063 : Teleservice et variable de contexte APN ,resultats interrogation table RatingGroupeAPN
# 30/07/2012 PKH QC1063 : evolution interrogation table RatingGroupAPN
# 13/08/2012 PKH QC1063 Correction V3t1.18 a FF et V3t1.8 prend le codeservice(valeur1) table RatingGroupeAPN
# 13/08/2012 PKH QC1063 Correction la valeur APN (valeur2) de la table RatingGoupeAPN tronque a 63 octets max
# 14/08/2012 PKH QC1084 Correction valorisation du champ T4t20.6 avec les cas de V3t13 (cause)
# 14/08/2012 PKH QC1085 Correction T4t21.7/UplnkMBR est recopier a tort dans Tdpvgsm V4t71.4
# 21/08/2012 JLG QC1089  enrichir variable fonctionnelle infoLocal avec 0x00000000 quand elle est incalculable
# 22/08/2012 JLG verif des pointeurs
# 05/09/2012 RHE QC1095 champ V3t1.10 : si T3t19/ratType = 0x02, restituer la valeur par d?faut : 0x01
# 07/09/2012 RHE QC1093 Suppression de l'appel de l'automate ASR5K2, mappage de T3t15/servedMSISDN dans V3t4
# 10/09/2012 RHE QC1094 Correction la valeur APN (valeur2) de la table RatingGoupeAPN : si pseudoAPN absent, restituer l'APN technique du DC 
# 11/09/2012 RHE QC1095 champ V3t1.10 : si T3t19/ratType = 0x02, restituer la valeur : 0x00
# 12/09/2012 JLG QC1100 cle table RatingGoupeAPN en decimal
# 05/03/2013 PKH QC1184 evolution valorisation des champs V3t7,V3t1.5 et V3t1.6 avec meta champs ddebut et dduree
# 02/07/2014 - JLG -G5R1 QC1405, champ eec du DPV si g_ieec > 500
####################################################################




#QC1094


pt_AX_IDEMET_660004635 = "pt_AX_IDEMET11111111"
pt_1_660004635 = "pt_1_11111111111111111111111"
pt_2_660004635 = "pt_2_22222222222222222222222"
#pt_Date_Tac = "pt_Date_Tac_918273645463728191"
pt_IdPLMN_660004635= "pt_IdPLMN999999999"
pt_cleIdPLMN_660004635= "pt_cleIdPLMN999999"
pt_InfoLocal_660004635= "pt_InfoLocal999999"
pt_APN_660004635= "pt_APN444444444444444444444444444444444444444444444444444444444444444444444466666644444444444444444444444444444444444444444555"
pt_TADIG_660004635 = "pt_TADIG3333333333"
pt_MCCMNC_660004635 = "pt_MCCMNC111111111"
pt_CodServ_660004635 = "pt_CodServ77777777"
pt_couple_660004635 = "pt_couple_3838383838383838383838383838383838383838383838383838383838383838383838383"
pt_cle_660004635 = "pt_cle929292929"



trace("Tpgwcdr : Debut DISTRIBUTION")


date_cra_660004635 = i_get_art_field(g_iartin, $Tpgwcdr::ddebut)
date_fin_660004635 = i_get_art_field(g_iartin, $Tpgwcdr::dfin)
date_audit_660004635 = i_DHgetLocalTime(NUMTAB_660004635, 7, i_date_audit())


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

# Initialisations
ERREUR_660004635 = 0
code_rejet_660004635 = 0
nb_Entree_660004635 = 0
long_660004635 = 0
Debut_660004635 = 0
##################################################################################
# Identification de la provenance de l'article
# flag_rdt : nb de passage en redistribution (lecture de l'enveloppe obligatoire)
##################################################################################
flag_rdt_660004635 = -1
flag_rdt_660004635 = i_LireRedistCpt()

SI (flag_rdt_660004635 == 0)
ALORS
	erreur_660004635 = i_add_opt( "E_Redistri2" )
FINSI
erreur_660004635 = i_set_attr_val_n( $E_Redistri2::EnvoiRedis, 0)

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

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

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

# AX_IDEMET
i_strcpy(pt_AX_IDEMET_660004635, "")
i_strcpy(pt_1_660004635, "")
erreur_660004635 = i_format_str2( pt_1_660004635, "%s%s", "AX_IDEMET_", i_LireEECSGTQS(g_ieec))
i_strcpy(pt_AX_IDEMET_660004635, i_get_tab_field("VariableContexte", date_cra_660004635, pt_1_660004635))

#QC 1184 enrichissement Debut 
#Debut
Debut_660004635 = i_get_art_field(g_iartin, $Tpgwcdr::ddebut)

# Duree
Duree_660004635 = i_get_art_field(g_iartin, $Tpgwcdr::dduree)

#TypeRAT (Initialise ? 1 pour UMTS)
TypeRAT_660004635 = 1
SI (i_valid_field_n( g_iartin, $Tpgwcdr::ratType))
ALORS
	TypeRAT_660004635 = i_get_art_field(g_iartin,$Tpgwcdr::ratType)
	#QC1095
	SI ( TypeRAT_660004635 == 2)
	ALORS
		TypeRAT_660004635 = 0
	FINSI
FINSI

# Date_Tac (conversion avec T2_date (DATE, DATEN) de l'article Conv_URS) => non utilise
#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)

# IdPLMN
i_strcpy(pt_IdPLMN_660004635, "FF")
SI (i_valid_field_n( g_iartin, $Tpgwcdr::pLMNId))
ALORS
	erreur_660004635 = i_get_art_str (g_iartin,$Tpgwcdr::pLMNId,pt_IdPLMN_660004635)
	SI (i_strlen(pt_IdPLMN_660004635)==6)
	ALORS
		SI (i_strplcmp (pt_IdPLMN_660004635, "F", 5, 1) == 0)
		ALORS
			i_get_sub_str(pt_IdPLMN_660004635, 0, 4, pt_IdPLMN_660004635)
		FINSI
	FINSI
	# Test format MAP
	i_get_sub_str(pt_IdPLMN_660004635, 0, 2, pt_1_660004635)
	i_get_sub_str(pt_IdPLMN_660004635, 4, 5, pt_2_660004635)
	# si 4 eme octet = F
	erreur_660004635 = i_format_str2(pt_cleIdPLMN_660004635, "%s%s", pt_1_660004635, pt_2_660004635)
	SI  (i_strplcmp ( pt_IdPLMN_660004635, "F", 3, 1) != 0)
	ALORS
		i_strcpy(pt_1_660004635, pt_cleIdPLMN_660004635)
		i_get_sub_str(pt_IdPLMN_660004635, 3, 3, pt_2_660004635)
		# si 4 eme octet != F
		erreur_660004635 = i_format_str2(pt_cleIdPLMN_660004635, "%s%s", pt_1_660004635, pt_2_660004635)
	FINSI
	i_strcpy(pt_IdPLMN_660004635, pt_cleIdPLMN_660004635)
FINSI

#QC1089 enrichir la variable pt_InfoLocal avec "00000000" quand elle n est pas calculable
# InfoLocal (pt_InfoLocal) plus de parametre TAC
# Tpgwcdr::lsdUserLocInfo
#  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_660004635, "")
SI (i_valid_field_n( g_iartin, $Tpgwcdr::lsdUserLocInfo))
ALORS
	i_strcpy(pt_1_660004635, "")
	erreur_660004635 = i_get_art_str (g_iartin, $Tpgwcdr::lsdUserLocInfo, pt_1_660004635)
	# pt_1 en ascii donc lg x 2, 26 au lieu de 13
	SI (i_strlen(pt_1_660004635) == 26 && i_strplcmp ( pt_1_660004635, "18", 0, 2) == 0)
	ALORS
		# 2eme digit du 10eme octet jusqu'a fin
		#19 20-21 22-23 24-25
		i_get_sub_str(pt_1_660004635, 19, 25, pt_InfoLocal_660004635)
	SINON
		# pt_1 en ascii donc lg x 2, 16 au lieu de 8 (CGI, SAI ou RAI)
		SI (i_strlen(pt_1_660004635) == 16)
		ALORS
			# octet 5 a 8 donc 8 a 15
			i_get_sub_str(pt_1_660004635, 8, 15, pt_InfoLocal_660004635)
		SINON
			i_strcpy (pt_InfoLocal_660004635,"00000000")
		FINSI
	FINSI
SINON
	SI (i_valid_field_n( g_iartin, $Tpgwcdr::userLocationInf))
	ALORS
		i_strcpy(pt_1_660004635, "")
		erreur_660004635 = i_get_art_str (g_iartin, $Tpgwcdr::userLocationInf, pt_1_660004635)
		# pt_1 en ascii donc lg x 2, 26 au lieu de 13
		SI (i_strlen(pt_1_660004635) == 26 && i_strplcmp ( pt_1_660004635, "18", 0, 2) == 0)
		ALORS
			i_get_sub_str(pt_1_660004635, 19, 25, pt_InfoLocal_660004635)
		SINON
			# pt_1 en ascii donc lg x 2, 16 au lieu de 8 (CGI, SAI ou RAI)
			SI (i_strlen(pt_1_660004635) == 16)
			ALORS
				i_get_sub_str(pt_1_660004635, 8, 15, pt_InfoLocal_660004635)
			SINON
				i_strcpy (pt_InfoLocal_660004635,"00000000")
			FINSI
		FINSI
	SINON
		i_strcpy (pt_InfoLocal_660004635,"00000000")
	FINSI
FINSI

## QC1069
## APN
#i_strcpy(pt_APN, "")
#APN=0
#SI (i_valid_field_n( g_iartin, $Tpgwcdr::lsdRatingGroup))
#ALORS
#	i_strcpy(pt_1, "")
#	# lsdRatingGroup string de sa valeur decimale
#	erreur = i_get_art_str (g_iartin, $Tpgwcdr::lsdRatingGroup, pt_1)
#	i_strcpy(pt_APN, i_get_tab_field("RatingGroupAPN", date_cra, pt_1))
#	APN=1
#FINSI
#SI (i_strcmp(pt_APN, "") == 0)
#ALORS
#	SI (i_valid_field_n( g_iartin, $Tpgwcdr::accessPtNameNI))
#ALORS
#		erreur = i_get_art_str (g_iartin, $Tpgwcdr::accessPtNameNI, pt_APN)
#		APN=2
#	FINSI
#FINSI

#QC1063 Ev
SI (i_valid_field_n( g_iartin, $Tpgwcdr::lsdRatingGroup))
ALORS
	trace("<<<__LINE__<<<__FILE__<<< bla bla")
	#trace ("<<<__LINE__<<<__FILE__<<<------ presence de lsdRatingGroup---------------")
	i_strcpy(pt_1_660004635, "")
	#QC1100 cle table RatingGoupeAPN en decimal
  #res = i_get_art_field (g_iartin, $Tpgwcdr::lsdRatingGroup)
	#erreur = i_set_art_field(g_iartout9,$Conv_URS::Entier4, res)
	#erreur = i_get_art_str(g_iartout9,$Conv_URS::TabNumHexa,pt_1)
	res_660004635 = i_get_art_str(g_iartin, $Tpgwcdr::lsdRatingGroup, pt_2_660004635)
	# trace2("<<<__LINE__<<<__FILE__<<<====== pt_2 (lsdRatingGroup) = %s ==================",pt_2,"")
#Ev
	nb_Entree_660004635= i_get_tab_nb_entries("RatingGroupeAPN", date_cra_660004635)
	trace1 ("<<__LINE__>> ========== nb_Entree = %d ==============",nb_Entree_660004635)

	SI (nb_Entree_660004635 < 0)
	ALORS
		trace ("<<__LINE__>> table RatingGroupeAPN non trouvee ")
		SAUT Boucle_Exit
	FINSI

	indice_660004635 = 0
	POINT Boucle_TabExt
	SI (indice_660004635 < nb_Entree_660004635 )
	ALORS
		i_strcpy (pt_couple_660004635,"")
		i_strcpy (pt_cle_660004635,"")
		res_660004635 = i_get_tab_one_entry("RatingGroupeAPN",date_cra_660004635,indice_660004635,pt_couple_660004635)
		#trace2 ("<<__LINE__>> ----------- pt_couple = %s ------------------",pt_couple,"")
		erreur_660004635 = i_recupererValeur(pt_couple_660004635,pt_cle_660004635,8,';')
		#trace2 ("<<__LINE__>> ----------- valeur = %s ------------------",pt_couple,"")
		#trace2 ("<<__LINE__>> ----------- cle = %s ------------------",pt_cle,"")
		#long = i_strlen(pt_cle)
		#i_get_sub_str (pt_1, -long, -1,pt_2)
		#trace2 ("<<__LINE__>> ----------- pt_2 = %s ------------------",pt_2,"")
		SI (i_strcmp(pt_2_660004635,pt_cle_660004635) == 0)
		ALORS
			b_PseudoAPN_660004635 = 1
			i_strcpy (pt_CodServ_660004635,"")
			erreur_660004635 = i_recupererValeur(pt_couple_660004635,pt_CodServ_660004635,5,'_')
			#QC1094
			b_CodServ_660004635 = 1
			#trace2("<<__LINE__>> ---------- Code_APN = %s --------------",pt_couple,"")
			#trace2("<<__LINE__>> ---------- CodeServ = %s --------------",pt_CodServ,"")
			SI (i_strlen(pt_couple_660004635) != 0)
			ALORS
				i_strcpy(pt_APN_660004635,pt_couple_660004635)
				APN_660004635=1
			SINON
				b_PseudoAPN_660004635 = 0
			FINSI
			SAUT Boucle_Exit
		FINSI
		indice_660004635 = indice_660004635 + 1
		SAUT Boucle_TabExt
	FINSI
FINSI
POINT Boucle_Exit
#trace1 ("<<<__LINE__<<<__FILE__<<<-----b_PseudoAPN=%d----------------",b_PseudoAPN)
#Ev Fin

SI (b_PseudoAPN_660004635 == 0)
ALORS
	SI (i_valid_field_n( g_iartin, $Tpgwcdr::accessPtNameNI ))
	ALORS
		erreur_660004635 = i_get_art_str (g_iartin, $Tpgwcdr::accessPtNameNI, pt_APN_660004635)
		APN_660004635=2
	SINON
		i_strcpy(pt_APN_660004635, "FF")
	FINSI
FINSI
#/QC1063 Ev


# VOLUME_NUL
VOLUME_NUL_660004635 = 1
SI (i_valid_field_n( g_iartin, $Tpgwcdr::lsdDataVolUp))
ALORS
	SI (i_get_art_field(g_iartin,$Tpgwcdr::lsdDataVolUp) > 0)
	ALORS
		VOLUME_NUL_660004635 = 0
	FINSI
FINSI
SI VOLUME_NUL_660004635
ALORS
	SI (i_valid_field_n( g_iartin, $Tpgwcdr::lsdDataVolDo))
	ALORS
		SI i_get_art_field(g_iartin,$Tpgwcdr::lsdDataVolDo) > 0
		ALORS
			VOLUME_NUL_660004635 = 0
		FINSI
	FINSI
FINSI

# ACTIV_VOL_NUL
ACTIV_VOL_NUL_660004635 = 0
SI ( i_get_tab_field("VariableContexte",date_cra_660004635,"FILT_GPRS_NUL") != g_inull )
ALORS
	ACTIV_VOL_NUL_660004635 = 1
FINSI

# RoamingOUT
RoamingOUT_660004635 = 0
SI  (i_strcmp(pt_IdPLMN_660004635,"FF") != 0  &&  i_strplcmp( pt_IdPLMN_660004635, "208", 0, 3) !=0)
ALORS
	RoamingOUT_660004635 = 1
FINSI

# TADIG, MCCMNC
i_strcpy(pt_MCCMNC_660004635, "")
i_strcpy(pt_TADIG_660004635, "")

SI RoamingOUT_660004635
ALORS
	# pt_MCCMNC contiendra la valeur de retour TADIG_MCCMNC
	i_strcpy(pt_MCCMNC_660004635,i_get_tab_field("MCCMNC_TADIG", date_cra_660004635, pt_cleIdPLMN_660004635))
	SI (i_strcmp( pt_MCCMNC_660004635, g_inull)  != 0)
	ALORS
		erreur_660004635 = i_recupererValeur(pt_MCCMNC_660004635,pt_TADIG_660004635,5,'-')
		SI (i_strcmp (pt_MCCMNC_660004635,g_inull) == 0)
		ALORS
			# si retour MCCMNC null (fictive) alors = cle (pt_cleIdPLMN)
			i_strcpy(pt_MCCMNC_660004635,pt_cleIdPLMN_660004635)
		FINSI
	SINON
		trace ("<<__LINE__>> ========= Echec interrogation table  MCCMNC_TADIC ============")
		ERREUR_660004635 = ERR_TAB_660004635
		code_rejet_660004635 = MODULE_DISTR_660004635 + ERREUR_660004635 + EFFICACE_660004635
		erreur_660004635=i_PlvMessEmettre(7518, 2, g_iartin, "", 3, code_rejet_660004635,"Tpgwcdr - MCCMNC_TADIC", pt_cleIdPLMN_660004635)
		SAUT STOCKE_ERRONE
	FINSI
FINSI


############################################################################
# Duplication Tdpv33 (g_iartout)
############################################################################
#Duplication article d entree vers DPV TLV

SI (i_dup_art_tab( g_iartin, g_iartout, C_Tdpv_660004635))
ALORS
	trace("Tpgwcdr, ERREUR de duplication tab")
	code_rejet_660004635 = MODULE_DISTR_660004635 + ERREUR_660004635 + EFFICACE_660004635
	erreur_660004635 = i_PlvMessEmettre(7502, 2, g_iartin, "", 2, code_rejet_660004635, C_Article_660004635, 0)
	SAUT STOCKE_ERRONE
FINSI

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

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

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

#V3t1.3 idemet		:-	:-	:MSET :FF
SI (i_strcmp(pt_AX_IDEMET_660004635,"") != 0)
ALORS
	erreur_660004635 = affectation_tab_660004265(g_iartout,$Tdpvgsm::idemet,pt_AX_IDEMET_660004635)
SINON
	erreur_660004635 = affectation_tab_660004265(g_iartout,$Tdpvgsm::idemet,"33610000000FFFFFFF")
FINSI

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

#V3t1.5 DATE		:-	:-	:MSET :FF
erreur_660004635 = i_set_art_field(g_iartout,$Tdpvgsm::DATE, Debut_660004635)

#V3t1.6 DUREE		:-	:-	:MSET :00:1
erreur_660004635 = i_set_art_field(g_iartout,$Tdpvgsm::DUREE, Duree_660004635)

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

#V3t1.8 tlserv		:-	:-	:MSET :FF:1
#QC1063 Code service issu de la table ext RatingGroupeAPN
#QC1094
#SI (b_PseudoAPN == 1  )
SI (b_CodServ_660004635 == 1  )
ALORS
	CodServ_660004635=toHEXInteger_660004265(pt_CodServ_660004635)
	erreur_660004635 = i_set_art_field(g_iartout,$Tdpvgsm::tlserv, CodServ_660004635)
FINSI

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

#V3t1.10 systype		:-	:-	:MSET :01:1
erreur_660004635 = i_set_art_field(g_iartout,$Tdpvgsm::systype, TypeRAT_660004635)

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

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

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

#V3t1.14 tterm		:-	:-	:MSET :FF:1
res_660004635=-1
res_660004635 = i_get_art_field(g_iartin, $Tpgwcdr::cause)
SI res_660004635 == 0
ALORS
	erreur_660004635 = i_set_art_field(g_iartout,$Tdpvgsm::tterm, 0x000)
SINON
	SI res_660004635 == 4
	ALORS
		erreur_660004635 = i_set_art_field(g_iartout,$Tdpvgsm::tterm, 0x10)
	SINON
		SI res_660004635 == 16
		ALORS
			erreur_660004635 = i_set_art_field(g_iartout,$Tdpvgsm::tterm, 0x0B)
		SINON
			SI res_660004635 == 17
			ALORS
				erreur_660004635 = i_set_art_field(g_iartout,$Tdpvgsm::tterm, 0x0C)
			SINON
				SI res_660004635 == 18
				ALORS
					erreur_660004635 = i_set_art_field(g_iartout,$Tdpvgsm::tterm, 0x0D)
				SINON
					SI res_660004635 == 19
					ALORS
						erreur_660004635 = i_set_art_field(g_iartout,$Tdpvgsm::tterm, 0x0E)
					SINON
						SI res_660004635 == 20
						ALORS
							erreur_660004635 = i_set_art_field(g_iartout,$Tdpvgsm::tterm, 0x0F)
						SINON
							SI res_660004635 == 22
							ALORS
								erreur_660004635 = i_set_art_field(g_iartout,$Tdpvgsm::tterm, 0x1B)
							SINON
								SI res_660004635 == 23
								ALORS
									erreur_660004635 = i_set_art_field(g_iartout,$Tdpvgsm::tterm, 0x1C)
								SINON
									SI res_660004635 == 24
									ALORS
										erreur_660004635 = 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		:-	:-	:1VAL :chargingCharac

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


# T3t2 pas implemente   # idpart		:-      :-      :MSET :FF

# T3t3
# local		:-      :-      :MSET :FF
SI  (i_strcmp(pt_IdPLMN_660004635,"FF") != 0)
ALORS
	erreur_660004635 = i_format_str2( pt_1_660004635, "%s%s", pt_IdPLMN_660004635, pt_InfoLocal_660004635)
	res_660004635= i_conv_ascii_dcb(pt_1_660004635, pt_2_660004635)
	SI res_660004635 > 9
	ALORS
		res_660004635 = 9
	FINSI
	erreur_660004635 = i_resize_tlv(g_iartout, "T3t3", "local", res_660004635 * 8)
	erreur_660004635 = i_memcpy_art_field_n(g_iartout, $Tdpvgsm::local, pt_2_660004635, res_660004635)
SINON
	erreur_660004635 = 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, $Tpgwcdr::servedMSISDN, $Tdpvgsm::MSISDN, -$NORM:ASR5K2, 0)
#SI (erreur != 0)
#ALORS
#	trace("Tpgwcdr : Erreur duplication champ servedMSISDN vers MSISDN du Tdpvgsm")
#	code_rejet = MODULE_DISTR + ERR_DUPL + EFFICACE
#	erreur=i_PlvMessEmettre(7003, 2, g_iartin, "", 2, code_rejet, "servedMSISDN", 0)
#	SAUT STOCKE_ERRONE
#FINSI



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

# T3t7
# estalloc	:-      :-	:MSET :FF
#QC1184  estalloc valorise avec Debut
erreur_660004635 = i_set_art_field(g_iartout,$Tdpvgsm::estalloc, Debut_660004635)

# T3t20
# T4t20.1
# PDPaddr		:-	:-	:MSET :FF
SI (i_valid_field_n( g_iartin, $Tpgwcdr::PdpiPBinV4A))
ALORS
	erreur_660004635 = i_dup_chp_1val(g_iartin, g_iartout, $Tpgwcdr::PdpiPBinV4A, $Tdpvgsm::PDPaddr)
SINON
	SI (i_valid_field_n( g_iartin, $Tpgwcdr::PdpiPBinV6A))
	ALORS
		erreur_660004635 = i_dup_chp_1val(g_iartin, g_iartout, $Tpgwcdr::PdpiPBinV6A, $Tdpvgsm::PDPaddr)
	SINON
		erreur_660004635 = i_supprChamp(g_iartout, "T4t20.1")
	FINSI
FINSI
#QC1069
# T4t20.2
# accPointName3	:-	:-	:MSET :FF
SI (i_strcmp(pt_APN_660004635, "FF") != 0)
ALORS
	SI APN_660004635 == 1
	ALORS
		res_660004635=i_strlen(pt_APN_660004635)
		SI (res_660004635 > 63)
		ALORS
			res_660004635= 63
			i_get_sub_str(pt_APN_660004635, 0, (res_660004635 - 1), pt_APN_660004635)
		FINSI
		erreur_660004635 = i_set_art_str(g_iartout9,$Conv_URS::APNA,pt_APN_660004635)
		erreur_660004635 = i_resize_tlv(g_iartout,"T4t20.2","accPointName3", res_660004635)
		erreur_660004635 = i_memcpy_art_field_n(g_iartout, $Tdpvgsm::accPointName3, i_get_art_fieldptr(g_iartout9, $Conv_URS::APNH), res_660004635)
	SINON
		SI APN_660004635 == 2
		ALORS
			erreur_660004635 = i_dup_chp_1val(g_iartin, g_iartout, $Tpgwcdr::accessPtNameNI, $Tdpvgsm::accPointName3)
		SINON
			erreur_660004635 = i_supprChamp(g_iartout, "T4t20.2")
		FINSI
	FINSI
SINON
	erreur_660004635 = i_supprChamp(g_iartout, "T4t20.2")
FINSI

# T4t20.4
# chargingID	:-	:-	:MSET :FF
erreur_660004635 = i_set_art_field(g_iartout, $Tdpvgsm::chargingID, i_get_art_field(g_iartin,$Tpgwcdr::chargingID))

# T4t20.5
# SeqNum	:-	:-	:MSET :FF
Seqnum_660004635 = 0x01
SeqnumBis_660004635 = -1
SI (i_valid_field_n( g_iartin, $Tpgwcdr::recSeqNum))
ALORS
	Seqnum_660004635 = i_get_art_field(g_iartin,$Tpgwcdr::recSeqNum)
	SeqnumBis_660004635 = Seqnum_660004635
FINSI
erreur_660004635 = i_set_art_field(g_iartout, $Tdpvgsm::SeqNum, Seqnum_660004635)

# T4t20.6
# PartialType	:-	:-	:MSET :FF
Partialtype_660004635 = 0x02
res_660004635=-1
res_660004635 = i_get_art_field(g_iartin, $Tpgwcdr::cause)
SI ((res_660004635 == 0) || (res_660004635 == 4) || (res_660004635 == 5) || (res_660004635 == 19) || (res_660004635 == 20))
ALORS
	Partialtype_660004635 = 0x03
SINON
	SI ( Seqnum_660004635 == 0x01 || SeqnumBis_660004635 == -1)
	ALORS
		Partialtype_660004635 = 0x01
	SINON
		Partialtype_660004635 = 0x02
	FINSI
FINSI
erreur_660004635 = i_set_art_field(g_iartout, $Tdpvgsm::PartialType, Partialtype_660004635)

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

# T4t20.8
# RecEntId2	:-	:-	:MSET :FF

SI (i_valid_field_n( g_iartin, $Tpgwcdr::lsdSgWiPBinV4Ad))
ALORS
	erreur_660004635 = i_dup_chp_1val(g_iartin, g_iartout, $Tpgwcdr::lsdSgWiPBinV4Ad, $Tdpvgsm::RecEntId2)
SINON
	SI (i_valid_field_n( g_iartin, $Tpgwcdr::lsdSgWiPBinV6Ad))
	ALORS
		erreur_660004635 = i_dup_chp_1val(g_iartin, g_iartout, $Tpgwcdr::lsdSgWiPBinV6Ad, $Tdpvgsm::RecEntId2)
	SINON
		SI (i_valid_field_n( g_iartin, $Tpgwcdr::SgWiPBinV4Ad))
		ALORS
			erreur_660004635 = i_dup_chp_1val(g_iartin, g_iartout, $Tpgwcdr::SgWiPBinV4Ad, $Tdpvgsm::RecEntId2)
		SINON
			SI (i_valid_field_n (g_iartin, $Tpgwcdr::SgWiPBinV6Ad))
			ALORS
				erreur_660004635 = i_dup_chp_1val(g_iartin, g_iartout, $Tpgwcdr::SgWiPBinV6Ad, $Tdpvgsm::RecEntId2)
			SINON
				erreur_660004635 = i_supprChamp(g_iartout, "T4t20.8")
			FINSI
		FINSI
	FINSI
FINSI

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

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

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

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

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

# T3t51
# servPlatRoaInf	:-	:-	:MSET :FF
SI RoamingOUT_660004635
ALORS
	res_660004635 = i_conv_ascii_dcb(pt_MCCMNC_660004635, pt_1_660004635)
	erreur_660004635 = i_memcpy_art_field_n(g_iartout, $Tdpvgsm::servPlatRoaInf, pt_1_660004635, res_660004635)
	erreur_660004635 = i_resize_tlv(g_iartout,"T3t51","servPlatRoaInf", res_660004635 * 8)
SINON
	erreur_660004635 = i_supprChamp(g_iartout, "T3t51")
FINSI

# T3t59
# PrefixIMSIpart	:-	:-	:MSET :FF
# LocalTADIG	:-	:-	:MSET :20
SI RoamingOUT_660004635
ALORS
	erreur_660004635=i_set_art_str(g_iartout,$Tdpvgsm::LocalTADIG,pt_TADIG_660004635)
SINON
	erreur_660004635 = i_supprChamp(g_iartout, "T3t59")
FINSI
# PrefixIMSIclt	:-	:-	:MSET :FF

# T3t71
T3t71present_660004635 = 0

# T4t71.1
# QoSClassId	:-	:-	:MSET :00
SI (i_valid_field_n( g_iartin, $Tpgwcdr::QCI))
ALORS
	erreur_660004635 = i_dup_chp_1val(g_iartin, g_iartout, $Tpgwcdr::QCI, $Tdpvgsm::QoSClassId)
	T3t71present_660004635 = 1
SINON
	erreur_660004635 = i_supprChamp(g_iartout, "T4t71.1")
FINSI

# T4t71.2
# maxReqBandUp	:-	:-	:MSET :00
SI (i_valid_field_n( g_iartin, $Tpgwcdr::UplnkMBR))
ALORS
	erreur_660004635 = i_dup_chp_1val(g_iartin, g_iartout, $Tpgwcdr::UplnkMBR, $Tdpvgsm::maxReqBandUp)
	T3t71present_660004635 = 1
SINON
	erreur_660004635 = i_supprChamp(g_iartout, "T4t71.2")
FINSI

# T4t71.3
# maxReqBandDown	:-	:-	:MSET :00
SI (i_valid_field_n( g_iartin, $Tpgwcdr::DnlnkMBR))
ALORS
	erreur_660004635 = i_dup_chp_1val(g_iartin, g_iartout, $Tpgwcdr::DnlnkMBR, $Tdpvgsm::maxReqBandDown)
	T3t71present_660004635 = 1
SINON
	erreur_660004635 = i_supprChamp(g_iartout, "T4t71.3")
FINSI

# T4t71.4
# garBitrateUp	:-	:-	:MSET :00
#QC1085
SI (i_valid_field_n( g_iartin, $Tpgwcdr::UplnkGB))
ALORS
	erreur_660004635 = i_dup_chp_1val(g_iartin, g_iartout, $Tpgwcdr::UplnkGB, $Tdpvgsm::garBitrateUp)
	T3t71present_660004635 = 1
SINON
	erreur_660004635 = i_supprChamp(g_iartout, "T4t71.4")
FINSI

# T4t71.5
# garBitrateDown	:-	:-	:MSET :00
SI (i_valid_field_n( g_iartin, $Tpgwcdr::DnlnkGB))
ALORS
	erreur_660004635 = i_dup_chp_1val(g_iartin, g_iartout, $Tpgwcdr::DnlnkGB, $Tdpvgsm::garBitrateDown)
	T3t71present_660004635 = 1
SINON
	erreur_660004635 = i_supprChamp(g_iartout, "T4t71.5")
FINSI

# T4t71.6
# RetentionPrior	:-	:-	:MSET :00
SI (i_valid_field_n( g_iartin, $Tpgwcdr::ARP))
ALORS
	erreur_660004635 = i_dup_chp_1val(g_iartin, g_iartout, $Tpgwcdr::ARP, $Tdpvgsm::RetentionPrior)
	T3t71present_660004635 = 1
SINON
	erreur_660004635 = i_supprChamp(g_iartout, "T4t71.6")
FINSI

SI (T3t71present_660004635 == 0)
ALORS
	erreur_660004635 = i_supprChamp(g_iartout, "T3t71")
FINSI


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

erreur_660004635 = aiguillage2_660004590 (g_iartin, g_iartout, DISTRIBUTION_INCONNU_660004635, Multidistribution_Non_660004635)
SI (erreur_660004635 == TRAI_KO_660004635)
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( "Tpgwcdr : fin Distribution Stockage de l'article en ERRONE" )
erreur_660004635 = i_make_art_rej(g_iartin, g_iartout11, code_rejet_660004635)
erreur_660004635 = i_stocke_art(g_iartout11,	0, PT_ERRONE, 0)
RETOUR TRAIT_OK

#---------------------------------------FIN Tpgwcdr_dis.src-------------------
