DEFINITION Vrai_660003962 1
DEFINITION Faux_660003962 0
DEFINITION NUMTAB_660003962 1
DEFINITION ZONEMETRO_660003962 7
DEFINITION TD_Imsi_660003962 0
DEFINITION Oui_660003962 1
DEFINITION FORMAT_ECC_660003962 "Format_ECC"
DEFINITION MODULE_DISTR_660003962 0xA000
DEFINITION ERR_DUPL_660003962 0x0D0
DEFINITION ERR_DISTR_660003962 0x110
DEFINITION EFFICACE_660003962 0x01
DEFINITION STCK_KO_660003962 0
REGISTRE ENTIER erreur_660003962
REGISTRE ENTIER code_rejet_660003962
REGISTRE ENTIER ic_network_660003962
REGISTRE ENTIER type_cra_660003962
REGISTRE ENTIER date_cra_660003962
REGISTRE ENTIER gmt_date_cra_660003962
REGISTRE ENTIER date_fin_660003962
REGISTRE ENTIER indice_660003962
REGISTRE ENTIER UTCOffcode_map_660003962
REGISTRE ENTIER UTCOffcode_660003962
REGISTRE ENTIER ic_charge_660003962
REGISTRE ENTIER val_Location_660003962
REGISTRE ENTIER val_CellId_660003962
REGISTRE ENTIER val_champ_660003962
REGISTRE ENTIER chargeSM_660003962
REGISTRE ENTIER instECC_660003962
REGISTRE ENTIER instanceECC_660003962
REGISTRE ENTIER CRA_a_redistribuer_660003962
REGISTRE ENTIER nombreECC_660003962
REGISTRE ENTIER res_660003962
REGISTRE ENTIER instVDIDCH_660003962
REGISTRE ENTIER instOLADCH_660003962
REGISTRE ENTIER instOL2DCH_660003962
REGISTRE ENTIER instOL3DCH_660003962
REGISTRE ENTIER instOR5DCH_660003962
REGISTRE ENTIER instCMODCH_660003962
REGISTRE ENTIER instM1GDCH_660003962
REGISTRE ENTIER instNVDDCH_660003962
REGISTRE ENTIER instNVCDCH_660003962
REGISTRE ENTIER b_COMESI_660003962
REGISTRE POINTEUR pt_IMSI_660003962
REGISTRE POINTEUR pt_RecEntityId_660003962
REGISTRE POINTEUR pt_indice_660003962
REGISTRE POINTEUR pt_charge_660003962
REGISTRE POINTEUR pt_chargeType_660003962
REGISTRE POINTEUR pt_IdCrae_660003962
REGISTRE POINTEUR pt_IMEI_660003962
REGISTRE POINTEUR pt_Min_660003962
REGISTRE POINTEUR pt_TlSvcCode1_660003962
REGISTRE POINTEUR pt_TlSvcCode2_660003962
REGISTRE POINTEUR pt_TlSvcCode3_660003962
REGISTRE POINTEUR pt_TlSvcCode4_660003962
REGISTRE POINTEUR pt_TlSvcCode5_660003962
REGISTRE POINTEUR pt_BrSvcCode1_660003962
REGISTRE POINTEUR pt_BrSvcCode2_660003962
REGISTRE POINTEUR pt_BrSvcCode3_660003962
REGISTRE POINTEUR pt_BrSvcCode4_660003962
REGISTRE POINTEUR pt_BrSvcCode5_660003962
REGISTRE POINTEUR pt_erreur_660003962
REGISTRE POINTEUR pt_CellId_660003962
REGISTRE POINTEUR pt_Location_660003962
REGISTRE POINTEUR pt_champ_660003962
REGISTRE POINTEUR pt_Min_DCB_660003962
REGISTRE POINTEUR pt_chargeSM_660003962
REGISTRE POINTEUR pt_LibelleAlarme_660003962
REGISTRE POINTEUR pt_NameOfFile_660003962
REGISTRE POINTEUR ptchp_format_660003962
REGISTRE ENTIER IMSI_Transnational_M2M_660003962
REGISTRE ENTIER REDIST_IMSI_Transnational_M2M_660003962
REGISTRE POINTEUR pt_MCCMNCx_660003962
REGISTRE POINTEUR pt_IMSIy_660003962
REGISTRE POINTEUR str_conteneur_660003962
REGISTRE POINTEUR ptr_res_660003962
#                         - Pcode du module de distribution : CRAE SERVICE COMPLEMENTAIRE, article : Tcrae_ssp
#                         - creation le 27/09/2006
#                         - Auteur : NBOU
# Ttapin40
# g_iartin  : Tcrae_ssp
# g_iartout (Tap2++ et Tap2.5)
# g_iartout2 : rejet
#
# HISTORIQUE:
# creation : 27/09/2006
# 18/12/2006: FO381 decalgae du mapping de TAPIN40/UTCTimeOff
# 09/02/2007: FO381 annulee
# 21/12/2007 : URS G1R6 : retrait ADV-VI
# 21/02/2008 : URS G1R6 : report G1R5 (SOFRECOM 3.0/586)
# 19/08/2008 - URS - Param ME-G1R9
# 08/09/2008 - URS - Param ME-G1R9 QC184
# 25/11/2008 -DECI - G2R1 lot2 Transmission des CRAs vers FE
# 01/12/2009 - DECI - G2R6 JLGTHE item NNF
# 23/12/2009 - DECI - G2R6 QC367 : (report G2R3C7) le mapping se fait maintenant dans le pcode IECC
# 17/06/2010 - DECI - G3R1 QC657 condition -1 au lieu de 0 pour UTCcode
# 12/10/2010 - DECI - G3R1  QC711
# 10/12/2010 - JLG - G3R1lot4 Verification/Correction des variables (constantes, entiers, pointeurs)
# 13/04/2011 - JLG - G3R2C7 QC839
# 19/08/2011 - DECI - G3R4 lot3 QC852, CRAE enrichissement du libelle des alarmes par le nom du fichier collecte
# 05/09/2011 - DECI - G3R4 evol suite non-reg G3R2C3, G3R3C9 : reinit pt et modif des fcts Ajuster_taille
# 04/10/2011 - DECI - G3R4 QC913 interrogation du referentiel a tort en LocalTime au lieu de GmtTime
# 04/02/2013 - DECI - G3R9 lot2 item COME
# 16/10/2014 - JLG  - G5R2 lot2 : QC1448, filtre IMSI transnational
# 06/11/2014 - JLG  - G5R2 : contournement core sur verbe pcode i_adequation_chaine_expreg (QC1441)
# 03/03/2015 - DERS/JLG  - G4R5lot2 suppresion de VPF
##########################################################################################################
#QC913


#Declaration des variables

#QC913

#G2R6
#G4R5lot2 suppresion de VPF
#/G2R6



# G5R2lot2, QC1448
#/G5R2lot2, QC1448


# initialisation des variables

type_cra_660003962  = 40

instVDIDCH_660003962  = -1
instOLADCH_660003962  = -1
instOL2DCH_660003962  = -1
instOL3DCH_660003962  = -1
instOR5DCH_660003962  = -1
instCMODCH_660003962  = -1
instM1GDCH_660003962  = -1
instNVDDCH_660003962  = -1
#G2R6
#G4R5lot2 suppresion de VPF
b_COMESI_660003962  = 0
#/G2R6
pt_IMSI_660003962  = "2468013579024680"
pt_RecEntityId_660003962 ="pt_RecEntityId012345678987654pt_RecEntityId"
pt_indice_660003962 = "0134"
pt_charge_660003962="pt_charge0123456789"

pt_IdCrae_660003962="pt_IdCrae0123456789"
pt_IMEI_660003962="pt_IMEI01234567899"
pt_Min_660003962= "pt_Min0123456789"
pt_TlSvcCode1_660003962= "pt_val_TlSvcCode10123466789"
pt_TlSvcCode2_660003962= "pt_val_TlSvcCode20123466789"
pt_TlSvcCode3_660003962= "pt_val_TlSvcCode30123466789"
pt_TlSvcCode4_660003962= "pt_val_TlSvcCode40123466789"
pt_TlSvcCode5_660003962= "pt_val_TlSvcCode50123466789"
pt_BrSvcCode1_660003962 = "pt_BrSvcCode10123456789"
pt_BrSvcCode2_660003962 =  "pt_BrSvcCode201234566789"
pt_BrSvcCode3_660003962 =  "pt_BrSvcCode301234568789"
pt_BrSvcCode4_660003962 =  "pt_BrSvcCode4012345566789"
pt_BrSvcCode5_660003962 = "pt_BrSvcCode50123456789"
pt_erreur_660003962 = "pt_erreur01234567"
pt_CellId_660003962 = "pt_CellId0123456789"
pt_Location_660003962 ="pt_Location01234567"
pt_champ_660003962="pt_champ01234567"
pt_Min_DCB_660003962= "pt_Min_d11111111"
pt_chargeSM_660003962="0123456789"
pt_chargeType_660003962="pt_chargeType123456pt_chargeType123456"
ptchp_format_660003962="ptchp_formatptchp_format"
pt_LibelleAlarme_660003962="pt_LibelleAlarme_111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"
i_strcpy(pt_LibelleAlarme_660003962,"")
pt_NameOfFile_660003962="NameOfFile0123456780111111111111189012345678901234567890123456789012345672345678190123456789012345678901234567890123456789012345"
i_strcpy(pt_NameOfFile_660003962,"")

# G5R2lot2, QC1448
IMSI_Transnational_M2M_660003962 = 0
REDIST_IMSI_Transnational_M2M_660003962 = 0
pt_MCCMNCx_660003962 = "pt_MCCMNCx12"
i_strcpy(pt_MCCMNCx_660003962,"")
pt_IMSIy_660003962   = "pt_IMSIy1234"
i_strcpy(pt_IMSIy_660003962,"")
str_conteneur_660003962 = "str_conteneur123456789"
i_strcpy(str_conteneur_660003962,"")
ptr_res_660003962    = "ptr_res12345"
i_strcpy(ptr_res_660003962,"")
#/G5R2lot2, QC1448


trace("   -----------------------------------------------"   )
trace("  |  TCRAE_SSP :DEBUT PCODE DE DISTRIBUTION SSP   |"  )
trace("   -----------------------------------------------"   )


i_strcpy(pt_IMSI_660003962,"")
i_strcpy(pt_RecEntityId_660003962,"")
i_strcpy(pt_indice_660003962,"")

i_strcpy(pt_IdCrae_660003962,"")
i_strcpy(pt_IMEI_660003962,"")
i_strcpy(pt_Min_660003962,"")
#i_strcpy(pt_CellId,"") fait plus bas
#i_strcpy(pt_Location,"") fait plus bas
#i_strcpy(pt_champ,"") fait plus bas
i_strcpy(pt_Min_DCB_660003962,"")
#i_strcpy(pt_chargeSM,"") fait plus bas

# G3R4 QC852
erreur_660003962 = i_get_art_str(g_iartin, $Tcrae_ssp::NameOfFile, pt_NameOfFile_660003962)
# /G3R4 QC852

# --------------------------------------------------------------------------
# recherer IMSI a partir du MSISDN
# --------------------------------------------------------------------------
#date_cra  = i_get_art_field(g_iartin, $Tcrae_ssp::CLocalTime)
date_cra_660003962   = i_get_art_field(g_iartin, $Tcrae_ssp::ddebut)
#QC913
gmt_date_cra_660003962 = i_DHgetCe2gTime(NUMTAB_660003962,ZONEMETRO_660003962,date_cra_660003962)

date_fin_660003962 = i_get_art_field(g_iartin, $Tcrae_ssp::dfin)
SI(i_valid_field_n(g_iartin, $Tcrae_ssp::IMSI))
ALORS
  erreur_660003962 = i_get_art_str(g_iartin, $Tcrae_ssp::IMSI, pt_IMSI_660003962)
  trace2("Imsi recherche est %s %s", pt_IMSI_660003962, "")
SINON
  erreur_660003962 = i_get_art_str(g_iartin, $Tcrae_ssp::Min, pt_IMSI_660003962)
  trace2("Min recherche est %s %s", pt_IMSI_660003962, "")
FINSI

# G5R2 lot2
# calcul de pt_MCCMNCx, pt_IMSIy, IMSI_Transnational_M2M
i_get_sub_str(pt_IMSI_660003962, 0, 5, pt_MCCMNCx_660003962)
i_get_sub_str(pt_IMSI_660003962, 6, 6, pt_IMSIy_660003962)
erreur_660003962 = i_format_str2(str_conteneur_660003962, "%s%s", "M2M_", pt_MCCMNCx_660003962)
i_strcpy(ptr_res_660003962, i_get_tab_field("MVNO", date_cra_660003962, str_conteneur_660003962))
# equivallent a QC1441 : anomalie core de i_adequation_chaine_expreg
SI (i_strcmp(pt_IMSIy_660003962, "") != 0 && i_strcmp(ptr_res_660003962, "") != 0)
ALORS
  SI ( i_strcmp(ptr_res_660003962,"Tous") == 0 || i_adequation_chaine_expreg(ptr_res_660003962, pt_IMSIy_660003962) == 0)
  ALORS
    IMSI_Transnational_M2M_660003962 = Vrai_660003962
  SINON
    IMSI_Transnational_M2M_660003962 = Faux_660003962
  FINSI
SINON
  IMSI_Transnational_M2M_660003962 = Faux_660003962
FINSI
#/QC1441
#/G5R2 lot2

erreur_660003962 = i_conv_ascii_dcb(pt_IMSI_660003962 , pt_Min_DCB_660003962)
erreur_660003962 = i_EnvoiReqConsTabDist(TD_Imsi_660003962, gmt_date_cra_660003962, pt_Min_DCB_660003962, 8, 0, 1)
trace1("Retour de i_EnvoiReqConsTabDist TD_Imsi = <%d>",erreur_660003962)

SI (erreur_660003962 != 0)
ALORS
  # IMSI inconnu
  SI IMSI_Transnational_M2M_660003962
  ALORS
    # IMSI Inconnu et transnational
    REDIST_IMSI_Transnational_M2M_660003962 = 1
  SINON
    SAUT REDISTRIB
  FINSI
FINSI


#---------------------------------------------------------------------------------
# traitements en //
# duplication vers le format TAP2++ et TAP2.5
#----------------------------------------------------------------------------------

erreur_660003962  = i_dup_art_dest(g_iartin , g_iartout , "Ttapin40")

SI (erreur_660003962  !=0)
ALORS
  trace("Tcrae_ssp, erreur de duplication vers le format TAPIN40**")
  code_rejet_660003962  = MODULE_DISTR_660003962  + ERR_DUPL_660003962  + EFFICACE_660003962
  erreur_660003962 = i_format_str2(pt_LibelleAlarme_660003962, "%s> <f=%s", "Ttapin40", pt_NameOfFile_660003962)
  erreur_660003962 = i_PlvMessEmettre(8867, 2, g_iartin, "", 3, code_rejet_660003962, type_cra_660003962, pt_LibelleAlarme_660003962)
  SAUT STOCKE_ERRONE
FINSI

# complement de duplication hors table  TAPIN40
trace("****Tcrae_ssp Debut de la duplication hors table***")

# mis a jour du champ RecordType

erreur_660003962  = i_memcpy_art_field_n(g_iartout , $Ttapin40::RecordType, "40" ,2)

# mis a jour du champ  ActionCode
# remplacement de la ligne de la table 1: $SupSvcActCode  :$ActionCode
#SI (i_valid_field(g_iartin, $Tcrae_ssp::SupSvcActCode))
#ALORS
#val_champ = i_get_art_field(g_iartin, $Tcrae_ssp::SupSvcActCode)
#erreur = i_memset_field_n(g_iartout, $Ttapin40::ActionCode ,val_champ)
#FINSI

# mis a jour du champ NetworkType
erreur_660003962  = i_get_art_field(g_iartin, $Tcrae_ssp::NetworkType)
SI( erreur_660003962  == 0)
ALORS
  ic_network_660003962  = $Tcrae_ssp::SSENetworkType
SINON
  ic_network_660003962  = $Tcrae_ssp::NetworkType
FINSI

erreur_660003962  = i_get_art_field(g_iartin, ic_network_660003962 )

SI(erreur_660003962  == 1)
ALORS
  erreur_660003962  = i_memcpy_art_field_n(g_iartout, $Ttapin40::NetworkType, "A", 1)
SINON
  SI(erreur_660003962  == 2)
  ALORS
    erreur_660003962  = i_memcpy_art_field_n(g_iartout, $Ttapin40::NetworkType, "B", 1)
  FINSI
FINSI

# mis a jour du champ IMSI

SI(i_valid_field_n(g_iartin, $Tcrae_ssp::IMSI))
ALORS
  erreur_660003962  = i_get_field_str(g_iartin, "IMSI", pt_IMSI_660003962 )
SINON
  erreur_660003962  = i_get_field_str(g_iartin, "Min", pt_IMSI_660003962 )
FINSI

erreur_660003962  = i_memcpy_art_field_n(g_iartout, $Ttapin40::IMSI, pt_IMSI_660003962 , i_strlen(pt_IMSI_660003962 ))
SI(erreur_660003962 !=0)
ALORS
  trace("Tcrae_ssp , erreur de mise a jour du champ IMSI")
  SAUT STOCKE_ERRONE
FINSI
trace2("IMSI Out est %s %s",pt_IMSI_660003962, "")
# mis a jour du champ IMEI

SI(i_valid_field_n(g_iartin, $Tcrae_ssp::IMEI))
ALORS
  erreur_660003962  = i_get_field_str(g_iartin, "IMEI", pt_IMEI_660003962 )
  erreur_660003962  = i_memcpy_art_field_n(g_iartout, $Ttapin40::IMEI ,pt_IMEI_660003962 , i_strlen(pt_IMEI_660003962 ))
FINSI

# mis a jour des champs ServiceType1 et ServiceCode1

SI(i_valid_field_n(g_iartin, $Tcrae_ssp::TlSvcCode1))
ALORS
  erreur_660003962 = i_memcpy_art_field_n(g_iartout, $Ttapin40::ServiceType_1 ,"0" , 1)
  pt_TlSvcCode1_660003962 = i_get_art_fieldptr(g_iartin, $Tcrae_ssp::TlSvcCode1)
  erreur_660003962 = i_memcpy_art_field(g_iartout,"ServiceCode_1",pt_TlSvcCode1_660003962,2)
FINSI

SI (i_valid_field_n(g_iartin, $Tcrae_ssp::BrSvcCode1))
ALORS
  erreur_660003962 = i_memcpy_art_field_n(g_iartout, $Ttapin40::ServiceType_1 ,"1" , 1)
  pt_BrSvcCode1_660003962 = i_get_art_fieldptr(g_iartin, $Tcrae_ssp::BrSvcCode1)
  erreur_660003962 = i_memcpy_art_field(g_iartout,"ServiceCode_1",pt_BrSvcCode1_660003962, 2)
FINSI

# mis a jour des champs ServiceType2 et ServiceCode2

SI(i_valid_field_n(g_iartin, $Tcrae_ssp::TlSvcCode2))
ALORS
  erreur_660003962 = i_memcpy_art_field_n(g_iartout, $Ttapin40::ServiceType_2 ,"0" , 1)
  pt_TlSvcCode2_660003962 = i_get_art_fieldptr(g_iartin, $Tcrae_ssp::TlSvcCode2)
  erreur_660003962 = i_memcpy_art_field(g_iartout,"ServiceCode_2",pt_TlSvcCode2_660003962, 2)
FINSI
SI (i_valid_field_n(g_iartin, $Tcrae_ssp::BrSvcCode2))
ALORS
  erreur_660003962 = i_memcpy_art_field_n(g_iartout, $Ttapin40::ServiceType_2 ,"1" , 1)
  pt_BrSvcCode2_660003962 = i_get_art_fieldptr(g_iartin, $Tcrae_ssp::BrSvcCode2)
  erreur_660003962 = i_memcpy_art_field(g_iartout,"ServiceCode_2",pt_BrSvcCode2_660003962, 2)
FINSI

# mis a jour des champs ServiceType3 et ServiceCode3

SI(i_valid_field_n(g_iartin, $Tcrae_ssp::TlSvcCode3))
ALORS
  erreur_660003962 = i_memcpy_art_field_n(g_iartout, $Ttapin40::ServiceType_3 ,"0" , 1)
  pt_TlSvcCode3_660003962 = i_get_art_fieldptr(g_iartin, $Tcrae_ssp::TlSvcCode3)
  erreur_660003962 = i_memcpy_art_field(g_iartout,"ServiceCode_3",pt_TlSvcCode3_660003962, 2)
FINSI
SI (i_valid_field_n(g_iartin, $Tcrae_ssp::BrSvcCode3))
ALORS
  erreur_660003962 = i_memcpy_art_field_n(g_iartout, $Ttapin40::ServiceType_3 ,"1" , 1)
  pt_BrSvcCode3_660003962 = i_get_art_fieldptr(g_iartin, $Tcrae_ssp::BrSvcCode3)
  erreur_660003962 = i_memcpy_art_field(g_iartout,"ServiceCode_3",pt_BrSvcCode3_660003962, 2)
FINSI

# mis a jour des champs ServiceType4 et ServiceCode4

SI(i_valid_field_n(g_iartin, $Tcrae_ssp::TlSvcCode4))
ALORS
  erreur_660003962 = i_memcpy_art_field_n(g_iartout, $Ttapin40::ServiceType_4 ,"0" , 1)
  pt_TlSvcCode4_660003962 = i_get_art_fieldptr(g_iartin, $Tcrae_ssp::TlSvcCode4)
  erreur_660003962 = i_memcpy_art_field(g_iartout,"ServiceCode_4",pt_TlSvcCode4_660003962, 2)
FINSI
SI (i_valid_field_n(g_iartin, $Tcrae_ssp::BrSvcCode4))
ALORS
  erreur_660003962 = i_memcpy_art_field_n(g_iartout, $Ttapin40::ServiceType_4 ,"1" , 1)
  pt_BrSvcCode4_660003962 = i_get_art_fieldptr(g_iartin, $Tcrae_ssp::BrSvcCode4)
  erreur_660003962 = i_memcpy_art_field(g_iartout,"ServiceCode_4",pt_BrSvcCode4_660003962, 2)
FINSI

# mis a jour des champs ServiceType5 et ServiceCode5

SI (i_valid_field_n(g_iartin, $Tcrae_ssp::TlSvcCode5))
ALORS
  erreur_660003962 = i_memcpy_art_field_n(g_iartout, $Ttapin40::ServiceType_5 ,"0" , 1)
  pt_TlSvcCode5_660003962 = i_get_art_fieldptr(g_iartin, $Tcrae_ssp::TlSvcCode5 )
  erreur_660003962 = i_memcpy_art_field(g_iartout,"ServiceCode_5",pt_TlSvcCode5_660003962, 2)
FINSI
SI (i_valid_field_n(g_iartin, $Tcrae_ssp::BrSvcCode5))
ALORS
  erreur_660003962 = i_memcpy_art_field_n(g_iartout, $Ttapin40::ServiceType_5 ,"1" , 1)
  pt_BrSvcCode5_660003962 = i_get_art_fieldptr(g_iartin, $Tcrae_ssp::BrSvcCode5 )
  erreur_660003962 = i_memcpy_art_field(g_iartout,"ServiceCode_5",pt_BrSvcCode5_660003962, 2)
FINSI

# mis a jour du champ Supplementary Service Code

SI(i_valid_field_n(g_iartin, $Tcrae_ssp::SuppSvcCode))
ALORS
  pt_erreur_660003962 = i_get_art_fieldptr(g_iartin, $Tcrae_ssp::SuppSvcCode)
  erreur_660003962 = i_memcpy_art_field(g_iartout,"SSCode",pt_erreur_660003962,2)
FINSI

# mis a jour du champ Action Code
SI (i_valid_field_n(g_iartin, $Tcrae_ssp::SupSvcActCode))
ALORS
  val_champ_660003962 = i_get_art_field(g_iartin, $Tcrae_ssp::SupSvcActCode)
  i_strcpy(pt_champ_660003962,"")
  erreur_660003962 = i_EntierToString(val_champ_660003962, pt_champ_660003962, 4)
  erreur_660003962 = i_memcpy_art_field(g_iartout,"ActionCode",pt_champ_660003962,1)
FINSI

#mis a jour du champ MSC Identification
# QC711
SI (i_valid_field_n(g_iartin, $Tcrae_ssp::RecEntityId))
ALORS
  erreur_660003962 = i_get_field_str(g_iartin, "RecEntityId", pt_RecEntityId_660003962)
  trace2("pt_RecEntityId %s %s",pt_RecEntityId_660003962, "")
  res_660003962 = i_strlen(pt_RecEntityId_660003962)
  SI( res_660003962 > 15)
  ALORS
    res_660003962 = 15
  FINSI
  erreur_660003962 = i_memcpy_art_field_n(g_iartout, $Ttapin40::MscId, pt_RecEntityId_660003962, res_660003962)
SINON
  SI (i_valid_field_n(g_iartin, $Tcrae_ssp::Recipient))
  ALORS
    erreur_660003962 = i_get_field_str(g_iartin, "Recipient", pt_RecEntityId_660003962)
    erreur_660003962 = i_memcpy_art_field_n(g_iartout, $Ttapin40::MscId, pt_RecEntityId_660003962, i_strlen(pt_RecEntityId_660003962))
  FINSI
FINSI

erreur_660003962 = i_get_field_str(g_iartout, "MscId", pt_RecEntityId_660003962)
trace2("MscId est %s %s ",pt_RecEntityId_660003962 , "")
# mis a jour du champ Location Area

SI(i_valid_field_n(g_iartin, $Tcrae_ssp::LocationArea))
ALORS
  val_Location_660003962 = i_get_art_field(g_iartin, $Tcrae_ssp::LocationArea)
# ano 3315
  SI( (val_Location_660003962 >= 0) && (val_Location_660003962 <= 99999) )
# /ano 3315
  ALORS
    i_strcpy(pt_Location_660003962, "")
    erreur_660003962 = Ajuster_taille_entier2_660003942(val_Location_660003962, 5, pt_Location_660003962)
    erreur_660003962 = i_memcpy_art_field(g_iartout, "LocationArea", pt_Location_660003962 , 5)
  SINON
    erreur_660003962 = i_memcpy_art_field(g_iartout, "LocationArea", "99999", 5)
  FINSI
SINON
  erreur_660003962 = i_memcpy_art_field(g_iartout, "LocationArea", "99999", 5)
FINSI

# mis a jour du champ cellId

SI(i_valid_field_n(g_iartin, $Tcrae_ssp::cellID))
ALORS
  val_CellId_660003962 = i_get_art_field(g_iartin, $Tcrae_ssp::cellID)
# ano 3315
  SI( (val_CellId_660003962 >= 0) && (val_CellId_660003962 <= 99999) )
# /ano 3315
  ALORS
    i_strcpy(pt_CellId_660003962,"")
    erreur_660003962 = Ajuster_taille_entier2_660003942(val_CellId_660003962, 5, pt_CellId_660003962)
    erreur_660003962 = i_memcpy_art_field_n(g_iartout, $Ttapin40::CellId, pt_CellId_660003962, 5)
  SINON
    erreur_660003962 = i_memcpy_art_field_n(g_iartout, $Ttapin40::CellId, "99999", 5)
  FINSI
SINON
  erreur_660003962 = i_memcpy_art_field_n(g_iartout, $Ttapin40::CellId, "99999", 5)
FINSI

# mis a jour du champ Mobile Station Mark

SI(!i_valid_field_n(g_iartin, $Tcrae_ssp::mblStMark))
ALORS
  val_champ_660003962 =0x34
SINON
  val_champ_660003962 = i_get_art_field(g_iartin, $Tcrae_ssp::mblStMark)
  SI((val_champ_660003962 >=0) && (val_champ_660003962 <=9))
  ALORS
    val_champ_660003962 = val_champ_660003962 + 0x30
  SINON
    val_champ_660003962 = Most_sgn_digit_660003942(val_champ_660003962)
    val_champ_660003962 = val_champ_660003962 + 0x30
  FINSI
FINSI
trace1(" mblStMark = %d", val_champ_660003962)
erreur_660003962 = i_memset_field(g_iartout, "MSClassMark", val_champ_660003962)

# mis a jour du champ UTCTimeoffsetCode
UTCOffcode_map_660003962  = 0x00
SI (i_valid_field_n(g_iartin, $Tcrae_ssp::UTCOffsetCode))
ALORS
  UTCOffcode_660003962  = i_get_art_field(g_iartin, $Tcrae_ssp::UTCOffsetCode)
  trace1("**Tcrae_ssp UTCOffsetcode TLV :<%x>", UTCOffcode_660003962 )
  #QC367 : le mapping se fait maintenant dans le pcode IECC
  UTCOffcode_map_660003962  = UTCOffcode_660003962
FINSI
trace1("**Tcrae_ssp UTCOffcode_map:<%x>", UTCOffcode_map_660003962 )
#si pas de mapping le champ garde sa valeur par  defaut (espace)
#QC657
SI (UTCOffcode_map_660003962 != -1)
ALORS
  erreur_660003962  = i_memset_field_n(g_iartout ,$Ttapin40::UTCTimeOff, UTCOffcode_map_660003962 )
FINSI

#mis a jour du champ Charge

chargeSM_660003962 = 0
ic_charge_660003962 = 1
indice_660003962  = 1

POINT  SOM_CHARGES

SI (indice_660003962 <= 50)
ALORS
  erreur_660003962  = i_EntierToString(indice_660003962 ,pt_indice_660003962,4)
  erreur_660003962 = i_format_str2(pt_charge_660003962,"%s%s","charge", pt_indice_660003962)
  erreur_660003962 = i_format_str2(pt_chargeType_660003962,"%s%s", "chargeType",pt_indice_660003962)
  SI(i_valid_field(g_iartin, pt_charge_660003962))
  ALORS
    ic_charge_660003962 = i_get_field_num(g_iartin,pt_charge_660003962 )
    SI(i_valid_field(g_iartin, pt_chargeType_660003962) == 1)
    ALORS
      erreur_660003962 = i_get_art_str(g_iartin, ic_charge_660003962 +1, pt_chargeType_660003962)
      trace2("chargeType est %s %s",pt_chargeType_660003962, "")
      SI ((i_strcmp(pt_chargeType_660003962, "0") == 0) || (i_strcmp(pt_chargeType_660003962, "00")== 0) || (i_strcmp(pt_chargeType_660003962, "000")==0))
      ALORS
        chargeSM_660003962 = chargeSM_660003962 + i_get_art_field(g_iartin, ic_charge_660003962)
      FINSI
    FINSI
  FINSI
  indice_660003962=indice_660003962+1
  SAUT SOM_CHARGES
FINSI

trace1("total des charges est %x", chargeSM_660003962)
i_strcpy(pt_chargeSM_660003962,"")
erreur_660003962 = Ajuster_taille_entier2_660003942(chargeSM_660003962, 9, pt_chargeSM_660003962)
erreur_660003962  = i_memcpy_art_field(g_iartout, "Charge",pt_chargeSM_660003962 , 9)

#mis a jour du champ ChargedItem
SI(chargeSM_660003962 != 0)
ALORS
  erreur_660003962  = i_memset_field_n(g_iartout ,$Ttapin40::ChargedItem, 0x45)
FINSI

#mis a jour du champ TaxRateCode
SI(chargeSM_660003962 == 0)
ALORS
# erreur  = i_memset_field_n(g_iartout ,$Ttapin40::TaxeRateCode, 0)
  erreur_660003962  = i_memcpy_art_field(g_iartout, "TaxeRateCode","0" , 1)
#SINON attente la reponse de SIFAC
FINSI

#mis a jour du champ ExcahngeRateCode
SI(chargeSM_660003962 != 0)
ALORS
  erreur_660003962  = i_memset_field_n(g_iartout ,$Ttapin40::ExchngRateCode, 0x45)
FINSI

#mis a jour du  champ idCrae
erreur_660003962 = i_get_field_str(g_iartin, "IdCrae",pt_IdCrae_660003962)
erreur_660003962  = i_memcpy_art_field(g_iartout, "IdCrae",pt_IdCrae_660003962,8)
trace2("pt_IdCrae %s %s", pt_IdCrae_660003962, "")

# Fin de duplication hors table  TAPIN40
trace("***Tcrae_ssp Fin de la duplication hors table ****")
#------------------------Fin de la duplication --------------------#

# G5R2lot2, QC1448
SI REDIST_IMSI_Transnational_M2M_660003962
ALORS
	SAUT PT_REDIS_Transnational
FINSI
#/G5R2lot2, QC1448

#-----------------------------------------------------------
# Attente requete Table de Distribution
# -----------------------------------------------------------

erreur_660003962  = i_LireReqConsTabDist()
trace1("<<<__LINE__<<<__FILE__<<< Retour de i_LireReqConsTabDist est %d",erreur_660003962)

SI (erreur_660003962 != 0)
ALORS
  # IMSI inconnu
  # G5R2lot2, QC1448
  SI IMSI_Transnational_M2M_660003962
  ALORS
    # IMSI Inconnu et transnational
    REDIST_IMSI_Transnational_M2M_660003962 = 1
    SAUT PT_REDIS_Transnational
  SINON
    # ---------------------------------------------------
    # Redistribution
    # ---------------------------------------------------
    SAUT REDISTRIB
  FINSI
  #/G5R2lot2, QC1448
FINSI

nombreECC_660003962  = i_LireNombreECC( )
trace1("<<<__LINE__<<<__FILE__<<< nombreECC %d", nombreECC_660003962)

SI (nombreECC_660003962 == 0)
ALORS
  # ECC absente
  # G5R2lot2, QC1448
  SI IMSI_Transnational_M2M_660003962
  ALORS
    # IMSI Inconnu et transnational
    REDIST_IMSI_Transnational_M2M_660003962 = 1
    SAUT PT_REDIS_Transnational
  SINON
    SAUT REDISTRIB
  FINSI
  #/G5R2lot2, QC1448
FINSI

instECC_660003962  = i_LireEntierECC(0)

SI (instECC_660003962 == -1)
ALORS
  # IMSI inconnu
  # G5R2lot2, QC1448
  SI IMSI_Transnational_M2M_660003962
  ALORS
    # IMSI Inconnu et transnational
    REDIST_IMSI_Transnational_M2M_660003962 = 1
    SAUT PT_REDIS_Transnational
  SINON
    SAUT REDISTRIB
  FINSI
  #/G5R2lot2, QC1448
FINSI

# G5R2lot2, QC1448
POINT PT_REDIS_Transnational

SI REDIST_IMSI_Transnational_M2M_660003962
ALORS
  trace("<<<__LINE__<<<__FILE__<<< **** NVDDCH ****")
  
  # Ajout dans le CRA du champ numero de filtre
  erreur_660003962 = i_ajout_tlv(g_iartin, "T3t3_NumOfFilte", "")
  erreur_660003962 = i_resize_tlv(g_iartin, "T3t3_NumOfFilte", "NumOfFilter", 1)
  SI (erreur_660003962!=0)
  ALORS
    trace("<<<__LINE__<<<__FILE__<<< Erreur d'ajout du TLV <T3t3_NumOfFilte>")
    code_rejet_660003962 = MODULE_DISTR_660003962 + ERR_DISTR_660003962 + EFFICACE_660003962
    erreur_660003962 = i_format_str2(pt_LibelleAlarme_660003962, "%s> <f=%s", "NumOfFilter", pt_NameOfFile_660003962)
    erreur_660003962 = i_PlvMessEmettre(8833, 2, g_iartin, "", 2, code_rejet_660003962, pt_LibelleAlarme_660003962, 0)
    SAUT STOCKE_ERRONE
  FINSI
  
  # Enrichissement du CRA par le numero de filtre
  erreur_660003962 = i_set_art_field(g_iartin, $Tcrae_ssp::NumOfFilter, 0x38)
  
  # Distribution vers NVDDCH
  instanceECC_660003962 = i_LireInstanceECC("NVDDCH")
  SI (instanceECC_660003962 == -1)
  ALORS
    trace("<<<__LINE__<<<__FILE__<<< Pas d'instance : NVDDCH")
    code_rejet_660003962 = MODULE_DISTR_660003962 + ERR_DISTR_660003962 + EFFICACE_660003962
    erreur_660003962 = i_format_str2(pt_LibelleAlarme_660003962, "%s> <f=%s", "NVDDCH", pt_NameOfFile_660003962)
    erreur_660003962 = i_PlvMessEmettre(8834, 2, g_iartin, "", 2, code_rejet_660003962, pt_LibelleAlarme_660003962, 0)
    SAUT STOCKE_ERRONE
  FINSI
  trace("<<<__LINE__<<<__FILE__<<< application NVDDCH")
  ptchp_format_660003962 = i_get_tab_field(FORMAT_ECC_660003962, date_cra_660003962, "NVDDCH")
  res_660003962 = Stockage_Article_660003942(g_iartin, g_iartout, g_iartout, instanceECC_660003962 , ptchp_format_660003962, date_fin_660003962, type_cra_660003962)
  
  SAUT ECC_SECONDAIRES
FINSI
#/G5R2lot2, QC1448

trace1("<<<__LINE__<<<__FILE__<<< Retour de i_LireEntierECC = <%d>",instECC_660003962  )

POINT CRITERES_DISTRI

#------------------------------------------------------
# Critre de distribution vers NVDDCH
#-----------------------------------------------------
SI(instECC_660003962  == i_LireInstanceECC("MSFGSM"))
ALORS
  trace("**** NVDDCH ****")
  # Enrichissement du CRA par le numero de filter
  erreur_660003962 = i_ajout_tlv(g_iartin, "T3t3_NumOfFilte", "")
  erreur_660003962 = i_resize_tlv(g_iartin, "T3t3_NumOfFilte", "NumOfFilter", 1)
  SI(erreur_660003962!=0)
  ALORS
    trace("Erreur d'ajout du TLV <T3t3_NumOfFilte>")
    SAUT STOCKE_ERRONE
  FINSI

  erreur_660003962 = i_set_art_field(g_iartin, $Tcrae_ssp::NumOfFilter, 0x22)
  instanceECC_660003962 = i_LireInstanceECC("NVDDCH")
  instNVDDCH_660003962 = instanceECC_660003962
  ptchp_format_660003962  = i_get_tab_field(FORMAT_ECC_660003962 , date_cra_660003962 , "NVDDCH")

  SI(instanceECC_660003962  == -1)
  ALORS
    trace("Pas d'ECC : NVDDCH")
    trace("**Tcrae_ssp , erreur d'envoi de l'article a l'application NVDDCH")
    erreur_660003962 = i_format_str2(pt_LibelleAlarme_660003962, "%s> <f=%s", "NVDDCH", pt_NameOfFile_660003962)
    erreur_660003962 = i_PlvMessEmettre(8868, 2, g_iartout, "", 3, code_rejet_660003962, type_cra_660003962, pt_LibelleAlarme_660003962)
    SAUT STOCKE_ERRONE
  SINON
    res_660003962 = Stockage_Article_660003942(g_iartin, g_iartout, g_iartout, instanceECC_660003962 , ptchp_format_660003962, date_fin_660003962, type_cra_660003962)
    SI(res_660003962  == 0 )
    ALORS
      trace("**Tcrae_ssp , erreur d'envoi de l'article a l'application NVDDCH")
      erreur_660003962 = i_format_str2(pt_LibelleAlarme_660003962, "%s> <f=%s", "NVDDCH", pt_NameOfFile_660003962)
      erreur_660003962 = i_PlvMessEmettre(8868, 2, g_iartout, "", 3, code_rejet_660003962, type_cra_660003962, pt_LibelleAlarme_660003962)
      SAUT STOCKE_ERRONE
    FINSI
    SAUT ECC_SECONDAIRES
  FINSI
FINSI

# G3R9 item COME
# -------------------------------- COMCH ou FRCDCH poubelle NVCDCH -------------------------------------------
# calcul de b_COMESI et des ID-instance de COMDCH et sinon FRCDCH
b_COMESI_660003962 =0
SI (instECC_660003962 == i_LireInstanceECC("COMGSM"))
ALORS
	b_COMESI_660003962 = 1
SINON
	SI (instECC_660003962 == i_LireInstanceECC("FRCGSM"))
	ALORS
		b_COMESI_660003962 = 2
	FINSI
FINSI

SI (b_COMESI_660003962)
ALORS
  instNVCDCH_660003962 = i_LireInstanceECC("NVCDCH")
  SI (instNVCDCH_660003962 == -1)
  ALORS
    trace("Pas d'instance : NVCDCH")
    code_rejet_660003962 = MODULE_DISTR_660003962 + ERR_DISTR_660003962 + EFFICACE_660003962
    erreur_660003962 = i_format_str2(pt_LibelleAlarme_660003962, "%s> <f=%s", "NVCDCH", pt_NameOfFile_660003962)
    erreur_660003962 = i_PlvMessEmettre(8854, 2, g_iartin, "", 2, code_rejet_660003962, pt_LibelleAlarme_660003962, 0)
    SAUT STOCKE_ERRONE
  FINSI
  # Enrichissement du CRA par le numero de filter
  erreur_660003962 = i_ajout_tlv(g_iartin, "T3t3_NumOfFilte", "")
  erreur_660003962 = i_resize_tlv(g_iartin, "T3t3_NumOfFilte", "NumOfFilter", 1)
  erreur_660003962 = i_set_art_field(g_iartin, $Tcrae_ssp::NumOfFilter, 0x24)

  ptchp_format_660003962 = i_get_tab_field(FORMAT_ECC_660003962, date_cra_660003962, "NVCDCH")
  res_660003962 = Stockage_Article_660003942(g_iartin, g_iartout, g_iartout, instNVCDCH_660003962 , ptchp_format_660003962, date_fin_660003962, type_cra_660003962)
  SI (res_660003962 == STCK_KO_660003962)
  ALORS
    trace("**Tcrae_ssp , erreur d'envoi de l'article a l'application NVCDCH")
    code_rejet_660003962 = MODULE_DISTR_660003962 + ERR_DISTR_660003962 + EFFICACE_660003962
    erreur_660003962 = i_format_str2(pt_LibelleAlarme_660003962, "%s> <f=%s", "NVCDCH", pt_NameOfFile_660003962)
    erreur_660003962 = i_PlvMessEmettre(8855, 2, g_iartin, "", 2, code_rejet_660003962, pt_LibelleAlarme_660003962, 0)
    SAUT STOCKE_ERRONE
  FINSI
  SAUT ECC_SECONDAIRES
FINSI

# -------------------------------- FEDCH poubelle NVDDCH -----------------------------------------------------
#--------------
#G3R9 lot2 FE
##--------------
SI(instECC_660003962 == i_LireInstanceECC("FEGSM"))
ALORS
  trace("**** NVDDCH ****")
  # Enrichissement du CRA par le numero de filter
  erreur_660003962 = i_ajout_tlv(g_iartin, "T3t3_NumOfFilte", "")
  erreur_660003962 = i_resize_tlv(g_iartin, "T3t3_NumOfFilte", "NumOfFilter", 1)
  SI(erreur_660003962!=0)
  ALORS
    trace("Erreur d'ajout du TLV <T3t3_NumOfFilte>")
    SAUT STOCKE_ERRONE
  FINSI
  erreur_660003962 = i_set_art_field(g_iartin, $Tcrae_ssp::NumOfFilter, 0x23)

  instNVDDCH_660003962 = i_LireInstanceECC("NVDDCH")

  SI (instNVDDCH_660003962  == -1)
  ALORS
    trace("Pas d'ECC : NVDDCH")
    trace("**Tcrae_ssp , erreur d'envoi de l'article a l'application NVDDCH")
    erreur_660003962 = i_format_str2(pt_LibelleAlarme_660003962, "%s> <f=%s", "NVDDCH", pt_NameOfFile_660003962)
    erreur_660003962 = i_PlvMessEmettre(8868, 2, g_iartout, "", 3, code_rejet_660003962, type_cra_660003962, pt_LibelleAlarme_660003962)
    SAUT STOCKE_ERRONE
  SINON
    ptchp_format_660003962  = i_get_tab_field(FORMAT_ECC_660003962 , date_cra_660003962 , "NVDDCH")
    res_660003962 = Stockage_Article_660003942(g_iartin, g_iartout, g_iartout, instNVDDCH_660003962 , ptchp_format_660003962, date_fin_660003962, type_cra_660003962)
    SI(res_660003962  == 0 )
    ALORS
      trace("**Tcrae_ssp , erreur d'envoi de l'article a l'application NVDDCH")
      erreur_660003962 = i_format_str2(pt_LibelleAlarme_660003962, "%s> <f=%s", "NVDDCH", pt_NameOfFile_660003962)
      erreur_660003962 = i_PlvMessEmettre(8868, 2, g_iartout, "", 3, code_rejet_660003962, type_cra_660003962, pt_LibelleAlarme_660003962)
      SAUT STOCKE_ERRONE
    FINSI
    SAUT ECC_SECONDAIRES
  FINSI
FINSI
#/G3R9 lot2 FE
# -------------------- VDIDCH, OLADCH, OL2DCH, OL3DCH, OR5DCH (ADV) poubelle NVADCH --------------------------
# ---------------------------------------------------
# criteres de distribution vers ADV
# ---------------------------------------------------
# Distribution vers l' application VDIGSM
#----------------------------------------------------
SI(instECC_660003962  == i_LireInstanceECC("VDIGSM"))
ALORS
  trace("**** VDIDCH ****")
  instanceECC_660003962  = i_LireInstanceECC("VDIDCH")
  instVDIDCH_660003962  = instanceECC_660003962
  # recherche dans la table externe Format_ECC le format de l'application
  ptchp_format_660003962  = i_get_tab_field(FORMAT_ECC_660003962 , date_cra_660003962 , "VDIDCH")

  SI(instanceECC_660003962  == -1)
  ALORS
    trace("Pas d'ECC : VDIDCH")
    trace("**Tcrae_ssp , erreur d'envoi de l'article a l'application VDIDCH")
    erreur_660003962 = i_format_str2(pt_LibelleAlarme_660003962, "%s> <f=%s", "VDIDCH", pt_NameOfFile_660003962)
    erreur_660003962 = i_PlvMessEmettre(8868, 2, g_iartout, "", 3, code_rejet_660003962, type_cra_660003962, pt_LibelleAlarme_660003962)
    SAUT STOCKE_ERRONE
  SINON
    res_660003962 = Stockage_Article_660003942(g_iartin, g_iartout, g_iartout, instanceECC_660003962 , ptchp_format_660003962, date_fin_660003962, type_cra_660003962)
    SI(res_660003962  == 0 )
    ALORS
      trace("**Tcrae_ssp , erreur d'envoi de l'article a l'application VDIDCH")
      erreur_660003962 = i_format_str2(pt_LibelleAlarme_660003962, "%s> <f=%s", "VDIDCH", pt_NameOfFile_660003962)
      erreur_660003962 = i_PlvMessEmettre(8868, 2, g_iartout, "", 3, code_rejet_660003962, type_cra_660003962, pt_LibelleAlarme_660003962)
      SAUT STOCKE_ERRONE
    FINSI
    SAUT ECC_SECONDAIRES
  FINSI
FINSI

#-------------------------------------------------------------------------------
#  Distribution vers l'application OLAGSM
#--------------------------------------------------------------------------------
SI(instECC_660003962  == i_LireInstanceECC("OLAGSM"))
ALORS
  trace("**** OLADCH ****")
  instanceECC_660003962  = i_LireInstanceECC("OLADCH")
  instOLADCH_660003962  =instanceECC_660003962
  # recherche dans la table externe Format_ECC le format de l'application
  ptchp_format_660003962  = i_get_tab_field(FORMAT_ECC_660003962 , date_cra_660003962 , "OLADCH")

  SI(instanceECC_660003962  == -1)
  ALORS
    trace("Pas d'ECC : OLADCH")
    trace("**Tcrae_ssp , erreur d'envoi de l'article a l'application OLADCH")
    erreur_660003962 = i_format_str2(pt_LibelleAlarme_660003962, "%s> <f=%s", "OLADCH", pt_NameOfFile_660003962)
    erreur_660003962 = i_PlvMessEmettre(8868, 2, g_iartout, "", 3, code_rejet_660003962, type_cra_660003962, pt_LibelleAlarme_660003962)
    SAUT STOCKE_ERRONE
  SINON
    res_660003962 = Stockage_Article_660003942(g_iartin, g_iartout, g_iartout, instanceECC_660003962 , ptchp_format_660003962, date_fin_660003962, type_cra_660003962)
    SI(res_660003962  == 0 )
    ALORS
      trace("**Tcrae_ssp , erreur d'envoi de l'article a l'application OLADCH")
      erreur_660003962 = i_format_str2(pt_LibelleAlarme_660003962, "%s> <f=%s", "OLADCH", pt_NameOfFile_660003962)
      erreur_660003962 = i_PlvMessEmettre(8868, 2, g_iartout, "", 3, code_rejet_660003962, type_cra_660003962, pt_LibelleAlarme_660003962)
      SAUT STOCKE_ERRONE
    FINSI
    SAUT ECC_SECONDAIRES
  FINSI
FINSI

#--------------------------------------------------------------------------------
#  Distribution vers l'application OL2DCH
#--------------------------------------------------------------------------------
SI(instECC_660003962  == i_LireInstanceECC("OL2GSM"))
ALORS
  trace("**** OL2DCH ****")
  instanceECC_660003962  = i_LireInstanceECC("OL2DCH")
  instOL2DCH_660003962  = instanceECC_660003962
  # recherche dans la table externe Format_ECC le format de l'application
  ptchp_format_660003962  = i_get_tab_field(FORMAT_ECC_660003962 , date_cra_660003962 , "OL2DCH")

  SI(instanceECC_660003962  == -1)
  ALORS
    trace("Pas d'ECC : OL2DCH")
    trace("**Tcrae_ssp , erreur d'envoi de l'article a l'application OL2DCH")
    erreur_660003962 = i_format_str2(pt_LibelleAlarme_660003962, "%s> <f=%s", "OL2DCH", pt_NameOfFile_660003962)
    erreur_660003962 = i_PlvMessEmettre(8868, 2, g_iartout, "", 3, code_rejet_660003962, type_cra_660003962, pt_LibelleAlarme_660003962)
    SAUT STOCKE_ERRONE
  SINON
    res_660003962 = Stockage_Article_660003942(g_iartin, g_iartout, g_iartout, instanceECC_660003962 , ptchp_format_660003962, date_fin_660003962, type_cra_660003962)
    SI(res_660003962  == 0 )
    ALORS
      trace("**Tcrae_ssp , erreur d'envoi de l'article a l'application OL2DCH")
      erreur_660003962 = i_format_str2(pt_LibelleAlarme_660003962, "%s> <f=%s", "OL2DCH", pt_NameOfFile_660003962)
      erreur_660003962 = i_PlvMessEmettre(8868, 2, g_iartout, "", 3, code_rejet_660003962, type_cra_660003962, pt_LibelleAlarme_660003962)
      SAUT STOCKE_ERRONE
    FINSI
    SAUT ECC_SECONDAIRES
  FINSI
FINSI

#--------------------------------------------------------------------------------
#  Distribution vers l'application OL3DCH
#--------------------------------------------------------------------------------
SI(instECC_660003962  == i_LireInstanceECC("OL3GSM"))
ALORS
  trace("**** OL3DCH ****")
  instanceECC_660003962  = i_LireInstanceECC("OL3DCH")
  instOL3DCH_660003962  = instanceECC_660003962
  # recherche dans la table externe Format_ECC le format de l'application
  ptchp_format_660003962  = i_get_tab_field(FORMAT_ECC_660003962 , date_cra_660003962 , "OL3DCH")

  SI(instanceECC_660003962  == -1)
  ALORS
    trace("Pas d'ECC : OL3DCH")
    trace("**Tcrae_ssp , erreur d'envoi de l'article a l'application OL3DCH")
    erreur_660003962 = i_format_str2(pt_LibelleAlarme_660003962, "%s> <f=%s", "OL3DCH", pt_NameOfFile_660003962)
    erreur_660003962 = i_PlvMessEmettre(8868, 2, g_iartout, "", 3, code_rejet_660003962, type_cra_660003962, pt_LibelleAlarme_660003962)
    SAUT STOCKE_ERRONE
  SINON
    res_660003962 = Stockage_Article_660003942(g_iartin, g_iartout, g_iartout, instanceECC_660003962 , ptchp_format_660003962, date_fin_660003962, type_cra_660003962)
    SI(res_660003962  == 0 )
    ALORS
      trace("**Tcrae_ssp , erreur d'envoi de l'article a l'application OL3DCH")
      erreur_660003962 = i_format_str2(pt_LibelleAlarme_660003962, "%s> <f=%s", "OL3DCH", pt_NameOfFile_660003962)
      erreur_660003962 = i_PlvMessEmettre(8868, 2, g_iartout, "", 3, code_rejet_660003962, type_cra_660003962, pt_LibelleAlarme_660003962)
      SAUT STOCKE_ERRONE
    FINSI
    SAUT ECC_SECONDAIRES
  FINSI
FINSI

#-------------------------------------------------------------------------------
#  Distribution vers l'application OR5DCH
#--------------------------------------------------------------------------------
SI(instECC_660003962  == i_LireInstanceECC("OR5GSM"))
ALORS
  trace("**** OR5DCH ****")
  instanceECC_660003962  = i_LireInstanceECC("OR5DCH")
  instOR5DCH_660003962 = instanceECC_660003962
  # recherche dans la table externe Format_ECC le format de l'application
  ptchp_format_660003962  = i_get_tab_field(FORMAT_ECC_660003962 , date_cra_660003962 , "OR5DCH")

  SI(instanceECC_660003962  == -1)
  ALORS
    trace("Pas d'ECC : OR5DCH")
    trace("**Tcrae_ssp , erreur d'envoi de l'article a l'application OR5DCH")
    erreur_660003962 = i_format_str2(pt_LibelleAlarme_660003962, "%s> <f=%s", "OR5DCH", pt_NameOfFile_660003962)
    erreur_660003962 = i_PlvMessEmettre(8868, 2, g_iartout, "", 3, code_rejet_660003962, type_cra_660003962, pt_LibelleAlarme_660003962)
    SAUT STOCKE_ERRONE
  SINON
    res_660003962 = Stockage_Article_660003942(g_iartin, g_iartout, g_iartout, instanceECC_660003962 , ptchp_format_660003962, date_fin_660003962, type_cra_660003962)
    SI(res_660003962  == 0 )
    ALORS
      trace("**Tcrae_ssp , erreur d'envoi de l'article a l'application OR5DCH")
      erreur_660003962 = i_format_str2(pt_LibelleAlarme_660003962, "%s> <f=%s", "OR5DCH", pt_NameOfFile_660003962)
      erreur_660003962 = i_PlvMessEmettre(8868, 2, g_iartout, "", 3, code_rejet_660003962, type_cra_660003962, pt_LibelleAlarme_660003962)
      SAUT STOCKE_ERRONE
    FINSI
    SAUT ECC_SECONDAIRES
  FINSI
FINSI

#--------------------------- Fin distribition vers  le groupe ADV -----------------------------------

#G2R6
#G4R5lot2 suppresion de VPF------------------ VPFDCH poubelle NVFDCH --------------------------------
#/G2R6

# -------------------------------- SHACHEM Mobicarte, CMODCH, M1GDCH---------------------------------
#-------------------------------------------------------------------
# Distribution vers SHACHEM Mobicarte
#-------------------------------------------------------------------
SI(instECC_660003962  == i_LireInstanceECC("SHMGSM"))
ALORS
  trace("**** M1GDCH ****")
  # Enrichissement du CRA par le numero de filter
  erreur_660003962 = i_ajout_tlv(g_iartin, "T3t3_NumOfFilte", "")
  erreur_660003962 = i_resize_tlv(g_iartin, "T3t3_NumOfFilte", "NumOfFilter", 1)
  SI(erreur_660003962!=0)
  ALORS
    trace("Erreur d'ajout du TLV <T3t3_NumOfFilte>")
    SAUT STOCKE_ERRONE
  FINSI
  erreur_660003962 = i_set_art_field(g_iartin, $Tcrae_ssp::NumOfFilter, 0x21)
  instanceECC_660003962  = i_LireInstanceECC("M1GDCH")
  instM1GDCH_660003962  = instanceECC_660003962
  # recherche dans la table externe Format_ECC le format de l'application
  ptchp_format_660003962  = i_get_tab_field(FORMAT_ECC_660003962 , date_cra_660003962 , "M1GDCH")

  SI(instanceECC_660003962  == -1)
  ALORS
    trace("Pas d'ECC : M1GDCH")
    trace("**Tcrae_ssp , erreur d'envoi de l'article a l'application M1GDCH")
    erreur_660003962 = i_format_str2(pt_LibelleAlarme_660003962, "%s> <f=%s", "M1GDCH", pt_NameOfFile_660003962)
    erreur_660003962 = i_PlvMessEmettre(8868, 2, g_iartout, "", 3, code_rejet_660003962, type_cra_660003962, pt_LibelleAlarme_660003962)
    SAUT STOCKE_ERRONE
  SINON
    res_660003962 = Stockage_Article_660003942(g_iartin, g_iartout, g_iartout, instanceECC_660003962 , ptchp_format_660003962, date_fin_660003962, type_cra_660003962)
    SI(res_660003962  == 0 )
    ALORS
      trace("**Tcrae_ssp , erreur d'envoi de l'article a l'application M1GDCH")
      erreur_660003962 = i_format_str2(pt_LibelleAlarme_660003962, "%s> <f=%s", "M1GDCH", pt_NameOfFile_660003962)
      erreur_660003962 = i_PlvMessEmettre(8868, 2, g_iartout, "", 3, code_rejet_660003962, type_cra_660003962, pt_LibelleAlarme_660003962)
      SAUT STOCKE_ERRONE
    FINSI
    SAUT ECC_SECONDAIRES
  FINSI
FINSI

# -------------------------------- SHACHEM CMO, CMODCH -------------------------------------------------------
#--------------------------------------------------------------------
# Distribution vers SHACHEM CMO
#-------------------------------------------------------------------
SI(instECC_660003962  == i_LireInstanceECC("SHPGSM"))
ALORS
  trace("**** CMODCH ****")
  # Enrichissement du CRA par le numero de filter
  erreur_660003962 = i_ajout_tlv(g_iartin, "T3t3_NumOfFilte", "")
  erreur_660003962 = i_resize_tlv(g_iartin, "T3t3_NumOfFilte", "NumOfFilter", 1)
  SI(erreur_660003962!=0)
  ALORS
    trace("Erreur d'ajout du TLV <T3t3_NumOfFilte>")
    SAUT STOCKE_ERRONE
  FINSI

  erreur_660003962 = i_set_art_field(g_iartin, $Tcrae_ssp::NumOfFilter, 0x22)
  instanceECC_660003962  = i_LireInstanceECC("CMODCH")
  instCMODCH_660003962  = instanceECC_660003962
  # recherche dans la table externe Format_ECC le format de l'application
  ptchp_format_660003962  = i_get_tab_field(FORMAT_ECC_660003962 , date_cra_660003962 , "CMODCH")

  SI(instanceECC_660003962  == -1)
  ALORS
    trace("Pas d'ECC : CMODCH")
    trace("**Tcrae_ssp , erreur d'envoi de l'article a l'apllication CMODCH")
    erreur_660003962 = i_format_str2(pt_LibelleAlarme_660003962, "%s> <f=%s", "CMODCH", pt_NameOfFile_660003962)
    erreur_660003962 = i_PlvMessEmettre(8868, 2, g_iartout, "", 3, code_rejet_660003962, type_cra_660003962, pt_LibelleAlarme_660003962)
    SAUT STOCKE_ERRONE
  SINON
    res_660003962 = Stockage_Article_660003942(g_iartin, g_iartout, g_iartout, instanceECC_660003962 , ptchp_format_660003962, date_fin_660003962, type_cra_660003962)
    SI(res_660003962  == 0 )
    ALORS
      trace("**Tcrae_ssp , erreur d'envoi de l'article a l'apllication CMODCH")
      erreur_660003962 = i_format_str2(pt_LibelleAlarme_660003962, "%s> <f=%s", "CMODCH", pt_NameOfFile_660003962)
      erreur_660003962 = i_PlvMessEmettre(8868, 2, g_iartout, "", 3, code_rejet_660003962, type_cra_660003962, pt_LibelleAlarme_660003962)
      SAUT STOCKE_ERRONE
    FINSI
    SAUT ECC_SECONDAIRES
  FINSI
FINSI

POINT REDISTRIB

#  Application de redistribution

SI (i_valid_field_n(g_iartin, $Tcrae_ssp::T3t2_DateOfRedi) == 0)
ALORS
  erreur_660003962  = i_ajout_tlv(g_iartin, "T3t2_DateOfRedi", "")
  erreur_660003962  = i_resize_tlv(g_iartin, "T3t2_DateOfRedi", "DateOfRedistri",4)
  erreur_660003962  = i_set_art_field(g_iartin ,$Tcrae_ssp::DateOfRedistri ,i_cur_time())
FINSI

val_champ_660003962 = i_get_art_field(g_iartin ,$Tcrae_ssp::DateOfRedistri)
#----------------------------------------------------------------------------------
# Envoi vers l'application ECDDCH tout CRA redistribue entre 0 et 6 jours
#-----------------------------------------------------------------------------------
# G1R9 QC184
instanceECC_660003962  = i_LireInstanceECC("ECDDCH")
SI(instanceECC_660003962  != -1)
ALORS
  ptchp_format_660003962 = i_get_tab_field(FORMAT_ECC_660003962, date_cra_660003962, "ECDDCH")
  res_660003962 = Stockage_Article_660003942(g_iartin, g_iartout, g_iartout, instanceECC_660003962 , ptchp_format_660003962, date_fin_660003962, type_cra_660003962)

  SI(res_660003962 == 0)
  ALORS
    trace("**Tcrae_ssp , erreur d'envoi de l'article a l'application ECDDCH")
    erreur_660003962 = i_format_str2(pt_LibelleAlarme_660003962, "%s> <f=%s", "ECDDCH", pt_NameOfFile_660003962)
    erreur_660003962 = i_PlvMessEmettre(8868, 2, g_iartout, "", 3, code_rejet_660003962, type_cra_660003962, pt_LibelleAlarme_660003962)
    SAUT STOCKE_ERRONE
  FINSI
FINSI
# / G1R9 QC184

POINT  ECC_SECONDAIRES

#--------------------------------------------------
# Application SYMPHONIE IMSI connu ou inconnu
#--------------------------------------------------
instanceECC_660003962  = i_LireInstanceECC("SYMDCH")
SI(instanceECC_660003962  != -1)
ALORS
  ptchp_format_660003962  = i_get_tab_field(FORMAT_ECC_660003962 , date_cra_660003962 , "SYMDCH")
  res_660003962 = Stockage_Article_660003942(g_iartin, g_iartout, g_iartout, instanceECC_660003962 , ptchp_format_660003962, date_fin_660003962, type_cra_660003962)
  SI(res_660003962   == 0 )
  ALORS
    trace("**Tcrae_ssp , erreur d'envoi de l'article a l'application SYMPHONIE")
    erreur_660003962 = i_format_str2(pt_LibelleAlarme_660003962, "%s> <f=%s", "SYMPHONIE", pt_NameOfFile_660003962)
    erreur_660003962 = i_PlvMessEmettre(8868, 2, g_iartout, "", 3, code_rejet_660003962, type_cra_660003962, pt_LibelleAlarme_660003962)
    SAUT STOCKE_ERRONE
  FINSI
FINSI

#--------------------------------------------------------------------------------
# les applications secondaires de (ADV et DISE, SHACHEM Mobicarte et SHACHEM CMO)
# sont : IRIS
#---------------------------------------------------------------------------------
#G4R5lot2 suppresion de VPF
SI (instNVDDCH_660003962 > 0 || instVDIDCH_660003962 >0 || instOLADCH_660003962 >0 ||
  instOL2DCH_660003962 > 0 || instOL3DCH_660003962 >0 || instOR5DCH_660003962 >0 || instM1GDCH_660003962 > 0 ||
  instCMODCH_660003962 > 0 || b_COMESI_660003962)
ALORS
  instanceECC_660003962  = i_LireInstanceECC("IRIDCH")
  SI(instanceECC_660003962  != -1)
  ALORS
    ptchp_format_660003962  = i_get_tab_field(FORMAT_ECC_660003962 , date_cra_660003962 , "IRIDCH")
    res_660003962 = Stockage_Article_660003942(g_iartin, g_iartout, g_iartout, instanceECC_660003962 , ptchp_format_660003962, date_fin_660003962, type_cra_660003962)
    SI(res_660003962   == 0 )
    ALORS
      trace("**Tcrae_ssp , erreur d'envoi de l'article a l'application IRIS")
      erreur_660003962 = i_format_str2(pt_LibelleAlarme_660003962, "%s> <f=%s", "IRIDCH", pt_NameOfFile_660003962)
      erreur_660003962 = i_PlvMessEmettre(8868, 2, g_iartout, "", 3, code_rejet_660003962, type_cra_660003962, pt_LibelleAlarme_660003962)
      SAUT STOCKE_ERRONE
    FINSI
  FINSI
FINSI

trace("### Tcrae_ssp : Fin de distributon pcode OK ####")

#-----------------------------------FIN PCODE DISTRIBUTION ssp -----------------------------------------

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

RETOUR TRAIT_OK
# stockage de l'article en errone

POINT STOCKE_ERRONE

erreur_660003962  = i_make_art_rej(g_iartin, g_iartout2, code_rejet_660003962 )
erreur_660003962  = i_stocke_art(g_iartout2,0,PT_ERRONE,0)
trace("**Tcrae_ssp , Article stocke en errone**")
#      RETOUR TRAIT_OK
RETOUR BAD_BLOC
#------------------------------------------- FIN Tcrae_ssp_dis.src --------------------------------------------
