DEFINITION C_Tdpv_660004717 "Tdpvgsm"
DEFINITION C_Article_660004717 "TmmTelTas"
DEFINITION Multidistribution_Non_660004717 0
DEFINITION TRAI_KO_660004717 -1
DEFINITION DISTRIBUTION_INCONNU_660004717 1
DEFINITION MODULE_DISTR_660004717 0xA000
DEFINITION EFFICACE_660004717 1
DEFINITION NUMTAB_660004717 4
DEFINITION OFFSET_660004717 11
DEFINITION ENTRANT_660004717 0x01
DEFINITION SORTANT_660004717 0x00
DEFINITION RENVOIG_660004717 0x06
DEFINITION RENVOIM_660004717 0x02
REGISTRE ENTIER erreur_660004717
REGISTRE ENTIER code_rejet_660004717
REGISTRE ENTIER flag_rdt_660004717
REGISTRE ENTIER date_cra_660004717
REGISTRE ENTIER date_fin_660004717
REGISTRE ENTIER date_audit_660004717
REGISTRE ENTIER Duree_660004717
REGISTRE ENTIER res_660004717
REGISTRE ENTIER indice_660004717
REGISTRE ENTIER roleofnode_660004717
REGISTRE ENTIER causeforrecclos_660004717
REGISTRE ENTIER scereturncode_660004717
REGISTRE ENTIER TransReturnCode_660004717
REGISTRE ENTIER transactiontype_660004717
REGISTRE ENTIER servicetype_660004717
REGISTRE ENTIER Mode_ServiceType6_660004717
REGISTRE ENTIER type_CRA_660004717
REGISTRE ENTIER b_RENVOI_660004717
REGISTRE ENTIER b_conference_660004717
REGISTRE ENTIER longueur_660004717
REGISTRE ENTIER b_Entrant_Service6_660004717
REGISTRE POINTEUR pt_AX_IDEMET_660004717
REGISTRE POINTEUR pt_1_660004717
REGISTRE POINTEUR pt_cgiInfo_660004717
REGISTRE POINTEUR pt_MCC_1_660004717
REGISTRE POINTEUR pt_MCC_2_660004717
REGISTRE POINTEUR pt_MCC_3_660004717
REGISTRE POINTEUR pt_MCC_660004717
REGISTRE POINTEUR pt_MNC_1_660004717
REGISTRE POINTEUR pt_MNC_2_660004717
REGISTRE POINTEUR pt_MNC_3_660004717
REGISTRE POINTEUR pt_MNC_660004717
REGISTRE POINTEUR pt_CI_660004717
REGISTRE POINTEUR pt_CallingLoc_ASCII_660004717
REGISTRE POINTEUR pt_CallingLoc_DCB_660004717
REGISTRE POINTEUR pt_CallingURI_ASCII_660004717
REGISTRE POINTEUR pt_CallingURI_ASCII_NORM_660004717
REGISTRE POINTEUR pt_CallingURI_ASCII_NORM_DCB_660004717
REGISTRE POINTEUR pt_subIdData_ASCII_660004717
REGISTRE POINTEUR pt_CalledAdr_660004717
REGISTRE POINTEUR pt_CalledAdr_NORM_660004717
REGISTRE POINTEUR pt_CalledAdr_NORM_DCB_660004717
REGISTRE POINTEUR pt_renvoiAssociated_ASCII_660004717
REGISTRE POINTEUR pt_renvoiAssociated_DCB_660004717
REGISTRE POINTEUR pt_servedIMEI_660004717
REGISTRE POINTEUR pt_IMEI_DCB_660004717
######################################################################
#
#    TmmTelTas_dist.src
#
#
# article CRA TmmTelTas ASN1 => type DPV TLV = 0x83 (T1=0x69 T2=0x02)
#
# 06/11/2014 - RHE - G5R3 lot2 : Creation
# 05/12/2014 - RHE - G5R3 lot3 ajout champ T4t99.2
# 05/12/2014 - RHE - G5R3 lot3 : QC1468 calcul type SORTANT
# 10/12/2014 - RHE - G5R3 lot3 QC1473 alimentation du champ T3t5/IMEI par T3t8/servedIMEI
# 15/12/2014 - RHE - G5R3 lot3 QC1472
# 13/01/2015 - RHE - G5R3 lot3 QC1492 modification d'alimentation du champ V3t1.9/support1
# 16/01/2015 - RHE - G5R3 lot3 QC1464 codage cgiInfo et calacil callingLoc
# 22/01/2015 - RHE - G5R3 lot3 envoi en erronne si le resultat de normalisation est une chaine ASCII
# 05/02/2015 - JLG - G5R3 QC1513 evolution : privilegier la prise en compte du sIP-URI
# 06/02/2015 - JLG - G5R3 QC1514 evolution : sceDelivStartT plus obligatoire
# 24/02/2015 - RHE - G5R3 QC1523 evolution : suppression de la variable renvoiAssociated
# 23/04/2015 - JLG - G5R4 QC1549, evolution des T4 du T3t5 Calling sequence de LCPA_sIP_URI et LCPA_tEL_URI
######################################################################










pt_AX_IDEMET_660004717 = "pt_AX_IDEMET11111111"
pt_1_660004717 = "pt_1_123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456"
pt_cgiInfo_660004717 = "pt_cgiInfo_123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789"
pt_MCC_1_660004717 = "pt_MCC_1"
pt_MCC_2_660004717 = "pt_MCC_2"
pt_MCC_3_660004717 = "pt_MCC_3"
pt_MCC_660004717 = "pt_MCC0123456789"
pt_MNC_1_660004717 = "pt_MNC_1"
pt_MNC_2_660004717 = "pt_MNC_2"
pt_MNC_3_660004717 = "pt_MNC_3"
pt_MNC_660004717 =   "pt_MNC 0123456789"
pt_CI_660004717 = "pt_CI012345678901234567890123456789"
pt_CallingLoc_ASCII_660004717 = "pt_CallingLoc_ASCII01234567890123456789012345678901234567890123456789"
pt_CallingLoc_DCB_660004717 = "pt_CallingLoc_DCB01234567890123456789012345678901234567890123456789"
pt_CallingURI_ASCII_660004717 = "pt_CallingURI_ASCII0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789111111111"
pt_CallingURI_ASCII_NORM_660004717 = "pt_CallingURI_ASCII_NORM01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567891234"
pt_CallingURI_ASCII_NORM_DCB_660004717 = "pt_CallingURI_ASCII_NORM_DCB0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
pt_subIdData_ASCII_660004717 = "pt_subIdData_ASCII01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
pt_CalledAdr_660004717 = "pt_CalledAdr01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345"
pt_CalledAdr_NORM_660004717 = "pt_CalledAdr_NORM012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678912345123456"
pt_CalledAdr_NORM_DCB_660004717 = "pt_CalledAdr_NORM_DCB01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567891234567"
pt_renvoiAssociated_ASCII_660004717 = "pt_renvoiAssociated_ASCII0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
pt_renvoiAssociated_DCB_660004717 = "pt_renvoiAssociated_DCB0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
pt_servedIMEI_660004717 = "pt_servedIMEI012"
pt_IMEI_DCB_660004717 = "pt_IMEI_DCB01234"

# Initialisations

i_strcpy(pt_AX_IDEMET_660004717, "")
i_strcpy(pt_1_660004717, "")
i_strcpy(pt_cgiInfo_660004717, "")
i_strcpy(pt_MCC_1_660004717, "")
i_strcpy(pt_MCC_2_660004717, "")
i_strcpy(pt_MCC_3_660004717, "")
i_strcpy(pt_MCC_660004717, "")
i_strcpy(pt_MNC_1_660004717, "")
i_strcpy(pt_MNC_2_660004717, "")
i_strcpy(pt_MNC_3_660004717, "")
i_strcpy(pt_MNC_660004717, "")
i_strcpy(pt_CI_660004717, "")
i_strcpy(pt_CallingLoc_ASCII_660004717, "")
i_strcpy(pt_CallingLoc_DCB_660004717, "")
i_strcpy(pt_CallingURI_ASCII_660004717, "")
i_strcpy(pt_CallingURI_ASCII_NORM_660004717, "")
i_strcpy(pt_CallingURI_ASCII_NORM_DCB_660004717, "")
i_strcpy(pt_subIdData_ASCII_660004717, "")
i_strcpy(pt_CalledAdr_660004717, "")
i_strcpy(pt_CalledAdr_NORM_660004717, "")
i_strcpy(pt_CalledAdr_NORM_DCB_660004717, "")
i_strcpy(pt_renvoiAssociated_ASCII_660004717, "")
i_strcpy(pt_renvoiAssociated_DCB_660004717, "")
i_strcpy(pt_servedIMEI_660004717, "")
i_strcpy(pt_IMEI_DCB_660004717, "")

trace("TmmTelTas : Debut DISTRIBUTION")

date_cra_660004717 = i_get_art_field(g_iartin, $TmmTelTas::ddebut)
date_fin_660004717 = i_get_art_field(g_iartin, $TmmTelTas::dfin)
date_audit_660004717 = i_DHgetLocalTime(NUMTAB_660004717, 7, i_date_audit())
Duree_660004717 = i_get_art_field(g_iartin, $TmmTelTas::dduree)

#trace1("<<<__LINE__<<<__FILE__<<< TmmTelTas_dist: date_cra = %d ", date_cra)
#trace1("<<<__LINE__<<<__FILE__<<< TmmTelTas_dist: date_fin = %d ", date_fin)
#trace1("<<<__LINE__<<<__FILE__<<< TmmTelTas_dist: date_audit = %d ", date_audit)
#trace1("<<<__LINE__<<<__FILE__<<< TmmTelTas_dist: Duree = %d ", Duree)


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

SI (flag_rdt_660004717 == 0)
ALORS
  erreur_660004717 = i_add_opt( "E_Redistri2" )
FINSI
erreur_660004717 = i_set_attr_val_n( $E_Redistri2::EnvoiRedis, 0)

# Cpt applicatif CPT_RDT=1509 (REDISTRIBUTION)
erreur_660004717= i_incr_redist_dist_660004265(date_fin_660004717)

############################################################################
# Variables fonctionnelles
############################################################################


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

roleofnode_660004717 = i_get_art_field(g_iartin,$TmmTelTas::roleOfNode)
transactiontype_660004717 = i_get_art_field(g_iartin,$TmmTelTas::transactionType)
#trace1("<<<__LINE__<<<__FILE__<<< TmmTelTas_dist: roleofnode = %d ", roleofnode)
#trace1("<<<__LINE__<<<__FILE__<<< TmmTelTas_dist: transactiontype = %d ", transactiontype)

#G5R3 lot 3
# recherche de serviceTypexx = 6
servicetype_660004717 = -1
indice_660004717 = 1

POINT DEBUT_RECHERCHE_servicetype

servicetype_660004717 = i_get_art_field(g_iartin,$TmmTelTas::serviceType00 + (OFFSET_660004717 * (indice_660004717 - 1)))
SI (servicetype_660004717 == -1)
ALORS
  SAUT FIN_RECHERCHE_servicetype
FINSI
SI (servicetype_660004717 != 6)
ALORS
  indice_660004717 = indice_660004717 +1
  SAUT DEBUT_RECHERCHE_servicetype
FINSI
POINT FIN_RECHERCHE_servicetype
#trace1("<<<__LINE__<<<__FILE__<<< TmmTelTas_dist: servicetype = %d ", servicetype)

#QC1523 suppression de renvoiAssociated
# Mode_ServiceType6, renvoiAssociated
# si servicetype = 6 et roleOfNode = 0 et TransactionType = 5
Mode_ServiceType6_660004717 = -1
SI (servicetype_660004717 == 6 && roleofnode_660004717 == 0 && transactiontype_660004717 == 5)
ALORS
  Mode_ServiceType6_660004717 = i_get_art_field(g_iartin,$TmmTelTas::serviceMode00 + (OFFSET_660004717 * (indice_660004717 - 1)))
  #erreur = i_get_art_str(g_iartin,$TmmTelTas::associatedAdr00 + (OFFSET * (indice - 1)), pt_renvoiAssociated_ASCII)
  #trace1("<<<__LINE__<<<__FILE__<<< TmmTelTas_dist: Mode_ServiceType6 = %d ", Mode_ServiceType6)
  #trace2("<<<__LINE__<<<__FILE__<<< TmmTelTas_dist: pt_renvoiAssociated_ASCII:< %s > ", pt_renvoiAssociated_ASCII, "")
FINSI

# type_CRA: ENTRANT (0x01), SORTANT (0x00), RENVOIG (0x06), RENVOIM (0x02)
SI (roleofnode_660004717 == 1 && (transactiontype_660004717 == 3 || transactiontype_660004717 == 6 || transactiontype_660004717 == 7))
ALORS
  type_CRA_660004717 = ENTRANT_660004717
  #trace1("<<<__LINE__<<<__FILE__<<< TmmTelTas_dist: type_CRA (ENTRANT) = %d ", type_CRA)
FINSI

# QC1468
#SI (roleofnode == 0 && (transactiontype == 2 || (transactiontype == 5 && Mode_ServiceType6 == -1)))
SI (roleofnode_660004717 == 0 && transactiontype_660004717 == 2 )
ALORS
  type_CRA_660004717 = SORTANT_660004717
  #trace1("<<<__LINE__<<<__FILE__<<< TmmTelTas_dist: type_CRA (SORTANT) = %d ", type_CRA)
FINSI

SI (roleofnode_660004717 == 0 && transactiontype_660004717 == 5 && Mode_ServiceType6_660004717 == 0)
ALORS
  type_CRA_660004717 = RENVOIG_660004717
  #trace1("<<<__LINE__<<<__FILE__<<< TmmTelTas_dist: type_CRA (RENVOIG) = %d ", type_CRA)
FINSI

SI (roleofnode_660004717 == 0 && transactiontype_660004717 == 5 && Mode_ServiceType6_660004717 > 0)
ALORS
  type_CRA_660004717 = RENVOIM_660004717
  #trace1("<<<__LINE__<<<__FILE__<<< TmmTelTas_dist: type_CRA (RENVOIM) = %d ", type_CRA)
FINSI

SI (type_CRA_660004717 == RENVOIM_660004717 || type_CRA_660004717 == RENVOIG_660004717)
ALORS
  b_RENVOI_660004717 = 1
SINON
  b_RENVOI_660004717 = -1
FINSI
#trace1("<<<__LINE__<<<__FILE__<<< TmmTelTas_dist: b_RENVOI = %d ", b_RENVOI)

#G5R3 lot3
SI (type_CRA_660004717 == ENTRANT_660004717 && servicetype_660004717 == 6)
ALORS
  b_Entrant_Service6_660004717 = 1
SINON
  b_Entrant_Service6_660004717 = -1
FINSI


########## Variables fonctionnelles du module ##########

# AX_IDEMET
erreur_660004717 = i_format_str2( pt_1_660004717, "%s%s", "AX_IDEMET_", i_LireEECSGTQS(g_ieec))
i_strcpy(pt_AX_IDEMET_660004717, i_get_tab_field("VariableContexte", date_cra_660004717, pt_1_660004717))
#trace2("<<<__LINE__<<<__FILE__<<< TmmTelTas_dist: pt_AX_IDEMET:< %s > ", pt_AX_IDEMET, "")

# TransReturnCode
causeforrecclos_660004717 = i_get_art_field(g_iartin,$TmmTelTas::causeForRecClos)
scereturncode_660004717 = i_get_art_field(g_iartin,$TmmTelTas::sceReturnCode)
#trace1("<<<__LINE__<<<__FILE__<<< TmmTelTas_dist: causeforrecclos = %d ", causeforrecclos)
#trace1("<<<__LINE__<<<__FILE__<<< TmmTelTas_dist: scereturncode = %d ", scereturncode)
SI (causeforrecclos_660004717 == 0)
ALORS
  TransReturnCode_660004717 = 0x00
  SAUT FIN_TransReturnCode
FINSI
SI (causeforrecclos_660004717 == 3)
ALORS
  TransReturnCode_660004717 = 0x07
  SAUT FIN_TransReturnCode
FINSI
SI (causeforrecclos_660004717 == 1 && scereturncode_660004717 >= 300 && scereturncode_660004717 < 400)
ALORS
  TransReturnCode_660004717 = 0xC1
  SAUT FIN_TransReturnCode
FINSI
SI (causeforrecclos_660004717 == 1 && scereturncode_660004717 >= 400 && scereturncode_660004717 < 500)
ALORS
  TransReturnCode_660004717 = 0xC2
  SAUT FIN_TransReturnCode
FINSI
SI (causeforrecclos_660004717 == 1 && scereturncode_660004717 >= 500 && scereturncode_660004717 < 600)
ALORS
  TransReturnCode_660004717 = 0xC3
  SAUT FIN_TransReturnCode
FINSI
SI (causeforrecclos_660004717 == 1 && scereturncode_660004717 >= 600)
ALORS
  TransReturnCode_660004717 = 0xC4
  SAUT FIN_TransReturnCode
FINSI
SI (causeforrecclos_660004717 == 1 && scereturncode_660004717 < 300)
ALORS
  TransReturnCode_660004717 = 0xC5
  SAUT FIN_TransReturnCode
FINSI
TransReturnCode_660004717 = 0xFF
POINT FIN_TransReturnCode
#trace1("<<<__LINE__<<<__FILE__<<< TmmTelTas_dist: TransReturnCode = %d ", TransReturnCode)

# CallingLoc
# QC1464
SI ((i_valid_field_n(g_iartin, $TmmTelTas::cgiInfo))
  && (i_valid_field_n(g_iartin, $TmmTelTas::cgiType)))
ALORS
  erreur_660004717 =  i_get_art_str(g_iartin, $TmmTelTas::cgiInfo, pt_cgiInfo_660004717)
  #trace2("<<<__LINE__<<<__FILE__<<< TmmTelTas_dist: pt_cgiInfo (cgiInfo):< %s > ", pt_cgiInfo, "")
  i_get_sub_str(pt_cgiInfo_660004717,1,1,pt_MCC_1_660004717)
  #trace2("<<<__LINE__<<<__FILE__<<< TmmTelTas_dist: pt_MCC_1:< %s > ", pt_MCC_1, "")
  i_get_sub_str(pt_cgiInfo_660004717,0,0,pt_MCC_2_660004717)
  #trace2("<<<__LINE__<<<__FILE__<<< TmmTelTas_dist: pt_MCC_2:< %s > ", pt_MCC_2, "")
  i_get_sub_str(pt_cgiInfo_660004717,3,3,pt_MCC_3_660004717)
  #trace2("<<<__LINE__<<<__FILE__<<< TmmTelTas_dist: pt_MCC_3:< %s > ", pt_MCC_3, "")
  erreur_660004717 = i_format_str2( pt_1_660004717, "%s%s", pt_MCC_1_660004717, pt_MCC_2_660004717)
  erreur_660004717 = i_format_str2( pt_MCC_660004717, "%s%s", pt_1_660004717, pt_MCC_3_660004717)
  #trace2("<<<__LINE__<<<__FILE__<<< TmmTelTas_dist: pt_MCC:< %s > ", pt_MCC, "")

  i_get_sub_str(pt_cgiInfo_660004717,5,5,pt_MNC_1_660004717)
  #trace2("<<<__LINE__<<<__FILE__<<< TmmTelTas_dist: pt_MNC_1:< %s > ", pt_MNC_1, "")
  i_get_sub_str(pt_cgiInfo_660004717,4,4,pt_MNC_2_660004717)
  #trace2("<<<__LINE__<<<__FILE__<<< TmmTelTas_dist: pt_MNC_2:< %s > ", pt_MNC_2, "")
  i_get_sub_str(pt_cgiInfo_660004717,2,2,pt_MNC_3_660004717)
  #trace2("<<<__LINE__<<<__FILE__<<< TmmTelTas_dist: pt_MNC_3:< %s > ", pt_MNC_3, "")
  erreur_660004717 = i_format_str2( pt_1_660004717, "%s%s", pt_MNC_1_660004717, pt_MNC_2_660004717)
  SI (i_strcmp(pt_MNC_3_660004717, "F") == 0)
  ALORS
    i_strcpy(pt_MNC_660004717, pt_1_660004717)
  SINON
    erreur_660004717 = i_format_str2( pt_MNC_660004717, "%s%s", pt_1_660004717, pt_MNC_3_660004717)
  FINSI
  #trace2("<<<__LINE__<<<__FILE__<<< TmmTelTas_dist: pt_MNC:< %s > ", pt_MNC, "")
  SI (i_get_art_field(g_iartin,$TmmTelTas::cgiType) == 1)
  ALORS
    i_get_sub_str(pt_cgiInfo_660004717,7,-1,pt_CI_660004717)
    #trace2("<<<__LINE__<<<__FILE__<<< TmmTelTas_dist: cgiType = 1 -> CI:< %s > ", pt_CI, "")
  SINON
    i_get_sub_str(pt_cgiInfo_660004717,6,-1,pt_CI_660004717)
    #trace2("<<<__LINE__<<<__FILE__<<< TmmTelTas_dist: cgiType = 0 -> pt_CI:< %s > ", pt_CI, "")
  FINSI
  erreur_660004717 = i_format_str2( pt_1_660004717, "%s%s", pt_MCC_660004717, pt_MNC_660004717)
  erreur_660004717 = i_format_str2( pt_CallingLoc_ASCII_660004717, "%s%s", pt_1_660004717, pt_CI_660004717)
  #trace2("<<<__LINE__<<<__FILE__<<< TmmTelTas_dist: pt_CallingLoc_ASCII:< %s > ", pt_CallingLoc_ASCII, "")
FINSI

# CallingURI
# QC1513 Analyse pour privilegier la prise en compte du sIP-URI dans le cas ou les 2 informations sIP-URI et tEL-URI sont transmises
# QC1549
SI (i_valid_field_n(g_iartin, $TmmTelTas::callingSipAdr01))
ALORS
  erreur_660004717 =  i_get_art_str(g_iartin, $TmmTelTas::callingSipAdr01, pt_CallingURI_ASCII_660004717)
SINON
  SI (i_valid_field_n(g_iartin, $TmmTelTas::callingSipAdr02))
  ALORS
    erreur_660004717 =  i_get_art_str(g_iartin, $TmmTelTas::callingSipAdr02, pt_CallingURI_ASCII_660004717)
  SINON
    SI (i_valid_field_n(g_iartin, $TmmTelTas::callingTelAdr01))
    ALORS
      erreur_660004717 =  i_get_art_str(g_iartin, $TmmTelTas::callingTelAdr01, pt_CallingURI_ASCII_660004717)
    SINON
      erreur_660004717 =  i_get_art_str(g_iartin, $TmmTelTas::callingTelAdr02, pt_CallingURI_ASCII_660004717)
    FINSI
  FINSI
FINSI

# b_conference
b_conference_660004717 = -1
indice_660004717 = 1
POINT DEBUT_RECHERCHE_conference
SI !(i_valid_field_n(g_iartin,$TmmTelTas::serviceType00 + (OFFSET_660004717 * (indice_660004717 - 1))))
ALORS
  SAUT FIN_RECHERCHE_conference
FINSI
servicetype_660004717 = i_get_art_field(g_iartin,$TmmTelTas::serviceType00 + (OFFSET_660004717 * (indice_660004717 - 1)))
SI (servicetype_660004717 == 11)
ALORS
  b_conference_660004717 = 1
SINON
  indice_660004717 = indice_660004717 +1
  SAUT DEBUT_RECHERCHE_conference
FINSI
POINT FIN_RECHERCHE_conference
#trace1("<<<__LINE__<<<__FILE__<<< TmmTelTas_dist: b_conference = %d ", b_conference)


#################### Normalisation et troncature ####################
#
#   Ces traitements sont realises par la fonction NORMA_PRIMS:
#     suppression des prefixe: tel: et sip:
#     suppression si le 1er digit est +
#     suppresion des caracteres DTMF
#     suppression si les 2 premiers digits valent 00
#     suppression des suffixes a partir du caracteres @


# V3t6/CalledAdr
erreur_660004717 =  i_get_art_str(g_iartin, $TmmTelTas::CalledAdr, pt_CalledAdr_660004717)
i_strcpy (pt_CalledAdr_NORM_660004717, NORMA_PRIMS_660004265(pt_CalledAdr_660004717))
#trace2("<<<__LINE__<<<__FILE__<<< TmmTelTas_dist:Normalisation de V3t6/CalledAdr:< %s > -> pt_CalledAdr_NORM:< %s >", pt_CalledAdr, pt_CalledAdr_NORM)
# 22/01/2015 - RHE - G5R3 lot3 envoi en erronne si le resultat de normalisation est une chaine ASCII
SI (i_strplcmp(pt_CalledAdr_NORM_660004717, " ", 0, 1) == 0)
ALORS
  trace("TmmTelTas, CalledAdr normalise = chaine ASCII")
  erreur_660004717 = 1
  code_rejet_660004717 = MODULE_DISTR_660004717 + erreur_660004717 + EFFICACE_660004717
  erreur_660004717 = i_PlvMessEmettre(6093, 2, g_iartin, "", 1, code_rejet_660004717, "", "")
  SAUT STOCKE_ERRONE
FINSI


# CallingURI
i_strcpy (pt_CallingURI_ASCII_NORM_660004717, NORMA_PRIMS_660004265(pt_CallingURI_ASCII_660004717))
#trace2("<<<__LINE__<<<__FILE__<<< TmmTelTas_dist:Normalisation de CallingURI:< %s > -> pt_CallingURI_ASCII_NORM:< %s >", pt_CallingURI_ASCII, pt_CallingURI_ASCII_NORM)
# 22/01/2015 - RHE - G5R3 lot3 envoi en erronne si le resultat de normalisation est une chaine ASCII
SI (i_strplcmp(pt_CallingURI_ASCII_NORM_660004717, " ", 0, 1) == 0)
ALORS
  trace("TmmTelTas, CallingURI normalise = chaine ASCII")
  erreur_660004717 = 1
  code_rejet_660004717 = MODULE_DISTR_660004717 + erreur_660004717 + EFFICACE_660004717
  erreur_660004717 = i_PlvMessEmettre(6094, 2, g_iartin, "", 1, code_rejet_660004717, "", "")
  SAUT STOCKE_ERRONE
FINSI


############################################################################
# Duplication Tdpv33 (g_iartout)
############################################################################
#Duplication article d entree vers DPV TLV

erreur_660004717 = i_dup_art_tab( g_iartin, g_iartout, C_Tdpv_660004717)

SI (erreur_660004717 != 0)
ALORS
  trace("TmmTelTas, erreur de duplication tab")
  code_rejet_660004717 = MODULE_DISTR_660004717 + erreur_660004717 + EFFICACE_660004717
  erreur_660004717 = i_PlvMessEmettre(6092, 2, g_iartin, "", 1, code_rejet_660004717, "", "")
  SAUT STOCKE_ERRONE
FINSI

############################################################################
# Mises au format DPV33
############################################################################

#T3t1
#T3t1/type    :-  :-  :MSET :00:1
erreur_660004717 = i_set_art_field(g_iartout,$Tdpvgsm::type, type_CRA_660004717)

#T3t1/tentite   :-  :-  :MSET :17:1

#T3t1/idemet    :-  :-  :MSET :FF
SI (i_strcmp(pt_AX_IDEMET_660004717,"") != 0)
ALORS
  erreur_660004717 = affectation_tab_660004265(g_iartout,$Tdpvgsm::idemet,pt_AX_IDEMET_660004717)
SINON
  # QC1472 correction valeur par defaut
  #erreur = affectation_tab(g_iartout,$Tdpvgsm::idemet,"33610000000FFFFFFF")
  erreur_660004717 = affectation_tab_660004265(g_iartout,$Tdpvgsm::idemet,"33009000000FFFFFFF")
FINSI

##T3t1/IMSI   :-  :-  :MSET :FF
SI (i_get_art_field(g_iartin,$TmmTelTas::subIdType01) == 1)
ALORS
  erreur_660004717 =  i_get_art_str(g_iartin, $TmmTelTas::subIdData01, pt_subIdData_ASCII_660004717)
  erreur_660004717 = affectation_tab_660004265(g_iartout,$Tdpvgsm::IMSI, pt_subIdData_ASCII_660004717)
  SAUT FIN_T3t1
FINSI
SI (i_valid_field_n(g_iartin, $TmmTelTas::subIdType02))
ALORS
  SI (i_get_art_field(g_iartin,$TmmTelTas::subIdType02) == 1)
  ALORS
    #QC1472
    #erreur =  i_get_art_str(g_iartin, $TmmTelTas::subIdData01, pt_subIdData_ASCII)
    erreur_660004717 =  i_get_art_str(g_iartin, $TmmTelTas::subIdData02, pt_subIdData_ASCII_660004717)
    erreur_660004717 = affectation_tab_660004265(g_iartout,$Tdpvgsm::IMSI, pt_subIdData_ASCII_660004717)
    SAUT FIN_T3t1
  FINSI
FINSI
erreur_660004717 = affectation_tab_660004265(g_iartout,$Tdpvgsm::IMSI, "999999999999999f")
POINT FIN_T3t1


# QC1514
#T3t1/DATE    :-  :-  :1VAL :ddebut


#T3t1/DUREE   :-  :-  :MSET :00:4
erreur_660004717 = i_set_art_field(g_iartout,$Tdpvgsm::DUREE, Duree_660004717)

#T3t1/svcsup    :D  :-  :MSET :C0:1

#T3t1/tlserv    :-  :-  :MSET :11:1

#T3t1/support1  :-  :-  :MSET :FF:1
# QC1492
SI ((type_CRA_660004717 == ENTRANT_660004717) || (type_CRA_660004717 == SORTANT_660004717))
ALORS
  erreur_660004717 = i_set_art_field(g_iartout,$Tdpvgsm::support1, 0x00)
FINSI

#T3t1/systype   :-  :-  :MSET :06:1

#T3t1/reserve2  :-  :-  :MSET :FF:1

#T3t1/origine   :-  :-  :MSET :FF:1

#T3t1/indeff    :-  :-  :MSET :00:1
SI Duree_660004717 <= 0
ALORS
  erreur_660004717 = i_set_art_field(g_iartout,$Tdpvgsm::indeff, 0x01)
FINSI

#T3t1/tterm   :-  :-  :MSET :FF:1
erreur_660004717 = i_set_art_field(g_iartout,$Tdpvgsm::tterm, TransReturnCode_660004717)

#T3t1/indtax    :-  :-  :MSET :FF:1

#T3t1/nbUT    :-  :-  :MSET :FF:4

#T3t1/chgcar    :-  :-  :MSET :FF:2

#T3t1/couleur   :-  :-  :MSET :02:1

#T3t2/idpart    :-      :-      :MSET :FF
SI (type_CRA_660004717 == SORTANT_660004717)
ALORS
  SI (i_strplcmp (pt_CalledAdr_NORM_660004717," ", 0, 1) != 0)
  ALORS
    longueur_660004717 = i_conv_ascii_dcb(pt_CalledAdr_NORM_660004717, pt_CalledAdr_NORM_DCB_660004717)
    SI (longueur_660004717 > 19)
    ALORS
      longueur_660004717 = 19
    FINSI
    erreur_660004717 = i_resize_tlv(g_iartout, "T3t2", "idpart", longueur_660004717*8)
    erreur_660004717 = i_memcpy_art_field_n(g_iartout, $Tdpvgsm::idpart, pt_CalledAdr_NORM_DCB_660004717, longueur_660004717)
  SINON
    longueur_660004717 = i_strlen(pt_CalledAdr_NORM_660004717)
    SI (longueur_660004717 > 19)
    ALORS
      longueur_660004717 = 19
    FINSI
    erreur_660004717 = i_resize_tlv(g_iartout, "T3t2", "idpart", longueur_660004717*8)
    erreur_660004717 = i_memcpy_art_field_n(g_iartout, $Tdpvgsm::idpart, pt_CalledAdr_NORM_660004717, longueur_660004717)
    erreur_660004717 = i_set_art_fieldtab(g_iartout, $Tdpvgsm::idpart, 0, 0x00)
  FINSI
SINON
  SI (i_strplcmp (pt_CallingURI_ASCII_NORM_660004717," ", 0, 1) != 0)
  ALORS
    longueur_660004717 = i_conv_ascii_dcb(pt_CallingURI_ASCII_NORM_660004717, pt_CallingURI_ASCII_NORM_DCB_660004717)
    SI (longueur_660004717 > 19)
    ALORS
      longueur_660004717 = 19
    FINSI
    erreur_660004717 = i_resize_tlv(g_iartout, "T3t2", "idpart", longueur_660004717*8)
    erreur_660004717 = i_memcpy_art_field_n(g_iartout, $Tdpvgsm::idpart, pt_CallingURI_ASCII_NORM_DCB_660004717, longueur_660004717)
  SINON
    longueur_660004717 = i_strlen(pt_CallingURI_ASCII_660004717)
    SI (longueur_660004717 > 19)
    ALORS
      longueur_660004717 = 19
    FINSI
    erreur_660004717 = i_resize_tlv(g_iartout, "T3t2", "idpart", longueur_660004717*8)
    erreur_660004717 = i_memcpy_art_field_n(g_iartout, $Tdpvgsm::idpart, pt_CallingURI_ASCII_660004717, longueur_660004717)
    erreur_660004717 = i_set_art_fieldtab(g_iartout, $Tdpvgsm::idpart, 0, 0x00)
  FINSI
FINSI

#T3t3/local   :-      :-      :MSET :FF
SI (b_RENVOI_660004717 == 1)
ALORS
  SI (i_strplcmp (pt_CalledAdr_NORM_660004717," ", 0, 1) != 0)
  ALORS
    longueur_660004717 = i_conv_ascii_dcb(pt_CalledAdr_NORM_660004717, pt_CalledAdr_NORM_DCB_660004717)
    SI (longueur_660004717 > 19)
    ALORS
      longueur_660004717 = 19
    FINSI
    erreur_660004717 = i_resize_tlv(g_iartout, "T3t3", "local", longueur_660004717*8)
    erreur_660004717 = i_memcpy_art_field_n(g_iartout, $Tdpvgsm::local, pt_CalledAdr_NORM_DCB_660004717, longueur_660004717)
  SINON
    longueur_660004717 = i_strlen(pt_CalledAdr_NORM_660004717)
    SI (longueur_660004717 > 19)
    ALORS
      longueur_660004717 = 19
    FINSI
    erreur_660004717 = i_resize_tlv(g_iartout, "T3t3", "local", longueur_660004717*8)
    erreur_660004717 = i_memcpy_art_field_n(g_iartout, $Tdpvgsm::local, pt_CalledAdr_NORM_660004717, longueur_660004717)
    erreur_660004717 = i_set_art_fieldtab(g_iartout, $Tdpvgsm::local, 0, 0x00)
  FINSI
SINON
  longueur_660004717 = i_conv_ascii_dcb(pt_CallingLoc_ASCII_660004717, pt_CallingLoc_DCB_660004717)
  erreur_660004717 = i_resize_tlv(g_iartout, "T3t3", "local", longueur_660004717*8)
  erreur_660004717 = i_memcpy_art_field_n(g_iartout, $Tdpvgsm::local, pt_CallingLoc_DCB_660004717, longueur_660004717)
FINSI

#T3t4/MSISDN    :-  :-  :MSET :FF
#QC1523 suppression de renvoiAssociated
#SI (b_RENVOI == 1)
#ALORS
#  longueur = i_conv_ascii_dcb(pt_renvoiAssociated_ASCII, pt_renvoiAssociated_DCB)
#  erreur = i_resize_tlv(g_iartout, "T3t4", "MSISDN", longueur*8)
#  erreur = i_memcpy_art_field_n(g_iartout, $Tdpvgsm::MSISDN, pt_renvoiAssociated_DCB, longueur)
#SINON
  SI (i_get_art_field(g_iartin,$TmmTelTas::subIdType01) == 0)
  ALORS
    erreur_660004717 =  i_get_art_str(g_iartin, $TmmTelTas::subIdData01, pt_subIdData_ASCII_660004717)
    longueur_660004717 = i_strlen(pt_subIdData_ASCII_660004717)
    SI (longueur_660004717 > 38)
    ALORS
      longueur_660004717 = 38
    FINSI
    erreur_660004717 = i_resize_tlv(g_iartout, "T3t4", "MSISDN", longueur_660004717*4)
    erreur_660004717 = affectation_tab_660004265(g_iartout,$Tdpvgsm::MSISDN, pt_subIdData_ASCII_660004717)
  SINON
    SI (i_get_art_field(g_iartin,$TmmTelTas::subIdType02) == 0)
    ALORS
      erreur_660004717 =  i_get_art_str(g_iartin, $TmmTelTas::subIdData02, pt_subIdData_ASCII_660004717)
      longueur_660004717 = i_strlen(pt_subIdData_ASCII_660004717)
      SI (longueur_660004717 > 38)
      ALORS
        longueur_660004717 = 38
      FINSI
      erreur_660004717 = i_resize_tlv(g_iartout, "T3t4", "MSISDN", longueur_660004717*4)
      erreur_660004717 = affectation_tab_660004265(g_iartout,$Tdpvgsm::MSISDN, pt_subIdData_ASCII_660004717)
    FINSI
  FINSI
#FINSI

# G5R3 lot3 QC1473
#T3t5/IMEI
SI (  i_valid_field_n(g_iartin, $TmmTelTas::servedIMEI) )
ALORS
  erreur_660004717 = i_get_art_str(g_iartin, $TmmTelTas::servedIMEI, pt_servedIMEI_660004717)
  longueur_660004717 = i_conv_ascii_dcb(pt_servedIMEI_660004717, pt_IMEI_DCB_660004717)
  erreur_660004717 = i_ajoutChamp(g_iartout,"T3t5","IMEI", 0)
  erreur_660004717 = i_resize_tlv(g_iartout, "T3t5", "IMEI", longueur_660004717*8)
  erreur_660004717 = i_memcpy_art_field_n(g_iartout, $Tdpvgsm::IMEI, pt_IMEI_DCB_660004717, longueur_660004717)
  erreur_660004717 = i_inv_quart_field_n(g_iartout, $Tdpvgsm::IMEI)
FINSI

#T3t7/estalloc  :-  :-  :MSET :FF:7
res_660004717 = i_get_art_field(g_iartin, $TmmTelTas::SceReqTimeStamp)
erreur_660004717 = i_set_art_field(g_iartout, $Tdpvgsm::estalloc, res_660004717)

#T3t30
#T4t30.1 timeInCE :-  :-  :MSET :FF
erreur_660004717 = i_set_art_field(g_iartout, $Tdpvgsm::timeInCE, date_audit_660004717)

#T4t30.2 eec    :-  :-  :MSET :00:1
SI (g_ieec > 500)
ALORS
  erreur_660004717 = i_set_art_field(g_iartout, $Tdpvgsm::eec, g_ieec - 500)
SINON
  erreur_660004717 = i_set_art_field(g_iartout, $Tdpvgsm::eec, g_ieec)
FINSI

#T3t35
#T4t35.4 presenceInd  :-  :-  :MSET :01:1
SI (b_conference_660004717 != 1)
ALORS
  erreur_660004717 = i_supprChamp(g_iartout, "T4t35.4")
FINSI

#T3t38
#T4t38.1 origCallpartId :-  :-  :MSET :00
SI (type_CRA_660004717 == SORTANT_660004717)
ALORS
  longueur_660004717 = i_strlen(pt_CalledAdr_660004717)
  SI (longueur_660004717 > 38)
  ALORS
    i_get_sub_str(pt_CalledAdr_660004717,0, 37, pt_CalledAdr_660004717)
  FINSI
  # QC1472
  erreur_660004717 = i_resize_tlv(g_iartout, "T4t38.1", "origCallpartId", longueur_660004717)
  #trace("<<<__LINE__<<<__FILE__<<< TmmTelTas_dist : CRA SORTANT: Alimentation du champ T4t38.1 par pt_CalledAdr")
  erreur_660004717 = i_set_art_str(g_iartout,$Tdpvgsm::origCallpartId, pt_CalledAdr_660004717)
SINON
  SI (b_RENVOI_660004717 == 1)
  ALORS
    longueur_660004717 = i_strlen(pt_CallingURI_ASCII_660004717)
    SI (longueur_660004717 > 38)
    ALORS
      i_get_sub_str(pt_CallingURI_ASCII_660004717,0, 37, pt_CallingURI_ASCII_660004717)
    FINSI
    # QC1472
    erreur_660004717 = i_resize_tlv(g_iartout, "T4t38.1", "origCallpartId", longueur_660004717)
    #trace("<<<__LINE__<<<__FILE__<<< TmmTelTas_dist : CRA RENVOI: Alimentation du champ T4t38.1 par pt_CallingURI_ASCII")
    erreur_660004717 = i_set_art_str(g_iartout,$Tdpvgsm::origCallpartId, pt_CallingURI_ASCII_660004717)
  SINON
    ##trace("<<<__LINE__<<<__FILE__<<< TmmTelTas_dist : supression du champ T4t38.1")
    erreur_660004717 = i_supprChamp(g_iartout, "T4t38.1")
  FINSI
FINSI

#T3t43
#T4t43.3 transactionDesc  :-  :-  :1VAL :IMSChargingId

#T3t66
#T4t66.1
#T4t66.1/RecSeqNumber:- :-  :MSET :FF:4

#T4t66.1/SigVolum:- :-  :MSET :00:4

#T4t66.1/ExtBearVolum:- :-  :MSET :00:4

#T4t66.1/TotalVolum:- :-  :MSET :00:4

#T4t66.1/CallEndTStamp:-  :-  :MSET :FF
SI (  i_valid_field_n(g_iartin, $TmmTelTas::sceDelivEndTime) )
ALORS
  erreur_660004717 = i_set_art_field(g_iartout,$Tdpvgsm::CallEndTStamp, i_get_art_field(g_iartin, $TmmTelTas::sceDelivEndTime))
SINON
  erreur_660004717 = i_set_art_field(g_iartout,$Tdpvgsm::CallEndTStamp, -1)
FINSI

#T4t66.1/CauseRecClose:-:D:1VAL:causeForRecClos

#T4t66.1/SessionTerm:-:D:1VAL:sceReturnCode

#T4t66.1/CORLStatus:- :-  :MSET :FF:1

#T4t66.6 OriginatingIOI:- :-  :MSET :FF
SI (  i_valid_field_n(g_iartin, $TmmTelTas::OriginatingIOI) )
ALORS
  erreur_660004717 = i_get_art_str(g_iartin, $TmmTelTas::OriginatingIOI, pt_1_660004717)
  longueur_660004717 = i_strlen(pt_1_660004717)
  SI (longueur_660004717 > 80)
  ALORS
    longueur_660004717 = 80
  FINSI
  erreur_660004717 = i_resize_tlv(g_iartout, "T4t66.6", "OriginatingIOI", longueur_660004717)
  erreur_660004717 = i_set_art_str(g_iartout,$Tdpvgsm::OriginatingIOI, pt_1_660004717)
SINON
  erreur_660004717 = i_supprChamp(g_iartout, "T4t66.6")
FINSI

#T4t66.7 TerminatingIOI:- :-  :MSET :FF
SI (  i_valid_field_n(g_iartin, $TmmTelTas::TerminatingIOI) )
ALORS
  erreur_660004717 = i_get_art_str(g_iartin, $TmmTelTas::TerminatingIOI, pt_1_660004717)
  longueur_660004717 = i_strlen(pt_1_660004717)
  SI (longueur_660004717 > 80)
  ALORS
    longueur_660004717 = 80
  FINSI
  erreur_660004717 = i_resize_tlv(g_iartout, "T4t66.7", "TerminatingIOI", longueur_660004717)
  erreur_660004717 = i_set_art_str(g_iartout,$Tdpvgsm::TerminatingIOI, pt_1_660004717)
SINON
  erreur_660004717 = i_supprChamp(g_iartout, "T4t66.7")
FINSI

#T4t66.8 AccessNetInfo:-  :-  :MSET :FF
SI (  i_valid_field_n(g_iartin, $TmmTelTas::AccessNetInfo) )
ALORS
  erreur_660004717 = i_get_art_str(g_iartin, $TmmTelTas::AccessNetInfo, pt_1_660004717)
  longueur_660004717 = i_strlen(pt_1_660004717)
  SI (longueur_660004717 > 128)
  ALORS
    longueur_660004717 = 128
  FINSI
  erreur_660004717 = i_resize_tlv(g_iartout, "T4t66.8", "AccessNetInfo", longueur_660004717)
  erreur_660004717 = i_set_art_str(g_iartout,$Tdpvgsm::AccessNetInfo, pt_1_660004717)
SINON
  erreur_660004717 = i_supprChamp(g_iartout, "T4t66.8")
FINSI

#T4t66.9 SessionId:-:D:1VAL:sessionId

#T4t66.11 AppliServerId:-:D:1VAL:NodeId

#T4t66.12 SIPMethod:- :-  :MSET :00
SI (  i_valid_field_n(g_iartin, $TmmTelTas::sIPMethod) )
ALORS
  erreur_660004717 = i_get_art_str(g_iartin, $TmmTelTas::sIPMethod, pt_1_660004717)
  longueur_660004717 = i_strlen(pt_1_660004717)
  SI (longueur_660004717 > 128)
  ALORS
    longueur_660004717 = 128
  FINSI
  erreur_660004717 = i_resize_tlv(g_iartout, "T4t66.12", "SIPMethod", longueur_660004717)
  erreur_660004717 = i_set_art_str(g_iartout,$Tdpvgsm::SIPMethod, pt_1_660004717)
SINON
  erreur_660004717 = i_supprChamp(g_iartout, "T4t66.12")
FINSI

# G5R3 lot3 Ajout du champ T3t99/T4t99.2 GMSCForwTerm
SI (b_Entrant_Service6_660004717 == 1)
ALORS
  erreur_660004717 = i_ajoutChamp(g_iartout,"T4t99.2","GMSCForwTerm", 0)
  erreur_660004717 = i_set_art_field(g_iartout, $Tdpvgsm::GMSCForwTerm, 0x01)
FINSI

####### FIN creation DPV pivot, Tdpvgsm ###############

code_rejet_660004717 = aiguillage2_660004590 (g_iartin, g_iartout, DISTRIBUTION_INCONNU_660004717, Multidistribution_Non_660004717)
SI (code_rejet_660004717 == TRAI_KO_660004717)
ALORS
  trace("<<<__LINE__<<<__FILE__<<< TmmTelTas: erreur retour fonction aiguillage2")
  SAUT STOCKE_ERRONE
FINSI

trace("<<<__LINE__<<<__FILE__<<< TmmTelTas : Fin Distribution OK")
RETOUR TRAIT_OK


POINT STOCKE_ERRONE
trace( "TmmTelTas : fin Distribution Stockage de l'article en ERRONE" )
erreur_660004717 = i_make_art_rej(g_iartin, g_iartout11, code_rejet_660004717)
erreur_660004717 = i_stocke_art(g_iartout11, 0, PT_ERRONE, 0)
RETOUR TRAIT_OK

#---------------------------------------FIN TmmTelTas_dis.src-------------------
