DEFINITION DUP_TAB_NORMITINERIS_660004676 0
DEFINITION DUP_TAB_NORMROAMERS_660004676 1
DEFINITION Multidistribution_Non_660004676 0
DEFINITION DISTRIBUTION_INCONNU_660004676 1
DEFINITION TRAI_KO_660004676 -1
DEFINITION MODULE_DISTR_660004676 0xA000
DEFINITION ERR_NORM_660004676 0x010
DEFINITION ERR_DUPL_660004676 0x0D0
DEFINITION ERR_DISTR_660004676 0x110
REGISTRE ENTIER erreur_660004676
REGISTRE ENTIER flag_rdt_660004676
REGISTRE ENTIER indice_duptab_660004676
REGISTRE ENTIER digit1_660004676
REGISTRE ENTIER digit2_660004676
REGISTRE ENTIER digit3_660004676
REGISTRE ENTIER digit4_660004676
REGISTRE ENTIER digit5_660004676
REGISTRE ENTIER TON_660004676
REGISTRE ENTIER NPI_660004676
REGISTRE ENTIER dig3_660004676
REGISTRE ENTIER userRate_660004676
REGISTRE ENTIER userProtocol_660004676
REGISTRE ENTIER tranInd_660004676
REGISTRE ENTIER CSDaddValue_660004676
REGISTRE ENTIER date_660004676
REGISTRE ENTIER date_fin_660004676
REGISTRE ENTIER code_rejet_660004676
REGISTRE ENTIER EFFICACE_660004676
REGISTRE ENTIER MODULE_660004676
REGISTRE ENTIER ERREUR_660004676
REGISTRE ENTIER position_660004676
REGISTRE ENTIER longueur_660004676
REGISTRE ENTIER IMSI_OrangeCo_660004676
REGISTRE POINTEUR str_IMSI_660004676
REGISTRE POINTEUR str_MCCMNC_660004676
REGISTRE POINTEUR str_conteneur_660004676
REGISTRE POINTEUR str_exchasciident_660004676
REGISTRE POINTEUR str_exchDCBdent_660004676
REGISTRE POINTEUR pt_localisation_660004676
REGISTRE POINTEUR pt_localisationDCB_660004676
REGISTRE POINTEUR pt_1_660004676
REGISTRE POINTEUR pt_2_660004676
REGISTRE POINTEUR pt_3_660004676
REGISTRE POINTEUR pt_4_660004676
######################################################################################
# Pcode distribution TtMsg_nss9
#
# Historique :
# 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)
# 10/12/2010 - BEA - G3R1 lot4 Verification/Correction des variables (constantes, entiers, pointeurs)
# 14/03/2011 - JLG - G3R2C4 fusion G3R2C3 avec G3R1C600 (ajout champ T3t99)
# 29/02/2012 - JLG -G3R6 QC1005 modif alarme retour aiguillage
# 23/05/2012 - PKH -G3R7 Item Gestion du code MNC pour les MVNOs Lights
# 25/10/2012 - JLG - G3R8 lot2 : CS Fallback, Localisation 4G
# 14/11/2012 - PKH - G3R8 lot3 ajout commentaire champ T3t63 ajoute par duplication 
# 21/11/2012 - JLG - QC1136 champ V3t3 est absent
# 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
# 09/10/2014 - JLG - QC1444 correction supplementaire de la QC1292
# 16/02/2015 - JLG - QC1522
#######################################################################################




#QC396

#G3R7

#G3R7

# /QC396

# Initialisations
pt_localisation_660004676 = "pt_localisation_"
pt_localisationDCB_660004676 = "pt_localisationDCB_"
pt_1_660004676="pt_1_1"
pt_2_660004676="pt_2_2"
pt_3_660004676="pt_3_3"
pt_4_660004676="pt_4_4444444"

EFFICACE_660004676 = 1
MODULE_660004676 = MODULE_DISTR_660004676
ERREUR_660004676 = 0
code_rejet_660004676 = 0

IMSI_OrangeCo_660004676 = 0

#QC396
str_exchasciident_660004676 = "str_exchasciident19191919191919191919191911991919191919191919"
str_exchDCBdent_660004676 = "str_exchDCBdent232323232323232323232323232323232323233223233233"
position_660004676 = 0
longueur_660004676 = 0
# /QC396

#G3R7

str_IMSI_660004676 = "str_IMSI5454545454545454454545454545454454545454545454454545455454544545454545"
str_MCCMNC_660004676 = "str_MCCMNC8686868686868686868686868686686868686868686866868686868668866868686"
str_conteneur_660004676 = "str_conteneur1919191919191919191919191919911919191919911919191919191919199"

i_strcpy(str_IMSI_660004676,"")
i_strcpy(str_MCCMNC_660004676,"")
i_strcpy(str_conteneur_660004676,"")


# OGA 230 g_iartin et redistribution
# ==================================
# copie du CRA original dans le g_iartout12
erreur_660004676 = i_dup_art_id(g_iartin, g_iartout12)
# /OGA 230


# FE_0028 comptabilisation des CRAs issus de la redistribution
date_fin_660004676 = i_get_art_field(g_iartin, $TtMsg_nss9::dfin)
erreur_660004676= i_incr_redist_dist_660004265(date_fin_660004676)

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

SI (flag_rdt_660004676 == 0)
ALORS
  erreur_660004676 = i_add_opt( "E_Redistri2" )
FINSI
erreur_660004676 = i_set_attr_val_n($E_Redistri2::EnvoiRedis, 0)


######### Variables fonctionnelles

#G3R8 lot2
# QC1136
## localisation (pt_localisation)
i_strcpy(pt_localisation_660004676, "")
erreur_660004676 = i_get_art_str(g_iartin, $TtMsg_nss9::1stCalledLocIf, pt_localisation_660004676)
# pt_localisation = 1stCalledLocIf
SI (i_valid_field_n(g_iartin, $TtMsg_nss9::1stCdLocInfEx))
ALORS
  #  localisation = pt_1 + pt_2 + pt_3 ou pt_4 + pt_3 (car pt_4=pt_1+pt_2)
  #  pt_1 = 5 premiers digits de T3t4/1stCalledLocIf
  #  pt_2 = 3 derniers digits de T3t12/1stCalledLocIfExt
  #  pt_3 = 4 derniers digits significatifs de T3t4/1stCalledLocIf (sans 0xF final de bourrage)
  i_get_sub_str (pt_localisation_660004676, 0, 4, pt_1_660004676)
  i_get_sub_str (pt_localisation_660004676, -1, -1, pt_4_660004676)

# QC1522 ne pas prendre en compte dernier quartet si == 0xF
  SI (i_strcmp(pt_4_660004676, "F"))
  ALORS
    i_get_sub_str (pt_localisation_660004676, -4, -1, pt_3_660004676)
  SINON
    i_get_sub_str (pt_localisation_660004676, -5, -2, pt_3_660004676)
  FINSI

  erreur_660004676 = i_get_art_str(g_iartin, $TtMsg_nss9::1stCdLocInfEx, pt_localisation_660004676)
  # pt_localisation = 1stCdLocInfEx
  i_get_sub_str (pt_localisation_660004676, -3, -1, pt_2_660004676)
  erreur_660004676 = i_format_str2( pt_4_660004676, "%s%s", pt_1_660004676, pt_2_660004676)
  erreur_660004676 = i_format_str2( pt_localisation_660004676, "%s%s", pt_4_660004676, pt_3_660004676)
  # pt_localisation=pt_1+pt_2+pt_3 = 5ers digits de 1stCalledLocIf +  3 derniers digits de 1stCdLocInfEx +  4 derniers digits significatifs de 1stCgLocIf
FINSI
trace2("<<<__LINE__<<<__FILE__<< pt_localisation=<%s>", pt_localisation_660004676, "")


## IMSI_OrangeCo
SI ( digit1_660004676==2 && digit2_660004676==0 && digit3_660004676==8 && digit4_660004676==0 && digit5_660004676==1)
ALORS
# Cas des abonnes ITINERIS
#la fonction i_rm_escape_char_end a ete commente c'est pas la peine de la remplacer
#   erreur = i_rm_escape_char_end(g_iartin, $TtMsg_nss9::serviceCentAdr)
  IMSI_OrangeCo_660004676 = 1
SINON
  SI (digit1_660004676==2 && digit2_660004676==0 && digit3_660004676==8)
  ALORS
    erreur_660004676 = i_get_art_str(g_iartin, $TtMsg_nss9::IMSI, str_IMSI_660004676)
    i_get_sub_str(str_IMSI_660004676, 0, 4, str_MCCMNC_660004676)
    erreur_660004676 = i_format_str2(str_conteneur_660004676, "%s%s", "L_", str_MCCMNC_660004676)
    SI (i_get_tab_field("MVNO", date_fin_660004676, str_conteneur_660004676) != g_inull)
    ALORS
      IMSI_OrangeCo_660004676 = 1
    SINON
      IMSI_OrangeCo_660004676 = 0
    FINSI
  SINON
    # Cas des ROAMERS
    IMSI_OrangeCo_660004676 = 0
  FINSI
FINSI

#G3R7
#####################################################################
# Choix de la table de duplication
#####################################################################
digit1_660004676 = i_get_art_fieldtab(g_iartin, $TtMsg_nss9::IMSI, 0)
digit2_660004676 = i_get_art_fieldtab(g_iartin, $TtMsg_nss9::IMSI, 1)
digit3_660004676 = i_get_art_fieldtab(g_iartin, $TtMsg_nss9::IMSI, 2)
digit4_660004676 = i_get_art_fieldtab(g_iartin, $TtMsg_nss9::IMSI, 3)
digit5_660004676 = i_get_art_fieldtab(g_iartin, $TtMsg_nss9::IMSI, 4)

SI IMSI_OrangeCo_660004676
ALORS
  indice_duptab_660004676 = DUP_TAB_NORMITINERIS_660004676
SINON
  #Cas des ROAMERS
  # --- SUppression des caracteres speciaux 'a' a 'e'
  TON_660004676 = i_get_art_fieldtab(g_iartin, $TtMsg_nss9::serviceCentAdr, 0)
  NPI_660004676 = i_get_art_fieldtab(g_iartin, $TtMsg_nss9::serviceCentAdr, 1)
  SI (TON_660004676 == 2 && (NPI_660004676 == 0||NPI_660004676 == 1))
  ALORS
    dig3_660004676 = i_get_art_fieldtab(g_iartin, $TtMsg_nss9::serviceCentAdr, 2)
    SI (dig3_660004676==0)
    ALORS
      indice_duptab_660004676 = DUP_TAB_NORMROAMERS_660004676
    SINON
      indice_duptab_660004676 = DUP_TAB_NORMROAMERS_660004676
    FINSI
  SINON
    indice_duptab_660004676 = DUP_TAB_NORMROAMERS_660004676
  FINSI
#         indice_duptab = DUP_TAB_NORMROAMERS
FINSI


trace1("TtMsg_nss9: Indice de la table de duplication: %d", indice_duptab_660004676)

####################################################################
# duplication au format DPV TLV
####################################################################

erreur_660004676 = i_dup_art_tab_choix(g_iartin,g_iartout,"Tdpvgsm",indice_duptab_660004676)
SI (erreur_660004676 != 0)
ALORS
  ERREUR_660004676 = ERR_DUPL_660004676
  code_rejet_660004676 = MODULE_660004676 + ERREUR_660004676 + EFFICACE_660004676
  erreur_660004676 = i_PlvMessEmettre(8424,2,g_iartout12,"",1,code_rejet_660004676,0,0)
  SAUT STOCKE_ERRONE
FINSI

#le 2Val ne marche pas correctement alors

#V3t1.1 type    :- : :CSTE :01
#V3t1.2 tentite :- : :CSTE :00
#V3t1.3 idemet  :D :D:1VAL :exchangeIdent
##################################################################
# QC396, QC1292
# T3t1.3 idemet
##################################################################
# QC1444
i_strcpy(str_exchasciident_660004676,"")
i_strcpy(str_exchDCBdent_660004676,"")
erreur_660004676 = i_get_art_str(g_iartin,$TtMsg_nss9::exchasciident,str_exchasciident_660004676)
trace2("TtMsg_nss9: ################# str_exchasciident = %s ################", str_exchasciident_660004676, "")
position_660004676 = RECHERCHE_CARACTERE_660004265(str_exchasciident_660004676," ")
trace1("TtMsg_nss9: ############ position= %d ###########",position_660004676)
SI ( position_660004676 > -1)
ALORS
  i_get_sub_str (str_exchasciident_660004676, 0, position_660004676 - 1 ,str_exchasciident_660004676)
  trace2("TtMsg_nss9: ################# str_exchasciident = %s ################", str_exchasciident_660004676, "")
FINSI
longueur_660004676 = i_conv_ascii_dcb (str_exchasciident_660004676,str_exchDCBdent_660004676 )
SI (longueur_660004676 > 9)
ALORS
  longueur_660004676 = 9
FINSI
erreur_660004676 = i_memcpy_art_field_n(g_iartout, $Tdpvgsm::idemet, str_exchDCBdent_660004676, longueur_660004676)
#Fin QC396

#V3t1.4 IMSI    :D :D:1VAL :IMSI

#V3t1.5 DATE    :D :D:1VAL :DATE
date_660004676 =  i_get_art_field(g_iartin,$TtMsg_nss9::ddebut)
erreur_660004676 = i_set_art_field(g_iartout,$Tdpvgsm::DATE, date_660004676)

#V3t1.6 DUREE   :D :D:1VAL :NbSms
#V3t1.7 svcsup  :- : :MSET :ff:1
#V3t1.8 tlserv  :- : :CSTE :33
#V3t1.9 support1:- : :MSET :ff

#V3t1.10 systype :- : :MSET :00
# G3R8 lot2
SI (i_valid_field_n(g_iartin, $TtMsg_nss9::1stCdLocInfEx))
ALORS
  erreur_660004676 = i_set_art_field(g_iartout, $Tdpvgsm::systype, 0x06)
SINON
  SI (i_valid_field_n(g_iartin, $TtMsg_nss9::rNCidOf1stRNC))
  ALORS
    erreur_660004676 = i_set_art_field(g_iartout, $Tdpvgsm::systype, 0x01)
  FINSI
FINSI

#V3t1.11 reserve2:- : :MSET :ff:1
#V3t1.12 origine :- : :MSET :ff:1
#V3t1.13 indeff  :- : :CSTE: 00
#V3t1.14 tterm   :- : :MSET :ff:1
#V3t1.15 indtax  :- : :MSET:ff:1
#V3t1.16 nbUT    :- : :MSET :00:4
#V3t1.17 chgcar  :- : :MSET :ff:2
#V3t1.18 couleur :- : :MSET :ff
#V3t2
#si dup=0 alors idpart :- :E:TRUNC+NORM :serviceCentAdr :TRUNC_IMSI_ITINERIS:$MET_ASN1_NEW_2242
#si dup=1 alors idpart :- :E:TRUNC+NORM :serviceCentAdr :TRUNC_ROAMERS:$ROAMERS_IDPART

#V3t3 local   :- :E:1VAL :1stCalledLocIf
SI (i_valid_field_n(g_iartin, $TtMsg_nss9::1stCdLocInfEx))
ALORS
  longueur_660004676 = i_conv_ascii_dcb(pt_localisation_660004676, pt_localisationDCB_660004676)
  erreur_660004676 = i_resize_tlv(g_iartout, "T3t3", "local", longueur_660004676*8)
  erreur_660004676 = i_memcpy_art_field_n(g_iartout, $Tdpvgsm::local, pt_localisationDCB_660004676, longueur_660004676)
FINSI

#V3t4 MSISDN  :- :E:NORM :calledNumber :-:$MET_ASN1_NEW
#V3t5 IMEI    :- :E:1VAL :IMEI

#V4t30.1 timeInCE:- : :MSET :11:7
#V4t30.2 eec     :- : :CSTE :-1
# QC1331
#erreur=set_timeInCE_EEC(0)
########### Date_Audit
erreur_660004676 = i_set_art_field(g_iartout, $Tdpvgsm::timeInCE,  i_DHgetLocalTime(4, 7, i_date_audit()))
########### eec
# QC1405
SI (g_ieec > 500)
ALORS
  erreur_660004676 = i_set_art_field(g_iartout, $Tdpvgsm::eec, g_ieec - 500)
SINON
  erreur_660004676 = i_set_art_field(g_iartout, $Tdpvgsm::eec, g_ieec)
FINSI
#/QC1405

#V3t33 SMSrecepMSISDN
## on teste que la longueur du champ origAddress est > 1 octet (3 digits mini)
## si oui, la normalisation sera OK car l'automate CIT_IDENT est de la forme [0-F][O-F][0-E]* => [0-E]*
## sinon, il y aurait un echec de normalisation, donc on ne duplique pas ce champ
erreur_660004676 = i_get_art_field(g_iartin, $TtMsg_nss9::origAddress-1)
SI (erreur_660004676 > 1)
ALORS
  erreur_660004676 = i_dup_art_tab_choix(g_iartin, g_iartout4, "TnormalTlv", indice_duptab_660004676)
  trace1("TtMsg_nss9: retour i_dup_art_tab_choix sur TnormalTlv = %d",erreur_660004676)
  SI( erreur_660004676 == 0 )
  ALORS
    trace("*TtMsg_nss9: * dup T3t33 / TnormalTlv")
    erreur_660004676 = i_ajout_tlv(g_iartout, "T3t33", "")
    erreur_660004676 = i_dup_chp_rnisGSM(g_iartout4, g_iartout, $TnormalTlv::buf, $Tdpvgsm::SMSrecepMSISDN, -$NORM:AUT_IDENT, 0)
    SI( erreur_660004676 != 0 )
    ALORS
      trace("TtMsg_nss9 : Erreur duplication champ SMSrecepMSISDN")
      ERREUR_660004676 = ERR_NORM_660004676
      code_rejet_660004676 = MODULE_660004676 + ERREUR_660004676 + EFFICACE_660004676
      erreur_660004676 = i_PlvMessEmettre(8425, 2, g_iartout12, "", 2, code_rejet_660004676, "SMSrecepMSISDN", 0)
      SAUT STOCKE_ERRONE
    FINSI
  FINSI
FINSI





#V3t37 CSDaddInfo
SI (i_get_art_field(g_iartout, $Tdpvgsm::svcsup) == 0x17 || i_get_art_field(g_iartout, $Tdpvgsm::svcsup) == 0x1F)
ALORS
  userRate_660004676     = 0x08
  userProtocol_660004676 = 0x04
  tranInd_660004676 = 0x00
SINON
  userRate_660004676     = 0xFF
  userProtocol_660004676 = 0xFF
  tranInd_660004676 = 0xFF
FINSI
SI (userRate_660004676 != 0xFF || userProtocol_660004676 != 0xFF || tranInd_660004676 != 0xFF)
ALORS
  erreur_660004676 = i_ajout_tlv(g_iartout,"T3t37", "")
  erreur_660004676 = i_resize_tlv(g_iartout,"T3t37", "CSDaddInfo", 3)
  CSDaddValue_660004676 = userRate_660004676*0x10000 + userProtocol_660004676*0x100 + tranInd_660004676
  erreur_660004676 = i_set_art_field(g_iartout, $Tdpvgsm::CSDaddInfo, CSDaddValue_660004676)
FINSI

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

#G3R8 Lot3 ajout V3t63
#si dup=0 alors LastCallingNb :-   :E:TRUNC+NORM :serviceCentAdr :TRUNC_IMSI_ITINERIS:$MET_ASN1_NEW_2242
#si dup=1 alors LastCallingNb :-      :E:TRUNC+NORM :serviceCentAdr :TRUNC_ROAMERS:$ROAMERS_IDPART

#V3t55
SI !(i_valid_field_n(g_iartout, $Tdpvgsm::GFlag2))
ALORS
  erreur_660004676 = i_ajout_tlv(g_iartout, "T3t55", "")
FINSI

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

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


erreur_660004676 = aiguillage2_660004590 (g_iartout12, g_iartout, DISTRIBUTION_INCONNU_660004676, Multidistribution_Non_660004676)
SI (erreur_660004676 == TRAI_KO_660004676)
ALORS
# QC1005
  trace("<<<__LINE__<<<__FILE__<<< Erreur retour fonction aiguillage2")
  SAUT STOCKE_ERRONE
FINSI


trace("**** TtMsg_nss9 : Fin de distributon pcode OK ****")
RETOUR TRAIT_OK



POINT STOCKE_ERRONE
erreur_660004676 = i_make_art_rej(g_iartout12, g_iartout11, code_rejet_660004676)
erreur_660004676 = i_stocke_art(g_iartout11, 0, PT_ERRONE, 0)
trace("TtMsg_nss9 : erreur de duplication => Fin de traitement")
RETOUR TRAIT_OK
#--------------------------------- TtMsg_nss9_dis.src -----------------------------------
