DEFINITION C_InstARAVIS_860026653 "ARAVIS"
DEFINITION C_InstFERPV_860026653 "FERPV"
DEFINITION C_InstSYMPH_860026653 "SYMP"
DEFINITION C_Article_860026653 "Trpvi2"
DEFINITION C_TSymTrpvi2_860026653 "TsymTrpvi2"
DEFINITION C_Taravis_860026653 "Taravis"
DEFINITION C_Tfe_rpv_860026653 "Tfe_rpv"
DEFINITION NUMTAB_860026653 1
DEFINITION ZONEMETRO_860026653 7
DEFINITION CPT_CPS_Loc_860026653 16
DEFINITION CPT_CPS_RI_860026653 17
DEFINITION C_DATCPS_860026653 "DATCPS" 
DEFINITION TD_SVA_860026653 9
DEFINITION C_INST_ALICE_860026653 "ALICE"
REGISTRE ENTIER instFERPV_860026653
REGISTRE ENTIER instSYMP_860026653
REGISTRE ENTIER instARAVIS_860026653
REGISTRE ENTIER res_860026653
REGISTRE ENTIER erreur_860026653
REGISTRE ENTIER HLAHM1_860026653
REGISTRE ENTIER taille_max_860026653
REGISTRE ENTIER valeur1_860026653
REGISTRE ENTIER valeur2_860026653
REGISTRE ENTIER valeur3_860026653
REGISTRE ENTIER valeur4_860026653
REGISTRE ENTIER indice_860026653
REGISTRE ENTIER bREDIST_860026653
REGISTRE ENTIER L_AR_860026653
REGISTRE ENTIER trait_ok_860026653
REGISTRE ENTIER NbCsv_860026653
REGISTRE ENTIER NumChamp_860026653
REGISTRE ENTIER dpivot_860026653
REGISTRE ENTIER id_corr_860026653
REGISTRE ENTIER RETOUR_CORR_860026653
REGISTRE ENTIER ENVELOPPE_NOK_860026653
REGISTRE ENTIER CharactCall_860026653
REGISTRE ENTIER AdrCalledNb_860026653
REGISTRE ENTIER gmt_date_860026653
REGISTRE ENTIER ddebut_860026653
REGISTRE ENTIER code_errone_860026653
REGISTRE ENTIER b_ARAVIS_860026653
REGISTRE ENTIER comid_n1_860026653
REGISTRE ENTIER EEC_audit_860026653
REGISTRE ENTIER bloc_audit_860026653
REGISTRE ENTIER DC_audit_860026653
REGISTRE ENTIER comid_num_860026653
REGISTRE ENTIER AdrAddCallingNb_860026653
REGISTRE ENTIER ccd_860026653
REGISTRE ENTIER calltype_860026653
REGISTRE ENTIER RenvoiMessagerie_860026653
REGISTRE ENTIER GestionRenvoi_860026653
REGISTRE ENTIER ConsultAnnVocal_860026653
REGISTRE ENTIER VPN_860026653
REGISTRE ENTIER PERFORMANCE_PREFERENCE_860026653
REGISTRE ENTIER EPortabilite_SCP_860026653
REGISTRE ENTIER SPortabilite_SCP_860026653
REGISTRE ENTIER CCD_REEL_860026653
REGISTRE ENTIER TYPAR_Etelephonie_860026653
REGISTRE ENTIER longueur_860026653
REGISTRE ENTIER Date_CPS_860026653
REGISTRE ENTIER instALICE_860026653 
REGISTRE ENTIER val_860026653
REGISTRE ENTIER b_FERPV_860026653
REGISTRE ENTIER typ_ctr_860026653
REGISTRE ENTIER bREDIST_SVA_860026653
REGISTRE ENTIER b_Fact_CPS_Loc_860026653
REGISTRE ENTIER b_Fact_CPS_RI_860026653
REGISTRE ENTIER b_ALICE_860026653
REGISTRE POINTEUR pt_service_860026653
REGISTRE POINTEUR pt_debChamp_860026653
REGISTRE POINTEUR pt_champ_860026653
REGISTRE POINTEUR pt_finChamp_860026653
REGISTRE POINTEUR pt_TransNb_860026653
REGISTRE POINTEUR pt_debTransNb_860026653
REGISTRE POINTEUR pt_EccFact_860026653
REGISTRE POINTEUR pt_InfoCompl_860026653
REGISTRE POINTEUR pt_AddCallingNb_860026653
REGISTRE POINTEUR pt_IDUS_NUM_860026653
REGISTRE POINTEUR pt_OrigCalledNb_860026653
REGISTRE POINTEUR pt2_860026653
REGISTRE POINTEUR pt_NUMDDR_860026653
REGISTRE POINTEUR pt_TYPACCRI_860026653
REGISTRE POINTEUR pt_NATAPPRI_860026653
REGISTRE POINTEUR pt_LIBELREDIST_860026653
REGISTRE POINTEUR pt_SGTQS_860026653
REGISTRE POINTEUR pt_csv_860026653
REGISTRE POINTEUR pt_opcsv_860026653
REGISTRE POINTEUR pt_cascorr_860026653
REGISTRE POINTEUR pt_marque_audit_860026653
REGISTRE POINTEUR pt_TYPCOM_860026653
REGISTRE POINTEUR pt_codcir_860026653
REGISTRE POINTEUR pt_codcirdr_860026653
REGISTRE POINTEUR pt_CodeSCP_860026653
REGISTRE POINTEUR pt_MESSAGE_860026653
REGISTRE POINTEUR pt_CODE_TARIF_860026653 
REGISTRE POINTEUR pt_TYPE_EDIT_860026653 
REGISTRE POINTEUR pt_NORM_860026653
REGISTRE POINTEUR pt_TEMP_860026653
############################################################################
#
# Fichier : Trpvi2.src
#
# Distribution :
#    Article RPVI2
#
# En entree :
#    Article : Trpvi2
#
# En sortie :
#    		FERPV
#    		ARAVIS
#    		SYMPHONIE
#
# HISTORIQUE :
# 23/06/2004 - NSA - Creation
# 31/08/2004 - NSA - FO804, FO836, FO818, FO827,FO830,FO831
#     	     - NSA - prise en compte des numeros speciaux RMTA pour FERPV
# 08/09/2004 - NSA - FO850,FO853
# 13/09/2004 - NSA - FO865 FO866
# 15/09/2004 - NSA - redist et correlation
# 22/11/2004 - NSA - FO 881 ajout d'un zero devant CMMUserIdentity pour NDDR dans  ARAVIS
# 22/11/2004 - NSA - FO 919 ajout d'un zero devant CMMUserIdentity pour NUMDDR dans  FERPV
# 22/11/2004 - NSA - FO 943 traitement de adrCalledNb avec 0x73 (NUMDDE de FERPV)
# 06/12/2004 - NSA - FO 988 modif des criteres de creation du champ AR
# 10/12/2004 - NSA - FO 998 nouvelles valeurs pour DDR_RMTA 01 11 11 11 11 et 02 22 22 22 22
# 10/12/2004 - NSA - FO 997 Noorig pour FERPV si Adr=04 suppression du 33 si Adr=04 et mise a jour de Adr
# 17/01/2005 - DRE - FO 1054 Dans le cas de calltype = 07 ou 09 ou 1D TYPACCRI doit prendre la valeur 7 au lieu de 4  (modif de spec)
# 19/01/2005 - DRE - FO 1058 valeur de SOURCE = 6(idem Accueil)  si DEDE_N = 083648 ou 083649
# 31/01/2005 - THE - G2R1Cg
# 22/03/2005 - THE - Correction lot2
# 31/03/2005 - THE - FO 1196 1199 1201 1206
# 31/03/2005 - THE - Intigration FO 1157 et 1164 CA des SCP portes
# 31/03/2005 - THE - Intigration FO 1195 CCD symphonie avec CCD_REEL
# 18/05/2005 - THE - FO 1288
# 26/05/2005 - THE - FO 1323
# 26/05/2005 - THE - FO 1333
# 14/06/2005 - THE - FO 1350 (Nouveau Calltype 51)
# 08/09/2005 - FAL - FO 1452 Le pointeur pt_EccFact a deux allocations memoire
# 09/09/2005 - PSA - Correction initialisation pointeur pt_debTransNb
# 15/09/2005 - DRE - FO1406 Retour Fonction i_LireInfoECC (doit etre != et non >)
# 18/09/2005 - FAL - FO1461 ajouter des calltype
# 23/09/2005 - FAL - FO1467 modif calcul id_corr
# 05/12/2005 - PSA - FO1618
# 13/04/2006 - FAL - G2R2Cd FO1773 calltype 0x19 pour  natappri 1
# 26/04/2006 - BEA - G2R2Cg lot 2 Marquage RMTA mobile pour FE sur DC RPVI_2
# 05/11/2006 - JLG - G2R2Cv lot 2 Evol TYPAR_Etelephonie (SOURCE de FERPV)
# 17/11/2006 - JLG - G2R2Cv FO2041 alarme 8601
# 20/03/2007 - RHE - G3R0Cb : Interfonctionnement BTIP-RPV
# 20/03/2007 - RHE - G3R0Cb : FO2150 retour arrihre BTIP/RPVI2 champ source ` 09
# 26/04/2007 - FAL - G3R0Cu Tfe_rpv Tfe_rpv SUPPORT alpha
# 10/09/2007 - FAL - G3R3 FO2219 Article avec CallinNB 33 seul attention car IDUS_NUM absent
# 02/02/2009 - THE - G3R12 Envoi a FERPV avec date locale
# 30/06/2010 - PKH - G3R17Cy valorisation du champ NUMDE de FERPV avec $Trpvi2::TRANS_NUM pour RenvoiMessagerie
# 10/10/2011 - THE - VerifPcode
# 14/04/2014 - DRE - G4R6 : Lot3
# 14/05/2014 - DRE - G4R6 QC818
# 24/06/2014 - DRE - G4R7 QC818
# 29/07/2014 - THE - G4R7 QC831 ECC_FACT (champ Symphonie) est renseigne a tort avec "FE"
# 30/07/2014 - THE - G4R7 QC829 ajout b_ALICE
# 13/01/2015 - DRE - G4R8C5 QC871 Pb redistribution SVA
# 29/01/2015 - DRE - G4R8C6 QC871 suite Pb redistribution SVA
#
###########################################################################

###########################################################################
# Declarations
###########################################################################
# Constantes
#DRE G4R6 lot3
#\DRE G4R6 lot3


# Variables entieres
#Instances
# VerifPcode
#Divers
#DRE G4R6 lot3
#DRE G4R7 QC818
#G4R7 Lot3 QC829


#********initialisation variables entieres
instFERPV_860026653	 = 0
instSYMP_860026653	 = 0
instARAVIS_860026653	 = 0
indice_860026653		 = 0
valeur1_860026653		 = 0
valeur2_860026653		 = 0
valeur3_860026653		 = 0
valeur4_860026653		 = 0
taille_max_860026653	 = 0
bREDIST_860026653		 = 0
L_AR_860026653		 = 0
id_corr_860026653		 = 0
RETOUR_CORR_860026653	 = 0
ENVELOPPE_NOK_860026653	 = 1
CharactCall_860026653	 = 0
b_ARAVIS_860026653	 = 0
RenvoiMessagerie_860026653 = 0
GestionRenvoi_860026653	 = 0
ConsultAnnVocal_860026653	 = 0
VPN_860026653		 = 0
CCD_REEL_860026653	 = 0xff
TYPAR_Etelephonie_860026653 = 0
PERFORMANCE_PREFERENCE_860026653 = 0
#DRE G4R6 lot3
Date_CPS_860026653 = 0
instALICE_860026653 = -1
longueur_860026653 = 0
val_860026653 = 0
ddebut_860026653 = -1
b_FERPV_860026653 = 0
typ_ctr_860026653 = 0
#DRE G4R7 QC818
bREDIST_SVA_860026653 = 0
b_Fact_CPS_Loc_860026653 = 0
b_Fact_CPS_RI_860026653 = 0
#G4R7 Lot3 QC829
b_ALICE_860026653 = 0


#******** Definition Pointeurs
# DRE G4R6 lot3


# Allocation de memoire pour le buffeur
#pt_AR		 = "2525252525252525252525252525252525252525252525252"
pt_service_860026653	 = "111111"
pt_debChamp_860026653	 = "222222222222"
pt_champ_860026653	 = "3333333333333333333333333333333333333333333333333"
pt_TransNb_860026653	 = "44444444444444444444444444444444444444444444444444"
pt_AddCallingNb_860026653	 = "55555555555555555555555555555555555555555555555555"
pt_IDUS_NUM_860026653	 = "6666666666666666666666666666666666666666666666666"
pt_finChamp_860026653	 = "7777777777777777777777777777777777777777777777"
pt_debTransNb_860026653	 = "88888888888888"
pt_InfoCompl_860026653	 = "101010101010101"
pt_OrigCalledNb_860026653	 = "24242424242424242424242424242424242424242424242424"
pt2_860026653		 = "121212121212121212121212121212121212122121121212121212121211212121221"
pt_NUMDDR_860026653	 = "21212121212121212121212121212121212122121121212121212121211212121221"
pt_TYPACCRI_860026653	 = "13131313"
pt_NATAPPRI_860026653	 = "19191919"
pt_EccFact_860026653	 = "151515151515151515"
pt_SGTQS_860026653	 = "1616161616161616161616"
pt_csv_860026653		 = "17171717171717"
pt_cascorr_860026653	 = "18181818181818"
pt_marque_audit_860026653	 = "2020202020202020202020202020202020"
pt_TYPCOM_860026653	 = "212121"
pt_opcsv_860026653	 = "2323232323232"
pt_codcirdr_860026653	 = "262626262626262626"
pt_codcir_860026653	 = "272727272727272727"
pt_CodeSCP_860026653	 = "19191919191919191919191919"
# DRE G4R6 lot3
pt_MESSAGE_860026653 = "pt_MESSAGEpt_MESSAGEpt_MESSAGEpt_MESSAGEpt_MESSAGEpt_MESSAGEpt_MESSAGEpt_MESSAGEpt_MESSAGEpt_MESSAGEpt_MESSAGEpt_MESSAGEpt_MESSAGEpt_MESSAGEpt_MESSAGEpt_MESSAGEpt_MESSAGEpt_MESSAGEpt_MESSAGEpt_MESSAGEpt_MESSAGEpt_MESSAGE"
pt_LIBELREDIST_860026653	 = "pt_LIBELREDISTpt_LIBELREDISTpt_LIBELREDISTpt_LIBELREDISTpt_LIBELREDISTpt_LIBELREDISTpt_LIBELREDISTpt_LIBELREDISTpt_LIBELREDISTpt_LIBELREDISTpt_LIBELREDISTpt_LIBELREDISTpt_LIBELREDIST"
pt_CODE_TARIF_860026653 	 = "pt_CODE_TARIFpt_CODE_TARIF"
pt_TYPE_EDIT_860026653	 = "pt_TYPE_EDIT"
pt_NORM_860026653		 = "389389389389389389996200258997115447999945899"
pt_TEMP_860026653		 = "pt_TEMPpt_TEMPpt_TEMPpt_TEMPpt_TEMPpt_TEMPpt_TEMPpt_TEMPpt_TEMPpt_TEMPpt_TEMPpt_TEMP"


#********initialisation pointeurs
i_strcpy(pt_CodeSCP_860026653,"")
i_strcpy(pt_EccFact_860026653," ")
i_strcpy(pt_debTransNb_860026653," ")
i_strcpy(pt_IDUS_NUM_860026653,"")
i_strcpy(pt_debChamp_860026653,"")
i_strcpy(pt_service_860026653,"")
i_strcpy(pt_finChamp_860026653,"")
i_strcpy(pt_TransNb_860026653,"")
i_strcpy(pt_InfoCompl_860026653,"")
i_strcpy(pt_AddCallingNb_860026653,"")
i_strcpy(pt_OrigCalledNb_860026653,"")
i_strcpy(pt2_860026653,"")
i_strcpy(pt_NUMDDR_860026653,"")
i_strcpy(pt_TYPACCRI_860026653,"")
i_strcpy(pt_LIBELREDIST_860026653,"")
i_strcpy(pt_SGTQS_860026653,"")
i_strcpy(pt_csv_860026653,"")
i_strcpy(pt_opcsv_860026653,"")
i_strcpy(pt_cascorr_860026653,"")
i_strcpy(pt_marque_audit_860026653,"")
i_strcpy(pt_TYPCOM_860026653,"")
i_strcpy(pt_codcir_860026653,"")
i_strcpy(pt_codcirdr_860026653,"")
# DRE G4R6 lot3
i_strcpy(pt_MESSAGE_860026653, "")
i_strcpy(pt_CODE_TARIF_860026653 , "    ")
i_strcpy(pt_TYPE_EDIT_860026653 , " ")
i_strcpy(pt_LIBELREDIST_860026653,"")
i_strcpy(pt_NORM_860026653,"")
i_strcpy(pt_TEMP_860026653,"")



#######################################################################################

#trace("ici pcode de distribution Trpvi2")

# ---------------------------------------------------
# Identification de la provenance de l'article
# ---------------------------------------------------

trait_ok_860026653 = -1
# trait_ok : nb de passage en redistribution
trait_ok_860026653 = i_LireRedistCpt()

SI ( trait_ok_860026653 > 0 )
ALORS
	ENVELOPPE_NOK_860026653 = 0
FINSI

#DRE G4R6 lot3
# ---------------------------------------------------
# Recuperation du REJET
# ---------------------------------------------------
#REJET
typ_ctr_860026653 = i_get_art_field(g_iartin, $Trpvi2::REJET)

#DRE - G4R7 QC818
SI typ_ctr_860026653 == CPT_CPS_Loc_860026653
ALORS
	b_Fact_CPS_Loc_860026653 = 1
FINSI
SI typ_ctr_860026653 == CPT_CPS_RI_860026653
ALORS
	b_Fact_CPS_RI_860026653 = 1
FINSI
#\DRE - G4R7 QC818


############################################################################
# 	Test retour de correlation
############################################################################

#trace1("DIST: GIPT: <%d>", g_ipt)
SI ( g_ipt == PT_OK )
ALORS
	RETOUR_CORR_860026653=0
SINON
	RETOUR_CORR_860026653=1
FINSI
calltype_860026653=i_get_art_field(g_iartin, $Trpvi2::calltype)

############################################################################
# Envoi en Correlation
############################################################################

#SI ( ( calltype == 0x01 || calltype == 0x14 || calltype == 0x50 || calltype == 0x51 || calltype == 0x18 
#    	|| calltype == 0x19 || calltype == 0x1A || calltype == 0x36 || calltype == 0x43 || calltype == 0x06 
#    	|| calltype == 0x1C || calltype == 0x07 || calltype == 0x1D ) && !RETOUR_CORR )
#DRE - G4R7 QC818
#SI ( typ_ctr != CPT_CPS_RI && !RETOUR_CORR
# G4R8C6 QC871
#SI ( !b_Fact_CPS_RI && !RETOUR_CORR
SI ( !b_Fact_CPS_RI_860026653 && !RETOUR_CORR_860026653 && trait_ok_860026653 == 0
	&& ( calltype_860026653 == 0x01 || calltype_860026653 == 0x14 || calltype_860026653 == 0x50 || calltype_860026653 == 0x51 || calltype_860026653 == 0x18 
    	|| calltype_860026653 == 0x19 || calltype_860026653 == 0x1A || calltype_860026653 == 0x36 || calltype_860026653 == 0x43 || calltype_860026653 == 0x06 
    	|| calltype_860026653 == 0x1C || calltype_860026653 == 0x07 || calltype_860026653 == 0x1D )  )
ALORS
	i_strcpy(pt_cascorr_860026653,"RPVI_2")
	#***********recherche des 3 derniers chiffres du numero ***************
	# on divise par 2 pour avoir la valeur en octets
	L_AR_860026653=(i_get_art_fieldlength(g_iartin,$Trpvi2::IDUS_NUM)+1)/2
	erreur_860026653 =i_resize_tlv(g_iartin,"T4idus","IDUS_NUM",L_AR_860026653*8)

	# Nombre de quartets
	taille_max_860026653=L_AR_860026653*2
	#  on enleve 1 a l'indice car les indices partent de zero
	indice_860026653=L_AR_860026653*2-1

	SI ( taille_max_860026653>=3 )
	ALORS
		valeur1_860026653=g_iartin.IDUS_NUM[indice_860026653]
		#**** recherche si dernier chiffre vaut F ***

		SI (valeur1_860026653 ==15 )
		ALORS
			indice_860026653=indice_860026653-1
			valeur1_860026653=g_iartin.IDUS_NUM[indice_860026653]
		FINSI
		#indice=indice-1
		valeur2_860026653=g_iartin.IDUS_NUM[indice_860026653-1]
		valeur3_860026653=g_iartin.IDUS_NUM[indice_860026653-2]
		valeur4_860026653=g_iartin.IDUS_NUM[indice_860026653-3]
	FINSI
#*******************************************************************
	id_corr_860026653 = (((valeur4_860026653*10) +(valeur3_860026653))*65536) + ((valeur2_860026653*10) + valeur1_860026653)
	#trace2("CORR_DIST - cas: %s", pt_cascorr, "")
	#trace1("G2R1Cj style 0x00aa00ff CORR_DIST - id: %x", id_corr)
	erreur_860026653 = i_initialiserPrmCorr(g_iartin)
	erreur_860026653 = i_ajouterPrmCorr(g_iartin, pt_cascorr_860026653, id_corr_860026653)
	#trace1("CORR_DIST - code retour i_ajouterPrmCorr %d", erreur)
	erreur_860026653 = i_stocke_art(g_iartin, 0, PT_CORRELE, 0)
FINSI

############################################################################
# 	Variables globales
############################################################################

#DRE G4R6 lot3 Creation de larticle conversion
erreur_860026653 = i_cree_art("Conversion",g_iartout10)

#************************TYPCOM************************************************
# dpivot
dpivot_860026653 = i_get_art_field( g_iartin, $dpivot )

#ddebut
ddebut_860026653 = i_get_art_field( g_iartin, $ddebut )

#CharactCall
CharactCall_860026653 =i_get_art_field(g_iartin, $Trpvi2::CharactCall)

#AdrCalledNb
AdrCalledNb_860026653=i_get_art_field(g_iartin, $Trpvi2::AdrCalledNb)

SI ( CharactCall_860026653==0x00 || CharactCall_860026653==0x0A || CharactCall_860026653==0x14 || CharactCall_860026653==0x1E || CharactCall_860026653==0x28 || CharactCall_860026653==0x02 || CharactCall_860026653==0x0C )
ALORS
	SI ( ( AdrCalledNb_860026653==0x03 || AdrCalledNb_860026653==0x04 ) && ( calltype_860026653==0x01 || calltype_860026653==0x14 || calltype_860026653==0x50 ) )
	ALORS
		#**** Forced on Net
		i_strcpy(pt_TYPCOM_860026653,"2")
	SINON
		#**** On Net
		i_strcpy(pt_TYPCOM_860026653,"1")
	FINSI
FINSI

SI (CharactCall_860026653==0x01 || CharactCall_860026653==0x0B || CharactCall_860026653==0x15)
ALORS
	#**** Off Net
	i_strcpy(pt_TYPCOM_860026653,"4")
FINSI

# pt_IDUS_NUM desormais optionel
SI i_valid_field_n(g_iartin,$IDUS_NUM)
ALORS
	erreur_860026653 = i_get_art_str(g_iartin,$IDUS_NUM,pt_IDUS_NUM_860026653)
SINON
	i_strcpy(pt_IDUS_NUM_860026653,"")
FINSI


##############################################################################
###  	 Renvoi messagerie
##############################################################################

erreur_860026653 = i_get_art_str(g_iartin, $Trpvi2::CalledNb, pt_champ_860026653)
i_get_sub_str(pt_champ_860026653, 0, 4, pt_debChamp_860026653)

SI ( i_valid_field_n(g_iartin, $Trpvi2::TransNb))
ALORS
	erreur_860026653 = i_get_art_str(g_iartin, $Trpvi2::TransNb, pt_TransNb_860026653)
	i_get_sub_str(pt_TransNb_860026653, 0, 4, pt_debTransNb_860026653)
FINSI

SI ( i_strcmp("07996", pt_debChamp_860026653 ) == 0 ) || ( i_strcmp("07996", pt_debTransNb_860026653 ) == 0 )
ALORS
	RenvoiMessagerie_860026653=1
FINSI

##############################################################################
### 	  Gestion renvoi
##############################################################################

calltype_860026653=i_get_art_field(g_iartin, $Trpvi2::calltype)

SI ( calltype_860026653==0xCB || calltype_860026653==0x20 || calltype_860026653==0x08 || calltype_860026653==0x09 )
ALORS
	GestionRenvoi_860026653=1
FINSI

##############################################################################
###  	 Consultation Annuaire Vocal
##############################################################################

SI ( calltype_860026653==0x30 || calltype_860026653==0x31 || calltype_860026653==0x34 || calltype_860026653==0x35 || calltype_860026653==0x36 || calltype_860026653==0x37 || calltype_860026653==0x60 || calltype_860026653==0x61 )
ALORS
	ConsultAnnVocal_860026653=1
FINSI

##############################################################################
### Enveloppe    E_Trpvi2
##############################################################################

SI (trait_ok_860026653 == 0)
ALORS
	SI ( ENVELOPPE_NOK_860026653 )
	ALORS
		#  AJOUT ENVELOPPE Optionelle:
		## Ajout enveloppe optionnelle E_RPVI
		# Contient la date metropole pour la distri

		# Creation de l'enveloppe

		erreur_860026653 = i_add_opt( "E_Trpvi2" )

		# champ T1 (=>  0x0C pour la reconnaissance de l'enveloppe,
		# par l'arbre de reconnaissance Dopt )
		#erreur = i_set_attr_val_n( $E_Trpvi2::T1, 0x24 )

		# Champ L1 (taille champ Nom_EEC = 0x0B octets)
		#erreur = i_set_attr_val_n( $E_Trpvi2::L1, 0x0B )

		#  Mise a jour de l'ENVELOPPE Optionelle:
		# Contient la date de fin metropole necessaire pour les metachamps de distri
		# Champ DATE
		res_860026653 = i_get_art_field(g_iartin, $Trpvi2::dfin)
		erreur_860026653 = i_set_attr_val_n( $E_Trpvi2::DATE_M, res_860026653)

		# Champ Nom_EEC
		# Contient le nom de l'EEC pour l'alarme de redistri
		i_strcpy(pt_SGTQS_860026653, i_LireEECSGTQS(g_ieec))
		res_860026653 = i_set_attr_str_n( $E_Trpvi2::Nom_EEC, pt_SGTQS_860026653)
	FINSI
FINSI

##############################################################################
###	HLAHM1
##############################################################################

HLAHM1_860026653 = i_get_art_field(g_iartin,$Trpvi2::HLAHM1)

##############################################################################
###	VPN cooperant
##############################################################################

erreur_860026653 = i_get_art_str(g_iartin, $Trpvi2::CalledNb, pt_champ_860026653)
i_get_sub_str(pt_champ_860026653, 0, 4, pt_debChamp_860026653)

SI ( i_valid_field_n(g_iartin, $Trpvi2::TransNb) )
ALORS
	erreur_860026653 = i_get_art_str(g_iartin, $Trpvi2::TransNb, pt_TransNb_860026653)
	i_get_sub_str(pt_TransNb_860026653, 0, 4, pt_debTransNb_860026653)
FINSI

SI ( i_strcmp("15072", pt_debChamp_860026653) == 0 )
ALORS
	VPN_860026653=1
FINSI

SI ( i_strcmp("15072", pt_debTransNb_860026653) == 0 )
ALORS
	VPN_860026653=1
FINSI

##############################################################################
### AdrOrigCalledNb / OrigCalledNb et mise a jour AR
##############################################################################

SI(!i_valid_field_n(g_iartin, $Trpvi2::AR))
ALORS
	erreur_860026653 = i_ajoutChampNum(g_iartin, $Trpvi2::T4ar,$Trpvi2::AR,0)
FINSI

##############################################################################
# Envoi Requetes Table de Distribution
##############################################################################

gmt_date_860026653 = i_DHgetCe2gTime(NUMTAB_860026653,ZONEMETRO_860026653,ddebut_860026653)


#####################################################################
# 	              Traitement C+S (CPS) table ALICE
#####################################################################
#DRE G4R6 lot3 
#DRE G4R6 QC818
#SI (typ_ctr==CPT_CPS_Loc)
#DRE G4R7 QC818
#SI (typ_ctr==CPT_CPS_Loc || typ_ctr==CPT_CPS_RI)
SI b_Fact_CPS_Loc_860026653 || b_Fact_CPS_RI_860026653
ALORS
	erreur_860026653 = i_get_art_str(g_iartin,$Trpvi2::NORMAL,pt_NORM_860026653)

	i_strcpy(pt_TEMP_860026653, i_get_tab_field( "TDATCPS", gmt_date_860026653, C_DATCPS_860026653 ))

	erreur_860026653 = i_set_art_str (g_iartout10,$Conversion::DATE_STR,pt_TEMP_860026653)
	Date_CPS_860026653 = i_get_art_field(g_iartout10, $Conversion::DATE_ASC)
			
	SI ddebut_860026653 < Date_CPS_860026653
	ALORS
		erreur_860026653 = i_format_str2(pt_MESSAGE_860026653," AR <%s> avec date DC inferieure a la date d'activation <%s> de la facturation CPS",pt_NORM_860026653,pt_TEMP_860026653)
		code_errone_860026653 = 0xA082
		erreur_860026653 = i_PlvMessEmettre( 8599, 1, g_iartin,"", 3,code_errone_860026653, C_Article_860026653, pt_MESSAGE_860026653 )
		SAUT ELIMINE_EXP
	SINON
		#######################################
		#  Soumission de la requete de consultation d'une table de distribution ALICE
		#######################################
		SI i_strplcmp (pt_NORM_860026653,"0",0,1) == 0
		ALORS
			i_get_sub_str(pt_NORM_860026653,1,-1,pt_NORM_860026653) 	
		FINSI
		longueur_860026653 = i_conv_ascii_dcb (pt_NORM_860026653, pt_TEMP_860026653)
		SI (i_EnvoiReqConsTabDist( TD_SVA_860026653,gmt_date_860026653,pt_TEMP_860026653,longueur_860026653,0,1) != 0)
		ALORS
			#trace("Erreur i_EnvoiReqConsTabDist ALICE")
			bREDIST_SVA_860026653 = 1
			i_strcpy(pt_LIBELREDIST_860026653,"Echec sur i_EnvoiReqConsTabDistDouble ALICE ")
		FINSI
		
		#######################################
		# Recherche de l'instance ECC ALICE
		#######################################
		instALICE_860026653 = i_LireInstanceECC(C_INST_ALICE_860026653)
		SI (!instALICE_860026653)
		ALORS
			#trace("Pas d'instance pour ALICE !")
			erreur_860026653 = i_PlvMessEmettre(8501,1,g_iartin,"",3,C_INST_ALICE_860026653,C_Article_860026653,g_ieec)
			SAUT DISTRI_ERR
		FINSI
		#trace1("instALICE  =<%d>",instALICE)	

		#######################################
		# Lecture Resultat requete ALICE
		#######################################
		erreur_860026653 = i_LireReqConsTabDist()
		#trace1("RETOUR i_LireReqConsTabDist retour requette ALICE, erreur=<%d>",erreur)
		SI ( erreur_860026653 != 0 )
		ALORS
			#trace1( "Erreur i_LireReqConsTabDist ALICE: <%d>", erreur)
			bREDIST_SVA_860026653 = 1
			i_strcpy(pt_LIBELREDIST_860026653,"Echec sur i_LireReqConsTabDistDouble ALICE ")
		FINSI
		val_860026653 = i_LireInfoECC( instALICE_860026653, 0 )
		
		i_strcpy(pt_TEMP_860026653,"")
		SI (val_860026653 != 0)
		ALORS
			# AR present dans ALICE
			erreur_860026653 = i_LireChaineInfo( val_860026653, 0, 4, pt_TEMP_860026653 )
			SI i_strcmp(pt_TEMP_860026653,"") != 0
			ALORS
				#G4R7 Lot3 QC829
				b_ALICE_860026653 = 1
				i_strcpy(pt_CODE_TARIF_860026653,pt_TEMP_860026653)
			SINON
				# info complementaire CODE_TARIF vide
				bREDIST_SVA_860026653 = 1
				erreur_860026653 = i_format_str2(pt_LIBELREDIST_860026653," AR <%s> trouve dans LAR ALICE mais aucune info complementaire valorisee",pt_NORM_860026653,0)
			FINSI
			
			erreur_860026653 = i_LireChaineInfo( val_860026653, 4, 1, pt_TEMP_860026653 )
			SI i_strcmp(pt_TEMP_860026653,"") != 0
			ALORS
				#G4R7 Lot3 QC829
				b_ALICE_860026653 = 1
				i_strcpy(pt_TYPE_EDIT_860026653,pt_TEMP_860026653)
			SINON
				# info complementaire TYPE_EDIT vide
				bREDIST_SVA_860026653 = 1
				erreur_860026653 = i_format_str2(pt_LIBELREDIST_860026653," AR <%s> trouve dans LAR ALICE mais aucune info complementaire valorisee",pt_NORM_860026653,0)
			FINSI
		SINON
			bREDIST_SVA_860026653 = 1
			erreur_860026653 = i_format_str2(pt_LIBELREDIST_860026653," AR <%s> non trouve dans ALICE",pt_NORM_860026653,0)
		FINSI
	FINSI
FINSI
#\DRE G4R6 lot3


##############################################################################
# Envoi Requetes Table de Distribution ACLA
##############################################################################

erreur_860026653=i_get_art_str(g_iartin,$Trpvi2::TRANS_NUM,pt_champ_860026653)
#trace2("--Trpiv2 -appel ACLA : <%s>----------",pt_champ,"")

pt_CodeSCP_860026653 = CodeOperateurTable6_860026233(gmt_date_860026653, pt_champ_860026653,"ACLA")
#trace2("--Trpiv2 -resultat pt_CodeSCP : <%s>--------",pt_CodeSCP,"")

SI (!i_strcmp(pt_CodeSCP_860026653, "84008"))
ALORS
	EPortabilite_SCP_860026653 = 1
SINON
	EPortabilite_SCP_860026653 = 0
	SI (i_strcmp(pt_CodeSCP_860026653,"84008")!=0 && i_strcmp(pt_CodeSCP_860026653,"")!=0)
	ALORS
		SPortabilite_SCP_860026653 = 1
	SINON
		SPortabilite_SCP_860026653 = 0
	FINSI
FINSI

SI (EPortabilite_SCP_860026653 == 1)
ALORS
	CCD_REEL_860026653 = 218
SINON
	SI (SPortabilite_SCP_860026653 == 1)
	ALORS
		CCD_REEL_860026653 = 219
	SINON
		CCD_REEL_860026653 = i_get_art_field(g_iartin,$Trpvi2::CCD)
	FINSI
FINSI

#trace1("EPortabilite_SCP <%d>", EPortabilite_SCP)
#trace1("SPortabilite_SCP <%d>", SPortabilite_SCP)
#trace1("        ccd     <%d>", ccd)
#trace1("        CCD_REEL <%d>", CCD_REEL)

#******** Mise en forme de l AR pour appel au referentiel

SI ( calltype_860026653 == 0x19 || calltype_860026653 == 0x1A || calltype_860026653 == 0x18 || calltype_860026653 == 0x34 || calltype_860026653 == 0x35 
  || calltype_860026653 == 0x42 || calltype_860026653 == 0x36 || calltype_860026653 == 0x37 || calltype_860026653 == 0x43 )
ALORS
	erreur_860026653 = i_dup_chp_1val(g_iartin, g_iartin, $Trpvi2::DEDE_NUM, $Trpvi2::AR)
SINON
	SI ( calltype_860026653 == 0x1B || calltype_860026653 == 0x50 || calltype_860026653 == 0x51 || calltype_860026653 == 0x60 
	  || calltype_860026653 == 0x61 || calltype_860026653 == 0x44 )
	ALORS
		erreur_860026653 = i_dup_chp_1val(g_iartin, g_iartin, $Trpvi2::ORIG_NUM, $Trpvi2::AR)
	SINON
		SI ( calltype_860026653 == 0x06 || calltype_860026653 == 0x07 || calltype_860026653 == 0x08 || calltype_860026653 == 0x09 
		  || calltype_860026653 == 0x1C || calltype_860026653 == 0x1D )
		ALORS
			##############################################################################
			### CMMuserIdent sans 33
			##############################################################################
			SI ( i_valid_field_n(g_iartin, $Trpvi2::CMMuserIdent) 
			  && i_valid_field_n(g_iartin, $Trpvi2::AdrCMMuserId))
			ALORS
				erreur_860026653 = i_get_art_str(g_iartin, $Trpvi2::CMMuserIdent, pt_champ_860026653)
				res_860026653=i_get_art_field(g_iartin, $Trpvi2::AdrCMMuserId)
				i_get_sub_str(pt_champ_860026653, 0, 1, pt_debChamp_860026653)

				SI ( res_860026653==0x04 && i_strcmp("33", pt_debChamp_860026653) == 0)
				ALORS
					#******************suppression du prefixe 33 ***************
					erreur_860026653 = i_dup_chp_1val(g_iartin, g_iartin, $Trpvi2::CMMuserIdent, $Trpvi2::AR)
					erreur_860026653 = i_supp_quart_num($Trpvi2::AR, 0, 2, 0x0f, g_iartin, g_iartin)
				SINON
					erreur_860026653 = i_dup_chp_1val(g_iartin, g_iartin, $Trpvi2::CMMuserIdent, $Trpvi2::AR)
				FINSI
			FINSI
		SINON
			erreur_860026653 = i_dup_chp_1val(g_iartin, g_iartin, $Trpvi2::IDUS_NUM, $Trpvi2::AR)
		FINSI
	FINSI
FINSI

L_AR_860026653= i_get_art_fieldlength(g_iartin,$AR)

SI ( L_AR_860026653 % 2 == 0 )
ALORS
	L_AR_860026653 = L_AR_860026653 / 2
SINON
	L_AR_860026653 = L_AR_860026653 / 2 + 1
FINSI

erreur_860026653 = i_EnvoiReqConsTabDistDouble( TD_Fixe, TD_Fixe, gmt_date_860026653,i_get_art_fieldptr(g_iartin,$AR), L_AR_860026653, L_AR_860026653, 1, 0, 1)

SI ( erreur_860026653 !=0 )
ALORS
	trace1("Erreur i_EnvoiReqConsTabDistDouble : %d", erreur_860026653)
	bREDIST_860026653 = 1
	#pt_LIBELREDIST = "Echec sur i_EnvoiReqConsTabDistDouble"
	i_strcpy(pt_LIBELREDIST_860026653,"Echec sur i_EnvoiReqConsTabDistDouble")
FINSI

############################################################################
# Distribution
############################################################################

############################################################################
# Recherche Instances des ECC
############################################################################

#---------------------------------------------------------------------------
#  FERPV
#---------------------------------------------------------------------------

instFERPV_860026653 = i_LireInstanceECC("FERPV")
#trace1("instFERPV=<%d>",instFERPV)

SI (!instFERPV_860026653)
ALORS
	#trace( "instance FERPV nulle! (ou erreur)=> envoi vers cette ECC impossible" )
	code_errone_860026653 = 0xA0B1
	erreur_860026653 = i_PlvMessEmettre(8601,2,g_iartin,"",3,code_errone_860026653,C_InstFERPV_860026653,C_Article_860026653)
	SAUT DISTRI_ERR
FINSI

#---------------------------------------------------------------------------
#  ARAVIS
#---------------------------------------------------------------------------

instARAVIS_860026653 = i_LireInstanceECC("ARAVIS")
#trace1("instARAVIS=<%d>",instARAVIS)

SI (!instARAVIS_860026653)
ALORS
	#trace( "instance ARAVIS nulle! (ou erreur)=> envoi vers cette ECC impossible" )
	code_errone_860026653 = 0xA0B1
	erreur_860026653 = i_PlvMessEmettre(8601,2,g_iartin,"",3,code_errone_860026653,C_InstARAVIS_860026653,C_Article_860026653)
	SAUT DISTRI_ERR
FINSI

#---------------------------------------------------------------------------
#  SYMPHONIE
#---------------------------------------------------------------------------

instSYMP_860026653=i_LireInstanceECC(C_InstSYMPH_860026653)
#trace1("instSYMP=<%d>",instSYMP)

SI (!instSYMP_860026653 )
ALORS
	trace("pas d instance SYMPHONIE")
	code_errone_860026653 = 0xA0B1
	erreur_860026653 = i_PlvMessEmettre(8601,2,g_iartin,"",3,code_errone_860026653,C_InstSYMPH_860026653,C_Article_860026653)
	SAUT DISTRI_ERR
FINSI

############################################################################
# Critere de distribution
############################################################################

##############################################################################
# Retour requetes Table de Distribution
##############################################################################

erreur_860026653 = i_LireReqConsTabDist()
#trace1("RETOUR i_LireReqConsTabDist, erreur=<%d>",erreur)

SI ( erreur_860026653 != 0 )
ALORS
	bREDIST_860026653 = 1
	#pt_LIBELREDIST = "Echec sur i_LireReqConsTabDist"
	i_strcpy(pt_LIBELREDIST_860026653,"Echec sur i_LireReqConsTabDist")
#	SAUT REDIST
	SAUT AVANT_REDIST
FINSI

##############################################################################
# Lecture Info Complementaire du LAR FERPV
# Recherche du type d'offre (service)
# Evol G2R2Cv : Recherche si TYPAR_Etelephonie
##############################################################################

res_860026653 = i_LireInfoECC(instFERPV_860026653, 0)
#trace1("Retour de i_LireInfoECC -  FERPV: <%d>",res)

SI (res_860026653 != 0)
ALORS
	#trace( "FERPV appartient a la table DISTRI")
	erreur_860026653 = i_LireChaineInfo(res_860026653,0,1,pt_InfoCompl_860026653)

	SI (i_strcmp(pt_InfoCompl_860026653,"1")==0)
	ALORS
		#*** Atout RPV *****
		i_strcpy(pt_service_860026653,"1")
	SINON
		SI (i_strcmp(pt_InfoCompl_860026653,"2")==0)
		ALORS
			#*** VPNU *****
			i_strcpy(pt_service_860026653,"2")
		SINON
			#*** VPNU GE *****
			i_strcpy(pt_service_860026653,"4")
		FINSI
	FINSI

	erreur_860026653=i_LireChaineInfo(res_860026653,1,2,pt_InfoCompl_860026653)
	#trace2("  G2R2Cv 20 ou 25 TYPAR_Etelephonie pour lecture referentiel <%s>",pt_InfoCompl, "")

	SI ( i_strcmp(pt_InfoCompl_860026653,"20") == 0 || i_strcmp(pt_InfoCompl_860026653,"25") == 0 )
	ALORS
		TYPAR_Etelephonie_860026653=1
		#trace("  G2R2Cv TYPAR_Etelephonie VRAI)
	FINSI
SINON
	#*** AR non present dans LAR*****
	i_strcpy(pt_service_860026653,"4")
FINSI

############################################################################
# Critere de distribution
############################################################################

## ARAVIS
res_860026653=i_get_art_field(g_iartin, $Trpvi2::TRANS_INF)
#DRE G4R6 QC818
#SI ( typ_ctr != CPT_CPS_RI && calltype != 0x0F && ( VPN == 1 || res == 4 ) && 
#   ( calltype != 0x01 && calltype != 0x14 && calltype != 0x50 && calltype != 0x51 && calltype != 0x18 
#  && calltype != 0x19 && calltype != 0x1A && calltype != 0x36 && calltype != 0x43 && calltype != 0x06 
#  && calltype != 0x1C && calltype != 0x07 && calltype != 0x1D || RETOUR_CORR ) )
SI ( calltype_860026653 != 0x0F && ( VPN_860026653 == 1 || res_860026653 == 4 )  
  && (
     calltype_860026653 != 0x01 && calltype_860026653 != 0x14 && calltype_860026653 != 0x50 && calltype_860026653 != 0x51 && calltype_860026653 != 0x18 && calltype_860026653 != 0x19 && calltype_860026653 != 0x1A && calltype_860026653 != 0x36 && calltype_860026653 != 0x43 && calltype_860026653 != 0x06 && calltype_860026653 != 0x1C && calltype_860026653 != 0x07 && calltype_860026653 != 0x1D 
     || RETOUR_CORR_860026653 
     ) 
   ) 
ALORS
	res_860026653 = i_LireInfoECC(instARAVIS_860026653, 0)
	#trace1("Retour de i_LireInfoECC -  ARAVIS: <%d>",res)

	SI (res_860026653 != 0)
	ALORS
		#trace( "ARAVIS appartient a la table DISTRI")
		res_860026653=i_AjouterCouranteECC(instARAVIS_860026653)
		# G4R7 Lot3 QC831
		#i_strcpy(pt_EccFact,"ARAVIS")
		b_ARAVIS_860026653=1
	FINSI
FINSI

#---------------------------------------------------------------------------
# FERPV
#---------------------------------------------------------------------------

#SI ( !b_ARAVIS && ( RETOUR_CORR || ( calltype != 0x01 && calltype != 0x14 && calltype != 0x50 && calltype != 0x51 && calltype != 0x18 && calltype != 0x19 && calltype != 0x1A && calltype != 0x36 && calltype != 0x43 && calltype != 0x06 && calltype != 0x1C && calltype != 0x07 && calltype != 0x1D && calltype != 0x34 && calltype != 0x35 && calltype != 0x37 && calltype != 0x0F ) ) )
#DRE QC818
#SI ( typ_ctr != CPT_CPS_RI && !b_ARAVIS 

#DRE G4R8C5 QC871

#SI ( !b_ARAVIS 
#	&& ( RETOUR_CORR 
#	  || ( calltype != 0x01 && calltype != 0x14 && calltype != 0x50 && calltype != 0x51 && calltype != 0x18 && calltype != 0x19 && calltype != 0x1A && calltype != 0x36 && calltype != 0x43 && calltype != 0x06 && calltype != 0x1C && calltype != 0x07 && calltype != 0x1D && calltype != 0x34 && calltype != 0x35 && calltype != 0x37 && calltype != 0x0F ) 
#	   )
#	&& !( ( b_Fact_CPS_Loc || b_Fact_CPS_RI ) && !b_ALICE )
#    )
#ALORS
#	res=i_AjouterCouranteECC(instFERPV)
#	# G4R7 Lot3 QC831
#	#i_strcpy(pt_EccFact,"FE")
#
#	#DRE G4R6 Lot3
#	b_FERPV = 1
#FINSI
#

#DRE G4R8C5 QC871
SI ( calltype_860026653 != 0x01 && calltype_860026653 != 0x14 && calltype_860026653 != 0x50 && calltype_860026653 != 0x51 && calltype_860026653 != 0x18 && calltype_860026653 != 0x19 && calltype_860026653 != 0x1A && calltype_860026653 != 0x36 && calltype_860026653 != 0x43 && calltype_860026653 != 0x06 && calltype_860026653 != 0x1C && calltype_860026653 != 0x07 && calltype_860026653 != 0x1D && calltype_860026653 != 0x34 && calltype_860026653 != 0x35 && calltype_860026653 != 0x37 && calltype_860026653 != 0x0F ) 
ALORS
	b_FERPV_860026653 = 1
FINSI

#G4R8C6 QC871 ajout test sur compteur retour de redistri (trait_ok)
SI ( !b_ARAVIS_860026653 
	&& ( RETOUR_CORR_860026653  ||  b_FERPV_860026653  || trait_ok_860026653 > 0 )
	&& !( ( b_Fact_CPS_RI_860026653 || b_Fact_CPS_Loc_860026653 ) && !b_ALICE_860026653 )
    )
ALORS
	res_860026653=i_AjouterCouranteECC(instFERPV_860026653)

FINSI
#\DRE G4R8C5 QC871


#---------------------------------------------------------------------------
# SYMPHONIE
#---------------------------------------------------------------------------
POINT AVANT_REDIST
#SI (!RETOUR_CORR)
SI (!RETOUR_CORR_860026653 && trait_ok_860026653 == 0)
ALORS
	res_860026653=i_AjouterCouranteECC(instSYMP_860026653)
FINSI

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

#---------------------------------------------------------------------------
# Valeurs communes
#---------------------------------------------------------------------------

##############################################################################
###TYPACCRI
##############################################################################

SI ( calltype_860026653==0x06 || calltype_860026653==0x08 || calltype_860026653==0x1C )
ALORS
	i_get_sub_str(pt_IDUS_NUM_860026653, 0, 2, pt_debChamp_860026653)
	SI ( i_strcmp("596", pt_debChamp_860026653 ) == 0 || i_strcmp( "590", pt_debChamp_860026653 ) == 0 || i_strcmp( "594", pt_debChamp_860026653 ) == 0 || i_strcmp( "262", pt_debChamp_860026653 ) == 0 )
	ALORS
		#***** RMTA depuis les DOM
		i_strcpy(pt_TYPACCRI_860026653,"8")
	SINON
		#***** RMTA France metropoloitaine
		i_strcpy(pt_TYPACCRI_860026653,"6")
	FINSI
SINON
	SI (calltype_860026653==0x07 || calltype_860026653==0x09 || calltype_860026653==0x1D)
	ALORS
		#***** RMTA international
		i_strcpy(pt_TYPACCRI_860026653,"7")
	SINON
		#***** Normal
		i_strcpy(pt_TYPACCRI_860026653,"1")
	FINSI
FINSI

##############################################################################
###NATAPPRI FO1773
##############################################################################
SI ( calltype_860026653==0x19 )
ALORS
	#***welcomecall***
	i_strcpy(pt_NATAPPRI_860026653, "1" )
SINON
	SI ( calltype_860026653==0x30 || calltype_860026653==0x60 )
	ALORS
		#***consultation annuaire en plan prive***
		i_strcpy(pt_NATAPPRI_860026653, "9" )
	SINON
		SI ( calltype_860026653==0x31 || calltype_860026653==0x61 )
		ALORS
			#***consultation annuaire avec MER echouee****
			i_strcpy(pt_NATAPPRI_860026653, "C" )
		SINON
			SI ( calltype_860026653==0x40 || calltype_860026653==0x42 || calltype_860026653==0x43 || calltype_860026653==0x44 )
			ALORS
				#****MER****
				i_strcpy(pt_NATAPPRI_860026653, "B" )
			SINON
				SI (calltype_860026653==0x36 )
				ALORS
					#***consultation annuaire en plan public***
					i_strcpy(pt_NATAPPRI_860026653, "A" )
				SINON
					i_strcpy(pt_NATAPPRI_860026653, " " )
				FINSI
			FINSI
		FINSI
	FINSI
FINSI
#trace1("calltype 0x<%x>",calltype)
#trace2("NATAPPRI   <%s>",pt_NATAPPRI,"")

#############################################################################
# NUMDDR
#############################################################################

SI ( calltype_860026653 == 0x18 || calltype_860026653 == 0x19 || calltype_860026653 == 0x1A || calltype_860026653 == 0x34 || calltype_860026653 == 0x35 
  || calltype_860026653 == 0x42 || calltype_860026653 == 0x36 || calltype_860026653 == 0x37 || calltype_860026653 == 0x43 )
ALORS
	#******* AVE public ----> 0 + DEDE_NUM ******************
	erreur_860026653 = i_get_art_str(g_iartin,$DEDE_NUM, pt_champ_860026653)
	erreur_860026653 = i_format_str2(pt_NUMDDR_860026653,"%s%s","0",pt_champ_860026653)
SINON
	#******* Appel VPN renvoye ----> 0 + ORIG_NUM ******************
	SI ( calltype_860026653 == 0x1B || calltype_860026653 == 0x50 || calltype_860026653 == 0x60 || calltype_860026653 == 0x61 
	  || calltype_860026653 == 0x44 || calltype_860026653==0x51 )
	ALORS
		erreur_860026653 = i_get_art_str(g_iartin,$ORIG_NUM, pt_OrigCalledNb_860026653)
		erreur_860026653 = i_format_str2(pt_NUMDDR_860026653,"%s%s","0",pt_OrigCalledNb_860026653)
	SINON
		#******* Appel RMTA ----> CMMuserIdent ******************
		SI ( calltype_860026653 == 0x06 || calltype_860026653 == 0x07 || calltype_860026653 == 0x08 || calltype_860026653 == 0x09 
		  || calltype_860026653 == 0x1C || calltype_860026653 == 0x1D )
		ALORS
			#***************** CMMuserIdent *********************
			SI ( i_valid_field_n(g_iartin, $Trpvi2::CMMuserIdent) 
			  && i_valid_field_n(g_iartin, $Trpvi2::AdrCMMuserId))
			ALORS
				erreur_860026653 = i_get_art_str(g_iartin, $Trpvi2::CMMuserIdent, pt_champ_860026653)
				res_860026653=i_get_art_field(g_iartin, $Trpvi2::AdrCMMuserId)
				i_get_sub_str(pt_champ_860026653, 0, 1, pt_debChamp_860026653)
				SI ( res_860026653==0x04 && i_strcmp("33", pt_debChamp_860026653) == 0)
				ALORS
					#******************CMMuserIdent suppression du prefixe 33 et ajout de 0**************
					i_get_sub_str(pt_champ_860026653, 2, -1, pt_champ_860026653)
					erreur_860026653 = i_format_str2(pt_NUMDDR_860026653,"%s%s","0",pt_champ_860026653)
				SINON
					#******************CMMuserIdent avec ajout de 0  ***************
					erreur_860026653 = i_format_str2(pt_NUMDDR_860026653,"%s%s","0",pt_champ_860026653)
				FINSI
			FINSI
		SINON
			#************* 0 + IDUS_NUM *****************
			erreur_860026653 = i_format_str2(pt_NUMDDR_860026653,"%s%s","0",pt_IDUS_NUM_860026653)
		FINSI
	FINSI
FINSI
#trace2(" NUMDDR = <%s> ",pt_NUMDDR, " ")

#############################################################################
# PERFORMANCE_PREFERENCE
#############################################################################

PERFORMANCE_PREFERENCE_860026653 = 0
erreur_860026653 = i_get_art_str(g_iartin,$TRANS_NUM, pt_champ_860026653)
i_strcpy(pt2_860026653,pt_champ_860026653)
i_get_sub_str(pt2_860026653, 0,4, pt_champ_860026653)

SI( i_strcmp(pt_champ_860026653,"83648")==0 || i_strcmp(pt_champ_860026653,"83649")==0)
ALORS
	PERFORMANCE_PREFERENCE_860026653 = 1
FINSI

#---------------------------------------------------------------------------
# ARAVIS
#---------------------------------------------------------------------------

SI (!i_ChercherCouranteECC(instARAVIS_860026653))
ALORS
	#trace("Stockage vers ARAVIS")
	# transformation de DATE_M en date de debut car Taravis (dlot_abs) attend une date de debut dans DATE_M
	res_860026653 = i_get_art_field(g_iartin, $Trpvi2::dfin) - i_get_art_field(g_iartin, $Trpvi2::DUREE)
	erreur_860026653 = i_set_attr_val_n( $E_Trpvi2::DATE_M, res_860026653)
	# Creation article Taravis
	SI (i_dup_art_dest( g_iartin, g_iartout8, C_Taravis_860026653 ))
	ALORS
		code_errone_860026653 = 0xA0D1
		erreur_860026653 = i_PlvMessEmettre(8602,2,g_iartin,"",3,code_errone_860026653,C_Taravis_860026653,C_Article_860026653)
		SAUT DISTRI_ERR
	FINSI
	# G4R7 Lot3 QC831
	i_strcpy(pt_EccFact_860026653,"ARAVIS")

	#NDDR
	SI ( calltype_860026653 == 0x18 || calltype_860026653 == 0x19 || calltype_860026653 == 0x1A || calltype_860026653 == 0x34 || calltype_860026653 == 0x35 
	  || calltype_860026653 == 0x42 || calltype_860026653 == 0x36 || calltype_860026653 == 0x37 || calltype_860026653 == 0x43 )
	ALORS
		#******* Appel Accueil ----> 0 + DEDE_NUM ******************
		erreur_860026653 = i_get_art_str(g_iartin,$DEDE_NUM, pt_champ_860026653)
		erreur_860026653 = i_format_str2(pt2_860026653,"%s%s","0",pt_champ_860026653)
		erreur_860026653 = i_set_art_str(g_iartout8,$Taravis::NDDR,pt2_860026653)
	SINON
		#******* Appel VPN renvoye ----> 0 + ORIG_NUM ******************
		SI ( calltype_860026653 == 0x1B || calltype_860026653 == 0x50 || calltype_860026653 == 0x60 || calltype_860026653 == 0x61 
		  || calltype_860026653 == 0x44 || calltype_860026653 == 0x51 )
		ALORS
			erreur_860026653 = i_get_art_str(g_iartin,$ORIG_NUM, pt_OrigCalledNb_860026653)
			erreur_860026653 = i_format_str2(pt2_860026653,"%s%s","0",pt_OrigCalledNb_860026653)
			erreur_860026653 = i_set_art_str(g_iartout8,$Taravis::NDDR,pt2_860026653)
		SINON
			#******* Appel RMTA ----> CMMuserIdent ******************
			SI ( calltype_860026653 == 0x06 || calltype_860026653 == 0x07 || calltype_860026653 == 0x08 || calltype_860026653 == 0x09 
			  || calltype_860026653 == 0x1C || calltype_860026653 == 0x1D )
			ALORS
				#***************** CMMuserIdent *********************
				SI ( i_valid_field_n(g_iartin, $Trpvi2::CMMuserIdent) 
				  && i_valid_field_n(g_iartin, $Trpvi2::AdrCMMuserId))
				ALORS
					erreur_860026653 = i_get_art_str(g_iartin, $Trpvi2::CMMuserIdent, pt_champ_860026653)
					res_860026653=i_get_art_field(g_iartin, $Trpvi2::AdrCMMuserId)
					i_get_sub_str(pt_champ_860026653, 0, 2, pt_debChamp_860026653)

					SI ( res_860026653==0x04 && i_strcmp("33", pt_debChamp_860026653) == 0 )
					ALORS
						#******************CMMuserIdent suppression du prefixe 33 ***************
						i_get_sub_str(pt_champ_860026653, 2, -1, pt_champ_860026653)
						erreur_860026653 = i_format_str2(pt2_860026653,"%s%s","0",pt_champ_860026653)
						erreur_860026653 = i_set_art_str(g_iartout8,$Taravis::NDDR,pt2_860026653)
					SINON
						#******************CMMuserIdent  ***************
						erreur_860026653 = i_format_str2(pt2_860026653,"%s%s","0",pt_champ_860026653)
						erreur_860026653 = i_set_art_str(g_iartout8,$Taravis::NDDR,pt2_860026653)
					FINSI
				FINSI
			SINON
				#************* 0 + IDUS_NUM *****************
				erreur_860026653 = i_format_str2(pt_champ_860026653,"%s%s","0",pt_IDUS_NUM_860026653)
				erreur_860026653 = i_set_art_str(g_iartout8,$Taravis::NDDR,pt_champ_860026653)
			FINSI
		FINSI
	FINSI

	#DEBCUM
	erreur_860026653 = i_set_art_field(g_iartout8,$Taravis::DEBCUM,HLAHM1_860026653)

	#TYPE
	SI ( i_strcmp(pt_TYPCOM_860026653,"1")==0)
	ALORS
		#****** Prive ****
		erreur_860026653 = i_set_art_str(g_iartout8,$Taravis::TYPE,"1")
	SINON
		#****** Public ****
		erreur_860026653 = i_set_art_str(g_iartout8,$Taravis::TYPE,"2")
	FINSI

	#SUPPORT
	SI ( calltype_860026653 == 0x06 || calltype_860026653 == 0x08 || calltype_860026653 == 0x1C || calltype_860026653 == 0x09 || calltype_860026653 == 0x1D )
	ALORS
		erreur_860026653 = i_set_art_str(g_iartout8,$Taravis::SUPPORT,"2")
	SINON
		erreur_860026653 = i_set_art_str(g_iartout8,$Taravis::SUPPORT,"1")
	FINSI

	#DEDE
	erreur_860026653 = i_get_art_str(g_iartin, $Trpvi2::TRANS_NUM, pt_champ_860026653)
	SI ( i_strcmp(pt_TYPCOM_860026653,"1")==0)
	ALORS
		#****** Numero prive*****
		i_get_sub_str(pt_champ_860026653, -7, -1, pt_finChamp_860026653)
		erreur_860026653 = i_set_art_str(g_iartout8,$Taravis::DEDE,pt_finChamp_860026653)
	SINON
		#****** Numero public*****
		erreur_860026653 = i_set_art_str(g_iartout8,$Taravis::DEDE,pt_champ_860026653)
	FINSI

	#COMID_ID
	erreur_860026653 = i_set_art_field(g_iartout8, $Taravis::COMID_ID,1 )

	# COMID_NUM
	# Remarque : etant donne que le processing travaille en entier signe, on ne peut travailler
	# que sur des valeurs numeriques codees sur 31 bits. En consequence, on se limite a 15 bits
	# (soit 32767 max) pour le codage du numero de bloc

	# Recuperation de l identifiant d audit (voir ME_PCODE pour le detail de sa structure)
	pt_marque_audit_860026653=i_LireMarqueAudit()

	# Recuperation de l'horadatage
	comid_n1_860026653 = (i_strtab(pt_marque_audit_860026653,2)*256 + i_strtab(pt_marque_audit_860026653,3)) & 0x1FFF
	#trace1("comid_n1 : %d",comid_n1)
	erreur_860026653 = i_set_art_field(g_iartout8, $Taravis::COMID_N1, comid_n1_860026653 )

	# Recuperation identifiant EEC (6eme octet) EEC
	# Masquage des 6 bits de poids faible
	EEC_audit_860026653 = i_strtab(pt_marque_audit_860026653, 5) & 0x3f
	#trace1("EEC_audit : %d", EEC_audit)

	# Recuperation identifiant de bloc (7 et 8eme octet)
	# Masquage des 15 bits de poids faible
	bloc_audit_860026653 =  ( ( i_strtab(pt_marque_audit_860026653, 6) * 256 ) + i_strtab(pt_marque_audit_860026653, 7) ) & 0x7fff
	#trace1("bloc_audit : %d", bloc_audit)

	# Recuperation identifiant du DC (11 et 12eme octet)
	# Masquage des 10 bits de poids faible
	DC_audit_860026653 = ( ( i_strtab(pt_marque_audit_860026653, 10) * 256 ) + i_strtab(pt_marque_audit_860026653, 11) ) & 0x3ff
	#trace1("DC_audit : %d", DC_audit)

	# Mise en forme pour ARAVIS COMID_NUM
	# On realise les masquages/concatenation par multiplication
	# Coefficients : 00000010000000000000000000000000 soit 2e25 soit 33554432
	#                00000000000000000000010000000000 soit 2e10 soit 1024
	comid_num_860026653 = (EEC_audit_860026653 * 33554432) + (bloc_audit_860026653 * 1024) + DC_audit_860026653
	#trace1("comid_num : %u", comid_num)
	erreur_860026653 = i_set_art_field(g_iartout8, $Taravis::COMID_NUM, comid_num_860026653 )

	# TYPSRV
	erreur_860026653 = i_set_art_field(g_iartout8,$Taravis::TYPSRV, 1)
FINSI

#---------------------------------------------------------------------------
# FERPV
#---------------------------------------------------------------------------

#DRE - G4R7 QC818
#SI (!i_ChercherCouranteECC(instFERPV))
SI (!i_ChercherCouranteECC(instFERPV_860026653) && bREDIST_SVA_860026653 == 0 )
ALORS
	#trace("Stockage vers FERPV")
	# Duplication article en entree

	SI (i_dup_art_dest( g_iartin, g_iartout, C_Tfe_rpv_860026653 ))
	ALORS
		code_errone_860026653 = 0xA0D1
		erreur_860026653 = i_PlvMessEmettre(8602,2,g_iartin,"",3,code_errone_860026653,C_Tfe_rpv_860026653,C_Article_860026653)
		SAUT DISTRI_ERR
	FINSI

	# G4R7 Lot3 QC831
	i_strcpy(pt_EccFact_860026653,"FE")

	#############################################################################
	# SERVICE
	#############################################################################
	erreur_860026653 = i_set_art_str(g_iartout,$Tfe_rpv::SERVICE,pt_service_860026653)

	#############################################################################
	# SOURCE
	#############################################################################

	#################################################################################
	#										#
	# 	G2R2Cv	Evolution convergence de RPV vers IP (TYPAR_Etelephony)		#
	#										#
	#################################################################################

	SI(TYPAR_Etelephonie_860026653)
	ALORS
		erreur_860026653 = i_set_art_str(g_iartout,$Tfe_rpv::SOURCE,"08")
	SINON
		SI( calltype_860026653==0x19 || calltype_860026653==0x18 || calltype_860026653==0x1A || PERFORMANCE_PREFERENCE_860026653 )
		ALORS
			erreur_860026653 = i_set_art_str(g_iartout,$Tfe_rpv::SOURCE,"06")
		SINON
			SI ( calltype_860026653==0x06 || calltype_860026653==0x08 || calltype_860026653== 0x1C )
			ALORS
				i_get_sub_str(pt_IDUS_NUM_860026653, 0, 2, pt_debChamp_860026653)
				SI ( i_strcmp("596", pt_debChamp_860026653) == 0 || i_strcmp("590", pt_debChamp_860026653) == 0 
				  || i_strcmp("594", pt_debChamp_860026653) == 0 || i_strcmp("262", pt_debChamp_860026653) == 0 )
				ALORS
					#***RI RMTA DOM
					erreur_860026653 = i_set_art_str(g_iartout,$Tfe_rpv::SOURCE,"04")
				SINON
					#***RI RMTA National
					erreur_860026653 = i_set_art_str(g_iartout,$Tfe_rpv::SOURCE,"01")
				FINSI
			SINON
				SI ( calltype_860026653==0x07 || calltype_860026653==0x09 || calltype_860026653== 0x1D )
				ALORS
					#***RI RMTA international
					erreur_860026653 = i_set_art_str(g_iartout,$Tfe_rpv::SOURCE,"02")
				SINON
					SI ( calltype_860026653==0x30 || calltype_860026653==0x36 || calltype_860026653== 0x60 )
					ALORS
						#***consultation AVE
						erreur_860026653 = i_set_art_str(g_iartout,$Tfe_rpv::SOURCE,"10")
					SINON
						SI(calltype_860026653==0x31 || calltype_860026653==0x61)
						ALORS
							#***echec AVE
							erreur_860026653 = i_set_art_str(g_iartout,$Tfe_rpv::SOURCE,"13")
						SINON
							SI(calltype_860026653==0x40 || calltype_860026653==0x44)
							ALORS
								#***MER plan prive
								erreur_860026653 = i_set_art_str(g_iartout,$Tfe_rpv::SOURCE,"11")
							SINON
								SI(calltype_860026653==0x42 || calltype_860026653==0x43)
								ALORS
									#***MER plan public
									erreur_860026653 = i_set_art_str(g_iartout,$Tfe_rpv::SOURCE,"12")
								SINON
									#***RI normal
									erreur_860026653 = i_set_art_str(g_iartout,$Tfe_rpv::SOURCE,"05")
								FINSI
							FINSI
						FINSI
					FINSI
				FINSI
			FINSI
		FINSI
	FINSI

	#############################################################################
	# TYPCOM
	#############################################################################

	erreur_860026653 = i_set_art_str(g_iartout,$Tfe_rpv::TYPCOM,pt_TYPCOM_860026653)

	#############################################################################
	# NUMDDR
	#############################################################################

	erreur_860026653 = i_set_art_str(g_iartout,$Tfe_rpv::NUMDDR,pt_NUMDDR_860026653)

	#############################################################################
	# NUMDDE
	#############################################################################

	#################################################################
	#trace1("RenvoiMessagerie : %d", RenvoiMessagerie)
	#trace1("GestionRenvoi : %d", GestionRenvoi)
	#trace1("ConsultAnnVocal : %d", ConsultAnnVocal)
	#trace1("PERFORMANCE_PREFERENCE : %d", PERFORMANCE_PREFERENCE)
	#################################################################
	# - valorisation du champ NUMDE avec $Trpvi2::TRANS_NUM pour RenvoiMessagerie
	res_860026653= i_get_art_field(g_iartin, $Trpvi2::TRANS_INF)
	erreur_860026653 = i_get_art_str(g_iartin, $Trpvi2::TRANS_NUM, pt_TransNb_860026653)
	i_get_sub_str(pt_TransNb_860026653, 0,4, pt_debChamp_860026653)
	trace2(" pt_transNum : <%s>", pt_TransNb_860026653," ")

	SI ( i_strcmp ( "60808", pt_debChamp_860026653 ) == 0 )
	ALORS
		# (Consultation Messagerie Vocale)
		erreur_860026653 = i_set_art_str(g_iartout,$Tfe_rpv::NUMDDE,"ConsultationMessages")
	SINON
		SI ( RenvoiMessagerie_860026653 )
		ALORS
			#erreur = i_get_art_str(g_iartin,$ORIG_NUM, pt_OrigCalledNb)
			#erreur = i_format_str2(pt2,"%s%s","0",pt_OrigCalledNb)
			erreur_860026653 = i_format_str2(pt2_860026653,"%s%s","0",pt_TransNb_860026653)
			erreur_860026653 = i_set_art_str(g_iartout,$Tfe_rpv::NUMDDE,pt2_860026653)
		SINON
			SI ( GestionRenvoi_860026653 )
			ALORS
				#Appel serveur vocal
				erreur_860026653 = i_set_art_str(g_iartout,$Tfe_rpv::NUMDDE,"AppelServeurVocal")
			SINON
				SI ( ConsultAnnVocal_860026653 )
				ALORS
					#Annuaire Vocal
					erreur_860026653 = i_set_art_str(g_iartout,$Tfe_rpv::NUMDDE,"AnnuaireVocal")
				SINON
					#** Formatage du DEDE avant analyse *******
					#**** Numero special / ne change pas********
					SI ( res_860026653==0x02 || res_860026653==0x73 )
					ALORS
						i_strcpy(pt2_860026653,pt_TransNb_860026653)
					FINSI
					#**** Numero national / ajout de 0 ******
					SI(res_860026653==0x03)
					ALORS
						erreur_860026653 = i_format_str2(pt2_860026653,"%s%s","0",pt_TransNb_860026653)
					FINSI
					#**** Numero international / ajout de 00 **********
					SI(res_860026653==0x04)
					ALORS
						erreur_860026653 = i_format_str2(pt2_860026653,"%s%s","00",pt_TransNb_860026653)
					FINSI
					erreur_860026653 = i_set_art_str(g_iartout,$Tfe_rpv::NUMDDE,pt2_860026653)
				FINSI
				#erreur = i_set_art_str(g_iartout,$Tfe_rpv::NUMDDE,pt2)
			FINSI
		FINSI
	FINSI

	SI ( PERFORMANCE_PREFERENCE_860026653 )
	ALORS
		erreur_860026653 = i_set_art_str(g_iartout,$Tfe_rpv::NUMDDE,pt2_860026653)
		i_get_sub_str(pt2_860026653,0,7,pt2_860026653)
		erreur_860026653 = i_set_art_str(g_iartout,$Tfe_rpv::NUMDDE,pt2_860026653)
	FINSI

	#############################################################################
	# DEBUT ParamFTSA-G3R12
	#############################################################################

	erreur_860026653 = i_set_art_field(g_iartout,$Tfe_rpv::DEBUT,HLAHM1_860026653)

	#############################################################################
	# DUREE
	#############################################################################

	res_860026653 = i_get_art_field(g_iartin,$DUREE)
	erreur_860026653 = i_set_art_field(g_iartout,$Tfe_rpv::DUREE,res_860026653)

	#############################################################################
	# NBCOD
	#############################################################################

	NbCsv_860026653 = 0
	NumChamp_860026653 = 0
	erreur_860026653 = i_set_art_field(g_iartout,$Tfe_rpv::NBCOD,NbCsv_860026653)
	NumChamp_860026653 = $Tfe_rpv::NBCOD + 1
	#** Gestion des renvois *******
	SI (calltype_860026653==0xCB || calltype_860026653==0x20 || calltype_860026653==0x08 || calltype_860026653==0x09)
	ALORS
		NbCsv_860026653 = NbCsv_860026653 + 1
		# C_CSVx
		pt_csv_860026653 = C_CSV_860026233("RI","01",dpivot_860026653)
		erreur_860026653 = i_set_art_str(g_iartout,NumChamp_860026653,pt_csv_860026653)
		NumChamp_860026653 = NumChamp_860026653 + 1
		# OP_CSVx
		pt_opcsv_860026653 = OP_CSV_860026233("RI","01",dpivot_860026653)
		erreur_860026653 = i_set_art_str(g_iartout,NumChamp_860026653,pt_opcsv_860026653)
		NumChamp_860026653 = NumChamp_860026653 + 1
	FINSI

	#** TransNb commence par 60808 (consultation messagerie vocale)
	erreur_860026653 = i_get_art_str(g_iartin, $Trpvi2::TRANS_NUM, pt_TransNb_860026653)
	i_get_sub_str(pt_TransNb_860026653, 0,4, pt_debChamp_860026653)
	SI ( i_strcmp("60808", pt_debChamp_860026653 ) == 0 )
	ALORS
		NbCsv_860026653 = NbCsv_860026653 + 1
		# C_CSVx
		pt_csv_860026653 = C_CSV_860026233("RI","03",dpivot_860026653)
		erreur_860026653 = i_set_art_str(g_iartout,NumChamp_860026653,pt_csv_860026653)
		NumChamp_860026653 = NumChamp_860026653 + 1
		# OP_CSVx
		pt_opcsv_860026653 = OP_CSV_860026233("RI","03",dpivot_860026653)
		erreur_860026653 = i_set_art_str(g_iartout,NumChamp_860026653,pt_opcsv_860026653)
		NumChamp_860026653 = NumChamp_860026653 + 1
	FINSI

	SI ( calltype_860026653==0x14 || calltype_860026653==0x1A || calltype_860026653==0x1D || calltype_860026653==0x1C || calltype_860026653==0x1B 
	  || calltype_860026653==0x36 || calltype_860026653==0x43 || calltype_860026653==0x37 || calltype_860026653==0x51 )
	ALORS
		SI ( RenvoiMessagerie_860026653 )
		ALORS
			NbCsv_860026653 = NbCsv_860026653 + 1
			# C_CSVx
			pt_csv_860026653 = C_CSV_860026233("RI","05",dpivot_860026653)
			erreur_860026653 = i_set_art_str(g_iartout,NumChamp_860026653,pt_csv_860026653)
			NumChamp_860026653 = NumChamp_860026653 + 1
			# OP_CSVx
			pt_opcsv_860026653 = OP_CSV_860026233("RI","05",dpivot_860026653)
			erreur_860026653 = i_set_art_str(g_iartout,NumChamp_860026653,pt_opcsv_860026653)
			NumChamp_860026653 = NumChamp_860026653 + 1
		SINON
			NbCsv_860026653 = NbCsv_860026653 + 1
			# C_CSVx
			pt_csv_860026653 = C_CSV_860026233("RI","04",dpivot_860026653)
			erreur_860026653 = i_set_art_str(g_iartout,NumChamp_860026653,pt_csv_860026653)
			NumChamp_860026653 = NumChamp_860026653 + 1
			# OP_CSVx
			pt_opcsv_860026653 = OP_CSV_860026233("RI","04",dpivot_860026653)
			erreur_860026653 = i_set_art_str(g_iartout,NumChamp_860026653,pt_opcsv_860026653)
			NumChamp_860026653 = NumChamp_860026653 + 1
		FINSI
	FINSI
	erreur_860026653 = i_set_art_field(g_iartout,$Tfe_rpv::NBCOD,NbCsv_860026653)

	#############################################################################
	# TYPACCRI
	#############################################################################

	erreur_860026653 = i_set_art_str(g_iartout,$Tfe_rpv::TYPACCRI,pt_TYPACCRI_860026653)

	#############################################################################
	# SUPPORT G3R0Cu alpha
	#############################################################################

	res_860026653 =i_get_art_field(g_iartin, $Trpvi2::TsvInd)

	SI ( res_860026653 == 0x01)
	ALORS
		erreur_860026653 = i_set_art_str(g_iartout,$Tfe_rpv::SUPPORT,"4")
	SINON
		erreur_860026653 = i_set_art_str(g_iartout,$Tfe_rpv::SUPPORT,"0")
	FINSI

	#############################################################################
	# NOCOMP
	#############################################################################

	erreur_860026653 = i_get_art_str(g_iartin,$DEDE_NUM, pt_champ_860026653)
	erreur_860026653 = i_set_art_str(g_iartout,$Tfe_rpv::NOCOMP,pt_champ_860026653)

	#############################################################################
	# NOORIG
	#############################################################################

	SI ( i_valid_field_n(g_iartin, $Trpvi2::AddCallingNb))
	ALORS
		erreur_860026653 = i_get_art_str(g_iartin, $Trpvi2::AddCallingNb, pt_AddCallingNb_860026653)
		AdrAddCallingNb_860026653=i_get_art_field(g_iartin, $Trpvi2::AdrAddCallNb)
		i_get_sub_str(pt_AddCallingNb_860026653, 0, 1, pt_debChamp_860026653)

		SI (AdrAddCallingNb_860026653==0x04 && i_strcmp("33", pt_debChamp_860026653) == 0)
		ALORS
			i_get_sub_str(pt_AddCallingNb_860026653, 2, -1, pt_AddCallingNb_860026653)
			AdrAddCallingNb_860026653=0x03
		FINSI

		SI (AdrAddCallingNb_860026653==0x03)
		ALORS
			erreur_860026653 = i_format_str2(pt_champ_860026653,"%s%s","0",pt_AddCallingNb_860026653)
		FINSI

		SI (AdrAddCallingNb_860026653==0x04 )
		ALORS
			erreur_860026653 = i_format_str2(pt_champ_860026653,"%s%s","00",pt_AddCallingNb_860026653)
		FINSI
	SINON
		i_strcpy(pt_champ_860026653," ")
	FINSI

	SI ( calltype_860026653==0x07 || calltype_860026653==0x08|| calltype_860026653==0x09 || calltype_860026653==0x1D || calltype_860026653==0x06 || calltype_860026653==0x1C )
	ALORS
		erreur_860026653 = i_set_art_str(g_iartout,$Tfe_rpv::NOORIG," ")
	SINON
		erreur_860026653 = i_set_art_str(g_iartout,$Tfe_rpv::NOORIG,pt_champ_860026653)
	FINSI

	#############################################################################
	# NATAPPRI
	#############################################################################

	erreur_860026653 = i_set_art_str(g_iartout,$Tfe_rpv::NATAPPRI,pt_NATAPPRI_860026653)

	#############################################################################
	# CCD
	#############################################################################

	#trace1( "CCD_REEL : <%d>", CCD_REEL)
	SI ( CCD_REEL_860026653 != 0xff )
	ALORS
#		erreur = i_cree_art("Conversion",g_iartout10)
		ccd_860026653 = CCD_REEL_860026653 + 1000
		erreur_860026653 = i_set_art_field(g_iartout10,$Conversion::CCD, ccd_860026653)
		erreur_860026653 = i_conv_field("CCD",g_iartout10, 2, g_iartout, 4,0)
		erreur_860026653 = i_get_art_str(g_iartout,$Tfe_rpv::CCD,pt_champ_860026653)
		i_get_sub_str(pt_champ_860026653,1,3,pt2_860026653)
		erreur_860026653 = i_set_art_str(g_iartout,$Tfe_rpv::CCD,pt2_860026653)
	SINON
		erreur_860026653=i_memset_field_n(g_iartout, $Tfe_rpv::CCD, 0x40)
	FINSI

	#############################################################################
	# DDR_RMTA
	#Deux numeros ont ete attribues pour que les numeros demandeurs dans les Details de Communications soient remplaces
	#par Platine par un numero technique  dans le cas d'appels RMTA depuis les DOM et depuis l'etranger (RMTA = Remote
	#Access = service se substituant a la carte) .
	#
	#Ces numeros ne sont pas des numeros d'acheminement, ils permettront a FE de calculer le montant des communications
	#RMTA passees a partir de postes situes hors de la metropole.
	#(FE ne disposant pas de tables de tarif pour facturer ces types d'appels).
	#############################################################################

	SI ( calltype_860026653==0x06 || calltype_860026653==0x08|| calltype_860026653==0x1C )
	ALORS
		i_get_sub_str(pt_IDUS_NUM_860026653, 0, 2, pt_debChamp_860026653)
		SI (i_strcmp(pt_debChamp_860026653,"596")==0 || i_strcmp(pt_debChamp_860026653,"590")==0 || i_strcmp(pt_debChamp_860026653,"594")==0 || i_strcmp(pt_debChamp_860026653,"262")==0)
		ALORS
			#** numero special DDR_RMTA DOM
			erreur_860026653 = i_set_art_str(g_iartout,$Tfe_rpv::DDR_RMTA,"0222222222")
		SINON
			i_get_sub_str(pt_IDUS_NUM_860026653, 0, 0, pt_debChamp_860026653)

			SI ((i_strcmp(pt_debChamp_860026653,"6")==0) || (i_strcmp(pt_debChamp_860026653,"7")==0))
			ALORS
				#** numero special DDR_RMTA mobile
				erreur_860026653 = i_set_art_str(g_iartout,$Tfe_rpv::DDR_RMTA,"0333333333")
			SINON
				#**** ajout de 0 devant IDUS_NUM
				erreur_860026653 = i_format_str2(pt2_860026653,"%s%s","0",pt_IDUS_NUM_860026653)
				erreur_860026653 = i_set_art_str(g_iartout,$Tfe_rpv::DDR_RMTA,pt2_860026653)
			FINSI
		FINSI
	FINSI
	SI ( calltype_860026653==0x07 || calltype_860026653==0x09|| calltype_860026653==0x1D )
	ALORS
		#** numero special RMTA international
		erreur_860026653 = i_set_art_str(g_iartout,$Tfe_rpv::DDR_RMTA, "0111111111")
	FINSI

# DRE G4R6 Lot3

	# TYPE_EDIT
	erreur_860026653=i_set_art_str(g_iartout, $Tfe_rpv::TYPE_EDIT, pt_TYPE_EDIT_860026653)
	
	# CODE_TARIF
	erreur_860026653=i_set_art_str(g_iartout, $Tfe_rpv::CODE_TARIF, pt_CODE_TARIF_860026653)
# \DRE G4R6 lot3
	




FINSI

#----------------------------------------------------------------------------
# Symphonie
#----------------------------------------------------------------------------

SI( !i_ChercherCouranteECC(instSYMP_860026653))
ALORS
	#trace("Duplication vers SYMPHONIE")
	erreur_860026653 = i_dup_art_tab(g_iartin,g_iartout2,C_TSymTrpvi2_860026653)
	# ******* NBCOD et CSVi *******************
	NbCsv_860026653 = 0
	NumChamp_860026653 = 0
	erreur_860026653 = i_set_art_field(g_iartout2,$TsymTrpvi2::NBCOD,NbCsv_860026653)
	NumChamp_860026653 = $TsymTrpvi2::NBCOD +3
	#** Gestion des renvois *******
	SI (calltype_860026653==0xCB || calltype_860026653==0x20 || calltype_860026653==0x08 || calltype_860026653==0x09)
	ALORS
		NbCsv_860026653 = NbCsv_860026653 + 1
		# C_CSVx
		pt_csv_860026653 = C_CSV_860026233("RI","01",dpivot_860026653)
		# OP_CSVx
		pt_opcsv_860026653 = OP_CSV_860026233("RI","01",dpivot_860026653)
		erreur_860026653 = i_format_str2(pt_champ_860026653,"%s%s",pt_csv_860026653,pt_opcsv_860026653)
		erreur_860026653 = i_ajoutChampNum(g_iartout2, NumChamp_860026653-2,NumChamp_860026653,0)
		erreur_860026653 = i_set_art_str(g_iartout2,NumChamp_860026653,pt_champ_860026653)
		NumChamp_860026653 = NumChamp_860026653 + 3
	FINSI
	#** TransNb commence par 60808 (consultation messagerie vocale)
	i_get_sub_str(pt_TransNb_860026653, 0,4, pt_debChamp_860026653)
	SI (i_strcmp("60808", pt_debChamp_860026653) == 0 )
	ALORS
		NbCsv_860026653 = NbCsv_860026653 + 1
		# C_CSVx
		pt_csv_860026653 = C_CSV_860026233("RI","03",dpivot_860026653)
		# OP_CSVx
		pt_opcsv_860026653 = OP_CSV_860026233("RI","03",dpivot_860026653)
		erreur_860026653 = i_format_str2(pt_champ_860026653,"%s%s",pt_csv_860026653,pt_opcsv_860026653)
		erreur_860026653 = i_ajoutChampNum(g_iartout2, NumChamp_860026653-2,NumChamp_860026653,0)
		erreur_860026653 = i_set_art_str(g_iartout2,NumChamp_860026653,pt_champ_860026653)
		NumChamp_860026653 = NumChamp_860026653 + 3
	FINSI

	SI ( calltype_860026653==0x14 || calltype_860026653==0x1A || calltype_860026653==0x1D || calltype_860026653==0x1C || calltype_860026653==0x1B 
	  || calltype_860026653==0x36 || calltype_860026653==0x43 || calltype_860026653==0x37 || calltype_860026653==0x51)
	ALORS
		SI ( RenvoiMessagerie_860026653 )
		ALORS
			NbCsv_860026653 = NbCsv_860026653 + 1
			# C_CSVx
			pt_csv_860026653 = C_CSV_860026233("RI","05",dpivot_860026653)
			# OP_CSVx
			pt_opcsv_860026653 = OP_CSV_860026233("RI","05",dpivot_860026653)
			erreur_860026653 = i_format_str2(pt_champ_860026653,"%s%s",pt_csv_860026653,pt_opcsv_860026653)
			erreur_860026653 = i_ajoutChampNum(g_iartout2, NumChamp_860026653-2,NumChamp_860026653,0)
			erreur_860026653 = i_set_art_str(g_iartout2,NumChamp_860026653,pt_champ_860026653)
		SINON
			NbCsv_860026653 = NbCsv_860026653 + 1
			# C_CSVx
			pt_csv_860026653 = C_CSV_860026233("RI","04",dpivot_860026653)
			# OP_CSVx
			pt_opcsv_860026653 = OP_CSV_860026233("RI","04",dpivot_860026653)
			erreur_860026653 = i_format_str2(pt_champ_860026653,"%s%s",pt_csv_860026653,pt_opcsv_860026653)
			erreur_860026653 = i_ajoutChampNum(g_iartout2, NumChamp_860026653-2,NumChamp_860026653,0)
			erreur_860026653 = i_set_art_str(g_iartout2,NumChamp_860026653,pt_champ_860026653)
		FINSI
	FINSI
	erreur_860026653 = i_set_art_field(g_iartout2,$TsymTrpvi2::NBCOD,NbCsv_860026653)

	# ******* HLAHM1 avec FO2219 *******************
	SI (i_strlen(pt_IDUS_NUM_860026653) > 2)
	ALORS
		i_get_sub_str(pt_IDUS_NUM_860026653, 0, 2, pt_debChamp_860026653)
		SI (i_strcmp("596", pt_debChamp_860026653) == 0 || i_strcmp("590", pt_debChamp_860026653) == 0 || i_strcmp("594", pt_debChamp_860026653) == 0 || i_strcmp("262", pt_debChamp_860026653) == 0)
		ALORS
			erreur_860026653 = i_ajoutChampNum(g_iartout2, $TsymTrpvi2::T4date_locale,$TsymTrpvi2::DATE_LOCALE,0)
			HLAHM1_860026653 = i_get_art_field(g_iartin,$Trpvi2::HLAHM1)
			erreur_860026653 = i_set_art_field(g_iartout2,$TsymTrpvi2::DATE_LOCALE,HLAHM1_860026653)
		FINSI
	FINSI

	# ************** SGTQS *****************
	erreur_860026653=i_set_art_str(g_iartout2,$TsymTrpvi2::SGTQS,i_LireEECSGTQS( g_ieec ))

	# ************** ECC_FACT *****************
	SI(i_strcmp(" ", pt_EccFact_860026653) != 0 && !bREDIST_860026653) 
	ALORS
		erreur_860026653=i_set_art_str(g_iartout2, $TsymTrpvi2::ECC_FACT,pt_EccFact_860026653)
	FINSI

	# ************** CODCIR et CODCIRDR *****************
	# CODCIRDR
	erreur_860026653=i_get_art_str(g_iartin, $Trpvi2::CODCIRDA,pt_codcirdr_860026653)
	SI(i_strcmp("202020", pt_codcirdr_860026653) != 0)
	ALORS
		erreur_860026653 = i_ajoutChampNum(g_iartout2, $TsymTrpvi2::T4codcirdr,$TsymTrpvi2::CODCIRDR,0)
		SI (g_iartin.CODCIRDA[2] > 9)
		ALORS
			i_get_sub_str(pt_codcirdr_860026653,2,5,pt_codcirdr_860026653)
		SINON
			i_get_sub_str(pt_codcirdr_860026653,1,5,pt_codcirdr_860026653)
		FINSI
		erreur_860026653=i_set_art_str(g_iartout2,$TsymTrpvi2::CODCIRDR,pt_codcirdr_860026653)
	FINSI

	# CODCIR
	erreur_860026653 = i_get_art_str(g_iartin, $Trpvi2::CODCIRA, pt_codcir_860026653)
	SI(i_strcmp("202020", pt_codcir_860026653) != 0)
	ALORS
		erreur_860026653 = i_ajoutChampNum(g_iartout2, $TsymTrpvi2::T4codcir,$TsymTrpvi2::CODCIR,0)
		SI (g_iartin.CODCIRA[2] > 9)
		ALORS
			i_get_sub_str(pt_codcir_860026653,2,5,pt_codcir_860026653)
		SINON
			i_get_sub_str(pt_codcir_860026653,1,5,pt_codcir_860026653)
		FINSI
		erreur_860026653=i_set_art_str(g_iartout2,$TsymTrpvi2::CODCIR,pt_codcir_860026653)
	FINSI

	# ************** OFFRE_DDEUR *****************
	erreur_860026653=i_set_art_str(g_iartout2, $TsymTrpvi2::OFFRE_DDEUR,pt_service_860026653)

	# TYPACCRI
	erreur_860026653=i_set_art_str(g_iartout2, $TsymTrpvi2::TYPACCRI,pt_TYPACCRI_860026653)

	# NATAPPRI
	erreur_860026653=i_set_art_str(g_iartout2, $TsymTrpvi2::NATAPPRI,pt_NATAPPRI_860026653)

	#CCD avec CCD_REEL
	erreur_860026653 = i_set_art_field(g_iartout2,$TsymTrpvi2::CCD,CCD_REEL_860026653)

	
# DRE G4R6 Lot3
	# TYPE_EDIT
	SI i_strcmp(pt_TYPE_EDIT_860026653," ") != 0
	ALORS
		erreur_860026653 = i_ajoutChampNum(g_iartout2, $TsymTrpvi2::T4type_edit,$TsymTrpvi2::TYPE_EDIT,0)
		erreur_860026653=i_set_art_str(g_iartout2, $TsymTrpvi2::TYPE_EDIT, pt_TYPE_EDIT_860026653)
	FINSI

	# CODE_TARIF
	SI i_strcmp(pt_CODE_TARIF_860026653,"    ") != 0
	ALORS
		erreur_860026653 = i_ajoutChampNum(g_iartout2, $TsymTrpvi2::T4code_tarif,$TsymTrpvi2::CODE_TARIF,0)
		erreur_860026653=i_set_art_str(g_iartout2, $TsymTrpvi2::CODE_TARIF, pt_CODE_TARIF_860026653)
	FINSI
# \DRE G4R6 Lot3




FINSI

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

#---------------------------------------------------------------------------
# ARAVIS
#---------------------------------------------------------------------------

SI (!i_ChercherCouranteECC(instARAVIS_860026653) )
ALORS
	res_860026653 = i_stocke_art_iecc( g_iartout8, instARAVIS_860026653 )
FINSI

#----------------------------------------------------------------------------
# Symphonie
#----------------------------------------------------------------------------

SI (! i_ChercherCouranteECC(instSYMP_860026653))
ALORS
	#trace("emission vers symphonie")
	erreur_860026653  = i_stocke_art_iecc(g_iartout2,instSYMP_860026653)
FINSI

#---------------------------------------------------------------------------
# REDISTRIBUTION
#---------------------------------------------------------------------------

# DRE G4R8 QC871
# DRE G4R6 Lot3
#SI ( bREDIST == 1 || (bREDIST_SVA == 1 && b_FERPV == 1) )
#G4R8C6 QC871
SI ( bREDIST_860026653 == 1 || (bREDIST_SVA_860026653 == 1 && ( b_FERPV_860026653 == 1 || RETOUR_CORR_860026653 || trait_ok_860026653 > 0 ) && !b_ARAVIS_860026653 ) )
ALORS
	SAUT REDIST
FINSI
# \DRE G4R6 Lot3

#---------------------------------------------------------------------------
# FERPV
#---------------------------------------------------------------------------

SI (!i_ChercherCouranteECC(instFERPV_860026653) )
ALORS
	res_860026653 = i_stocke_art_iecc( g_iartout, instFERPV_860026653 )
FINSI


RETOUR TRAIT_OK
#trace("Fin du Pcode de distribution Trpvi2")

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

POINT DISTRI_ERR

#trace( "Stockage en errone de distribution")
res_860026653 = i_make_art_rej(g_iartin, g_iartout9, code_errone_860026653)
res_860026653 = i_stocke_art( g_iartout9, 0, PT_ERRONE, 0)

RETOUR TRAIT_OK

############################################################################
# Stockage en REDISTRIBUTION
############################################################################

POINT REDIST

#DRE - G4R7 QC818
SI (trait_ok_860026653 == 0)
ALORS
	erreur_860026653 = i_PlvMessEmettre(8503,2,g_iartin,"",3,pt_LIBELREDIST_860026653,C_Article_860026653,pt_SGTQS_860026653)
FINSI
#\DRE - G4R7 QC818

res_860026653 = i_stocke_art( g_iartin, 0, PT_REDIST|RD_TABLE1, 0 )

RETOUR TRAIT_OK

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

POINT ELIMINE_EXP

trace( "Stockage en elimine explicite")
res_860026653 = i_stocke_art( g_iartin, 0, PT_DIVERS, 0 )

RETOUR TRAIT_OK

# \DRE G4R6 lot3

# fin de fichier Trpvi2_dis.src -----------------------------------------------
