DEFINITION ERR_SYNTAX_780042451 0x5041
DEFINITION MAX_LEG_780042451 30
DEFINITION INCREMENT_780042451 1
DEFINITION CPT_780042451 1501
DEFINITION OFFSET_780042451 63
DEFINITION VRAI_780042451 1
DEFINITION FAUX_780042451 0
DEFINITION DATE_REF_780042451 0xBC191380
REGISTRE ENTIER X_780042451
REGISTRE ENTIER Y_780042451
REGISTRE ENTIER Z_780042451
REGISTRE ENTIER date_audit_780042451
REGISTRE ENTIER erreur_780042451
REGISTRE ENTIER code_rejet_780042451
REGISTRE ENTIER resultat_780042451
REGISTRE ENTIER ServiceType30_780042451
REGISTRE ENTIER ServiceType31_780042451
REGISTRE ENTIER NbServices_780042451
REGISTRE ENTIER CauseForTerm_780042451
REGISTRE ENTIER effmo_780042451
REGISTRE ENTIER indice_780042451
REGISTRE ENTIER EFFICACE_MO_780042451
REGISTRE ENTIER CauseForTermO_780042451
REGISTRE POINTEUR pt_champ_780042451
################################################################
# Pcode de TRAITEMENT Ttn_tr.src
# Service Talk Now 
# Article : TTn
################################################################
# 
# URS/PSA	22/02/06	Creation
# URS/PSA	20/04/06	FO 182, 185
# URS/THEFAL	22/06/06	G3R0CbME FO 224
# URS PSA	09/08/07	G1R4 : FO TT18
# 20/01/11 - G3R1 lot4 Verification/Correction des variables (constantes, entiers, pointeurs)
#
################################################################

# tous les DC sont efficaces


# G3R0CbME



# G3R0CbME


# G3R0CbME
EFFICACE_MO_780042451 = FAUX_780042451

resultat_780042451 = -1
ServiceType30_780042451 = -1
ServiceType31_780042451 = -1
NbServices_780042451 = -1
CauseForTerm_780042451 = -1
effmo_780042451 = 0
indice_780042451 = 0

# G3R0CbME
CauseForTermO_780042451 = -1

pt_champ_780042451 = "pt_champ012345678901234567890123456789012345678901234567890123456789"


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

trace("Pcode de traitement de Ttn")


#erreur=i_test_art(g_iartin)
#SI erreur
#ALORS
#        trace("test_art en erreur")
#	code_rejet = ERR_SYNTAX 
#	erreur = i_PlvMessEmettre(6350,2,g_iartin,"",1,code_rejet,0,0)
#        SAUT STOCKE_ERRONE
#FINSI

################################################################################################
# Controles unitaires
# Remarque : les tests sur les champs contenus dans les MT seront faits en distribution
################################################################################################
#
# Test sur le champ GENE/RecordType
#
resultat_780042451 = i_get_art_field(g_iartin,$Ttn::RecordType)
SI resultat_780042451 != 0x3E
ALORS
	code_rejet_780042451 = ERR_SYNTAX_780042451 
	i_strcpy(pt_champ_780042451, "RecordType")
	erreur_780042451 = i_PlvMessEmettre(6501,2,g_iartin,"",3,code_rejet_780042451,resultat_780042451,pt_champ_780042451)
    	SAUT STOCKE_ERRONE
FINSI

#
# Test sur le champ GENE/CallType
#
resultat_780042451 = i_get_art_field(g_iartin,$Ttn::CallType)
SI  (resultat_780042451 != 0x00) && (resultat_780042451 != 0x01)
ALORS
	code_rejet_780042451 = ERR_SYNTAX_780042451 
	i_strcpy(pt_champ_780042451, "CallType")
	erreur_780042451 = i_PlvMessEmettre(6501,2,g_iartin,"",3,code_rejet_780042451,resultat_780042451,pt_champ_780042451)
	SAUT STOCKE_ERRONE
FINSI

#
# Test sur le champ ORIG/LegType
#
resultat_780042451 = i_get_art_field(g_iartin,$Ttn::LegTypeO)
SI  (resultat_780042451 != 0x00)
ALORS
	code_rejet_780042451 = ERR_SYNTAX_780042451 
	i_strcpy(pt_champ_780042451, "LegTypeO")
	erreur_780042451 = i_PlvMessEmettre(6501,2,g_iartin,"",3,code_rejet_780042451,resultat_780042451,pt_champ_780042451)
    	SAUT STOCKE_ERRONE
FINSI

#
# Test sur le champ ORIG/CauseForTerm
#
CauseForTerm_780042451 = i_get_art_field(g_iartin,$Ttn::CauseTermO)
SI  (CauseForTerm_780042451 < 0x00) || (CauseForTerm_780042451 > 0x04)
ALORS
	code_rejet_780042451 = ERR_SYNTAX_780042451 
	i_strcpy(pt_champ_780042451, "CauseTermO")
	erreur_780042451 = i_PlvMessEmettre(6501,2,g_iartin,"",3,code_rejet_780042451,CauseForTerm_780042451,pt_champ_780042451)
	SAUT STOCKE_ERRONE
FINSI

#
# Test sur le champ ORIG/NbServices
#
NbServices_780042451 = i_get_art_field(g_iartin,$Ttn::NumOfServO)
SI  (NbServices_780042451 != 0x01) && (NbServices_780042451 != 0x02)
ALORS
	code_rejet_780042451 = ERR_SYNTAX_780042451 
	i_strcpy(pt_champ_780042451, "NumOfServO")
	erreur_780042451 = i_PlvMessEmettre(6501,2,g_iartin,"",3,code_rejet_780042451,NbServices_780042451,pt_champ_780042451)
	SAUT STOCKE_ERRONE
FINSI

#
# Test sur le champ ORIG/SIRLIST 30/ServiceType  
#
ServiceType30_780042451 = i_get_art_field(g_iartin,$Ttn::ServType30O)
SI  (ServiceType30_780042451 != 0x00) && (ServiceType30_780042451 != 0x03)
ALORS
	code_rejet_780042451 = ERR_SYNTAX_780042451 
	i_strcpy(pt_champ_780042451, "ServType30O")
	erreur_780042451 = i_PlvMessEmettre(6501,2,g_iartin,"",3,code_rejet_780042451,ServiceType30_780042451,pt_champ_780042451)
	SAUT STOCKE_ERRONE
FINSI

#
# Test sur le champ ORIG/SIRLIST 31/ServiceType 
#
SI i_valid_field_n(g_iartin,$Ttn::ServType31O)
ALORS
	ServiceType31_780042451 = i_get_art_field(g_iartin,$Ttn::ServType31O)
	SI  (ServiceType31_780042451 != 0x00) && (ServiceType31_780042451 != 0x03)
	ALORS
		code_rejet_780042451 = ERR_SYNTAX_780042451 
		i_strcpy(pt_champ_780042451, "ServType31O")
		erreur_780042451 = i_PlvMessEmettre(6501,2,g_iartin,"",3,code_rejet_780042451,ServiceType31_780042451,pt_champ_780042451)
		SAUT STOCKE_ERRONE
	FINSI
FINSI


################################################################################################
# Controles croises
# Remarque : les tests sur les champs contenus dans les MT seront faits en distribution
################################################################################################
#
# ORIG/NbServices
# ORIG/SIRLIST 30/ServiceType
#
SI (NbServices_780042451 == 0x01) 
ALORS
	SI (ServiceType30_780042451 != 0x00)
	ALORS
		code_rejet_780042451 = ERR_SYNTAX_780042451 
		i_strcpy(pt_champ_780042451, "NumOfServO et ServType30O")
		erreur_780042451 = i_PlvMessEmettre(6502,2,g_iartin,"",2,code_rejet_780042451,pt_champ_780042451,0)
		SAUT STOCKE_ERRONE
	FINSI
FINSI

#
# ORIG/NbServices
# ORIG/SIRLIST 30/ServiceType
# ORIG/SIRLIST 31/ServiceType
#
SI (NbServices_780042451 == 0x02) 
ALORS
	SI !( ((ServiceType30_780042451 == 0x00) && (ServiceType31_780042451 == 0x03)) || ((ServiceType30_780042451 == 0x03) && (ServiceType31_780042451 == 0x00)) )
	ALORS
		code_rejet_780042451 = ERR_SYNTAX_780042451 
		i_strcpy(pt_champ_780042451, "NumOfServO, ServType30O et ServType31O")
		erreur_780042451 = i_PlvMessEmettre(6502,2,g_iartin,"",2,code_rejet_780042451,pt_champ_780042451,0)
	SAUT STOCKE_ERRONE
	FINSI
FINSI

#
# ORIG/NbServices
# ORIG/Upgrade2P2Ctime
#
SI (NbServices_780042451 > 0x01)
ALORS
	SI !i_valid_field_n(g_iartin,$Ttn::Up2P2CtimeO)
	ALORS
		code_rejet_780042451 = ERR_SYNTAX_780042451 
		i_strcpy(pt_champ_780042451, "NumOfServO et Up2P2CtimeO")
		erreur_780042451 = i_PlvMessEmettre(6502,2,g_iartin,"",2,code_rejet_780042451,pt_champ_780042451,0)
		SAUT STOCKE_ERRONE
	FINSI
FINSI

#
# ORIG/NbServices
# ORIG/Upgrade2P2Ctime
# ORIG/AnswerTime
#
SI (NbServices_780042451 > 0x01)
ALORS
	resultat_780042451 = i_get_art_field(g_iartin,$Ttn::Up2P2CtimeO) - i_get_art_field(g_iartin,$Ttn::DATE)	
	SI ( resultat_780042451 < 0 )
	ALORS
		code_rejet_780042451 = ERR_SYNTAX_780042451 
		i_strcpy(pt_champ_780042451, "NumOfServO, Up2P2CtimeO et AnswerTimeO (DATE)")
		erreur_780042451 = i_PlvMessEmettre(6502,2,g_iartin,"",2,code_rejet_780042451,pt_champ_780042451,0)
		SAUT STOCKE_ERRONE
	FINSI
FINSI

#
# GENE/CallType
# TERMLEGLIST2
#			
resultat_780042451 = i_get_art_field(g_iartin,$Ttn::CallType)
SI (resultat_780042451 == 0)
ALORS
	SI i_valid_field_n(g_iartin,$Ttn::T2TERMLEGLIST2)
	ALORS
		code_rejet_780042451 = ERR_SYNTAX_780042451 
		i_strcpy(pt_champ_780042451, "CallType et T2TERMLEGLIST2")
		erreur_780042451 = i_PlvMessEmettre(6502,2,g_iartin,"",2,code_rejet_780042451,pt_champ_780042451,0)
		SAUT STOCKE_ERRONE
	FINSI
FINSI

# G3R0CbME
###############
# EFFICACE_MO #
###############
resultat_780042451 = i_get_art_field(g_iartin,$Ttn::DATE)	
CauseForTermO_780042451 = i_get_art_field(g_iartin,$Ttn::CauseTermO)
SI ( CauseForTermO_780042451 != 0x03 ) && ( resultat_780042451 != DATE_REF_780042451 ) 
ALORS
	EFFICACE_MO_780042451 = VRAI_780042451
SINON
	EFFICACE_MO_780042451 = FAUX_780042451
FINSI

SI ( EFFICACE_MO_780042451 == FAUX_780042451 )
ALORS
	SAUT STOCKE_ELIMINE
FINSI



################################################################################################
# Calcul de effmo
# On s'arrete au 1er MT efficace
################################################################################################

indice_780042451 = 1

POINT DEBUT_BOUCLE_MT

SI i_valid_field_n(g_iartin,$Ttn::CauseTerm1 + (OFFSET_780042451 * (indice_780042451 - 1)))
ALORS
	CauseForTerm_780042451 = i_get_art_field(g_iartin,$Ttn::CauseTerm1 + (OFFSET_780042451 * (indice_780042451 - 1)))
	SI ( CauseForTerm_780042451 != 0x03 )
	ALORS
		effmo_780042451 = indice_780042451
		SAUT FIN_BOUCLE_MT
	SINON
		indice_780042451 = indice_780042451 + 1
		SAUT DEBUT_BOUCLE_MT
	FINSI
SINON
	SI ( indice_780042451 < MAX_LEG_780042451 + 1 )
	ALORS
		indice_780042451 = indice_780042451 + 1
		SAUT DEBUT_BOUCLE_MT
	SINON
		SAUT FIN_BOUCLE_MT
	FINSI
FINSI

POINT FIN_BOUCLE_MT

SI ( effmo_780042451 == 0 )
ALORS
	SAUT STOCKE_ELIMINE
FINSI

#
########################################################
# Cpt applicatifs
########################################################
date_audit_780042451 = i_date_audit()

X_780042451=0x00
Y_780042451=g_ieec
Z_780042451=0

erreur_780042451=i_incr_cpt(CPT_780042451,X_780042451,Y_780042451,Z_780042451,date_audit_780042451,INCREMENT_780042451)


#####################################################################
# POINT de branchement : stockage PT_OK
#####################################################################

POINT STOCKE_OK

erreur_780042451 = i_stocke_art(g_iartin, 0, PT_OK,0)
trace("######### Stockage en OK")


RETOUR TRAIT_OK

#####################################################################
# POINT de branchement : stockage PT_ERRONE
#	       correspond au cas d'erreur syntaxiques et semantiques
#####################################################################
POINT STOCKE_ERRONE


erreur_780042451 = i_make_art_rej(g_iartin, g_iartout, code_rejet_780042451)
erreur_780042451 = i_stocke_art(g_iartout, 0, PT_ERRONE, 0)


RETOUR TRAIT_OK


#####################################################################
# POINT de branchement : stockage PT_ELIMINE
#	       correspond aux articles sans MT EFFICACE
#####################################################################
POINT STOCKE_ELIMINE

erreur_780042451 = i_stocke_art(g_iartin, 0, PT_DIVERS, 0)

RETOUR TRAIT_OK
#--------------------- Fin Ttn_tr.src --------------------------------------
