DEFINITION C_Article_860026421 "Topitml"
DEFINITION BASE_860026421 1
DEFINITION MILEURODR_860026421 110
DEFINITION UTCDR_860026421 100
DEFINITION RES_CODCIR_860026421 3
DEFINITION RES_CODCIRDR_860026421 5
DEFINITION RES_UNITE_860026421 6
DEFINITION RES_TYPCTR_860026421 2
DEFINITION RES_TYPCOM_860026421 0
DEFINITION UTC_860026421 0
DEFINITION NUMTABSEL_860026421 1
DEFINITION NUMTAB_860026421 1
DEFINITION ZONE_METROPOLE_860026421 7
DEFINITION C_phone_860026421 ";phone-context=+33"
DEFINITION CATEG_860026421 0
DEFINITION CODE_ARTICLE_860026421 3
DEFINITION RES_CCD_860026421 1
DEFINITION C_Inst45S_860026421 "45S"
DEFINITION C_InstACLA_860026421 "ACLA"
DEFINITION C_InstTRAFIC_860026421 "TRAFIC"
DEFINITION C_InstSYMP_860026421 "SYMP"
DEFINITION C_InstCASPER_860026421 "CASPER"
DEFINITION CTR_CPSRI_860026421 17
DEFINITION CTR_CPSLOC_860026421 16
DEFINITION TD_ALICE_860026421 9
DEFINITION C_instALICE_860026421 "ALICE"
REGISTRE ENTIER DATE_GMT_860026421
REGISTRE ENTIER Indicator_860026421
REGISTRE ENTIER RoleNode_860026421
REGISTRE ENTIER erreur_860026421
REGISTRE ENTIER code_rejet_860026421
REGISTRE ENTIER b_IDUS_OPITML_860026421
REGISTRE ENTIER b_DEDE_OPITML_860026421
REGISTRE ENTIER b_EFFICACE_860026421
REGISTRE ENTIER b_FACTURABLE_860026421
REGISTRE ENTIER IDUS_INF_860026421
REGISTRE ENTIER NUMZONE_860026421
REGISTRE ENTIER longueur_860026421
REGISTRE ENTIER HLAHM1_860026421
REGISTRE ENTIER DEDE_INF_860026421
REGISTRE ENTIER Duree_860026421
REGISTRE ENTIER CODCIRDR_860026421
REGISTRE ENTIER CODCIR_860026421
REGISTRE ENTIER TYPCTR_860026421
REGISTRE ENTIER CCD_860026421
REGISTRE ENTIER TYPCOM_860026421
REGISTRE ENTIER res_860026421
REGISTRE ENTIER ICAR_ABS_860026421
REGISTRE ENTIER retour_BNC_860026421
REGISTRE ENTIER vc_860026421
REGISTRE ENTIER UNITE_860026421
REGISTRE ENTIER b_EPORTABILITE_SRP_860026421
REGISTRE ENTIER b_SPORTABILITE_SRP_860026421
REGISTRE ENTIER b_EPORTABILITE_SCP_860026421
REGISTRE ENTIER b_SPORTABILITE_SCP_860026421
REGISTRE ENTIER CCD_REEL_860026421
REGISTRE ENTIER b_Emessage_IP_860026421
REGISTRE ENTIER b_REJET1_860026421
REGISTRE ENTIER b_REJET2_860026421
REGISTRE ENTIER b_REJET3_860026421
REGISTRE ENTIER b_REJET5_860026421
REGISTRE ENTIER b_IDUS_INF_NAT_860026421
REGISTRE ENTIER b_IDUS_INF_INTER_860026421
REGISTRE ENTIER b_DEDE_INF_NAT_860026421
REGISTRE ENTIER b_DEDE_INF_INTER_860026421
REGISTRE ENTIER b_DEDE_INF_SPE_860026421
REGISTRE ENTIER b_IDUS_redirectNb_860026421
REGISTRE ENTIER b_IDUS_callingNb_860026421
REGISTRE ENTIER b_DISTRI_TRAFIC_860026421
REGISTRE ENTIER CPT_RDT_860026421
REGISTRE ENTIER b_REDIST_860026421
REGISTRE ENTIER flag_TRAFIC_860026421
REGISTRE ENTIER instTRAFIC_860026421
REGISTRE ENTIER instSYMP_860026421
REGISTRE ENTIER instCASPER_860026421
REGISTRE ENTIER inst45S_860026421
REGISTRE ENTIER instACLA_860026421
REGISTRE ENTIER b_SRP_TIERS_PTD_860026421
REGISTRE ENTIER b_118_TIERS_PTD_860026421
REGISTRE ENTIER long_IDUS_NUM_DCB_860026421
REGISTRE ENTIER b_Fact_CPS_Loc_860026421
REGISTRE ENTIER b_Fact_CPS_RI_860026421
REGISTRE ENTIER b_Fact_CPS_Act_860026421
REGISTRE ENTIER b_ALICE_860026421
REGISTRE ENTIER instALICE_860026421
REGISTRE ENTIER date_table_860026421
REGISTRE ENTIER code_errone_860026421
REGISTRE POINTEUR pt_IDUS_SELECT_860026421
REGISTRE POINTEUR pt_IDUS_NUM_860026421
REGISTRE POINTEUR pt_IDUS_NUM_BNC_860026421
REGISTRE POINTEUR pt_DEDE_NUM_FAC_860026421
REGISTRE POINTEUR pt_IDUS_NUM_DCB_860026421
REGISTRE POINTEUR pt_DEDE_SELECT_860026421
REGISTRE POINTEUR pt_DEDE_NUM_860026421
REGISTRE POINTEUR pt_DEDE_INF_860026421
REGISTRE POINTEUR pt_Info7_860026421
REGISTRE POINTEUR pt_BUF1_860026421
REGISTRE POINTEUR pt_temp_860026421
REGISTRE POINTEUR pt_EccFact_860026421
REGISTRE POINTEUR pt_sgtqs_860026421
REGISTRE POINTEUR pt_CODESRP_860026421
REGISTRE POINTEUR pt_CODESCP_860026421
REGISTRE POINTEUR pt_debChamp1_860026421
REGISTRE POINTEUR pt_Num_860026421
REGISTRE POINTEUR pt_message_860026421
REGISTRE POINTEUR pt_Z_860026421
REGISTRE POINTEUR pt_ZABx_860026421
REGISTRE POINTEUR pt_InfoCompl_860026421
REGISTRE POINTEUR pt_inst_860026421
REGISTRE POINTEUR pt_datCPLUSS_860026421
REGISTRE POINTEUR pt_TARIF_860026421
REGISTRE POINTEUR pt_EDIT_860026421
REGISTRE POINTEUR pt_LIBELREDIST_860026421
#####################################################################
# DISTRIBUTION Topitml : DC de facturation transmises par la PF CGW-IMS
#####################################################################
# En entree :
#    Article : Topitml
#
# En sortie :
#		TRAFIC		- g_iartout2	- TtraficN
#		SYMPH		- g_iartout6	- TsymTopitml
#		CASPER 		- g_iartout3	- TcasperTopitml
#
#		ERRONNE		- g_iartout8
#		Conversion	- g_iartout10
#
#	HISTORIQUE
# 11/08/11 - RHE - G3R22 Creation
# 22/08/11 - DRE - G3R22 QC511 Evolution spec: OPITML_SOF2.doc
# 06/09/11 - DRE - G3R22 QC512 Modif NUMDEDE de facturation pour appli Trafic
# 16/11/2011 - THE - G3R22C5 QC546 Normalisation Ddeur (Z= 6,7,8,9 )
# 01/12/2011 - THE DRE - G3R22 QC554 normalisation DEDE_INF
# 23/01/2012 - THE - VerifPcode
# 21/03/2012 - DRE - G3R24 : nouveau palier tarifaire 0898PQ : SRP Tiers Deterministe
# 11/02/2013 - DRE - G4R02 : QC677, rechercher SCP-SRP uniquement si Dde non international
# 25/02/2013 - DRE - G4R02 : Reprise QC677 (OPITML_S3F1.doc) utilisation de la nature du demande au lieu du CCD pour filtrer l'acces a ACLA et 45S
# 25/04/2013 - DRE - G4R02 : QC718 Correction calcul longueur pt_IDUS_NUM_DCB
# 30/08/2013 - DRE - G4R3C5 QC744 : Conversion %23 en # avant suppression
# 17/12/2013 - DRE - G4R5 QC772 Suppression des caracteres a partir de ";" au lieu de ";phone-context=+33"
# 27/03/2014 - THE - G4R6 Lot2  Creation C+S 
# 24/06/2014 - THE - G4R7 Lot1 ##### Appel ACLA avec tous les dde
# 25/07/2014 - THE - #G4R7 Lot3 QC834 envoi en redist si IC ALICE vide
#
############################################################################################

#G4R6 Lot2 


#########################################################
# Variables fonctionnelles
# DRE G3R24
#G3R24
# 25/04/2013 - DRE - G4R02 : QC718 Correction calcul longueur pt_IDUS_NUM_DCB
#G4R6 Lot2 


#########################################################
# DECLARATION POINTEUR
#G4R6 Lot2 


#########################################################
#Affectation
pt_IDUS_SELECT_860026421 	= "pt_IDUS_SELECT012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
pt_IDUS_NUM_860026421 	= "pt_IDUS_NUM000012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
pt_IDUS_NUM_BNC_860026421	= "pt_IDUS_NUM_BNC12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
pt_DEDE_NUM_FAC_860026421	= "pt_DEDE_NUM_FAC08888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888"
pt_IDUS_NUM_DCB_860026421 = "pt_IDUS_NUM_DCB12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
pt_DEDE_SELECT_860026421 	= "pt_DEDE_SELECT012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
pt_DEDE_NUM_860026421	= "pt_DEDE_NUM000012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
pt_DEDE_INF_860026421 	= "pt_DEDE_INF0123456789"
pt_Info7_860026421	= "pt_Info71234567890"
pt_BUF1_860026421		= "pt_BUF01010101012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
pt_temp_860026421		= "pt_temp0101010012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
pt_EccFact_860026421	= "pt_EccFact17617617617616176176"
pt_sgtqs_860026421	= "pt_sgtqs7777777497507597407694876"
pt_CODESRP_860026421	= "pt_CODESRP91791791791917917917917917917917917"
pt_CODESCP_860026421	= "pt_CODESCP32132132132132132132132132132132113"
pt_debChamp1_860026421	= "pt_debChamp179797979797979797979797979797979797979797979797979797979797979797979797979797"
pt_Num_860026421		= "pt_Num325999999999123459999123459999999991234599991234599999999912345999912345999999999123459999123459999999991234599991234599999999912345999912345999999999123459999123459999999991234599991234599999999912345999912345999999999123459999123459999999991234599991234\
99991234599999999912345999912345999999999123459999123459999999991234599991234599999999912345999912345999999999123459999123459999999991234599991234599999999912345999912345999999999123459999123459999999991234599991234599999999912345999912345999999999123459999123555555554"
pt_message_860026421 	= "pt_message01234567890123456789012345678901234567890123456789012345678901234567890123456789"
pt_Z_860026421		= "pt_Z0123456789"
pt_ZABx_860026421		= "pt_ZABx0123456789"
pt_InfoCompl_860026421	= "pt_InfoCompl0123456789"
pt_inst_860026421		= "pt_inst0123456789"
#G4R6 Lot2 
pt_datCPLUSS_860026421 = "pt_datCPLUSS98765432109876543210"
pt_TARIF_860026421 = "pt_TARIF0123456789"
pt_EDIT_860026421 = "pt_EDIT0123456789"
pt_LIBELREDIST_860026421 = "pt_LIBELREDIST0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"


#########################################################
# Initialisation
Indicator_860026421	= -1
RoleNode_860026421	= -1
erreur_860026421		= 0
code_rejet_860026421	= 0
b_IDUS_OPITML_860026421	= 0
b_DEDE_OPITML_860026421	= 0
b_EFFICACE_860026421	= 0
b_FACTURABLE_860026421	= 0
IDUS_INF_860026421	= 0
NUMZONE_860026421		= -1
longueur_860026421	= 0
DATE_GMT_860026421	= 0
HLAHM1_860026421		= -1
DEDE_INF_860026421	= 0
Duree_860026421		= -1
res_860026421		= 0
ICAR_ABS_860026421	= 0
retour_BNC_860026421	= 0
vc_860026421		= 0
UNITE_860026421		= -1
b_EPORTABILITE_SRP_860026421 = 0
b_SPORTABILITE_SRP_860026421 = 0
b_EPORTABILITE_SCP_860026421 = 0
b_SPORTABILITE_SCP_860026421 = 0
b_Emessage_IP_860026421 	= 0
b_REJET1_860026421 	= 0
b_REJET2_860026421 	= 0
b_REJET3_860026421 	= 0
b_REJET5_860026421 	= 0
b_DEDE_INF_NAT_860026421 	= 0
b_DEDE_INF_INTER_860026421 = 0
b_DEDE_INF_SPE_860026421 = 0
b_IDUS_INF_NAT_860026421 = 0
b_IDUS_INF_INTER_860026421 = 0
b_IDUS_redirectNb_860026421 = 0
b_IDUS_callingNb_860026421 = 0
b_DISTRI_TRAFIC_860026421 = 0
CPT_RDT_860026421 	= 0
b_REDIST_860026421 	= 0
flag_TRAFIC_860026421 	= 0
instTRAFIC_860026421	= -1
instSYMP_860026421	= -1
instCASPER_860026421	= -1
# 25/04/2013 - DRE - G4R02 : QC718 Correction calcul longueur pt_IDUS_NUM_DCB
long_IDUS_NUM_DCB_860026421 = 0
#G4R6 Lot2 
b_Fact_CPS_Act_860026421 = 0
b_Fact_CPS_Loc_860026421 = 0
b_Fact_CPS_RI_860026421 = 0
b_ALICE_860026421 = 0
date_table_860026421 = 0


#########################################################
i_strcpy (pt_Info7_860026421,"" )
i_strcpy (pt_BUF1_860026421,"")
i_strcpy (pt_IDUS_NUM_860026421,"")
i_strcpy (pt_DEDE_NUM_860026421,"")
i_strcpy (pt_temp_860026421,"")
i_strcpy (pt_sgtqs_860026421,"")
i_strcpy (pt_EccFact_860026421,"")
i_strcpy (pt_CODESRP_860026421,"")
i_strcpy (pt_CODESCP_860026421,"")
i_strcpy (pt_debChamp1_860026421,"")
i_strcpy (pt_Num_860026421,"")
i_strcpy (pt_DEDE_INF_860026421,"")
i_strcpy (pt_message_860026421,"")
i_strcpy (pt_DEDE_SELECT_860026421,"")
i_strcpy (pt_IDUS_NUM_DCB_860026421,"")
i_strcpy (pt_IDUS_SELECT_860026421,"")
i_strcpy (pt_IDUS_NUM_BNC_860026421,"")
i_strcpy (pt_Z_860026421,"")
i_strcpy (pt_ZABx_860026421,"")
i_strcpy (pt_InfoCompl_860026421,"")
i_strcpy (pt_inst_860026421,"")
#DRE - QC511
i_strcpy (pt_DEDE_NUM_FAC_860026421,"")
#G4R6 Lot2 
i_strcpy (pt_datCPLUSS_860026421,"")
i_strcpy(pt_TARIF_860026421,"    ")
i_strcpy(pt_EDIT_860026421," ")
i_strcpy(pt_LIBELREDIST_860026421," ")


###########################################################################################
#============================================================
trace("## Debut Distribution -  [ __FILE__ ] ")
#============================================================

# Creation  article Conversion
erreur_860026421 = i_cree_art("Conversion",g_iartout10)

# SGTQS
i_strcpy(pt_sgtqs_860026421, i_LireEECSGTQS(g_ieec))

# CPT_RDT (nb de passage en redistribution)
CPT_RDT_860026421 = -1
CPT_RDT_860026421 = i_LireRedistCpt()
#trace1(" ============= Nb de passage en redistribution CPT_RDT = <%d> ===",CPT_RDT)

#====================================
# Variables fonctionnelles globales
#====================================

# b_IDUS_OPITML
# b_DEDE_OPITML
# 	champ RoleNode	RoleNode = 0 appel sortant (ORIGINATING) -> b_IDUS_OPITML = 1
# 			RoleNode = 1 appel entrant (TERMINATING) -> b_DEDE_OPITML = 1
RoleNode_860026421 = i_get_art_field(g_iartin, $Topitml::RoleNode)
SI (RoleNode_860026421 == 0)
ALORS
	b_IDUS_OPITML_860026421 = 1
SINON
	SI (RoleNode_860026421 == 1)
	ALORS
		b_DEDE_OPITML_860026421 = 1
	FINSI
FINSI
#trace1 ("__LINE__ ##  (ORIGINATING) b_IDUS_OPITML = %d ==========",b_IDUS_OPITML)
#trace1 ("__LINE__ ##  (TERMINATING) b_DEDE_OPITML = %d ==========",b_DEDE_OPITML)

# b_EFFICACE
SI (i_valid_field_n(g_iartin,$Topitml::AnswerIndicator))
ALORS
	Indicator_860026421 = i_get_art_field(g_iartin, $Topitml::AnswerIndicator)
	SI (Indicator_860026421 == 0x00 || Indicator_860026421 == 0x02)
	ALORS
		SI (i_valid_field_n(g_iartin, $Topitml::CallDuration))
		ALORS
			Duree_860026421 = i_get_art_field(g_iartin, $Topitml::CallDuration)
			SI (Duree_860026421 > 0x00)
			ALORS
				SI (i_valid_field_n(g_iartin, $Topitml::CORLStatus))
				ALORS
					erreur_860026421 = i_get_art_str(g_iartin,$Topitml::CORLStatus,pt_Info7_860026421)
					SI (i_strcmp(pt_Info7_860026421,"6") != 0)
					ALORS
						b_EFFICACE_860026421 = 1
					FINSI
				FINSI
			FINSI
		FINSI
	FINSI
FINSI
#trace1 ("__LINE__ ##  b_EFFICACE = %d ==========",b_EFFICACE)


# IDUS_SELECT
# b_IDUS_redirectNb
# b_IDUS_callingNb
#	T3ComputeInfo06 -> NDI
#	T3SvcSpecInfo1 -> T4RedirecNb01 -> RedirecNb
#	T3CallingNb -> T4CallingPart02 -> CallingPart02
#	T3Computeinfo05 -> Computeinfo05
SI (b_IDUS_OPITML_860026421 == 1)
ALORS
	SI (i_valid_field_n(g_iartin, $Topitml::NDI))
	ALORS
		erreur_860026421 = i_get_art_str(g_iartin,$Topitml::NDI,pt_IDUS_SELECT_860026421)
		#trace2("__LINE__ ##  [b_IDUS_OPITML] pt_IDUS_SELECT -> NDI = %s =============", pt_IDUS_SELECT,"")
	SINON
		SI (i_valid_field_n(g_iartin, $Topitml::RedirecNb))
		ALORS
			erreur_860026421 = i_get_art_str(g_iartin,$Topitml::RedirecNb,pt_IDUS_SELECT_860026421)
			#trace2("__LINE__ ##  [b_IDUS_OPITML] pt_IDUS_SELECT -> RedirecNb = %s =============", pt_IDUS_SELECT,"")
			b_IDUS_redirectNb_860026421 = 1
		SINON
			SI (i_valid_field_n(g_iartin, $Topitml::CallingPart02))
			ALORS
				erreur_860026421 = i_get_art_str(g_iartin,$Topitml::CallingPart02,pt_IDUS_SELECT_860026421)
				#trace2("__LINE__ ##  [b_IDUS_OPITML] pt_IDUS_SELECT -> CallingPart02 = %s =============", pt_IDUS_SELECT,"")
			SINON
				SI (i_valid_field_n(g_iartin, $Topitml::Computeinfo05))
				ALORS
					erreur_860026421 = i_get_art_str(g_iartin,$Topitml::Computeinfo05,pt_IDUS_SELECT_860026421)
					#trace2("__LINE__ ##  [b_IDUS_OPITML] pt_IDUS_SELECT -> Computeinfo05 = %s =============", pt_IDUS_SELECT,"")
					b_IDUS_callingNb_860026421 = 1
				FINSI
			FINSI
		FINSI
	FINSI
SINON
	SI (b_DEDE_OPITML_860026421 == 1)
	ALORS
		SI (i_valid_field_n(g_iartin, $Topitml::RedirecNb))
		ALORS
			erreur_860026421 = i_get_art_str(g_iartin,$Topitml::RedirecNb,pt_IDUS_SELECT_860026421)
			#trace2("__LINE__ ##  [b_DEDE_OPITML] pt_IDUS_SELECT -> RedirecNb = %s =============", pt_IDUS_SELECT,"")
		SINON
			SI (i_valid_field_n(g_iartin, $Topitml::CallingPart02))
			ALORS
				erreur_860026421 = i_get_art_str(g_iartin,$Topitml::CallingPart02,pt_IDUS_SELECT_860026421)
				#trace2("__LINE__ ##  [b_DEDE_OPITML] pt_IDUS_SELECT -> CallingPart02 = %s =============", pt_IDUS_SELECT,"")
			SINON
				SI (i_valid_field_n(g_iartin, $Topitml::Computeinfo05))
				ALORS
					erreur_860026421 = i_get_art_str(g_iartin,$Topitml::Computeinfo05,pt_IDUS_SELECT_860026421)
					#trace2("__LINE__ ##  [b_DEDE_OPITML] pt_IDUS_SELECT -> Computeinfo05 = %s =============", pt_IDUS_SELECT,"")
				FINSI
			FINSI
		FINSI
	FINSI
FINSI

# IDUS_NUM
# IDUS_INF
# b_IDUS_INF_NAT
# b_IDUS_INF_INTER
# IDUS_NUM_BNC
SI (i_strcmp("", pt_IDUS_SELECT_860026421) != 0)
ALORS
	longueur_860026421 = i_strlen(pt_IDUS_SELECT_860026421)
	erreur_860026421 = i_recupererValeur(pt_IDUS_SELECT_860026421, pt_IDUS_NUM_860026421,longueur_860026421, '@')
	#trace1("__LINE__ ##  longueur pt_IDUS_SELECT    = %d =======", longueur)
	#trace2("__LINE__ ##  pt_IDUS_SELECT = %s ======= pt_IDUS_NUM = %s ====", pt_IDUS_SELECT, pt_IDUS_NUM)

	SI (i_strplcmp(pt_IDUS_NUM_860026421,"sip:",0,4) == 0 || i_strplcmp(pt_IDUS_NUM_860026421,"tel:",0,4) == 0 )
	ALORS
		i_get_sub_str(pt_IDUS_NUM_860026421, 4,-1, pt_IDUS_NUM_860026421)
	FINSI

	SI (i_strplcmp(pt_IDUS_NUM_860026421,"+",0,1) == 0)
	ALORS
		i_get_sub_str(pt_IDUS_NUM_860026421, 1,-1, pt_IDUS_NUM_860026421)
	FINSI

	SI (i_strplcmp(pt_IDUS_NUM_860026421,"33",0,2)==0)
	ALORS
		i_get_sub_str(pt_IDUS_NUM_860026421, 2,-1, pt_IDUS_NUM_860026421)
		IDUS_INF_860026421 = 0x80
		b_IDUS_INF_NAT_860026421 = 1
	SINON
		SI ( i_strplcmp(pt_IDUS_NUM_860026421,"262",res_860026421,3) == 0 || i_strplcmp(pt_IDUS_NUM_860026421,"269",res_860026421,3) == 0 
		  || i_strplcmp(pt_IDUS_NUM_860026421,"590",res_860026421,3) == 0 || i_strplcmp(pt_IDUS_NUM_860026421,"594",res_860026421,3) == 0 
		  || i_strplcmp(pt_IDUS_NUM_860026421,"596",res_860026421,3) == 0 || i_strplcmp(pt_IDUS_NUM_860026421,"508",res_860026421,3) == 0 )
		ALORS
			i_get_sub_str(pt_IDUS_NUM_860026421, 3,-1, pt_IDUS_NUM_860026421)
			IDUS_INF_860026421 = 0x80
			b_IDUS_INF_NAT_860026421 = 1
		SINON
			IDUS_INF_860026421 = 0xC0
			b_IDUS_INF_INTER_860026421 = 1
		FINSI
	FINSI
# 25/04/2013 - DRE - G4R02 : QC718 Correction calcul longueur pt_IDUS_NUM_DCB
#	longueur = i_conv_ascii_dcb(pt_IDUS_NUM, pt_IDUS_NUM_DCB)
	long_IDUS_NUM_DCB_860026421 = i_conv_ascii_dcb(pt_IDUS_NUM_860026421, pt_IDUS_NUM_DCB_860026421)
FINSI

# b_FACTURABLE     G3R22C5 QC546
SI (b_EFFICACE_860026421 && b_IDUS_OPITML_860026421 && b_IDUS_INF_NAT_860026421)
ALORS
	b_FACTURABLE_860026421 = 1
FINSI
#trace1("__LINE__ ##  b_FACTURABLE = %d =======", b_FACTURABLE)

# IDUS_NUM_BNC (Normalisation du demandeur)
# G3R22C5 QC546
i_get_sub_str(pt_IDUS_NUM_860026421, 0, 0, pt_Z_860026421)
SI (IDUS_INF_860026421 == 0x80)
ALORS
	SI ( i_strcmp("0", pt_Z_860026421) == 0 || i_strcmp("6", pt_Z_860026421) == 0 || i_strcmp("7", pt_Z_860026421) == 0 
	  || i_strcmp("8", pt_Z_860026421) == 0 || i_strcmp("9", pt_Z_860026421) == 0 )
	ALORS
		SI b_FACTURABLE_860026421
		ALORS
			#trace("__LINE__ ##  erreur de normalisateur du demandeur")
			erreur_860026421 = i_format_str2(pt_BUF1_860026421,"%s%s","Erreur de normalisateur du demandeur : ",pt_IDUS_NUM_860026421)
			code_rejet_860026421 = 0xA011
			erreur_860026421 = i_PlvMessEmettre(8612,2,g_iartin,"",3,code_rejet_860026421,C_Article_860026421,pt_BUF1_860026421)
			SAUT DISTRI_ERR
		SINON
			erreur_860026421 = i_format_str2(pt_IDUS_NUM_BNC_860026421,"%s%s","0*",pt_IDUS_NUM_860026421)
		FINSI
	FINSI

	SI ( i_strcmp("1", pt_Z_860026421) == 0 || i_strcmp("2", pt_Z_860026421) == 0 || i_strcmp("3", pt_Z_860026421) == 0 
	  || i_strcmp("4", pt_Z_860026421) == 0 || i_strcmp("5", pt_Z_860026421) == 0 )
	ALORS
		erreur_860026421 = i_format_str2(pt_IDUS_NUM_BNC_860026421,"%s%s","0",pt_IDUS_NUM_860026421)
	FINSI

	i_get_sub_str(pt_IDUS_NUM_860026421, 0, 3, pt_ZABx_860026421)
	SI ( i_strcmp(pt_ZABx_860026421,"9760") == 0 || i_strcmp(pt_ZABx_860026421,"9761") == 0 || i_strcmp(pt_ZABx_860026421,"9762") == 0 
	  || i_strcmp(pt_ZABx_860026421,"9763") == 0 || i_strcmp(pt_ZABx_860026421,"9764") == 0 || i_strcmp(pt_ZABx_860026421,"9765") == 0 
	  || i_strcmp(pt_ZABx_860026421,"9766") == 0 || i_strcmp(pt_ZABx_860026421,"9767") == 0 || i_strcmp(pt_ZABx_860026421,"9768") == 0 )
	ALORS
		erreur_860026421 = i_format_str2(pt_IDUS_NUM_BNC_860026421, "%s%s", "0*", pt_ZABx_860026421)
	FINSI
FINSI

SI (IDUS_INF_860026421 == 0xC0)
ALORS
	i_strcpy(pt_IDUS_NUM_BNC_860026421, pt_IDUS_NUM_860026421)
FINSI

longueur_860026421 = i_strlen(pt_IDUS_NUM_BNC_860026421)
SI longueur_860026421 > 10
ALORS
	i_get_sub_str(pt_IDUS_NUM_BNC_860026421,0,9,pt_IDUS_NUM_BNC_860026421)
	erreur_860026421 = i_memcpy_art_field_n(g_icopo, $Tcopo::NDR, pt_IDUS_NUM_BNC_860026421, 11)
SINON
	erreur_860026421 = i_memcpy_art_field_n(g_icopo, $Tcopo::NDR, pt_IDUS_NUM_BNC_860026421, longueur_860026421+1)
FINSI

#trace1("__LINE__ ##  IDUS_INF			= %d =======", IDUS_INF)
#trace1("__LINE__ ##  b_IDUS_INF_NAT	= %d =======", b_IDUS_INF_NAT)
#trace1("__LINE__ ##  b_IDUS_INF_INTER	= %d =======", b_IDUS_INF_INTER)
#trace2("__LINE__ ##  pt_IDUS_NUM = %s  = %s ====", pt_IDUS_NUM, "")
#trace2("__LINE__ ##  pt_IDUS_NUM_BNC = %s ===========", pt_IDUS_NUM_BNC,"")

# b_FACTURABLE     G3R22C5 QC546

# Controles croises entre champs connus du DC
SI (b_FACTURABLE_860026421)
ALORS
	SI (!i_valid_field_n(g_iartin, $Topitml::NDI))
	ALORS
		i_strcpy (pt_message_860026421,"champ NDI absent")
		code_rejet_860026421 = 0xA041
		erreur_860026421 = i_PlvMessEmettre(7306,2,g_iartin,"",3,code_rejet_860026421,C_Article_860026421,pt_message_860026421)
		#trace2("__LINE__ ##  Controles croises entre champs connus du DC:  %s =============", pt_message,"")
		SAUT DISTRI_ERR
	FINSI

	SI ( !i_valid_field_n(g_iartin, $Topitml::DialledDigits) && !i_valid_field_n(g_iartin,$Topitml::AsCalledPartyAd))
	ALORS
		i_strcpy (pt_message_860026421,"champs DialledDigits et AsCalledPartyAd absents")
		code_rejet_860026421 = 0xA041
		erreur_860026421 = i_PlvMessEmettre(7306,2,g_iartin,"",3,code_rejet_860026421,C_Article_860026421,pt_message_860026421)
		#trace2("__LINE__ ##  Controles croises entre champs connus du DC:  %s =============", pt_message,"")
		SAUT DISTRI_ERR
	FINSI

	SI (!i_valid_field_n(g_iartin,$Topitml::CallDuration))
	ALORS
		i_strcpy (pt_message_860026421,"champ CallDuration absent")
		code_rejet_860026421 = 0xA041
		erreur_860026421 = i_PlvMessEmettre(7306,2,g_iartin,"",3,code_rejet_860026421,C_Article_860026421,pt_message_860026421)
		#trace2("__LINE__ ##  Controles croises entre champs connus du DC:  %s =============", pt_message,"")
		SAUT DISTRI_ERR
	FINSI
FINSI

# DEDE_SELECT
#	T3dialleD ->DialledDigits
#	T3Computeinfo04 -> AsCalledPartyAd
#	T3ComputeInfo06 -> NDI
SI (b_IDUS_OPITML_860026421 == 1)
ALORS
	SI (i_valid_field_n(g_iartin, $Topitml::DialledDigits))
	ALORS
		erreur_860026421 = i_get_art_str(g_iartin,$Topitml::DialledDigits,pt_DEDE_SELECT_860026421)
		#trace2("__LINE__ ##  [b_IDUS_OPITML] pt_DEDE_SELECT -> DialledDigits = %s =============", pt_DEDE_SELECT,"")
	SINON
		SI (i_valid_field_n(g_iartin, $Topitml::AsCalledPartyAd))
		ALORS
			erreur_860026421 = i_get_art_str(g_iartin,$Topitml::AsCalledPartyAd,pt_DEDE_SELECT_860026421)
			#trace2("__LINE__ ##  [b_IDUS_OPITML] pt_DEDE_SELECT -> AsCalledPartyAd (Computeinfo04) = %s =============", pt_DEDE_SELECT,"")
		FINSI
	FINSI
SINON
	SI (b_DEDE_OPITML_860026421 == 1)
	ALORS
		SI (i_valid_field_n(g_iartin, $Topitml::NDI))
		ALORS
			erreur_860026421 = i_get_art_str(g_iartin,$Topitml::NDI,pt_DEDE_SELECT_860026421)
			#trace2("__LINE__ ##  [b_IDUS_OPITML] pt_DEDE_SELECT -> NDI = %s =============", pt_DEDE_SELECT,"")
		FINSI
	FINSI
FINSI

# DEDE_NUM
# DEDE_INF
# b_DEDE_INF_NAT
# b_DEDE_INF_INTER
# b_DEDE_INF_SPEC
# DEDE_NUM_BNC
i_strcpy (pt_DEDE_NUM_860026421,"")
SI (i_strcmp("", pt_DEDE_SELECT_860026421) != 0)
ALORS
	longueur_860026421 = i_strlen(pt_DEDE_SELECT_860026421)

	# suppression des caracteres a partir de '@'
	erreur_860026421 = i_recupererValeur(pt_DEDE_SELECT_860026421, pt_DEDE_NUM_860026421,longueur_860026421, '@')
	#trace1("__LINE__ ##  longueur pt_DEDE_SELECT     = %d =======", longueur)
	#trace2("__LINE__ ##  pt_DEDE_SELECT = %s ======= pt_DEDE_NUM = %s ====", pt_DEDE_SELECT, pt_DEDE_NUM)

	# suppression de 'sip:' ou 'tel:'
	SI (i_strplcmp(pt_DEDE_NUM_860026421,"sip:",0,4) == 0) || (i_strplcmp(pt_DEDE_NUM_860026421,"tel:",0,4) == 0)
	ALORS
		i_get_sub_str(pt_DEDE_NUM_860026421, 4, -1, pt_DEDE_NUM_860026421)
	FINSI
	# suppression de '847'
	SI (i_strplcmp(pt_DEDE_NUM_860026421,"847", 0, 3) == 0)
	ALORS
		i_get_sub_str(pt_DEDE_NUM_860026421, 3, -1, pt_DEDE_NUM_860026421)
	FINSI

#G4R5 QC772 
	## suppression de la chaine C_phone
	#i_strcpy(pt_DEDE_NUM,REMPLACE_CHAINE(pt_DEDE_NUM, C_phone, ""))

	# Si ? ; ? present, suppression des caracteres a partir de ? ; ?
	i_strcpy (pt_temp_860026421,pt_DEDE_NUM_860026421)
	erreur_860026421 = i_recupererValeur(pt_temp_860026421, pt_DEDE_NUM_860026421, i_strlen(pt_temp_860026421),';')
#\G4R5 QC772



# DRE QC744 Conversion avant suppression
	# remplacement de %23 par #
	erreur_860026421 = i_adequation_chaine_expreg (pt_DEDE_NUM_860026421, "%23")
	#trace1("__LINE__ ##  ******** erreur = %x ******** ",erreur)
	SI erreur_860026421 == 0
	ALORS
		i_strcpy(pt_DEDE_NUM_860026421,REMPLACE_CHAINE_860026233(pt_DEDE_NUM_860026421,"%23","#"))
	FINSI

	# suppression du '#' final
	i_get_sub_str(pt_DEDE_NUM_860026421, -1, -1, pt_temp_860026421)
	SI i_strcmp(pt_temp_860026421, "#") == 0
	ALORS
		i_get_sub_str(pt_DEDE_NUM_860026421, 0, -2, pt_DEDE_NUM_860026421)
	FINSI

#	# remplacement de %23 par #
#	erreur = i_adequation_chaine_expreg (pt_DEDE_NUM, "%23")
#	#trace1("__LINE__ ##  ******** erreur = %x ******** ",erreur)
#
#	SI erreur == 0
#	ALORS
#		i_strcpy(pt_DEDE_NUM,REMPLACE_CHAINE(pt_DEDE_NUM,"%23","#"))
#	FINSI

	#Remplacer * par B et # par C
	i_replace_str(pt_DEDE_NUM_860026421,"*#","BC",pt_DEDE_NUM_860026421)

	# conversion DEDE_NUM ascii en DCB
	#longueur = i_conv_ascii_dcb(pt_DEDE_NUM, pt_IDUS_DEDE_DCB)
FINSI

########################################################################
#DEDE_INTERNAT
########################################################################
SI ( i_strplcmp(pt_DEDE_NUM_860026421,"+",0,1) == 0 )
ALORS
	SI ( i_strplcmp(pt_DEDE_NUM_860026421,"33",1,2) != 0 && i_strplcmp(pt_DEDE_NUM_860026421,"262",1,3) != 0
	  && i_strplcmp(pt_DEDE_NUM_860026421,"594",1,3) != 0 && i_strplcmp(pt_DEDE_NUM_860026421,"596",1,3) != 0
	  && i_strplcmp(pt_DEDE_NUM_860026421,"590",1,3) != 0 && i_strplcmp(pt_DEDE_NUM_860026421,"508",1,3) != 0
	  && i_strplcmp(pt_DEDE_NUM_860026421,"2696",1,4) != 0 && i_strplcmp(pt_DEDE_NUM_860026421,"2692",1,4) != 0 )
	ALORS
		b_DEDE_INF_INTER_860026421 = 1
	FINSI
FINSI

SI (i_strplcmp(pt_DEDE_NUM_860026421,"00",0,2) == 0 )
ALORS
	SI ( i_strplcmp(pt_DEDE_NUM_860026421,"33",2,2) != 0 && i_strplcmp(pt_DEDE_NUM_860026421,"262",2,3) != 0
	  && i_strplcmp(pt_DEDE_NUM_860026421,"594",2,3) != 0 && i_strplcmp(pt_DEDE_NUM_860026421,"596",2,3) != 0
	  && i_strplcmp(pt_DEDE_NUM_860026421,"590",2,3) != 0 && i_strplcmp(pt_DEDE_NUM_860026421,"508",2,3) != 0
	  && i_strplcmp(pt_DEDE_NUM_860026421,"2696",2,4) != 0 && i_strplcmp(pt_DEDE_NUM_860026421,"2692",2,4) != 0 )
	ALORS
		b_DEDE_INF_INTER_860026421 = 1
	FINSI
FINSI


########################################################################
#Modification DEDE_NUM
########################################################################
SI (i_strplcmp(pt_DEDE_NUM_860026421, "+", 0, 1) == 0)
ALORS
	i_get_sub_str(pt_DEDE_NUM_860026421, 1, -1, pt_DEDE_NUM_860026421)
SINON
	SI (i_strplcmp(pt_DEDE_NUM_860026421, "00", 0, 2) == 0)
	ALORS
		i_get_sub_str(pt_DEDE_NUM_860026421, 2, -1, pt_DEDE_NUM_860026421)
	FINSI
FINSI


SI (i_strplcmp(pt_DEDE_NUM_860026421, "33", 0, 2) == 0)
ALORS
	i_get_sub_str(pt_DEDE_NUM_860026421, 2, -1, pt_DEDE_NUM_860026421)
SINON
	SI ( i_strplcmp(pt_DEDE_NUM_860026421, "262", 0, 3) == 0 || i_strplcmp(pt_DEDE_NUM_860026421, "594", 0, 3) == 0
	  || i_strplcmp(pt_DEDE_NUM_860026421, "596", 0, 3) == 0 || i_strplcmp(pt_DEDE_NUM_860026421, "590", 0, 3) == 0 )
	ALORS
		i_get_sub_str(pt_DEDE_NUM_860026421, 3, -1, pt_DEDE_NUM_860026421)
	FINSI
FINSI

SI b_DEDE_INF_INTER_860026421 != 1
ALORS
	SI (i_strplcmp(pt_DEDE_NUM_860026421,"0",0,1)==0  && i_strplcmp(pt_DEDE_NUM_860026421,"0",1,1) != 0)
	ALORS
		i_get_sub_str(pt_DEDE_NUM_860026421,1,-1,pt_DEDE_NUM_860026421)
	FINSI
FINSI


##############################################################################
# DEDE_INF (0x80: national, 0x40: special, 0xC0: international)
##############################################################################
SI  b_DEDE_INF_INTER_860026421
ALORS
	DEDE_INF_860026421 = 0xC0
	i_strcpy(pt_DEDE_INF_860026421 , "C0")
SINON
	#G3R22 QC554
	SI (i_strcmp("", pt_DEDE_NUM_860026421) != 0)
	ALORS
	#\G3R22 QC554
		SI (i_strlen(pt_DEDE_NUM_860026421)< 7)
		ALORS
			DEDE_INF_860026421 = 0x40
			i_strcpy(pt_DEDE_INF_860026421 , "40")
			b_DEDE_INF_SPE_860026421 = 1
		SINON
			DEDE_INF_860026421 = 0x80
			i_strcpy(pt_DEDE_INF_860026421 , "80")
			b_DEDE_INF_NAT_860026421 = 1
		FINSI
	FINSI
FINSI

##############################################################################
# elimination prefixe 150PQ ou VWXY
##############################################################################
#QC512 DRE
SI (DEDE_INF_860026421 == 0x80)
ALORS
	longueur_860026421 = i_strlen(pt_DEDE_NUM_860026421)
	SI (longueur_860026421 > 9)
	ALORS
		SI (i_strplcmp(pt_DEDE_NUM_860026421, "150", 0, 3) == 0)
		ALORS
			i_get_sub_str(pt_DEDE_NUM_860026421, 5, -1, pt_DEDE_NUM_860026421)
		SINON
			i_get_sub_str(pt_DEDE_NUM_860026421, 4, -1, pt_DEDE_NUM_860026421)
		FINSI
	FINSI
FINSI
#\QC512 DRE

# DATE_GMT (ICAR_UTC)
DATE_GMT_860026421 = i_get_art_field(g_iartin, $Topitml::StartTime_SDATE)

#G4R6 Lot2 TDATCPS
#-----------------------------------------------------------
# DATCPS : Determine si la Tv2oip::DATE est egale ou posteriereure a celle
# retournee par la table TDATCPS
#------------------------------------------------------------
i_strcpy (pt_datCPLUSS_860026421,i_get_tab_field("TDATCPS", DATE_GMT_860026421, "DATCPS"))
erreur_860026421 = i_set_art_str (g_iartout10,$Conversion::DATE_STR,pt_datCPLUSS_860026421)
date_table_860026421 = i_get_art_field(g_iartout10, $Conversion::DATE_ASC)

SI DATE_GMT_860026421 >= date_table_860026421
ALORS
	b_Fact_CPS_Act_860026421 = 1
FINSI

# Metropole (ICAR_METRO)
ICAR_ABS_860026421 = i_DHgetLocalTime(NUMTAB_860026421, ZONE_METROPOLE_860026421, DATE_GMT_860026421)

#  HLAHM1 (ICAR_LOCAL)
SI (IDUS_INF_860026421 == 0x80)
ALORS
	longueur_860026421 = i_conv_ascii_dcb(pt_IDUS_NUM_860026421, pt_BUF1_860026421)
	erreur_860026421 = i_memcpy_art_field_n(g_iartout10, $Conversion::NDR, pt_BUF1_860026421, longueur_860026421)
	NUMZONE_860026421 = i_DHgetZoneID(NUMTABSEL_860026421, g_iartout10)
	HLAHM1_860026421 = i_DHgetLocalTime(NUMTAB_860026421, NUMZONE_860026421, DATE_GMT_860026421)
FINSI

########################################################################
#Normalisation du demande
########################################################################

# G3R22C6 QC554
SI (i_strcmp("", pt_DEDE_NUM_860026421) != 0) 
ALORS
	erreur_860026421 = i_format_str2(pt_Num_860026421,"%s%s",pt_DEDE_INF_860026421,pt_DEDE_NUM_860026421)
	#trace2("<<<<__LINE__ <<<<<############# pt_Num = <%s> ###########################",pt_Num,"")
	longueur_860026421 = i_conv_ascii_dcb(pt_Num_860026421, pt_BUF1_860026421)
	#trace1("######### Longueur pt_Num = <%d> ############ ",longueur)
	erreur_860026421 = i_memcpy_art_field_n(g_iartout10, $Conversion::NOS, pt_BUF1_860026421, longueur_860026421)
	erreur_860026421 = i_normal(g_iartout10, $Conversion::NOS, $Conversion::NOS, g_icopo, $Tcopo::NDE ,$Tcopo::NDE ,3 , "BIDON", "OPIT_NDE")
	erreur_860026421 = i_get_art_str(g_icopo,$Tcopo::NDE,pt_Num_860026421)
	longueur_860026421 = i_conv_ascii_dcb(pt_Num_860026421, pt_BUF1_860026421)

	SI longueur_860026421 > 10
	ALORS
		i_get_sub_str(pt_BUF1_860026421, 0, 9, pt_Num_860026421)
		erreur_860026421 = i_memcpy_art_field_n(g_icopo, $Tcopo::NDE, pt_Num_860026421, 11)
	FINSI

	#QC512 01/09/2011 DRE  suppression du 00 ou du 0
	######## pt_DEDE_NUM_FAC ########
	i_strcpy(pt_DEDE_NUM_FAC_860026421,pt_BUF1_860026421)

	SI (i_strplcmp(pt_DEDE_NUM_FAC_860026421,"00",0,2) == 0 )
	ALORS
		i_get_sub_str(pt_DEDE_NUM_FAC_860026421,2,-1,pt_DEDE_NUM_FAC_860026421)
	SINON
		SI (i_strplcmp(pt_DEDE_NUM_FAC_860026421,"0",0,1) == 0 )
		ALORS
			i_get_sub_str(pt_DEDE_NUM_FAC_860026421,1,-1,pt_DEDE_NUM_FAC_860026421)
		FINSI
	FINSI
FINSI
#\G3R22C6 QC554
#\QC512 DRE

###################
# Appel a la BNC
###################
# critere de valorisation

CODCIRDR_860026421=-1
CODCIR_860026421=-1
TYPCTR_860026421=-1
CCD_860026421 = 0xFF
TYPCOM_860026421 = 0xFF

#trace1("__LINE__ ##  EFFICACE = <%d>", b_EFFICACE)
#trace1("__LINE__ ##  IDUS_INF = <%d>", IDUS_INF)
#trace2("__LINE__ ##  pt_DEDE_NUM = %s", pt_DEDE_NUM, "")

SI ( b_EFFICACE_860026421 == 1 && IDUS_INF_860026421 == 0x80 && i_strcmp(pt_DEDE_NUM_860026421, "") != 0 && ( i_strcmp("0", pt_Z_860026421) != 0 ) )
ALORS
	#trace("__LINE__ ##  Appel a la base de comptage")
	g_icopo.TAXE   = 0
	g_icopo.CREDIT = 0
	erreur_860026421 = i_set_art_date(g_icopo, HLAHM1_860026421)
	g_icopo.DUREE  = Duree_860026421
	g_icopo.CODE   = CODE_ARTICLE_860026421
	g_icopo.CATEG  = CATEG_860026421
	g_icopo.SUP[0] = 0
	g_icopo.SUP[1] = 0
	g_icopo.SUP[2] = 0
	g_icopo.SUP[3] = 0
	g_icopo.SUP[4] = 0
	g_icopo.SUP[5] = 0
	g_icopo.SUP[6] = 0
	g_icopo.SUP[7] = 0

	retour_BNC_860026421 = i_comptage(g_icopo, BASE_860026421, HLAHM1_860026421)

	# Erreur retour base de comptage
	SI (retour_BNC_860026421 == -1 && b_FACTURABLE_860026421)
	ALORS
		#trace1("__LINE__ ##  Erreur retour BNC : erreur = %d", retour_BNC)
		code_rejet_860026421 = 0xA020 + b_EFFICACE_860026421
		erreur_860026421 = i_PlvMessEmettre(8507,2,g_iartin,"",3,code_rejet_860026421,C_Article_860026421,g_ierrno)
		SAUT DISTRI_ERR
	FINSI

	# TYPCOM, CCD, CODCIR, CODCIRDR, vc, UNITE, TYPCTR
	SI retour_BNC_860026421 == 0
	ALORS
		SI (b_FACTURABLE_860026421)
		ALORS
			TYPCOM_860026421 = g_icopo.SUP[RES_TYPCOM_860026421]
		FINSI

		CCD_860026421 = g_icopo.SUP[RES_CCD_860026421]

		CODCIRDR_860026421 = g_icopo.SUP[RES_CODCIRDR_860026421]
		CODCIR_860026421 = g_icopo.SUP[RES_CODCIR_860026421]

		############################################
		# Controle sur l'unite renvoyee par la BNC
		# COEFF=94 MILEURO=10 MILEURODR=110
		# NbUT=vcUT UTC=0 UTCDR=100
		############################################
		vc_860026421 = g_icopo.TAXE
		UNITE_860026421 = g_icopo.SUP[RES_UNITE_860026421]
		SI UNITE_860026421 != UTC_860026421 && UNITE_860026421 != MILEURODR_860026421 && UNITE_860026421 != UTCDR_860026421
		ALORS
			#trace(">>>__LINE__>>> Erreur retour BNC")
			code_rejet_860026421 = 0xA020
			code_rejet_860026421 = code_rejet_860026421 + b_EFFICACE_860026421
			erreur_860026421 = i_PlvMessEmettre(8506,2,g_iartin,"",3,code_rejet_860026421,C_Article_860026421,UNITE_860026421)
			SAUT DISTRI_ERR
		FINSI
		TYPCTR_860026421 = g_icopo.SUP[RES_TYPCTR_860026421]
	FINSI
FINSI

# b_REJET1
# b_REJET2
# b_REJET3
# b_REJET5
SI (TYPCTR_860026421 == 11)
ALORS
	b_REJET1_860026421 = 1
SINON
	SI (TYPCTR_860026421 == 10)
	ALORS
		b_REJET2_860026421 = 1
	SINON
		SI (TYPCTR_860026421 == 12)
		ALORS
			b_REJET3_860026421 = 1
		SINON
			SI (TYPCTR_860026421 == 9)
			ALORS
				b_REJET5_860026421 = 1
			FINSI
		FINSI
	FINSI
FINSI

##########################################################################################################
#G4R6 Lot2 Verif DATE
SI ( TYPCTR_860026421 == CTR_CPSLOC_860026421 || TYPCTR_860026421 == CTR_CPSRI_860026421 ) && !b_Fact_CPS_Act_860026421
ALORS
	# message dalarme AR <DEDE_NUM> C+S avec date DC <ICAR_UTC> inferieure a la date d'activation de la facturation C+S < Date_CPS> 
	erreur_860026421 = i_format_str2(pt_LIBELREDIST_860026421," AR <%s> avec date DC inferieure a la date d'activation <%s> de la facturation CPS",pt_DEDE_NUM_860026421,pt_datCPLUSS_860026421)
	code_errone_860026421 = 0xA080
	code_errone_860026421 = code_errone_860026421 + b_EFFICACE_860026421
	erreur_860026421 = i_PlvMessEmettre( 8599, 1, g_iartin,"", 3,code_errone_860026421, C_Article_860026421, pt_LIBELREDIST_860026421 )
	SAUT ELIMINE_EXP
SINON
	SI TYPCTR_860026421 == CTR_CPSLOC_860026421 && b_Fact_CPS_Act_860026421
	ALORS
		b_Fact_CPS_Loc_860026421 =1
	SINON
		SI TYPCTR_860026421 == CTR_CPSRI_860026421 && b_Fact_CPS_Act_860026421
		ALORS
			b_Fact_CPS_RI_860026421 = 1
		FINSI
	FINSI
FINSI

# b_Emessage_IP
SI (CCD_860026421 == 0x17)
ALORS
	b_Emessage_IP_860026421 = 1
FINSI

# referentiel ACLA
# b_EPORTABILITE_SCP
# b_SPORTABILITE_SCP
#G4R7 Lot1
#i_get_sub_str(pt_DEDE_NUM, 0, 0, pt_debChamp1)
longueur_860026421 = i_strlen(pt_DEDE_NUM_860026421)


#DRE QC677
SI b_DEDE_INF_NAT_860026421 || b_DEDE_INF_SPE_860026421
#SI CCD != CCD_Internat
ALORS
	#SI ( (i_strcmp(pt_debChamp1,"8") == 0 || (i_strcmp(pt_debChamp1,"3") == 0 ) && longueur == 4 ))
	#ALORS
	#G4R7 Lot1
	instACLA_860026421 = i_LireInstanceECC(C_InstACLA_860026421)

	SI (!instACLA_860026421)
	ALORS
		#trace (">>>__LINE__>>> --------Pas d'instance pour ACLA------------------------------")
		code_rejet_860026421 = 0xA0B0
		code_rejet_860026421 = code_rejet_860026421 + b_EFFICACE_860026421
		erreur_860026421   = i_PlvMessEmettre(8601,2,g_iartin,"",3,code_rejet_860026421,C_InstACLA_860026421,C_Article_860026421)
		SAUT DISTRI_ERR
	FINSI
	#trace1(">>>__LINE__>>> -------instACLA=<%d>-----------------------------",instACLA  )
	
	# Envoi Requetes Table de Distribution ACLA
	i_strcpy(pt_BUF1_860026421,pt_DEDE_NUM_860026421)
	#trace2(">>>__LINE__>>> ------ envoi ACLA avec pt_DEDE_NUM= pt_BUF1 <%s>---------",pt_BUF1,"")
	pt_CODESCP_860026421 = CodeOperateurTable6_860026233(DATE_GMT_860026421, pt_BUF1_860026421, "ACLA")
	#trace2(">>>__LINE__>>> ------ resultat de pt_CODESCP : <%s>---------",pt_CODESCP   ,"")

	SI i_strcmp(pt_CODESCP_860026421, "84008") == 0
	ALORS
		#trace(" ACLA pt_CODESCP=84008  EPORTABILITE_SCP   = 1")
		b_EPORTABILITE_SCP_860026421 = 1
	SINON
		SI i_strcmp(pt_CODESCP_860026421  ,"")!= 0
		ALORS
			b_SPORTABILITE_SCP_860026421 = 1
		FINSI
	FINSI
	#FINSI

	# referentiel 45S "SKITEL"
	# b_EPORTABILITE_SRP
	# b_SPORTABILITE_SRP
	inst45S_860026421 = i_LireInstanceECC(C_Inst45S_860026421)
	
	SI (!inst45S_860026421)
	ALORS
		#trace (">>>__LINE__>>> --------Pas d'instance pour 45S------------------------------")
		code_rejet_860026421 = 0xA0B0
		code_rejet_860026421 = code_rejet_860026421 + b_EFFICACE_860026421
		erreur_860026421   = i_PlvMessEmettre(8601,2,g_iartin,"",3,code_rejet_860026421,C_Inst45S_860026421,C_Article_860026421)
		SAUT DISTRI_ERR
	FINSI
	
	# Envoi Requetes Table de Distribution 45S
	i_strcpy(pt_BUF1_860026421,pt_DEDE_NUM_860026421)
	#trace2(">>>__LINE__>>> ------ envoi 45S avec pt_DEDE_NUM= pt_BUF1 <%s>---------",pt_BUF1,"")
	pt_CODESRP_860026421 = CodeOperateurTable6_860026233(DATE_GMT_860026421, pt_BUF1_860026421, "45S")
	#trace2(">>>__LINE__>>> ------ resultat de pt_CODESRP : <%s>---------",pt_CODESRP   ,"")
	
	SI i_strcmp(pt_CODESRP_860026421  , "84208") == 0
	ALORS
		#trace("******** EPORTABILITE_SRP   = 1 car pt_CODESRP  84208")
		b_EPORTABILITE_SRP_860026421 = 1
	SINON
		SI (i_strcmp(pt_CODESRP_860026421, "84208")!=0 && i_strcmp(pt_CODESRP_860026421, "")!=0)
		ALORS
			b_SPORTABILITE_SRP_860026421 = 1
		FINSI
	FINSI
FINSI
#FIN DRE QC677
# DRE G3R24

	## b_PTD (SRP_PTD)
	#b_PTD = 0
	#
	#SI (TYPCOM == 0x4E)
	#ALORS
	#	b_PTD = 1
	#FINSI
	#
	## b_SRP_TIERS_sans_ITX
	#########################################################################
	#b_SRP_TIERS_sans_ITX = 0
	#
	#SI ( CCD == 0x18 ) 
	#&& ( TYPCOM == 0x52 || TYPCOM == 0x58 || TYPCOM == 0x59 || TYPCOM == 0x5A || TYPCOM == 0x5B || TYPCOM == 0x5C )
	#ALORS
	#	b_SRP_TIERS_sans_ITX = 1
	#FINSI
	
##################### b_SRP_TIERS_PTD Calcul du Booleen ##################
b_SRP_TIERS_PTD_860026421 = 0

SI ( (CCD_860026421 == 0x18) && (TYPCTR_860026421 == 3) )
ALORS
	b_SRP_TIERS_PTD_860026421 = 1
FINSI


#################### b_118_TIERS_PTD Calcul du Booleen ####################
b_118_TIERS_PTD_860026421 = 0
SI (CCD_860026421 == 0x1B)
ALORS
	b_118_TIERS_PTD_860026421 = 1
FINSI

# \DRE G3R24

##########################################################################################################
#G4R6 Lot2 Interro Ref ALICE

SI b_Fact_CPS_Loc_860026421
ALORS
	longueur_860026421 = i_conv_ascii_dcb(pt_DEDE_NUM_FAC_860026421, pt_temp_860026421)
	SI ( i_EnvoiReqConsTabDist( TD_ALICE_860026421, DATE_GMT_860026421, pt_temp_860026421, longueur_860026421, 0, 1) != 0 )
	ALORS
		code_errone_860026421 = 0xA0C0
		code_errone_860026421 = code_errone_860026421 + b_EFFICACE_860026421
		erreur_860026421 = i_PlvMessEmettre(8607,2,g_iartin,"",3,code_errone_860026421,C_instALICE_860026421,C_Article_860026421)
		SAUT DISTRI_ERR
	FINSI

	instALICE_860026421 = i_LireInstanceECC(C_instALICE_860026421)

	SI (!instALICE_860026421)
	ALORS
		erreur_860026421 = i_PlvMessEmettre(8501,2, g_iartin, "", 3, "ALICE", C_Article_860026421, g_ieec)
		SAUT DISTRI_ERR
	FINSI

	erreur_860026421 = i_LireReqConsTabDist()

	SI erreur_860026421 == 0
	ALORS
		#erreur = i_LireChaineECCv(instALICE, pt_ECCv)
		#instECCv = i_LireEntierECCv( instALICE )
		res_860026421 = i_LireInfoECC( instALICE_860026421, 0 )

#G4R7 Lot3 QC834
		SI ( res_860026421 != 0)
		ALORS
			# AR present dans ALICE
			erreur_860026421 = i_LireChaineInfo( res_860026421, 0, 4, pt_temp_860026421 )
			SI i_strcmp(pt_temp_860026421, "" ) != 0
			ALORS
				i_strcpy(pt_TARIF_860026421, pt_temp_860026421 )
				b_ALICE_860026421 = 1
			SINON
				# info complementaire CODE_TARIF vide
				b_REDIST_860026421 = 1
				erreur_860026421 = i_format_str2(pt_LIBELREDIST_860026421," AR <%s> trouve dans LAR ALICE mais aucune info complementaire valorisee",pt_DEDE_NUM_860026421,0)
			FINSI
			
			erreur_860026421 = i_LireChaineInfo( res_860026421, 4, 1, pt_temp_860026421 )
			SI i_strcmp(pt_temp_860026421, "" ) != 0
			ALORS
				i_strcpy(pt_EDIT_860026421, pt_temp_860026421 )
				b_ALICE_860026421 = 1
			SINON
				# info complementaire TYPE_EDIT vide
				b_REDIST_860026421 = 1
				erreur_860026421 = i_format_str2(pt_LIBELREDIST_860026421," AR <%s> trouve dans LAR ALICE mais aucune info complementaire valorisee",pt_DEDE_NUM_860026421,0)
			FINSI
		SINON
			erreur_860026421 = i_format_str2(pt_LIBELREDIST_860026421," AR <%s> non trouve dans ALICE",pt_DEDE_NUM_860026421,0)
			b_REDIST_860026421 = 1
		FINSI
	FINSI
FINSI

# CCD_REEL
SI b_EPORTABILITE_SRP_860026421
ALORS
	CCD_REEL_860026421 = 212
SINON
	SI b_SPORTABILITE_SRP_860026421
	ALORS
		CCD_REEL_860026421 = 213
	SINON
		SI b_EPORTABILITE_SCP_860026421
		ALORS
			CCD_REEL_860026421 = 218
		SINON
			SI b_SPORTABILITE_SCP_860026421
			ALORS
				CCD_REEL_860026421 = 219
			SINON
				SI CCD_860026421 != -1
				ALORS
					CCD_REEL_860026421 = CCD_860026421
				SINON
					CCD_REEL_860026421 = 255
				FINSI
			FINSI
		FINSI
	FINSI
FINSI

# b_DISTRI_TRAFIC
#G4R6 Lot2 
#SI ( b_FACTURABLE && !( b_REJET1 ||  b_REJET2 || b_REJET3 || b_REJET5 ) && !( b_SPORTABILITE_SRP ) )
SI ( b_FACTURABLE_860026421 && !( b_Fact_CPS_RI_860026421 || b_REJET1_860026421 ||  b_REJET2_860026421 || b_REJET3_860026421 || b_REJET5_860026421 ) && !( b_SPORTABILITE_SRP_860026421 ) )
ALORS
	b_DISTRI_TRAFIC_860026421 = 1
FINSI

############################
#  Recherche instances ECC
############################

# TRAFIC (ECC de facturation)
# bassin de facturation dans MAJ2G (TD_Inter / 4)
SI (b_DISTRI_TRAFIC_860026421 == 1)
ALORS
	instTRAFIC_860026421 = i_LireInstanceECC(C_InstTRAFIC_860026421)
	SI (!instTRAFIC_860026421)
	ALORS
		erreur_860026421 = i_PlvMessEmettre(8501, 2, g_iartin,"", 3, C_InstTRAFIC_860026421, C_Article_860026421, g_ieec)
		SAUT DISTRI_ERR
	FINSI
	#trace1(">>>__LINE__>>> instTRAFIC=<%d>",instTRAFIC)
# 25/04/2013 - DRE - G4R02 : QC718 Correction calcul longueur pt_IDUS_NUM_DCB
#	longueur = i_strlen(pt_IDUS_NUM_DCB)
#	res = i_EnvoiReqConsTabDist(TD_Inter, DATE_GMT, pt_IDUS_NUM_DCB, longueur, 0, 1)
	res_860026421 = i_EnvoiReqConsTabDist(TD_Inter, DATE_GMT_860026421, pt_IDUS_NUM_DCB_860026421, long_IDUS_NUM_DCB_860026421, 0, 1)
	SI ( res_860026421 != 0 )
	ALORS
		#trace1(">>>__LINE__>>> Erreur i_EnvoiReqConsTabDist %d - alarme a emettre", res)
		code_rejet_860026421 = 0xA0C0
		code_rejet_860026421 = code_rejet_860026421 + b_EFFICACE_860026421
		erreur_860026421 = i_PlvMessEmettre(8607, 2, g_iartin, "", 3, code_rejet_860026421, "MAJ2G", C_Article_860026421)
		SAUT DISTRI_ERR
	FINSI

	erreur_860026421 = i_LireReqConsTabDist()
	#trace1(">>>__LINE__>>> RETOUR i_LireReqConsTabDist, erreur=<%d>",erreur)
	SI ( erreur_860026421 != 0 )
	ALORS
		#trace1( ">>>__LINE__>>> Erreur i_LireReqConsTabDist: <%d>", erreur)
		code_rejet_860026421 = 0xA070
		code_rejet_860026421 = code_rejet_860026421 + b_EFFICACE_860026421
		erreur_860026421 = i_PlvMessEmettre(8508, 2, g_iartin, "", 3, C_Article_860026421, "LireReqConsTabDist", "MAJ2G")
		SAUT DISTRI_ERR
	FINSI

	res_860026421 = i_LireInfoECC(instTRAFIC_860026421, 0)
	#trace1(">>>__LINE__>>> ============res i_LireInfoECC(instTRAFIC) = <%d>",res)
	SI ( res_860026421 != 0)
	ALORS
		erreur_860026421 = i_LireChaineInfo( res_860026421, 0, 3, pt_InfoCompl_860026421)
		erreur_860026421 = i_format_str2(pt_inst_860026421, "TRAF%s", pt_InfoCompl_860026421,0)
		#trace2(">>>__LINE__>>> Concatenation de TRAF avec info.compl: <%s>", pt_inst, "")
		instTRAFIC_860026421 = i_LireInstanceECC(pt_inst_860026421)
		#trace1(">>>__LINE__>>> Instance de TRAFIC: instTRAFIC=<%d>",instTRAFIC)
		SI (!instTRAFIC_860026421)
		ALORS
			erreur_860026421 = i_PlvMessEmettre(8501,2,g_iartin,"",3,pt_inst_860026421,C_Article_860026421,g_ieec)
			SAUT DISTRI_ERR
		FINSI
#G4R6 Lot2
#		b_REDIST = 0
		flag_TRAFIC_860026421 = 1
		i_strcpy(pt_EccFact_860026421, pt_inst_860026421)
		#trace2(">>>__LINE__>>> ECC de facturation: <%s>", pt_EccFact, "")
	SINON
		b_REDIST_860026421 = 1
		erreur_860026421 = i_format_str2(pt_LIBELREDIST_860026421,"Indicatif inconnu dans la table DISTRI MAJ2G",pt_DEDE_NUM_860026421,0)
		flag_TRAFIC_860026421 = 0
	FINSI
SINON
	flag_TRAFIC_860026421 = 0
FINSI

# SYMPHONIE (tous DC)
instSYMP_860026421 =i_LireInstanceECC(C_InstSYMP_860026421)

SI (!instSYMP_860026421)
ALORS
	erreur_860026421 = i_PlvMessEmettre(8501, 2, g_iartin, "", 3, C_InstSYMP_860026421, C_Article_860026421, g_ieec)
	SAUT DISTRI_ERR
FINSI

# CASPER (tous DC)
instCASPER_860026421=i_LireInstanceECC(C_InstCASPER_860026421)

SI (!instCASPER_860026421)
ALORS
	erreur_860026421 = i_PlvMessEmettre(8501, 2, g_iartin, "", 3, C_InstCASPER_860026421, C_Article_860026421, g_ieec)
	SAUT DISTRI_ERR
FINSI

############################
#  Ajout des ECC
############################

SI (flag_TRAFIC_860026421 == 1) && !b_REDIST_860026421
ALORS
	erreur_860026421 = i_AjouterCouranteECC(instTRAFIC_860026421)
FINSI

SI (CPT_RDT_860026421 == 0)
ALORS
	erreur_860026421 = i_AjouterCouranteECC(instSYMP_860026421)
	erreur_860026421 = i_AjouterCouranteECC(instCASPER_860026421)
FINSI

# Validation de la liste des ECCs destinataires
erreur_860026421 = i_ValiderListeECC( 0, 0, 0, 0)

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

#---------------------------------------------------------------------------
# TRAFIC - g_iartout2
#---------------------------------------------------------------------------
SI ( !i_ChercherCouranteECC(instTRAFIC_860026421) )
ALORS
	#trace(" ##__LINE__## Duplication vers TRAFIC")
	SI (i_dup_art_dest(g_iartin,g_iartout2,"TtraficN"))
	ALORS
		#trace(" ##__LINE__## erreur de i_dup_art_dest")
		erreur_860026421 = i_PlvMessEmettre(8502, 2, g_iartin, "", 3, "TtraficN", C_Article_860026421, g_ieec)
		SAUT  DISTRI_ERR
	FINSI

	# DOMAINE
	erreur_860026421=i_set_art_str(g_iartout2,$TtraficN::DOMAINE, "10")

	# SERVICE
	erreur_860026421=i_set_art_str(g_iartout2,$TtraficN::SERVICE, "67")

	#I DUS_INF
	# table de duplication : 6:F0:3:$IDUS_INF # "000" -> IDUS_INF

	# E
	# table de duplication : 6:F0:1:$E # "0" -> E

	# IDUS_NUM
	erreur_860026421=i_set_art_str(g_iartout2,$TtraficN::IDUS_NUM, pt_IDUS_NUM_860026421)

	# DEDE_INF
	# table de duplication : 6:F0:3:$DEDE_INF # "000" -> DEDE_INF
	SI (b_DEDE_INF_NAT_860026421 || b_DEDE_INF_INTER_860026421)
	ALORS
		erreur_860026421=i_set_art_field(g_iartout2,$TtraficN::DEDE_INF, DEDE_INF_860026421)
	FINSI

	# DEDE_NUM
	#QC511 22/08/2011 DRE pt_DEDE_NUM_FAC = Numero normalise sans 0 devant (00 ou 0)
	#erreur=i_set_art_str(g_iartout2,$TtraficN::DEDE_NUM, pt_DEDE_NUM)
	erreur_860026421=i_set_art_str(g_iartout2,$TtraficN::DEDE_NUM, pt_DEDE_NUM_FAC_860026421)
	#\QC511 22/08/2011 DRE suppression du 00 ou du 0

	# DATE
	erreur_860026421 = i_set_art_field(g_iartout2,$TtraficN::DATE, HLAHM1_860026421)

	# DUREE
	erreur_860026421 = i_set_art_field(g_iartout2,$TtraficN::DUREE,Duree_860026421)

	# CAX
	# table de duplication : 6:F0:1:$CAX # "0" -> CAX

	# TAX
	# table de duplication : 6:F0:8:$TAX # "00000000" -> TAX
	#DRE G3R24
	#SI ( b_SRP_TIERS_sans_ITX || b_PTD || b_Emessage_IP )
	SI (b_SRP_TIERS_PTD_860026421 == 1 || b_118_TIERS_PTD_860026421 == 1 || b_Emessage_IP_860026421 == 1)
	ALORS
		erreur_860026421 = i_set_art_field(g_iartout2,$TtraficN::TAX, vc_860026421)
	FINSI

	# NDS_NUM
	# table de duplication : 6:40:10:$NDS_NUM # "          " -> NDS_NUM
	SI (b_IDUS_redirectNb_860026421 || b_IDUS_callingNb_860026421)
	ALORS
		erreur_860026421 = i_set_art_str(g_iartout2,$TtraficN::NDS_NUM, pt_IDUS_NUM_DCB_860026421)
	FINSI

	# SUP
	# table de duplication : 6:F0: 1:$SUP # "0" -> SUP
	erreur_860026421 = i_set_art_field(g_iartout2,$TtraficN::SUP, 9)

	# REF, MES1, MES2, ...
	# table de duplication :
	# 6:F0:3:$REF		# "000"   -> REF
	# 5:255:$MES1		# "255" -> MES1
	# 5:255:$MES2		# "255" -> MES2
	# 6:40:1:$NB_CSV
	# 6:40:2:$C_CSV1
	# 6:40:1:$OP_CSV1
	# 6:40:2:$C_CSV2
	# 6:40:1:$OP_CSV2
	# 6:40:2:$C_CSV3
	# 6:40:1:$OP_CSV3
	# 6:40:2:$C_CSV4
	# 6:40:1:$OP_CSV4
	# 6:40:2:$C_CSV5
	# 6:40:1:$OP_CSV5
	# 6:C6:2:$STY		# "FF"     -> STY
	# 6:40:4:$COCA		# "    "   -> COCA
	# 6:40:4:$COCAV		# "    "   -> COCAV
	# 6:F0:3:$IDAV_INF	# "000"   -> IDAV_INF
	# 6:40:20:$IDAV_NUM	# "                    "   -> IDAV_NUM
	# 6:40:10:$MNEMO	# " "   -> MNEMO
	# 6:40:1:$TAG		# " "   -> TAG

	#champ SGTQS
	erreur_860026421=i_set_art_str(g_iartout2, $TtraficN::SGTQS, pt_sgtqs_860026421)

	#champ CLASSDEST
	erreur_860026421=i_set_art_field(g_iartout2, $TtraficN::CLASSDEST, CCD_REEL_860026421)
	
	#G4R6 Lot2 
	#CODE_TARIF
	erreur_860026421 = i_set_art_str(g_iartout2, $TtraficN::CODE_TARIF,pt_TARIF_860026421 )

	#TYPE_EDIT
	erreur_860026421 = i_set_art_str(g_iartout2, $TtraficN::TYPE_EDIT,pt_EDIT_860026421 )
FINSI

#---------------------------------------------------------------------------
# Symphonie - g_iartout5
#---------------------------------------------------------------------------

SI ( !i_ChercherCouranteECC(instSYMP_860026421) )
ALORS
	#trace(">>>__LINE__>>> Duplication vers SYMPHONIE")
	erreur_860026421 = i_dup_art_id(g_iartin,g_iartout5)

	SI (erreur_860026421)
	ALORS
		#trace1(">>>__LINE__>>>__FILE__>>> ERREUR de duplication vers SYMPHONIE : %d",erreur)
		code_rejet_860026421 = 0xA0D0
		code_rejet_860026421 = code_rejet_860026421 + b_EFFICACE_860026421
		erreur_860026421 = i_PlvMessEmettre(8602,2,g_iartin, "", 3, code_rejet_860026421, "TsymTopitml", C_Article_860026421)
		SAUT DISTRI_ERR
	FINSI

	res_860026421 = i_rename_art(g_iartout5, "TsymTopitml")

	# ajout de tous les champs de T3ce
	erreur_860026421 = i_ajoutChampNum(g_iartout5, $TsymTopitml::T4ccd,$TsymTopitml::CCD,6)

	# CCD
	SI (b_IDUS_INF_NAT_860026421 == 1)
	ALORS
		erreur_860026421 = i_set_art_field(g_iartout5,$TsymTopitml::CCD, CCD_REEL_860026421)
	SINON
		erreur_860026421 = i_set_art_field(g_iartout5,$TsymTopitml::CCD, 255)
	FINSI

	# SGTQS
	erreur_860026421=i_set_art_str(g_iartout5,$TsymTopitml::SGTQS, pt_sgtqs_860026421)

	# ECC_FACT
	SI (i_strcmp("", pt_EccFact_860026421) != 0)
	ALORS
		erreur_860026421=i_set_art_str(g_iartout5, $TsymTopitml::ECC_FACT, pt_EccFact_860026421)
	SINON
		erreur_860026421=i_set_art_str(g_iartout5, $TsymTopitml::ECC_FACT,"        ")
	FINSI

	#  HLAHM1 (DATE_LOCALE)
	SI (b_IDUS_INF_NAT_860026421 == 1)
	ALORS
		erreur_860026421 = i_set_art_field(g_iartout5, $TsymTopitml::DATE_LOCALE, HLAHM1_860026421)
	SINON
		erreur_860026421 = i_supprChamp(g_iartout5, "T4date_locale")
	FINSI

	# CODCIRDR (g_iartout10, $Conversion num hexa /tab hexa)
	SI CODCIRDR_860026421 != -1
	ALORS
		#trace(">>>__LINE__>>>CODCIRDR est valide")
		i_strcpy(pt_BUF1_860026421, " ")
		erreur_860026421 = i_set_art_field(g_iartout10,$Conversion::CODCIRDR,CODCIRDR_860026421)
		erreur_860026421 = i_get_art_str(g_iartout10, $Conversion::CODCIRDA,pt_BUF1_860026421)
		SI  g_iartout10.CODCIRDA[2] > 9
		ALORS
			i_get_sub_str(pt_BUF1_860026421,2,5,pt_BUF1_860026421)
		SINON
			i_get_sub_str(pt_BUF1_860026421,1,5,pt_BUF1_860026421)
		FINSI
		erreur_860026421=i_set_art_str(g_iartout5, $TsymTopitml::CODCIRDR, pt_BUF1_860026421)
	SINON
		erreur_860026421=i_supprChamp(g_iartout5,"T4codcirdr")
	FINSI

	# CODCIR (g_iartout10, $Conversion num hexa /tab hexa)
	SI CODCIR_860026421 != -1
	ALORS
		#trace(">>>__LINE__>>>CODCIR est valide")
		i_strcpy(pt_BUF1_860026421, "")
		erreur_860026421 = i_set_art_field(g_iartout10,$Conversion::CODCIRDR,CODCIR_860026421)
		erreur_860026421 = i_get_art_str(g_iartout10, $Conversion::CODCIRDA,pt_BUF1_860026421)
		SI (g_iartout10.CODCIRDA[2] > 9)
		ALORS
			i_get_sub_str(pt_BUF1_860026421,2,5,pt_BUF1_860026421)
		SINON
			i_get_sub_str(pt_BUF1_860026421,1,5,pt_BUF1_860026421)
		FINSI
		erreur_860026421=i_set_art_str(g_iartout5, $TsymTopitml::CODCIR, pt_BUF1_860026421)
	SINON
		erreur_860026421=i_supprChamp(g_iartout5,"T4codcir")
	FINSI

	# EFFICACITE
	erreur_860026421 = i_set_art_field(g_iartout5,$TsymTopitml::EFFICACE, b_EFFICACE_860026421)

	# DETR_INF
	#G3R22 QC554
	SI DEDE_INF_860026421 == 0x40
	ALORS
		DEDE_INF_860026421 = 0x00
	FINSI
	#\G3R22 QC554
	erreur_860026421 = i_set_art_field(g_iartout5,$TsymTopitml::DEDE_INF, DEDE_INF_860026421)

	# IDUS_INF
	erreur_860026421 = i_set_art_field(g_iartout5,$TsymTopitml::IDUS_INF, IDUS_INF_860026421)
	
	#G4R6 Lot2 
	SI b_ALICE_860026421
	ALORS
		erreur_860026421 = i_set_art_str(g_iartout5, $TsymTopitml::CODE_TARIF,pt_TARIF_860026421 )
		erreur_860026421 = i_set_art_str(g_iartout5, $TsymTopitml::TYPE_EDIT,pt_EDIT_860026421 )
	SINON
		erreur_860026421 = i_supprChamp(g_iartout5, "T4code_tarif")
		erreur_860026421 = i_supprChamp(g_iartout5, "T4type_edit")
	FINSI

FINSI

#---------------------------------------------------------------------------
# CASPER - g_iartout3
#---------------------------------------------------------------------------
SI( !i_ChercherCouranteECC(instCASPER_860026421))
ALORS
	#trace(">>>__LINE__>>> Duplication vers CASPER")
	erreur_860026421 = i_dup_art_id(g_iartin,g_iartout3)

	SI (erreur_860026421)
	ALORS
		#trace1(">>>__LINE__>>>__FILE__>>> ERREUR de duplication vers CASPER : %d",erreur)
		code_rejet_860026421 = 0xA0D0
		code_rejet_860026421 = code_rejet_860026421 + b_EFFICACE_860026421
		erreur_860026421 = i_PlvMessEmettre(8602,2,g_iartin, "", 3, code_rejet_860026421, "TcasperTopitml", C_Article_860026421)
		SAUT DISTRI_ERR
	FINSI

	res_860026421 = i_rename_art(g_iartout3, "TcasperTopitml")

	# ajout de tous les champs de T3ce
	erreur_860026421 = i_ajoutChampNum(g_iartout3, $TcasperTopitml::T4sgtqs, $TsymTopitml::SGTQS, 6)

	# Champ SGTQS
	erreur_860026421 = i_set_art_str(g_iartout3,$TcasperTopitml::SGTQS, pt_sgtqs_860026421)

	# Champ CODCIR
	SI CODCIR_860026421 != -1
	ALORS
		#trace(">>>__LINE__>>>CODCIR est valide")
		i_strcpy(pt_BUF1_860026421, "")
		erreur_860026421 = i_set_art_field(g_iartout10,$Conversion::CODCIRDR,CODCIR_860026421)
		erreur_860026421 = i_get_art_str(g_iartout10, $Conversion::CODCIRDA,pt_BUF1_860026421)
		SI (g_iartout10.CODCIRDA[2] > 9)
		ALORS
			i_get_sub_str(pt_BUF1_860026421,2,5,pt_BUF1_860026421)
		SINON
			i_get_sub_str(pt_BUF1_860026421,1,5,pt_BUF1_860026421)
		FINSI
		erreur_860026421=i_set_art_str(g_iartout3, $TcasperTopitml::CODCIR, pt_BUF1_860026421)
	SINON
		erreur_860026421=i_set_art_str(g_iartout3, $TcasperTopitml::CODCIR, "     ")
	FINSI

	# Champ CODCIRDR
	SI CODCIRDR_860026421 != -1
	ALORS
		#trace(">>>__LINE__>>>CODCIR est valide")
		i_strcpy(pt_BUF1_860026421, "")
		erreur_860026421 = i_set_art_field(g_iartout10,$Conversion::CODCIRDR,CODCIRDR_860026421)
		erreur_860026421 = i_get_art_str(g_iartout10, $Conversion::CODCIRDA,pt_BUF1_860026421)

		SI (g_iartout10.CODCIRDA[2] > 9)
		ALORS
			i_get_sub_str(pt_BUF1_860026421,2,5,pt_BUF1_860026421)
		SINON
			i_get_sub_str(pt_BUF1_860026421,1,5,pt_BUF1_860026421)
		FINSI
		erreur_860026421=i_set_art_str(g_iartout3, $TcasperTopitml::CODCIRDR, pt_BUF1_860026421)
	SINON
		erreur_860026421=i_set_art_str(g_iartout3, $TcasperTopitml::CODCIRDR, "     ")
	FINSI
FINSI

########################################################################
# Envoi vers IECC
########################################################################

SI (! i_ChercherCouranteECC(instTRAFIC_860026421))
ALORS
	#trace(">>>__LINE__>>> emission vers TRAFIC")
	erreur_860026421  = i_stocke_art_iecc(g_iartout2, instTRAFIC_860026421)
FINSI

SI (! i_ChercherCouranteECC(instSYMP_860026421))
ALORS
	#trace(">>>__LINE__>>> emission vers Symphonie")
	erreur_860026421  = i_stocke_art_iecc(g_iartout5, instSYMP_860026421)
FINSI

SI( !i_ChercherCouranteECC(instCASPER_860026421))
ALORS
	#trace(">>>__LINE__>>> emission vers CASPER")
	res_860026421 = i_stocke_art_iecc(g_iartout3, instCASPER_860026421)
FINSI

# Redistribution
SI (b_REDIST_860026421 == 1)
ALORS
#  Enregistrement du champ Nom_EEC dans l'ENVELOPPE Optionelle de redistribution
	#G4R6 Lot2
	#res = i_add_opt( "EnomEEC" )
	#res = i_set_attr_str_n($EnomEEC::Nom_EEC, pt_sgtqs)
	#trace1("__FILE__:__LINE__ ## TEST ## ======> Envoi en redistribution CPT : <%d> #### ", CPT_RDT_860026004)
	SI (CPT_RDT_860026421 == 0)
	ALORS
		erreur_860026421 = i_PlvMessEmettre(8503,2,g_iartin,"",3, pt_LIBELREDIST_860026421, C_Article_860026421, pt_sgtqs_860026421)
	FINSI
	res_860026421 = i_stocke_art( g_iartin, 0, PT_REDIST|RD_TABLE6, 0 )
FINSI

RETOUR TRAIT_OK

#G4R6 Lot2
##############################################################################
# Stockage en ELIMINE EXPLICITE  (REJET3 = 1 ex: cas DC 119)
##############################################################################

POINT ELIMINE_EXP

#trace( ">>>__LINE__>>> Stockage en elimine explicite")
res_860026421 = i_stocke_art( g_iartin, 0, PT_DIVERS, 0 )

RETOUR TRAIT_OK


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

POINT DISTRI_ERR

#trace( ">>>__LINE__>>> Stockage en errone de distribution")
res_860026421 = i_make_art_rej(g_iartin, g_iartout8, code_rejet_860026421)
res_860026421 = i_stocke_art( g_iartout8, 0, PT_ERRONE, 0)

RETOUR TRAIT_OK

RETOUR TRAIT_OK

#--------------Fin Pcode Distribution Topitml ------------------------
