DEFINITION C_ZB_1133600DOT_660004661 1
DEFINITION C_ZB_XX600DOT_660004661 2
DEFINITION PREFIX_ZB_660004661 1
DEFINITION PREFIX_ITIN_660004661 2
DEFINITION PREFIX_PORTA_660004661 3
DEFINITION PREFIX_SVA_660004661 4
DEFINITION PREFIX_ITI_660004661 5
DEFINITION PREFIX_OMOF_660004661 6
DEFINITION PREFIX_JOIG_660004661 7
DEFINITION Multidistribution_Non_660004661 0
DEFINITION DISTRIBUTION_SPECIALE_660004661 0
DEFINITION TRAI_KO_660004661 -1
DEFINITION MODULE_DISTR_660004661 0xA000
DEFINITION ERR_NORM_660004661 0x010
DEFINITION ERR_DUPL_660004661 0x0D0
DEFINITION ERR_DISTR_660004661 0x110
DEFINITION RNSAC_660004661 "RoutinNumberSac"
REGISTRE ENTIER Flag_ZB_660004661
REGISTRE ENTIER erreur_660004661
REGISTRE ENTIER valTerm_660004661
REGISTRE ENTIER flag_rdt_660004661
REGISTRE ENTIER tailleChpTrans_660004661
REGISTRE ENTIER date_stocke_660004661
REGISTRE ENTIER origCalledNum_present_660004661
REGISTRE ENTIER redirectNumber_present_660004661
REGISTRE ENTIER indice_champ_valo_660004661
REGISTRE ENTIER TON_origLocNum_660004661
REGISTRE ENTIER NPI_origLocNum_660004661
REGISTRE ENTIER origLocNum_present_660004661
REGISTRE ENTIER ZBPrefixDigitD_660004661
REGISTRE ENTIER ZBPrefixDigitO_660004661
REGISTRE ENTIER ZBPrefixDigitT_660004661
REGISTRE ENTIER date_660004661
REGISTRE ENTIER date_fin_660004661
REGISTRE POINTEUR pt_valeur_660004661
REGISTRE ENTIER code_rejet_660004661
REGISTRE ENTIER EFFICACE_660004661
REGISTRE ENTIER MODULE_660004661
REGISTRE ENTIER ERREUR_660004661
REGISTRE ENTIER ZBTransSortD_660004661
REGISTRE ENTIER ZBTransSortO_660004661
REGISTRE ENTIER ZBTransSortT_660004661
REGISTRE ENTIER fgZBTransSort_660004661
REGISTRE ENTIER position_660004661
REGISTRE POINTEUR str_exchasciident_660004661
REGISTRE POINTEUR str_exchDCBdent_660004661
REGISTRE ENTIER Prefix_calledNumber_660004661
REGISTRE ENTIER flag_pref_660004661
REGISTRE ENTIER TypePrefixe_660004661
REGISTRE ENTIER longueur_660004661
REGISTRE ENTIER Prefix_index_660004661
REGISTRE POINTEUR pt_cle_660004661
REGISTRE POINTEUR pt_RetourTable_660004661
REGISTRE POINTEUR pt_champ_660004661
REGISTRE POINTEUR pt_prefixe_660004661
REGISTRE POINTEUR pt_prefixe_DCB_660004661
REGISTRE ENTIER ic_660004661
REGISTRE ENTIER indice_champ_660004661
####################################################################
#       article Ttrans_nss9
#
# AE 24/08/05 Creation
# 22/01/2008 - PSA - G1R6 - modification du traitement du prefixe Routing Number
# 08/02/2008 - PSA - G1R6 - FO 640
# 03/04 2008 - PKH - G1R6 - traitement Zone Blanche sortante Tdpvgsm::T3t57
# 28/04/2008 - PKH -G1R6 lot 4 FO672 + modification specif pour champ T3t38
# 17/11/2008 - JLG - G2R1 - lot2 Item : Prefixes OMOF pour MIPC
# 08/12/2008 - JLG - G2R1 - QC265 (si portabilite pas d'OMOF)
# 11/02/2009 - JLG - G2R1 - QC326 (OMOF : test longueur)
# 26/08/2009 - PKH - G2R3 - QC396
# 11/06/2010 - JLG - G2R6C800 : appel fonction aiguillage2, creation enveloppe E_Redistri2,
#                               ajout champ T3t55 (GFlag2) et T3t56 (GValue)
# 21/12/2010 - BEA - G3R1 lot4 Verification/Correction des variables (constantes, entiers, pointeurs)
# 14/03/2011 - JLG - G3R2C4 fusion G3R2C3 avec G3R1C600 (ajout champ T3t99)
# 25/03/2011 - PKH - G3R3 lot2 : mapping ABC ajout du T3t63 et T3t64
# 26/04/2011 - PKH - G3R3 lot3 : Curling Free
# 11/07/2011 - PKH - G3R4 lot1 Gestion prefixe de portabilite pour les SVA
# 10/08/2011 - PKH - GER4 QC910 Libelle V3t70 PrefixeSVA au lieu de PrefixeSAV
# 12/08/2011 - PKH - G3R4 QC912 suppression du prefix sva sur OrigCalledNumber avant d'alimenter idpart T3t2
# 06/09/2011 - JLG - G3R4 QC925 evol champs V3t63, V3t64 suppression des envois vers errones si echec de normalisation
# 16/09/2011 - JLG - G3R4 QC925 pb avec verbe i_retrait_tlv
# 20/02/2012 - JLG - G3R6 item 1 : Free_Prefixe_Iti_Sortant
# 29/02/2012 - JLG - G3R6 QC1005 modif alarme retour aiguillage
# 30/10/2012 - RHE - G3R8 lot2 Prefix de joignabilite
# 14/11/2012 - PKH - G3R8 lot3 Correctif Mapping ABC reiterer la normalisation du T3t63 pour les champs candidats
# 27/05/2013 - JLG - G3R10 lot2 : Modification prefixe itinerance
# 03/07/2013 - JLG - G3R10 lot3 QC1239 : Suppression de la recherche du prefixe itinerance pour redirectNumber et pour origCalledNum
# 11/12/2013 - PKH - G3R10 lot4 QC1302 correction item prefix itinerance sur 6 digits la valeur de la longeur est a 9 au lieu de 16 pour tenir compte des n? court
# 11/02/2014 - JLG - G5R1 QC1331, Built 3 : Changement Marque Audit
# 02/07/2014 - JLG - G5R1 QC1405, champ eec du DPV si g_ieec > 500
# 05/08/2014 - JLG - G5R2 lot2 : Item IntercoIP PrefixeZoneBlanche Modification du prefixe Zone Blanche
# 09/10/2014 - JLG - QC1444 correction supplementaire de la QC1292
####################################################################

#G5R2 lot2

#G3R10
#\G3R10



#/G3R3 Lot3 Curling Free

#/G3R3 Lot3 Curling Free


#G1R6 lot4
#/G1R6 lot4

# FE 54 ##
# /FE 54 ##


#QC396
# /QC396

#G3R10
# Initialisations
#G3R10
# valeurs de TypePrefixe : 1=>ZB, 2=>itin, 3=>porta, 4=>sva, 5=>iti, 6=>omof, 7=>joignabilite
TypePrefixe_660004661 = 0
flag_pref_660004661 = 0
Prefix_calledNumber_660004661 = 0
pt_champ_660004661="pt_champ_1111111111111111111111"
i_strcpy(pt_champ_660004661, "")
pt_prefixe_DCB_660004661 = "pt_prefixe_DCB_111111111111111111"
pt_prefixe_660004661= "pt_prefixe222222222222222222222"
i_strcpy(pt_prefixe_660004661, "")
longueur_660004661 = 0

# FE 54 ##
EFFICACE_660004661 = 1
fgZBTransSort_660004661 = 0
#Prefix_index = -1
MODULE_660004661 = MODULE_DISTR_660004661
ERREUR_660004661 = 0
code_rejet_660004661 = 0

#QC396
str_exchasciident_660004661 = "str_exchasciident19191919191919191919191911991919191919191919"
str_exchDCBdent_660004661 = "str_exchDCBdent232323232323232323232323232323232323233223233233"
position_660004661 = 0
longueur_660004661 = 0
# /QC396
pt_RetourTable_660004661 = "pt_portabilite767676767676767676767676767676767676767676767676767"
i_strcpy(pt_RetourTable_660004661,"")

##################################################################################
# Identification de la provenance de l'article
# flag_rdt : nb de passage en redistribution (lecture de l'enveloppe obligatoire)
##################################################################################
flag_rdt_660004661 = -1
flag_rdt_660004661 = i_LireRedistCpt()
SI (flag_rdt_660004661 == 0)
ALORS
  erreur_660004661 = i_add_opt( "E_Redistri2" )
FINSI
erreur_660004661 = i_set_attr_val_n( $E_Redistri2::EnvoiRedis, 0)

trace("Ttrans_nss9 : Debut Distribution ****")
pt_valeur_660004661="123456789123456789"
i_strcpy(pt_valeur_660004661, "")
pt_cle_660004661 = "pt_cle0000000000000000"
i_strcpy(pt_cle_660004661,"")

# ==================================
# copie du CRA original dans le g_iartout12
erreur_660004661 = i_dup_art_id(g_iartin, g_iartout12)

# FE_0028 comptabilisation des CRAs issus de la redistribution
date_fin_660004661=i_get_art_field(g_iartin,$Ttrans_nss9::dfin)
erreur_660004661= i_incr_redist_dist_660004265(date_fin_660004661)
erreur_660004661 = i_cree_art("Conv_URS",g_iartout9)

######################################################################################
# Traitement d'un eventuel prefixe Zone Blanche entrant, valorisera le champ DPV V3t34
# dans le champ called Party Number xx 600xxx ZABPQMCDU
# G5R2 lot2 : Item IntercoIP PrefixeZoneBlanche (TON+NPI)[33]<ZBprefix>
# Format de ZBprefix : 600DOT
# Avec :
#   D : le PLMN de destination (OF = 8, SFR = 7, Bytel = 9 )
#   O : le PLMN dorigine (OF = 8, SFR = 7, Bytel = 9 )
#   T : Type of number (National = 4 , International = 1 , Inconnu = 2 ; msrn = 9)
# G5R2 lot2
######################################################################################

Prefix_index_660004661 = -1
erreur_660004661 = 0
SI (  i_get_art_fieldtab(g_iartin,$Ttrans_nss9::calledNumber,0) < 10
  &&  i_get_art_fieldtab(g_iartin,$Ttrans_nss9::calledNumber,1) < 10
  &&  i_get_art_fieldtab(g_iartin,$Ttrans_nss9::calledNumber,2) < 10
  &&  i_get_art_fieldtab(g_iartin,$Ttrans_nss9::calledNumber,3) < 10
  &&  i_get_art_fieldtab(g_iartin,$Ttrans_nss9::calledNumber,4) < 10
  &&  i_get_art_fieldtab(g_iartin,$Ttrans_nss9::calledNumber,5) < 10
  &&  i_get_art_fieldtab(g_iartin,$Ttrans_nss9::calledNumber,6) < 10
  &&  i_get_art_fieldtab(g_iartin,$Ttrans_nss9::calledNumber,7) < 10
  )
ALORS
  erreur_660004661 = i_get_art_str(g_iartin, $Ttrans_nss9::calledNumber, pt_champ_660004661)
  longueur_660004661=i_strlen(pt_champ_660004661)
  Flag_ZB_660004661 = 0
  SI (i_strplcmp(pt_champ_660004661,"1133600",0,7) == 0)
  ALORS
    ZBPrefixDigitD_660004661=i_get_art_fieldtab(g_iartin,$Ttrans_nss9::calledNumber,7)
    ZBPrefixDigitO_660004661=i_get_art_fieldtab(g_iartin,$Ttrans_nss9::calledNumber,8)
    ZBPrefixDigitT_660004661=i_get_art_fieldtab(g_iartin,$Ttrans_nss9::calledNumber,9)
    Flag_ZB_660004661 = C_ZB_1133600DOT_660004661
  SINON
    SI (i_strplcmp(pt_champ_660004661,"11",0,2) != 0 && i_strplcmp(pt_champ_660004661,"600",2,3) == 0)
    ALORS
      ZBPrefixDigitD_660004661=i_get_art_fieldtab(g_iartin,$Ttrans_nss9::calledNumber,5)
      ZBPrefixDigitO_660004661=i_get_art_fieldtab(g_iartin,$Ttrans_nss9::calledNumber,6)
      ZBPrefixDigitT_660004661=i_get_art_fieldtab(g_iartin,$Ttrans_nss9::calledNumber,7)
      Flag_ZB_660004661 = C_ZB_XX600DOT_660004661
    FINSI
  FINSI

  # Si  (zb = 600<7|8|9><7|8|9><1|2|4|9>)
  SI (  (Flag_ZB_660004661 == C_ZB_1133600DOT_660004661 || Flag_ZB_660004661 == C_ZB_XX600DOT_660004661) &&
    ZBPrefixDigitD_660004661 >= 7 && ZBPrefixDigitD_660004661 <= 9 &&
    ZBPrefixDigitO_660004661 >= 7 && ZBPrefixDigitO_660004661 <= 9 &&
    (ZBPrefixDigitT_660004661 == 1 || ZBPrefixDigitT_660004661 == 2 || ZBPrefixDigitT_660004661 == 4 || ZBPrefixDigitT_660004661 == 9) )
  ALORS
    TypePrefixe_660004661 = PREFIX_ZB_660004661
    Prefix_calledNumber_660004661 = 1

    SI (Flag_ZB_660004661 == C_ZB_XX600DOT_660004661)
    ALORS
      i_get_sub_str(pt_champ_660004661, 2, 7, pt_prefixe_660004661)
      longueur_660004661 = i_strlen(pt_prefixe_660004661)
    SINON
      i_get_sub_str(pt_champ_660004661, 4, 9, pt_prefixe_660004661)
      longueur_660004661 = i_strlen(pt_prefixe_660004661) + 2
    FINSI

    Prefix_index_660004661 = 2

    # Suppression de [33] eventuel et du prefixe ZB avant normalisation
    POINT BOUCLE_ZBSKIP1
    erreur_660004661 = i_set_art_fieldtab(g_iartin, $Ttrans_nss9::calledNumber, Prefix_index_660004661, 0x0f)
    erreur_660004661 = i_skip_f_in_field_n(g_iartin, $Ttrans_nss9::calledNumber)
    longueur_660004661 = longueur_660004661 - 1
    SI (longueur_660004661 != 0)
    ALORS
      SAUT BOUCLE_ZBSKIP1
    FINSI
    # Si T = 4 ou 9 alors forcage du TON+NPI a 41 avant normalisation
    SI (ZBPrefixDigitT_660004661 == 4 || ZBPrefixDigitT_660004661 == 9)
    ALORS
      erreur_660004661 = i_set_art_fieldtab(g_iartin, $Ttrans_nss9::calledNumber,0,0x4)
      erreur_660004661 = i_set_art_fieldtab(g_iartin, $Ttrans_nss9::calledNumber,1,0x1)
    FINSI
    # Si T = 1 alors forcage du TON+NPI a 11 avant normalisation
    SI (ZBPrefixDigitT_660004661 == 1)
    ALORS
      erreur_660004661 = i_set_art_fieldtab(g_iartin, $Ttrans_nss9::calledNumber,0,0x1)
      erreur_660004661 = i_set_art_fieldtab(g_iartin, $Ttrans_nss9::calledNumber,1,0x1)
    FINSI
    # Si T = 2 alors forcage du TON+NPI a 21 avant normalisation
    SI (ZBPrefixDigitT_660004661 == 2)
    ALORS
      erreur_660004661 = i_set_art_fieldtab(g_iartin, $Ttrans_nss9::calledNumber,0,0x2)
      erreur_660004661 = i_set_art_fieldtab(g_iartin, $Ttrans_nss9::calledNumber,1,0x1)
    FINSI
  FINSI

FINSI

#############################################################################################
# Traitement d'un eventuel prefixe Zone Blanche sortant, valorisera le champ DPV V3t57
# dans le champ T3t17/translatedNumber
# G1R6 lot4
# G5R2 lot2 : Item IntercoIP PrefixeZoneBlanche (TON+NPI)[33]<ZBprefix>
# Format de ZBprefix : 600DOT
# Avec :
#   D : le PLMN de destination (OF = 8, SFR = 7, Bytel = 9 )
#   O : le PLMN dorigine (OF = 8, SFR = 7, Bytel = 9 )
#   T : Type of number (National = 4 , International = 1 , Inconnu = 2 ; msrn = 9)
#############################################################################################
SI (i_valid_field_n(g_iartin, $Ttrans_nss9::translatedNum))
ALORS
  SI (  i_get_art_fieldtab(g_iartin,$Ttrans_nss9::translatedNum,0) < 10
    &&  i_get_art_fieldtab(g_iartin,$Ttrans_nss9::translatedNum,1) < 10
    &&  i_get_art_fieldtab(g_iartin,$Ttrans_nss9::translatedNum,2) < 10
    &&  i_get_art_fieldtab(g_iartin,$Ttrans_nss9::translatedNum,3) < 10
    &&  i_get_art_fieldtab(g_iartin,$Ttrans_nss9::translatedNum,4) < 10
    &&  i_get_art_fieldtab(g_iartin,$Ttrans_nss9::translatedNum,5) < 10
    &&  i_get_art_fieldtab(g_iartin,$Ttrans_nss9::translatedNum,6) < 10
    &&  i_get_art_fieldtab(g_iartin,$Ttrans_nss9::translatedNum,7) < 10
    )
  ALORS
    erreur_660004661 = i_get_art_str(g_iartin, $Ttrans_nss9::translatedNum, pt_champ_660004661)
    longueur_660004661=i_strlen(pt_champ_660004661)
    Flag_ZB_660004661 = 0
    SI (i_strplcmp(pt_champ_660004661,"1133600",0,7) == 0)
    ALORS
      ZBTransSortD_660004661=i_get_art_fieldtab(g_iartin,$Ttrans_nss9::translatedNum,7)
      ZBTransSortO_660004661=i_get_art_fieldtab(g_iartin,$Ttrans_nss9::translatedNum,8)
      ZBTransSortT_660004661=i_get_art_fieldtab(g_iartin,$Ttrans_nss9::translatedNum,9)
      Flag_ZB_660004661 = C_ZB_1133600DOT_660004661
    SINON
      SI (i_strplcmp(pt_champ_660004661,"11",0,2) != 0 && i_strplcmp(pt_champ_660004661,"600",2,3) == 0)
      ALORS
        ZBTransSortD_660004661=i_get_art_fieldtab(g_iartin,$Ttrans_nss9::translatedNum,5)
        ZBTransSortO_660004661=i_get_art_fieldtab(g_iartin,$Ttrans_nss9::translatedNum,6)
        ZBTransSortT_660004661=i_get_art_fieldtab(g_iartin,$Ttrans_nss9::translatedNum,7)
        Flag_ZB_660004661 = C_ZB_XX600DOT_660004661
      FINSI
    FINSI
    # Si  (zb = 600<7|8|9><7|8|9><1|2|4|9>)
    SI (  (Flag_ZB_660004661 == C_ZB_1133600DOT_660004661 || Flag_ZB_660004661 == C_ZB_XX600DOT_660004661) &&
      ZBTransSortD_660004661 >= 7 && ZBTransSortD_660004661 <= 9 &&
      ZBTransSortO_660004661 >= 7 && ZBTransSortO_660004661 <= 9 &&
      (ZBTransSortT_660004661 == 1 || ZBTransSortT_660004661 == 2 || ZBTransSortT_660004661 == 4 || ZBTransSortT_660004661 == 9) )
    ALORS
      fgZBTransSort_660004661 = 1
    FINSI
  FINSI
FINSI

#G1R6 lot4
#####################################################################
# Traitement d'un eventuel prefixe de itin a 6 chiffres
# dans le champ called Party Number
#####################################################################
# G3R10
Prefix_index_660004661 = -1
SI (!Prefix_calledNumber_660004661)
ALORS
  # Prefixe RNSAC a 6 chiffres 41XXXX0TZABPQMCDU  => 17 digits  (nouveau format)
  # avec T (8eme digit) = 1, 2 ou 4
  # dans le champ calledNumber uniquement (called Party Number)
  valTerm_660004661 = i_get_art_fieldtab(g_iartin,$Ttrans_nss9::calledNumber,7)
  SI ( i_get_art_fieldtab(g_iartin,$Ttrans_nss9::calledNumber,0) == 4
    && i_get_art_fieldtab(g_iartin,$Ttrans_nss9::calledNumber,1) == 1
    && i_get_art_fieldtab(g_iartin,$Ttrans_nss9::calledNumber,6) == 0
    && (valTerm_660004661 == 1 || valTerm_660004661 == 2 || valTerm_660004661 == 4)
    )
  ALORS
    erreur_660004661 = i_get_art_str(g_iartin, $Ttrans_nss9::calledNumber, pt_champ_660004661)
    longueur_660004661=i_strlen(pt_champ_660004661)
    #QC1302 correction sur la valeur de la longeur 9 au lieu de 16 pour tenir compte des n? court
    SI (longueur_660004661 >= 9)
    ALORS
      i_get_sub_str(pt_champ_660004661, 2, 7, pt_cle_660004661)
      i_strcpy(pt_RetourTable_660004661,i_get_tab_field(RNSAC_660004661, date_fin_660004661, pt_cle_660004661))
      SI (i_strcmp(pt_RetourTable_660004661,"itin") == 0)
      ALORS
        SI (i_strcmp(pt_prefixe_660004661, "") == 0)
        ALORS
          TypePrefixe_660004661 = PREFIX_ITIN_660004661
          # Seuls les 4ers digits du prefixe d'itinerance sont renseignes dans V3t69 (PrefItinerance)
          i_get_sub_str(pt_cle_660004661, 0, 3, pt_prefixe_660004661)
        FINSI
        longueur_660004661 = i_strlen(pt_cle_660004661)
        Prefix_index_660004661 = 2

      FINSI
      SI (Prefix_index_660004661 != -1)
      ALORS
        trace2 ("<<__LINE__ >> ---------------- pt_cle = %s ----------",pt_cle_660004661,"")
        Prefix_calledNumber_660004661 = 1
        # Suppression du prefixe RNA du champ d origine : TON+NPI [33] RNA ZABPQMCDU
        POINT BOUCLE_RNASKIP1
        # Dx
        erreur_660004661 = i_set_art_fieldtab(g_iartin, $Ttrans_nss9::calledNumber, Prefix_index_660004661, 0x0f)
        erreur_660004661 = i_skip_f_in_field_n(g_iartin, $Ttrans_nss9::calledNumber)
        longueur_660004661 = longueur_660004661 - 1
        SI (longueur_660004661 != 0)
        ALORS
          SAUT BOUCLE_RNASKIP1
        FINSI
        SI ( valTerm_660004661 == 1)
        ALORS
          erreur_660004661 = i_set_art_fieldtab(g_iartin, $Ttrans_nss9::calledNumber, 0, 1)
        SINON
          SI ( valTerm_660004661 == 2)
          ALORS
            erreur_660004661 = i_set_art_fieldtab(g_iartin, $Ttrans_nss9::calledNumber, 0, 2)
          FINSI
        FINSI
      FINSI
    FINSI
  FINSI
FINSI

# Prefixe RNSAC  a 4 chiffres
# 41XXXXZABPQMCDU => 15 digits, prefixes PORTA, SVA, ITI dans les champs calledNumber (called Party Number), redirectNumber, origCalledNum, impact dpv : V3t12 (porta), V3t70 (sva) ou V3t69 (iti)
# 1133XXXXZABPQMCDU => 17 digits, prefixes PORTA, SVA, ITI dans les champs calledNumber (called Party Number), redirectNumber, origCalledNum, impact dpv : V3t12 (porta), V3t70 (sva) ou V3t69 (iti)
# 11XXXXCC* avec 1er C != 0 => 8 digits (1er C = 7eme digit), prefixe ITI dans le champ calledNumber, impact dpv : V3t69 (iti)
# B1XXXX* => 6 digits, prefixe ITI dans le champ calledNumber, impact dpv : V3t69 (iti)

ic_660004661 = 0

POINT DEB_BOUCLE_RNA

Prefix_index_660004661 = -1
ic_660004661 = ic_660004661 + 1
flag_pref_660004661 = 0
SI (ic_660004661 == 1)
ALORS
  indice_champ_660004661 = $Ttrans_nss9::calledNumber
  flag_pref_660004661 = Prefix_calledNumber_660004661
SINON
  SI (ic_660004661 == 2)
  ALORS
    indice_champ_660004661 = $Ttrans_nss9::redirectNumber
  SINON
    SI (ic_660004661 == 3)
    ALORS
      indice_champ_660004661 = $Ttrans_nss9::origCalledNum
    FINSI
  FINSI
FINSI

SI (!flag_pref_660004661)
ALORS
  SI (i_valid_field_n(g_iartin,indice_champ_660004661))
  ALORS
    i_strcpy(pt_champ_660004661, "")
    erreur_660004661 = i_get_art_str(g_iartin, indice_champ_660004661, pt_champ_660004661)
    longueur_660004661=i_strlen(pt_champ_660004661)

    SI ((i_strplcmp(pt_champ_660004661,"41",0,2) == 0 && longueur_660004661 > 14) || (i_strplcmp(pt_champ_660004661,"B1",0,2) == 0 && longueur_660004661 > 6) || (i_strplcmp(pt_champ_660004661,"11",0,2) == 0 && i_strplcmp(pt_champ_660004661,"0",6,1) != 0 && longueur_660004661 >= 8) || (i_strplcmp(pt_champ_660004661,"1133",0,4) == 0 && longueur_660004661 > 16))
    ALORS
      i_strcpy(pt_cle_660004661, "")
      SI (i_strplcmp(pt_champ_660004661,"41",0,2) == 0)
      ALORS
        # Prendre les 4 chiffres suivant le TON/NPI
        i_get_sub_str(pt_champ_660004661, 2, 5, pt_cle_660004661)
        i_strcpy(pt_RetourTable_660004661,i_get_tab_field(RNSAC_660004661, date_fin_660004661, pt_cle_660004661))
        SI (i_strcmp(pt_RetourTable_660004661,"porta") == 0)
        ALORS
          Prefix_index_660004661 = 2
          longueur_660004661 = i_strlen(pt_cle_660004661)
          SI (i_strcmp(pt_prefixe_660004661, "") == 0 && indice_champ_660004661 == $Ttrans_nss9::calledNumber)
          ALORS
            TypePrefixe_660004661 = PREFIX_PORTA_660004661
            i_strcpy(pt_prefixe_660004661, pt_cle_660004661)
          FINSI
        SINON
          SI (i_strcmp(pt_RetourTable_660004661,"sva") == 0)
          ALORS
            Prefix_index_660004661 = 2
            longueur_660004661 = i_strlen(pt_cle_660004661)
            SI (i_strcmp(pt_prefixe_660004661, "") == 0 && indice_champ_660004661 == $Ttrans_nss9::calledNumber)
            ALORS
              TypePrefixe_660004661 = PREFIX_SVA_660004661
              i_strcpy(pt_prefixe_660004661, pt_cle_660004661)
            FINSI
          SINON
            #QC1239
            SI (i_strcmp(pt_RetourTable_660004661,"iti") == 0 && indice_champ_660004661 != $Ttrans_nss9::redirectNumber && indice_champ_660004661 != $Ttrans_nss9::origCalledNum)
            ALORS
              Prefix_index_660004661 = 2
              longueur_660004661 = i_strlen(pt_cle_660004661)
              SI (i_strcmp(pt_prefixe_660004661, "") == 0 && indice_champ_660004661 == $Ttrans_nss9::calledNumber)
              ALORS
                TypePrefixe_660004661 = PREFIX_ITI_660004661
                i_strcpy(pt_prefixe_660004661, pt_cle_660004661)
              FINSI
            FINSI
          FINSI
        FINSI
      SINON
        # QC xxxx
        SI (i_strplcmp(pt_champ_660004661,"1133",0,4) == 0 && longueur_660004661 > 16)
        ALORS
          # Prendre les 4 chiffres suivant le TON/NPI
          i_get_sub_str(pt_champ_660004661, 4, 7, pt_cle_660004661)
          i_strcpy(pt_RetourTable_660004661,i_get_tab_field(RNSAC_660004661, date_fin_660004661, pt_cle_660004661))
          SI (i_strcmp(pt_RetourTable_660004661,"porta") == 0)
          ALORS
            Prefix_index_660004661 = 4
            longueur_660004661 = i_strlen(pt_cle_660004661)
            SI (i_strcmp(pt_prefixe_660004661, "") == 0 && indice_champ_660004661 == $Ttrans_nss9::calledNumber)
            ALORS
              TypePrefixe_660004661 = PREFIX_PORTA_660004661
              i_strcpy(pt_prefixe_660004661, pt_cle_660004661)
            FINSI
          SINON
            SI (i_strcmp(pt_RetourTable_660004661,"sva") == 0)
            ALORS
              Prefix_index_660004661 = 4
              longueur_660004661 = i_strlen(pt_cle_660004661)
              SI (i_strcmp(pt_prefixe_660004661, "") == 0 && indice_champ_660004661 == $Ttrans_nss9::calledNumber)
              ALORS
                TypePrefixe_660004661 = PREFIX_SVA_660004661
                i_strcpy(pt_prefixe_660004661, pt_cle_660004661)
              FINSI
            SINON
              #QC1239
              SI (i_strcmp(pt_RetourTable_660004661,"iti") == 0 && indice_champ_660004661 != $Ttrans_nss9::redirectNumber && indice_champ_660004661 != $Ttrans_nss9::origCalledNum)
              ALORS
                Prefix_index_660004661 = 4
                longueur_660004661 = i_strlen(pt_cle_660004661)
                SI (i_strcmp(pt_prefixe_660004661, "") == 0 && indice_champ_660004661 == $Ttrans_nss9::calledNumber)
                ALORS
                  TypePrefixe_660004661 = PREFIX_ITI_660004661
                  i_strcpy(pt_prefixe_660004661, pt_cle_660004661)
                FINSI
              FINSI
            FINSI
          FINSI
        SINON
          SI ((i_strplcmp(pt_champ_660004661,"B1",0,2) == 0 || (i_strplcmp(pt_champ_660004661,"11",0,2) == 0 && i_strplcmp(pt_champ_660004661,"0",6,1) != 0 && longueur_660004661 >= 8)) && indice_champ_660004661 == $Ttrans_nss9::calledNumber)
          ALORS
            i_get_sub_str(pt_champ_660004661, 2, 5, pt_cle_660004661)
            i_strcpy(pt_RetourTable_660004661,i_get_tab_field(RNSAC_660004661, date_fin_660004661, pt_cle_660004661))
            SI (i_strcmp(pt_RetourTable_660004661,"iti") == 0)
            ALORS
              Prefix_index_660004661 = 2
              longueur_660004661 = i_strlen(pt_cle_660004661)
              SI (i_strcmp(pt_prefixe_660004661, "") == 0 && indice_champ_660004661 == $Ttrans_nss9::calledNumber)
              ALORS
                TypePrefixe_660004661 = PREFIX_ITI_660004661
                i_strcpy(pt_prefixe_660004661, pt_cle_660004661)
              FINSI
            FINSI
          FINSI
        FINSI
      FINSI
    FINSI
    SI (Prefix_index_660004661 != -1)
    ALORS
      SI (indice_champ_660004661 == $Ttrans_nss9::calledNumber)
      ALORS
        Prefix_calledNumber_660004661 = 1
      FINSI
      trace2 ("<<__LINE__ >> ---------------- pt_cle = %s ----------",pt_cle_660004661,"")
      # Suppression du prefixe RNA du champ d origine : TON+NPI [33] RNA ZABPQMCDU
      POINT BOUCLE_RNASKIP2
      # Dx
      erreur_660004661 = i_set_art_fieldtab(g_iartin, indice_champ_660004661, Prefix_index_660004661, 0x0f)
      erreur_660004661 = i_skip_f_in_field_n(g_iartin, indice_champ_660004661)
      longueur_660004661 = longueur_660004661 - 1
      SI (longueur_660004661 != 0)
      ALORS
        SAUT BOUCLE_RNASKIP2
      FINSI
    FINSI
  FINSI
FINSI

SI (ic_660004661 < 3)
ALORS
  SAUT DEB_BOUCLE_RNA
FINSI

#G2R1 lot2
#####################################################################
# Traitement d'un eventuel prefixe OMOF
# dans le champ called Party Number
#####################################################################

#G3R10
Prefix_index_660004661 = -1
SI (!Prefix_calledNumber_660004661)
ALORS
  SI (g_iartin.calledNumber!NELEM > 12)
  ALORS
    erreur_660004661 = 0
    i_strcpy(pt_champ_660004661, "")
    erreur_660004661 = i_get_art_str(g_iartin, $Ttrans_nss9::calledNumber, pt_champ_660004661)
    longueur_660004661=i_strlen(pt_champ_660004661)
    SI ( (i_strplcmp(pt_champ_660004661,"41",0,2) == 0 && longueur_660004661 > 12) || (i_strplcmp(pt_champ_660004661,"1133",0,4) == 0 && longueur_660004661 > 14) )
    ALORS
      SI (i_strplcmp(pt_champ_660004661,"41",0,2) == 0)
      ALORS
        #retirer le 1er octet A1 puis retirer les 9 digits ZABPQMCDU de droite
        i_get_sub_str(pt_champ_660004661, 2, -10, pt_cle_660004661)
        i_strcpy(pt_RetourTable_660004661,i_get_tab_field(RNSAC_660004661, date_fin_660004661, pt_cle_660004661))
        SI (i_strcmp(pt_RetourTable_660004661,"omof") == 0)
        ALORS
          SI (i_strcmp(pt_prefixe_660004661, "") == 0)
          ALORS
            TypePrefixe_660004661 = PREFIX_OMOF_660004661
            i_strcpy(pt_prefixe_660004661, pt_cle_660004661)
          FINSI
          Prefix_index_660004661=2
          longueur_660004661 = i_strlen(pt_cle_660004661)
        FINSI
      SINON
        SI (i_strplcmp(pt_champ_660004661,"1133",0,4) == 0)
        ALORS
          i_get_sub_str(pt_champ_660004661, 4, -10, pt_cle_660004661)
          i_strcpy(pt_RetourTable_660004661,i_get_tab_field(RNSAC_660004661, date_fin_660004661, pt_cle_660004661))
          SI (i_strcmp(pt_RetourTable_660004661,"omof") == 0)
          ALORS
            SI (i_strcmp(pt_prefixe_660004661, "") == 0)
            ALORS
              TypePrefixe_660004661 = PREFIX_OMOF_660004661
              i_strcpy(pt_prefixe_660004661, pt_cle_660004661)
            FINSI
            Prefix_index_660004661 = 4
            longueur_660004661 = i_strlen(pt_cle_660004661)
          FINSI
        FINSI
      FINSI
    FINSI
  FINSI
  SI (Prefix_index_660004661 != -1)
  ALORS
    Prefix_calledNumber_660004661 = 1
    # Suppression du prefixe OMOF du champ d origine : TON+NPI [33] OMOF ZABPQMCDU
    POINT BOUCLE_OMOF
    # Dx
    erreur_660004661 = i_set_art_fieldtab(g_iartin, $Ttrans_nss9::calledNumber, Prefix_index_660004661, 0x0f)
    erreur_660004661 = i_skip_f_in_field_n(g_iartin, $Ttrans_nss9::calledNumber)
    longueur_660004661 = longueur_660004661 - 1
    SI longueur_660004661 != 0
    ALORS
      SAUT BOUCLE_OMOF
    FINSI
  FINSI
FINSI
#/G3R10

#----------------------------------------------------#
# G3R8Lot2  Traitement du prefix de Joignabilite
# du champ T3t6/calledNumber
#----------------------------------------------------#
Prefix_index_660004661 = -1

SI (!Prefix_calledNumber_660004661)
ALORS
  i_strcpy(pt_champ_660004661, "")
  erreur_660004661 = i_get_art_str(g_iartin, $Ttrans_nss9::calledNumber, pt_champ_660004661)
  longueur_660004661=i_strlen(pt_champ_660004661)
  SI ( (i_strplcmp(pt_champ_660004661,"41",0,2) == 0 && longueur_660004661 > 12) || (i_strplcmp(pt_champ_660004661,"1133",0,4) == 0 && longueur_660004661 > 14) )
  ALORS
    SI (i_strplcmp(pt_champ_660004661,"41",0,2) == 0)
    ALORS
      #retirer le 1er octet A1 puis retirer les 9 digits ZABPQMCDU de droite
      i_get_sub_str(pt_champ_660004661, 2, -10, pt_cle_660004661)
      i_strcpy(pt_RetourTable_660004661,i_get_tab_field(RNSAC_660004661, date_fin_660004661, pt_cle_660004661))
      SI (i_strcmp(pt_RetourTable_660004661,"joig") == 0)
      ALORS
        SI (i_strcmp(pt_prefixe_660004661, "") == 0)
        ALORS
          TypePrefixe_660004661 = PREFIX_JOIG_660004661
          i_strcpy(pt_prefixe_660004661, pt_cle_660004661)
        FINSI
        Prefix_index_660004661=2
        longueur_660004661 = i_strlen(pt_cle_660004661)
      FINSI
    SINON
      SI (i_strplcmp(pt_champ_660004661,"1133",0,4) == 0)
      ALORS
        i_get_sub_str(pt_champ_660004661, 4, -10, pt_cle_660004661)
        i_strcpy(pt_RetourTable_660004661,i_get_tab_field(RNSAC_660004661, date_fin_660004661, pt_cle_660004661))
        SI (i_strcmp(pt_RetourTable_660004661,"joig") == 0)
        ALORS
          SI (i_strcmp(pt_prefixe_660004661, "") == 0)
          ALORS
            TypePrefixe_660004661 = PREFIX_JOIG_660004661
            i_strcpy(pt_prefixe_660004661, pt_cle_660004661)
          FINSI
          Prefix_index_660004661=4
          longueur_660004661 = i_strlen(pt_cle_660004661)
        FINSI
      FINSI
    FINSI
  FINSI
  SI (Prefix_index_660004661 != -1)
  ALORS
    Prefix_calledNumber_660004661 = 1
    # Suppression du prefixe OMOF du champ d origine : TON+NPI [33] OMOF ZABPQMCDU
    POINT BOUCLE_JOING
    # Dx
    erreur_660004661 = i_set_art_fieldtab(g_iartin, $Ttrans_nss9::calledNumber, Prefix_index_660004661, 0x0f)
    erreur_660004661 = i_skip_f_in_field_n(g_iartin, $Ttrans_nss9::calledNumber)
    longueur_660004661 = longueur_660004661 - 1
    SI longueur_660004661 != 0
    ALORS
      SAUT BOUCLE_JOING
    FINSI
  FINSI
FINSI
#/G3R10
#/G2R1
####################################################################
# duplication au format DPV TLV
####################################################################
erreur_660004661 = i_dup_art_tab(g_iartin,g_iartout,"Tdpvgsm")
SI (erreur_660004661 != 0)
ALORS
  ERREUR_660004661 = ERR_DUPL_660004661
  code_rejet_660004661 = MODULE_660004661 + ERREUR_660004661 + EFFICACE_660004661
  erreur_660004661 = i_PlvMessEmettre(8334,2,g_iartout12,"",1,code_rejet_660004661,0,0)
  SAUT STOCKE_ERRONE
FINSI

#le 2Val ne marche pas correctement alors
date_660004661 =  i_get_art_field(g_iartin,$Ttrans_nss9::ddebut)
erreur_660004661 = i_set_art_field(g_iartout,$Tdpvgsm::DATE, date_660004661)
#Mise a jour du IMSI par 15 fois 9 + F
erreur_660004661 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::IMSI, 15, 0xF)
#----- Mise a jour de la cellule Ajout CE
# QC1331
#erreur=set_timeInCE_EEC(0)
########### Date_Audit
erreur_660004661 = i_set_art_field(g_iartout, $Tdpvgsm::timeInCE,  i_DHgetLocalTime(4, 7, i_date_audit()))
########### eec
# QC1405
SI (g_ieec > 500)
ALORS
  erreur_660004661 = i_set_art_field(g_iartout, $Tdpvgsm::eec, g_ieec - 500)
SINON
  erreur_660004661 = i_set_art_field(g_iartout, $Tdpvgsm::eec, g_ieec)
FINSI
#/QC1405

##################################################################
# QC396, QC1292
# T3t1.3 idemet
##################################################################
# QC1444
i_strcpy(str_exchasciident_660004661,"")
i_strcpy(str_exchDCBdent_660004661,"")
erreur_660004661 = i_get_art_str(g_iartin,$Ttrans_nss9::exchasciident,str_exchasciident_660004661)
trace2("################# str_exchasciident = %s ################",str_exchasciident_660004661,"")
position_660004661 = RECHERCHE_CARACTERE_660004265(str_exchasciident_660004661," ")
trace1("############ position= %d ###########",position_660004661)
SI ( position_660004661 > -1)
ALORS
  i_get_sub_str (str_exchasciident_660004661, 0, position_660004661 - 1 ,str_exchasciident_660004661)
  trace2("################# str_exchasciident = %s ################",str_exchasciident_660004661,"")
FINSI
longueur_660004661 = i_conv_ascii_dcb (str_exchasciident_660004661,str_exchDCBdent_660004661 )
SI (longueur_660004661 > 9)
ALORS
	longueur_660004661 = 9
FINSI
erreur_660004661 = i_memcpy_art_field_n(g_iartout, $Tdpvgsm::idemet, str_exchDCBdent_660004661, longueur_660004661)
#Fin QC396

#####################################################################
# Mise a jour du champ idpart avec
# possible valorisation a 3 niveaux du champ
#####################################################################

# --- Recherche du champ a utiliser pour valoriser idpart

indice_champ_valo_660004661 = 0

# --- Si valorisation a trois niveaux du champ idpart
# Il faut utiliser la fonction i_get_tab_field (TABLE, DATE, ELEMENT)  aulieu de i_getv_ctxt

date_stocke_660004661 = i_get_art_date(g_iartin)
i_strcpy(pt_valeur_660004661, i_get_tab_field("VariableContexte", date_stocke_660004661, "VALO_IDPART_3N"))

SI (i_strcmp(pt_valeur_660004661, g_inull) != 0)
ALORS
  redirectNumber_present_660004661 = i_valid_field_n(g_iartin,$Ttrans_nss9::redirectNumber)
  SI (redirectNumber_present_660004661)
  ALORS
    SI (i_get_art_field(g_iartin,$Ttrans_nss9::redirectNumber-1) == 0)
    ALORS
      redirectNumber_present_660004661=0
    FINSI
  FINSI
  SI (redirectNumber_present_660004661)
  ALORS
# --- Valorisation avec le champ redirectNumber
    indice_champ_valo_660004661 = $Ttrans_nss9::redirectNumber
  SINON
    origCalledNum_present_660004661 = i_valid_field_n(g_iartin,$Ttrans_nss9::origCalledNum)
    SI (origCalledNum_present_660004661)
    ALORS
      SI (i_get_art_field(g_iartin,$Ttrans_nss9::origCalledNum-1) == 0)
      ALORS
        origCalledNum_present_660004661=0
      FINSI
    FINSI
    SI (origCalledNum_present_660004661)
    ALORS
# --- Valorisation avec le champ origCalledNum
      indice_champ_valo_660004661 = $Ttrans_nss9::origCalledNum
    SINON
# --- Valorisation avec le champ callingNumber
      indice_champ_valo_660004661 = $Ttrans_nss9::callingNumber
    FINSI
  FINSI
SINON
# --- Valorisation classique avec le champ callingNumber
  indice_champ_valo_660004661 = $Ttrans_nss9::callingNumber
FINSI

SI (i_valid_field_n(g_iartin, indice_champ_valo_660004661))
ALORS
  erreur_660004661 = i_ajout_tlv(g_iartout, "T3t2", "")
# --- Valorisation du champ idpart
  SI ( i_get_art_field(g_iartin, indice_champ_valo_660004661-1) == 2)
  ALORS
    SI ( (i_get_art_fieldtab(g_iartin, indice_champ_valo_660004661, 0) == 4) &&
      (i_get_art_fieldtab(g_iartin, indice_champ_valo_660004661, 1) == 1) &&
      (i_get_art_fieldtab(g_iartin, indice_champ_valo_660004661, 2) == 0) &&
      (i_get_art_fieldtab(g_iartin, indice_champ_valo_660004661, 3) == 0x0f) )
    ALORS
# Cas Appelant = 0 (on utilise l'automate specifique pour la normalisation)
      erreur_660004661 = i_dup_chp_rnisGSM(g_iartin,g_iartout,indice_champ_valo_660004661,$Tdpvgsm::idpart,-$NORM:MET_ASN1_410,0)
    SINON
# Cas Normal (on utilise l'automate de base pour la normalisation)
      erreur_660004661 = i_dup_chp_rnisGSM(g_iartin,g_iartout,indice_champ_valo_660004661,$Tdpvgsm::idpart,-$NORM:MET_ASN1_NEW_2242,0)
    FINSI
  SINON
# Cas Normal (on utilise l'automate de base pour la normalisation)
    erreur_660004661 = i_dup_chp_rnisGSM(g_iartin,g_iartout,indice_champ_valo_660004661,$Tdpvgsm::idpart,-$NORM:MET_ASN1_NEW_2242,0)
  FINSI
  SI ( erreur_660004661 != 0)
  ALORS
    trace("Ttrans_nss9 :Erreur duplication champ idpart")
    ERREUR_660004661 = ERR_NORM_660004661
    code_rejet_660004661 = MODULE_660004661 + ERREUR_660004661 + EFFICACE_660004661
    erreur_660004661 = i_PlvMessEmettre(8335,2,g_iartout12,"",2, code_rejet_660004661,"idpart",0)
    SAUT STOCKE_ERRONE
  FINSI
FINSI

#####################################################################
# Traitement du champ origine
#
#####################################################################
SI (i_valid_field_n(g_iartin, $Ttrans_nss9::intIncomingCall))
ALORS
  SI (i_get_art_field(g_iartin, $Ttrans_nss9::intIncomingCall) == 1)
  ALORS
    erreur_660004661 = i_set_art_field(g_iartout, $Tdpvgsm::origine,1)
  FINSI
FINSI

#####################################################################
# Traitement du champ portOrigNet (T3t6)
#
#####################################################################
# --- On verifie que le champ origLocNumber est present
origLocNum_present_660004661 = i_valid_field_n(g_iartin, $Ttrans_nss9::origLocNumber)
SI (origLocNum_present_660004661)
ALORS
  SI (i_get_art_field(g_iartin, $Ttrans_nss9::origLocNumber-1) == 0)
  ALORS
    origLocNum_present_660004661 = 0
  FINSI
FINSI

# --- Si le champ est absent le T3t6 du DPV sera absent
SI (origLocNum_present_660004661)
ALORS
# Taille en octet : le champ origLocNumber est un tableau de BIT
  SI (i_get_art_field(g_iartin, $Ttrans_nss9::origLocNumber-1) >= 2)
  ALORS
    TON_origLocNum_660004661 = i_get_art_fieldtab(g_iartin, $Ttrans_nss9::origLocNumber, 0)
    NPI_origLocNum_660004661 = i_get_art_fieldtab(g_iartin, $Ttrans_nss9::origLocNumber, 1)

# --- portOrigNet sera absent du DPV si en entree le champ
# --- origLocNumber a un TON NPI different de 41 (E///)
# --- ou A1 (alcatel)  et si le
# --- numero ne commence pas par 61 ou 62 ou 63
    SI (TON_origLocNum_660004661 == 4 && NPI_origLocNum_660004661 == 1)
    ALORS
# --- On normalise le champ origLocNumber vers le champ V3t6 du DPV (portOrigNet)
      erreur_660004661 = i_ajout_tlv(g_iartout,"T3t6","")
      erreur_660004661 = i_dup_chp_rnisGSM(g_iartin, g_iartout, $Ttrans_nss9::origLocNumber,$Tdpvgsm::portOrigNet, -$NORM:CIT_IDENT, 0)
      SI ( erreur_660004661 != 0 )
      ALORS
        trace("Ttrans_nss9 :Erreur duplication champ portOrigNet")
        ERREUR_660004661 = ERR_NORM_660004661
        code_rejet_660004661 = MODULE_660004661 + ERREUR_660004661 + EFFICACE_660004661
        erreur_660004661 = i_PlvMessEmettre(8335,2,g_iartout12,"",2, code_rejet_660004661,"portOrigNet",0)
        SAUT STOCKE_ERRONE
      FINSI
    FINSI
  FINSI
FINSI

#####################################################################
# Mise a jour du T3 portability prefix (T3t12)
#####################################################################
SI (TypePrefixe_660004661 == PREFIX_PORTA_660004661)
ALORS
# --- Si un prefixe RNSAC porta a ete trouve
  erreur_660004661 = i_ajout_tlv(g_iartout, "T3t12", "")
  longueur_660004661 = i_conv_ascii_dcb(pt_prefixe_660004661, pt_prefixe_DCB_660004661)
  erreur_660004661 = i_memcpy_art_field_n(g_iartout, $Tdpvgsm::portpref, pt_prefixe_DCB_660004661, longueur_660004661)
  erreur_660004661 = i_resize_tlv( g_iartout, "T3t12", "portpref", longueur_660004661 * 8 )
FINSI

#####################################################################
# Traitement du champs transporteurs sortant et entrants
# T3t16 et T3t17
#####################################################################
# ---- Duplication du champ transporteur Sortant
tailleChpTrans_660004661=i_get_art_field(g_iartin,($Ttrans_nss9::outgoingRoute-1))
SI (tailleChpTrans_660004661 <= 7 && i_valid_field_n(g_iartin, $Ttrans_nss9::outgoingRoute))
ALORS
  erreur_660004661 = i_ajout_tlv(g_iartout, "T3t16", "")
  erreur_660004661 = i_resize_tlv(g_iartout,"T3t16","TrSortant",tailleChpTrans_660004661)
  erreur_660004661 = i_memcpy_art_field_n(g_iartout, $Tdpvgsm::TrSortant, g_iartin.outgoingRoute[], tailleChpTrans_660004661)
FINSI

# ---- Duplication du champ transporteur Entrant
tailleChpTrans_660004661 = i_get_art_field(g_iartin,($Ttrans_nss9::incomingRoute-1))
SI (tailleChpTrans_660004661 <= 7  && i_valid_field_n(g_iartin, $Ttrans_nss9::incomingRoute))
ALORS
  erreur_660004661 = i_ajout_tlv(g_iartout, "T3t17", "")
  erreur_660004661 = i_resize_tlv(g_iartout,"T3t17","TrEntrant",tailleChpTrans_660004661)
  erreur_660004661 = i_memcpy_art_field_n(g_iartout, $Tdpvgsm::TrEntrant, g_iartin.incomingRoute[], tailleChpTrans_660004661)
SINON
  SI (i_valid_field_n(g_iartin,$Ttrans_nss9::incomingRoute))
  ALORS
    erreur_660004661 = i_ajout_tlv(g_iartout, "T3t17", "")
    erreur_660004661 = i_resize_tlv(g_iartout,"T3t17","TrEntrant",7)
    erreur_660004661 = i_memcpy_art_field_n(g_iartout, $Tdpvgsm::TrEntrant, g_iartin.incomingRoute[], 7)
  FINSI
FINSI

################################################
#   CAS DPV 3.2 : Ajout du champs T3t34 ZBprefix
################################################
SI (TypePrefixe_660004661 == PREFIX_ZB_660004661  && !fgZBTransSort_660004661)
ALORS
# --- Si un prefixe ZB sur calledNumber a ete trouve
  erreur_660004661 = i_ajout_tlv(g_iartout,"T3t34","")
  longueur_660004661 = i_conv_ascii_dcb(pt_prefixe_660004661, pt_prefixe_DCB_660004661)
  erreur_660004661 = i_memcpy_art_field_n(g_iartout, $Tdpvgsm::ZBprefix, pt_prefixe_DCB_660004661, longueur_660004661)
  erreur_660004661 = i_resize_tlv( g_iartout, "T3t34", "ZBprefix", longueur_660004661 * 8 )
FINSI

###################################################################
# Ajout du champ V4t38.1 origCallpartId
###################################################################
#G3R10 lot 2 : OMOF, Ajout du champ V4t38.1 origCallpartId
SI (TypePrefixe_660004661 == PREFIX_OMOF_660004661)
ALORS
  erreur_660004661 = i_ajout_tlv(g_iartout,"T4t38.1","")
  erreur_660004661 = i_set_art_str(g_iartout, $Tdpvgsm::origCallpartId, pt_prefixe_660004661)
  erreur_660004661 = i_resize_tlv(g_iartout,"T4t38.1","origCallpartId", i_strlen(pt_prefixe_660004661))
FINSI
#\G3R10

###################################################################
# Ajout du champ V4t38.3 equipmentType
###################################################################
erreur_660004661 = i_ajout_tlv(g_iartout,"T4t38.3","")
erreur_660004661 = i_resize_tlv(g_iartout,"T4t38.3","equipmentType",1)
erreur_660004661 = 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_660004661 = i_ajout_tlv(g_iartout,"T3t55","")
FINSI

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

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

#############################################
#Ajout champ T3t57 GDCB
#G1R6 lot4
##############################################
SI (i_valid_field_n(g_iartin,$Ttrans_nss9::translatedNum) && fgZBTransSort_660004661)
ALORS
  erreur_660004661 = i_ajout_tlv(g_iartout,"T3t57","")
  erreur_660004661 = i_resize_tlv(g_iartout,"T3t57","GDCB",3*8)
  erreur_660004661 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::GDCB,0,6)
  erreur_660004661 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::GDCB,1,0)
  erreur_660004661 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::GDCB,2,0)
  erreur_660004661 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::GDCB,3,ZBTransSortD_660004661)
  erreur_660004661 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::GDCB,4,ZBTransSortO_660004661)
  erreur_660004661 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::GDCB,5,ZBTransSortT_660004661)
FINSI
#/G1R6 lot4

##########################################################
#G3R3 lot2 mapping ABC ajout du T3T63 (LastCallingNb)
##########################################################
#G3R8 lot3 Mapping ABC reiterer la normalisation de T3t63 pour les champs candidats

redirectNumber_present_660004661 = i_valid_field_n(g_iartin,$Ttrans_nss9::redirectNumber)
SI (redirectNumber_present_660004661)
ALORS
  SI (i_get_art_field(g_iartin,$Ttrans_nss9::redirectNumber-1) == 0)
  ALORS
    redirectNumber_present_660004661=0
  FINSI
FINSI

SI (redirectNumber_present_660004661)
ALORS
  erreur_660004661 = i_ajout_tlv(g_iartout,"T3t63","")
  SI ( i_get_art_field(g_iartin, $Ttrans_nss9::redirectNumber-1) == 2)
  ALORS
    SI (  (i_get_art_fieldtab(g_iartin, $Ttrans_nss9::redirectNumber, 0) ==    4) &&
      (i_get_art_fieldtab(g_iartin, $Ttrans_nss9::redirectNumber, 1) ==    1) &&
      (i_get_art_fieldtab(g_iartin, $Ttrans_nss9::redirectNumber, 2) ==    0) &&
      (i_get_art_fieldtab(g_iartin, $Ttrans_nss9::redirectNumber, 3) == 0x0f)  )
    ALORS
      erreur_660004661 = i_dup_chp_rnisGSM(g_iartin,g_iartout,$Ttrans_nss9::redirectNumber,$Tdpvgsm::LastCallingNb,-$NORM:MET_ASN1_410,0)
      #QC925
      SI ( erreur_660004661 != 0)
      ALORS
        trace("Ttrans_nss9: Erreur de duplication + normalisation  du champ T3t63 LastCallingNb")
        #erreur = i_retrait_tlv(g_iartout, "T3t63", "")
        SAUT redirectNorma1
      FINSI
    SINON
      erreur_660004661 = i_dup_chp_rnisGSM(g_iartin,g_iartout,$Ttrans_nss9::redirectNumber,$Tdpvgsm::LastCallingNb,-$NORM:MET_ASN1_NEW_2242,0)
      #QC925
      SI ( erreur_660004661 != 0)
      ALORS
        trace("Ttrans_nss9: Erreur de duplication + normalisation  du champ T3t63 LastCallingNb")
        #erreur = i_retrait_tlv(g_iartout, "T3t63", "")
        SAUT redirectNorma1
      FINSI
    FINSI
  SINON
    erreur_660004661 = i_dup_chp_rnisGSM(g_iartin,g_iartout,$Ttrans_nss9::redirectNumber,$Tdpvgsm::LastCallingNb,-$NORM:MET_ASN1_NEW_2242,0)
    #QC925
    SI ( erreur_660004661 != 0)
    ALORS
      trace("Ttrans_nss9: Erreur de duplication + normalisation  du champ T3t63 LastCallingNb")
      #erreur = i_retrait_tlv(g_iartout, "T3t63", "")
      SAUT redirectNorma1
    FINSI
  FINSI
SINON
  POINT redirectNorma1
  origCalledNum_present_660004661 = i_valid_field_n(g_iartin,$Ttrans_nss9::origCalledNum)
  SI (origCalledNum_present_660004661)
  ALORS
    SI (i_get_art_field(g_iartin,$Ttrans_nss9::origCalledNum-1) == 0)
    ALORS
      origCalledNum_present_660004661=0
    FINSI
  FINSI
  SI (origCalledNum_present_660004661)
  ALORS
    SI (!i_valid_field_n(g_iartout,$Tdpvgsm::LastCallingNb))
    ALORS
      erreur_660004661 = i_ajout_tlv(g_iartout,"T3t63","")
    FINSI
    SI ( i_get_art_field(g_iartin, $Ttrans_nss9::origCalledNum-1) == 2)
    ALORS
      SI((i_get_art_fieldtab(g_iartin, $Ttrans_nss9::origCalledNum, 0) == 4) &&
        (i_get_art_fieldtab(g_iartin, $Ttrans_nss9::origCalledNum, 1) == 1) &&
        (i_get_art_fieldtab(g_iartin, $Ttrans_nss9::origCalledNum, 2) == 0) &&
        (i_get_art_fieldtab(g_iartin, $Ttrans_nss9::origCalledNum, 3) == 0x0f) )
      ALORS
        erreur_660004661 = i_dup_chp_rnisGSM(g_iartin,g_iartout,$Ttrans_nss9::origCalledNum,$Tdpvgsm::LastCallingNb,-$NORM:MET_ASN1_410,0)
        #QC925
        SI ( erreur_660004661 != 0)
        ALORS
          trace("Ttrans_nss9: Erreur de duplication + normalisation  du champ T3t63 LastCallingNb")
          #erreur = i_retrait_tlv(g_iartout, "T3t63", "")
          SAUT origCalledNumNorma1
        FINSI
      SINON
        erreur_660004661 = i_dup_chp_rnisGSM(g_iartin,g_iartout,$Ttrans_nss9::origCalledNum,$Tdpvgsm::LastCallingNb,-$NORM:MET_ASN1_NEW_2242,0)
        #QC925
        SI ( erreur_660004661 != 0)
        ALORS
          trace("Ttrans_nss9: Erreur de duplication + normalisation  du champ T3t63 LastCallingNb")
          #erreur = i_retrait_tlv(g_iartout, "T3t63", "")
          SAUT origCalledNumNorma1
        FINSI
      FINSI
    SINON
      erreur_660004661 = i_dup_chp_rnisGSM(g_iartin,g_iartout,$Ttrans_nss9::origCalledNum,$Tdpvgsm::LastCallingNb,-$NORM:MET_ASN1_NEW_2242,0)
      #QC925
      SI ( erreur_660004661 != 0)
      ALORS
        trace("Ttrans_nss9: Erreur de duplication + normalisation  du champ T3t63 LastCallingNb")
        #erreur = i_retrait_tlv(g_iartout, "T3t63", "")
        SAUT origCalledNumNorma1
      FINSI
    FINSI
  SINON
#ICI
    POINT origCalledNumNorma1
    SI (i_valid_field_n(g_iartin,$Ttrans_nss9::callingNumber))
    ALORS
      SI (!i_valid_field_n(g_iartout,$Tdpvgsm::LastCallingNb))
      ALORS
        erreur_660004661 = i_ajout_tlv(g_iartout,"T3t63","")
      FINSI
      SI  (i_get_art_field(g_iartin, $Ttrans_nss9::callingNumber-1) == 2)
      ALORS
        SI ((i_get_art_fieldtab(g_iartin, $Ttrans_nss9::callingNumber, 0) == 4) &&
          (i_get_art_fieldtab(g_iartin, $Ttrans_nss9::callingNumber, 1) == 1) &&
          (i_get_art_fieldtab(g_iartin, $Ttrans_nss9::callingNumber, 2) == 0) &&
          (i_get_art_fieldtab(g_iartin, $Ttrans_nss9::callingNumber, 3) == 0x0f) )
        ALORS
          erreur_660004661 = i_dup_chp_rnisGSM(g_iartin,g_iartout,$Ttrans_nss9::callingNumber,$Tdpvgsm::LastCallingNb,-$NORM:MET_ASN1_410,0)
          #QC925
          SI ( erreur_660004661 != 0)
          ALORS
            trace("Ttrans_nss9: Erreur de duplication + normalisation  du champ T3t63 LastCallingNb")
            #erreur = i_retrait_tlv(g_iartout, "T3t63", "")
          FINSI
        SINON
          erreur_660004661 = i_dup_chp_rnisGSM(g_iartin,g_iartout,$Ttrans_nss9::callingNumber,$Tdpvgsm::LastCallingNb,-$NORM:MET_ASN1_NEW_2242,0)
          #QC925
          SI ( erreur_660004661 != 0)
          ALORS
            trace("Ttrans_nss9: Erreur de duplication + normalisation  du champ T3t63 LastCallingNb")
            #erreur = i_retrait_tlv(g_iartout, "T3t63", "")
          FINSI
        FINSI
      SINON
        erreur_660004661 = i_dup_chp_rnisGSM(g_iartin,g_iartout,$Ttrans_nss9::callingNumber,$Tdpvgsm::LastCallingNb,-$NORM:MET_ASN1_NEW_2242,0)
        #QC925
        SI ( erreur_660004661 != 0)
        ALORS
          trace("Ttrans_nss9: Erreur de duplication + normalisation  du champ T3t63 LastCallingNb")
          #erreur = i_retrait_tlv(g_iartout, "T3t63", "")
        FINSI
      FINSI
    FINSI
  FINSI
FINSI

#########################################################
#G3R3 lot2 mapping ABC ajout du T3t64 (RedirectingNb)
##########################################################
redirectNumber_present_660004661 = i_valid_field_n(g_iartin,$Ttrans_nss9::redirectNumber)
SI (redirectNumber_present_660004661)
ALORS
  SI (i_get_art_field(g_iartin,$Ttrans_nss9::redirectNumber-1) == 0)
  ALORS
    redirectNumber_present_660004661=0
  FINSI
FINSI

SI (redirectNumber_present_660004661)
ALORS
  erreur_660004661 = i_ajout_tlv(g_iartout,"T3t64","")
  SI ( i_get_art_field(g_iartin, $Ttrans_nss9::redirectNumber-1) == 2)
  ALORS
    SI (  (i_get_art_fieldtab(g_iartin, $Ttrans_nss9::redirectNumber, 0) ==    4) &&
      (i_get_art_fieldtab(g_iartin, $Ttrans_nss9::redirectNumber, 1) ==    1) &&
      (i_get_art_fieldtab(g_iartin, $Ttrans_nss9::redirectNumber, 2) ==    0) &&
      (i_get_art_fieldtab(g_iartin, $Ttrans_nss9::redirectNumber, 3) == 0x0f)  )
    ALORS
      erreur_660004661 = i_dup_chp_rnisGSM(g_iartin,g_iartout,$Ttrans_nss9::redirectNumber,$Tdpvgsm::RedirectingNb,-$NORM:MET_ASN1_410,0)
      #QC925
      SI ( erreur_660004661 != 0)
      ALORS
        trace("Ttrans_nss9: Erreur de duplication + normalisation  du champ T3t64 RedirectingNb")
        #erreur = i_retrait_tlv(g_iartout, "T3t64", "")
      FINSI
    SINON
      erreur_660004661 = i_dup_chp_rnisGSM(g_iartin,g_iartout,$Ttrans_nss9::redirectNumber,$Tdpvgsm::RedirectingNb,-$NORM:MET_ASN1_NEW_2242,0)
      #QC925
      SI ( erreur_660004661 != 0)
      ALORS
        trace("Ttrans_nss9: Erreur de duplication + normalisation  du champ T3t64 RedirectingNb")
        #erreur = i_retrait_tlv(g_iartout, "T3t64", "")
      FINSI
    FINSI
  SINON
    erreur_660004661 = i_dup_chp_rnisGSM(g_iartin,g_iartout,$Ttrans_nss9::redirectNumber,$Tdpvgsm::RedirectingNb,-$NORM:MET_ASN1_NEW_2242,0)
    #QC925
    SI ( erreur_660004661 != 0)
    ALORS
      trace("Ttrans_nss9: Erreur de duplication + normalisation  du champ T3t64 RedirectingNb")
      #erreur = i_retrait_tlv(g_iartout, "T3t64", "")
    FINSI
  FINSI
FINSI
#/G3R lot2 mapping ABC

#############################################################
#G3R3 lot3 Curling_Free
# Mise a jour du champ T3t69 (PrefItinerance)
##############################################################
SI (TypePrefixe_660004661 == PREFIX_ITI_660004661 || TypePrefixe_660004661 == PREFIX_ITIN_660004661)
ALORS
  erreur_660004661 = i_ajout_tlv(g_iartout, "T3t69", "")
  longueur_660004661 = i_conv_ascii_dcb(pt_prefixe_660004661, pt_prefixe_DCB_660004661)
  erreur_660004661 = i_memcpy_art_field_n(g_iartout, $Tdpvgsm::PrefItinerance, pt_prefixe_DCB_660004661, longueur_660004661)
  erreur_660004661 = i_resize_tlv( g_iartout, "T3t69", "PrefItinerance", longueur_660004661 * 8 )
FINSI


#############################################################
#G3R4 lot1 Prefixe sva
# Mise a jour du champ T3t70 (PrefixeSAV)
##############################################################

SI (TypePrefixe_660004661 == PREFIX_SVA_660004661)
ALORS
# --- Si un prefixe RNSAC sva a ete trouve
  erreur_660004661 = i_ajout_tlv(g_iartout, "T3t70", "")
  longueur_660004661 = i_conv_ascii_dcb(pt_prefixe_660004661, pt_prefixe_DCB_660004661)
  erreur_660004661 = i_memcpy_art_field_n(g_iartout, $Tdpvgsm::PrefixeSVA, pt_prefixe_DCB_660004661, longueur_660004661)
  erreur_660004661 = i_resize_tlv( g_iartout, "T3t70", "PrefixeSVA", longueur_660004661 * 8 )
FINSI

SI (TypePrefixe_660004661 == PREFIX_JOIG_660004661)
ALORS
  erreur_660004661 = i_ajout_tlv(g_iartout, "T3t70", "")
  longueur_660004661 = i_conv_ascii_dcb (pt_prefixe_660004661, pt_prefixe_DCB_660004661)
  erreur_660004661 = i_memcpy_art_field_n(g_iartout, $Tdpvgsm::PrefixeSVA, pt_prefixe_DCB_660004661, longueur_660004661)
  erreur_660004661 = i_resize_tlv( g_iartout, "T3t70", "PrefixeSVA", longueur_660004661 * 8)
FINSI

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

erreur_660004661 = aiguillage2_660004590 (g_iartout12, g_iartout, DISTRIBUTION_SPECIALE_660004661, Multidistribution_Non_660004661)

SI (erreur_660004661 == TRAI_KO_660004661)
ALORS
# QC1005
  trace("<<<__LINE__<<<__FILE__<<< Erreur retour fonction aiguillage2")
  SAUT STOCKE_ERRONE
FINSI

trace("Ttrans_nss9 :Ttrans_nss9 : Fin Distribution")
RETOUR TRAIT_OK
####################################################################


POINT STOCKE_ERRONE

erreur_660004661 = i_make_art_rej(g_iartout12, g_iartout11, code_rejet_660004661)
erreur_660004661 = i_stocke_art(g_iartout11, 0, PT_ERRONE, 0)

RETOUR TRAIT_OK
#----------------------Fin Ttrans_nss9_dis.src --------------
