DEFINITION C_Article_860026645 "Trpvi2"
DEFINITION C_prefixe33_860026645 "33"
DEFINITION NUMTAB_METRO_860026645 2
DEFINITION NUMTABSEL_860026645 0
DEFINITION CATEG_860026645 0
DEFINITION CODE_ARTICLE_860026645 1 
DEFINITION BASE_860026645 1
DEFINITION RES_CLDEST_860026645 1
DEFINITION RES_CODCIR_860026645 3
DEFINITION RES_CODCIRDR_860026645 5
DEFINITION RES_TYPCTR_860026645 2
REGISTRE ENTIER hlahm1_860026645
REGISTRE ENTIER Callednb_adrind_860026645
REGISTRE ENTIER Callingnb_adrind_860026645
REGISTRE ENTIER Origcalled_AdrInd_860026645
REGISTRE ENTIER TransNb_AdrInd_860026645
REGISTRE ENTIER Calltype_860026645
REGISTRE ENTIER Renvoi_Call_860026645
REGISTRE ENTIER Renvoi_Tr_860026645
REGISTRE ENTIER GestionRenvoi_860026645
REGISTRE ENTIER ConsultAnnVocal_860026645
REGISTRE ENTIER LA_Call_860026645
REGISTRE ENTIER LA_Tr_860026645
REGISTRE ENTIER VPN_Call_860026645
REGISTRE ENTIER VPN_Tr_860026645
REGISTRE ENTIER erreur_860026645
REGISTRE ENTIER code_errone_860026645
REGISTRE ENTIER res_860026645
REGISTRE ENTIER prefixe_33_860026645
REGISTRE ENTIER numzone_860026645
REGISTRE ENTIER existe_860026645
REGISTRE ENTIER longueur_860026645
REGISTRE ENTIER nb_supp_860026645
REGISTRE ENTIER bPERFORMANCE_860026645
REGISTRE ENTIER indice_860026645
REGISTRE ENTIER Appel_BNC_860026645
REGISTRE POINTEUR pt_CallingNb_860026645
REGISTRE POINTEUR pt_debCalling_860026645
REGISTRE POINTEUR pt_OrigCalledNb_860026645
REGISTRE POINTEUR pt_debOrig_860026645
REGISTRE POINTEUR pt_CalledNb_860026645
REGISTRE POINTEUR pt_debCalled_860026645
REGISTRE POINTEUR pt_TransNb_860026645
REGISTRE POINTEUR pt_debTransNb_860026645
REGISTRE POINTEUR pt_BUF50_860026645
REGISTRE POINTEUR pt_BUF7_860026645
############################################################################
#	Article DC RPVI2 en entree de Platine
#	Pcode de traitement
#	2004 - NSA- Creation
# Historique
# 02/09/2004 - NSA - FO817,FO842, FO849
# 13/09/2004 - NSA - FO863
# 22/11/2004 - NSA - FO943 prise en compte d'une nouvelle valeur pour( AdrCalledNb et AdrTransNb) = 0x73
# 18/01/2005 - DRE - FO1051 ne pas normaliser si Calltype=0x0F 
# 21/01/2005 - DRE - FO1062 ne pas normaliser si Calltype=(0xCB) ou (0x20) ou (0x08) ou (0x09) 
# 31/01/2005 - THE - G2R1Cg
# 22/03/2005 - THE - correction lot2
# 31/03/2005 - THE - FO 1197
# 31/03/2005 - THE - Integration FO1205 pas normalisation et appel base si num preference_performance
# 12/04/2005 - THE - FO 1205
# 18/05/2005 - THE - FO 1288
# 26/05/2005 - THE - FO 1323
# 14/06/2005 - THE - FO 1350 (Nouveau Calltype 51)
# 05/07/2006 - THEFAL - FO1848 (FO1205+) plus de norm /BNC si preference_performance
# 31/08/2007 - FAL - FO2219 controle de CallingNb 
# 14/10/2010 - DRE - G3R18 QC422 DC rpvi envoi en "errone"
#	05/10/2011 RHE VerifPcode
# 27/04/2012 - DRE - G3R23C8 QC594 DC rpvi envoi en "errone" champ OrigCalledNb incomplet (ne contient que 33)
# 29/05/2012 - THE - QC597 DC rpvi envoi en "errone" Pb alarme 6061
# 14/04/2014 - DRE - G4R6 : Lot3
# 14/01/2015 - DRE - G4R8C5 QC870 Pb de normalisation du DEDE si pas d'appel a la BNC
#
############################################################################

# Variables fonctionnelles globales

# Constantes pour message d alarme
# Constantes pour decalages horaires
# Base de comptage
# Definition des indices de resultat supplementaire proc_copo

#DRE G4R6 Lot3


# Variables fonctionnelles globales
# Divers
#DRE G4R6 lot3
#DRE G4R8C5 QC870

# Pointeurs

############################
# Initialisation variables #
############################

prefixe_33_860026645 = 0
hlahm1_860026645 = 0
numzone_860026645 = 0
Calltype_860026645=0
code_errone_860026645=0
Renvoi_Tr_860026645=0
Renvoi_Call_860026645=0
GestionRenvoi_860026645=0
ConsultAnnVocal_860026645=0
LA_Tr_860026645=0
LA_Call_860026645=0
VPN_Tr_860026645=0
VPN_Call_860026645=0
bPERFORMANCE_860026645 = 0
#DRE G4R6 lot3
indice_860026645 = 0
#DRE G4R8C5 QC870
Appel_BNC_860026645 = 0

pt_CallingNb_860026645	= "1111111111111111111111111111111111111111111111111"
pt_OrigCalledNb_860026645 = "7777777777777777777777777777777777777777777777777"
pt_CalledNb_860026645	=  "2222222222222222222222222222222222222222222222222"
pt_TransNb_860026645	=   "3333333333333333333333333333333333333333333333333"
pt_debCalling_860026645	="4444444444444444"
pt_debOrig_860026645	="8888888888888888"
pt_debCalled_860026645	="5555555555555555"
pt_debTransNb_860026645	="6666666666666666"
pt_BUF50_860026645	= "5050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050"
pt_BUF7_860026645		= "999999999999999999"

i_strcpy(pt_CallingNb_860026645,"")
i_strcpy(pt_OrigCalledNb_860026645,"")
i_strcpy(pt_CalledNb_860026645,"")
i_strcpy(pt_TransNb_860026645,"")
i_strcpy(pt_debCalling_860026645,"")
i_strcpy(pt_debOrig_860026645,"")
i_strcpy(pt_debCalled_860026645,"")
i_strcpy(pt_debTransNb_860026645,"")
i_strcpy(pt_BUF50_860026645,"")
i_strcpy(pt_BUF7_860026645,"")

##############################################################################
###	Controles semantiques et croises des champs 
##############################################################################

#trace("__FILE__:__LINE__ #### Debut pcode traitement")
### Type =0x02####
res_860026645 =i_get_art_field(g_iartin, $Trpvi2::TYPE)
SI ( res_860026645 != 0x02 )
ALORS
	code_errone_860026645 = 0x5041
	erreur_860026645 = i_PlvMessEmettre(6050,2,g_iartin,"",3,code_errone_860026645,C_Article_860026645,res_860026645)
	SAUT STOCKE_ERRONE
FINSI

### INF du numero demandeur= AdrCallingNb National( 0x03) ou International (0x04)  ####
SI ( i_valid_field_n(g_iartin, $Trpvi2::AdrCallingNb))
ALORS
	res_860026645 =i_get_art_field(g_iartin, $Trpvi2::AdrCallingNb)

	SI ( res_860026645!= 0x04 && res_860026645 != 0x03 )
	ALORS
		code_errone_860026645 = 0x5041
		erreur_860026645 = i_PlvMessEmettre(6051,2,g_iartin,"",3,code_errone_860026645,C_Article_860026645,res_860026645)
		SAUT STOCKE_ERRONE
	FINSI
FINSI

### INF du numero demande= AdrCalledNb compris entre 0x01 et 0x04
### Numero prive(0x01), Numero special (0x02), Numero national (0x03), Numero international (0x04)####

res_860026645 =i_get_art_field(g_iartin, $Trpvi2::AdrCalledNb)
SI ( res_860026645 <0x01 || (res_860026645 > 0x04 && res_860026645!=0x73))
ALORS
	code_errone_860026645 = 0x5041
	erreur_860026645 = i_PlvMessEmettre(6052,2,g_iartin,"",3,code_errone_860026645,C_Article_860026645,res_860026645)
	SAUT STOCKE_ERRONE
FINSI

### INF du numero traduit=AdrTransNb compris entre 0x02 et 0x04 ####
###  Numero special (0x02), Numiro national (0x03), Numero international (0x04)####

SI ( i_valid_field_n(g_iartin, $Trpvi2::AdrTransNb))
ALORS
	res_860026645 =i_get_art_field(g_iartin, $Trpvi2::AdrTransNb)
	SI ( res_860026645 < 0x02 || (res_860026645 > 0x04 && res_860026645!=0x73))
	ALORS
		code_errone_860026645 = 0x5041
		erreur_860026645 = i_PlvMessEmettre(6053,2,g_iartin,"",3,code_errone_860026645,C_Article_860026645,res_860026645)
		SAUT STOCKE_ERRONE
	FINSI
FINSI

##############################################################################
### 	calltype 
##############################################################################

Calltype_860026645 =i_get_art_field(g_iartin, $Trpvi2::calltype)
SI ( Calltype_860026645 != 0x01 && Calltype_860026645 != 0x06 && Calltype_860026645 != 0x07 && Calltype_860026645 != 0x08 && Calltype_860026645 != 0x09 && Calltype_860026645 != 0x0F && Calltype_860026645 != 0x14 && Calltype_860026645 != 0x18 && Calltype_860026645 != 0x19 && Calltype_860026645 != 0x1A && Calltype_860026645 != 0x1B && Calltype_860026645 != 0x1C && Calltype_860026645 != 0x1D && Calltype_860026645 != 0x20 && Calltype_860026645 != 0x30 && Calltype_860026645 != 0x31 && Calltype_860026645 != 0x34 && Calltype_860026645 != 0x35 && Calltype_860026645 != 0x36 && Calltype_860026645 != 0x37 && Calltype_860026645 != 0x40 && Calltype_860026645 != 0x42 && Calltype_860026645 != 0x43 && Calltype_860026645 != 0x44 && Calltype_860026645 != 0x50 && Calltype_860026645 != 0x51 && Calltype_860026645 != 0x60 && Calltype_860026645 != 0x61 && Calltype_860026645 != 0xCB ) 
ALORS
	code_errone_860026645 = 0x5041
	erreur_860026645 = i_PlvMessEmettre(6054,2,g_iartin,"",3,code_errone_860026645,C_Article_860026645,Calltype_860026645)
	SAUT STOCKE_ERRONE
FINSI

##############################################################################
### 	controle croises si Calltype!=0x1B  ---> CallingNb obligatoire 
##############################################################################

# le cas 33 seul pose egalement pb meme si Calltype !=0x1B ( AII )

SI (Calltype_860026645 != 0x1B)
ALORS
	SI ( !i_valid_field_n(g_iartin, $Trpvi2::CallingNb) )
	ALORS
		code_errone_860026645 = 0x5041
		erreur_860026645 = i_PlvMessEmettre(6065,2,g_iartin,"",3,code_errone_860026645,C_Article_860026645,Calltype_860026645)
		SAUT STOCKE_ERRONE
	SINON
		erreur_860026645 = i_get_art_str(g_iartin, $Trpvi2::CallingNb, pt_CallingNb_860026645)
		SI ( i_strcmp(pt_CallingNb_860026645,C_prefixe33_860026645)== 0 )
		ALORS
			code_errone_860026645 = 0x5041
			erreur_860026645 = i_PlvMessEmettre(6065,2,g_iartin,"",3,code_errone_860026645,C_Article_860026645,Calltype_860026645)
			SAUT STOCKE_ERRONE
		FINSI
	FINSI
FINSI
#/FO2219

##############################################################################
### 	controle croises si AdrCalledNb=0x01 TransNb obligatoire 
##############################################################################

res_860026645 = i_get_art_field(g_iartin, $Trpvi2::AdrCalledNb)
SI (res_860026645 == 0x01 && !i_valid_field_n(g_iartin, $Trpvi2::TransNb))
ALORS
	code_errone_860026645 = 0x5041
	erreur_860026645 = i_PlvMessEmettre(6064,2,g_iartin,"",3,code_errone_860026645,C_Article_860026645,res_860026645)
	SAUT STOCKE_ERRONE
FINSI

##############################################################################
### 	controle croises CMMuserIdentity et calltype RMTA 
##############################################################################

SI ( ( Calltype_860026645 == 0x06 || Calltype_860026645 == 0x07 || Calltype_860026645 == 0x08 
    || Calltype_860026645 == 0x09 || Calltype_860026645 == 0x1C || Calltype_860026645 == 0x1D ) 
   && !i_valid_field_n(g_iartin, $Trpvi2::CMMuserIdent ) )
ALORS
	code_errone_860026645 = 0x5041
	erreur_860026645 = i_PlvMessEmettre(6060,2,g_iartin,"",2,code_errone_860026645,C_Article_860026645,0)
	SAUT STOCKE_ERRONE
FINSI

# /QC597
##############################################################################
###	 controle croises OrigCalledNb et calltype DC renvoyes 
##############################################################################

#SI ( ( Calltype == 0x1B || Calltype == 0x14 || Calltype == 0x1A || Calltype == 0x1C || Calltype == 0x1D 
#    || Calltype == 0x36 || Calltype == 0x37 || Calltype == 0x43 || Calltype == 0x50 || Calltype == 0x60 
#    || Calltype == 0x61 || Calltype == 0x44 || Calltype == 0x51 ) 
#    && !i_valid_field_n ( g_iartin, $Trpvi2::OrigCalledNb )) 
SI ( ( Calltype_860026645 == 0x1B || Calltype_860026645 == 0x50 || Calltype_860026645 == 0x60 
    || Calltype_860026645 == 0x61 || Calltype_860026645 == 0x44 || Calltype_860026645 == 0x51 )
   && !i_valid_field_n( g_iartin, $Trpvi2::OrigCalledNb ) ) 
ALORS
	code_errone_860026645 = 0x5041
	erreur_860026645 = i_PlvMessEmettre(6061,2,g_iartin,"",2,code_errone_860026645,C_Article_860026645,0)
	SAUT STOCKE_ERRONE
FINSI

###  Type de service= TsvInd =0x01 ou 0x00 ou 0x0F ####
###  Voix (0x00), fax/donnee (0x01), inconnu (0x0F)####

res_860026645 =i_get_art_field(g_iartin, $Trpvi2::TsvInd)
SI ( res_860026645 != 0x00 &&  res_860026645 != 0x01 && res_860026645 != 0x0F )
ALORS
	code_errone_860026645 = 0x5041
	erreur_860026645 = i_PlvMessEmettre(6055,2,g_iartin,"",3,code_errone_860026645,C_Article_860026645,res_860026645)
	SAUT STOCKE_ERRONE
FINSI

###  AdrOrigCallNb = 0x03 ou 0x04 ####
###  numero national(0x03), numero international (0x04)   ####

SI ( i_valid_field_n(g_iartin, $Trpvi2::AdrOrigCallNb))
ALORS
	res_860026645 =i_get_art_field(g_iartin, $Trpvi2::AdrOrigCallNb)
	SI ( res_860026645 !=0x03 && res_860026645 !=0x04 )
	ALORS
		code_errone_860026645 = 0x5041
		erreur_860026645 = i_PlvMessEmettre(6056,2,g_iartin,"",3,code_errone_860026645,C_Article_860026645,res_860026645)
		SAUT STOCKE_ERRONE
	FINSI
FINSI

###  CharactCall = 0x00,0x01,0x0A,0x14,0x1E,0x28,0x0B,0x15,0x02,0x0C ####

SI ( i_valid_field_n(g_iartin, $Trpvi2::CharactCall) )
ALORS
	res_860026645 =i_get_art_field(g_iartin, $Trpvi2::CharactCall)

	SI ( res_860026645 !=0x00 && res_860026645 !=0x01 && res_860026645 !=0x02 && res_860026645 !=0x0A && res_860026645 !=0x0B && res_860026645 !=0x0C && res_860026645 !=0x14 && res_860026645 !=0x15 && res_860026645 !=0x1E && res_860026645 !=0x28 )
	ALORS
		code_errone_860026645 = 0x5041
		erreur_860026645 = i_PlvMessEmettre(6057,2,g_iartin,"",3,code_errone_860026645,C_Article_860026645,res_860026645)
		SAUT STOCKE_ERRONE
	FINSI
FINSI

###  AdrAddCallNb = 0x03,0x04 ####

SI ( i_valid_field_n(g_iartin, $Trpvi2::AdrAddCallNb) )
ALORS
	res_860026645 =i_get_art_field(g_iartin, $Trpvi2::AdrAddCallNb)
	SI (res_860026645 !=0x03 && res_860026645 !=0x04)
	ALORS
		code_errone_860026645 = 0x5041
		erreur_860026645 = i_PlvMessEmettre(6058,2,g_iartin,"",3,code_errone_860026645,C_Article_860026645,res_860026645)
		SAUT STOCKE_ERRONE
	FINSI
FINSI

###  AdrCMMuserId = 0x03,0x04 ####

SI ( i_valid_field_n(g_iartin, $Trpvi2::AdrCMMuserId) )
ALORS
	res_860026645 =i_get_art_field(g_iartin, $Trpvi2::AdrCMMuserId)
	SI (res_860026645 !=0x03 && res_860026645 !=0x04)
	ALORS
		code_errone_860026645 = 0x5041
		erreur_860026645 = i_PlvMessEmettre(6059,2,g_iartin,"",3,code_errone_860026645,C_Article_860026645,res_860026645)
		SAUT STOCKE_ERRONE
	FINSI
FINSI

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

Calltype_860026645=i_get_art_field(g_iartin, $Trpvi2::calltype)
SI ( Calltype_860026645==0xCB || Calltype_860026645==0x20 || Calltype_860026645==0x08 || Calltype_860026645==0x09 )
ALORS
	GestionRenvoi_860026645=1
FINSI

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

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

###############################################################################################
# Ajouts des champs qui seront utiles pour la distribution                                    #
# On passe par un ajout CE (et non par l'enveloppe)  :                                        #
# - certains champs sont de longueurs variables                                               #
# - cet ajout CE ne sera pas envoye a Symphonie car on changera d'article de sortie en distri #
###############################################################################################

erreur_860026645 = i_dup_art_id(g_iartin, g_iartout)

erreur_860026645 = i_ajoutChampNum(g_iartout, $Trpvi2::T4ccd,$Trpvi2::CCD,0)
erreur_860026645 = i_ajoutChampNum(g_iartout, $Trpvi2::T4codcirdr,$Trpvi2::CODCIRDR,0)
erreur_860026645 = i_ajoutChampNum(g_iartout, $Trpvi2::T4codcir,$Trpvi2::CODCIR,0)
erreur_860026645 = i_ajoutChampNum(g_iartout, $Trpvi2::T4idus,$Trpvi2::IDUS_NUM,0)
erreur_860026645 = i_ajoutChampNum(g_iartout, $Trpvi2::T4dede,$Trpvi2::DEDE_NUM,0)
erreur_860026645 = i_ajoutChampNum(g_iartout, $Trpvi2::T4trans,$Trpvi2::TRANS_NUM,0)
erreur_860026645 = i_ajoutChampNum(g_iartout, $Trpvi2::T4hlahm1,$Trpvi2::HLAHM1,0)
erreur_860026645 = i_ajoutChampNum(g_iartout, $Trpvi2::T4orig,$Trpvi2::ORIG_NUM,0)

################################################################################################
# 	Mise en forme des champs demandeurs et demandes avant normalisation                    #
################################################################################################

############### OrigCalledNb  ----> ORIG_NUM ##################################

SI ( i_valid_field_n(g_iartout, $Trpvi2::OrigCalledNb) )
ALORS
	erreur_860026645 = i_get_art_str(g_iartout, $Trpvi2::OrigCalledNb, pt_OrigCalledNb_860026645)
	res_860026645=i_get_art_field(g_iartout, $Trpvi2::AdrOrigCallNb)
	erreur_860026645 = i_dup_chp_1val(g_iartout, g_iartout, $Trpvi2::OrigCalledNb, $Trpvi2::ORIG_NUM)
	erreur_860026645 = i_dup_chp_1val(g_iartout, g_iartout, $Trpvi2::AdrOrigCallNb, $Trpvi2::ORIG_INF)
	SI ( res_860026645==0x04 ) 
	ALORS
		i_get_sub_str(pt_OrigCalledNb_860026645, 0, 1, pt_debOrig_860026645)
		SI (i_strcmp("33", pt_debOrig_860026645) == 0) 
		ALORS
			#******************suppression du prefixe 33 ***************
#G3R23C8 QC594
			SI i_get_art_field(g_iartout,$Trpvi2::L3OrigCalledNb) == 1
			ALORS
				# Cas ou OrigCalledNb ne contient que 33
				code_errone_860026645 = 0x5011
				erreur_860026645 = i_PlvMessEmettre(6066,2,g_iartin,"",2,code_errone_860026645,C_Article_860026645,0)
				SAUT STOCKE_ERRONE
			FINSI
#\G3R23C8 QC594
			i_get_sub_str(pt_OrigCalledNb_860026645, 2, -1, pt_OrigCalledNb_860026645)
			erreur_860026645 = i_supp_quart_num($Trpvi2::ORIG_NUM, 0, 2, 0x0f, g_iartout, g_iartout)
			Origcalled_AdrInd_860026645=3
		FINSI
		erreur_860026645 = i_set_art_field(g_iartout, $Trpvi2::ORIG_INF, Origcalled_AdrInd_860026645)
	FINSI
FINSI

############### Demandeur / Calling_Nb  ----> IDUS_NUM ##################################

SI ( i_valid_field_n(g_iartout, $Trpvi2::CallingNb) )
ALORS
	# si calltype != 0x1b alors  CallingNb obligatoire
	erreur_860026645 = i_get_art_str(g_iartout, $Trpvi2::CallingNb, pt_CallingNb_860026645)
	Callingnb_adrind_860026645 = i_get_art_field(g_iartin, $Trpvi2::AdrCallingNb)
	erreur_860026645 = i_dup_chp_1val(g_iartin, g_iartout, $Trpvi2::CallingNb, $Trpvi2::IDUS_NUM)
	i_get_sub_str(pt_CallingNb_860026645, 0,1, pt_debCalling_860026645)
	SI ( i_strcmp("33", pt_debCalling_860026645) == 0 ) 
	ALORS
		prefixe_33_860026645=1
		SI ( Callingnb_adrind_860026645==0x04)
		ALORS
			Callingnb_adrind_860026645=3
			erreur_860026645 = i_set_art_field(g_iartout, $Trpvi2::IDUS_INF, Callingnb_adrind_860026645)
			# suppression du prefixe 33 IMPOSSIBLE sauf si IDUS_NUM optionnel dans artobj
			erreur_860026645 = i_supp_quart_num($Trpvi2::IDUS_NUM, 0, 2, 0x0f, g_iartout, g_iartout)
		FINSI
	FINSI
	erreur_860026645 = i_set_art_field(g_iartout, $Trpvi2::IDUS_INF, Callingnb_adrind_860026645)
FINSI

############### Renvoi Messagerie / VPN_cooperant / Libre Appel ##################################

erreur_860026645 = i_get_art_str(g_iartout, $Trpvi2::CalledNb, pt_CalledNb_860026645)
i_get_sub_str(pt_CalledNb_860026645, 0, 4, pt_debCalled_860026645)
SI ( i_valid_field_n(g_iartout, $Trpvi2::TransNb) )
ALORS
	erreur_860026645 = i_get_art_str(g_iartout, $Trpvi2::TransNb, pt_TransNb_860026645)
	i_get_sub_str(pt_TransNb_860026645, 0, 4, pt_debTransNb_860026645)
FINSI

SI ( i_strcmp("07996", pt_debCalled_860026645) == 0 )
ALORS
	Renvoi_Call_860026645=1
FINSI

SI ( i_strcmp("07996", pt_debTransNb_860026645) == 0 )
ALORS
	Renvoi_Tr_860026645=1
FINSI

SI ( i_strcmp("15072", pt_debCalled_860026645) == 0 )
ALORS
	VPN_Call_860026645=1
FINSI

SI ( i_strcmp("15072", pt_debTransNb_860026645) == 0 )
ALORS
	VPN_Tr_860026645=1
FINSI

SI ( i_strcmp("15071", pt_debCalled_860026645) == 0 )
ALORS
	LA_Call_860026645=1
FINSI

SI ( i_strcmp("15071", pt_debTransNb_860026645) == 0 )
ALORS
	LA_Tr_860026645=1
FINSI

############### Demande/Numero compose/CalledNb ##################################

erreur_860026645 = i_dup_chp_1val(g_iartin, g_iartout, $Trpvi2::CalledNb, $Trpvi2::DEDE_NUM)
erreur_860026645 = i_dup_chp_1val(g_iartin, g_iartout, $Trpvi2::AdrCalledNb, $Trpvi2::DEDE_INF)

SI (Renvoi_Call_860026645==1 || VPN_Call_860026645==1 || LA_Call_860026645==1 )
ALORS
	#************************* suppression du prefixe Renvoi Messagerie ou VPN_cooperant ou Libre Appel
	erreur_860026645 = i_supp_quart_num($Trpvi2::DEDE_NUM, 0, 5, 0x0f, g_iartout, g_iartout)
FINSI

erreur_860026645 = i_get_art_str(g_iartout, $Trpvi2::DEDE_NUM, pt_CalledNb_860026645)
i_get_sub_str(pt_CalledNb_860026645, 0,1, pt_debCalled_860026645)
Callednb_adrind_860026645= i_get_art_field(g_iartin, $Trpvi2::AdrCalledNb) 

SI (i_strcmp("33", pt_debCalled_860026645) == 0 && Callednb_adrind_860026645==4) 
ALORS
	#******************Appel national suppression du prefixe 33 et mise a jour du champ INF***************
	erreur_860026645 = i_supp_quart_num($Trpvi2::DEDE_NUM, 0, 2, 0x0f, g_iartout, g_iartout)
	Callednb_adrind_860026645=3
SINON
	#******************Appel international VPN cooperant**********************************
	SI (i_strcmp("33", pt_debCalled_860026645) != 0 && Callednb_adrind_860026645==3 && VPN_Call_860026645==1) 
	ALORS	
		Callednb_adrind_860026645=4
	FINSI
	SI (i_strcmp("33", pt_debCalled_860026645) == 0 && Callednb_adrind_860026645==3) 
	ALORS
		#******************Appel national suppression du prefixe 33***************
		erreur_860026645 = i_supp_quart_num($Trpvi2::DEDE_NUM, 0, 2, 0x0f, g_iartout, g_iartout)
	FINSI
FINSI

erreur_860026645 = i_set_art_field(g_iartout, $Trpvi2::DEDE_INF, Callednb_adrind_860026645)

###############  Demande/Numero traduit/TransNb ##################################

SI ( i_valid_field_n(g_iartout, $Trpvi2::TransNb) )
ALORS
	erreur_860026645 = i_dup_chp_1val(g_iartin, g_iartout, $Trpvi2::TransNb, $Trpvi2::TRANS_NUM)
	erreur_860026645 = i_dup_chp_1val(g_iartin, g_iartout, $Trpvi2::AdrTransNb, $Trpvi2::TRANS_INF)

	SI (Renvoi_Tr_860026645==1 || VPN_Tr_860026645==1 || LA_Tr_860026645==1 )
	ALORS
		#************************* suppression du prefixe Renvoi Messagerie ou VPN_cooperant ou Libre Appel
		erreur_860026645 = i_supp_quart_num($Trpvi2::TRANS_NUM, 0, 5, 0x0f, g_iartout, g_iartout)
	FINSI
	erreur_860026645 = i_get_art_str(g_iartout, $Trpvi2::TRANS_NUM, pt_TransNb_860026645)
	i_get_sub_str(pt_TransNb_860026645, 0, 1, pt_debTransNb_860026645)
	TransNb_AdrInd_860026645= i_get_art_field(g_iartout, $Trpvi2::TRANS_INF) 

	SI (i_strcmp("33", pt_debTransNb_860026645) == 0 && TransNb_AdrInd_860026645==4) 
	ALORS
		#****************** Appel national suppression du prefixe 33 et mise a jour du champ INF***************
		erreur_860026645 = i_supp_quart_num($Trpvi2::TRANS_NUM, 0, 2, 0x0f, g_iartout, g_iartout)
		TransNb_AdrInd_860026645=3
	SINON
		#******************Appel international  VPN cooperant ************************
		SI (i_strcmp("33", pt_debTransNb_860026645) != 0 && TransNb_AdrInd_860026645==3 && VPN_Tr_860026645==1) 
		ALORS	
			TransNb_AdrInd_860026645=4
		FINSI
	FINSI
	erreur_860026645 = i_set_art_field(g_iartout, $Trpvi2::TRANS_INF, TransNb_AdrInd_860026645)
SINON
	#*************************si pas de champ TransNb  on prend les valeur de CalledNb**************
	erreur_860026645 = i_dup_chp_1val(g_iartout, g_iartout, $Trpvi2::DEDE_NUM, $Trpvi2::TRANS_NUM)
	erreur_860026645 = i_dup_chp_1val(g_iartout, g_iartout, $Trpvi2::DEDE_INF, $Trpvi2::TRANS_INF)
FINSI

#********************************** hlahm1 date locale *******************************************

numzone_860026645 = i_DHgetZoneID(NUMTABSEL_860026645, g_iartout)
hlahm1_860026645 = i_DHgetLocalTime(NUMTAB_METRO_860026645,numzone_860026645,i_get_art_field(g_iartin,$DATE))

# pas de normalisation appel BDC si PERFORMANCE_PREFERENCE 083648MCDU et 083649MCDU
erreur_860026645 = i_get_art_str(g_iartout,$Trpvi2::TRANS_NUM, pt_BUF50_860026645)

#trace2("__FILE__:__LINE__ #### DEDE TRANS_NUM <%s>", pt_BUF50, "")
#trace2("__FILE__:__LINE__ #### occup mem7     <%s>", pt_BUF7, "")
#trace2("__FILE__:__LINE__ #### TransNB        <%s>", pt_TransNb, "")
i_get_sub_str(pt_BUF50_860026645, 0,4, pt_BUF7_860026645)
#trace2("verif perf <%s>", pt_BUF7, "")

SI( i_strcmp(pt_BUF7_860026645,"83648")==0 || i_strcmp(pt_BUF7_860026645,"83649")==0)
ALORS
	#trace("__FILE__:__LINE__ #### NUM perf")
bPERFORMANCE_860026645 = 1
FINSI

#trace1("__FILE__:__LINE__ #### bPERFORMANCE : %d", bPERFORMANCE )

#************** Tests si besoin d'appel a la base de comptage ***********************

# Si appel RMTA international(0x07) ou RMTA international renvoye(0x1D) 
# ou VPN cooperant renvoye(0x1B)
# ou VPN cooperant (0x0F)                      (FO 1051)
# ou (0xCB) ou (0x20) ou (0x08) ou (0x09)      (FO 1062)
# dans ce cas CallingNb absent))
# alors pas d'appel ` la base de comptage
# pour trouver les valeurs CCD, CODCIR et CODCIRDR 


# ajout test bPERFORMANCE
SI ( bPERFORMANCE_860026645 )
ALORS
	res_860026645 = i_memset_field(g_iartout,"CCD",0xFF) 
	res_860026645 = i_memset_field(g_iartout,"CODCIRDR",0x20)
	res_860026645 = i_memset_field(g_iartout,"CODCIR",0x20)
	SAUT STOCKE_OK
SINON
	SI ( Calltype_860026645!=0x18 && Calltype_860026645!=0x19 && Calltype_860026645!=0x1A && Calltype_860026645!=0x42 && Calltype_860026645!=0x43 )
	ALORS
		SI ( Calltype_860026645!=0x1B && Calltype_860026645!=0x50 && Calltype_860026645!=0x44 && Calltype_860026645!=0x51 )
		ALORS
			SI ( Calltype_860026645==0x07 || Calltype_860026645==0x1D || Calltype_860026645==0x0F || GestionRenvoi_860026645 || ConsultAnnVocal_860026645)
			ALORS
				res_860026645 = i_memset_field(g_iartout,"CCD",0xFF) 
				res_860026645 = i_memset_field(g_iartout,"CODCIRDR",0x20)
				res_860026645 = i_memset_field(g_iartout,"CODCIR",0x20)
				SAUT STOCKE_OK
			SINON
				#************* 0 + IDUS_NUM *****************
				# - normalisation du demandeur : on normalise avec l'automate RPVI2_NDR
				# - normalisation du demande : on normalise avec l'automate RPVI2_NDE
				longueur_860026645=i_get_art_field(g_iartout,$Trpvi2::L4idus)

				SI longueur_860026645 > 10
				ALORS
					nb_supp_860026645 = ((longueur_860026645 - 1) * 2) - 18
					erreur_860026645 = i_supp_quart_num($Trpvi2::IDUS_NUM, 17, nb_supp_860026645, 0x0f, g_iartout, g_iartout10)
					existe_860026645 = 1
				FINSI
				longueur_860026645=i_get_art_field(g_iartout,$Trpvi2::L4trans)

				SI longueur_860026645 > 10
				ALORS
					nb_supp_860026645 = ((longueur_860026645 - 1) * 2) - 18
					erreur_860026645 = i_supp_quart_num($Trpvi2::TRANS_NUM, 17, nb_supp_860026645, 0x0f, g_iartout, g_iartout10)
					existe_860026645 = 1
				FINSI

				SI ( existe_860026645 == 0 )
				ALORS
					erreur_860026645 = i_dup_art_id(g_iartout, g_iartout10)
				FINSI
				erreur_860026645 = i_normal(g_iartout10, $Trpvi2::IDUS,$Trpvi2::TRANS, g_icopo, $Tcopo::NDR,$Tcopo::NDE ,3, "RPVI2_NDR", "RPVI2_NDE")

				SI erreur_860026645
				ALORS
					code_errone_860026645 = 0x5011
					erreur_860026645 = i_PlvMessEmettre(6062,2,g_iartin,"",1,code_errone_860026645,0,0)
					SAUT STOCKE_ERRONE
				FINSI
			FINSI
		SINON
			#******* Appel VPN renvoye ----> 0 + ORIG_NUM ******************
			# ATTENTION : si on normalise un numero trop long, procopo fait corer
			# Pour pallier ce probleme, on limite les numeros passes en argument a 10 octets (soit, en comptant le INF, 18 digits)
			longueur_860026645=i_get_art_field(g_iartout,$Trpvi2::L4orig)

			SI longueur_860026645 > 10
			ALORS
				nb_supp_860026645 = ((longueur_860026645 - 1) * 2) - 18
				erreur_860026645 = i_supp_quart_num($Trpvi2::ORIG_NUM, 17, nb_supp_860026645, 0x0f, g_iartout, g_iartout10)
				existe_860026645 = 1
			FINSI
			longueur_860026645=i_get_art_field(g_iartout,$Trpvi2::L4trans)

			SI longueur_860026645 > 10
			ALORS
				nb_supp_860026645 = ((longueur_860026645 - 1) * 2) - 18
				erreur_860026645 = i_supp_quart_num($Trpvi2::TRANS_NUM, 17, nb_supp_860026645, 0x0f, g_iartout, g_iartout10)
				existe_860026645 = 1
			FINSI

			SI ( existe_860026645 == 0 )
			ALORS
				erreur_860026645 = i_dup_art_id(g_iartout, g_iartout10)
			FINSI
			erreur_860026645 = i_normal(g_iartout10, $Trpvi2::ORIG,$Trpvi2::TRANS, g_icopo, $Tcopo::NDR,$Tcopo::NDE ,3, "RPVI2_NDR", "RPVI2_NDE")

			SI erreur_860026645
			ALORS
				code_errone_860026645 = 0x5011
				erreur_860026645 = i_PlvMessEmettre(6062,2,g_iartin,"",1,code_errone_860026645,0,0)
				SAUT STOCKE_ERRONE
			FINSI
		FINSI
	SINON
		#******* AVE public ----> 0 + DEDE_NUM ******************
		# ATTENTION : si on normalise un numero trop long, procopo fait corer
		# Pour pallier ce probleme, on limite les numeros passes en argument a 10 octets (soit, en comptant le INF, 18 digits)
		longueur_860026645=i_get_art_field(g_iartout,$Trpvi2::L4dede)

		SI longueur_860026645 > 10
		ALORS
			nb_supp_860026645 = ((longueur_860026645 - 1) * 2) - 18
			erreur_860026645 = i_supp_quart_num($Trpvi2::DEDE_NUM, 17, nb_supp_860026645, 0x0f, g_iartout, g_iartout10)
			existe_860026645 = 1
		FINSI
		longueur_860026645=i_get_art_field(g_iartout,$Trpvi2::L4trans)

		SI longueur_860026645 > 10
		ALORS
			nb_supp_860026645 = ((longueur_860026645 - 1) * 2) - 18
			erreur_860026645 = i_supp_quart_num($Trpvi2::TRANS_NUM, 17, nb_supp_860026645, 0x0f, g_iartout, g_iartout10)
			existe_860026645 = 1
		FINSI

		SI ( existe_860026645 == 0 )
		ALORS
			erreur_860026645 = i_dup_art_id(g_iartout, g_iartout10)
		FINSI
		erreur_860026645 = i_normal(g_iartout10, $Trpvi2::DEDE,$Trpvi2::TRANS, g_icopo, $Tcopo::NDR,$Tcopo::NDE ,3, "RPVI2_NDR", "RPVI2_NDE")

		SI erreur_860026645
		ALORS
			code_errone_860026645 = 0x5011
			erreur_860026645 = i_PlvMessEmettre(6062,2,g_iartin,"",1,code_errone_860026645,0,0)
			SAUT STOCKE_ERRONE
		FINSI
	FINSI
FINSI

##############################################################################
# 	Appel base de comptage
##############################################################################

# Initialisation de l'interface "proc_copo"
g_icopo.TAXE   = 0
g_icopo.CREDIT = 0
erreur_860026645 = i_set_art_date(g_icopo,hlahm1_860026645)
g_icopo.DUREE  = i_get_art_field(g_iartout, $Trpvi2::DUREE)
g_icopo.CODE   = CODE_ARTICLE_860026645
g_icopo.CATEG  = CATEG_860026645
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

erreur_860026645 = i_comptage(g_icopo,BASE_860026645,hlahm1_860026645)

##############################################################################
# 	Erreur retour base de comptage
##############################################################################

SI (erreur_860026645 != 0)
ALORS
	code_errone_860026645 = 0x5021
	erreur_860026645 = i_PlvMessEmettre(6063,2,g_iartout,"",2,code_errone_860026645,g_ierrno,0)
	SAUT STOCKE_ERRONE
FINSI
#DRE G4R8C5 QC870
Appel_BNC_860026645 = 1

##############################################################################
# 	Mise a jour des champs pour l'ajout 
##############################################################################

erreur_860026645 = i_set_art_field(g_iartout, $Trpvi2::CCD, g_icopo.SUP[RES_CLDEST_860026645])
erreur_860026645 = i_set_art_field(g_iartout, $Trpvi2::CODCIRDR, g_icopo.SUP[RES_CODCIRDR_860026645])
erreur_860026645 = i_set_art_field(g_iartout, $Trpvi2::CODCIR, g_icopo.SUP[RES_CODCIR_860026645])
#trace1("__FILE__:__LINE__ #### CCD : %d", $Trpvi2::CCD )

##############################################################################
# 	POINT de branchement : stockage OK 
##############################################################################

POINT STOCKE_OK


#DRE G4R8C5 QC870
SI Appel_BNC_860026645 == 1
ALORS
	#DRE G4R6 lot2
	
	erreur_860026645=i_ajoutChampNum(g_iartout,$Trpvi2::T4rejet,$Trpvi2::REJET,0)
	erreur_860026645 = i_set_art_field(g_iartout, $Trpvi2::REJET, g_icopo.SUP[RES_TYPCTR_860026645])
	
	#SI ( i_valid_field_n(g_iartout, $TRANS ) )
	#ALORS
	
		#Ajout NORMAL (NDE normalise)
		erreur_860026645=i_ajoutChampNum(g_iartout,$Trpvi2::T4normal,$Trpvi2::NORMAL,0)
		indice_860026645 = 0
		POINT BOUCLE_NDE
		res_860026645 = i_get_art_fieldtab(g_icopo, $Tcopo::NDE, indice_860026645)
		#        trace1(" element : %x",res)
		SI (res_860026645 != 00)
		ALORS
			erreur_860026645 = i_set_art_fieldtab(g_iartout, $Trpvi2::NORMAL, indice_860026645, res_860026645-0x30)
			indice_860026645 = indice_860026645 + 1
			SAUT BOUCLE_NDE
		SINON
			erreur_860026645 = i_set_art_fieldtab(g_iartout, $Trpvi2::NORMAL, indice_860026645, 0xFF)
		FINSI
	#FINSI
	#\DRE G4R6 lot2

FINSI


erreur_860026645 = i_set_art_field(g_iartout, $Trpvi2::HLAHM1, hlahm1_860026645)
erreur_860026645 = i_stocke_art(g_iartout, 0, PT_OK, 0)

RETOUR TRAIT_OK

##############################################################################
#	 POINT de branchement : stockage ERRONE 
##############################################################################

POINT STOCKE_ERRONE

#trace("__FILE__:__LINE__ #### Stockage en ERRONE ")
erreur_860026645 = i_make_art_rej(g_iartin,g_iartout7,code_errone_860026645)
erreur_860026645 = i_stocke_art(g_iartout7, 0,PT_ERRONE,0)

RETOUR TRAIT_OK
