DEFINITION Vrai_660003960 1
DEFINITION Faux_660003960 0
DEFINITION NUMTAB_660003960 1
DEFINITION ZONEMETRO_660003960 7
DEFINITION TD_Imsi_660003960 0x00
DEFINITION Oui_660003960 0x01
DEFINITION Non_660003960 0x00
DEFINITION STCK_KO_660003960 0x00
DEFINITION MODULE_DISTR_660003960 0xA000
DEFINITION ERR_DUPL_660003960 0x0D0
DEFINITION ERR_DISTR_660003960 0x110
DEFINITION EFFICACE_660003960 0x01
DEFINITION FORMAT_ECC_660003960 "Format_ECC"
DEFINITION CALL_NUM_PUSHTALK_660003960 "33689006121"
REGISTRE ENTIER erreur_660003960
REGISTRE ENTIER code_rejet_660003960
REGISTRE ENTIER ic_network_660003960
REGISTRE ENTIER type_cra_660003960
REGISTRE ENTIER date_cra_660003960
REGISTRE ENTIER gmt_date_cra_660003960
REGISTRE ENTIER date_fin_660003960
REGISTRE ENTIER indice_660003960
REGISTRE ENTIER indice2_660003960
REGISTRE ENTIER val_champ_660003960
REGISTRE ENTIER SSCode1_660003960
REGISTRE ENTIER SSCode2_660003960
REGISTRE ENTIER SSCode3_660003960
REGISTRE ENTIER SSCode4_660003960
REGISTRE ENTIER UTCOffcode_660003960
REGISTRE ENTIER UTCOffcode_map_660003960
REGISTRE ENTIER chrgdItem_prio_660003960
REGISTRE ENTIER chrgdItem_priout_660003960
REGISTRE ENTIER ic_chrgItem_prio_660003960
REGISTRE ENTIER ic_chrgItem_660003960
REGISTRE ENTIER ic_charge_660003960
REGISTRE ENTIER ic_chgblUnit_660003960
REGISTRE ENTIER val_chgblUnit_660003960
REGISTRE ENTIER val_chgdUnit_660003960
REGISTRE ENTIER val_charge_660003960
REGISTRE ENTIER chargeSM_660003960
REGISTRE ENTIER chargeSM_00_660003960
REGISTRE ENTIER chgblUnitsSM_660003960
REGISTRE ENTIER chgdUnitsSM_660003960
REGISTRE ENTIER appel_sms_660003960
REGISTRE ENTIER nombreECC_660003960
REGISTRE ENTIER res_660003960
REGISTRE ENTIER Push_to_talk_660003960
REGISTRE ENTIER FILT_SMMSRoaming_660003960
REGISTRE ENTIER SYSFACT_660003960
REGISTRE ENTIER instECC_660003960
REGISTRE ENTIER instanceECC_660003960
REGISTRE ENTIER instMSFDCH_660003960
REGISTRE ENTIER instFEDCH_660003960
REGISTRE ENTIER instVDIDCH_660003960
REGISTRE ENTIER instOLADCH_660003960
REGISTRE ENTIER instOL2DCH_660003960
REGISTRE ENTIER instOL3DCH_660003960
REGISTRE ENTIER instOR5DCH_660003960
REGISTRE ENTIER instCMODCH_660003960
REGISTRE ENTIER instM1GDCH_660003960
REGISTRE ENTIER instCOMDCH_660003960
REGISTRE ENTIER instFRCDCH_660003960
REGISTRE ENTIER instNVDDCH_660003960
REGISTRE ENTIER instNVCDCH_660003960
REGISTRE ENTIER date_table_660003960
REGISTRE ENTIER bDATE_MVNO_660003960
REGISTRE POINTEUR pt_IMSI_660003960
REGISTRE POINTEUR pt_Min_DCB_660003960
REGISTRE POINTEUR pt_localDatePtr_660003960
REGISTRE POINTEUR pt_localDateRes_660003960
REGISTRE POINTEUR pt_DateFiltSMS_660003960
REGISTRE POINTEUR pt_calledNumber_660003960
REGISTRE POINTEUR pt_chrgItem_cour_660003960
REGISTRE POINTEUR pt_chrgItem_660003960
REGISTRE POINTEUR pt_ic_chrgItem_660003960
REGISTRE POINTEUR pt_ic1_chgblUns_660003960
REGISTRE POINTEUR pt_ic2_chgblUns_660003960
REGISTRE POINTEUR pt_ic3_chgblUns_660003960
REGISTRE POINTEUR pt_ic_chgblUns_660003960
REGISTRE POINTEUR pt_ic1_charge_660003960
REGISTRE POINTEUR pt_ic2_charge_660003960
REGISTRE POINTEUR pt_ic3_charge_660003960
REGISTRE POINTEUR pt_ic_charge_660003960
REGISTRE POINTEUR pt_chgblUnitsSM_660003960
REGISTRE POINTEUR pt_chgdUnitsSM_660003960
REGISTRE POINTEUR pt_chargeType_660003960
REGISTRE POINTEUR pt_resultat_660003960
REGISTRE POINTEUR pt_champ_660003960
REGISTRE POINTEUR pt_Date_660003960
REGISTRE POINTEUR pt_LibelleAlarme_660003960
REGISTRE POINTEUR pt_NameOfFile_660003960
REGISTRE POINTEUR ptchp_format_660003960
REGISTRE ENTIER b_CRA_nonreval_COME_660003960
REGISTRE ENTIER b_FE_Eligible_COME_660003960
REGISTRE ENTIER b_COMESI_660003960
REGISTRE POINTEUR pt1_660003960
REGISTRE ENTIER IMSI_Transnational_M2M_660003960
REGISTRE ENTIER REDIST_IMSI_Transnational_M2M_660003960
REGISTRE POINTEUR pt_MCCMNCx_660003960
REGISTRE POINTEUR pt_IMSIy_660003960
REGISTRE POINTEUR str_conteneur_660003960
REGISTRE POINTEUR ptr_res_660003960
#            **   **     ****    ****
#            * * * *    *    *  *
#            *  *  *    *    *  *
#            *     *    *    *  *
#            *     *     ****     ***
#
#                     - Pcode du module de distribution : CRAE MOC, aricle : Tcrae_moc
#                         - creation le 21/09/2006
#                         - Auteur : RAS
#  Ttapin20
#  g_iartin   : Tcrae_moc
#  g_iartout  = TAP2++
#  g_iartout5 = TAP2.5
#  g_iartout2 = rejet (copie de g_iartin)
#
# HISTORIQUE:
# creation : 21/09/2006
# 18/12/2006: FO381 decalage du mapping de TAPIN20/UTCTimeOff
# 22/12/2006: FO383 passage des champs <SupSvcActCode> en HEXA
# 27/12/2006: FO395 Mis a jour du champ chargedItem
# 09/02/2007: FO381 annulee
# 05/04/2007: FE0069 S-MMS en roaming out
# 14/11/2007: TT0052
# 21/12/2007 : URS G1R6 : retait ADV-VI et PANEL
# 21/02/2008 : URS G1R6 : report G1R5 (SOFRECOM 3.0/586)
# 13/08/2008 - URS - Param ME-G1R9
# 08/09/2008 - URS - Param ME-G1R9 QC184
# 11/09/2008 - URS - Param ME-G1R9 QC189
# 28/10/2009 - DECI - G2R5 lot 1 : modification filtre pour DISE
# 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)
# 17/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
# 07/12/2011 - DECI - G3R5 lot1 filtrage SMS MVNO prepayes avec date parametree et suppression de DATE ROAMING SMS 
# 28/12/2011 - DECI - QC985 filtrage SMS MVNO prepayes avec date parametree et suppression de DATE ROAMING SMS
# 31/01/2013 - DECI - G3R9 lot2 item COME
# 08/08/2014 - JLG  - G5R2 lot2 : Ajout variables fonctionnelles MCCMNCx, IMSIy, IMSI_Transnational_M2M, Ajout controle sur Imsi, Filtrage des IMSIs inconnus vers NVDDCH (au lieu de ECDDCH) si IMSI transnational
# 20/08/2014 - JLG  - G5R2 lot2 : Corrections suite  a VerifPcode (pointeurs et entiers)
# 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



#QC913

#G4R5lot2 suppresion de VPF

#G3R5 lot1
#/G3R5 lot1

# G1R9



# G5R2lot2
#/G5R2lot2


# initialisation des variables

type_cra_660003960 = 0x14
appel_sms_660003960 = 0x00
Push_to_talk_660003960 = Non_660003960
SSCode1_660003960 = 0
SSCode2_660003960 = 0
SSCode3_660003960 = 0
SSCode4_660003960 = 0
instMSFDCH_660003960 =-1
instFEDCH_660003960 = -1
instCOMDCH_660003960 = -1
instFRCDCH_660003960 = -1
b_COMESI_660003960 = 0

instVDIDCH_660003960 =-1
instOLADCH_660003960 =-1
instOL2DCH_660003960 =-1
instOL3DCH_660003960 =-1
instOR5DCH_660003960 =-1
instCMODCH_660003960 =-1
instM1GDCH_660003960 =-1
#G2R6
#G4R5lot2 suppresion de VPF
#/G2R6



pt_IMSI_660003960 = "pt_IMSI24680135790246800000000000000000"
pt_Min_DCB_660003960 = "pt_Min_DCB5471456879"
pt_localDatePtr_660003960 ="19791225102412"
pt_localDateRes_660003960 ="20061026143142"
pt_DateFiltSMS_660003960 ="200704061741371111"
pt_calledNumber_660003960="pt_calledNumber89765432109876543210"
pt_ic_chrgItem_660003960 ="Ms"
pt_chrgItem_cour_660003960 ="Ns"
pt_chrgItem_660003960="chargedItem12"
pt_ic1_chgblUns_660003960="3111"
pt_ic2_chgblUns_660003960="1111"
pt_ic3_chgblUns_660003960="3333_1111"
pt_ic_chgblUns_660003960="chgblUnits3333_1111"
pt_chgblUnitsSM_660003960="241256"
pt_chgdUnitsSM_660003960 ="475478"
pt_ic1_charge_660003960="5555"
pt_ic2_charge_660003960="1717"
pt_ic3_charge_660003960="5555_1717"
pt_ic_charge_660003960 ="charge2555_1414"
pt_chargeType_660003960 ="1745"
pt_resultat_660003960="745894512356748"
pt_champ_660003960="57682"
# G1R9
pt_Date_660003960 = "pt_Date11223344555"

pt_LibelleAlarme_660003960="pt_LibelleAlarme_111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"
i_strcpy(pt_LibelleAlarme_660003960,"")
pt_NameOfFile_660003960="NameOfFile0123456780111111111111189012345678901234567890123456789012345672345678190123456789012345678901234567890123456789012345"
i_strcpy(pt_NameOfFile_660003960,"")
ptchp_format_660003960 = "ptchp_formatptchp_format"
pt1_660003960= "pt1_222222222222222222"

# G5R2lot2
IMSI_Transnational_M2M_660003960 = 0
REDIST_IMSI_Transnational_M2M_660003960 = 0
pt_MCCMNCx_660003960 = "pt_MCCMNCx12"
i_strcpy(pt_MCCMNCx_660003960,"")
pt_IMSIy_660003960   = "pt_IMSIy1234"
i_strcpy(pt_IMSIy_660003960,"")
str_conteneur_660003960 = "str_conteneur123456789"
i_strcpy(str_conteneur_660003960,"")
ptr_res_660003960    = "ptr_res12345"
i_strcpy(ptr_res_660003960,"")
#/G5R2lot2

#-----------------------------------

trace("   -----------------------------------------------"   )
trace("  |  TCRAE_MOC :DEBUT PCODE DE DISTRIBUTION MOC   |"  )
trace("   -----------------------------------------------"   )

i_strcpy(pt_IMSI_660003960,"")
i_strcpy(pt_Min_DCB_660003960,"")
i_strcpy(pt_localDateRes_660003960,"")
i_strcpy(pt_DateFiltSMS_660003960,"")
i_strcpy(pt_calledNumber_660003960,"")
i_strcpy(pt_chrgItem_cour_660003960,"")
i_strcpy(pt_ic_chrgItem_660003960,"")
i_strcpy(pt_ic1_chgblUns_660003960,"")
i_strcpy(pt_ic2_chgblUns_660003960,"")
i_strcpy(pt_ic1_charge_660003960,"")
i_strcpy(pt_ic2_charge_660003960,"")
i_strcpy(pt_chgblUnitsSM_660003960,"")
i_strcpy(pt_chgdUnitsSM_660003960,"")
i_strcpy(pt_chargeType_660003960,"")
i_strcpy(pt_resultat_660003960,"")
#i_strcpy(pt_champ,"") fait plus bas
i_strcpy(pt_Date_660003960,"")



# G3R4 QC852
erreur_660003960 = i_get_art_str(g_iartin, $Tcrae_moc::NameOfFile, pt_NameOfFile_660003960)
# /G3R4 QC852

#--------------------------------------------------------------------------
#| Recherer IMSI a partir du MSISDN                                       |
#--------------------------------------------------------------------------

date_cra_660003960  = i_get_art_field(g_iartin, $Tcrae_moc::ddebut)
#QC913
gmt_date_cra_660003960 = i_DHgetCe2gTime(NUMTAB_660003960,ZONEMETRO_660003960,date_cra_660003960)

SI (i_valid_field_n(g_iartin, $Tcrae_moc::IMSI))
ALORS
  trace("<<<__LINE__<<<__FILE__<<< MAJ du champ <IMSI> avec le champ IMSI  d entree")
  erreur_660003960 = i_get_art_str(g_iartin, $Tcrae_moc::IMSI, pt_IMSI_660003960)
SINON
	trace("<<<__LINE__<<<__FILE__<<< MAJ du champ <IMSI> avec le champ Min  d entree")
  erreur_660003960 = i_get_art_str(g_iartin, $Tcrae_moc::Min, pt_IMSI_660003960)
FINSI

# G5R2 lot2
# calcul de pt_MCCMNCx, pt_IMSIy, IMSI_Transnational_M2M
i_get_sub_str(pt_IMSI_660003960, 0, 5, pt_MCCMNCx_660003960)
i_get_sub_str(pt_IMSI_660003960, 6, 6, pt_IMSIy_660003960)
erreur_660003960 = i_format_str2(str_conteneur_660003960, "%s%s", "M2M_", pt_MCCMNCx_660003960)
i_strcpy(ptr_res_660003960, i_get_tab_field("MVNO", date_cra_660003960, str_conteneur_660003960))
# equivallent a QC1441 : anomalie core de i_adequation_chaine_expreg
SI (i_strcmp(pt_IMSIy_660003960, "") != 0 && i_strcmp(ptr_res_660003960, "") != 0)
ALORS
  SI ( i_strcmp(ptr_res_660003960,"Tous") == 0 || i_adequation_chaine_expreg(ptr_res_660003960, pt_IMSIy_660003960) == 0)
  ALORS
    IMSI_Transnational_M2M_660003960 = Vrai_660003960
  SINON
    IMSI_Transnational_M2M_660003960 = Faux_660003960
  FINSI
SINON
  IMSI_Transnational_M2M_660003960 = Faux_660003960
FINSI
#/QC1441
#/G5R2 lot2


erreur_660003960 = i_conv_ascii_dcb(pt_IMSI_660003960 , pt_Min_DCB_660003960)
erreur_660003960 = i_EnvoiReqConsTabDist(TD_Imsi_660003960, gmt_date_cra_660003960, pt_Min_DCB_660003960, 8, 0, 1)
trace1("Retour de i_EnvoiReqConsTabDist TD_Imsi = <%d>",erreur_660003960)


SI (erreur_660003960 != 0)
ALORS
  # IMSI inconnu
  SI IMSI_Transnational_M2M_660003960
  ALORS
    # IMSI Inconnu et transnational
    REDIST_IMSI_Transnational_M2M_660003960 = 1
  SINON
    SAUT REDISTRIB
  FINSI
FINSI

#----------------------------------------------------------------------------------
#| duplication vers le format TAP2++ et TAP2.5                                    |
#|  g_iartout = TAP2++ et g_iartout5 = TAP2.5                                     |
#----------------------------------------------------------------------------------

erreur_660003960 = i_dup_art_dest(g_iartin , g_iartout , "Ttapin20")

SI (erreur_660003960 !=0)
ALORS
  trace("Tcrae_moc, erreur de duplication vers le format TAPIN20**")
  code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DUPL_660003960 + EFFICACE_660003960
  erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "Ttapin20", pt_NameOfFile_660003960)
  erreur_660003960 = i_PlvMessEmettre(8832, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
  SAUT STOCKE_ERRONE
FINSI

# complement de duplication hors table  TAPIN20
# mis a jour du champ RecordType
#-----------------------------------------------
erreur_660003960 = i_memcpy_art_field_n(g_iartout , $Ttapin20::RecordType, "20" ,2)

# mis a jour du champ NetworkType
#---------------------------------

erreur_660003960 = i_get_art_field(g_iartin, $Tcrae_moc::NetworkType)
SI ( erreur_660003960 == 0)
ALORS
  ic_network_660003960 = $Tcrae_moc::MoNetworkType
SINON
  ic_network_660003960 = $Tcrae_moc::NetworkType
FINSI

erreur_660003960 = i_get_art_field(g_iartin, ic_network_660003960)

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

# mis a jour du champ IMSI
#---------------------------

SI (i_valid_field_n(g_iartin, $Tcrae_moc::IMSI))
ALORS
  erreur_660003960 = i_get_field_str(g_iartin, "IMSI", pt_IMSI_660003960)
SINON
  erreur_660003960 = i_get_field_str(g_iartin, "Min", pt_IMSI_660003960)
FINSI

erreur_660003960 = i_memcpy_art_field_n(g_iartout, $Ttapin20::IMSI, pt_IMSI_660003960, i_strlen(pt_IMSI_660003960))
SI (erreur_660003960!=0)
ALORS
  trace("Tcrae_moc , erreur de mise a jour du champ <IMSI>")
  code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DUPL_660003960 + EFFICACE_660003960
  erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "IMSI", pt_NameOfFile_660003960)
  erreur_660003960 = i_PlvMessEmettre(8831, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
  SAUT STOCKE_ERRONE
FINSI


# mis a jour du champ IMEI
#--------------------------

SI ( i_valid_field_n(g_iartin, $Tcrae_moc::IMEI))
ALORS
  erreur_660003960 = i_get_field_str(g_iartin, "IMEI", pt_IMSI_660003960)
  erreur_660003960 = i_memcpy_art_field_n(g_iartout, $Ttapin20::IMEI ,pt_IMSI_660003960, i_strlen(pt_IMSI_660003960))
  SI (erreur_660003960!=0)
  ALORS
    trace("Tcrae_moc , erreur de mise a jour du champ <IMEI>")
    code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DUPL_660003960 + EFFICACE_660003960
    erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "IMEI", pt_NameOfFile_660003960)
    erreur_660003960 = i_PlvMessEmettre(8831, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
    SAUT STOCKE_ERRONE
  FINSI
FINSI

# mis a jour des champs Modification Indicator, TON et NPI
#----------------------------------------------------------

SI (i_valid_field_n(g_iartin, $Tcrae_moc::calledNumber))
ALORS
  erreur_660003960 = i_memset_field_n(g_iartout, $Ttapin20::ModifIndic, 0x30)
  erreur_660003960 = i_memset_field_n(g_iartout, $Ttapin20::TON, 0x58)
  erreur_660003960 = i_memset_field_n(g_iartout, $Ttapin20::NPI, 0x58)
FINSI

# mis a jour du champ calledNumber
#---------------------------------

SI (i_valid_field_n(g_iartin, $Tcrae_moc::calledNumber))
ALORS
  erreur_660003960 = i_get_field_str(g_iartin, "calledNumber", pt_calledNumber_660003960)
# TT 49
# si taille superieure a taille champ de sortie, on tronque
  res_660003960 = i_strlen(pt_calledNumber_660003960)
  SI (res_660003960 > 21)
  ALORS
    res_660003960=21
  FINSI
# erreur = i_memcpy_art_field_n(g_iartout, $Ttapin20::CalledNumber, pt_calledNumber, i_strlen(pt_calledNumber))
  erreur_660003960 = i_memcpy_art_field_n(g_iartout, $Ttapin20::CalledNumber, pt_calledNumber_660003960, res_660003960)
# /TT 49
  SI (erreur_660003960!=0)
  ALORS
    trace("Tcrae_moc , erreur de mise a jour du champ <CalledNumber>")
    code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DUPL_660003960 + EFFICACE_660003960
    erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "CalledNumber", pt_NameOfFile_660003960)
    erreur_660003960 = i_PlvMessEmettre(8831, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
    SAUT STOCKE_ERRONE
  FINSI
SINON
  SI (i_valid_field_n(g_iartin, $Tcrae_moc::DialledDigits))
  ALORS
    erreur_660003960 = i_get_field_str(g_iartin, "DialledDigits", pt_calledNumber_660003960)
# TT 49
# si taille superieure a taille champ de sortie, on tronque
    res_660003960 = i_strlen(pt_calledNumber_660003960)
    SI (res_660003960 > 21)
    ALORS
      res_660003960=21
    FINSI
#   erreur = i_memcpy_art_field_n(g_iartout, $Ttapin20::CalledNumber, pt_calledNumber, i_strlen(pt_calledNumber))
    erreur_660003960 = i_memcpy_art_field_n(g_iartout, $Ttapin20::CalledNumber, pt_calledNumber_660003960, res_660003960)
# /TT 49
    SI (erreur_660003960!=0)
    ALORS
      trace("Tcrae_moc , erreur de mise a jour du champ <CalledNumber>")
      code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DUPL_660003960 + EFFICACE_660003960
      erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "CalledNumber", pt_NameOfFile_660003960)
      erreur_660003960 = i_PlvMessEmettre(8831, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
      SAUT STOCKE_ERRONE
    FINSI
  FINSI
FINSI

# mis a jour des champs ServiceType et ServiceCode
# SI TelserviceCode est present => 0  , Si BearederServiceCode present => 1
#--------------------------------------------------------------------------

SI (i_valid_field_n(g_iartin, $Tcrae_moc::TeleserviceCode))
ALORS
  erreur_660003960 = i_memset_field_n(g_iartout ,$Ttapin20::ServiceType, 0x30)
  erreur_660003960 = i_memcpy_art_field(g_iartout, "ServiceCode", g_iartin.TeleserviceCode[], 2)
SINON
  erreur_660003960 = i_memset_field_n(g_iartout ,$Ttapin20::ServiceType, 0x31)
  erreur_660003960 = i_memcpy_art_field(g_iartout, "ServiceCode", g_iartin.BearerSvcCode[], 2)
FINSI

# mis a jour des champs DualServiceType et DualServiceCode
#----------------------------------------------------------

SI (i_valid_field_n(g_iartin, $Tcrae_moc::DualTeleservice))
ALORS
  erreur_660003960 = i_memset_field_n(g_iartout ,$Ttapin20::DualSvcType, 0x30)
  erreur_660003960 = i_memcpy_art_field(g_iartout, "DualSvcCode", g_iartin.DualTeleservice[], 2)
FINSI

SI (i_valid_field_n(g_iartin, $Tcrae_moc::DualBearerSvc))
ALORS
  erreur_660003960 = i_memset_field_n(g_iartout ,$Ttapin20::DualSvcType, 0x31)
  erreur_660003960 = i_memcpy_art_field(g_iartout, "DualSvcCode", g_iartin.DualBearerSvc[], 2)
FINSI

# mis a jour du champ RadioChanelRequest
#---------------------------------------

val_champ_660003960 = i_get_art_field(g_iartin, $Tcrae_moc::RadioChnlReq)
SI ( val_champ_660003960 >=0 && val_champ_660003960 <=3)
ALORS
  val_champ_660003960 = val_champ_660003960 + 0x30
  erreur_660003960 =i_memset_field_n(g_iartout, $Ttapin20::RadioChnlReq, val_champ_660003960)
FINSI

# mis a jour du champ RadioChanelUsed
#------------------------------------

val_champ_660003960 = i_get_art_field(g_iartin, $Tcrae_moc::RadioChnlUsed)
SI ( (val_champ_660003960 ==0 )||(val_champ_660003960 ==1))
ALORS
  val_champ_660003960 = val_champ_660003960 + 0x30
  erreur_660003960 =i_memset_field_n(g_iartout, $Ttapin20::RadioChnlUsed, val_champ_660003960)
FINSI

# mis a jour du champ Transparency Indicator
#--------------------------------------------

val_champ_660003960 = i_get_art_field(g_iartin, $Tcrae_moc::TransparcIndic)
SI ( (val_champ_660003960 ==0)|| (val_champ_660003960 ==1))
ALORS
  val_champ_660003960 = val_champ_660003960 + 0x30
  erreur_660003960 = i_memset_field_n(g_iartout, $Ttapin20::TranspIndic, val_champ_660003960)
FINSI

#-------------------------------------------------------------
#| mis a jour des champs SSCode1,2 et ActionCode1,2          |
#-------------------------------------------------------------
# FO 383 : passage de SupSvcActCode en HEXA

SI (i_valid_field_n(g_iartin, $Tcrae_moc::SupSvcActCode1))
ALORS
  val_champ_660003960 = i_get_art_field(g_iartin, $Tcrae_moc::SupSvcActCode1)

  SI ( val_champ_660003960==0x05 )
  ALORS
    trace1("GR1 SupSvcActCode1 =0x0%x", val_champ_660003960)
    i_strcpy(pt_champ_660003960,"")
    erreur_660003960 = i_get_field_str(g_iartin, "SupSvcCode1", pt_champ_660003960)

    SI ((!i_strcmp(pt_champ_660003960,"28"))||(!i_strcmp(pt_champ_660003960,"29"))||(!i_strcmp(pt_champ_660003960,"2A"))||(!i_strcmp(pt_champ_660003960,"2B")))
    ALORS
      trace2("GR1 SupSvcCode1 =%s", pt_champ_660003960, 0)
      erreur_660003960 = i_memset_field(g_iartout, "ActionCode1", 0x35)
      erreur_660003960 = i_memcpy_art_field(g_iartout,"SSCode1",g_iartin.SupSvcCode1[],2)
      SSCode1_660003960 = 1
      # SSCode1 est pris par le premier groupe
      SAUT  DEUXM_SSCODE
    FINSI
  FINSI
FINSI

SI (i_valid_field_n(g_iartin, $Tcrae_moc::SupSvcActCode2))
ALORS
  val_champ_660003960 = i_get_art_field(g_iartin, $Tcrae_moc::SupSvcActCode2)

  SI ( val_champ_660003960==0x05 )
  ALORS
    trace1("GR1 SupSvcActCode2 =0x0%x", val_champ_660003960)
    i_strcpy(pt_champ_660003960,"")
    erreur_660003960 = i_get_field_str(g_iartin, "SupSvcCode2", pt_champ_660003960)

    SI ((!i_strcmp(pt_champ_660003960,"28"))||(!i_strcmp(pt_champ_660003960,"29"))||(!i_strcmp(pt_champ_660003960,"2A"))||(!i_strcmp(pt_champ_660003960,"2B")))
    ALORS
      trace2("GR1 SupSvcCode2 =%s", pt_champ_660003960, 0)
      erreur_660003960 = i_memset_field(g_iartout, "ActionCode1", 0x35)
      erreur_660003960 = i_memcpy_art_field(g_iartout,"SSCode1",g_iartin.SupSvcCode2[],2)
      SSCode2_660003960 = 1
      # SSCode2 est pris par le premier groupe
      SAUT  DEUXM_SSCODE
    FINSI
  FINSI
FINSI

SI (i_valid_field_n(g_iartin, $Tcrae_moc::SupSvcActCode3))
ALORS
  val_champ_660003960 = i_get_art_field(g_iartin, $Tcrae_moc::SupSvcActCode3)

  SI ( val_champ_660003960==0x05 )
  ALORS
    trace1("GR1 SupSvcActCode3 =0x0%x", val_champ_660003960)
    i_strcpy(pt_champ_660003960,"")
    erreur_660003960 = i_get_field_str(g_iartin, "SupSvcCode3", pt_champ_660003960)

    SI ((!i_strcmp(pt_champ_660003960,"28"))||(!i_strcmp(pt_champ_660003960,"29"))||(!i_strcmp(pt_champ_660003960,"2A"))||(!i_strcmp(pt_champ_660003960,"2B")))
    ALORS
      trace2("GR1 SupSvcCode3 =%s", pt_champ_660003960, 0)
      erreur_660003960 = i_memset_field(g_iartout, "ActionCode1", 0x35)
      erreur_660003960 = i_memcpy_art_field(g_iartout,"SSCode1",g_iartin.SupSvcCode3[],2)
      SSCode3_660003960 = 1
      # SSCode2 est pris par le premier groupe
      SAUT  DEUXM_SSCODE
    FINSI
  FINSI
FINSI

SI (i_valid_field_n(g_iartin, $Tcrae_moc::SupSvcActCode4))
ALORS
  val_champ_660003960 = i_get_art_field(g_iartin, $Tcrae_moc::SupSvcActCode4)

  SI ( val_champ_660003960==0x05 )
  ALORS
    trace1("GR1 SupSvcActCode4 =0x0%x", val_champ_660003960)
    i_strcpy(pt_champ_660003960,"")
    erreur_660003960 = i_get_field_str(g_iartin, "SupSvcCode4", pt_champ_660003960)

    SI ((!i_strcmp(pt_champ_660003960,"28"))||(!i_strcmp(pt_champ_660003960,"29"))||(!i_strcmp(pt_champ_660003960,"2A"))||(!i_strcmp(pt_champ_660003960,"2B")))
    ALORS
      trace2("GR1 SupSvcCode4 =%s", pt_champ_660003960, 0)
      erreur_660003960 = i_memset_field(g_iartout, "ActionCode1", 0x35)
      erreur_660003960 = i_memcpy_art_field(g_iartout,"SSCode1",g_iartin.SupSvcCode4[],2)
      SSCode4_660003960 = 1
      # SSCode4 est pris par le premier groupe
      SAUT  DEUXM_SSCODE
    FINSI
  FINSI
FINSI

# MISE EN COMMENT du test sur le SupSvcActCode5 pour la contrainte du nombre de champ dans l'article
# SupSvcActCode5 est supprime de l'article
#                  SINON
#                        val_champ = i_get_art_field(g_iartin, $Tcrae_moc::SupSvcActCode5)
#                        SI (val_champ == 5)
#                        ALORS
#                              val_champ = i_get_art_field(g_iartin, $Tcrae_moc::SupSvcCode5)
#                              SI (val_champ >= 0x28 && val_champ <= 0x2B)
#                              ALORS
#                      erreur = i_memcpy_art_field(g_iartout,"ActionCode1",g_iartin.SupSvcActCode5[],1)
#                      erreur = i_memcpy_art_field(g_iartout,"SSCode1",g_iartin.SupSvcCode5[],2)
#                                     SSCode5 = 1
#                                     # SSCode4 est pris par le premier groupe
#                              FINSI
#                        FINSI

POINT  DEUXM_SSCODE

## recherche du deuxieme groupe SupSvcAvtCode,SupSvcCode
# si SSCode1,2,3 sont libres , probablement le 4 est pris par le premier groupe
# le test devra se faire jusqu'au le 4 code (3 est provisoire)
# SI ( (SSCode1==0) && (SSCode2==0) && (SSCode3==0) && (SSCode4==0))
#--------------------------------------------------------------------------------

SI ( (SSCode1_660003960==0) && (SSCode2_660003960==0) && (SSCode3_660003960==0))
ALORS
  SAUT SUITE_MAJ_DUPL
FINSI

SI (i_valid_field_n(g_iartin, $Tcrae_moc::SupSvcActCode2))
ALORS
  val_champ_660003960 = i_get_art_field(g_iartin, $Tcrae_moc::SupSvcActCode2)

  SI ((val_champ_660003960==0x05)&&(SSCode2_660003960==0))
  ALORS
    trace1("GR2 SupSvcActCode2 =0x0%x", val_champ_660003960)
    i_strcpy(pt_champ_660003960,"")
    erreur_660003960 =i_get_field_str(g_iartin, "SupSvcCode2", pt_champ_660003960)

    SI ((!i_strcmp(pt_champ_660003960,"28"))||(!i_strcmp(pt_champ_660003960,"29"))||(!i_strcmp(pt_champ_660003960,"2A"))||(!i_strcmp(pt_champ_660003960,"2B")))
    ALORS
      trace2("GR2 SupSvcCode2 =%s", pt_champ_660003960, 0)
      erreur_660003960 = i_memset_field(g_iartout, "ActionCode2", 0x35)
      erreur_660003960 = i_memcpy_art_field(g_iartout,"SSCode2",g_iartin.SupSvcCode2[],2)
      SAUT SUITE_MAJ_DUPL
    FINSI
  FINSI
FINSI

SI (i_valid_field_n(g_iartin, $Tcrae_moc::SupSvcActCode3))
ALORS
  val_champ_660003960 = i_get_art_field(g_iartin, $Tcrae_moc::SupSvcActCode3)

  SI ((val_champ_660003960==0x05)&&(SSCode3_660003960==0))
  ALORS
    trace1("GR2 SupSvcActCode3 =0x0%x", val_champ_660003960)
    i_strcpy(pt_champ_660003960,"")
    erreur_660003960 =i_get_field_str(g_iartin, "SupSvcCode3", pt_champ_660003960)

    SI ((!i_strcmp(pt_champ_660003960,"28"))||(!i_strcmp(pt_champ_660003960,"29"))||(!i_strcmp(pt_champ_660003960,"2A"))||(!i_strcmp(pt_champ_660003960,"2B")))
    ALORS
      trace2("GR2 SupSvcCode3 =%s", pt_champ_660003960, 0)
      erreur_660003960 = i_memset_field(g_iartout, "ActionCode2", 0x35)
      erreur_660003960 = i_memcpy_art_field(g_iartout,"SSCode2",g_iartin.SupSvcCode3[],2)
      SAUT SUITE_MAJ_DUPL
    FINSI
  FINSI
FINSI

SI (i_valid_field_n(g_iartin, $Tcrae_moc::SupSvcActCode4))
ALORS
  val_champ_660003960 = i_get_art_field(g_iartin, $Tcrae_moc::SupSvcActCode4)

  SI ((val_champ_660003960==0x05)&&(SSCode4_660003960==0))
  ALORS
    trace1("GR2 SupSvcActCode4 =0x0%x", val_champ_660003960)
    i_strcpy(pt_champ_660003960,"")
    erreur_660003960 =i_get_field_str(g_iartin, "SupSvcCode4", pt_champ_660003960)

    SI ((!i_strcmp(pt_champ_660003960,"28"))||(!i_strcmp(pt_champ_660003960,"29"))||(!i_strcmp(pt_champ_660003960,"2A"))||(!i_strcmp(pt_champ_660003960,"2B")))
    ALORS
      trace2("GR2 SupSvcCode4 =%s", pt_champ_660003960, 0)
      erreur_660003960 = i_memset_field(g_iartout, "ActionCode2", 0x35)
      erreur_660003960 = i_memcpy_art_field(g_iartout,"SSCode2",g_iartin.SupSvcCode4[],2)
    FINSI
  FINSI
FINSI
#            SINON
#                   val_champ = i_get_art_field(g_iartin, $Tcrae_moc::SupSvcActCode5)
#                   SI ((val_champ == 5)&&(SSCode5 ==0))
#                   ALORS
#                         val_champ = i_get_art_field(g_iartin, $Tcrae_moc::SupSvcCode5)
#                         SI (val_champ >= 0x28 && val_champ <= 0x2B)
#                         ALORS
#                          erreur = i_memcpy_art_field(g_iartout,"ActionCode2",g_iartin.SupSvcActCode5[],1)
#                          erreur = i_memcpy_art_field(g_iartout,"SSCode2",g_iartin.SupSvcCode5[],2)
#                         FINSI
#                  FINSI

POINT  SUITE_MAJ_DUPL

# mis a jour du champ RecEntity
#------------------------------
SI (i_valid_field_n(g_iartin, $Tcrae_moc::RecEntityId))
ALORS
  erreur_660003960 = i_get_field_str(g_iartin, "RecEntityId" , pt_IMSI_660003960)
SINON
  erreur_660003960 = i_get_field_str(g_iartin, "Recipient" , pt_IMSI_660003960)
FINSI
# QC711
SI (erreur_660003960 == 0)
ALORS
  res_660003960 = i_strlen(pt_IMSI_660003960)
  SI ( res_660003960 > 15)
  ALORS
    res_660003960 = 15
  FINSI
  erreur_660003960= i_memcpy_art_field(g_iartout,"MscId", pt_IMSI_660003960, res_660003960)
  SI (erreur_660003960 != 0)
  ALORS
    trace("**Tcrae_moc , erreur de mis a jour du champ <MscId>")
    code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DUPL_660003960 + EFFICACE_660003960
    erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "MscId", pt_NameOfFile_660003960)
    erreur_660003960 = i_PlvMessEmettre(8831, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
    SAUT STOCKE_ERRONE
  FINSI
FINSI
#/QC711

# mis a jour du champ Location Area
#-----------------------------------

SI (i_valid_field_n(g_iartin, $Tcrae_moc::LocationArea))
ALORS
  val_champ_660003960 = i_get_art_field(g_iartin, $Tcrae_moc::LocationArea)
# ano 3315
  SI ( (val_champ_660003960 >= 0) && (val_champ_660003960 <= 99999) )
# /ano 3315
  ALORS
    i_strcpy(pt_champ_660003960, "")
    erreur_660003960 = Ajuster_taille_entier2_660003942(val_champ_660003960, 5, pt_champ_660003960)
    erreur_660003960 = i_memcpy_art_field(g_iartout, "LocationArea", pt_champ_660003960 , 5)
  SINON
    erreur_660003960 = i_memcpy_art_field(g_iartout, "LocationArea", "99999", 5)
  FINSI
SINON
  erreur_660003960 = i_memcpy_art_field(g_iartout, "LocationArea", "99999", 5)
FINSI

# mis a jour du champ cellId
#----------------------------

SI (i_valid_field_n(g_iartin, $Tcrae_moc::cellID))
ALORS
  val_champ_660003960 = i_get_art_field(g_iartin, $Tcrae_moc::cellID)
# ano 3315
  SI ( (val_champ_660003960 >= 0) && (val_champ_660003960 <= 99999) )
# /ano 3315
  ALORS
    i_strcpy(pt_champ_660003960, "")
    erreur_660003960 = Ajuster_taille_entier2_660003942(val_champ_660003960, 5, pt_champ_660003960)
    erreur_660003960 = i_memcpy_art_field(g_iartout, "CellId", pt_champ_660003960,5)
  SINON
    erreur_660003960 = i_memcpy_art_field(g_iartout, "CellId", "99999", 5)
  FINSI
SINON
  erreur_660003960 = i_memcpy_art_field(g_iartout, "CellId", "99999", 5)
FINSI

# mis a jour du champ Mobile Station Mark  HEXA sign ASCII
#---------------------------------------------------------
SI (!i_valid_field_n(g_iartin, $Tcrae_moc::mblStMark))
ALORS
  val_champ_660003960 =0x34
SINON
  val_champ_660003960 = i_get_art_field(g_iartin, $Tcrae_moc::mblStMark)

  SI ((val_champ_660003960 >=0) && (val_champ_660003960 <=9))
  ALORS
    val_champ_660003960 = val_champ_660003960 + 0x30
  SINON
    val_champ_660003960 = Most_sgn_digit_660003942(val_champ_660003960)
    val_champ_660003960 = val_champ_660003960 + 0x30
  FINSI
FINSI

trace1(" mblStMark = %d", val_champ_660003960)
erreur_660003960 = i_memset_field(g_iartout, "mblStatMark", val_champ_660003960)

# mis a jour du champ CharginDate
#---------------------------------

SI (!i_valid_field_n(g_iartin, $Tcrae_moc::CLocalTime))
ALORS
  pt_localDatePtr_660003960 = i_get_art_fieldptr(g_iartin, $Tcrae_moc::CESLocalTime)
  i_get_sub_str(pt_localDatePtr_660003960, 2, 13, pt_localDateRes_660003960)
  erreur_660003960 = i_memcpy_art_field(g_iartout, "CharginDate", pt_localDateRes_660003960, 12)
FINSI
#QC367 : le mapping se fait maintenant dans le pcode IECC
# mis a jour du champ UTCTimeoffsetCode
#--------------------------------------
UTCOffcode_map_660003960 =0x00
UTCOffcode_660003960 = i_get_art_field(g_iartin, $Tcrae_moc::COffsetCode)

SI (UTCOffcode_660003960 == -1)
ALORS
  UTCOffcode_660003960 = i_get_art_field(g_iartin, $Tcrae_moc::CESOffsetCode)
FINSI
UTCOffcode_map_660003960 = UTCOffcode_660003960
# mapping offssetCode TLV - >TAPIN
#---------------------------------

trace1("**Tcrae_moc UTCOffcode TLV :<0x%x>", UTCOffcode_660003960)
trace1("**Tcrae_moc UTCOffcode_map:<0x%x>", UTCOffcode_map_660003960)
#si pas de mapping le champ garde sa valeur par  defaut (espace)
#QC657
SI (UTCOffcode_map_660003960 != -1)
ALORS
  erreur_660003960 = i_memset_field_n(g_iartout ,$Ttapin20::UTCTimeOff, UTCOffcode_map_660003960)
FINSI

#-----------------------------------------------------------------------------------
#|  Algorithme de calcul des chamsp chargedItem , chgblUnits et chgdUnits          |
#|  variable fonctionnelle  appel_sms = sms_roaming de la spec                     |
#-----------------------------------------------------------------------------------
chrgdItem_prio_660003960 ='Z'
ic_chrgItem_prio_660003960 = -1
i_strcpy(pt_champ_660003960,"")
erreur_660003960 = i_get_field_str(g_iartin, "TeleserviceCode", pt_champ_660003960)
SI (!i_strcmp(pt_champ_660003960, "22"))
ALORS
  trace(" Tcrae_moc , appel sms ")
  appel_sms_660003960 = 1
FINSI

#-----------------------------------------------------------------------------------
#|  variable fonctionnelle  b_CRA_nonreval_COME                                     |
#-----------------------------------------------------------------------------------
b_CRA_nonreval_COME_660003960 = 0
SI (i_valid_field_n(g_iartin, $Tcrae_moc::OpSpecInf1))
ALORS
  i_strcpy(pt1_660003960, "")
  erreur_660003960=i_get_art_str(g_iartin, $Tcrae_moc::OpSpecInf1, pt1_660003960)
  i_replace_str(pt1_660003960, "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", pt1_660003960)
  # QC1441
  SI (i_strcmp(pt1_660003960, "") != 0)
  ALORS
    SI (!i_adequation_chaine_expreg (pt1_660003960, "NRC *= *ONL"))
    ALORS
      b_CRA_nonreval_COME_660003960 = 1
      SAUT FIN_b_CRA_nonreval_COME
    FINSI
  SINON
    b_CRA_nonreval_COME_660003960 = 0
    SAUT FIN_b_CRA_nonreval_COME
  FINSI
  #/QC1441
FINSI

SI (i_valid_field_n(g_iartin, $Tcrae_moc::OpSpecInf2))
ALORS
  i_strcpy(pt1_660003960, "")
  erreur_660003960=i_get_art_str(g_iartin, $Tcrae_moc::OpSpecInf2, pt1_660003960)
  i_replace_str(pt1_660003960, "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", pt1_660003960)
  # QC1441
  SI (i_strcmp(pt1_660003960, "") != 0)
  ALORS
    SI (!i_adequation_chaine_expreg (pt1_660003960, "NRC *= *ONL"))
    ALORS
      b_CRA_nonreval_COME_660003960 = 1
      SAUT FIN_b_CRA_nonreval_COME
    FINSI
  SINON
    b_CRA_nonreval_COME_660003960 = 0
    SAUT FIN_b_CRA_nonreval_COME
  FINSI
  #/QC1441
FINSI

SI (i_valid_field_n(g_iartin, $Tcrae_moc::OpSpecInf3))
ALORS
  i_strcpy(pt1_660003960, "")
  erreur_660003960=i_get_art_str(g_iartin, $Tcrae_moc::OpSpecInf3, pt1_660003960)
  i_replace_str(pt1_660003960, "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", pt1_660003960)
  # QC1441
  SI (i_strcmp(pt1_660003960, "") != 0)
  ALORS
    SI (!i_adequation_chaine_expreg (pt1_660003960, "NRC *= *ONL"))
    ALORS
      b_CRA_nonreval_COME_660003960 = 1
      SAUT FIN_b_CRA_nonreval_COME
    FINSI
  SINON
    b_CRA_nonreval_COME_660003960 = 0
    SAUT FIN_b_CRA_nonreval_COME
  FINSI
  #/QC1441
FINSI

SI (i_valid_field_n(g_iartin, $Tcrae_moc::OpSpecInf4))
ALORS
  i_strcpy(pt1_660003960, "")
  erreur_660003960=i_get_art_str(g_iartin, $Tcrae_moc::OpSpecInf4, pt1_660003960)
  i_replace_str(pt1_660003960, "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", pt1_660003960)
  # QC1441
  SI (i_strcmp(pt1_660003960, "") != 0)
  ALORS
    SI (!i_adequation_chaine_expreg (pt1_660003960, "NRC *= *ONL"))
    ALORS
      b_CRA_nonreval_COME_660003960 = 1
      SAUT FIN_b_CRA_nonreval_COME
    FINSI
  SINON
    b_CRA_nonreval_COME_660003960 = 0
    SAUT FIN_b_CRA_nonreval_COME
  FINSI
  #/QC1441
FINSI

SI (i_valid_field_n(g_iartin, $Tcrae_moc::OpSpecInf5))
ALORS
  i_strcpy(pt1_660003960, "")
  erreur_660003960=i_get_art_str(g_iartin, $Tcrae_moc::OpSpecInf5, pt1_660003960)
  i_replace_str(pt1_660003960, "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", pt1_660003960)
  # QC1441
  SI (i_strcmp(pt1_660003960, "") != 0)
  ALORS
    SI (!i_adequation_chaine_expreg (pt1_660003960, "NRC *= *ONL"))
    ALORS
      b_CRA_nonreval_COME_660003960 = 1
    FINSI
  SINON
    b_CRA_nonreval_COME_660003960 = 0
  FINSI
  #/QC1441
FINSI

POINT FIN_b_CRA_nonreval_COME
#-------------------------------------------------------------------
#| Boucle CHARGED_ITEM_PRIOR determiner le chargedItem prioritaire |
#-------------------------------------------------------------------
ic_chrgItem_660003960 = 1
ic_chrgItem_prio_660003960 = -1
POINT   CHARGED_ITEM_PRIOR

erreur_660003960 = i_EntierToString(ic_chrgItem_660003960,pt_ic_chrgItem_660003960,4)
erreur_660003960 = i_format_str2(pt_chrgItem_660003960,"%s%s","chargedItem",pt_ic_chrgItem_660003960)
trace2("**Tcrae_moc champs chargedItem courant est :<%s>", pt_chrgItem_660003960, 0)
erreur_660003960 = i_get_field_str(g_iartin,pt_chrgItem_660003960,pt_chrgItem_cour_660003960)
SI (erreur_660003960==0)
ALORS
  trace2("pt_chrgItem est :<%s>", pt_chrgItem_cour_660003960, 0)

  SI (!i_strcmp(pt_chrgItem_cour_660003960,"D") && (chrgdItem_prio_660003960 != 'D'))
  ALORS
    chrgdItem_prio_660003960 = 'D'
    ic_chrgItem_prio_660003960 = ic_chrgItem_660003960
  SINON
    SI (!i_strcmp(pt_chrgItem_cour_660003960,"V") && (chrgdItem_prio_660003960 != 'D') &&(chrgdItem_prio_660003960 != 'V'))
    ALORS
      chrgdItem_prio_660003960 = 'V'
      ic_chrgItem_prio_660003960 = ic_chrgItem_660003960
    SINON
      SI (!i_strcmp(pt_chrgItem_cour_660003960,"E") && (chrgdItem_prio_660003960 != 'D') && (chrgdItem_prio_660003960 != 'V')&&(chrgdItem_prio_660003960 != 'E'))
      ALORS
        chrgdItem_prio_660003960 = 'E'
        ic_chrgItem_prio_660003960 = ic_chrgItem_660003960
      SINON
        SI (!i_strcmp(pt_chrgItem_cour_660003960,"I") && (chrgdItem_prio_660003960 != 'D') && (chrgdItem_prio_660003960 != 'V') && (chrgdItem_prio_660003960 != 'E') && (chrgdItem_prio_660003960 != 'I'))
        ALORS
          chrgdItem_prio_660003960 = 'I'
          ic_chrgItem_prio_660003960 = ic_chrgItem_660003960
        SINON
          SI (!i_strcmp(pt_chrgItem_cour_660003960,"F") && ((chrgdItem_prio_660003960 == 'A') || (chrgdItem_prio_660003960 =='N' ) ||(chrgdItem_prio_660003960 == 'Z')))
          ALORS
            chrgdItem_prio_660003960 = 'F'
            ic_chrgItem_prio_660003960 = ic_chrgItem_660003960
          SINON
            SI (!i_strcmp(pt_chrgItem_cour_660003960,"A") && ((chrgdItem_prio_660003960 == 'N') || (chrgdItem_prio_660003960 == 'Z')))
            ALORS
              chrgdItem_prio_660003960 = 'A'
              ic_chrgItem_prio_660003960 = ic_chrgItem_660003960
            SINON
              SI (!i_strcmp(pt_chrgItem_cour_660003960,"N") && ((chrgdItem_prio_660003960 != 'N') || (chrgdItem_prio_660003960 == 'Z')))
              ALORS
                chrgdItem_prio_660003960 = 'N'
                ic_chrgItem_prio_660003960 = ic_chrgItem_660003960
              FINSI
            FINSI
          FINSI
        FINSI
      FINSI
    FINSI
  FINSI
FINSI
ic_chrgItem_660003960 = ic_chrgItem_660003960 +1

SI ( ic_chrgItem_660003960 <5)
ALORS
  SAUT  CHARGED_ITEM_PRIOR
FINSI

#### Debut FO 395

# si chargedItem non trouve on utilisera la valeur par defaut 'N'
SI (ic_chrgItem_prio_660003960 != -1)
ALORS
  trace1("chargedItem prioritaire :<%x>", chrgdItem_prio_660003960)
  trace1("indice chargeItem prioritaire :<%d>",ic_chrgItem_prio_660003960)
  chrgdItem_priout_660003960 = chrgdItem_prio_660003960
FINSI

SI ( ic_chrgItem_prio_660003960 == -1)
ALORS
  trace("chargeItem prioritaire non trouve on utilisera la valeur 'N'")
  chrgdItem_priout_660003960 = 'N'
FINSI

#---------------------------- ETAPE 2------------------------------------------
#| si chargedItem est trouve et vaut N , le champ out prend la valeur espace  |
#------------------------------------------------------------------------------
SI (( ic_chrgItem_prio_660003960 != -1) && (chrgdItem_prio_660003960 =='N'))
ALORS
  chrgdItem_priout_660003960 = ' '
SINON
  #----------------------- ETAPE 3 --------------
  #| Si Appel SMS  mettre le chargedItem a 'E'  |
  #----------------------------------------------
  SI (appel_sms_660003960 == 1)
  ALORS
    chrgdItem_priout_660003960 = 'E'
# Ano 3319
  SINON
    chrgdItem_priout_660003960 = 'D'
# /Ano 3319
  FINSI
FINSI

#----------------------------- ETAPE 4 -------------------------------------
#| calcul des chargeablesUnits pour le chargedItem courant                 |
#|  et les charges pour tous les chargedItem confondus                     |
#---------------------------------------------------------------------------

SI (ic_chrgItem_prio_660003960 != -1)
ALORS
  chgblUnitsSM_660003960 = 0
  erreur_660003960 = i_EntierToString(ic_chrgItem_prio_660003960,pt_ic1_chgblUns_660003960,4)

  indice_660003960 =10
  POINT  SOM_CHGBLUNITS

  erreur_660003960 = i_EntierToString(indice_660003960,pt_ic2_chgblUns_660003960,4)
  erreur_660003960 = i_format_str2(pt_ic3_chgblUns_660003960,"%s_%s", pt_ic1_chgblUns_660003960, pt_ic2_chgblUns_660003960)
  erreur_660003960  = i_format_str2(pt_ic_chgblUns_660003960, "%s%s", "chgblUnits", pt_ic3_chgblUns_660003960)
  trace2("**Tcrae_moc ,chargeableUnits nom :<%s>",pt_ic_chgblUns_660003960, 0)
  ic_chgblUnit_660003960 = i_get_field_num(g_iartin, pt_ic_chgblUns_660003960)

  SI ( ic_chgblUnit_660003960 != -1)
  ALORS
    val_chgblUnit_660003960 = i_get_art_field(g_iartin, ic_chgblUnit_660003960)
    trace1("val_chgblUnit:<%d>", val_chgblUnit_660003960)
    SI ( val_chgblUnit_660003960!=-1 )
    ALORS
      chgblUnitsSM_660003960 = chgblUnitsSM_660003960 + val_chgblUnit_660003960
    FINSI
  FINSI

  SI (indice_660003960 <= 19)
  ALORS
    indice_660003960 = indice_660003960 +1
    SAUT SOM_CHGBLUNITS
  FINSI
FINSI

# calcul des charges pour tous les chargeItem confondus

chargeSM_660003960 =0
indice2_660003960 = 1
chargeSM_00_660003960 = 0

#  SI pas de T3t27.1_charge , ne pas faire des calculs

SI (i_valid_field_n(g_iartin, $Tcrae_moc::chargedItem1-4))
ALORS
  POINT  SOM_CHARGE_LIST

  indice_660003960 = 10
  erreur_660003960 = i_EntierToString(indice2_660003960 ,pt_ic1_charge_660003960,4)
  POINT  SOM_CHARGES

  erreur_660003960 = i_EntierToString(indice_660003960,pt_ic2_charge_660003960,4)
  erreur_660003960 = i_format_str2(pt_ic3_charge_660003960,"%s_%s", pt_ic1_charge_660003960, pt_ic2_charge_660003960)
  erreur_660003960  = i_format_str2(pt_ic_charge_660003960, "%s%s", "charge", pt_ic3_charge_660003960)
  trace2("**Tcrae_moc ,charge nom :<%s>",pt_ic_charge_660003960, 0)
  ic_charge_660003960 = i_get_field_num(g_iartin, pt_ic_charge_660003960)

  SI ( ic_charge_660003960 != -1)
  ALORS
    val_charge_660003960 = i_get_art_field(g_iartin, ic_charge_660003960)
    trace1("Tcrae_moc ,ic_charge <%d>", ic_charge_660003960)
    trace1("Tcrae_moc ,val_charge <%d>", val_charge_660003960)

    SI ( val_charge_660003960!=-1 )
    ALORS
      chargeSM_660003960 = chargeSM_660003960 + val_charge_660003960
    FINSI
    # calcul des charges dont le charge type est a 00
    erreur_660003960 = i_get_art_str(g_iartin, ic_charge_660003960 +3, pt_chargeType_660003960)
    # FO 572
    SI ( (i_strcmp(pt_chargeType_660003960, "00")==0) || (i_strcmp(pt_chargeType_660003960, "0")==0) || (i_strcmp(pt_chargeType_660003960, "000")==0))
      # /FO 572
    ALORS
      SI ( val_charge_660003960!=-1 )
      ALORS
        chargeSM_00_660003960 = chargeSM_00_660003960 +  val_charge_660003960
      FINSI
    FINSI
  FINSI

  SI (indice_660003960 <=19 )
  ALORS
    indice_660003960 = indice_660003960 +1
    SAUT SOM_CHARGES
  FINSI
  indice2_660003960 = indice2_660003960 +1

  #  test provisoire sur 4 (il faut mettre 5)

  SI (indice2_660003960 <= 4)
  ALORS
    SAUT  SOM_CHARGE_LIST
  FINSI
FINSI

trace1("somme totale des charges :<%d>",chargeSM_660003960)
trace1("somme totale des charges_00 :<%d>",chargeSM_00_660003960)
trace1("somme totale des chgblUnitsSM :<%d>", chgblUnitsSM_660003960 )
#------------------------------------------- ETAPE 5 ------------------------------------------------
#| si charedItem n'est pas blanc                                                                    |
#|   si charge > 0 ou chargeableUnits > 0 et appel non SMS et chargedItem !=V => chargedItem =D     |
#|   si charge = 0 et chargeableUnits = 0 => chargedItem => espace                                  |
#----------------------------------------------------------------------------------------------------

SI (chrgdItem_priout_660003960 != ' ')
ALORS
  SI ((chargeSM_660003960 > 0 || chgblUnitsSM_660003960 > 0) &&(appel_sms_660003960 ==0) &&
    (chrgdItem_prio_660003960 !='V') &&(ic_chrgItem_prio_660003960!=-1))
  ALORS
    chrgdItem_priout_660003960 = 'D'
  FINSI

  SI ((chargeSM_660003960 == 0) &&(chgblUnitsSM_660003960 == 0))
  ALORS
    chrgdItem_priout_660003960 = ' '
  FINSI
FINSI

#-----------------------------------------------------------------------------------
#| chgblUnits = Somme des chgblUnits dont le chargItem est prioritaire             |
#| et chargeType ="00"                                                             |
#| chgdUnits = Somme des chgdUnits dont le chargItem est prioritaire               |
#| et chargeType ="00"                                                             |
#-----------------------------------------------------------------------------------

# SI  APPEL SMS , Ne pas faire ces calculs

SI (appel_sms_660003960 == 0)
ALORS
  chgblUnitsSM_660003960 = 0
  chgdUnitsSM_660003960 = 0

  SI (ic_chrgItem_prio_660003960 !=-1)
  ALORS
    erreur_660003960 = i_EntierToString(ic_chrgItem_prio_660003960,pt_ic1_chgblUns_660003960,4)
    indice_660003960 =10
    POINT  SOM_CHGBLUNITS_00
    erreur_660003960 = i_EntierToString(indice_660003960,pt_ic2_chgblUns_660003960,4)
    erreur_660003960 = i_format_str2(pt_ic3_chgblUns_660003960,"%s_%s", pt_ic1_chgblUns_660003960, pt_ic2_chgblUns_660003960)
    erreur_660003960  = i_format_str2(pt_ic_chgblUns_660003960, "%s%s", "chgblUnits", pt_ic3_chgblUns_660003960)
    trace2("**Tcrae_moc ,chargeableUnits nom :<%s>",pt_ic_chgblUns_660003960, 0)
    ic_chgblUnit_660003960 = i_get_field_num(g_iartin,pt_ic_chgblUns_660003960)
    erreur_660003960 = i_get_art_str(g_iartin, ic_chgblUnit_660003960 +2, pt_chargeType_660003960)
    trace2("pt_chargeType = %s",pt_chargeType_660003960,0)
    # FO 572
    SI ( (i_strcmp(pt_chargeType_660003960, "00")==0) || (i_strcmp(pt_chargeType_660003960, "0")==0) || (i_strcmp(pt_chargeType_660003960, "000")==0))
      # /FO 572
    ALORS
      val_chgblUnit_660003960 = i_get_art_field(g_iartin, ic_chgblUnit_660003960)
      val_chgdUnit_660003960 = i_get_art_field(g_iartin, ic_chgblUnit_660003960 +1)
      trace1("val_chgblUnit = %x",val_chgblUnit_660003960)
      trace1("val_chgdUnit = %x",val_chgdUnit_660003960)
      SI ( val_chgblUnit_660003960 != -1)
      ALORS
        chgblUnitsSM_660003960 = chgblUnitsSM_660003960 + val_chgblUnit_660003960
      FINSI

      SI ( val_chgdUnit_660003960 != -1)
      ALORS
        chgdUnitsSM_660003960 = chgdUnitsSM_660003960 + val_chgdUnit_660003960
      FINSI
    FINSI

    SI (indice_660003960 <= 19 )
    ALORS
      indice_660003960 = indice_660003960 +1
      SAUT SOM_CHGBLUNITS_00
    FINSI
  FINSI
FINSI

# mis a jour du champ charge
# charge <- somme des charges
#-----------------------------
i_strcpy(pt_resultat_660003960, "")
erreur_660003960  = Ajuster_taille_entier2_660003942(chargeSM_00_660003960, 9, pt_resultat_660003960)
erreur_660003960 = i_memcpy_art_field(g_iartout , "Charge", pt_resultat_660003960, 9)
SI (erreur_660003960!=0)
ALORS
  trace("Tcrae_moc , erreur de mise a jour du champ <charge>")
  code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DUPL_660003960 + EFFICACE_660003960
  erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "charge", pt_NameOfFile_660003960)
  erreur_660003960 = i_PlvMessEmettre(8831, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
  SAUT STOCKE_ERRONE
FINSI

# mis a jour du champ chargedItem
#---------------------------------
erreur_660003960 = i_memset_field(g_iartout, "ChargedItem", chrgdItem_priout_660003960)

#### Fin FO 395

# mis a jour du champ TaxeRateCode
#----------------------------------
# TT0052
#SI (chargeSM_00 != 0)
#ALORS
# erreur = i_memset_field(g_iartout,"TaxeRate", 0x30)
#FINSI
# /TT0052


# mis a jour du champ du champ ExchngRateCode
#---------------------------------------------
SI (chargeSM_00_660003960 != 0)
ALORS
  erreur_660003960 = i_memset_field(g_iartout,"ExchngRate", 0x45)
FINSI

# mis a jour du champ IdCrae
#---------------------------
SI (i_valid_field_n(g_iartin, $Tcrae_moc::IdCrae))
ALORS
  erreur_660003960 = i_memcpy_art_field(g_iartout, "IdCrae" , g_iartin.IdCrae[], 8)
FINSI


# Duplication de g_iartout(TAP2++) dans g_iartout5 (TAP2.5)
#----------------------------------------------------------
erreur_660003960 = i_dup_art_id(g_iartout, g_iartout5)

#------------------------------------------------------------------------
#|mis a jour du champ chgblUnits <- somme des chargeableUnits [TAP2++]  |
#------------------------------------------------------------------------
trace1("chgblUnitsSM =<%d>", chgblUnitsSM_660003960)
SI (appel_sms_660003960 == 1)
ALORS
  erreur_660003960 = i_memcpy_art_field(g_iartout ,"ChgblUnits", "000001", 6)
SINON
  i_strcpy(pt_chgblUnitsSM_660003960,"")
  erreur_660003960 = Ajuster_taille_entier2_660003942(chgblUnitsSM_660003960, 6, pt_chgblUnitsSM_660003960)
  trace2("pt_chgblUnitsSM =<%s>", pt_chgblUnitsSM_660003960,0)
  erreur_660003960 = i_memcpy_art_field(g_iartout , "ChgblUnits",  pt_chgblUnitsSM_660003960, 6)

  SI (erreur_660003960!=0)
  ALORS
    trace("Tcrae_moc , erreur de mise a jour du champ <chgblUnits>")
    code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DUPL_660003960 + EFFICACE_660003960
    erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "chgblUnits", pt_NameOfFile_660003960)
    erreur_660003960 = i_PlvMessEmettre(8831, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
    SAUT STOCKE_ERRONE
  FINSI
FINSI

#---------------------------------------------------------------------
#|mis a jour du champ chgblUnits <- somme des chargedUnits [TAP2.5]  |
#---------------------------------------------------------------------
trace1("chgdUnitsSM :<%d>", chgdUnitsSM_660003960)
SI (appel_sms_660003960 == 1)
ALORS
  erreur_660003960 = i_memcpy_art_field(g_iartout5 , "ChgblUnits", "000000",6)
SINON
  i_strcpy(pt_chgdUnitsSM_660003960,"")
  erreur_660003960 = Ajuster_taille_entier2_660003942(chgdUnitsSM_660003960, 6, pt_chgdUnitsSM_660003960)
  trace2("pt_chgdUnitsSM =<%s>", pt_chgdUnitsSM_660003960,0)
  erreur_660003960 = i_memcpy_art_field(g_iartout5 , "ChgblUnits",  pt_chgdUnitsSM_660003960, 6)

  SI (erreur_660003960!=0)
  ALORS
    trace("Tcrae_moc , erreur de mise a jour du champ <chgblUnits>")
    code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DUPL_660003960 + EFFICACE_660003960
    erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "chgblUnits", pt_NameOfFile_660003960)
    erreur_660003960 = i_PlvMessEmettre(8831, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
    SAUT STOCKE_ERRONE
  FINSI
FINSI

#G3R9 COME
#---------------------------------------------------------------------
#|mis a jour du champ Filler_tri <- si OpSpecInfx contient "NRC=ONL"  |
#---------------------------------------------------------------------
SI (b_CRA_nonreval_COME_660003960)
ALORS
  erreur_660003960 = i_set_art_str(g_iartout5 , $Ttapin20::Filler_tri, "O")
FINSI
#/G3R9

#-----------------------------------------------------------------------------
#| mis a jour du champ DatVolumeReference              [TAP2++]              |
#| DatVolumRef -> somme des chargeableUnits                                  |
#-----------------------------------------------------------------------------
val_champ_660003960 = i_get_art_field(g_iartin, $Tcrae_moc::DataVolumeRef)

SI (( val_champ_660003960 >= 0) && (val_champ_660003960 <= 999999))
ALORS
  i_strcpy(pt_resultat_660003960,"")
  erreur_660003960 = Ajuster_taille_entier2_660003942(val_champ_660003960, 6, pt_resultat_660003960)
  erreur_660003960 = i_memcpy_art_field(g_iartout, "DataVolumeRef", pt_resultat_660003960, 6)
SINON
  erreur_660003960 =  i_memcpy_art_field(g_iartout, "DataVolumeRef","000000", 6)
FINSI

SI (erreur_660003960!=0)
ALORS
  trace("Tcrae_moc , erreur de mise a jour du champ <DataVolumRef>")
  code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DUPL_660003960 + EFFICACE_660003960
  erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "DataVolumRef", pt_NameOfFile_660003960)
  erreur_660003960 = i_PlvMessEmettre(8831, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
  SAUT STOCKE_ERRONE
FINSI

#-----------------------------------------------------------------------------
#| mis a jour du champ DatVolumeReference              [TAP2.5]              |
#| DatVolumRef -> somme des chargeableUnits                                  |
#-----------------------------------------------------------------------------

SI (appel_sms_660003960 == 1)
ALORS
  erreur_660003960 = i_memcpy_art_field(g_iartout5 , "DataVolumeRef", "000001",6)
SINON
  i_strcpy(pt_chgblUnitsSM_660003960, "")
  erreur_660003960 = Ajuster_taille_entier2_660003942(chgblUnitsSM_660003960, 6, pt_chgblUnitsSM_660003960)
  erreur_660003960 = i_memcpy_art_field(g_iartout5 , "DataVolumeRef", pt_chgblUnitsSM_660003960, 6)

  SI (erreur_660003960!=0)
  ALORS
    trace("Tcrae_moc , erreur de mise a jour du champ <DataVolumRef>")
    code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DUPL_660003960 + EFFICACE_660003960
    erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "DataVolumRef", pt_NameOfFile_660003960)
    erreur_660003960 = i_PlvMessEmettre(8831, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
    SAUT STOCKE_ERRONE
  FINSI
FINSI

#------------------------------- FIN DE DUPLICATION ------------------------------

# G5R2lot2
SI REDIST_IMSI_Transnational_M2M_660003960
ALORS
	SAUT PT_REDIS_Transnational
FINSI
#/G5R2lot2

#-------------------------------------------------------------------------------
#| Attente requete Table de Distribution                                       |
#-------------------------------------------------------------------------------
date_fin_660003960  = i_get_art_field(g_iartin, $Tcrae_moc::dfin)
erreur_660003960 = i_get_field_str(g_iartin, "calledNumber", pt_calledNumber_660003960)

SI (!i_strcmp(pt_calledNumber_660003960, CALL_NUM_PUSHTALK_660003960) && appel_sms_660003960 ==1)
ALORS
  Push_to_talk_660003960 = Oui_660003960
FINSI

erreur_660003960 = i_LireReqConsTabDist()

SI (erreur_660003960 != 0)
ALORS
  # IMSI inconnu
  SI IMSI_Transnational_M2M_660003960
  ALORS
    # IMSI Inconnu et transnational
    REDIST_IMSI_Transnational_M2M_660003960 = 1
    SAUT PT_REDIS_Transnational
  SINON
    SAUT REDISTRIB
  FINSI
FINSI

nombreECC_660003960 = i_LireNombreECC()
trace1(" Retour i_LireNombreECC :<%d>", nombreECC_660003960)

SI (nombreECC_660003960 == 0)
ALORS
  # IMSI inconnu
  SI IMSI_Transnational_M2M_660003960
  ALORS
    # IMSI Inconnu et transnational
    REDIST_IMSI_Transnational_M2M_660003960 = 1
    SAUT PT_REDIS_Transnational
  SINON
    SAUT REDISTRIB
  FINSI
FINSI

instECC_660003960 = i_LireEntierECC(0)

SI (instECC_660003960 == -1)
ALORS
  # IMSI inconnu
  SI IMSI_Transnational_M2M_660003960
  ALORS
    # IMSI Inconnu et transnational
    REDIST_IMSI_Transnational_M2M_660003960 = 1
    SAUT PT_REDIS_Transnational
  SINON
    SAUT REDISTRIB
  FINSI
FINSI

POINT PT_REDIS_Transnational

SI REDIST_IMSI_Transnational_M2M_660003960
ALORS
  trace("**** NVDDCH ****")
  
  # Ajout dans le CRA du champ numero de filtre
  erreur_660003960 = i_ajout_tlv(g_iartin, "T3t3_NumOfFilte", "")
  erreur_660003960 = i_resize_tlv(g_iartin, "T3t3_NumOfFilte", "NumOfFilter", 1)
  SI (erreur_660003960!=0)
  ALORS
    trace("Erreur d'ajout du TLV <T3t3_NumOfFilte>")
    code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
    erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "NumOfFilter", pt_NameOfFile_660003960)
    erreur_660003960 = i_PlvMessEmettre(8833, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
    SAUT STOCKE_ERRONE
  FINSI
  
  # Enrichissement du CRA par le numero de filtre
  erreur_660003960 = i_set_art_field(g_iartin, $Tcrae_moc::NumOfFilter, 0x38)
  
  # Distribution vers NVDDCH
  instanceECC_660003960 = i_LireInstanceECC("NVDDCH")
  SI (instanceECC_660003960 == -1)
  ALORS
    trace("Pas d'instance : NVDDCH")
    code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
    erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "NVDDCH", pt_NameOfFile_660003960)
    erreur_660003960 = i_PlvMessEmettre(8834, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
    SAUT STOCKE_ERRONE
  FINSI
  trace("aplication NVDDCH")
  ptchp_format_660003960 = i_get_tab_field(FORMAT_ECC_660003960, date_cra_660003960, "NVDDCH")
  res_660003960 = Stockage_Article_660003942(g_iartin, g_iartout, g_iartout5, instanceECC_660003960 , ptchp_format_660003960, date_fin_660003960, type_cra_660003960)
  
  SAUT ECC_SECONDAIRES
FINSI
#/G5R2 lot2


trace1("Retour de i_LireEntierECC = <%d>",instECC_660003960 )

POINT CRITERES_DISTRI

#------------------------------------------------------
#| Critre de distribution vers DISE                   |
#------------------------------------------------------
erreur_660003960 = i_cree_art("Conv_URS",g_iartout13)
bDATE_MVNO_660003960 = 0

SI appel_sms_660003960 == 1
ALORS
  pt_Date_660003960 = i_get_tab_field("VariableContexte",date_cra_660003960,"DATE_MVNO_PCS")
  SI (i_strcmp(pt_Date_660003960,g_inull)!=0)
  ALORS
       erreur_660003960 = i_set_art_str (g_iartout13,$Conv_URS::DATECHAINE,pt_Date_660003960)
       date_table_660003960 = i_get_art_field(g_iartout13, $Conv_URS::DATE_ASC)
       SI date_cra_660003960 >= date_table_660003960
       ALORS
           bDATE_MVNO_660003960 = 1
       FINSI
  FINSI
FINSI

# -------------------------------- MSFDCH (DISE) poubelle NVDDCH ---------------------------------------------
# /ParamFTSA-G1R9
SI (instECC_660003960 == i_LireInstanceECC("MSFGSM"))
ALORS
# Debut G2R5 : recuperation SYSFACT
  res_660003960=i_LireInfoECC( instECC_660003960, 0 )
  SYSFACT_660003960=i_LireEntierInfo( res_660003960, 1, 2)
# Fin G2R5
#G3R5 lot1 ajout de la condition SYSFACT == 0x31314 pour filtre 0x00
  instMSFDCH_660003960 = i_LireInstanceECC("MSFDCH")
  SI (Push_to_talk_660003960 && SYSFACT_660003960 == 0x3134)
  ALORS
    trace("**** NVDDCH ****")
    # Enrichissement du CRA par le numero de filtre
    erreur_660003960 = i_ajout_tlv(g_iartin, "T3t3_NumOfFilte", "")
    erreur_660003960 = i_resize_tlv(g_iartin, "T3t3_NumOfFilte", "NumOfFilter", 1)
    SI (erreur_660003960!=0)
    ALORS
      trace("Erreur d'ajout du TLV <T3t3_NumOfFilte>")
      code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
      erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "NumOfFilter", pt_NameOfFile_660003960)
      erreur_660003960 = i_PlvMessEmettre(8833, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
      SAUT STOCKE_ERRONE
    FINSI
    erreur_660003960 = i_set_art_field(g_iartin, $Tcrae_moc::NumOfFilter, 0x00)
    
    instanceECC_660003960 = i_LireInstanceECC("NVDDCH")
    SI (instanceECC_660003960 == -1)
    ALORS
      trace("Pas d'instance : NVDDCH")
      code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
      erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "NVDDCH", pt_NameOfFile_660003960)
      erreur_660003960 = i_PlvMessEmettre(8834, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
      SAUT STOCKE_ERRONE
    FINSI
    trace("aplication NVDDCH")
    ptchp_format_660003960 = i_get_tab_field(FORMAT_ECC_660003960, date_cra_660003960, "NVDDCH")
  SINON
    SI (appel_sms_660003960 == 1 && SYSFACT_660003960!=0x3134)
    ALORS
      trace("**** NVDDCH ****")
      # Enrichissement du CRA par le numero de filtre
      erreur_660003960 = i_ajout_tlv(g_iartin, "T3t3_NumOfFilte", "")
      erreur_660003960 = i_resize_tlv(g_iartin, "T3t3_NumOfFilte", "NumOfFilter", 1)

      SI (erreur_660003960!=0)
      ALORS
        trace("Erreur d'ajout du TLV <T3t3_NumOfFilte>")
        code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
        erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "NumOfFilter", pt_NameOfFile_660003960)
        erreur_660003960 = i_PlvMessEmettre(8833, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
        SAUT STOCKE_ERRONE
      FINSI
      erreur_660003960 = i_set_art_field(g_iartin, $Tcrae_moc::NumOfFilter, 0x04)
      instanceECC_660003960 = i_LireInstanceECC("NVDDCH")

      SI (instanceECC_660003960 == -1)
      ALORS
        trace("Pas d'instance : NVDDCH")
        code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
        erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "NVDDCH", pt_NameOfFile_660003960)
        erreur_660003960 = i_PlvMessEmettre(8834, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
        SAUT STOCKE_ERRONE
      FINSI
      trace("aplication NVDDCH")
      ptchp_format_660003960 = i_get_tab_field(FORMAT_ECC_660003960, date_cra_660003960, "NVDDCH")
    SINON
      SI (appel_sms_660003960 == 1 && SYSFACT_660003960==0x3134 && bDATE_MVNO_660003960)
      ALORS
        trace("**** NVDDCH ****")
        # Enrichissement du CRA par le numero de filtre
        erreur_660003960 = i_ajout_tlv(g_iartin, "T3t3_NumOfFilte", "")
        erreur_660003960 = i_resize_tlv(g_iartin, "T3t3_NumOfFilte", "NumOfFilter", 1)
        SI (erreur_660003960!=0)
        ALORS
          trace("Erreur d'ajout du TLV <T3t3_NumOfFilte>")
          code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
          erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "NumOfFilter", pt_NameOfFile_660003960)
          erreur_660003960 = i_PlvMessEmettre(8833, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
          SAUT STOCKE_ERRONE
        FINSI
        erreur_660003960 = i_set_art_field(g_iartin, $Tcrae_moc::NumOfFilter, 0x08)
        instanceECC_660003960 = i_LireInstanceECC("NVDDCH")

        SI (instanceECC_660003960 == -1)
        ALORS
          trace("Pas d'instance : NVDDCH")
          code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
          erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "NVDDCH", pt_NameOfFile_660003960)
          erreur_660003960 = i_PlvMessEmettre(8834, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
          SAUT STOCKE_ERRONE
        FINSI
        
        trace("aplication NVDDCH")
        ptchp_format_660003960 = i_get_tab_field(FORMAT_ECC_660003960, date_cra_660003960, "NVDDCH")

      SINON
        trace("**** MSFDCH ****")
        # recherche dans la table externe Format_ECC le format de l'application

        SI (instMSFDCH_660003960 == -1)
        ALORS
          trace("Pas d'instance : MSFDCH")
          code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
          erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "MSFDCH", pt_NameOfFile_660003960)
          erreur_660003960 = i_PlvMessEmettre(8834, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
          SAUT STOCKE_ERRONE
        FINSI
        trace("aplication MSFDCH")
        instanceECC_660003960 = instMSFDCH_660003960
        ptchp_format_660003960 = i_get_tab_field(FORMAT_ECC_660003960, date_cra_660003960, "MSFDCH")
      FINSI
    FINSI
  FINSI
  res_660003960 = Stockage_Article_660003942(g_iartin, g_iartout, g_iartout5, instanceECC_660003960 , ptchp_format_660003960, date_fin_660003960, type_cra_660003960)

  SI (res_660003960 == STCK_KO_660003960)
  ALORS
    trace("**Tcrae_moc , erreur d'envoi de l'article a l'application MSFDCH")
    code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
    erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "MSFDCH", pt_NameOfFile_660003960)
    erreur_660003960 = i_PlvMessEmettre(8835, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
    SAUT STOCKE_ERRONE
  FINSI

  SAUT ECC_SECONDAIRES
FINSI
# / G1R9 QC189

# G3R9 item COME
# -------------------------------- COMDCH ou FRCDCH poubelle NVCDCH-------------------------------------------
# calcul de b_COMESI et des ID-instance de COMDCH et sinon FRCDCH
SI (instECC_660003960 == i_LireInstanceECC("COMGSM"))
ALORS
  b_COMESI_660003960 = 1
  # calcul ID-instance de COMDCH
  instCOMDCH_660003960 = i_LireInstanceECC("COMDCH")
  SI(instCOMDCH_660003960 == -1)
  ALORS
    trace("Pas d'instance : COMDCH")
    code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
    erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "COMDCH", pt_NameOfFile_660003960)
    erreur_660003960 = i_PlvMessEmettre(8834, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
    SAUT STOCKE_ERRONE
  FINSI
SINON
  SI (instECC_660003960 == i_LireInstanceECC("FRCGSM"))
  ALORS
    b_COMESI_660003960 = 2
    # calcul ID-instance de FRCDCH
    instFRCDCH_660003960 = i_LireInstanceECC("FRCDCH")
    SI(instFRCDCH_660003960 == -1)
    ALORS
      trace("Pas d'instance : FRCDCH")
      code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
      erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "FRCDCH", pt_NameOfFile_660003960)
      erreur_660003960 = i_PlvMessEmettre(8834, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
      SAUT STOCKE_ERRONE
    FINSI
  FINSI
FINSI

SI (b_COMESI_660003960)
ALORS

  SI (appel_sms_660003960)
  ALORS
    #CRAE filtres => poubelle NVCDCH
    trace("**** NVCDCH ****")
    # calcul ID-instance de NVCDCH
    instNVCDCH_660003960 = i_LireInstanceECC("NVCDCH")
    SI(instNVCDCH_660003960 == -1)
    ALORS
      trace("Pas d'instance : NVCDCH")
      code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
      erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "NVCDCH", pt_NameOfFile_660003960)
      erreur_660003960 = i_PlvMessEmettre(8834, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
      SAUT STOCKE_ERRONE
    FINSI

    # Enrichissement du CRA par le numero de filtre
    erreur_660003960 = i_ajout_tlv(g_iartin, "T3t3_NumOfFilte", "")
    erreur_660003960 = i_resize_tlv(g_iartin, "T3t3_NumOfFilte", "NumOfFilter", 1)
    SI (erreur_660003960!=0)
    ALORS
      trace("Erreur d'ajout du TLV <T3t3_NumOfFilte>")
      code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
      erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "NumOfFilter", pt_NameOfFile_660003960)
      erreur_660003960 = i_PlvMessEmettre(8833, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
      SAUT STOCKE_ERRONE
    FINSI
    erreur_660003960 = i_set_art_field(g_iartin, $Tcrae_moc::NumOfFilter, 0x09)
    
    trace("aplication NVCDCH")
    # recherche dans la table externe Format_ECC le format de l'application
    ptchp_format_660003960 = i_get_tab_field(FORMAT_ECC_660003960, date_cra_660003960, "NVCDCH")
    # stockage poubelle NVCDCH
    res_660003960 = Stockage_Article_660003942(g_iartin, g_iartout, g_iartout5, instNVCDCH_660003960 , ptchp_format_660003960, date_fin_660003960, type_cra_660003960)
    SI(res_660003960 == STCK_KO_660003960)
    ALORS
      trace("**Tcrae_moc , erreur d'envoi de l'article a l'application instNVCDCH")
      code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
      erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "instNVCDCH", pt_NameOfFile_660003960)
      erreur_660003960 = i_PlvMessEmettre(8835, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
      SAUT STOCKE_ERRONE
    FINSI

  SINON
    # CRAE non-filtres donc factures => COMDCH ou FRCDCH
    SI (b_COMESI_660003960 == 1)
    ALORS
      trace("**** COMDCH ****")
      # recherche dans la table externe Format_ECC le format de l'application
      ptchp_format_660003960 = i_get_tab_field(FORMAT_ECC_660003960, date_cra_660003960, "COMDCH")

      res_660003960 = Stockage_Article_660003942(g_iartin, g_iartout, g_iartout5, instCOMDCH_660003960, ptchp_format_660003960, date_fin_660003960, type_cra_660003960)
      SI(res_660003960 == STCK_KO_660003960)
      ALORS
        trace("**Tcrae_moc , erreur d'envoi de l'article a l'application COMDCH")
        code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
        erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "COMDCH", pt_NameOfFile_660003960)
        erreur_660003960 = i_PlvMessEmettre(8835, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
        SAUT STOCKE_ERRONE
      FINSI
    SINON
      trace("**** FRCDCH ****")
      # recherche dans la table externe Format_ECC le format de l'application
      ptchp_format_660003960 = i_get_tab_field(FORMAT_ECC_660003960, date_cra_660003960, "FRCDCH")

      res_660003960 = Stockage_Article_660003942(g_iartin, g_iartout, g_iartout5, instFRCDCH_660003960, ptchp_format_660003960, date_fin_660003960, type_cra_660003960)
      SI(res_660003960 == STCK_KO_660003960)
      ALORS
        trace("**Tcrae_moc , erreur d'envoi de l'article a l'application FRCDCH")
        code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
        erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "FRCDCH", pt_NameOfFile_660003960)
        erreur_660003960 = i_PlvMessEmettre(8835, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
        SAUT STOCKE_ERRONE
      FINSI
    FINSI
  FINSI

  SAUT ECC_SECONDAIRES
FINSI
#/G3R9

# -------------------------------- FEDCH poubelle NVDDCH -----------------------------------------------------
#G2R1 lot2 FE
# G3R9 item COME
SI (instECC_660003960 == i_LireInstanceECC("FEGSM"))
ALORS

  # calcul de SYSFAC
  res_660003960=i_LireInfoECC( instECC_660003960, 0 )
  SYSFACT_660003960=i_LireEntierInfo( res_660003960, 1, 2)
  
  # Calcul ID-instance FE, NVD avec leurs tests)
  instFEDCH_660003960 = i_LireInstanceECC("FEDCH")
  SI (instFEDCH_660003960 == -1)
  ALORS
    trace("Pas d'instance : FEDCH")
    code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
    erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "FEDCH", pt_NameOfFile_660003960)
    erreur_660003960 = i_PlvMessEmettre(8834, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
    SAUT STOCKE_ERRONE
  FINSI
  
  instNVDDCH_660003960 = i_LireInstanceECC("NVDDCH")
  SI (instNVDDCH_660003960 == -1)
  ALORS
    trace("Pas d'instance : NVDDCH")
    code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
    erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "NVDDCH", pt_NameOfFile_660003960)
    erreur_660003960 = i_PlvMessEmettre(8834, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
    SAUT STOCKE_ERRONE
  FINSI

  # Calcul variable fonctionnelle b_FE_Eligible_COME
  SI (SYSFACT_660003960 == 0x3430)
  ALORS
    b_FE_Eligible_COME_660003960 = 1
    # Calcul ID-instance FRCDCH et test
    instFRCDCH_660003960 = i_LireInstanceECC("FRCDCH")
    SI (instFRCDCH_660003960 == -1)
    ALORS
      trace("Pas d'instance : FRCDCH")
      code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
      erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "FRCDCH", pt_NameOfFile_660003960)
      erreur_660003960 = i_PlvMessEmettre(8834, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
      SAUT STOCKE_ERRONE
    FINSI
  SINON
    b_FE_Eligible_COME_660003960 = 0
    # Calcul ID-instance FRCDCH et test
    instMSFDCH_660003960 = i_LireInstanceECC("MSFDCH")
    SI (instMSFDCH_660003960 == -1)
    ALORS
      trace("Pas d'instance : MSFDCH")
      code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
      erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "MSFDCH", pt_NameOfFile_660003960)
      erreur_660003960 = i_PlvMessEmettre(8834, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
      SAUT STOCKE_ERRONE
    FINSI
  FINSI
  
  # CRAE filtres => poubelle NVDDCH
  SI Push_to_talk_660003960
  ALORS
    trace("**** NVDDCH ****")
    # Enrichissement du CRA par le numero de filtre
    erreur_660003960 = i_ajout_tlv(g_iartin, "T3t3_NumOfFilte", "")
    erreur_660003960 = i_resize_tlv(g_iartin, "T3t3_NumOfFilte", "NumOfFilter", 1)

    SI (erreur_660003960!=0)
    ALORS
      trace("Erreur d'ajout du TLV <T3t3_NumOfFilte>")
      code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
      erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "NumOfFilter", pt_NameOfFile_660003960)
      erreur_660003960 = i_PlvMessEmettre(8833, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
      SAUT STOCKE_ERRONE
    FINSI
    erreur_660003960 = i_set_art_field(g_iartin, $Tcrae_moc::NumOfFilter, 0x06)
    trace("aplication NVDDCH")
    ptchp_format_660003960 = i_get_tab_field(FORMAT_ECC_660003960, date_cra_660003960, "NVDDCH")

    res_660003960 = Stockage_Article_660003942(g_iartin, g_iartout, g_iartout5, instNVDDCH_660003960 , ptchp_format_660003960, date_fin_660003960, type_cra_660003960)
    SI (res_660003960 == STCK_KO_660003960)
    ALORS
      trace("**Tcrae_moc , erreur d'envoi de l'article a l'application NVDDCH")
      code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
      erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "NVDDCH", pt_NameOfFile_660003960)
      erreur_660003960 = i_PlvMessEmettre(8835, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
      SAUT STOCKE_ERRONE
    FINSI

  SINON
    SI (appel_sms_660003960 == 1)
    ALORS
      trace("**** NVDDCH ****")
      # Enrichissement du CRA par le numero de filtre
      erreur_660003960 = i_ajout_tlv(g_iartin, "T3t3_NumOfFilte", "")
      erreur_660003960 = i_resize_tlv(g_iartin, "T3t3_NumOfFilte", "NumOfFilter", 1)

      SI (erreur_660003960!=0)
      ALORS
        trace("Erreur d'ajout du TLV <T3t3_NumOfFilte>")
        code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
        erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "NumOfFilter", pt_NameOfFile_660003960)
        erreur_660003960 = i_PlvMessEmettre(8833, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
        SAUT STOCKE_ERRONE
      FINSI
      erreur_660003960 = i_set_art_field(g_iartin, $Tcrae_moc::NumOfFilter, 0x05)
      trace("aplication NVDDCH")
      ptchp_format_660003960 = i_get_tab_field(FORMAT_ECC_660003960, date_cra_660003960, "NVDDCH")
      
      res_660003960 = Stockage_Article_660003942(g_iartin, g_iartout, g_iartout5, instNVDDCH_660003960 , ptchp_format_660003960, date_fin_660003960, type_cra_660003960)
      SI (res_660003960 == STCK_KO_660003960)
      ALORS
        trace("**Tcrae_moc , erreur d'envoi de l'article a l'application NVDDCH")
        code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
        erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "NVDDCH", pt_NameOfFile_660003960)
        erreur_660003960 = i_PlvMessEmettre(8835, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
        SAUT STOCKE_ERRONE
      FINSI
    SINON

      # CRAE non filtres => FEDCH et (FRCDCH ou MSFDCH)
      trace("aplication FEDCH")
      ptchp_format_660003960 = i_get_tab_field(FORMAT_ECC_660003960, date_cra_660003960, "FEDCH")
      res_660003960 = Stockage_Article_660003942(g_iartin, g_iartout, g_iartout5, instFEDCH_660003960 , ptchp_format_660003960, date_fin_660003960, type_cra_660003960)
      SI (res_660003960 == STCK_KO_660003960)
      ALORS
        trace("**Tcrae_moc , erreur d'envoi de l'article a l'application FEDCH")
        code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
        erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "FEDCH", pt_NameOfFile_660003960)
        erreur_660003960 = i_PlvMessEmettre(8835, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
        SAUT STOCKE_ERRONE
      FINSI

      SI (b_FE_Eligible_COME_660003960)
      ALORS
        trace("aplication FRCDCH")
        ptchp_format_660003960 = i_get_tab_field(FORMAT_ECC_660003960, date_cra_660003960, "FRCDCH")
        res_660003960 = Stockage_Article_660003942(g_iartin, g_iartout, g_iartout5, instFRCDCH_660003960 , ptchp_format_660003960, date_fin_660003960, type_cra_660003960)
        SI (res_660003960 == STCK_KO_660003960)
        ALORS
          trace("**Tcrae_moc , erreur d'envoi de l'article a l'application FRCDCH")
          code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
          erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "FRCDCH", pt_NameOfFile_660003960)
          erreur_660003960 = i_PlvMessEmettre(8835, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
          SAUT STOCKE_ERRONE
        FINSI
      SINON
        trace("aplication MSFDCH")
        ptchp_format_660003960 = i_get_tab_field(FORMAT_ECC_660003960, date_cra_660003960, "MSFDCH")
        res_660003960 = Stockage_Article_660003942(g_iartin, g_iartout, g_iartout5, instMSFDCH_660003960 , ptchp_format_660003960, date_fin_660003960, type_cra_660003960)
        SI (res_660003960 == STCK_KO_660003960)
        ALORS
          trace("**Tcrae_moc , erreur d'envoi de l'article a l'application MSFDCH")
          code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
          erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "MSFDCH", pt_NameOfFile_660003960)
          erreur_660003960 = i_PlvMessEmettre(8835, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
          SAUT STOCKE_ERRONE
        FINSI
      FINSI
    FINSI
  FINSI

  SAUT ECC_SECONDAIRES
FINSI
#/G3R9
#/G2R1 lot2 FE


#+----------------------------------------------------+
#| criteres communs de distribution vers ADV          |
#+----------------------------------------------------+
#
# FE0069 Filtre S-MMS en roaming out
# SI la date de l article est posterieure ou egale la date d activation du filtre
#    et article SMS (Teleservice=22)
#

FILT_SMMSRoaming_660003960 = Non_660003960

SI (appel_sms_660003960 == 0)
ALORS
  FILT_SMMSRoaming_660003960 = Non_660003960
SINON
  pt_DateFiltSMS_660003960=i_get_tab_field("VariableContexte",date_cra_660003960,"DATE_ROAMING_SMMS")
  SI (i_strcmp(pt_DateFiltSMS_660003960,g_inull)!=0)
  ALORS
# Controle du format de la date parametre dans la table : AAAMMJJhhmmss
    erreur_660003960 = FormatDate_660003942(pt_DateFiltSMS_660003960)
    SI ( erreur_660003960!=0 )
    ALORS
      FILT_SMMSRoaming_660003960 = Non_660003960
    SINON
      FILT_SMMSRoaming_660003960 = Oui_660003960
    FINSI
  SINON
    FILT_SMMSRoaming_660003960 = Non_660003960
  FINSI
FINSI

SI ( FILT_SMMSRoaming_660003960 == Oui_660003960 )
ALORS
  SI (i_valid_field_n(g_iartin, $Tcrae_moc::CLocalTime))
  ALORS
    pt_localDatePtr_660003960 = i_get_art_fieldptr(g_iartin, $Tcrae_moc::CLocalTime)
    i_get_sub_str(pt_localDatePtr_660003960, 0, 13, pt_localDateRes_660003960)
  SINON
    SI (i_valid_field_n(g_iartin, $Tcrae_moc::CESLocalTime))
    ALORS
      pt_localDatePtr_660003960 = i_get_art_fieldptr(g_iartin, $Tcrae_moc::CESLocalTime)
      i_get_sub_str(pt_localDatePtr_660003960, 0, 13, pt_localDateRes_660003960)
    FINSI
  FINSI

  SI (i_strcmp(pt_localDateRes_660003960, pt_DateFiltSMS_660003960) >=0 )
  ALORS
    trace2("Date article <%s> posterieure a la date du filtre SMSRoaming <%s>",pt_localDateRes_660003960,pt_DateFiltSMS_660003960)
  SINON
    FILT_SMMSRoaming_660003960 = Non_660003960
  FINSI
FINSI


# ---------------------- VDIDCH, OLADCH, OL2DCH, OL3DCH, OR5DCH (ADV)  poubelle NVADCH -----------------------
#+----------------------------------------------------+
#| Distribution vers l' application VDIDCH            |
#+----------------------------------------------------+

SI (instECC_660003960 == i_LireInstanceECC("VDIGSM"))
ALORS
  instVDIDCH_660003960 = i_LireInstanceECC("VDIDCH")
  SI ( FILT_SMMSRoaming_660003960 == Non_660003960)
  ALORS
    trace("**** VDIDCH ****")
    SI (instVDIDCH_660003960 == -1)
    ALORS
      trace("Pas d'ECC : VDIDCH")
      code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
      erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "VDIDCH", pt_NameOfFile_660003960)
      erreur_660003960 = i_PlvMessEmettre(8834, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
      SAUT STOCKE_ERRONE
    FINSI
    trace("aplication VDIDCH")
    # recherche dans la table externe Format_ECC le format de l'application
    ptchp_format_660003960 = i_get_tab_field(FORMAT_ECC_660003960, date_cra_660003960, "VDIDCH")
    res_660003960 = Stockage_Article_660003942(g_iartin, g_iartout, g_iartout5, instVDIDCH_660003960 , ptchp_format_660003960, date_fin_660003960, type_cra_660003960)
    SI (res_660003960 == STCK_KO_660003960)
    ALORS
      trace("**Tcrae_moc , erreur d'envoi de l'article a l'application VDIDCH")
      code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
      erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "VDIDCH", pt_NameOfFile_660003960)
      erreur_660003960 = i_PlvMessEmettre(8835, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
      SAUT STOCKE_ERRONE
    FINSI
    SAUT ECC_SECONDAIRES
  SINON
    trace("Application VDIDCH: Filtrage SMS en Roaming out")
    SAUT POUBELLE_ADV_NVADCH
  FINSI
FINSI

#-------------------------------------------------------------------------------
#|  Distribution vers l'application OLADCH                                     |
#-------------------------------------------------------------------------------
SI (instECC_660003960 == i_LireInstanceECC("OLAGSM"))
ALORS
  instOLADCH_660003960 = i_LireInstanceECC("OLADCH")
  SI ( FILT_SMMSRoaming_660003960 == Non_660003960)
  ALORS
    trace("**** OLADCH ****")
    SI (instOLADCH_660003960 == -1)
    ALORS
      trace("Pas d'ECC : OLADCH")
      code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
      erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "OLADCH", pt_NameOfFile_660003960)
      erreur_660003960 = i_PlvMessEmettre(8834, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
      SAUT STOCKE_ERRONE
    FINSI
    trace("application OLADCH")
    # recherche dans la table externe Format_ECC le format de l'application
    ptchp_format_660003960 = i_get_tab_field(FORMAT_ECC_660003960, date_cra_660003960, "OLADCH")
    res_660003960 = Stockage_Article_660003942(g_iartin, g_iartout, g_iartout5, instOLADCH_660003960 , ptchp_format_660003960, date_fin_660003960, type_cra_660003960)
    SI (res_660003960 == STCK_KO_660003960)
    ALORS
      trace("**Tcrae_moc , erreur d'envoi de l'article a l'application OLADCH")
      code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
      erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "OLADCH", pt_NameOfFile_660003960)
      erreur_660003960 = i_PlvMessEmettre(8835, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
      SAUT STOCKE_ERRONE
    FINSI
    SAUT ECC_SECONDAIRES
  SINON
    trace("Application OLADCH: Filtrage SMS en Roaming out")
    SAUT POUBELLE_ADV_NVADCH
  FINSI
FINSI

#--------------------------------------------------------------------------------
#|  Distribution vers l'application OL2DCH                                      |
#--------------------------------------------------------------------------------
SI (instECC_660003960 == i_LireInstanceECC("OL2GSM"))
ALORS
  instOL2DCH_660003960 = i_LireInstanceECC("OL2DCH")
  SI ( FILT_SMMSRoaming_660003960 == Non_660003960)
  ALORS
    trace("**** OL2DCH ****")
    SI (instOL2DCH_660003960 == -1)
    ALORS
      trace("Pas d'ECC : OLA2DCH")
      code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
      erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "OL2DCH", pt_NameOfFile_660003960)
      erreur_660003960 = i_PlvMessEmettre(8834, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
      SAUT STOCKE_ERRONE
    FINSI
    trace("application OL2DCH")
    # recherche dans la table externe Format_ECC le format de l'application
    ptchp_format_660003960 = i_get_tab_field(FORMAT_ECC_660003960, date_cra_660003960, "OL2DCH")
    res_660003960 = Stockage_Article_660003942(g_iartin, g_iartout, g_iartout5, instOL2DCH_660003960 , ptchp_format_660003960, date_fin_660003960, type_cra_660003960)
    SI (res_660003960 == STCK_KO_660003960)
    ALORS
      trace("**Tcrae_moc , erreur d'envoi de l'article a l'application OL2DCH")
      code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
      erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "OL2DCH", pt_NameOfFile_660003960)
      erreur_660003960 = i_PlvMessEmettre(8835, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
      SAUT STOCKE_ERRONE
    FINSI
    SAUT ECC_SECONDAIRES
  SINON
    trace("Application OL2DCH: Filtrage SMS en Roaming out")
    SAUT POUBELLE_ADV_NVADCH
  FINSI
FINSI

#--------------------------------------------------------------------------------
#| Distribution vers l'application OL3DCH                                       |
#--------------------------------------------------------------------------------
SI (instECC_660003960 == i_LireInstanceECC("OL3GSM"))
ALORS
  instOL3DCH_660003960 = i_LireInstanceECC("OL3DCH")
  SI ( FILT_SMMSRoaming_660003960 == Non_660003960)
  ALORS
    trace("**** OL3DCH ****")
    SI (instOL3DCH_660003960 == -1)
    ALORS
      trace("Pas d'ECC : OLA3DCH")
      code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
      erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "OL3DCH", pt_NameOfFile_660003960)
      erreur_660003960 = i_PlvMessEmettre(8834, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
      SAUT STOCKE_ERRONE
    FINSI
    trace("application OL3DCH")
    # recherche dans la table externe Format_ECC le format de l'application
    ptchp_format_660003960 = i_get_tab_field(FORMAT_ECC_660003960, date_cra_660003960, "OL3DCH")
    res_660003960 = Stockage_Article_660003942(g_iartin, g_iartout, g_iartout5, instOL3DCH_660003960 , ptchp_format_660003960, date_fin_660003960, type_cra_660003960)
    SI (res_660003960 == STCK_KO_660003960)
    ALORS
      trace("**Tcrae_moc , erreur d'envoi de l'article a l'application OL3DCH")
      code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
      erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "OL3DCH", pt_NameOfFile_660003960)
      erreur_660003960 = i_PlvMessEmettre(8835, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
      SAUT STOCKE_ERRONE
    FINSI
    SAUT ECC_SECONDAIRES
  SINON
    trace("Application OL3DCH: Filtrage SMS en Roaming out")
    SAUT POUBELLE_ADV_NVADCH
  FINSI
FINSI

#-------------------------------------------------------------------------------
#| Distribution vers l'application OR5DCH                                      |
#-------------------------------------------------------------------------------
SI (instECC_660003960 == i_LireInstanceECC("OR5GSM"))
ALORS
  instOR5DCH_660003960 = i_LireInstanceECC("OR5DCH")
  SI ( FILT_SMMSRoaming_660003960 == Non_660003960)
  ALORS
    trace("**** OR5DCH ****")
    SI (instOR5DCH_660003960 == -1)
    ALORS
      trace("pas d'instance OR5DCH")
      code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
      erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "OR5DCH", pt_NameOfFile_660003960)
      erreur_660003960 = i_PlvMessEmettre(8834, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
      SAUT STOCKE_ERRONE
    FINSI
    trace("application OR5DCH")
    # recherche dans la table externe Format_ECC le format de l'application
    ptchp_format_660003960 = i_get_tab_field(FORMAT_ECC_660003960, date_cra_660003960, "OR5DCH")
    res_660003960 = Stockage_Article_660003942(g_iartin, g_iartout, g_iartout5, instOR5DCH_660003960 , ptchp_format_660003960, date_fin_660003960, type_cra_660003960)
    SI (res_660003960 == STCK_KO_660003960)
    ALORS
      trace("**Tcrae_moc , erreur d'envoi de l'article a l'application OR5DCH")
      code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
      erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "OR5DCH", pt_NameOfFile_660003960)
      erreur_660003960 = i_PlvMessEmettre(8835, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
      SAUT STOCKE_ERRONE
    FINSI
    SAUT ECC_SECONDAIRES
  SINON
    trace("Application OR5DCH: Filtrage SMS en Roaming out")
    SAUT POUBELLE_ADV_NVADCH
  FINSI
FINSI

SAUT   FIN_DISTRI_ADV

# ------------------------- poubelle NVADCH ----------------------------------------------------

POINT  POUBELLE_ADV_NVADCH

trace("**** NVADCH ****")
# Enrichissement du CRA par le numero de filtre
erreur_660003960 = i_ajout_tlv(g_iartin, "T3t3_NumOfFilte", "")
erreur_660003960 = i_resize_tlv(g_iartin, "T3t3_NumOfFilte", "NumOfFilter", 1)
SI (erreur_660003960!=0)
ALORS
  trace("Erreur d'ajout du TLV <T3t3_NumOfFilte>")
  code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
  erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "NumOfFilter", pt_NameOfFile_660003960)
  erreur_660003960 = i_PlvMessEmettre(8833, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
  SAUT STOCKE_ERRONE
FINSI
erreur_660003960 = i_set_art_field(g_iartin, $Tcrae_moc::NumOfFilter, 0x01)
instanceECC_660003960 = i_LireInstanceECC("NVADCH")
SI (instanceECC_660003960 == -1)
ALORS
  trace("Pas d'ECC : NVADCH")
  code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
  erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "NVADCH", pt_NameOfFile_660003960)
  erreur_660003960 = i_PlvMessEmettre(8834, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
  SAUT STOCKE_ERRONE
FINSI
trace("application NVADCH")
ptchp_format_660003960 = i_get_tab_field(FORMAT_ECC_660003960, date_cra_660003960, "NVADCH")

res_660003960 = Stockage_Article_660003942(g_iartin, g_iartout, g_iartout5, instanceECC_660003960 , ptchp_format_660003960, date_fin_660003960, type_cra_660003960)
SI (res_660003960 == STCK_KO_660003960)
ALORS
  trace("**Tcrae_moc , erreur d'envoi de l'article a l'application NVADCH")
  code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
  erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "NVADCH", pt_NameOfFile_660003960)
  erreur_660003960 = i_PlvMessEmettre(8835, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
  SAUT STOCKE_ERRONE
FINSI
SAUT ECC_SECONDAIRES


POINT  FIN_DISTRI_ADV

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

# ----G5R4lot2 Suppression VPF--------------------- poubelle NVADCH ----------------------------------------------------



# -------------------------------- SHACHEM Mobicarte, CMODCH, M1GDCH------------------------------------------
#-------------------------------------------------------------------
#| Distribution vers SHACHEM Mobicarte                             |
#| M1GDCH application poubelle de SHACHEM Mobicarte                |
#-------------------------------------------------------------------

SI (instECC_660003960 == i_LireInstanceECC("SHMGSM"))
ALORS
  trace("**** M1GDCH ****")
  instM1GDCH_660003960 = i_LireInstanceECC("M1GDCH")
  SI (instM1GDCH_660003960 == -1)
  ALORS
    trace("pas d'instance M1GDCH")
    code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
    erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "M1GDCH", pt_NameOfFile_660003960)
    erreur_660003960 = i_PlvMessEmettre(8834, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
    SAUT STOCKE_ERRONE
  FINSI
  trace("application M1GDCH")
  # Enrichissement du CRA par le numero de filtre
  erreur_660003960 = i_ajout_tlv(g_iartin, "T3t3_NumOfFilte", "")
  erreur_660003960 = i_resize_tlv(g_iartin, "T3t3_NumOfFilte", "NumOfFilter", 1)
  SI (erreur_660003960!=0)
  ALORS
    trace("Erreur d'ajout du TLV <T3t3_NumOfFilte>")
    code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
    erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "NumOfFilter", pt_NameOfFile_660003960)
    erreur_660003960 = i_PlvMessEmettre(8833, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
    SAUT STOCKE_ERRONE
  FINSI
  erreur_660003960 = i_set_art_field(g_iartin, $Tcrae_moc::NumOfFilter, 0x02)

  # recherche dans la table externe Format_ECC le format de l'application
  ptchp_format_660003960 = i_get_tab_field(FORMAT_ECC_660003960, date_cra_660003960, "M1GDCH")

  res_660003960 = Stockage_Article_660003942(g_iartin, g_iartout, g_iartout5, instM1GDCH_660003960 , ptchp_format_660003960, date_fin_660003960, type_cra_660003960)
  SI (res_660003960 == STCK_KO_660003960)
  ALORS
    trace("**Tcrae_moc , erreur d'envoi de l'article a l'application M1GDCH")
    code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
    erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "M1GDCH", pt_NameOfFile_660003960)
    erreur_660003960 = i_PlvMessEmettre(8835, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
    SAUT STOCKE_ERRONE
  FINSI
  SAUT ECC_SECONDAIRES
FINSI

# -------------------------------- SHACHEM CMO, CMODCH -------------------------------------------------------
#-------------------------------------------------------------------
#| Distribution vers SHACHEM CMO                                   |
#| CMODCH application poubelle de SHACHEM CMO                      |
#-------------------------------------------------------------------
SI (instECC_660003960 == i_LireInstanceECC("SHPGSM"))
ALORS
  trace("**** CMODCH ****")
  instCMODCH_660003960 = i_LireInstanceECC("CMODCH")
  SI (instCMODCH_660003960 == -1)
  ALORS
    trace("Tcrae_moc: pas d'ECC CMODCH")
    code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
    erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "CMODCH", pt_NameOfFile_660003960)
    erreur_660003960 = i_PlvMessEmettre(8834, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
    SAUT STOCKE_ERRONE
  FINSI
  trace("application CMODCH")
  # Enrichissement du CRA par le numero de filtre
  erreur_660003960 = i_ajout_tlv(g_iartin, "T3t3_NumOfFilte", "")
  erreur_660003960 = i_resize_tlv(g_iartin, "T3t3_NumOfFilte", "NumOfFilter", 1)
  SI (erreur_660003960!=0)
  ALORS
    trace("Erreur d'ajout du TLV <T3t3_NumOfFilte>")
    code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
    erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "NumOfFilter", pt_NameOfFile_660003960)
    erreur_660003960 = i_PlvMessEmettre(8833, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
    SAUT STOCKE_ERRONE
  FINSI
  erreur_660003960 = i_set_art_field(g_iartin, $Tcrae_moc::NumOfFilter, 0x03)

  # recherche dans la table externe Format_ECC le format de l'application
  ptchp_format_660003960 = i_get_tab_field(FORMAT_ECC_660003960, date_cra_660003960, "CMODCH")
  res_660003960 = Stockage_Article_660003942(g_iartin, g_iartout, g_iartout5, instCMODCH_660003960 , ptchp_format_660003960, date_fin_660003960, type_cra_660003960)
  SI (res_660003960 == STCK_KO_660003960)
  ALORS
    trace("**Tcrae_moc , erreur d'envoi de l'article a l'apllication CMODCH")
    code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
    erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "CMODCH", pt_NameOfFile_660003960)
    erreur_660003960 = i_PlvMessEmettre(8835, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
    SAUT STOCKE_ERRONE
  FINSI
  SAUT ECC_SECONDAIRES
FINSI

#----------------------------------------------------------------------
#| Application de redistribution                                      |
#| si CRA issu redistribue pendant 7 jours  => FRAUDE                 |
#| sinon envoi vers l'application poubelle                            |
#----------------------------------------------------------------------

POINT REDISTRIB

SI (i_valid_field_n(g_iartin, $Tcrae_moc::T3t2_DateOfRedi) == 0)
ALORS
  erreur_660003960 = i_ajout_tlv(g_iartin, "T3t2_DateOfRedi", "")
  erreur_660003960 = i_resize_tlv(g_iartin, "T3t2_DateOfRedi", "DateOfRedistri",4)
  erreur_660003960 = i_set_art_field(g_iartin ,$Tcrae_moc::DateOfRedistri ,i_cur_time())
FINSI
val_champ_660003960 = i_get_art_field(g_iartin ,$Tcrae_moc::DateOfRedistri)

#----------------------------------------------------------------------------------
#| Envoi vers l'application ECDDCH tout CRA redistribue entre 2 et 6 jours        |
#----------------------------------------------------------------------------------
instanceECC_660003960 =i_LireInstanceECC("ECDDCH")
SI (instanceECC_660003960 != -1)
ALORS
  trace("application ECDHDCH")
  ptchp_format_660003960 = i_get_tab_field(FORMAT_ECC_660003960, date_cra_660003960, "ECDDCH")
  res_660003960 = Stockage_Article_660003942(g_iartin, g_iartout, g_iartout5, instanceECC_660003960 , ptchp_format_660003960, date_fin_660003960, type_cra_660003960)
  SI (res_660003960 == STCK_KO_660003960)
  ALORS
    trace("**Tcrae_moc , erreur d'envoi de l'article a l'application ECDDCH")
    code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
    erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "ECDDCH", pt_NameOfFile_660003960)
    erreur_660003960 = i_PlvMessEmettre(8835, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
    SAUT STOCKE_ERRONE
  FINSI
FINSI

POINT  ECC_SECONDAIRES

#------------------------------------------------------
#| envoi inconditionnel vers l'application SYMPHONIE  |
#------------------------------------------------------
instanceECC_660003960 = i_LireInstanceECC("SYMDCH")
SI (instanceECC_660003960 != -1)
ALORS
  trace("application SYMPHONIE")
  ptchp_format_660003960 = i_get_tab_field(FORMAT_ECC_660003960, date_cra_660003960, "SYMDCH")
  res_660003960 = Stockage_Article_660003942(g_iartin, g_iartout, g_iartout5, instanceECC_660003960 , ptchp_format_660003960, date_fin_660003960, type_cra_660003960)
  SI (res_660003960  == STCK_KO_660003960)
  ALORS
    trace("**Tcrae_moc , erreur d'envoi de l'article vers l'application SYMPHONIE")
    code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
    erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "SYMDCH", pt_NameOfFile_660003960)
    erreur_660003960 = i_PlvMessEmettre(8835, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
    SAUT STOCKE_ERRONE
  FINSI
FINSI

#-----------------------------------------------------------------------------------------------
#| Application secondaire de (ADV et DISE, SHACHEM Mobicarte et SHACHEM CMO) : IRIS        |
#-----------------------------------------------------------------------------------------------
#G3R9 lot2, ajout de instCOMDCH et instFRCDCH
#G5R4lot2 Suppression VPF
SI (instMSFDCH_660003960 > 0 || instVDIDCH_660003960 > 0 || instOLADCH_660003960 > 0 ||
  instOL2DCH_660003960 > 0 || instOL3DCH_660003960 > 0 || instOR5DCH_660003960 > 0 || instM1GDCH_660003960 > 0 ||
  instCMODCH_660003960 > 0  || instFEDCH_660003960 > 0 || b_COMESI_660003960)
ALORS
  #  Application IRIS
  #-------------------------------------------------------------------------------------
  instanceECC_660003960 = i_LireInstanceECC("IRIDCH")
  SI (instanceECC_660003960 != -1)
  ALORS
    trace("application IRIS")
    ptchp_format_660003960 = i_get_tab_field(FORMAT_ECC_660003960, date_cra_660003960, "IRIDCH")
    res_660003960 = Stockage_Article_660003942(g_iartin, g_iartout, g_iartout5, instanceECC_660003960 , ptchp_format_660003960, date_fin_660003960, type_cra_660003960)
    SI (res_660003960  == STCK_KO_660003960)
    ALORS
      trace("**Tcrae_moc , erreur d'envoi de l'article a l'application IRIS")
      code_rejet_660003960 = MODULE_DISTR_660003960 + ERR_DISTR_660003960 + EFFICACE_660003960
      erreur_660003960 = i_format_str2(pt_LibelleAlarme_660003960, "%s> <f=%s", "IRIDCH", pt_NameOfFile_660003960)
      erreur_660003960 = i_PlvMessEmettre(8835, 2, g_iartin, "", 2, code_rejet_660003960, pt_LibelleAlarme_660003960, 0)
      SAUT STOCKE_ERRONE
    FINSI
  FINSI
FINSI

trace("****TCRAE_MOC : FIN PCODE DU MODULE DE DISTRIBUTION OK****")

#-----------------------------------FIN PCODE DISTRIBUTION MOC -----------------------------------------


RETOUR TRAIT_OK

# stockage de l'article en errone

POINT STOCKE_ERRONE

erreur_660003960 = i_make_art_rej(g_iartin, g_iartout2, code_rejet_660003960)
erreur_660003960 = i_stocke_art(g_iartout2,0,PT_ERRONE,0)
trace("**Tcrae_moc , Artcile stocke en errone**")
#      RETOUR TRAIT_OK
RETOUR BAD_BLOC
#------------------------------------------- FIN Tcrae_moc_dis.src --------------------------------------------
