DEFINITION TYPE_SMSC_MT_660004724 0x10
DEFINITION TYPE_SMSC_MO_660004724 0x11
DEFINITION MODULE_TRAIT_660004724 0x5000
DEFINITION ERR_SEM_660004724 0x040
DEFINITION ERR_DATE_660004724 0x060
DEFINITION ERR_SYNTAX_660004724 0x070
DEFINITION ERR_CROISE_660004724 0x0F0
DEFINITION ERR_NORM_660004724 0x010
DEFINITION CPT_1501_660004724 1501
DEFINITION CPT_1521_660004724 1521
DEFINITION CPT_1522_660004724 1522
DEFINITION CPT_1523_660004724 1523
DEFINITION CPT_1524_660004724 1524
DEFINITION CPT_1525_660004724 1525
DEFINITION CPT_1526_660004724 1526
DEFINITION CPT_1527_660004724 1527
DEFINITION CPT_1528_660004724 1528
DEFINITION CPT_1529_660004724 1529
DEFINITION CPT_1530_660004724 1530
DEFINITION ERR_CONV_660004724 0x0E0
REGISTRE ENTIER TYPE_SMSC_660004724
REGISTRE ENTIER erreur_660004724
REGISTRE ENTIER date_pivot_660004724
REGISTRE ENTIER valid_chp_660004724
REGISTRE ENTIER length_consol_660004724
REGISTRE ENTIER origAddress_present_660004724
REGISTRE ENTIER origAddressTON_660004724
REGISTRE ENTIER origAddressNPI_660004724
REGISTRE ENTIER origAddressDIGIT1_660004724
REGISTRE ENTIER origAddressDIGIT2_660004724
REGISTRE ENTIER origAddressLong_660004724
REGISTRE ENTIER status_present_660004724
REGISTRE ENTIER status_val_660004724
REGISTRE ENTIER consolidation_present_660004724
REGISTRE ENTIER recipAddress_present_660004724
REGISTRE ENTIER submitDate_present_660004724
REGISTRE ENTIER submitTime_present_660004724
REGISTRE ENTIER termintDate_present_660004724
REGISTRE ENTIER terminTime_present_660004724
REGISTRE POINTEUR pt_smsc_la_mode_660004724
REGISTRE POINTEUR pt_consolAlph_660004724
REGISTRE POINTEUR pt_erreur_660004724
REGISTRE ENTIER code_rejet_660004724
REGISTRE ENTIER EFFICACE_660004724
REGISTRE ENTIER MODULE_660004724
REGISTRE ENTIER ERREUR_660004724
REGISTRE ENTIER bbillID_present_660004724
REGISTRE ENTIER bSMS_MO_National_660004724
REGISTRE ENTIER bSMS_MO_International_660004724
REGISTRE ENTIER bSMS_Err_660004724
REGISTRE ENTIER bSMS_MO_660004724
REGISTRE ENTIER bSMS_MO_4_660004724
REGISTRE ENTIER bSMS_MO_Mobile_660004724
REGISTRE ENTIER bSMS_MO_LA_4_660004724
REGISTRE ENTIER bSMS_MO_Gateway_660004724
REGISTRE ENTIER bSMS_MT_660004724
REGISTRE ENTIER bSMS_MT_0_660004724
REGISTRE ENTIER bSMS_MT_4_660004724
REGISTRE ENTIER bSMS_MT_ServPrive_660004724
REGISTRE ENTIER bSMS_MT_Gateway_660004724
REGISTRE ENTIER bSMS_MT_M2M_660004724
REGISTRE ENTIER bSTATUS_0_660004724
REGISTRE ENTIER bSMS_PrepaidMO_660004724
REGISTRE ENTIER bSMS_PrepaidMO_Mobile_660004724
REGISTRE ENTIER bSMS_PrepaidLA_660004724
REGISTRE ENTIER bSTATUS_4_660004724
REGISTRE ENTIER bsmsc_prepaid_660004724
REGISTRE ENTIER date_fin_660004724
REGISTRE ENTIER bSMS_PrepaidMO_PRISM_660004724
REGISTRE ENTIER bSMS_PrepaidMO_GORI_660004724
REGISTRE ENTIER ogtiAddressTON_660004724
REGISTRE ENTIER ogtiAddressNPI_660004724
REGISTRE ENTIER ogtiAddressDIGIT1_660004724
REGISTRE ENTIER ogtiAddressDIGIT2_660004724
REGISTRE ENTIER ogtiAddressDIGIT3_660004724
REGISTRE ENTIER ogtiAddressDIGIT4_660004724
REGISTRE ENTIER ogtiAddressDIGIT5_660004724
REGISTRE ENTIER ogtiAddressLong_660004724
REGISTRE POINTEUR pt_consolidation_660004724
REGISTRE POINTEUR pt_billID_660004724
REGISTRE POINTEUR pt_table_660004724
REGISTRE POINTEUR pt_recipAddress_660004724

#################################################################################
#              Article TSms_cmg Module de traitement
#              TSms_cmg_tr.src
#              Creation le 09/09/2005 par :RAS
#
#	Historique
# 04/06/07 - DRE - FO 524 supprimer le controle sur SMT_MT et Consolidation +
#			  ajout d'un controle croise Consolidation et longueur origAddress
# 03/07/07 - RHE - FO 549 correction incrementation 1501
# 05/09/07 - RHE - G1R5 Tableau de bord SMS
# 12/09/07 - RHE - G1R5 FO 583
# 17/09/07 - RHE - G1R5 : modifs compteurs (1521) et nouveaux compteurs (1528, 1529 et 1530)
# 18/09/07 - RHE - G1R5 reprise TT0023/FO577 : utilisation de i_get_art_str et de champ sans deplacement
# 21/09/07 - RHE - G1R5 FO591
# 21/09/07 - RHE - G1R5 FO592 : correction pour nouveaux compteurs (1529 et 1530)
# 24/09/07 - RHE - G1R5 FO593 : compteur 1525 non incremente
# 18/01/11 - BEA - G3R1 lot4 Verification/Correction des variables (constantes, entiers, pointeurs)
# 06/06/11 - JLG - G3R3 lot3 QC880 Anomalies de Libelle d'alarme SMS-C
# 15/12/11 - JLG - G3R5 lot1 modif automates SMSC_MO_OGTI_PREPAID au lieu de SMSC_MO_RECIP
# 09/01/12 - PKH - QC989 Correction incrementation du compteur 1529 pour les SMS_PrepaidMO_PRISM ou d'un SMS_PrepaidMO_GORI
# 16/02/12 - JLG - G3R5 QC991 TSms_cmg, pb de sequencement dans le pcode de traitement
# 29/04/15 - RHE - G5R5 QC1560 M2M 15D Test croise consolidation / Origadress
########################################################################################################################

# definition des constantes
#

# G1R5
# /G1R5

# declaration des variables locales


# G1R5
#QC989



# /G1R5

#################################################################
#    Module de traitement
#    Article SMS-C CMG
################################################################
ogtiAddressTON_660004724 = 0
ogtiAddressNPI_660004724 = 0
ogtiAddressDIGIT1_660004724 = 0
ogtiAddressDIGIT2_660004724 = 0
ogtiAddressDIGIT3_660004724 = 0
ogtiAddressDIGIT4_660004724 = 0
ogtiAddressDIGIT5_660004724 = 0
ogtiAddressLong_660004724 = 0

#--initialisation
pt_smsc_la_mode_660004724="01"
pt_consolAlph_660004724="012345"
i_strcpy(pt_consolAlph_660004724,"")
pt_erreur_660004724="123456789012345"
i_strcpy(pt_erreur_660004724,"")
pt_consolidation_660004724 = "pt_consolidation012"
pt_billID_660004724 = "pt_billID789"
i_strcpy(pt_billID_660004724,"")
pt_table_660004724 = "pt_table456"
pt_recipAddress_660004724 = "pt_recipAddress0123456789012345678901234567890123456789"
i_strcpy(pt_recipAddress_660004724,"")

# Initialisations
EFFICACE_660004724 = 1
MODULE_660004724 = MODULE_TRAIT_660004724
ERREUR_660004724 = 0
code_rejet_660004724 = 0

#trace("")
#trace("**** SMS-C CMG Call Detail Record : Debut traitement ****")

####################################################################
# traitement des articles sans champ origAdressGSM
####################################################################

origAddress_present_660004724 = i_valid_field_n(g_iartin, $TSms_cmg::origAddress)
SI (!origAddress_present_660004724)
ALORS
	#trace("SMS CMG : champ origAddress absent impossible de suivre les traitements")
	ERREUR_660004724 = ERR_SYNTAX_660004724
	code_rejet_660004724 = MODULE_660004724 + ERREUR_660004724 + EFFICACE_660004724
	erreur_660004724 = i_PlvMessEmettre(8006, 2, g_iartin, "", 2, code_rejet_660004724, "origAddress",  0)
	SAUT STOCKE_ERRONE
FINSI

erreur_660004724 = i_test_field_ila_off_n(g_iartin, $TSms_cmg::origAddress, "Lrnis", 1)
SI( erreur_660004724 != 0 )
ALORS
	#trace("SMS-C CMG le champ origAddress presente une syntaxe erronee ")
	ERREUR_660004724 = ERR_SYNTAX_660004724
	code_rejet_660004724 = MODULE_660004724 + ERREUR_660004724 + EFFICACE_660004724
	erreur_660004724 = i_PlvMessEmettre(8005, 2, g_iartin, "", 3, code_rejet_660004724, "origAddress", "RNIS")
	SAUT STOCKE_ERRONE
FINSI

####################################################################
#	Determine le type de CRA (ToSms_cmg ou TtSms_cmg)
####################################################################

origAddressTON_660004724 = i_get_art_fieldtab(g_iartin, $TSms_cmg::origAddress, 0)
origAddressNPI_660004724 = i_get_art_fieldtab(g_iartin, $TSms_cmg::origAddress, 1)
origAddressDIGIT1_660004724 = i_get_art_fieldtab(g_iartin, $TSms_cmg::origAddress, 2)
origAddressDIGIT2_660004724 = i_get_art_fieldtab(g_iartin, $TSms_cmg::origAddress, 3)
origAddressLong_660004724 = i_get_art_field(g_iartin, $TSms_cmg::origAddress - 1)

#--- si SMS MO
SI  (
	(( origAddressTON_660004724 == 8 )    && ( origAddressNPI_660004724 == 1) &&
	( origAddressDIGIT1_660004724 == 0 ) && ( origAddressDIGIT2_660004724 >= 1 )
	&& ( origAddressDIGIT2_660004724 <= 7 ) &&  (origAddressLong_660004724 > 4 ))
	||
	(( origAddressTON_660004724 == 8 )    && (origAddressNPI_660004724 == 1) &&
	( origAddressDIGIT1_660004724 == 0 ) && (origAddressDIGIT2_660004724 == 0) &&
	( origAddressLong_660004724 > 2 ))
	||
	(( origAddressTON_660004724 == 9 )    && (origAddressNPI_660004724 == 1) && (origAddressLong_660004724 > 1))
	)
ALORS
	TYPE_SMSC_660004724 = TYPE_SMSC_MO_660004724
	SAUT SMSC_SORTANT
SINON
# Les CRA dont la longueur orig_adress = TON+NPI (=1) necessite une verification
# sur le champ consolidation ( numero du serveur de provenance )
# Si le test est bon il partent en inefficaces
	SI (
		(origAddressLong_660004724 == 1) && (
		(( origAddressTON_660004724 == 8 )    && (origAddressNPI_660004724 == 1)) ||
		(( origAddressTON_660004724 == 9 )    && (origAddressNPI_660004724 == 1))))
	ALORS
		consolidation_present_660004724 = i_valid_field_n(g_iartin, $TSms_cmg::consolidation)

# restriction au cas ou consolidation est present et de longueur non nulle
		SI (consolidation_present_660004724)
		ALORS
			length_consol_660004724 = i_get_art_field(g_iartin, $TSms_cmg::consolidation -1)
			SI (!length_consol_660004724)
			ALORS
				consolidation_present_660004724 = 0
			FINSI
		FINSI

		SI(consolidation_present_660004724)
		ALORS
			# fonction i_test_serveur_LA a reprendre sur Meteor, comparer le champ
			# consolidation avec le contenu de la table SMS_CMG_serveur_LA
			#trace("SMSC gestion du cas OrigAddress=TON+NPI")
			SI (!(i_valid_field_n(g_iartin, $TSms_cmg::orSubmitDate))
				|| !(i_valid_field_n(g_iartin, $TSms_cmg::orSubmitTime)))
			ALORS
				#trace("SMS CMG : origine submit date absent ")
				ERREUR_660004724 = ERR_SYNTAX_660004724
				code_rejet_660004724 = MODULE_660004724 + ERREUR_660004724 + EFFICACE_660004724
				erreur_660004724 = i_PlvMessEmettre(8006, 2, g_iartin, "", 2, code_rejet_660004724, "origine submitDate", 0)
				SAUT STOCKE_ERRONE
			FINSI
			date_pivot_660004724 = i_get_art_field(g_iartin, $TSms_cmg::orSubmitDate)
			#-- test syntaxique de orSubmiteDate
			SI( date_pivot_660004724 == -1)
			ALORS
				#trace("SMS CMG orSubmitDate n a pas un bon format")
				ERREUR_660004724 = ERR_DATE_660004724
				code_rejet_660004724 = MODULE_660004724 + ERREUR_660004724 + EFFICACE_660004724
				erreur_660004724 = i_PlvMessEmettre(8005, 2,g_iartin, "", 3, code_rejet_660004724, "orSubmitDate", "AAMMJJhhmmss DCB")
				SAUT STOCKE_ERRONE
			FINSI
			date_pivot_660004724 = date_pivot_660004724+i_get_art_field(g_iartin, $TSms_cmg::orSubmitTime)

			# debut TT0023/FO 577
			erreur_660004724 = i_get_art_str(g_iartin, $TSms_cmg::consolidationA, pt_consolAlph_660004724)
			# fin TT0023/FO 577

			i_get_sub_str(pt_consolAlph_660004724, 0, 4, pt_consolAlph_660004724)
			pt_erreur_660004724 = i_get_tab_field("SMS_CMG_serveurLA", date_pivot_660004724, pt_consolAlph_660004724)

			SI (i_strcmp(pt_erreur_660004724, g_inull))
			ALORS
				#--- Article inefficace -> stockage en elimine
				#trace("SMSC Consolidation trouve dans la tables des serveurs LA")
				erreur_660004724 = i_stocke_art(g_iartin,0,PT_DIVERS,0)
				#trace("SMS-C CMG : Article inefficace => Fin de traitement")
				RETOUR TRAIT_OK
			SINON
				#trace("SMSC Consolidation non trouve dans la tables des serveurs LA")
				#trace("SMS-C CMG : Mauvais champ origAddress")
				ERREUR_660004724 = ERR_SEM_660004724
				code_rejet_660004724 = MODULE_660004724 + ERREUR_660004724 + EFFICACE_660004724
				erreur_660004724 = i_PlvMessEmettre(8001, 2, g_iartin, "", 2, code_rejet_660004724,pt_consolAlph_660004724, 0)
				SAUT STOCKE_ERRONE
			FINSI
		FINSI
	FINSI

# -- rejet des cas 810[8-9]*

	SI ((origAddressTON_660004724 == 8)    && (origAddressNPI_660004724 == 1) && 		    (origAddressDIGIT1_660004724 == 0))
	ALORS
		#trace("SMS-C CMG: Erreur champ origAddress -> le cas 810[8-9]* est impossible")
		ERREUR_660004724 = ERR_SEM_660004724
		code_rejet_660004724 = MODULE_660004724 + ERREUR_660004724 + EFFICACE_660004724
		erreur_660004724 = i_PlvMessEmettre(8004, 2 ,g_iartin, "", 2, code_rejet_660004724, "origAddress", 0)
		SAUT STOCKE_ERRONE
	FINSI

#--- sinon => SMS-MT
	TYPE_SMSC_660004724=TYPE_SMSC_MT_660004724
	SAUT SMSC_ENTRANT
FINSI

####################################################################
#	l article est un article sortant
####################################################################

POINT	SMSC_SORTANT

#trace("SMSC type sortant MO ")
# Differenciation du traitement des SMS MO et des SMS MO vers LA

consolidation_present_660004724 = i_valid_field_n(g_iartin,$TSms_cmg::consolidation)
# restriction au cas ou consolidation est present et de longueur non nulle
SI (consolidation_present_660004724)
ALORS
	length_consol_660004724 = i_get_art_field(g_iartin, $TSms_cmg::consolidation -1)
	SI (!length_consol_660004724)
	ALORS
		consolidation_present_660004724 = 0
	FINSI
FINSI

SI(!consolidation_present_660004724)
ALORS
	trace("SMSC MO vers Mobile ")
SINON
	trace("SMSC MO vers serveur prive")
FINSI

SI (consolidation_present_660004724)
ALORS
	erreur_660004724 = i_test_field_ila_n(g_iartin, $TSms_cmg::consolidation, "Lrnis")
	SI erreur_660004724
	ALORS
		#trace("SMS-C CMG MO : le champ consolidation presente une syntaxe erronee ")
		ERREUR_660004724 = ERR_SYNTAX_660004724
		code_rejet_660004724 = MODULE_660004724 + ERREUR_660004724 + EFFICACE_660004724
		erreur_660004724 = i_PlvMessEmettre(8005, 2, g_iartin, "", 3, code_rejet_660004724, "consolidation", "RNIS")
		SAUT STOCKE_ERRONE
	FINSI
FINSI

#-- test syntaxique du champ intlMobSubId

valid_chp_660004724 = i_valid_field_n(g_iartin, $TSms_cmg::intlMobSubId)

SI (valid_chp_660004724)
ALORS
	erreur_660004724 = i_test_field_ila_n(g_iartin, $TSms_cmg::intlMobSubId, "Lgsm")
	SI (erreur_660004724 != 0 )
	ALORS
		#trace("SMS MO : le champ IMSI presente un syntaxe erronee")
		ERREUR_660004724 = ERR_SYNTAX_660004724
		code_rejet_660004724 = MODULE_660004724 + ERREUR_660004724 + EFFICACE_660004724
		erreur_660004724 = i_PlvMessEmettre(8005, 2, g_iartin, "", 3, code_rejet_660004724, "intlMobSubId", "GSM")
		SAUT STOCKE_ERRONE
	FINSI
FINSI

#--- controle de presence du champ status
status_present_660004724 = i_valid_field_n(g_iartin, $TSms_cmg::status)
SI (!status_present_660004724)
ALORS
	#trace("SMS-C CMG MO : champ status absent ")
	ERREUR_660004724 = ERR_SYNTAX_660004724
	code_rejet_660004724 = MODULE_660004724 + ERREUR_660004724 + EFFICACE_660004724
	erreur_660004724 = i_PlvMessEmettre(8006, 2, g_iartin , "", 2, code_rejet_660004724, "status", 0)
	SAUT STOCKE_ERRONE
FINSI

#--- controle d efficacite de l article suivant le champ status

status_val_660004724 = i_get_art_field(g_iartin,$TSms_cmg::status)
SI (consolidation_present_660004724)
ALORS
#
#--- Traitement specifique aux SMS MO vers Large Account
	date_pivot_660004724 = i_get_art_field(g_iartin, $TSms_cmg::orSubmitDate) + i_get_art_field(g_iartin, $TSms_cmg::orSubmitTime)
	i_strcpy(pt_smsc_la_mode_660004724, i_get_tab_field("VariableContexte", date_pivot_660004724, "SMS_LA_MODE"))
	#trace2("SMS MO: variable SMS_LA_MODE est : %s %s ", pt_smsc_la_mode , "")

	SI ((i_strcmp(pt_smsc_la_mode_660004724, "2")) && (i_strcmp(pt_smsc_la_mode_660004724, "3")))
	ALORS
		# --- Mode 1 : SMS MO vers LA de status 4
		SI (status_val_660004724 != 4)
		ALORS
			#trace("SMS-C CMG MO vers LA : Article inefficace SMS_LA_MODE=1 et Status!=4) => Fin de traitement")
			erreur_660004724 = i_stocke_art(g_iartin, 0, PT_DIVERS, 0)
			RETOUR TRAIT_OK
		FINSI
	FINSI

	SI (!i_strcmp(pt_smsc_la_mode_660004724, "2"))
	ALORS
		# --- Mode 2 : SMS MO vers LA status 0 et status 4
		SI ( (status_val_660004724 != 4) && (status_val_660004724 != 0) )
		ALORS
			#trace("SMS-C CMG vers LA : Article inefficace (SMS_LA_MODE=2 et Status!=4 et !=0)=> Fin de traitement")
			erreur_660004724 = i_stocke_art(g_iartin, 0, PT_DIVERS, 0)
			RETOUR TRAIT_OK
		FINSI
	FINSI

	SI (!i_strcmp(pt_smsc_la_mode_660004724,"3"))
	ALORS
		# --- Mode 3 : SMS MO vers LA status 0
		SI (status_val_660004724 != 0)
		ALORS
			#trace("SMS-C CMG MO vers LA: Article inefficace(SMS_LA_MODE=3 et status!=0)=> Fin de traitement")
			erreur_660004724 = i_stocke_art(g_iartin, 0, PT_DIVERS, 0)
			RETOUR TRAIT_OK
		FINSI
	FINSI
SINON
#
# --- Traitement specifique aux SMS MO
#
	SI (status_val_660004724 != 4)
	ALORS
		#trace("SMS-C CMG MO : Article inefficace status!=4=> Fin de traitement")
		erreur_660004724 = i_stocke_art(g_iartin, 0, PT_DIVERS, 0)
		RETOUR TRAIT_OK
	FINSI
FINSI

#--- test de presence du champ lengthOfMess
erreur_660004724= i_valid_field_n(g_iartin, $TSms_cmg::lengthOfMess)
SI (erreur_660004724 == 0)
ALORS
	#trace(" SMS-C CMG MO :Erreur, champ lengthOfMess absent ")
	ERREUR_660004724 = ERR_SYNTAX_660004724
	code_rejet_660004724 = MODULE_660004724 + ERREUR_660004724 + EFFICACE_660004724
	erreur_660004724 = i_PlvMessEmettre(8006, 2, g_iartin, "", 2, code_rejet_660004724, "lengthOfMess", 0)
	SAUT STOCKE_ERRONE
FINSI

####################################################################
#	fin des controles syntaxiques specifiques MO
####################################################################

#--- test de presence du champ recipAddress
recipAddress_present_660004724 = i_valid_field_n(g_iartin, $TSms_cmg::recipAddress)
SI (!recipAddress_present_660004724)
ALORS
	#trace("SMS-C CMG MO: Le champ recipAddress est absent ")
	ERREUR_660004724 = ERR_SYNTAX_660004724
	code_rejet_660004724 = MODULE_660004724 + ERREUR_660004724 + EFFICACE_660004724
	erreur_660004724 = i_PlvMessEmettre(8006, 2, g_iartin, "", 2, code_rejet_660004724, "recipAddress", 0)
	SAUT STOCKE_ERRONE
FINSI

#--- test syntaxique du champ recipAddress
erreur_660004724 = i_test_field_ila_off_n(g_iartin, $TSms_cmg::recipAddress, "Lrnis", 1)
SI (erreur_660004724 != 0)
ALORS
	#trace("SMS-C CMG: Le champ recipAddress presente une syntaxe erronee ")
	ERREUR_660004724 = ERR_SYNTAX_660004724
	code_rejet_660004724 = MODULE_660004724 + ERREUR_660004724 + EFFICACE_660004724
	erreur_660004724 = i_PlvMessEmettre(8005, 2, g_iartin, "", 3, code_rejet_660004724, "recipAddress", "RNIS")
	SAUT STOCKE_ERRONE
FINSI


#-- test auto (submitDate,submitTime,terminDate,terminTime,orSubmitDate,orSubmitTime,intlMobSubId)
erreur_660004724 = i_test_art(g_iartin)
SI (erreur_660004724 == -1)
ALORS
	#trace(" Test automatique de l article -> article errone ")
	ERREUR_660004724 = ERR_SYNTAX_660004724
	code_rejet_660004724 = MODULE_660004724 + ERREUR_660004724 + EFFICACE_660004724
	erreur_660004724 = i_PlvMessEmettre(8007, 2, g_iartin, "", 1, code_rejet_660004724, 0, 0)
	SAUT STOCKE_ERRONE
FINSI

#-- test de presence du champ orSubmitDate

valid_chp_660004724 = i_valid_field_n(g_iartin, $TSms_cmg::orSubmitDate)
SI (!valid_chp_660004724)
ALORS
	#trace("SMS-C CMG :champ orSubmitDate absent ")
	ERREUR_660004724 = ERR_SYNTAX_660004724
	code_rejet_660004724 = MODULE_660004724 + ERREUR_660004724 + EFFICACE_660004724
	erreur_660004724 = i_PlvMessEmettre(8006, 2, g_iartin, "", 2, code_rejet_660004724, "orSubmitDate", 0)
	SAUT STOCKE_ERRONE
FINSI

#--- test de validite du champ orSubmitDate format AAMMJJHHMMSS en DCB
erreur_660004724 = i_get_art_field(g_iartin, $TSms_cmg::orSubmitDate)
SI(erreur_660004724 == -1)
ALORS
	#trace(" le champ orSubmitDate presente une syntaxe erronee")
	ERREUR_660004724 = ERR_SYNTAX_660004724
	code_rejet_660004724 = MODULE_660004724 + ERREUR_660004724 + EFFICACE_660004724
	erreur_660004724 = i_PlvMessEmettre(8005, 2, g_iartin, "", 3, code_rejet_660004724, "orSubmitDate", "AAMMJJHHMMSS en DCB")
	SAUT STOCKE_ERRONE
FINSI

#-- test de presence du champ orSubmitTime
valid_chp_660004724 = i_valid_field_n(g_iartin, $TSms_cmg::orSubmitTime)
SI (!valid_chp_660004724)
ALORS
	#trace("SMS-C CMG: champ orSubmitTime absent ")
	ERREUR_660004724 = ERR_SYNTAX_660004724
	code_rejet_660004724 = MODULE_660004724 + ERREUR_660004724 + EFFICACE_660004724
	erreur_660004724 = i_PlvMessEmettre(8005, 2, g_iartin, "", 3, code_rejet_660004724, "orSubmitDate", "AAMMJJHHMMSS en DCB")
	SAUT STOCKE_ERRONE
FINSI

#-- test syntaxique champ billID s il est present
valid_chp_660004724 = i_valid_field_n(g_iartin, $TSms_cmg::billID)
SI(valid_chp_660004724)
ALORS
	erreur_660004724 = i_test_field_ila_n (g_iartin, $TSms_cmg::billID, "Lrnis")
	SI(erreur_660004724 != 0)
	ALORS
		#trace("le champ billID presente une syntaxe errone")
		ERREUR_660004724 = ERR_SYNTAX_660004724
		code_rejet_660004724 = MODULE_660004724 + ERREUR_660004724 + EFFICACE_660004724
		erreur_660004724 = i_PlvMessEmettre(8005, 2, g_iartin, "", 3, code_rejet_660004724, "billID", "RNIS")
		SAUT STOCKE_ERRONE
	FINSI
FINSI

#-- Fin traitemnt article valide
SAUT STOCKE_OK

####################################################################
#	l'article est un article entrant
####################################################################

POINT	SMSC_ENTRANT

#trace("SMSC : type entrant MT ")
#--- test de presence du champ status
status_present_660004724 = i_valid_field_n(g_iartin, $TSms_cmg::status)
SI (!status_present_660004724)
ALORS
	#trace("SMS-C CMG MT : champ status absent ")
	ERREUR_660004724 = ERR_SYNTAX_660004724
	code_rejet_660004724 = MODULE_660004724 + ERREUR_660004724 + EFFICACE_660004724
	erreur_660004724 = i_PlvMessEmettre(8006, 2, g_iartin, "", 2, code_rejet_660004724, "status", 0)
	SAUT STOCKE_ERRONE
FINSI

#---- controle d efficacite de l article

status_val_660004724 = i_get_art_field(g_iartin, $TSms_cmg::status)
SI ((status_val_660004724 != 0) && (status_val_660004724 != 4))
ALORS
	#trace("SMS-C CMG MT: Article inefficace status !=4 et !=0 => Fin de traitement")
	erreur_660004724 = i_stocke_art(g_iartin, 0, PT_DIVERS, 0)
	RETOUR TRAIT_OK
FINSI

####################################################################
#	fin des controles Syntaxiques specifiques MT
####################################################################

#----Test de presence du champ recipAddress
recipAddress_present_660004724 = i_valid_field_n(g_iartin,$TSms_cmg::recipAddress)
SI (!recipAddress_present_660004724)
ALORS
	#trace("SMS-C CMG MT: Le champ recipAddress est absent ")
	ERREUR_660004724 = ERR_SYNTAX_660004724
	code_rejet_660004724 = MODULE_660004724 + ERREUR_660004724 + EFFICACE_660004724
	erreur_660004724 = i_PlvMessEmettre(8006, 2, g_iartin, "", 2, code_rejet_660004724, "recipAddress", 0)
	SAUT STOCKE_ERRONE
FINSI

#--- Test syntaxique du champ recipAddress

erreur_660004724 = i_test_field_ila_off_n(g_iartin, $TSms_cmg::recipAddress, "Lrnis", 1)
SI (erreur_660004724 != 0)
ALORS
	#trace("SMS-C CMG MT:Le champ recipAddress presente une syntaxe erronee ")
	ERREUR_660004724 = ERR_SYNTAX_660004724
	code_rejet_660004724 = MODULE_660004724 + ERREUR_660004724 + EFFICACE_660004724
	erreur_660004724 = i_PlvMessEmettre(8005, 2, g_iartin, "", 3, code_rejet_660004724, "recipAddress", "RNIS")
	SAUT STOCKE_ERRONE
FINSI

#--- test syntaxique du champ consolidation
consolidation_present_660004724 = i_valid_field_n(g_iartin, $TSms_cmg::consolidation)
# restriction au cas ou consolidation est present et de longueur non nulle
SI (consolidation_present_660004724)
ALORS
	length_consol_660004724 = i_get_art_field(g_iartin, $TSms_cmg::consolidation -1)
	SI (!length_consol_660004724)
	ALORS
		consolidation_present_660004724=0
	FINSI
FINSI

#-- test de presence du champ consolidation et test de la syntaxique du champ
SI (consolidation_present_660004724)
ALORS
	erreur_660004724 = i_test_field_ila_n(g_iartin, $TSms_cmg::consolidation, "Lrnis")
	SI (erreur_660004724 != 0)
	ALORS
		#trace("SMS-C CMG MT:le champ consolidation  presente une syntaxe erronee ")
		ERREUR_660004724 = ERR_SYNTAX_660004724
		code_rejet_660004724 = MODULE_660004724 + ERREUR_660004724 + EFFICACE_660004724
		erreur_660004724 = i_PlvMessEmettre(8005, 2, g_iartin, "", 3, code_rejet_660004724, "consolidation", "RNIS")
		SAUT STOCKE_ERRONE
	FINSI
# debut FO 524
#	SINON
#		#trace("SMS-C CMG MT : champ consolidation absent")
## FE 54 ##
#	ERREUR = ERR_SYNTAX
#	code_rejet = MODULE + ERREUR + EFFICACE
## /FE 54 ##
#  erreur=i_PlvMessEmettre(8006, 2, g_iartin, "", 2, code_rejet,"consolidation", 0)
#                SAUT STOCKE_ERRONE
# Fin FO 524
FINSI

#-- test syntaxique du champ intlMobSubId

valid_chp_660004724 = i_valid_field_n(g_iartin, $TSms_cmg::intlMobSubId)

SI (valid_chp_660004724)
ALORS
	erreur_660004724 = i_test_field_ila_n(g_iartin, $TSms_cmg::intlMobSubId, "Lgsm")
	SI (erreur_660004724 != 0)
	ALORS
		#trace("SMS MT : le champ IMSI presente un syntaxe erronee")
		ERREUR_660004724 = ERR_SYNTAX_660004724
		code_rejet_660004724 = MODULE_660004724 + ERREUR_660004724 + EFFICACE_660004724
		erreur_660004724 = i_PlvMessEmettre(8005, 2, g_iartin, "", 3, code_rejet_660004724, "intlMobSubId", "GSM")
		SAUT STOCKE_ERRONE
	FINSI
FINSI

#-- test auto (submitDate,submitTime,terminDate,terminTime,orSubmitDate,orSubmitTime,intlMobSubId)
erreur_660004724 = i_test_art(g_iartin)
SI (erreur_660004724 != 0)
ALORS
	#trace("SMS-C CMG MT: Test automatique -> article erronee ")
	ERREUR_660004724 = ERR_SYNTAX_660004724
	code_rejet_660004724 = MODULE_660004724 + ERREUR_660004724 + EFFICACE_660004724
	erreur_660004724 = i_PlvMessEmettre(8007, 2, g_iartin, "", 1, code_rejet_660004724, 0, 0)
	SAUT STOCKE_ERRONE
FINSI

#--- test de presence du champ IMSI (controle croise entre les deux champs intlMobSubId et status)
valid_chp_660004724 = i_valid_field_n(g_iartin, $TSms_cmg::intlMobSubId)
SI ((!valid_chp_660004724) && (status_val_660004724 != 4))
ALORS
	#trace("SMS-C CMG MT: champ intlMobSubId absent pour le status 0")
	ERREUR_660004724 = ERR_CROISE_660004724
	code_rejet_660004724 = MODULE_660004724 + ERREUR_660004724 + EFFICACE_660004724
	erreur_660004724 = i_PlvMessEmettre(8008, 2, g_iartin, "",3, code_rejet_660004724, "intlMobSubId", "status")
	SAUT STOCKE_ERRONE
FINSI

# FO 524
#--- test de presence du champ Consolidation ou Origadress > 10 (controle croise entre les deux champs Consolidation et Origadress)
#G5R5 QC1560
#SI ((i_valid_field_n(g_iartin, $TSms_cmg::consolidation) == 0) && ((origAddressLong != 7) || (g_iartin.origAddress[13] != 0xF)))
SI (i_valid_field_n(g_iartin, $TSms_cmg::consolidation) == 0)
	ALORS
	SI ((g_iartin.origAddress[4] == 7) && (g_iartin.origAddress[5] == 0) && (g_iartin.origAddress[6] == 0)
		&& ((origAddressLong_660004724 != 9) || (g_iartin.origAddress[17] != 0xF)))
		|| ( (g_iartin.origAddress[4] != 7) && ((origAddressLong_660004724 != 7) || (g_iartin.origAddress[13] != 0xF)))
		ALORS
		#trace("SMS-C CMG MT: controle croise champ Consolidation et champ Origadress ")
		ERREUR_660004724 = ERR_CROISE_660004724
		code_rejet_660004724 = MODULE_660004724 + ERREUR_660004724 + EFFICACE_660004724
		erreur_660004724 = i_PlvMessEmettre(8006, 2, g_iartin, "", 2, code_rejet_660004724, "champ Consolidation absent et longueur origAddress incorrecte", 0)
		# message: "ERR=0x50F1 article erronee, champ Consolidation absent et longueur origAddress incorrecte"
		SAUT STOCKE_ERRONE
	FINSI
FINSI
#FIN FO 524

#--- test de presence du champ teminDate (controle croise entre les deux champs teminDate et status)
valid_chp_660004724 = i_valid_field_n(g_iartin, $TSms_cmg::terminDate)
SI ((!valid_chp_660004724) && (status_val_660004724 != 4))
ALORS
	#trace("SMS-C CMG MT : champ terminDate absent pour le status 0")
	ERREUR_660004724 = ERR_CROISE_660004724
	code_rejet_660004724 = MODULE_660004724 + ERREUR_660004724 + EFFICACE_660004724
	erreur_660004724 = i_PlvMessEmettre(8008, 2, g_iartin, "", 3, code_rejet_660004724, "terminDate", "status")
	SAUT STOCKE_ERRONE
FINSI

#--- test de validite du champ terminDate format AAMMJJHHMMSS en DCB
erreur_660004724 = i_get_art_field(g_iartin, $TSms_cmg::terminDate)
SI((erreur_660004724 == -1)&&(status_val_660004724 != 4))
ALORS
	#trace(" le champ terminDate presente une syntaxe erronee")
	ERREUR_660004724 = ERR_SEM_660004724
	code_rejet_660004724 = MODULE_660004724 + ERREUR_660004724 + EFFICACE_660004724
	erreur_660004724 = i_PlvMessEmettre(8005, 2, g_iartin, "", 3, code_rejet_660004724,"terminDate", "AAMMJJHHMMSS en DCB")
	SAUT STOCKE_ERRONE
FINSI

#--- test de presence du champ terminTime (controle croise entre les deux champs teminTime et status)
valid_chp_660004724 = i_valid_field_n(g_iartin, $TSms_cmg::terminTime)
SI ((!valid_chp_660004724) && (status_val_660004724 != 4))
ALORS
	#trace("SMS-C CMG MT : champ terminTime absent pour le status 0")
	ERREUR_660004724 = ERR_CROISE_660004724
	code_rejet_660004724 = MODULE_660004724 + ERREUR_660004724 + EFFICACE_660004724
	erreur_660004724 = i_PlvMessEmettre(8008, 2, g_iartin, "", 3, code_rejet_660004724, "terminTime", "status")
	SAUT STOCKE_ERRONE
FINSI

#-- test de presence des champs submitDate et submitTime
#-- Si status=4 et termineDate ou termineTime absent
submitDate_present_660004724 = i_valid_field_n(g_iartin, $TSms_cmg::submitDate)
submitTime_present_660004724 = i_valid_field_n(g_iartin, $TSms_cmg::submitTime)
termintDate_present_660004724 = i_valid_field_n(g_iartin, $TSms_cmg::terminDate)
terminTime_present_660004724 = i_valid_field_n(g_iartin, $TSms_cmg::terminTime)


SI((status_val_660004724 == 4)&&
	((!termintDate_present_660004724)||(!terminTime_present_660004724)) &&
	((!submitDate_present_660004724)||(!submitTime_present_660004724)) )
ALORS
	#trace(" status=4, terminDate ou terminTime absent ")
	#trace("Erreur champ submitDate ou submitTime absent")
	ERREUR_660004724 = ERR_CROISE_660004724
	code_rejet_660004724 = MODULE_660004724 + ERREUR_660004724 + EFFICACE_660004724
	erreur_660004724 = i_PlvMessEmettre(8006 , 2, g_iartin, "", 2, code_rejet_660004724, "terminTime", 0)
	SAUT STOCKE_ERRONE
FINSI

#-- test de validite du champ submitDate format AAMMJJhhmmss en DCB
SI(submitDate_present_660004724)
ALORS
	erreur_660004724 = i_get_art_field(g_iartin, $TSms_cmg::submitDate)
	SI (erreur_660004724 == -1)
	ALORS
		#trace(" le champ submitDate presente une syntaxe erronee")
		ERREUR_660004724 = ERR_SEM_660004724
		code_rejet_660004724 = MODULE_660004724 + ERREUR_660004724 + EFFICACE_660004724
		erreur_660004724 = i_PlvMessEmettre(8005, 2, g_iartin, "", 3, code_rejet_660004724, "submitDate", "AAMMJJhhmmss en DCB")
		SAUT STOCKE_ERRONE
	FINSI
FINSI

#--- test de presence du champ lengthOfMess
erreur_660004724 = i_valid_field_n(g_iartin, $TSms_cmg::lengthOfMess)
SI (erreur_660004724 == 0)
ALORS
	#trace(" SMS-C CMG MO :Erreur, champ lengthOfMess absent ")
	ERREUR_660004724 = ERR_SYNTAX_660004724
	code_rejet_660004724 = MODULE_660004724 + ERREUR_660004724 + EFFICACE_660004724
	erreur_660004724 = i_PlvMessEmettre(8006,  2, g_iartin, "", 2, code_rejet_660004724, "lengthOfMess", 0)
	SAUT STOCKE_ERRONE
FINSI

#-- test syntaxique champ billID s il est present
valid_chp_660004724 = i_valid_field_n(g_iartin, $TSms_cmg::billID)
SI(valid_chp_660004724)
ALORS
	erreur_660004724 = i_test_field_ila_n (g_iartin, $TSms_cmg::billID, "Lrnis")
	SI( erreur_660004724 != 0 )
	ALORS
		#trace("le champ billID presente une syntaxe errone")
		ERREUR_660004724 = ERR_SYNTAX_660004724
		code_rejet_660004724 = MODULE_660004724 + ERREUR_660004724 + EFFICACE_660004724
		erreur_660004724 = i_PlvMessEmettre(8005, 2, g_iartin, "", 3, code_rejet_660004724, "billID", "RNIS")
		SAUT STOCKE_ERRONE
	FINSI
FINSI

#
# ---- Fin de traitement : OK
#

POINT STOCKE_OK

#QC991 deplacement du stockage vers distribution
# G1R5

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

# Variables utilisees:
# date_pivot
# consolidation_present
# QC880
SI (consolidation_present_660004724 == 1)
ALORS
	erreur_660004724 =i_get_art_str(g_iartin, $TSms_cmg::consolidationA, pt_consolidation_660004724)
FINSI
#/QC880

bbillID_present_660004724 = i_valid_field_n(g_iartin, $TSms_cmg::billID)
SI (bbillID_present_660004724 == 1)
ALORS
	erreur_660004724 =i_get_art_str(g_iartin, $TSms_cmg::billIDA, pt_billID_660004724)
FINSI
# G1R5 : modifs compteurs et nouveaux compteurs

# Variable globale STATUS
status_val_660004724 = i_get_art_field(g_iartin, $TSms_cmg::status)

# Variable globale STATUS_0
SI (status_val_660004724 == 0)
ALORS
	bSTATUS_0_660004724 = 1
SINON
	bSTATUS_0_660004724 = 0
FINSI

# Variable globale STATUS_4
SI (status_val_660004724 == 4)
ALORS
	bSTATUS_4_660004724 = 1
SINON
	bSTATUS_4_660004724 = 0
FINSI

# Variable globale SMS_MO_National
SI ((origAddressTON_660004724 == 8) && (origAddressNPI_660004724 == 1) &&
	(origAddressDIGIT1_660004724 == 0) && (origAddressDIGIT2_660004724 >= 1) &&
	(origAddressDIGIT2_660004724 <= 7) &&  (origAddressLong_660004724 > 4))
ALORS
	bSMS_MO_National_660004724 = 1
SINON
	bSMS_MO_National_660004724 = 0
FINSI

# Variable globale SMS_MO_International
SI ((origAddressTON_660004724 == 8) && (origAddressNPI_660004724 == 1) &&
	(origAddressDIGIT1_660004724 == 0) && (origAddressDIGIT2_660004724 == 0) &&
	(origAddressLong_660004724 > 2))
	||
	((origAddressTON_660004724 == 9) && (origAddressNPI_660004724 == 1) && (origAddressLong_660004724 > 1))
ALORS
	bSMS_MO_International_660004724 = 1
SINON
	bSMS_MO_International_660004724 = 0
FINSI

# Variable globale SMS_Err
SI ((origAddressTON_660004724 == 8) && (origAddressNPI_660004724 == 1) &&
	(origAddressDIGIT1_660004724 == 0) && (origAddressDIGIT2_660004724 >= 8) &&
	(origAddressDIGIT2_660004724 <= 9) &&  (origAddressLong_660004724 > 4))
ALORS
	bSMS_Err_660004724 = 1
SINON
	bSMS_Err_660004724 = 0
FINSI

# Variable globale SMS_MO
SI ((bSMS_MO_National_660004724 == 1) || (bSMS_MO_International_660004724 == 1))
ALORS
	bSMS_MO_660004724 = 1
SINON
	bSMS_MO_660004724 = 0
FINSI

# Variable globale SMS_MO_Mobile
SI ((bSMS_MO_660004724 == 1) && (consolidation_present_660004724 == 0))
ALORS
	bSMS_MO_Mobile_660004724 = 1
SINON
	bSMS_MO_Mobile_660004724 = 0
FINSI

# Variable globale SMS_MO_LA
#SI ((bSMS_MO == 1) && (consolidation_present == 1))
#  ALORS
#  bSMS_MO_LA = 1
#SINON
#  bSMS_MO_LA = 0
#FINSI

# Variable globale SMS_MO_LA_4
SI ((bSMS_MO_660004724 == 1) && (consolidation_present_660004724 == 1) && (bSTATUS_4_660004724 == 1))
ALORS
	bSMS_MO_LA_4_660004724 = 1
SINON
	bSMS_MO_LA_4_660004724 = 0
FINSI

# Variable globale SMS_MO_Gateway
i_get_sub_str(pt_consolidation_660004724, 0, 4, pt_consolidation_660004724)
i_strcpy(pt_table_660004724, i_get_tab_field("SMS_CMG_Gateway", date_pivot_660004724, pt_consolidation_660004724))
SI ((bSMS_MO_660004724 == 1) && (consolidation_present_660004724 == 1) && (i_strcmp(pt_table_660004724, g_inull) != 0))
ALORS
	bSMS_MO_Gateway_660004724 = 1
SINON
	bSMS_MO_Gateway_660004724 = 0
FINSI

# Variable globale SMS_MT
# FO 583
#SI ((bSMS_MO == 0) || (bSMS_Err == 0))
SI ((bSMS_MO_660004724 == 0) && (bSMS_Err_660004724 == 0))
ALORS
	bSMS_MT_660004724 = 1
SINON
	bSMS_MT_660004724 = 0
FINSI

# Variable globale SMS_MT_0
#SI ((bSMS_MT == 1) || (bSTATUS_0 == 1))
SI ((bSMS_MT_660004724 == 1) && (bSTATUS_0_660004724 == 1))
ALORS
	bSMS_MT_0_660004724 = 1
SINON
	bSMS_MT_0_660004724 = 0
FINSI

# Variable globale SMS_MO_4
SI ((bSMS_MO_Mobile_660004724 == 1) && (bSTATUS_4_660004724 == 1))
ALORS
	bSMS_MO_4_660004724 = 1
SINON
	bSMS_MO_4_660004724 = 0
FINSI

# Variable globale SMS_MT_4
SI ((bSMS_MT_660004724 == 1) && (bSTATUS_4_660004724 == 1))
ALORS
	bSMS_MT_4_660004724 = 1
SINON
	bSMS_MT_4_660004724 = 0
FINSI

# Variable globale SMS_MT_ServPrive
SI ((bSMS_MT_660004724 == 1) && (consolidation_present_660004724 == 1))
ALORS
	bSMS_MT_ServPrive_660004724 = 1
SINON
	bSMS_MT_ServPrive_660004724 = 0
FINSI

# Variable globale SMS_MT_Gateway
SI ((bSMS_MT_660004724 == 1) && (consolidation_present_660004724 == 1) && (i_strcmp(pt_table_660004724, g_inull) != 0))
ALORS
	bSMS_MT_Gateway_660004724 = 1
SINON
	bSMS_MT_Gateway_660004724 = 0
FINSI

# Variable globale SMS_MT_M2M
i_strcpy(pt_table_660004724, i_get_tab_field("SMS_CMG_SMS_HUB", date_pivot_660004724, pt_billID_660004724))
SI ((bSMS_MT_660004724 == 1) && (bbillID_present_660004724 == 1) && (i_strcmp(pt_table_660004724, g_inull) != 0))
ALORS
	bSMS_MT_M2M_660004724 = 1
SINON
	bSMS_MT_M2M_660004724 = 0
FINSI


# Variable globale SMS_LA_MODE
i_strcpy(pt_smsc_la_mode_660004724,i_get_tab_field("VariableContexte", date_pivot_660004724, "SMS_LA_MODE"))


#QC989 - G3R5 lot1 bSMS_PrepaidMO_PRISM et bSMS_PrepaidMO_GORI

SI bSMS_MO_660004724
ALORS
	bSMS_PrepaidMO_GORI_660004724 = 0
	bSMS_PrepaidMO_PRISM_660004724 = 0
	
	# Determine la plateforme origine RI MVNO PRISM(SAC=890) ou RI MVNO GORI(SAC = 891)
	SI(i_valid_field_n(g_iartin,$TSms_cmg::ogtiAddress))
	ALORS 
		ogtiAddressTON_660004724 = i_get_art_fieldtab(g_iartin,$TSms_cmg::ogtiAddress,0)
		ogtiAddressNPI_660004724 = i_get_art_fieldtab(g_iartin,$TSms_cmg::ogtiAddress,1)
		ogtiAddressDIGIT1_660004724 = i_get_art_fieldtab(g_iartin,$TSms_cmg::ogtiAddress,2)
		ogtiAddressDIGIT2_660004724 = i_get_art_fieldtab(g_iartin,$TSms_cmg::ogtiAddress,3)
		ogtiAddressDIGIT3_660004724 = i_get_art_fieldtab(g_iartin,$TSms_cmg::ogtiAddress,4)
		ogtiAddressDIGIT4_660004724 = i_get_art_fieldtab(g_iartin,$TSms_cmg::ogtiAddress,5)
		ogtiAddressDIGIT5_660004724 = i_get_art_fieldtab(g_iartin,$TSms_cmg::ogtiAddress,6)
		ogtiAddressLong_660004724 = i_get_art_field(g_iartin,$TSms_cmg::ogtiAddress - 1)

		SI (
			(( ogtiAddressTON_660004724 == 8 ) && ( ogtiAddressNPI_660004724 == 1) &&
			(ogtiAddressDIGIT1_660004724 == 8 ) && ( ogtiAddressDIGIT2_660004724 == 9 ) &&
			(ogtiAddressDIGIT3_660004724 == 0) && (ogtiAddressDIGIT4_660004724 == 0) && (ogtiAddressLong_660004724 > 3))	
			||
			(( ogtiAddressTON_660004724 == 8 ) && ( ogtiAddressNPI_660004724 == 1) &&
			(ogtiAddressDIGIT1_660004724 == 0 ) && ( ogtiAddressDIGIT2_660004724 == 0 ) &&
			(ogtiAddressDIGIT3_660004724 == 8) && (ogtiAddressDIGIT4_660004724 == 9) && (ogtiAddressDIGIT5_660004724 == 0) && (ogtiAddressLong_660004724 > 4) 
			)
			)
	ALORS
	      bSMS_PrepaidMO_PRISM_660004724 = 1
		SINON
			SI (
				(( ogtiAddressTON_660004724 == 8 ) && ( ogtiAddressNPI_660004724 == 1) &&
				(ogtiAddressDIGIT1_660004724 == 8 ) && ( ogtiAddressDIGIT2_660004724 == 9 ) &&
				(ogtiAddressDIGIT3_660004724 == 1 ) && (ogtiAddressDIGIT4_660004724 == 0) && (ogtiAddressLong_660004724 > 3))
				||
				(( ogtiAddressTON_660004724 == 8 ) && ( ogtiAddressNPI_660004724 == 1) &&
				(ogtiAddressDIGIT1_660004724 == 0 ) && ( ogtiAddressDIGIT2_660004724 == 0 ) &&
				(ogtiAddressDIGIT3_660004724 == 8) && (ogtiAddressDIGIT4_660004724 == 9) && (ogtiAddressDIGIT5_660004724 == 1) &&  (ogtiAddressLong_660004724 > 4))
				)
			ALORS
				bSMS_PrepaidMO_GORI_660004724 = 1
			FINSI
		FINSI
	FINSI
FINSI		


#/G3R5 lot1 SMS_PrepaidMO_PRISM

# Variable globale SMS_PrepaidMO
# FO591
#QC989 - G3R5 lot1 bSMS_PrepaidMO_PRISM et bSMS_PrepaidMO_GORI
SI bSMS_MO_660004724
ALORS
	SI (i_valid_field_n(g_iartin, $TSms_cmg::ogtiAddress))
	ALORS
		erreur_660004724 = i_cree_art("Tnormal", g_iartout2)
		#G3R5 lot1
		erreur_660004724 = i_dup_chp_rnisGSM(g_iartin, g_iartout2, $TSms_cmg::ogtiAddress, $Tnormal::Address, -$NORM:SMSC_MO_OGTI_PREPAID, 0)
		#QC991
		SI (erreur_660004724 != 0)
		ALORS
			#trace("Erreur recuperation ogtiAddress ")
			ERREUR_660004724 = ERR_NORM_660004724
			code_rejet_660004724 = MODULE_660004724 + ERREUR_660004724 + EFFICACE_660004724
			erreur_660004724 = i_PlvMessEmettre(7503, 2, g_iartin, "", 3, code_rejet_660004724, "TSms_cmg traitement", "ogtiAddress")
			SAUT STOCKE_ERRONE
		FINSI
		erreur_660004724 = i_get_art_str(g_iartout2, $Tnormal::Address, pt_recipAddress_660004724)
		#trace2("Normalisation ogtiAddress <%s> ", pt_recipAddress , "")
		#QC991
		pt_erreur_660004724 = i_get_tab_field("SMS_CMG_PrepaidMO", date_pivot_660004724, pt_recipAddress_660004724)
		SI (i_strcmp(pt_erreur_660004724, g_inull) || bSMS_PrepaidMO_PRISM_660004724 == 1 || bSMS_PrepaidMO_GORI_660004724 == 1)
		ALORS
			bsmsc_prepaid_660004724 = 1
			#trace("Champ ogtiAdressGSM present dans la liste des adresses PrepaidMO")
		SINON
			bsmsc_prepaid_660004724 = 0
			#trace("Champ ogtiAdressGSM absent dans la liste des adresses PrepaidMO")
		FINSI
	SINON
		bsmsc_prepaid_660004724 = 0
	FINSI
SINON
	bsmsc_prepaid_660004724 = 0
FINSI	

# FO591
SI ((bSMS_MO_660004724 == 1) && (bsmsc_prepaid_660004724 == 1))
ALORS
	bSMS_PrepaidMO_660004724 = 1
SINON
	bSMS_PrepaidMO_660004724 = 0
FINSI

# Variable globale SMS_PrepaidMO_Mobile
# FO591
SI ((bSMS_PrepaidMO_660004724 == 1) && (consolidation_present_660004724 == 0))
ALORS
	bSMS_PrepaidMO_Mobile_660004724 = 1
SINON
	bSMS_PrepaidMO_Mobile_660004724 = 0
FINSI

# Variable globale SMS_PrepaidLA
SI ((bSMS_PrepaidMO_660004724 == 1) && (consolidation_present_660004724 == 1))
ALORS
	bSMS_PrepaidLA_660004724 = 1
SINON
	bSMS_PrepaidLA_660004724 = 0
FINSI

####################################################################
# Compteurs applicatifs
####################################################################
date_fin_660004724 = i_get_art_field(g_iartin, $TSms_cmg::dfin)

# Nombre de CRA/EEC/Type de CRA/JOUR : CPT_1501
erreur_660004724 = i_incr_cpt(CPT_1501_660004724, TYPE_SMSC_660004724, g_ieec, 0, i_DHgetLocalTime(4, 7, i_date_audit()), 1)
#trace("Incremantation du compteur CPT_1501")

# Nombre de CRA/EEC/"SMS_MO_LA"/jour : CPT_1521
#SI (bSMS_MO_LA == 1)
# Nombre de CRA/EEC/"SMS_MO_LA_4"/jour : CPT_1521
SI (bSMS_MO_LA_4_660004724 == 1)
ALORS
	erreur_660004724 = i_incr_cpt(CPT_1521_660004724, TYPE_SMSC_660004724, g_ieec, 0, date_fin_660004724, 1)
	#trace("Incremantation du compteur CPT_1521")
FINSI

# Nombre de CRA/EEC/"SMS_MO_Gateway"/jour : CPT_1522
SI (bSMS_MO_Gateway_660004724 == 1)
ALORS
	erreur_660004724 = i_incr_cpt(CPT_1522_660004724, TYPE_SMSC_660004724, g_ieec, 0, date_fin_660004724, 1)
	#trace("Incremantation du compteur CPT_1522")
FINSI

# Nombre de CRA/EEC/"SMS_MT_ServPrive"/jour : CPT_1523
SI (bSMS_MT_ServPrive_660004724 == 1)
ALORS
	erreur_660004724 = i_incr_cpt(CPT_1523_660004724, TYPE_SMSC_660004724, g_ieec, 0, date_fin_660004724, 1)
	#trace("Incremantation du compteur CPT_1523")
FINSI

# Nombre de CRA/EEC/"SMS_MT_Gateway"/jour : CPT_1524
SI (bSMS_MT_Gateway_660004724 == 1)
ALORS
	erreur_660004724 = i_incr_cpt(CPT_1524_660004724, TYPE_SMSC_660004724, g_ieec, 0, date_fin_660004724, 1)
	#trace("Incremantation du compteur CPT_1524")
FINSI

# Nombre de CRA/EEC/"SMS_MT_M2M"/jour : CPT_1525
SI (bSMS_MT_M2M_660004724 == 1)
ALORS
	erreur_660004724 = i_incr_cpt(CPT_1525_660004724, TYPE_SMSC_660004724, g_ieec, 0, date_fin_660004724, 1)
	#trace("Incremantation du compteur CPT_1525")
FINSI

# Nombre de CRA/EEC/"SMS_PrepaidMO"/jour : CPT_1526
# FO591
SI (bSMS_PrepaidMO_Mobile_660004724 == 1)
ALORS
	erreur_660004724 = i_incr_cpt(CPT_1526_660004724, TYPE_SMSC_660004724, g_ieec, 0, date_fin_660004724, 1)
	#trace("Incremantation du compteur CPT_1526")
FINSI

# Nombre de CRA/EEC/"SMS_PrepaidLA"/jour : CPT_1527
SI (bSMS_PrepaidLA_660004724 == 1)
ALORS
	erreur_660004724 = i_incr_cpt(CPT_1527_660004724, TYPE_SMSC_660004724, g_ieec, 0, date_fin_660004724, 1)
	#trace("Incremantation du compteur CPT_1527")
FINSI

# Nombre de CRA/EEC/"SMS_MT_0"/jour : CPT_1528
SI (bSMS_MT_0_660004724 == 1)
ALORS
	erreur_660004724 = i_incr_cpt(CPT_1528_660004724, TYPE_SMSC_660004724, g_ieec, 0, date_fin_660004724, 1)
	#trace("Incremantation du compteur CPT_1528")
FINSI

# Nombre de CRA/EEC/"SMS_MO_4"/jour : CPT_1529
SI (bSMS_MO_4_660004724 == 1)
ALORS
	erreur_660004724 = i_incr_cpt(CPT_1529_660004724, TYPE_SMSC_660004724, g_ieec, 0, date_fin_660004724, 1)
	#trace("Incremantation du compteur CPT_1529")
FINSI

# Nombre de CRA/EEC/"SMS_MT_4"/jour : CPT_1530
SI (bSMS_MT_4_660004724 == 1)
ALORS
	erreur_660004724 = i_incr_cpt(CPT_1530_660004724, TYPE_SMSC_660004724, g_ieec, 0, date_fin_660004724, 1)
	#trace("Incremantation du compteur CPT_1530")
FINSI

# /G1R5

#QC991 deplacement du stockage vers distribution
trace("**** TSms_cmg : Fin traitement OK ****")
erreur_660004724 = i_stocke_art(g_iartin, 0, PT_OK, 0)

RETOUR TRAIT_OK

#
# ---- Point de branchement :Stockage en errone
#

POINT STOCKE_ERRONE

trace("SMS-C CMG: stokage de l article en errone")
erreur_660004724 = i_make_art_rej(g_iartin, g_iartout, code_rejet_660004724)
erreur_660004724 = i_stocke_art(g_iartout, 0, PT_ERRONE, 0)
trace( "Fin traitement, Article TSms_cmg ERRONE " )
RETOUR TRAIT_OK

#---- fin traitements  TSms_cmg_tr.src ------------------------------------
