DEFINITION DUP_TAB_NORMITINERIS_660004663 0
DEFINITION DUP_TAB_NORMROAMERS_660004663 1
DEFINITION DUP_TAB_NORMTGROUPE_660004663 3
DEFINITION DUP_TAB_URGENT_NOSIM_660004663 4
DEFINITION DUP_TAB_ECHECNORM_660004663 5
DEFINITION Multidistribution_Non_660004663 0
DEFINITION DISTRIBUTION_SPECIALE_660004663 0
DEFINITION DISTRIBUTION_INCONNU_660004663 1
DEFINITION TRAI_KO_660004663 -1
DEFINITION MODULE_DISTR_660004663 0xA000
DEFINITION ERR_NORM_660004663 0x010
DEFINITION ERR_VALO_660004663 0x020
DEFINITION ERR_DUPL_660004663 0x0D0
DEFINITION ERR_DISTR_660004663 0x110
REGISTRE ENTIER erreur_660004663
REGISTRE ENTIER flag_rdt_660004663
REGISTRE ENTIER app_urg_660004663
REGISTRE ENTIER nbut_660004663
REGISTRE ENTIER IMSI_present_660004663
REGISTRE ENTIER MSISDN_present_660004663
REGISTRE ENTIER digit1_660004663
REGISTRE ENTIER digit2_660004663
REGISTRE ENTIER digit3_660004663
REGISTRE ENTIER digit4_660004663
REGISTRE ENTIER digit5_660004663
REGISTRE ENTIER dig3_660004663
REGISTRE ENTIER val_OICK_660004663
REGISTRE ENTIER TON_origLocNum_660004663
REGISTRE ENTIER NPI_origLocNum_660004663
REGISTRE ENTIER origLocNum_present_660004663
REGISTRE ENTIER tailleChpTrans_660004663
REGISTRE ENTIER indice_duptab_660004663
REGISTRE ENTIER ic_660004663
REGISTRE ENTIER TON_660004663
REGISTRE ENTIER NPI_660004663
REGISTRE ENTIER calledNumber_present_660004663
REGISTRE ENTIER flag_rm_escape_char_660004663
REGISTRE ENTIER userRate_660004663
REGISTRE ENTIER userProtocol_660004663
REGISTRE ENTIER tranInd_660004663
REGISTRE ENTIER transIndicator_present_660004663
REGISTRE ENTIER calltype_660004663
REGISTRE ENTIER CSDaddValue_660004663
REGISTRE ENTIER lg_calledNumber_660004663
REGISTRE ENTIER tlserv_mod_660004663
REGISTRE ENTIER gsmTlSrv_660004663
REGISTRE ENTIER svcsup_660004663
REGISTRE ENTIER Q1_660004663
REGISTRE ENTIER Q2_660004663
REGISTRE ENTIER vsvcsup_660004663
REGISTRE ENTIER taille_idpart_660004663
REGISTRE ENTIER date_660004663
REGISTRE ENTIER date_fin_660004663
REGISTRE ENTIER heure_660004663
REGISTRE ENTIER res_660004663
REGISTRE ENTIER timeForTccall_660004663
REGISTRE ENTIER Digit_660004663
REGISTRE ENTIER indice_idpart_660004663
REGISTRE ENTIER indice_called_660004663
REGISTRE ENTIER IMSI_OrangeCo_660004663
REGISTRE POINTEUR str_IMSI_660004663
REGISTRE POINTEUR str_MNC_660004663
REGISTRE POINTEUR str_conteneur_660004663
REGISTRE ENTIER code_rejet_660004663
REGISTRE ENTIER EFFICACE_660004663
REGISTRE ENTIER MODULE_660004663
REGISTRE ENTIER ERREUR_660004663
REGISTRE ENTIER position_660004663
REGISTRE ENTIER longueur_660004663
REGISTRE POINTEUR str_exchasciident_660004663
REGISTRE POINTEUR str_exchDCBdent_660004663
REGISTRE ENTIER date_cra_660004663
REGISTRE ENTIER date_table_660004663
REGISTRE ENTIER bT3T8ITX_660004663
REGISTRE POINTEUR ptr_valeurDATE_660004663
REGISTRE POINTEUR ptr_date_res_660004663
####################################################################
#       Appel Sortant MET NSS9, cas d'article Torig_nss9
####################################################################
#       article CRA MET ASN1 => type DPV TLV = 00
#
# AE 25/08/05 Creation
# 23/05/2008 - FAL - G1R8 - Appel urgence 112
# 15/04/2009 - DRE - G2R2 - Retour arriere urgence 112 spec: CRA_Tcomp_nss9_A25.0.doc
# 07/05/2009 - PSA - G2R2 - QC 383 : complement retour arriere urgence 112
# 24/08/2009 - PKH - G2R3 - Correction QC396
# 11/06/2010 - JLG - G2R6C800 : appel fonction aiguillage2, creation enveloppe E_Redistri2,
#                                     ajout champ T3t55 (GFlag2) et T3t56 (GValue)
# 07/12/2010 - JLG - G3R1lot4 Verification/Correction des variables (constantes, entiers, pointeurs)
# 10/03/2011 - JLG - G3R2C4 fusion G3R2C3 avec G3R1C600 (ajout champ T3t99)
# 09/05/2011 - PKH - QC843 Modification du paramettre DUMP(0->2) dans le verbe i_PlvMessEmmetre alarme : 8310,
# 29/02/2012 - JLG - G3R6 QC1005 modif alarme retour aiguillage
# 14/05/2012 - PKH - G3R7 Gestion du code MNC pour les MVNOs Lights
# 17/07/2013         G3R10 lot3 QC1232 : DPV FREE V3t9, MSC E// mapping donnee disconnectingParty - Correction V3t1.14/DPV4.0
# 07/08/2013 - PKH - G3R10 lot3 QC1232 : reprise pour correction mauvaise interpretation de la valeur retour de i_valid_field_n
# 11/02/2014 - JLG - G5R1 QC1331, Built 3 : Changement Marque Audit
# 01/04/2014 - RHE - G5R1 Modification de l'alimentation du champ V3t8 ITX
# 20/05/2014 - RHE - G5R1 Modification de l'alimentation du champ V3t8 ITX (QC 1386)
# 02/07/2014 - JLG - G5R1 QC1405, champ eec du DPV si g_ieec > 500
# 09/10/2014 - JLG - QC1444 correction supplementaire de la QC1292
####################################################################

#G3R7


#QC396
# /QC396

# Definition des constantes



#G5R1
ptr_valeurDATE_660004663 ="ptr_valeurDATE0123456789"
ptr_date_res_660004663 ="ptr_date_res0123456789"
i_strcpy (ptr_valeurDATE_660004663,"")
i_strcpy (ptr_date_res_660004663,"")


IMSI_OrangeCo_660004663 = 0
str_IMSI_660004663 = "str_IMSI757575757575757657575757575757575757575757575757575757757757575757575757"
str_MNC_660004663 = "str_MNC535353533535353535353535353535333"
str_conteneur_660004663 = "str_conteneur93939393933939393939939393939393939"

i_strcpy (str_IMSI_660004663,"")
i_strcpy (str_MNC_660004663,"")
i_strcpy (str_conteneur_660004663,"")

trace("Torig_nss9 : Debut Distribution")

#  g_iartin et redistribution
# ==================================
# copie du CRA original dans le g_iartout12
erreur_660004663 = i_dup_art_id(g_iartin, g_iartout12)

# Initialisations
EFFICACE_660004663 = 1
MODULE_660004663 = MODULE_DISTR_660004663
ERREUR_660004663 = 0
code_rejet_660004663 = 0

#QC396
str_exchasciident_660004663 = "str_exchasciident19191919191919191919191911991919191919191919"
str_exchDCBdent_660004663 = "str_exchasciident232323232323232323232323232323232323233223233"
position_660004663 = 0
longueur_660004663 = 0
# /QC396

#  comptabilisation des CRAs issus de la redistribution
date_fin_660004663=i_get_art_field(g_iartin,$Torig_nss9::dfin)
erreur_660004663= i_incr_redist_dist_660004265(date_fin_660004663)

#G5R1
####################################################################################
# Modification de l'alimentation du champ T3t8 ITX
# bT3T8ITX : 1 si DATEFIN_ITX absent de table VariableContexte ou si  date_cra < DATEFIN_ITX
####################################################################################

date_cra_660004663 = i_get_art_field(g_iartin,$Torig_nss9::ddebut)

bT3T8ITX_660004663 = 0
date_table_660004663 = 0
SI(i_get_tab_field("VariableContexte",date_cra_660004663,"DATEFIN_ITX") == g_inull)
ALORS
	trace("DATEFIN_ITX Absent de la table VariableContexte -> msgITX present")
	bT3T8ITX_660004663 = 1
SINON        
	i_strcpy(ptr_valeurDATE_660004663, i_get_tab_field("VariableContexte", date_cra_660004663, "DATEFIN_ITX"))
	i_get_sub_str(ptr_valeurDATE_660004663,2,-1,ptr_date_res_660004663)
	erreur_660004663 = i_cree_art("Conv_URS", g_iartout7)
	erreur_660004663 = i_set_art_str (g_iartout7,$Conv_URS::DATE,ptr_date_res_660004663)
	date_table_660004663 = i_get_art_field(g_iartout7, $Conv_URS::DATEN)
	trace1(" date_cra   = %d", date_cra_660004663)
	trace1(" date_table = %d", date_table_660004663)
  SI (date_cra_660004663 < date_table_660004663)
  ALORS       
  	trace("date_cra < date_table -> msgITX present")
  	bT3T8ITX_660004663 = 1
  FINSI
FINSI	    


##################################################################################
# Identification de la provenance de l'article
# flag_rdt : nb de passage en redistribution (lecture de l'enveloppe obligatoire)
##################################################################################
flag_rdt_660004663 = -1
flag_rdt_660004663 = i_LireRedistCpt()

SI (flag_rdt_660004663 == 0)
ALORS
  erreur_660004663 = i_add_opt( "E_Redistri2" )
FINSI
erreur_660004663 = i_set_attr_val_n( $E_Redistri2::EnvoiRedis, 0)

# En premier lieu on test si l appel est urgent
gsmTlSrv_660004663 = i_get_art_field(g_iartin,$Torig_nss9::teleServiceCode)
SI (gsmTlSrv_660004663 == 0x12)
ALORS
  IMSI_present_660004663 =  i_valid_field_n(g_iartin,$Torig_nss9::IMSI)
  MSISDN_present_660004663 = i_valid_field_n(g_iartin,$Torig_nss9::callingNumber)
  SI ((!IMSI_present_660004663) && (!MSISDN_present_660004663))
  ALORS
    SAUT TRAIT_APPEL_APPEL_URGENT_NO_SIM
  FINSI
FINSI
#####################################################################
# Choix de la table de duplication
#####################################################################
#
# (si le champ est present car il est optionnel)
#
calledNumber_present_660004663 = i_get_art_field(g_iartin, $Torig_nss9::calledNumber - 1)
SI (calledNumber_present_660004663 > 0 )
ALORS
  TON_660004663 = i_get_art_fieldtab(g_iartin, $Torig_nss9::calledNumber, 0)
  NPI_660004663 = i_get_art_fieldtab(g_iartin, $Torig_nss9::calledNumber, 1)
FINSI

# On valide la suppression des caracteres speciaux
flag_rm_escape_char_660004663=1

digit1_660004663 = i_get_art_fieldtab(g_iartin, $Torig_nss9::IMSI, 0)
digit2_660004663 = i_get_art_fieldtab(g_iartin, $Torig_nss9::IMSI, 1)
digit3_660004663 = i_get_art_fieldtab(g_iartin, $Torig_nss9::IMSI, 2)
digit4_660004663 = i_get_art_fieldtab(g_iartin, $Torig_nss9::IMSI, 3)
digit5_660004663 = i_get_art_fieldtab(g_iartin, $Torig_nss9::IMSI, 4)
SI ( (digit1_660004663==2) &&
  (digit2_660004663==0) &&
  (digit3_660004663==8) &&
  (digit4_660004663==0) &&
  (digit5_660004663==1) )
ALORS
#G3R7 Gestion des MVNOs ligths
  IMSI_OrangeCo_660004663 = 1
SINON
  SI ( (digit1_660004663==2) &&
    (digit2_660004663==0) &&
    (digit3_660004663==8))
  ALORS
    erreur_660004663 = i_get_art_str(g_iartin, $Torig_nss9::IMSI,str_IMSI_660004663)
    i_get_sub_str (str_IMSI_660004663, 0, 4, str_MNC_660004663)
    erreur_660004663=i_format_str2( str_conteneur_660004663, "%s%s", "L_", str_MNC_660004663)
    SI (i_get_tab_field("MVNO", date_fin_660004663, str_conteneur_660004663)) != g_inull
    ALORS
      IMSI_OrangeCo_660004663 = 1
    SINON
      IMSI_OrangeCo_660004663 = 0
    FINSI
  FINSI
# Cas des abonnes ITINERIS
FINSI
#\G3R7
SI IMSI_OrangeCo_660004663
ALORS
  indice_duptab_660004663 = DUP_TAB_NORMITINERIS_660004663
SINON
# Cas des ROAMERS

#Une nouvelle Table de duplication d indice 6 a ete ajouter pour permettre
#de tester la normalisationde calledNumber avec la table de normlisation 34

  erreur_660004663 = i_dup_art_tab_choix(g_iartin,g_iartout5,"TnormalTlv",6)
  #G5R1
  #Pas d'ajout de T3t8

  trace1("Torig_nss9 : retour i_test_chp_rnis = %d",erreur_660004663)
  SI (erreur_660004663 < 0)
  ALORS
# Cas echec normalisation idpart
    indice_duptab_660004663 = DUP_TAB_ECHECNORM_660004663
  SINON
    indice_duptab_660004663 = DUP_TAB_NORMROAMERS_660004663
  FINSI

  SI (calledNumber_present_660004663 > 0 )
  ALORS
    SI ( (TON_660004663 == 2) && ((NPI_660004663 == 0)||(NPI_660004663 == 1)) )
    ALORS
      dig3_660004663 = i_get_art_fieldtab(g_iartin, $Torig_nss9::calledNumber, 2)
      SI (dig3_660004663!=0)
      ALORS
# On invalide la suppression des caracteres speciaux
        flag_rm_escape_char_660004663=0
      FINSI
    FINSI
  FINSI
FINSI
#####################################################################
# Pour le service Transgroupe (OICK=4), retrait du prefixe 0 (TON=2)
#####################################################################

digit1_660004663 = i_get_art_fieldtab(g_iartin, $Torig_nss9::oIcK, 0)
digit2_660004663 = i_get_art_fieldtab(g_iartin, $Torig_nss9::oIcK, 1)
digit3_660004663 = i_get_art_fieldtab(g_iartin, $Torig_nss9::oIcK, 2)
digit4_660004663 = i_get_art_fieldtab(g_iartin, $Torig_nss9::oIcK, 3)

SI ( ( digit1_660004663 == 0 ) &&
  ( digit2_660004663 == 0 ) &&
  ( digit3_660004663 == 4 ) &&
  ( digit4_660004663 == 0x0f ) )
ALORS
  dig3_660004663 = i_get_art_fieldtab(g_iartin, $Torig_nss9::calledNumber, 2)
  SI ( ( TON_660004663 == 2 ) && ( dig3_660004663 == 0 ) )
  ALORS
    erreur_660004663 = i_set_art_fieldtab(g_iartin, $Torig_nss9::calledNumber, 2, 0x0f)
    erreur_660004663 = i_skip_f_in_field_n(g_iartin, $Torig_nss9::calledNumber)

  SINON
#####################################################################
# MB  Ajout du prefixe 8588 pour les numeros courts on-net
#          L'article change de nom pour pouvoir utiliser un autre
#          automate
#        Pas de prefixe 0 d'echappement
# MB EV624 L'article ne change plus de nom, mais de table de duplication
#####################################################################
    SI ( (TON_660004663 == 2) && ((NPI_660004663 == 0)||(NPI_660004663 == 1)) )
    ALORS
      indice_duptab_660004663 = DUP_TAB_NORMTGROUPE_660004663
    FINSI

  FINSI
FINSI

# Suppression des caracteres speciaux
SI ((calledNumber_present_660004663 > 0) && (flag_rm_escape_char_660004663==1))
ALORS
# cette fonction n'est pas suppoter par platine, va etre remplacer par une autre fonction platine
  #erreur = i_rm_escape_char_end(g_iartin, $Torig_nss9::calledNumber)
  erreur_660004663 =  rm_escape_char_end_660004265(g_iartin, $Torig_nss9::calledNumber)
FINSI

trace1("Torig_nss9 : Indice de la table de duplication: %d", indice_duptab_660004663)

#####################################################################
# Creation DPV
# Duplication en DPV TLV
#####################################################################
ic_660004663 = i_dup_art_tab_choix(g_iartin,g_iartout,"Tdpvgsm", indice_duptab_660004663)


#G5R1
# Ajout de T3t8/msgITX si (bT3T8ITX == 1) et indice_duplication == {0, 1, 3, 5}
SI (bT3T8ITX_660004663 == 1) &&
	((indice_duptab_660004663 == 0)
	|| (indice_duptab_660004663 == 1)
	|| (indice_duptab_660004663 == 3)
	|| (indice_duptab_660004663 == 5))
	ALORS
	SI (i_valid_field_n(g_iartin,$Torig_nss9::numberOfMrPulse))
		ALORS
		erreur_660004663 = i_ajout_tlv(g_iartout,"T3t8","")
		erreur_660004663 = i_set_art_field(g_iartout, $Tdpvgsm::msgITX, i_get_art_field(g_iartin, $Torig_nss9::numberOfMrPulse))
		trace ("Ajout du champ msgITX")
	FINSI
FINSI

POINT APRES_DUPLICATION

SI (ic_660004663 != 0)
ALORS
  ERREUR_660004663 = ERR_DUPL_660004663
  code_rejet_660004663 = MODULE_660004663 + ERREUR_660004663 + EFFICACE_660004663
  erreur_660004663 = i_PlvMessEmettre(8307,2,g_iartout12,"",1,code_rejet_660004663,0,0)
  SAUT STOCKE_ERRONE
FINSI

#G1R8 etait plus bas
#####################################################################
# appel urgent:
# - si champ "tlserv" du CRA = 0x12 => appel urgent
#####################################################################
gsmTlSrv_660004663 = i_get_art_field(g_iartin,$Torig_nss9::teleServiceCode)
SI (gsmTlSrv_660004663 == 0x12)
ALORS
  app_urg_660004663 = 1
SINON
  app_urg_660004663 = 0
FINSI

SI (indice_duptab_660004663 == DUP_TAB_NORMTGROUPE_660004663)
ALORS
# DEBUT 15/04/2009 - DRE - G2R2 - Retour arriere urgence 112 spec: CRA_Tcomp_nss9_A25.0.doc
# #debut G1R8 SDETR plus de troncature et normalisation quand app_urg vrai
  dig3_660004663 = i_get_art_fieldtab(g_iartin, $Torig_nss9::calledNumber, 2)
  SI ((dig3_660004663 < 1) || (dig3_660004663 > 9))
  ALORS
    trace("Torig_nss9 : Normalisation TRANSGROUPE NOK")
    ERREUR_660004663 = ERR_DUPL_660004663
    code_rejet_660004663 = MODULE_660004663 + ERREUR_660004663 + EFFICACE_660004663
    erreur_660004663 = i_PlvMessEmettre(8307,2,g_iartout12,"",1,code_rejet_660004663,0,0)
    SAUT STOCKE_ERRONE
  FINSI
  taille_idpart_660004663 = i_get_art_field(g_iartin, $Torig_nss9::calledNumber-1)
  erreur_660004663 = i_ajout_tlv(g_iartout, "T3t2", "")
  erreur_660004663 = i_resize_tlv(g_iartout,"T3t2", "idpart", (taille_idpart_660004663+2)*8)
  erreur_660004663 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::idpart, 0, 0x3)
  erreur_660004663 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::idpart, 1, 0x3)
  erreur_660004663 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::idpart, 2, 0x8)
  erreur_660004663 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::idpart, 3, 0x5)
  erreur_660004663 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::idpart, 4, 0x8)
  erreur_660004663 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::idpart, 5, 0x8)
  indice_idpart_660004663 = 6
  indice_called_660004663 = 2

  POINT BOUCLE_IDPART
  Digit_660004663 = i_get_art_fieldtab(g_iartin, $Torig_nss9::calledNumber, indice_called_660004663)
  erreur_660004663 = i_set_art_fieldtab(g_iartout, $Tdpvgsm::idpart, indice_idpart_660004663, Digit_660004663)

  indice_idpart_660004663 = indice_idpart_660004663 + 1
  indice_called_660004663 = indice_called_660004663 + 1

  SI (indice_called_660004663 < taille_idpart_660004663*2)
  ALORS
    SAUT BOUCLE_IDPART
  FINSI
# FINSI
FINSI

# le 2val de la table de duplication ne marche pas, en attendant que ca marche
date_660004663 = i_get_art_field(g_iartin,$Torig_nss9::DATE)
heure_660004663 = i_get_art_field(g_iartin,$Torig_nss9::Heure)
res_660004663 = date_660004663 + heure_660004663
erreur_660004663 = i_set_art_field(g_iartout, $Tdpvgsm::DATE, res_660004663)
timeForTccall_660004663 = i_get_art_field(g_iartin,$Torig_nss9::timeForTCCall)
res_660004663 = date_660004663 + timeForTccall_660004663
erreur_660004663 = i_set_art_field(g_iartout, $Tdpvgsm::estalloc, res_660004663)

#####################################################################
#  : OLA 25/11/04
# Si la normalisation echoue et si IMSI roamer, recopie du
# CalledPartyNumber ds le champ V3t2 sans le TON+NPI
#####################################################################
SI (indice_duptab_660004663 == DUP_TAB_ECHECNORM_660004663)
ALORS
# Cas Echec normalisation : copie sans TON+NPI
  calledNumber_present_660004663 = i_valid_field_n(g_iartin,$Torig_nss9::calledNumber)
  SI (calledNumber_present_660004663)
  ALORS
    taille_idpart_660004663 = i_get_art_field(g_iartin, $Torig_nss9::calledNumber-1)
    erreur_660004663 = i_ajout_tlv(g_iartout, "T3t2", "")
    erreur_660004663 = i_resize_tlv(g_iartout,"T3t2", "idpart", taille_idpart_660004663*8)
    trace("Torig_nss9 :Echec normalisation : copie sans TON+NPI")
    erreur_660004663 = i_dup_chp_rnisGSM(g_iartin, g_iartout, $Torig_nss9::calledNumber, $Tdpvgsm::idpart, -$NORM:CIT_IDENT, 0)
  FINSI
FINSI

trace("Torig_nss9 :Fin traitement idpart 2242")

##################################################################
# QC396, QC1292
# T3t1.3 idemet
##################################################################
# QC1444
i_strcpy(str_exchasciident_660004663,"")
i_strcpy(str_exchDCBdent_660004663,"")
erreur_660004663 = i_get_art_str(g_iartin,$Torig_nss9::exchasciident,str_exchasciident_660004663)
trace2("################# str_exchasciident = %s ################",str_exchasciident_660004663,"")
position_660004663 = RECHERCHE_CARACTERE_660004265(str_exchasciident_660004663," ")
trace1("############ position= %d ###########",position_660004663)
SI ( position_660004663 > -1)
ALORS
  i_get_sub_str (str_exchasciident_660004663, 0, position_660004663 - 1 ,str_exchasciident_660004663)
  trace2("################# str_exchasciident = %s ################",str_exchasciident_660004663,"")
FINSI
longueur_660004663 = i_conv_ascii_dcb (str_exchasciident_660004663,str_exchDCBdent_660004663 )
SI (longueur_660004663 > 9)
ALORS
	longueur_660004663 = 9
FINSI
erreur_660004663 = i_memcpy_art_field_n(g_iartout, $Tdpvgsm::idemet, str_exchDCBdent_660004663, longueur_660004663)

#Fin QC396

###################################################################
# MAJ du V3t1.9
###################################################################
SI (i_valid_field_n(g_iartin,$Torig_nss9::1stRdioChnlUsed) == 0)
ALORS
  erreur_660004663 = i_set_art_field(g_iartout, $Tdpvgsm::support1, 0x00)
FINSI

##################################################################
#MAJ du V3t1.14  QC1232
##################################################################
SI (i_valid_field_n(g_iartin,$Torig_nss9::disconnectParty))
ALORS
  res_660004663 = i_get_art_field(g_iartin,$Torig_nss9::disconnectParty)
  SI (res_660004663 == 0 || res_660004663 == 1)
  ALORS
    erreur_660004663 = i_set_art_field(g_iartout, $Tdpvgsm::tterm, 0x00)
  SINON
    SI (res_660004663 == 2)
    ALORS
      erreur_660004663 = i_set_art_field(g_iartout, $Tdpvgsm::tterm, 0x01)
    FINSI
  FINSI
FINSI

#####################################################################
# Traitement du champ portOrigNet (T3t6)
#
#####################################################################
trace("Torig_nss9 :Debut de traitement du champ portOrigNet")

# --- On verifie que le champ origLocNumber est present
origLocNum_present_660004663 = i_valid_field_n(g_iartin, $Torig_nss9::origLocNum)
SI (origLocNum_present_660004663)
ALORS
  SI (i_get_art_field(g_iartin, $Torig_nss9::origLocNum-1) == 0)
  ALORS
    origLocNum_present_660004663 = 0
  FINSI
FINSI

# --- Si le champ est absent le T3t6 du DPV sera absent
SI (origLocNum_present_660004663)
ALORS
#        SI (i_get_field_osize(g_iartin, $Torig_nss9::origLocNum) >= 2)
  SI (i_get_art_field(g_iartin, $Torig_nss9::origLocNum-1) >= 2)
  ALORS
    TON_origLocNum_660004663 = i_get_art_fieldtab(g_iartin, $Torig_nss9::origLocNum, 0)
    NPI_origLocNum_660004663 = i_get_art_fieldtab(g_iartin, $Torig_nss9::origLocNum, 1)

# --- portOrigNet sera absent du DPV si en entree le champ
# --- origLocNumber a un TON NPI different de 41 (E///) ou A1 (alcatel)
    SI ( (TON_origLocNum_660004663 == 4) && (NPI_origLocNum_660004663 == 1) )
    ALORS
# --- On normalise le champ origLocNumber vers le champ V3t6 du DPV (portOrigNet)
      erreur_660004663 = i_ajout_tlv(g_iartout,"T3t6","")
      erreur_660004663 = i_dup_chp_rnisGSM(g_iartin, g_iartout, $Torig_nss9::origLocNum,$Tdpvgsm::portOrigNet, -$NORM:CIT_IDENT, 0)
      SI ( erreur_660004663 != 0 )
      ALORS
        trace("Torig_nss9 :Erreur duplication champ portOrigNet")
#                   type_erreur = CODE_ERREUR_DUPLICATION
        ERREUR_660004663 = ERR_NORM_660004663
        code_rejet_660004663 = MODULE_660004663 + ERREUR_660004663 + EFFICACE_660004663
        erreur_660004663 = i_PlvMessEmettre(8308,2,g_iartout12,"",2, code_rejet_660004663,"portOrigNet",0)
        SAUT STOCKE_ERRONE
      FINSI
    FINSI
  FINSI
FINSI
trace("Torig_nss9 :Fin de traitement du champ portOrigNet")

# traduction en un entier 16 bit du champ OICK
# et creation du champ dans l'article en sortie

erreur_660004663 = i_get_art_field(g_iartin, $Torig_nss9::oIcK -1)

SI ( erreur_660004663 > 0)
ALORS
  val_OICK_660004663 = digit1_660004663*100 + digit2_660004663*10 + digit3_660004663
#  Creation du T4t11.1
  erreur_660004663 = i_ajout_tlv(g_iartout, "T4t11.1", "")
  erreur_660004663 = i_resize_tlv(g_iartout,"T4t11.1","nbsvcIN",1)
#  Creation du T4t11.2
#  la taille 2 correspond a 2 octet (taille d'une clef)
  erreur_660004663 = i_ajout_tlv(g_iartout, "T4t11.2", "")
  erreur_660004663 = i_resize_tlv(g_iartout,"T4t11.2","lstSVCIN",2)
  erreur_660004663 = i_set_art_field(g_iartout, $Tdpvgsm::nbsvcIN, 1)
#  DPV TLV : mise a jour lstSVCIN
#  ecriture de l'octet de poids fort
  erreur_660004663 = i_set_art_fieldtab(g_iartout, $Tdpvgsm::lstSVCIN, 0, (val_OICK_660004663 / 256))
#  ecriture de l'octet de poids faible
  erreur_660004663 = i_set_art_fieldtab(g_iartout, $Tdpvgsm::lstSVCIN, 1, (val_OICK_660004663 & 0xFF))
FINSI

#####################################################################
# Mise a jour 'date d'entree dans le CE' + 'EEC'
# g_ibloc_date mis a jour dans Pcode Txxha ou trait_pla_file_bloc()
#####################################################################
# QC1331
#erreur=set_timeInCE_EEC(0)
########### Date_Audit
erreur_660004663 = i_set_art_field(g_iartout, $Tdpvgsm::timeInCE,  i_DHgetLocalTime(4, 7, i_date_audit()))
########### eec
# QC1405
SI (g_ieec > 500)
ALORS
  erreur_660004663 = i_set_art_field(g_iartout, $Tdpvgsm::eec, g_ieec - 500)
SINON
  erreur_660004663 = i_set_art_field(g_iartout, $Tdpvgsm::eec, g_ieec)
FINSI
#/QC1405

#####################################################################
# Traitement du system type
#
#####################################################################
SI (i_valid_field_n(g_iartin,$Torig_nss9::rNCidOf1stRNC))
ALORS
  erreur_660004663 = i_set_art_field(g_iartout,$Tdpvgsm::systype,0x01)
FINSI

#G1R8 deplace plus haut #####################################################################

#####################################################################
# Prise en compte du champ "service support":
# Si teleservice == 0xff et service support renseigne
# -> on renseigne teleservice pour la valorisation et le CTDC
#####################################################################
tlserv_mod_660004663 = 0
gsmTlSrv_660004663 = i_get_art_field(g_iartin,$Torig_nss9::teleServiceCode)

SI ((gsmTlSrv_660004663 & 0xff) == 0xff)
ALORS
  tlserv_mod_660004663 = 1
  svcsup_660004663 = i_get_art_field(g_iartout,$Tdpvgsm::svcsup)
  Q1_660004663 = svcsup_660004663 & 0xf0
  Q2_660004663 = svcsup_660004663 & 0x0f

  SI ((Q1_660004663 != 0x10) && (Q1_660004663 != 0x90))
  ALORS
    SAUT ERR_SVCSUP
  FINSI
  SI (Q2_660004663 && (Q2_660004663 < 0x07))
  ALORS
    vsvcsup_660004663 = 0x16
    SAUT OK_SVCSUP
  FINSI
  SI ((Q2_660004663 > 0x09) && (Q2_660004663 < 0x0f) && (Q2_660004663 != 0x0b))
  ALORS
    vsvcsup_660004663 = 0x1e
    SAUT OK_SVCSUP
  FINSI
  SI (Q2_660004663 == 0x07)
  ALORS
    vsvcsup_660004663 = 0x17
    SAUT OK_SVCSUP
  FINSI
  SI (Q2_660004663 == 0x0F)
  ALORS
    vsvcsup_660004663 = 0x1f
    SAUT OK_SVCSUP
  FINSI

  POINT   ERR_SVCSUP
  i_message1("Erreur champ service support -> 0x%x", svcsup_660004663)
  SAUT FIN_SVCSUP

  POINT   OK_SVCSUP
  erreur_660004663 = i_set_art_field(g_iartout,$Tdpvgsm::svcsup,vsvcsup_660004663)
  erreur_660004663 = i_set_art_field(g_iartout,$Tdpvgsm::tlserv,vsvcsup_660004663)
FINSI

POINT   FIN_SVCSUP

#####################################################################
# Traitement du champs transporteurs sortant
#
#####################################################################
#
# ---- Duplication du champ transporteur Sortant
#
tailleChpTrans_660004663=i_get_art_field(g_iartin,($Torig_nss9::outgoingRoute-1))

SI    ((tailleChpTrans_660004663 <= 7 )
  && (i_valid_field_n(g_iartin,$Torig_nss9::outgoingRoute)))
ALORS
  erreur_660004663 = i_ajout_tlv(g_iartout, "T3t16", "")
  erreur_660004663 = i_resize_tlv(g_iartout,"T3t16","TrSortant",tailleChpTrans_660004663)
  erreur_660004663 = i_memcpy_art_field_n(g_iartout, $Tdpvgsm::TrSortant, g_iartin.outgoingRoute[], tailleChpTrans_660004663)
FINSI
#
# Si appel d'urgence (partenaire non renseigne) on force a 0 le nombre
# d'UM et d'UT
#
SI app_urg_660004663
ALORS
  nbut_660004663 = 0
  erreur_660004663 = i_set_art_field(g_iartout,$Tdpvgsm::nbUT,nbut_660004663)

###################################################################
# Ajout du champ T4t35.4 presenceInd
###################################################################
  SI ( ( i_get_art_field(g_iartin,$Torig_nss9::sSCode1 ) == 0x51 )
    || ( i_get_art_field(g_iartin,$Torig_nss9::sSCode2 ) == 0x51 )
    || ( i_get_art_field(g_iartin,$Torig_nss9::sSCode3 ) == 0x51 )
    || ( i_get_art_field(g_iartin,$Torig_nss9::sSCode4 ) == 0x51 )
    || ( i_get_art_field(g_iartin,$Torig_nss9::sSCode5 ) == 0x51 )
    || ( i_get_art_field(g_iartin,$Torig_nss9::sSCode6 ) == 0x51 )
    || ( i_get_art_field(g_iartin,$Torig_nss9::sSCode7 ) == 0x51 )
    || ( i_get_art_field(g_iartin,$Torig_nss9::sSCode8 ) == 0x51 )
    || ( i_get_art_field(g_iartin,$Torig_nss9::sSCode9 ) == 0x51 )
    || ( i_get_art_field(g_iartin,$Torig_nss9::sSCode10) == 0x51 ) )
  ALORS
    erreur_660004663 = i_ajout_tlv(g_iartout,"T4t35.4","")
    erreur_660004663 = i_resize_tlv(g_iartout,"T4t35.4","presenceInd",1)
    erreur_660004663 = i_set_art_field(g_iartout,$Tdpvgsm::presenceInd,0x01)
  FINSI

###################################################################
# Ajout du champ T3t37 CSDaddInfo
###################################################################
  SI ( (i_get_art_field(g_iartout, $Tdpvgsm::svcsup) == 0x17 )
    ||(i_get_art_field(g_iartout, $Tdpvgsm::svcsup) == 0x1F) )
  ALORS
    userRate_660004663     = 0x08
    userProtocol_660004663 = 0x04
  SINON
    userRate_660004663     = 0xFF
    userProtocol_660004663 = 0xFF
  FINSI

  transIndicator_present_660004663 = i_valid_field_n(g_iartin,$Torig_nss9::transIndicator)

  SI ( transIndicator_present_660004663 )
  ALORS
    tranInd_660004663 = i_get_art_field(g_iartin,$Torig_nss9::transIndicator)
# correction FO 426 : transInd si pr?sent
  SINON
    SI ( (i_get_art_field(g_iartout, $Tdpvgsm::svcsup) == 0x17)
      || (i_get_art_field(g_iartout, $Tdpvgsm::svcsup) == 0x1F) )
    ALORS
      tranInd_660004663 = 0x00
    SINON
      tranInd_660004663 = 0xFF
    FINSI
  FINSI

  SI ( (userRate_660004663 != 0xFF) || (userProtocol_660004663 != 0xFF) || (tranInd_660004663 != 0xFF) )
  ALORS
    erreur_660004663 = i_ajout_tlv(g_iartout,"T3t37","")
    erreur_660004663 = i_resize_tlv(g_iartout,"T3t37","CSDaddInfo",3)
    CSDaddValue_660004663 = userRate_660004663*0x10000 + userProtocol_660004663*0x100 + tranInd_660004663
    erreur_660004663 = i_set_art_field(g_iartout,$Tdpvgsm::CSDaddInfo,CSDaddValue_660004663)
  FINSI

###################################################################
# Ajout du champ T4t38.1 origCallpartId
###################################################################
  calltype_660004663 = i_get_art_field(g_iartout, $Tdpvgsm::type)
  SI ((calltype_660004663 == 0x00) || (calltype_660004663 == 0x02) )
  ALORS
    calledNumber_present_660004663 = i_valid_field_n(g_iartin,$Torig_nss9::calledNumber)
    SI (calledNumber_present_660004663)
    ALORS
      erreur_660004663 = i_cree_art("TnormalHAscii", g_iartout4)
      erreur_660004663 = i_ajout_tlv(g_iartout4, "T3t1", "buf")
      erreur_660004663 = i_dup_chp_rnisGSM(g_iartin, g_iartout4, $Torig_nss9::calledNumber, $TnormalHAscii::buf, -$NORM:IDENT2,0)

      res_660004663 = i_get_art_field(g_iartout4, $TnormalHAscii::buf -1)
      erreur_660004663 = i_ajout_tlv(g_iartout,"T4t38.1","")
      erreur_660004663 = i_memcpy_art_field_n(g_iartout, $Tdpvgsm::origCallpartId, g_iartout4.buf[], res_660004663)
      erreur_660004663 = i_resize_tlv(g_iartout,"T4t38.1","origCallpartId", res_660004663)
# FIN 15/04/2009 - DRE - G2R2 - Retour arriere urgence 112 spec: CRA_Tcomp_nss9_A25.0.doc
    FINSI
  FINSI
  
###################################################################
# Ajout du champ T4t38.2 dialledDigits
###################################################################
  SI (calltype_660004663 == 0x00)
  ALORS
    calledNumber_present_660004663 = i_valid_field_n(g_iartin,$Torig_nss9::calledNumber)
    SI (calledNumber_present_660004663)
    ALORS
      lg_calledNumber_660004663 = i_get_art_field(g_iartin,$Torig_nss9::calledNumber - 1)
      SI (lg_calledNumber_660004663 > 1)
      ALORS
        erreur_660004663 = i_cree_art("TnormalHAscii", g_iartout6)
        erreur_660004663 = i_ajout_tlv(g_iartout6, "T3t1", "buf")
        erreur_660004663 = i_dup_chp_rnisGSM(g_iartout12, g_iartout6, $Torig_nss9::calledNumber, $TnormalHAscii::buf, -$NORM:CIT_IDENT,0)

        res_660004663 = i_get_art_field(g_iartout6, $TnormalHAscii::buf -1)
        erreur_660004663 = i_ajout_tlv(g_iartout,"T4t38.2","")
        erreur_660004663 = i_memcpy_art_field_n(g_iartout, $Tdpvgsm::dialledDigits, g_iartout6.buf[], res_660004663)
        erreur_660004663 = i_resize_tlv(g_iartout,"T4t38.2","dialledDigits", res_660004663)
      FINSI
# 15/04/2009 - DRE - G2R2 - Retour arriere urgence 112 spec: CRA_Tcomp_nss9_A25.0.doc
    FINSI
  FINSI

###################################################################
# Ajout du champ V4t38.3 equipmentType
###################################################################
  erreur_660004663 = i_ajout_tlv(g_iartout,"T4t38.3","")
  erreur_660004663 = i_resize_tlv(g_iartout,"T4t38.3","equipmentType",1)
  erreur_660004663 = i_set_art_field(g_iartout,$Tdpvgsm::equipmentType,0x00)

  # Ajout des T3t55 et T3t56
  SI !(i_valid_field_n(g_iartout, $Tdpvgsm::GFlag2))
  ALORS
    erreur_660004663 = i_ajout_tlv(g_iartout,"T3t55","")
  FINSI

  SI !(i_valid_field_n(g_iartout, $Tdpvgsm::GValue))
  ALORS
    erreur_660004663 = i_ajout_tlv(g_iartout,"T3t56","")
  FINSI

  SI !(i_valid_field_n(g_iartout, $Tdpvgsm::GretaTag))
  ALORS
    erreur_660004663 = i_ajout_tlv(g_iartout,"T3t99","")
  FINSI

  erreur_660004663 = aiguillage2_660004590(g_iartout12, g_iartout, DISTRIBUTION_SPECIALE_660004663, Multidistribution_Non_660004663)
  SI (erreur_660004663 == TRAI_KO_660004663)
  ALORS
#   QC1005
    trace("<<<__LINE__<<<__FILE__<<< Erreur retour fonction aiguillage2")
    SAUT STOCKE_ERRONE
  FINSI

  trace("Torig_nss9 : Fin du pcode de Distribution")
  RETOUR TRAIT_OK

SINON
#####################################################################
# calcul prevalorisation et affectation des valeurs nbut au DPV
#####################################################################
# FO8134 : Maj de la valeur du champ indtax a 0x01 avant le calcul
# de prevalorisation
#
  erreur_660004663 = i_set_art_field(g_iartout, $Tdpvgsm::indtax, 0x01)

#############
# appel preval Torig
#############
  res_660004663 = preval_ut_660004265(g_iartout)

  SI (res_660004663 == -1 )
  ALORS
    ERREUR_660004663 = ERR_VALO_660004663
    code_rejet_660004663 = MODULE_660004663 + ERREUR_660004663 + EFFICACE_660004663
#QC843
    erreur_660004663 = i_PlvMessEmettre(8310,2,g_iartout12, "" , 1, code_rejet_660004663, 0, 0 )
    trace("Fin traitement: erreur prevalorisation")
    SAUT STOCKE_ERRONE
  SINON
    SI (res_660004663 == -2 )
    ALORS
      trace("pas de prevalorisation : retour preval == -2")
    SINON
      trace1("Prevalorisation OK avec valeur : %d", res_660004663)
      erreur_660004663 = i_set_art_field(g_iartout,$Tdpvgsm::nbUT, res_660004663)
    FINSI
  FINSI
#############
# /appel preval
#############
# FO8134 : Maj de la valeur du champ indtax a 0xff apres le calcul
# de prevalorisation
#
  erreur_660004663 = i_set_art_field(g_iartout, $Tdpvgsm::indtax, 0xff)
FINSI

#
# Remise a 0xff de tlserv dans le DPV
#
SI (tlserv_mod_660004663 == 1)
ALORS
  erreur_660004663 = i_set_art_field(g_iartout, $Tdpvgsm::tlserv, 0xff)
FINSI

###################################################################
# Ajout du champ T4t35.4 presenceInd
###################################################################
SI ( ( i_get_art_field(g_iartin,$Torig_nss9::sSCode1 ) == 0x51 )
  || ( i_get_art_field(g_iartin,$Torig_nss9::sSCode2 ) == 0x51 )
  || ( i_get_art_field(g_iartin,$Torig_nss9::sSCode3 ) == 0x51 )
  || ( i_get_art_field(g_iartin,$Torig_nss9::sSCode4 ) == 0x51 )
  || ( i_get_art_field(g_iartin,$Torig_nss9::sSCode5 ) == 0x51 )
  || ( i_get_art_field(g_iartin,$Torig_nss9::sSCode6 ) == 0x51 )
  || ( i_get_art_field(g_iartin,$Torig_nss9::sSCode7 ) == 0x51 )
  || ( i_get_art_field(g_iartin,$Torig_nss9::sSCode8 ) == 0x51 )
  || ( i_get_art_field(g_iartin,$Torig_nss9::sSCode9 ) == 0x51 )
  || ( i_get_art_field(g_iartin,$Torig_nss9::sSCode10) == 0x51 ) )
ALORS
  erreur_660004663 = i_ajout_tlv(g_iartout,"T4t35.4","")
  erreur_660004663 = i_resize_tlv(g_iartout,"T4t35.4","presenceInd",1)
  erreur_660004663 = i_set_art_field(g_iartout,$Tdpvgsm::presenceInd,0x01)
FINSI

###################################################################
# Ajout du champ T3t37 CSDaddInfo
###################################################################
SI ( (i_get_art_field(g_iartout, $Tdpvgsm::svcsup) == 0x17 )
  ||(i_get_art_field(g_iartout, $Tdpvgsm::svcsup) == 0x1F) )
ALORS
  userRate_660004663     = 0x08
  userProtocol_660004663 = 0x04
SINON
  userRate_660004663     = 0xFF
  userProtocol_660004663 = 0xFF
FINSI

transIndicator_present_660004663 = i_valid_field_n(g_iartin,$Torig_nss9::transIndicator)

SI ( transIndicator_present_660004663 )
ALORS
  tranInd_660004663 = i_get_art_field(g_iartin,$Torig_nss9::transIndicator)
  SI (tranInd_660004663 == 0)
  ALORS
    tranInd_660004663 = 0x00
  SINON
    tranInd_660004663 = 0x01
  FINSI
SINON
  SI ( (i_get_art_field(g_iartout, $Tdpvgsm::svcsup) == 0x17)
    || (i_get_art_field(g_iartout, $Tdpvgsm::svcsup) == 0x1F) )
  ALORS
    tranInd_660004663 = 0x00
  SINON
    tranInd_660004663 = 0xFF
  FINSI
FINSI

SI ( (userRate_660004663 != 0xFF) || (userProtocol_660004663 != 0xFF) || (tranInd_660004663 != 0xFF) )
ALORS
  erreur_660004663 = i_ajout_tlv(g_iartout,"T3t37","")
  erreur_660004663 = i_resize_tlv(g_iartout,"T3t37","CSDaddInfo",3)
  CSDaddValue_660004663 = userRate_660004663*0x10000 + userProtocol_660004663*0x100 + tranInd_660004663
  erreur_660004663 = i_set_art_field(g_iartout,$Tdpvgsm::CSDaddInfo,CSDaddValue_660004663)
FINSI

###################################################################
# Ajout du champ T4t38.1 origCallpartId
###################################################################
calltype_660004663 = i_get_art_field(g_iartout, $Tdpvgsm::type)
SI ((calltype_660004663 == 0x00) || (calltype_660004663 == 0x02) )
ALORS
  calledNumber_present_660004663 = i_valid_field_n(g_iartin,$Torig_nss9::calledNumber)
  SI (calledNumber_present_660004663)
  ALORS
    erreur_660004663 = i_cree_art("TnormalHAscii", g_iartout4)
    erreur_660004663 = i_ajout_tlv(g_iartout4, "T3t1", "buf")
    erreur_660004663 = i_dup_chp_rnisGSM(g_iartin, g_iartout4, $Torig_nss9::calledNumber, $TnormalHAscii::buf, -$NORM:IDENT2,0)
    res_660004663 = i_get_art_field(g_iartout4, $TnormalHAscii::buf -1)
    erreur_660004663 = i_ajout_tlv(g_iartout,"T4t38.1","")
    erreur_660004663 = i_memcpy_art_field_n(g_iartout, $Tdpvgsm::origCallpartId, g_iartout4.buf[], res_660004663)
    erreur_660004663 = i_resize_tlv(g_iartout,"T4t38.1","origCallpartId", res_660004663)
    #info G1R8 app_urg est deja traite en amont
  FINSI
FINSI

###################################################################
# Ajout du champ T4t38.2 dialledDigits
###################################################################
SI (calltype_660004663 == 0x00)
ALORS
  calledNumber_present_660004663 = i_valid_field_n(g_iartin,$Torig_nss9::calledNumber)
  SI (calledNumber_present_660004663)
  ALORS
    lg_calledNumber_660004663 = i_get_art_field(g_iartin,$Torig_nss9::calledNumber - 1)
    SI (lg_calledNumber_660004663 > 1)
    ALORS
      erreur_660004663 = i_cree_art("TnormalHAscii", g_iartout6)
      erreur_660004663 = i_ajout_tlv(g_iartout6, "T3t1", "buf")
      erreur_660004663 = i_dup_chp_rnisGSM(g_iartout12, g_iartout6, $Torig_nss9::calledNumber, $TnormalHAscii::buf, -$NORM:CIT_IDENT,0)
      res_660004663 = i_get_art_field(g_iartout6, $TnormalHAscii::buf -1)
      erreur_660004663 = i_ajout_tlv(g_iartout,"T4t38.2","")
      erreur_660004663 = i_memcpy_art_field_n(g_iartout, $Tdpvgsm::dialledDigits, g_iartout6.buf[], res_660004663)
      erreur_660004663 = i_resize_tlv(g_iartout,"T4t38.2","dialledDigits", res_660004663)
    FINSI
    #info G1R8 app_urg est deja traite en amont
  FINSI
FINSI

###################################################################
# Ajout du champ V4t38.3 equipmentType
###################################################################
erreur_660004663 = i_ajout_tlv(g_iartout,"T4t38.3","")
erreur_660004663 = i_resize_tlv(g_iartout,"T4t38.3","equipmentType",1)
erreur_660004663 = i_set_art_field(g_iartout,$Tdpvgsm::equipmentType,0x00)

# Ajout des T3t55 et T3t56
SI !(i_valid_field_n(g_iartout, $Tdpvgsm::GFlag2))
ALORS
  erreur_660004663 = i_ajout_tlv(g_iartout,"T3t55","")
FINSI

SI !(i_valid_field_n(g_iartout, $Tdpvgsm::GValue))
ALORS
  erreur_660004663 = i_ajout_tlv(g_iartout,"T3t56","")
FINSI

SI !(i_valid_field_n(g_iartout, $Tdpvgsm::GretaTag))
ALORS
  erreur_660004663 = i_ajout_tlv(g_iartout,"T3t99","")
FINSI

erreur_660004663 = aiguillage2_660004590(g_iartout12, g_iartout, DISTRIBUTION_INCONNU_660004663, Multidistribution_Non_660004663)
SI (erreur_660004663 == TRAI_KO_660004663)
ALORS
# QC1005
  trace("<<<__LINE__<<<__FILE__<<< Erreur retour fonction aiguillage2")
  SAUT STOCKE_ERRONE
FINSI

trace("Torig_nss9 : Fin du pcode de Distribution")
RETOUR TRAIT_OK

POINT STOCKE_ERRONE
erreur_660004663 = i_make_art_rej(g_iartout12, g_iartout11, code_rejet_660004663)
erreur_660004663 = i_stocke_art(g_iartout11, 0, PT_ERRONE, 0)
trace("Torig_nss9 : erreur de duplication => Fin du pcode de distribution")
trace("Torig_nss9 : Stockage en ERRONE")
RETOUR TRAIT_OK

#####################################################################
# traitements specifiques aux appels urgents sans carte SIM
#####################################################################
POINT TRAIT_APPEL_APPEL_URGENT_NO_SIM
# tests equivalents a test_art (sauf IMSI et calling number)
#
# Test syntaxique champ "localisation" (cellId1st)
#
# Ce test est fait au niveau traitement
#
# Test syntaxique champ "nbPulse" si present
#
# Ce test est fait au niveau traitement

#####################################################################
# Fin controle syntaxique de l'article
#####################################################################

digit1_660004663 = i_get_art_fieldtab(g_iartin, $Torig_nss9::oIcK, 0)
digit2_660004663 = i_get_art_fieldtab(g_iartin, $Torig_nss9::oIcK, 1)
digit3_660004663 = i_get_art_fieldtab(g_iartin, $Torig_nss9::oIcK, 2)
digit4_660004663 = i_get_art_fieldtab(g_iartin, $Torig_nss9::oIcK, 3)

app_urg_660004663=1

ic_660004663 = i_dup_art_tab_choix(g_iartin,g_iartout,"Tdpvgsm",  DUP_TAB_URGENT_NOSIM_660004663)
indice_duptab_660004663 =  DUP_TAB_URGENT_NOSIM_660004663
#G5R1
# Ajout de T3t8/msgITX si (bT3T8ITX == 1) et indice_duptab == 4 (DUP_TAB_URGENT_NOSIM)
SI (bT3T8ITX_660004663 == 1)
	ALORS
	SI (i_valid_field_n(g_iartin,$Torig_nss9::numberOfMrPulse))
		ALORS
		erreur_660004663 = i_ajout_tlv(g_iartout,"T3t8","")
		erreur_660004663 = i_set_art_field(g_iartout, $Tdpvgsm::msgITX, i_get_art_field(g_iartin, $Torig_nss9::numberOfMrPulse))
		trace ("Ajout du champ msgITX")
	FINSI
FINSI

# Mise a jour du champ IMSI en sortie (on ajoute un F en 16eme position)
erreur_660004663 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::IMSI, 15, 0xF)

SAUT APRES_DUPLICATION
#------------------------------- Fin Torig_nss9_dis.src ----------------------------------
