# Fonction PCODE ID = 660004590
REGISTRE ENTIER multidistribution
REGISTRE ENTIER type_distri
REGISTRE ARTOBJ artout
REGISTRE ARTOBJ artin

#definitions/constantes

## G3R10 lot4 constante C_FRA_APN_TRT[1-5]
##  Une valeur = "0" indique un filtrage possible (cf. criteres exclusion des filtres)
## C_FRA_APN_TRT1  0  = 0eme caractere de ptr_ResFRAAPNTRT (retour table externe FRA_APN_TRT) si "0" -> envoi des CRA reseau locaux
## C_FRA_APN_TRT2  2  = 2eme caractere de ptr_ResFRAAPNTRT (retour table externe FRA_APN_TRT) si "0" -> envoi des CRA reseau locaux en roaming out
## C_FRA_APN_TRT3  4  = 4eme caractere de ptr_ResFRAAPNTRT (retour table externe FRA_APN_TRT) si "0" -> envoi des CRA DCB locaux
## C_FRA_APN_TRT4  6  = 6eme caractere de ptr_ResFRAAPNTRT (retour table externe FRA_APN_TRT) si "0" -> envoi des CRA DCB en roaming out
## C_FRA_APN_TRT5  8  = 8eme caractere de ptr_ResFRAAPNTRT (retour table externe FRA_APN_TRT) si "0" -> envoi des CRA vers ECC IRIS
## format retourne par la table    "[01]:[01]:[01]:[01]:[01]"
## position dans ptr_ResFRAAPNTRT =  0    2    4    6    8
## C_FRA_APN_TRTx     avec      x =  1    2    3    4    5
DEFINITION C_FRA_APN_TRT1  0
DEFINITION C_FRA_APN_TRT2  2
DEFINITION C_FRA_APN_TRT3  4
DEFINITION C_FRA_APN_TRT4  6
DEFINITION C_FRA_APN_TRT5  8

#G5R1lot2 (chaque poste represente respectivement envoi des IMSI : ADV, DISE, FE, Come, TPE, VPN), 1_1_1_1_1_1
#                                                                   0     2    4    6    8    10 , 012345678910
DEFINITION C_FiltreCetS_ADV  0
DEFINITION C_FiltreCetS_DISE 2
DEFINITION C_FiltreCetS_FE   4
DEFINITION C_FiltreCetS_COME 6
DEFINITION C_FiltreCetS_TPE  8
DEFINITION C_FiltreCetS_VPN  10

#QC913
DEFINITION  C_NUMTAB 1
DEFINITION  C_ZONEMETRO 7
# G5R1
DEFINITION  C_BIGSM   "BI1GSM"

DEFINITION  TD_Imsi   0
DEFINITION  TD_Msisdn 1
DEFINITION  TD_Alice  2
DEFINITION  TD_SVA    2
# nom de la table 3 : SVA
# nom du referentiel et de l'instance : ALICE

DEFINITION  C_ptr_IMSI_44           "444444444444444"
DEFINITION  C_ptr_IMSI_55           "555555555555555"
DEFINITION  C_ptr_IMSI_77           "777777777777777"
DEFINITION  C_ptr_IMSI_88           "888888888888888"
DEFINITION  C_ptr_IMSI_99           "999999999999999"
DEFINITION  C_ptr_IMSI_ORANGE       "20801"
DEFINITION  C_ptr_IMSI_REUNION      "64700"
DEFINITION  C_ptr_local_REUNION     "64700"
DEFINITION  C_ptr_IMSI_Mobicarte_1  "208990000000001"
DEFINITION  C_ptr_IMSI_Mobicarte_2  "208990000000002"
DEFINITION  C_ptr_IMSI_Mobicarte_3  "208990000000003"
DEFINITION  C_ptr_IMSI_Mobicarte_4  "208990000000004"

DEFINITION  STOCKAGE_KO -1

DEFINITION  Oui     1
DEFINITION  Non     0

DEFINITION  Vrai     1
DEFINITION  Faux     0

DEFINITION  TRAI_OK    0
DEFINITION  TRAI_KO   -1
DEFINITION  TRAI_REDISTRIBUTION -2
DEFINITION  CRIT_SPEC   0
DEFINITION  CRIT_INCONNU    1
DEFINITION  CRIT_AIG_IMSI   2

# definition des tables externes
DEFINITION  Activation            "EtatCritere"
DEFINITION  SMS_MO_STATUS4        "SMS_MO_STATUS4"
DEFINITION  FILTRE_DISE_LOC       "FILTRE_DISE_LOC"
DEFINITION  PUSH_TO_TALK_ADV      "PUSH_TO_TALK_ADV"
DEFINITION  ACTIVSG               "ACTIVSG"
DEFINITION  ACTIV_MMS             "ACTIV_MMS"
DEFINITION  EFF_I2G               "EFF_I2G"
DEFINITION  SHORT_ID_Non_FAC      "shortid_non_factures"
DEFINITION  GRETA                 "GRETA_TAG"
DEFINITION  CSD_CB                "CSD_CB"
DEFINITION  CSD_MSC               "CSD_MSC"
DEFINITION  LISTE_APN_DCB         "LISTE_APN_DCB"
DEFINITION  PCCARD                "PCCard"
DEFINITION  Dise_Ent_ShortID      "Dise_Ent_ShortID"
DEFINITION  LISTE_CHARGING_CARAC  "LISTE_CHARGING_CARAC"
DEFINITION  IDPART_USSD           "IDPART_USSD"
DEFINITION  CB_S1D0               "CB_S1D0"
DEFINITION  PCCARD_FW             "PCCard_FW"
DEFINITION  DOM_OPE_TIERS         "DOM_OPE_TIERS"

REGISTRE ENTIER b_control_ECCfac
REGISTRE ENTIER instMsisdn
REGISTRE ENTIER instAlice
REGISTRE ENTIER instIMSI
REGISTRE ENTIER instARTGSM
REGISTRE ENTIER instCMOGSM
REGISTRE ENTIER instDCHGSM
REGISTRE ENTIER instECDGSM
REGISTRE ENTIER instEIRGSM
REGISTRE ENTIER instFRAERR
REGISTRE ENTIER instI2GGSM
REGISTRE ENTIER instIRIGSM
REGISTRE ENTIER instM1GGSM
REGISTRE ENTIER instMSFGSM
REGISTRE ENTIER instNVAGSM
REGISTRE ENTIER instNVSGSM
REGISTRE ENTIER instNVDGSM
REGISTRE ENTIER instOL2GSM
REGISTRE ENTIER instOL3GSM
REGISTRE ENTIER instOLAGSM
REGISTRE ENTIER instOR5GSM

REGISTRE ENTIER instRJPGSM
REGISTRE ENTIER instSHMGSM
REGISTRE ENTIER instSHPGSM
REGISTRE ENTIER instSSMGSM
REGISTRE ENTIER instSSPGSM

#G5R1
REGISTRE ENTIER FlagBI2
REGISTRE ENTIER instBIGSM
REGISTRE ENTIER instBI2GSM

REGISTRE ENTIER instTRGGSM
REGISTRE ENTIER instVDIGSM
REGISTRE ENTIER instFEGSM
REGISTRE ENTIER instOL2PMV
REGISTRE ENTIER instOL3PMV
REGISTRE ENTIER instOLAPMV
REGISTRE ENTIER instOR5PMV
REGISTRE ENTIER instVDIPMV
REGISTRE ENTIER instMACDTE
REGISTRE ENTIER instFREEGSM
REGISTRE ENTIER instTHEMISGSM
REGISTRE ENTIER instFULL2
REGISTRE ENTIER instFULL1
#G3R9 lot2 COME
REGISTRE ENTIER instCOMGSM
REGISTRE ENTIER instFRCGSM
REGISTRE ENTIER instNVCGSM

REGISTRE ENTIER long
REGISTRE ENTIER AppelPortabilite
REGISTRE ENTIER PartnerNetworkOperator
REGISTRE ENTIER ClientNetworkOperator
REGISTRE ENTIER puissance
REGISTRE ENTIER indice
REGISTRE ENTIER GValue
REGISTRE ENTIER InfoComp
REGISTRE ENTIER BillingPF
REGISTRE ENTIER EnvoiRedis


REGISTRE ENTIER instSHVGSM
REGISTRE ENTIER instSSVGSM

REGISTRE ENTIER type_cra
REGISTRE ENTIER pnm
REGISTRE ENTIER erreur
REGISTRE ENTIER nb_ecc
REGISTRE ENTIER nb_SVCIN
REGISTRE ENTIER i
REGISTRE ENTIER res
REGISTRE ENTIER res_IMSI
REGISTRE ENTIER app_dest

REGISTRE ENTIER taille_idpart


REGISTRE ENTIER CRA_FRAERR
REGISTRE ENTIER CRA_VPN
REGISTRE ENTIER TYPE_GPRS_GGSN
REGISTRE ENTIER CRA_OR_SUR_OF
REGISTRE ENTIER CRA_IMSI_Reunion_Local_Reunion
REGISTRE ENTIER CRA_IMSI_Orange_local_Reunion

REGISTRE ENTIER TYPE_GPRS_volNULL
REGISTRE ENTIER CRA_REUNION
REGISTRE ENTIER CRA_A_ENRICHIR
REGISTRE ENTIER CRA_a_redistribuer
REGISTRE ENTIER CLS_ETRANGER
REGISTRE ENTIER IMSI_TEST
REGISTRE ENTIER IMSI_REUNION
REGISTRE ENTIER IMSI_ORANGE
REGISTRE ENTIER IMSI_VPN1
REGISTRE ENTIER IMSI_URGENCE
REGISTRE ENTIER IMSI_TPE

REGISTRE ENTIER FILTRE_CB
REGISTRE ENTIER REJET40


REGISTRE ENTIER lg_imsi
REGISTRE ENTIER idemet
REGISTRE ENTIER date_cra
REGISTRE ENTIER date_trait_cra
REGISTRE ENTIER date_fin_cra
#QC913
REGISTRE ENTIER gmt_date_cra
REGISTRE ENTIER instECCv_msisdn
REGISTRE ENTIER Nb_jour
REGISTRE ENTIER date_table
REGISTRE ENTIER date_table2
REGISTRE ENTIER   CB_HORSPERI
REGISTRE ENTIER   Date_cur
REGISTRE ENTIER Date_curFRAERR
REGISTRE ENTIER Nb_jourFRAERR

REGISTRE ENTIER   CORIOLIS
REGISTRE ENTIER   GRETA_TAG
REGISTRE ENTIER   DISE_Entreprise
REGISTRE ENTIER   UsageTV

REGISTRE ENTIER posINCC
REGISTRE ENTIER posVPN
REGISTRE ENTIER Nb_CS
REGISTRE ENTIER FE
#G3R10 lot4
REGISTRE ENTIER DataRoaming_Legacy
REGISTRE ENTIER DataRoaming_LTE
REGISTRE ENTIER Flag_transType

REGISTRE ENTIER SMS_SURTAXE
REGISTRE ENTIER PRESENCE_IDPART

#G3R3 2GDT
REGISTRE ENTIER TYPE_GPRS_SGSN
#G3R3 lot3 Curling_Free
REGISTRE ENTIER ITI_FREE
REGISTRE ENTIER IMSI_FREE
#G3R4 lot3
REGISTRE ENTIER Hostspot_THEMIS

#QC983
REGISTRE ENTIER Old_Family
REGISTRE ENTIER val

#G3R6 LICIA-Full MVNO OMEA
REGISTRE ENTIER EntierMVNO

REGISTRE ENTIER IMSI_candidat_MVNOFull
REGISTRE ENTIER IMSI_MVNOFull1
REGISTRE ENTIER IMSI_MVNOFull2
REGISTRE ENTIER FormatDist
REGISTRE ENTIER c_eec

#G3R6 Filtrage CRAs GGSN hors MVNO pour EIR
REGISTRE ENTIER MVNO

#G3R7
REGISTRE ENTIER IMSI_OrangeCo

#G3R7 LTE
REGISTRE ENTIER b_4GPgw
REGISTRE ENTIER b_4GSgw

#G3R8 lot1
REGISTRE ENTIER OnLineFlag

#G3R9 lot2 COME
REGISTRE ENTIER COMESI
REGISTRE ENTIER COME
REGISTRE ENTIER FRCOME
REGISTRE ENTIER FE_DISE
REGISTRE ENTIER FEElligible
REGISTRE POINTEUR ptr_prefMVNO

REGISTRE POINTEUR ptr_IMSI_MSISDN
REGISTRE POINTEUR pt_dcb_IMSI
REGISTRE POINTEUR pt_res_table

REGISTRE POINTEUR str_idpart_ascii
REGISTRE POINTEUR str_idpart
REGISTRE POINTEUR str_imsi_ascii
REGISTRE POINTEUR str_idpart_ascii_min
REGISTRE POINTEUR str_local_ascii
REGISTRE POINTEUR str_idemet_ascii
REGISTRE POINTEUR ptr_imsi_ascii_tmp
REGISTRE POINTEUR pt_indeff_hex
REGISTRE POINTEUR pt_indeff_ascii
REGISTRE POINTEUR pt_chgcar_ascii
REGISTRE POINTEUR ptr_chgcar_ascii
REGISTRE POINTEUR ptr_accPointName3
REGISTRE POINTEUR str_accPointName3
REGISTRE POINTEUR pt_totVolOut_ascii
REGISTRE POINTEUR pt_totVolIn_ascii
REGISTRE POINTEUR pt_totVol_tmp
REGISTRE POINTEUR pt_MSP

REGISTRE POINTEUR pt_DDE_IMSI
REGISTRE POINTEUR pt_Buffer
REGISTRE POINTEUR pt_CAMEL_DEST_NUMBER
REGISTRE POINTEUR pt_MSISDN
REGISTRE POINTEUR str_ENTaccPointName3

REGISTRE POINTEUR ptr_date_res
REGISTRE POINTEUR ptr_valeurDATE
REGISTRE POINTEUR ptr_idpart
REGISTRE POINTEUR ptr_resul

REGISTRE POINTEUR ptr_service
REGISTRE POINTEUR ptr_Amount
REGISTRE POINTEUR ptr_extra
REGISTRE POINTEUR ptr_Emettrice
REGISTRE POINTEUR ptr_advme
REGISTRE POINTEUR ptr_advme_id
REGISTRE POINTEUR ptr_valINCC
REGISTRE POINTEUR ptr_valHCE
REGISTRE POINTEUR ptr_valORLCF

REGISTRE POINTEUR ptr_valVPN
REGISTRE POINTEUR ptr_transactionType

REGISTRE POINTEUR ptr_GASCII
REGISTRE POINTEUR ptr_GASCII4
REGISTRE POINTEUR ptr_GASCII9
REGISTRE POINTEUR ptr_GASCII14

REGISTRE POINTEUR str_MADN

REGISTRE POINTEUR ptr_res
REGISTRE POINTEUR ptr_Fin

REGISTRE POINTEUR str_IDEMET_CMM

#G4R10 lot4
REGISTRE POINTEUR ptr_ARCHITECTURE
REGISTRE POINTEUR ptr_SEGMENT_CLIENT
REGISTRE POINTEUR ptr_archi
REGISTRE POINTEUR ptr_archiCB
REGISTRE POINTEUR ptr_SGTQS
REGISTRE POINTEUR ptr_ResFRAAPNTRT
REGISTRE POINTEUR ptr_FRAAPNTRT

REGISTRE ENTIER MVNO_postpaid
REGISTRE ENTIER MVNO_prepaid

REGISTRE ENTIER CSDCB_FS_Desactive

REGISTRE ENTIER Dise_Ent_ShortID_VRAI
REGISTRE ENTIER IND_EFF

REGISTRE ENTIER Grand_Public

REGISTRE ENTIER RZB_RoamingZB
REGISTRE ENTIER RINT_Roaming_International

REGISTRE POINTEUR pt_cle

REGISTRE POINTEUR ptr_SMS
REGISTRE POINTEUR ptr_SMSrecepMSISDN

REGISTRE POINTEUR str_RVMV
REGISTRE POINTEUR ptr_WlanHotSpotId
REGISTRE POINTEUR ptr_prefSpot

REGISTRE ENTIER NumOfFilter
REGISTRE ENTIER flag_ADVPMV

#G3R7
REGISTRE POINTEUR str_MNC
REGISTRE POINTEUR str_conteneur

#G3R8 lot1
REGISTRE POINTEUR ptr_ECM

#G3R9 lot2 COME
REGISTRE POINTEUR str_COMESI

#G5R1 lot2
REGISTRE POINTEUR pt_NumPart
REGISTRE POINTEUR pt_CodeTarifSVA
REGISTRE POINTEUR pt_TypeEditeurSVA
REGISTRE ENTIER ACTIV_CS
REGISTRE POINTEUR ptr_CetS_GRATUIT

#G5R2 lot1
REGISTRE ENTIER ACTIV_AP
REGISTRE ENTIER b_mapTarif_CS
REGISTRE ENTIER b_mapTarif_AP

# G5R2lot2
REGISTRE ENTIER   IMSI_Transnational_M2M
REGISTRE POINTEUR pt_MCCMNCx
REGISTRE POINTEUR pt_IMSIy
#/G5R2lot2

# G5R3 lot1
REGISTRE ENTIER optiers
REGISTRE POINTEUR pt_optiers

# G5R3 QC1500
REGISTRE ENTIER position

multidistribution = depilerENTIER()
type_distri = depilerENTIER()
artout = depilerARTOBJ()
artin = depilerARTOBJ()

# Initialisation
type_cra = -1
pnm = -1
erreur = -1
nb_SVCIN = -1
nb_ecc = -1
res = -1
instIMSI = -1
app_dest = -1
lg_imsi = -1
taille_idpart = -1
MVNO_postpaid=Non
MVNO_prepaid=Non
CORIOLIS=Non
GRETA_TAG=-1
DISE_Entreprise=Non
UsageTV = Non
AppelPortabilite=Non
PartnerNetworkOperator=0xFFFF
ClientNetworkOperator=0xFFFF
GValue = 0xFFFFFFFF
BillingPF = 0xFF
CRA_FRAERR = Non
CRA_VPN = Non
TYPE_GPRS_GGSN = Non
CRA_OR_SUR_OF = Non
CRA_IMSI_Reunion_Local_Reunion = Non
CRA_IMSI_Orange_local_Reunion = Non
TYPE_GPRS_volNULL = Non
CRA_REUNION = Non
CRA_A_ENRICHIR = Non
CRA_a_redistribuer = Non
CLS_ETRANGER = Non
IMSI_TEST = Non
IMSI_VPN1 = Non
IMSI_URGENCE = Non
IMSI_TPE = Non
IMSI_REUNION = Non
IMSI_ORANGE = Non
REJET40 = Non
Grand_Public = Non
RZB_RoamingZB = Non
RINT_Roaming_International = Non
long = 0
CB_HORSPERI = 0
Date_cur = 0
Date_curFRAERR = 0
Nb_jourFRAERR = 0
CSDCB_FS_Desactive = Non
posINCC = 0
posVPN = 0
Nb_CS = 0
#G2R1_FE
FE = -1
#G2R6  SMS_SURTAXE lot3
SMS_SURTAXE = 0
PRESENCE_IDPART = 0
#G3R10 lot4
DataRoaming_Legacy = Non
DataRoaming_LTE = Non
Flag_transType = Non
#G3R3 2GDT
TYPE_GPRS_SGSN = Non
#G3R3 lot3 Curling Free
ITI_FREE = 0
IMSI_FREE = 0
#G3R4 lot3
Hostspot_THEMIS = 0
#QC983
Old_Family = 0
val = 0
IMSI_candidat_MVNOFull = 0
IMSI_MVNOFull1 = 0
IMSI_MVNOFull2 = 0
FormatDist = 0
c_eec = 0
MVNO = 0
EntierMVNO = 0
IMSI_OrangeCo = 0
#G3R7 LTE
b_4GPgw = Non
b_4GSgw = Non
#G3R8 lot1
OnLineFlag = 0
#G3R9 lot2 COME
COMESI = 0
COME = Non
FRCOME = Non
FE_DISE = Non
FEElligible = Non
instCOMGSM = 0
instFRCGSM = 0
instNVCGSM = 0
ACTIV_AP = 0
b_mapTarif_CS = 0
b_mapTarif_AP = 0

# Affectation, Initialisation
ptr_prefMVNO = "ptr_prefMVNO57575757575757575575757575757575757557575757557"
ptr_IMSI_MSISDN  = "ptr_IMSI_MSISDN987654321012345666666666666666666"
pt_dcb_IMSI =      "pt_dcb_IMSI9988776655443322333333333333333333333"
pt_res_table = "00112233445566778899"
ptr_valeurDATE = "ptr_valeurDATE_0871871871871871871871878178718817817817"
ptr_date_res = "ptr_date_res_918273645463728191"
str_idpart_ascii = "str_idpart_ascii00112233445566778899001122334455"
ptr_res     = "ptr_res001122334455667788990011223344556666"
pt_NumPart  = "pt_NumPart2222222222222222222222222222222222222222"
str_idpart =           "str_idpart_99887001122334455667788990011223344552222"
str_idpart_ascii_min = "str_idpart_ascii_min00112233445566778899001122334455"
str_imsi_ascii = "str_imsi_ascii1111111111111111111111111111111111"
str_local_ascii = "str_local_ascii0123456789"
str_idemet_ascii = "str_idemet_ascii0123456789"
ptr_imsi_ascii_tmp = "ptr_imsi_ascii_tmp0123456789"
ptr_chgcar_ascii = "ptr_chgcar_ascii0123456789"
ptr_resul ="ptr_result_"
pt_indeff_hex="h"
pt_indeff_ascii="a"
pt_CAMEL_DEST_NUMBER = "pt_CAMEL_DEST_NUMBER01234567890123456789"
pt_MSISDN = "pt_MSISDN0123456789012345678901234567890123456789"
i_strcpy(pt_MSISDN, "")
pt_DDE_IMSI = "pt_DDE_IMSI01234567890123456789"
pt_Buffer = "pt_Buffer978987898789878987898798789987898789878987789qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq123456789"
pt_cle = "pt_cle0123456789012345678901234567890123456789"
pt_chgcar_ascii = "pt_chgcar_ascii"
ptr_accPointName3 = "ptr_accPointName3012345678901234567890123456789012345678901234567890123456789"
str_accPointName3 = "str_accPointName301234567890123456789012345678901234567890123456789012345678901201234567901234567890"
str_ENTaccPointName3 = "str_ENTaccPointName3301234567890123456789012345678901234567890123456789012345678901201234567901234567890"
pt_totVolOut_ascii = "totVolOut_as"
pt_totVolIn_ascii = "totVolIn_asc"
pt_totVol_tmp = "pt_totVol_tmp:"
pt_MSP ="pt_MSP555555555555555555555555555555555555555555555"
i_strcpy(ptr_resul,"")
ptr_idpart = "ptr_idpart9877899877898778987898789879898789877899878998787899787898787676778678"
ptr_service = "ptr_service0789078907890789078907890789078907890"
ptr_Amount = "ptr_Amount5432543254325432564326543276543298765432187654098789009876"
ptr_extra = "ptr_extra7"
ptr_Emettrice = "ptr_Emettrice1971971971971978197197197197197197197917917917917917917197"
ptr_advme = "ptr_advme29892829829289289289289289289289289289289282982928928928928928928928"
ptr_advme_id = "ptr_advme_id7357357357357357357357357357357357357357357357537537537573537537537537537"
ptr_valINCC = "ptr_valINCC1591591591591591591591591591589151905191519851915195191591591"
ptr_valHCE = "ptr_valHCE01591591591591591591591591591589151905191519851915195191591591"
ptr_valORLCF = "ptr_valORLCF01591591591591591591591591591589151905191519851915195191591591"
ptr_valVPN = "ptr_valVPN712712717271271271721727127127172781727712771172172771267127712"
ptr_transactionType = "ptr_transactionType12345"
ptr_GASCII = "ptr_GASCII5934593459458954976511111111111111111111"
ptr_GASCII4 = "194519451945"
ptr_GASCII9 = "174530949342"
ptr_GASCII14 = "27437391276"
str_MADN = "str_MADN837837837837837837837837837837837837837837837837837883783783783783787387387837837"
ptr_SMSrecepMSISDN = "ptr_SMSrecepMSISDN99999999999999999999999999999999999999999999999"
ptr_SMS = "ptr_SMS_1275757575757575757575757575775757577577557577557575757557575757755757575757575757"
ptr_Fin = "ptr_Fin44444"
str_IDEMET_CMM = "str_IDEMET_CMM1231232131231231213213112311213121321131231121312131213121321312131123112131213121312131123112312131"
#G3R4 lot3
str_RVMV = "str_RVMV95959595959599595595959595959595595959595959595959559595959595959595959595959595959595959595959"
ptr_WlanHotSpotId = "ptr_WlanHotSpotId12312312312312312131231213121312131121312312113121321312131213112131231123112"
ptr_prefSpot  = "ptr_prefSpot1071071071070170170170"
str_MNC = "str_MNC176176176176171671617161171617161716117161761171617161716171617161716176117161716"
str_conteneur = "str_conteneur2972972972927927927927292729227292729278292729272927292729272927292729"
#G3R8 lot1
ptr_ECM = "ptr_ECM254254524524524252452425242252425242"
str_COMESI = "str_COMESI71971971971971971971971971971971979179179179179179179179179179"
ptr_ARCHITECTURE = "ptr_ARCHITECTURE1111"
ptr_SEGMENT_CLIENT = "ptr_SEGMENT_CLIENT22222"
ptr_SGTQS = "ptr_SGTQS746746746746746743454"
ptr_archi = "ptr_archi19871987519876178951654642424565443"
ptr_ResFRAAPNTRT = "ptr_ResFRAAPNTRT376537653676537653756537"
ptr_FRAAPNTRT = "ptr_FRAAPNTRT0123212321232123301234567890123456789012345678901234567890123456789012345678934546579876543456789876789567"
ptr_archiCB = "ptr_archiCB123456789123456789123456789123456"
ptr_CetS_GRATUIT = "ptr_CetS_GRATUIT"
pt_CodeTarifSVA   = "pt_CodeTarifSVA"
pt_TypeEditeurSVA = "pt_TypeEditeurSVA"

# G5R2lot2
IMSI_Transnational_M2M = 0
pt_MCCMNCx = "pt_MCCMNCx12"
i_strcpy(pt_MCCMNCx,"")
pt_IMSIy   = "pt_IMSIy1234"
i_strcpy(pt_IMSIy,"")
#/G5R2lot2

# G5R3 lot1
pt_optiers = "pt_optiers0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"

# Initialisation
i_strcpy(ptr_ARCHITECTURE, "")
i_strcpy(ptr_SEGMENT_CLIENT, "")
i_strcpy(ptr_SGTQS,"")
i_strcpy(ptr_archi,"")
i_strcpy(ptr_ResFRAAPNTRT,"")
i_strcpy(ptr_FRAAPNTRT,"")
i_strcpy(ptr_archiCB,"")
i_strcpy(ptr_chgcar_ascii,"")
i_strcpy(ptr_Emettrice,"")
i_strcpy(ptr_Amount,"")
i_strcpy(ptr_service,"")
i_strcpy(ptr_IMSI_MSISDN, "")
i_strcpy(pt_dcb_IMSI, "")
i_strcpy(pt_res_table, "")
i_strcpy(str_idpart_ascii, "")
i_strcpy(str_idpart, "")
i_strcpy(str_imsi_ascii, "")
i_strcpy(str_local_ascii, "")
i_strcpy(str_idemet_ascii, "")
i_strcpy(ptr_imsi_ascii_tmp, "")
i_strcpy(pt_indeff_hex, "j")
i_strcpy(pt_indeff_ascii, "z")
i_strcpy(pt_chgcar_ascii, "")
i_strcpy(str_accPointName3,"")
i_strcpy(pt_totVolOut_ascii, "@s")
i_strcpy(pt_totVolIn_ascii, "")
i_strcpy(pt_totVol_tmp, "")
i_strcpy(ptr_idpart, "")
i_strcpy(pt_DDE_IMSI, "")
i_strcpy (pt_Buffer, "")
i_strcpy(str_MADN, "")
i_strcpy(ptr_SMSrecepMSISDN, "")
i_strcpy(ptr_SMS, "")
i_strcpy(ptr_res,"")
i_strcpy(ptr_Fin,"")
i_strcpy(str_IDEMET_CMM,"")
i_strcpy(str_RVMV,"")
i_strcpy(ptr_WlanHotSpotId,"")
i_strcpy (ptr_prefSpot,"")
i_strcpy (ptr_prefMVNO,"")
i_strcpy (str_MNC,"")
i_strcpy(str_conteneur,"")
i_strcpy(ptr_ECM,"")
i_strcpy(str_COMESI,"")
i_strcpy(pt_NumPart,"")
i_strcpy(pt_CodeTarifSVA,"")
i_strcpy(pt_TypeEditeurSVA,"")
i_strcpy(ptr_CetS_GRATUIT,"")

# Debut Aiguillage
type_cra = i_get_art_field(g_iartout, $Tdpvgsm::type)
IND_EFF = i_get_art_field(g_iartout, $Tdpvgsm::indeff)

SI (type_cra < 0)
ALORS
  trace1("<<<__LINE__<<<__FILE__<<< ERR : type=<0x%x>",type_cra)
  erreur = i_PlvMessEmettre(7524, 2, g_iartin, "", 3, 0xA072, type_cra, "type")
  RETOUR TRAI_KO
FINSI

#QC983 Determination des Classes articles new et old
SI i_valid_field (artin,"T1")
ALORS
  val = i_get_art_field (artin,0)
  SI (val == 0x20 || val == 0x21 || val == 0x24 || val == 0x25 || val == 0x27 || val == 0x28 )
  ALORS
    Old_Family = 1
  FINSI
FINSI
#/QC983

date_cra = i_get_art_field(g_iartout, $Tdpvgsm::DATE)
date_fin_cra = i_get_art_field(g_iartout, $Tdpvgsm::dfin)
date_trait_cra = i_cur_time()
#QC913
gmt_date_cra = i_DHgetCe2gTime(C_NUMTAB,C_ZONEMETRO,date_cra)
SI (date_cra == -1)
ALORS
  trace1("<<<__LINE__<<<__FILE__<<< ERR : DATE=<0x%x>",date_cra)
  erreur = i_PlvMessEmettre(7524, 2, g_iartin, "", 3, 0xA072, date_cra, "DATE")
  RETOUR TRAI_KO
FINSI

SI (date_fin_cra == -1)
ALORS
  trace1("<<<__LINE__<<<__FILE__<<< ERR : dfin=<0x%x>",date_fin_cra)
  erreur = i_PlvMessEmettre(7524, 2, g_iartin, "", 3, 0xA072, date_fin_cra, "dfin")
  RETOUR TRAI_KO
FINSI

# Test de presence BI2 dans table externe
SI (i_get_tab_field("Format_ECC", date_trait_cra, "BI2GSM") != g_inull)
ALORS
  FlagBI2 = 1
SINON
  FlagBI2 = 0
FINSI

#Ajout/modification de l enveloppe optionnelle
EnvoiRedis = i_get_attr_val_n($E_Redistri2::EnvoiRedis)
SI (i_LireRedistCpt() == 0) && (EnvoiRedis != 1)
ALORS
  erreur = i_set_attr_val_n( $E_Redistri2::c_eec, 0)
  erreur = i_set_attr_val_n( $E_Redistri2::DatePremierPass, i_cur_date())
  erreur = i_set_attr_val_n( $E_Redistri2::DateDernierPass, i_cur_date())

FINSI

#recuperation IMSI
erreur = i_get_art_str(g_iartout, $Tdpvgsm::IMSI, str_imsi_ascii)
SI (i_strcmp(str_imsi_ascii, "") == 0)
ALORS
  trace1("<<<__LINE__<<<__FILE__<<< ERR conversion dcb ascii : IMSI=<0x%x>",0)
  erreur = i_PlvMessEmettre(7524, 2, g_iartin, "", 3, 0xA072, 0, "IMSI")
  RETOUR TRAI_KO
FINSI

# str_imsi_ascii, ptr_IMSI_MSISDN sont equivalents (ptr_IMSI_MSISDN servait pour l'IMSI calcule a partir du MSISDN)
# Ces trois pointeurs contiennent la meme info : IMSI contenu dans le CRAL d'entree et si absent celui recalcule par la requete referentiel sur le  MSISDN
i_strcpy(ptr_IMSI_MSISDN, str_imsi_ascii)
trace2("str_imsi_ascii = <%s>", str_imsi_ascii, "")


#G5R2 lot2
# MCCMNCx : 6 premiers caracteres de IMSI
# rmq : IMSI = MCCMNC (5 digits) + MSIN commen?ant par xy, MSIN etant Mobile Subscriber Identifiant Number
i_get_sub_str(str_imsi_ascii, 0, 5, pt_MCCMNCx)


# IMSIy : 7eme caractere de IMSI
# rmq : IMSI = MCC/MNC/xy&..
i_get_sub_str(str_imsi_ascii, 6, 6, pt_IMSIy)


# IMSI_Transnational_M2M : booleen vrai si
# RechercherValeurClefTable(MVNO, "M2M_"+MCCMNCx) = "Tous"   ou   IMSIy appartient a la liste des valeurs (separees par "_") retournee par [RechercherValeurClefTable(MVNO, "M2M_"+MCCMNCx)]
# table externe MVNO, nouvelles occurrences :
#   M2M_901312; Tous   ;  Tous les IMSI commencant par 901312 sont transnationaux M2M
#   M2M_901312; 1_2_5  ;  Seuls les IMSI 9013121*; 9013122* ; 90131215* sont transnationaux M2M
erreur = i_format_str2(str_conteneur, "%s%s", "M2M_", pt_MCCMNCx)
i_strcpy(ptr_res, i_get_tab_field("MVNO", date_cra, str_conteneur))
# QC1441
SI (i_strcmp(pt_IMSIy, "") != 0 && i_strcmp(ptr_res, "") != 0)
ALORS
  SI ( i_strcmp(ptr_res,"Tous") == 0 || i_adequation_chaine_expreg(ptr_res, pt_IMSIy) == 0)
  ALORS
    IMSI_Transnational_M2M = Vrai
  SINON
    IMSI_Transnational_M2M = Faux
  FINSI
SINON
  IMSI_Transnational_M2M = Faux
FINSI
#/G5R2 lot2

#G3R7 valorisation de IMSI_OrangeCo
SI (i_strplcmp(str_imsi_ascii, C_ptr_IMSI_ORANGE, 0, i_strlen(C_ptr_IMSI_ORANGE)) == 0)
ALORS
  IMSI_OrangeCo = Oui
SINON
  SI (i_strplcmp (str_imsi_ascii,"208", 0, 3) == 0)
  ALORS
    i_get_sub_str (str_imsi_ascii, 0, 4, str_MNC)
    erreur=i_format_str2( str_conteneur, "%s%s", "L_", str_MNC)
    SI (i_get_tab_field("MVNO", date_cra, str_conteneur)) != g_inull
    ALORS
      IMSI_OrangeCo = Oui
    SINON
      IMSI_OrangeCo = Non
    FINSI
  FINSI
FINSI

#recuperation idemet
erreur = i_get_art_str(g_iartout, $Tdpvgsm::idemet, str_idemet_ascii)

#recuperation idpart
SI (i_valid_field_n(g_iartout, $Tdpvgsm::idpart))
ALORS
  erreur = i_get_art_str(g_iartout, $Tdpvgsm::idpart, str_idpart_ascii)
  # QC1447 report de la QC1434
  SI (i_strcmp(str_idpart_ascii, "") != 0)
  ALORS
    i_replace_str(str_idpart_ascii, "ABCDE", "abcde", str_idpart_ascii_min)
    trace2("str_idpart_ascii = <%s>, str_idpart_ascii_min = <%s>", str_idpart_ascii, str_idpart_ascii_min)
    PRESENCE_IDPART = 1
  FINSI
FINSI

#recuperation chgcar
erreur = i_cree_art("Conv_URS", g_iartout7)
erreur = i_cree_art("Tdistribution", g_iartout13)

erreur = i_dup_chp_1val(g_iartout, g_iartout7, $Tdpvgsm::chgcar , $Conv_URS::chgcarHEX)
erreur = i_get_art_str(g_iartout7, $Conv_URS::chgcarDCB, ptr_chgcar_ascii)
# en passant en DCB on perd les eventuels F de bourrage
erreur = i_format_str2(pt_chgcar_ascii, "%s%s", ptr_chgcar_ascii, "FFFF")
i_get_sub_str(pt_chgcar_ascii,0,3,ptr_chgcar_ascii)

#G3R3 lot3 Evaluation du booleen ITI_FREE
SI i_valid_field_n(g_iartout, $Tdpvgsm::PrefItinerance)
ALORS
  ITI_FREE = 1
FINSI

#G3R3 lot3 Evaluation du booleen IMSI_FREE
#QC864  utiliser str_imsi_ascii et non str_idpart_ascii
SI (i_strplcmp(str_imsi_ascii,"20815",0,5) == 0)
ALORS
  IMSI_FREE = 1
FINSI

# IMSI_VPN1 ( demandeur fixe, offre Entreprise)
SI (i_strplcmp(str_imsi_ascii, C_ptr_IMSI_77, 0, i_strlen(C_ptr_IMSI_77)) == 0)
ALORS
  IMSI_VPN1 = Oui
FINSI

# IMSI_TPE (VOIP,offre VOIP Entreprise)
SI (i_strplcmp(str_imsi_ascii, C_ptr_IMSI_44, 0, i_strlen(C_ptr_IMSI_44)) == 0)
ALORS
  IMSI_TPE = Oui
FINSI

# IMSI_URGENCE
SI (i_strplcmp(str_imsi_ascii, C_ptr_IMSI_88, 0, i_strlen(C_ptr_IMSI_88)) == 0)
ALORS
  IMSI_URGENCE = Oui
FINSI

# recuperation accPointName3
SI (i_valid_field_n(g_iartout, $Tdpvgsm::accPointName3))
ALORS
  erreur = i_dup_chp_1val(g_iartout, g_iartout7,$Tdpvgsm::accPointName3, $Conv_URS::accpt3T )
  erreur = i_get_art_str(g_iartout7, $Conv_URS::accpt3A, ptr_accPointName3)
SINON
  i_strcpy(ptr_accPointName3, "FAUX")
FINSI

# filtre CB
SI (i_get_art_field(g_iartout, $Tdpvgsm::tentite) == 0x0B)
ALORS
  FILTRE_CB = Oui
SINON
  FILTRE_CB = Non
FINSI

#G3R7 LTE
SI (i_get_art_field(g_iartout, $Tdpvgsm::tentite) == 0x19)
ALORS
  b_4GPgw = Oui
SINON
  SI(i_get_art_field(g_iartout, $Tdpvgsm::tentite) == 0x18)
  ALORS
    b_4GSgw = Oui
  FINSI
FINSI

#trace1 ("<<__LINE__>>__FILE__>> -------------- b_4GPgw = %d --------------------",b_4GPgw)
#trace1 ("<<__LINE__>>__FILE__>> -------------- b_4GSgw = %d --------------------",b_4GSgw)

#G3R5 Item Gestion du code MNC pour les MVNOs Lights
#G3R7
SI IMSI_OrangeCo
ALORS
  IMSI_ORANGE = Oui
SINON
  SI ( (i_strplcmp(str_imsi_ascii, C_ptr_IMSI_Mobicarte_1, 0, i_strlen(C_ptr_IMSI_Mobicarte_1)) == 0) ||
    (i_strplcmp(str_imsi_ascii, C_ptr_IMSI_Mobicarte_2, 0, i_strlen(C_ptr_IMSI_Mobicarte_2)) == 0) ||
    (i_strplcmp(str_imsi_ascii, C_ptr_IMSI_Mobicarte_3, 0, i_strlen(C_ptr_IMSI_Mobicarte_3)) == 0) ||
    (i_strplcmp(str_imsi_ascii, C_ptr_IMSI_Mobicarte_4, 0, i_strlen(C_ptr_IMSI_Mobicarte_4)) == 0) )
  ALORS
    IMSI_ORANGE = Oui
  FINSI
FINSI
#/G3R7

SI i_valid_field_n(g_iartout, $Tdpvgsm::C_DestNum1)
ALORS
  erreur = i_get_art_str(g_iartout, $Tdpvgsm::C_DestNum1, pt_CAMEL_DEST_NUMBER)
SINON
  i_strcpy(pt_CAMEL_DEST_NUMBER, " ")
FINSI

#QC1424 (correction de la G5R2C1)
erreur = i_get_art_str(g_iartout, $Tdpvgsm::MSISDN, pt_MSISDN)

SI i_valid_field_n(g_iartout, $Tdpvgsm::GretaTag)
ALORS
  GRETA_TAG = i_get_art_field(g_iartout, $Tdpvgsm::GretaTag)
FINSI
#QC983
#SINON
## G3R2 : si T3t99 absent, on l'ajoute pour enrichissement avec FilterNumber

# G1R7
# Verification nature roaming
# Recuperation champ T3t3/local
SI (i_valid_field_n(artout, $Tdpvgsm::local))
ALORS
  erreur = i_get_art_str(g_iartout, $Tdpvgsm::local, str_local_ascii)
  erreur = i_format_str2(pt_cle,"%s%s","DCB_RZB_",str_local_ascii)
  SI (i_get_tab_field("VariableContexte", date_cra, pt_cle) != g_inull)
  ALORS
    RZB_RoamingZB = Oui
    RINT_Roaming_International = Non
  SINON
    RZB_RoamingZB = Non
  FINSI
# G1R7 : spec A23.5
# QC975 ajout du controle sur le champ local vide
  SI (i_strplcmp(str_local_ascii, "20801", 0, 5) != 0 && i_strplcmp(str_local_ascii, "20802", 0, 5) != 0 && RZB_RoamingZB == Non)
  ALORS
    RINT_Roaming_International = Oui
  SINON
    RINT_Roaming_International = Non
  FINSI
SINON
  RINT_Roaming_International = Oui
FINSI

#trace1("<<__LINE__>> =============== RINT_Roaming_International = <%d> =====================",RINT_Roaming_International)
#trace1("<<__LINE__>> =============== RZB_RoamingZB = <%d> ================================", RZB_RoamingZB)

#G3R4 lot3 WIFI THEMIS
#Hostspot_THEMIS
SI (i_valid_field_n(g_iartout,$Tdpvgsm::WlanHotSpotId))
ALORS
  erreur = i_get_art_str(g_iartout, $Tdpvgsm::WlanHotSpotId, ptr_WlanHotSpotId)
  i_get_sub_str(ptr_WlanHotSpotId,0,2,ptr_prefSpot)
  SI (i_strcmp(ptr_prefSpot,"W0W") == 0 || i_strcmp(ptr_prefSpot,"W1W") == 0 || i_strcmp(ptr_prefSpot,"W4W") == 0 || i_strcmp(ptr_prefSpot,"W5W") == 0)
  ALORS
    SI (FILTRE_CB == Non)
    ALORS
      Hostspot_THEMIS = 1
    FINSI
  FINSI
FINSI
#\G3R4 lot3 WIFI THEMIS

# initialisation et controle des ECC rejet, referentiel, poubelle
# RJPGSM
instRJPGSM = i_LireInstanceECC("RJPGSM")
SI ( !instRJPGSM )
ALORS
  trace("Pas d'instance pour RJPGSM !")
  erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "RJPGSM", 0)
  SAUT DISTRI_ERR
FINSI

#G3R6 LICIA-Full MVNO OMEA - Interrogation table MVNO -
#Evaluation du booleen Full1 et Full2

i_get_sub_str(str_imsi_ascii,0,4,ptr_prefMVNO)

#QC1032 QC conversion EntierMVNO en hexa

EntierMVNO = ((i_strtab( ptr_prefMVNO, 0) - 0x30) * 0x10000)
EntierMVNO = EntierMVNO + ((i_strtab( ptr_prefMVNO, 1) - 0x30) * 0x1000)
EntierMVNO = EntierMVNO + ((i_strtab( ptr_prefMVNO, 2) - 0x30) * 0x100)
EntierMVNO = EntierMVNO + ((i_strtab(ptr_prefMVNO, 3) - 0x30) * 0x10)
EntierMVNO = EntierMVNO + (i_strtab( ptr_prefMVNO, 4) - 0x30)

#trace1 ("<<__LINE__>>__FILE__>> ==============EntierMVNO = %d ====================",EntierMVNO)
SI ( 0x20801 < EntierMVNO && EntierMVNO < 0x20899 && IMSI_FREE == 0)
ALORS
  IMSI_candidat_MVNOFull = 1
FINSI

trace1 ("<<__LINE__>>__FILE__>> ===================== IMSI_candidat_MVNOFull = %d =====================",IMSI_candidat_MVNOFull)
SI (IMSI_candidat_MVNOFull == 1)
ALORS
  pt_res_table = i_get_tab_field("MVNO", date_cra, ptr_prefMVNO)

  SI (i_strcmp(pt_res_table,"Full1") == 0)
  ALORS
    IMSI_MVNOFull1 = 1
    FormatDist = i_get_attr_val("FormatDist")
    c_eec = i_get_attr_val("c_eec")
    erreur= i_add_opt( "E_Free" )
    erreur = i_set_attr_val_n($E_Free::PrefixImsi,EntierMVNO)
    erreur = i_set_attr_val_n($E_Free::FormatDist,FormatDist)
    erreur = i_set_attr_val_n($E_Free::c_eec,c_eec)
  SINON
    SI (i_strcmp(pt_res_table,"Full2") == 0)
    ALORS
      IMSI_MVNOFull2 = 1
      FormatDist = i_get_attr_val("FormatDist")
      c_eec = i_get_attr_val("c_eec")
      erreur= i_add_opt( "E_Free" )
      erreur = i_set_attr_val_n($E_Free::PrefixImsi,EntierMVNO)
      erreur = i_set_attr_val_n($E_Free::FormatDist,FormatDist)
      erreur = i_set_attr_val_n($E_Free::c_eec,c_eec)
    FINSI
  FINSI
FINSI

# SVA, ALICE instance du referentiel
instAlice = i_LireInstanceECC("ALICE")
SI ( !instAlice )
ALORS
  trace("Pas d'instance pour ALICE !")
  erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "ALICE", 0)
  SAUT DISTRI_ERR
FINSI

# SGRT instance du referentiel
instMsisdn = i_LireInstanceECC("SGRT")
SI ( !instMsisdn )
ALORS
  trace("Pas d'instance pour SGRT !")
  erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "SGRT", 0)
  SAUT DISTRI_ERR
FINSI

# G5R1
instBIGSM = i_LireInstanceECC(C_BIGSM)
SI ( !instBIGSM )
ALORS
  trace("Pas d'instance pour C_BIGSM !")
  erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, C_BIGSM, 0)
  SAUT DISTRI_ERR
FINSI

SI (FlagBI2)
ALORS
  instBI2GSM = i_LireInstanceECC("BI2GSM")
  SI ( !instBI2GSM )
  ALORS
    trace("Pas d'instance pour BI2GSM !")
    erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "BI2GSM", 0)
    SAUT DISTRI_ERR
  FINSI
FINSI

instEIRGSM = i_LireInstanceECC("EIRGSM")
SI ( !instEIRGSM )
ALORS
  trace("Pas d'instance pour EIRGSM !")
  erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "EIRGSM", 0)
  SAUT DISTRI_ERR
FINSI

instARTGSM = i_LireInstanceECC("ARTGSM")
SI ( !instARTGSM )
ALORS
  trace("Pas d'instance pour ARTGSM !")
  erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "ARTGSM", 0)
  SAUT DISTRI_ERR
FINSI

instIRIGSM = i_LireInstanceECC("IRIGSM")
SI ( !instIRIGSM )
ALORS
  trace("Pas d'instance pour IRIGSM !")
  erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "ARTGSM", 0)
  SAUT DISTRI_ERR
FINSI

instI2GGSM = i_LireInstanceECC("I2GGSM")
SI ( !instI2GGSM )
ALORS
  trace("Pas d'instance pour I2GGSM !")
  erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "I2GGSM", 0)
  SAUT DISTRI_ERR
FINSI

instMSFGSM = i_LireInstanceECC("MSFGSM")
SI ( !instMSFGSM )
ALORS
  trace("Pas d'instance pour MSFGSM !")
  erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "MSFGSM", 0)
  SAUT DISTRI_ERR
FINSI

#G3R9 lot2 COME
#COME
instCOMGSM = i_LireInstanceECC("COMGSM")
SI ( !instCOMGSM )
ALORS
  trace("Pas d'instance pour COMGSM !")
  erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "COMGSM", 0)
  SAUT DISTRI_ERR
FINSI

instFRCGSM = i_LireInstanceECC("FRCGSM")
SI ( !instFRCGSM )
ALORS
  trace("Pas d'instance pour FRCGSM !")
  erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "FRCGSM", 0)
  SAUT DISTRI_ERR
FINSI
#/COME

# Poubelle MSF
instNVDGSM = i_LireInstanceECC("NVDGSM")
SI ( !instNVDGSM )
ALORS
  trace("Pas d'instance pour NVDGSM !")
  erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "NVDGSM", 0)
  SAUT DISTRI_ERR
FINSI

# Poubelle COME
instNVCGSM = i_LireInstanceECC("NVCGSM")
SI ( !instNVCGSM )
ALORS
  trace("Pas d'instance pour NVCGSM !")
  erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "NVCGSM", 0)
  SAUT DISTRI_ERR
FINSI

# Poubelles ADV (generale)
instNVAGSM = i_LireInstanceECC("NVAGSM")
SI ( !instNVAGSM )
ALORS
  trace("Pas d'instance pour NVAGSM !")
  erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "NVAGSM", 0)
  SAUT DISTRI_ERR
FINSI

# Poubelles ADV (filtrage SMS depuis la G3R3)
instNVSGSM = i_LireInstanceECC("NVSGSM")
SI ( !instNVSGSM )
ALORS
  erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "NVSGSM", 0)
  trace("Pas d'instance pour NVSGSM !")
  SAUT DISTRI_ERR
FINSI

instDCHGSM = i_LireInstanceECC("DCHGSM")
SI ( !instDCHGSM )
ALORS
  trace("Pas d'instance pour DCHGSM !")
  erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "DCHGSM", 0)
  SAUT DISTRI_ERR
FINSI

instFREEGSM = i_LireInstanceECC("FREEGSM")
SI ( !instFREEGSM )
ALORS
  trace("Pas d'instance pour instFREEGSM !")
  erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "FREEGSM", 0)
  SAUT DISTRI_ERR
FINSI

#G3R4 lot3 Nouvelle ECC THEMIS
instTHEMISGSM = i_LireInstanceECC("TMIGSM")
SI (!instTHEMISGSM)
ALORS
  trace("Pas d'instance libelle TMIGSM pour instTHEMISGSM !")
  erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "TMIGSM", 0)
  SAUT DISTRI_ERR
FINSI

#G3R6 LICIA-FULL MVNO OMEA
# Nouvelle ECC FULL1GSM
instFULL1 = i_LireInstanceECC("FULL1GSM")
SI (!instFULL1)
ALORS
  trace("Pas d'instance libelle FULL1GSM pour instFULL1 !")
  erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "FULL1", 0)
  SAUT DISTRI_ERR
FINSI

#G3R6 LICIA-FULL MVNO OMEA
# Nouvelle ECC FULL2GSM
instFULL2 = i_LireInstanceECC("FULL2GSM")
SI (!instFULL2)
ALORS
  trace("Pas d'instance libelle FULL2GSM pour instFULL2 !")
  erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "FULL2", 0)
  SAUT DISTRI_ERR
FINSI

# G5R1lot2 C+S
# Variables Fonctionnelles

#G5R2 lot1 Item Wholesale: SI (type_cra 0x04 ou 0x08  alors  Numpart avec T3t4/V3t4 MSISDN
SI ((type_cra == 0x04) || (type_cra == 0x08))
ALORS
  # 1) pt_NumPart : pour les CRA 04 et 08, on utilise le champ T3t4/V3t4 MSISDN  (pt_MSISDN)
  # Si (numero special = 33ZABPQMCDU avec Z=8), T3t4/V3t4 MSISDN = 338* et T3t4/L3t4 = 6 octets et dernier digit = f
  SI (i_strlen(pt_MSISDN) == 11 && i_strplcmp(pt_MSISDN, "338", 0, 3) == 0)
  ALORS
    # NumPart = 9 digits apres 33 = ZABPQMCDU avec Z=8
    i_get_sub_str (pt_MSISDN, 2, -1, pt_NumPart)
  SINON
    # numero court national, T3t4/V3t4 MSISDN = 33* et T3t4/L3t4 < 6 octets
    SI (i_strlen(pt_MSISDN) < 12 && i_strplcmp(pt_MSISDN, "33", 0, 2) == 0)
    ALORS
      # prendre les digits suivant le 33
      i_get_sub_str (pt_MSISDN, 2, -1, pt_NumPart)
    SINON
      # numero court non normalise, T3t4/L3t4 < 4 octets
      SI (i_strlen(pt_MSISDN) < 8 )
      ALORS
        # QC1427 : 33 est absent, NumPart = T3t4/V3t4 MSISDN
        i_strcpy(pt_NumPart, pt_MSISDN)
      FINSI
    FINSI
  FINSI
SINON
  # 1) pt_NumPart avec str_idpart_ascii
  SI (i_strcmp(str_idpart_ascii,""))
  ALORS
    # Si (numero special = 33ZABPQMCDU avec Z=8), T3t2/V3t2 idpart = 338* et T3t2/L3t2 = 6 octets et dernier digit = f
    SI (i_strlen(str_idpart_ascii) == 11 && i_strplcmp(str_idpart_ascii, "338", 0, 3) == 0)
    ALORS
      # NumPart = 9 digits apres 33 = ZABPQMCDU avec Z=8
      i_get_sub_str (str_idpart_ascii, 2, -1, pt_NumPart)
    SINON
      # numero court a traduire
      erreur = i_format_str2(pt_cle,"%s%s","TRAD_",str_idpart_ascii)
      i_strcpy(ptr_res, i_get_tab_field("GRETA_TAG", date_cra, pt_cle))
      SI (i_strlen(str_idpart_ascii) <= 6 && i_strplcmp(str_idpart_ascii, "33", 0, 2) == 0 && i_strcmp(ptr_res,""))
      ALORS
        # NumPart = valeur trouvee en table GRETA_TAG, prendre 9 digits suivant le 33
        i_get_sub_str (ptr_res, 2, 10, pt_NumPart)
      SINON
        # numero court autre
        SI (i_strlen(str_idpart_ascii) < 12 && i_strplcmp(str_idpart_ascii, "33", 0, 2) == 0)
        ALORS
          # prendre les digits suivant le 33
          i_get_sub_str (str_idpart_ascii, 2, -1, pt_NumPart)
        SINON
          # numero court non normalise, T3t2/L3t2 < 4 octets
          SI (i_strlen(pt_NumPart) < 8 )
          ALORS
            # QC1427 : NumPart = T3t2/V3t2 idpart
            i_strcpy(pt_NumPart, str_idpart_ascii)
          FINSI
        FINSI
      FINSI
    FINSI
  FINSI
FINSI

# 2) ACTIV_CS avec interrogation de la table Activation=EtatCritere
SI (i_strplcmp(i_get_tab_field(Activation,date_cra,"ACTIV_CS"),"Actif", 0, 5) == 0)
ALORS
  ACTIV_CS = 1
FINSI
trace1("<<<__LINE__<<<__FILE__<<< ACTIV_CS = <%d>", ACTIV_CS)

# 5 - Enrichissement du CRA par le referentiel SVA ou ALICE , TD_Alice ou TD_SVA
#L'enrichissement concerne les appels vers des numeros SVA ( Service a Valeur Ajoutee ), pour la valorisation C+S ( cout de la communication + cout du service ).
#Pour ces DCs il s'agit de communiquer le Code de Tarification et le type editeur suite a l'interrogation de la table de distribution SVA.
#
#Cet enrichissement a pour but d'alimenter les Champs V3t72 et V3t73
#dans le format DPV4.0 comme suit:
#
#La recherche C+S porte sur les CRAs respectant les criteres suivants :
#
#-  types de CRA sortant : V3t1.1 = 0x00
#-  IMSI_OrangeCo = vrai ou IMSI_VPN1 = vrai
#-  code Tarif SVA : V3t73 absent ( En redistribution )
#-  variable fonctionnelle RZB Roaming ZB = faux (exclus les appels emis en ZB )
#-  teleservice V3t1.8 <> 22 (SMS), V3t1.8 <> 31 (Talknow) (exclus SMS et talknow)
#-  idpart V3t2 present et national (commence par 33*)
#
#Si ACTIV_CS est vrai et  les criteres de recherche C+S sont reunis
#Alors  interrogation du referentiel SVA avec la fonction  InfosTarifSVA et les parametres suivants :
#- <Date> = Date_DC V3t1.5
#- <NumSVA> = NumPart
#Cette fonction retourne les informations :
#- Le code tarif sur 4 octets  en ASCII : CodeTarif SVA
#- Le type editeur sur 1 octet  en ASCII : TypeEditeur SVA

i_strcpy(ptr_res, "")
i_strcpy(pt_cle, "")
SI (!i_valid_field_n(g_iartout, $Tdpvgsm::CodeTarifSVA))
ALORS
  #G5R2 lot1
  SI ( type_cra == 0x00 && i_strcmp(pt_NumPart,"") && i_get_art_field(g_iartout,$Tdpvgsm::tlserv) != 0x22 && i_get_art_field(g_iartout,$Tdpvgsm::tlserv) != 0x31 && ACTIV_CS )
    || ( (type_cra == 0x04 || type_cra == 0x08) && i_strcmp(pt_NumPart,"") && ACTIV_CS)
    || ( type_cra != 0x00 && type_cra != 0x04 && type_cra != 0x08 && (i_valid_field_n(g_iartout, $Tdpvgsm::TypeEditeurSVA)) && i_strcmp(pt_NumPart,"") && ACTIV_CS)
  ALORS
    long = i_conv_ascii_dcb(pt_NumPart, pt_Buffer)
    erreur = i_EnvoiReqConsTabDist(TD_SVA, gmt_date_cra, pt_Buffer, long, 0, 1 )
    SI (!erreur)
    ALORS
      erreur = i_LireReqConsTabDist()
      SI (erreur)
      ALORS
        SAUT FIN_SVA
      FINSI
      res = i_LireInfoECC(instAlice, 0)
      SI (res)
      ALORS
        erreur = i_LireChaineInfo( res, 0, 4, pt_CodeTarifSVA)
        erreur = i_LireChaineInfo( res, 4, 1, pt_TypeEditeurSVA)
#        trace2("<<<__LINE__<<<__FILE__<< IC de ALICE pt_TypeEditeurSVA=<%s>, pt_CodeTarifSVA=<%s>", pt_TypeEditeurSVA, pt_CodeTarifSVA)
        SI (!erreur)
        ALORS
          #G5R2 lot1
          SI (i_strplcmp(pt_CodeTarifSVA, "A", 1, 1) != 0)
          ALORS
            b_mapTarif_CS = 1
          FINSI
          trace1("<<<__LINE__<<<__FILE__<<< b_mapTarif_CS = <%d>", b_mapTarif_CS)
          SI(b_mapTarif_CS == 1)
          ALORS
            #QC1428
            SI Old_Family
            ALORS
              SI (!i_valid_field_n(g_iartout, $Tdpvgsm::TypeEditeurSVA))
              ALORS
                erreur = i_ajout_tlv(g_iartout, "T3t72", "TypeEditeurSVA")
                erreur = i_set_art_str(g_iartout, $Tdpvgsm::TypeEditeurSVA, pt_TypeEditeurSVA)
              FINSI
              erreur = i_ajout_tlv(g_iartout, "T3t73", "CodeTarifSVA")
            SINON
              SI (!i_valid_field_n(g_iartout, $Tdpvgsm::TypeEditeurSVA))
              ALORS
                erreur = i_ajoutChamp(g_iartout, "T3t72", "TypeEditeurSVA",1)
                erreur = i_set_art_str(g_iartout, $Tdpvgsm::TypeEditeurSVA, pt_TypeEditeurSVA)
              FINSI
              erreur = i_ajoutChamp(g_iartout, "T3t73", "CodeTarifSVA",1)
            FINSI
            #/QC1428
            erreur = i_set_art_str(g_iartout, $Tdpvgsm::CodeTarifSVA, pt_CodeTarifSVA)
          FINSI
        FINSI
      FINSI
    FINSI
  FINSI
SINON
  # les champs sont deja renseignes par TPE
  erreur = i_get_art_str(g_iartout, $Tdpvgsm::TypeEditeurSVA, pt_TypeEditeurSVA)
  erreur = i_get_art_str(g_iartout, $Tdpvgsm::CodeTarifSVA, pt_CodeTarifSVA)
FINSI

POINT FIN_SVA

# 3) CetS_GRATUIT apres interrogation du referentiel ALICE
#G5R1lot2 (chaque poste represente respectivement envoi des IMSI : ADV, DISE, FE, Come, TPE, VPN), 1_1_1_1_1_1
#                                                                   0     2    4    6    8    10 , 012345678910
SI (i_strcmp(pt_CodeTarifSVA, "") != 0)
ALORS
  erreur = i_format_str2(pt_cle,"%s%s","CetS_GRATUIT_",pt_CodeTarifSVA)
  i_strcpy(ptr_CetS_GRATUIT, i_get_tab_field("VariableContexte", date_cra, pt_cle))
FINSI

SI (i_strcmp(ptr_CetS_GRATUIT, "") == 0)
ALORS
  ## pas de reponse donc pas de filtre = tout a 1
  i_strcpy(ptr_CetS_GRATUIT, "1_1_1_1_1_1")
  #trace2("<<__LINE__>> ================ ptr_CetS_GRATUIT, valeur par defaut tout a 1 = <%s> ===================",ptr_CetS_GRATUIT,"")
FINSI

#-----------------------------------------------------------------------#
# Enrichissement avec la portabilite (appel de la fonction pcode)
#-----------------------------------------------------------------------#
# G1R4 : complement FO 438
# La valeur par defaut du champ couleur est 0xFF
# Certains fichiers de duplication l'initialise ? une autre valeur
# On le reinitialise donc ici pour plus de surete
# Rq : le code ci-dessous pourra etre simplifie
# G1R5/TT47 pas de FF par defaut pour champ couleur
#erreur = i_set_art_field(g_iartout, $Tdpvgsm::couleur, 0xFF)

#---Uniquement les Cras MMS
SI ((type_cra == 0x30) || (type_cra == 0x32) || (type_cra == 0x36) || (type_cra == 0x38) || (type_cra == 0x39))
ALORS

#----FO327 URSLYON PKH DEBUT RAJOUT des 2 lignes PCODES ci-dessous  15/11/06  correction portabilite -------
#  modification de la recuperation de idpart utilisation de i_get_art_str et du pointeur ptr_idpart et non g_iartout.idpart[]

  SI (i_valid_field_n(g_iartout, $Tdpvgsm::idpart))
  ALORS
    SI ( i_test_field_ila_n(g_iartout,$Tdpvgsm::idpart,"LDmsisdn") == 0 )
    ALORS
      erreur = i_get_art_str(g_iartout, $Tdpvgsm::idpart, ptr_idpart)
      #F04OO  URSLYON debut 01/02/2007 uniquemlent pour les CrAs MMS ne pas appeller PORTABILITE  si idpart commence par 00
      i_get_sub_str(ptr_idpart,0,1,ptr_resul)
      SI (i_strcmp(ptr_resul,"00"))
      ALORS

        # G1R4: PORTABILITE
        long = i_conv_ascii_dcb(ptr_idpart, pt_Buffer)
        #QC913
        erreur = i_EnvoiReqConsTabDist(TD_Msisdn, gmt_date_cra, pt_Buffer, long, 0, 1 )
        SI (erreur == 0)
        ALORS
          erreur = i_LireReqConsTabDist()
          SI (erreur != 0)
          ALORS
            erreur = i_set_art_field(g_iartout, $Tdpvgsm::couleur, 0xFF)
          FINSI
          pnm = i_LireEntierECCv(instMsisdn)
          erreur = i_set_art_field(g_iartout, $Tdpvgsm::couleur, (pnm << 4 | 0x0F))
        SINON
          erreur = i_set_art_field(g_iartout, $Tdpvgsm::couleur, 0xFF)
        FINSI
        AppelPortabilite = Oui
        # G1R4: Fin PORTABILITE
      FINSI
    SINON
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::couleur, 0xFF)
    FINSI
  FINSI
FINSI

#------Autres Cras
#G3R0CwME nouveaux types pour la portabilite
SI  (  ((type_cra >= 0x00) && (type_cra <= 0x06))
  ||  (type_cra == 0x11)
  ||  (type_cra == 0x20)
  || ((type_cra >= 0x22) && (type_cra <= 0x25))
  || ((type_cra >= 0xA0) && (type_cra <= 0xA5))
  || ((type_cra >= 0xA7) && (type_cra <= 0xAF))
  ||  (type_cra == 0x0F)
  ||  (type_cra == 0x0E) )

ALORS
  # valeur par defaut de couleur a 0xFF si idpart absent
  # G1R5/TT47 pas de FF par defaut pour champ couleur
  SI (i_valid_field_n(g_iartout, $Tdpvgsm::idpart))
  ALORS
    SI ( i_test_field_ila_n(g_iartout,$Tdpvgsm::idpart,"LDmsisdn") == 0 )
    ALORS
      erreur = i_get_art_str(g_iartout, $Tdpvgsm::idpart, ptr_idpart)

      # G1R4: PORTABILITE
      long = i_conv_ascii_dcb(ptr_idpart, pt_Buffer)
      #QC913
      erreur = i_EnvoiReqConsTabDist(TD_Msisdn, gmt_date_cra, pt_Buffer, long, 0, 1 )
      SI (erreur == 0)
      ALORS
        erreur = i_LireReqConsTabDist()
        SI (erreur != 0)
        ALORS
          erreur = i_set_art_field(g_iartout, $Tdpvgsm::couleur, 0xFF)
        FINSI
        pnm = i_LireEntierECCv(instMsisdn)
        erreur = i_set_art_field(g_iartout, $Tdpvgsm::couleur, (pnm << 4 | 0x0F))
      SINON
        erreur = i_set_art_field(g_iartout, $Tdpvgsm::couleur, 0xFF)
      FINSI
      AppelPortabilite = Oui
      # G1R4: Fin PORTABILITE
    SINON
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::couleur, 0xFF)
    FINSI
  FINSI
FINSI

# Ajout des T3t55 et T3t56
SI !(i_valid_field_n(g_iartout, $Tdpvgsm::GFlag2))
ALORS
  erreur = i_ajoutChamp(g_iartout, "T3t55","GFlag2",0)
FINSI

SI !(i_valid_field_n(g_iartout, $Tdpvgsm::GValue))
ALORS
  erreur = i_ajoutChamp(g_iartout, "T3t56","GValue",0)
FINSI

SI  (  ((type_cra >= 0x00) && (type_cra <= 0x06))
  ||  (type_cra == 0x0D)
  ||  (type_cra == 0x0E)
  ||  (type_cra == 0x0F)
  ||  ((type_cra >= 0x10) && (type_cra <= 0x15))
  ||  ((type_cra >= 0x20) && (type_cra <= 0x2F))
  ||  (type_cra == 0x30)
  ||  (type_cra == 0x31)
  ||  (type_cra == 0x3C)
  || ((type_cra >= 0xA0) && (type_cra <= 0xAF)) )
ALORS
  SI ( AppelPortabilite == 0 )
  ALORS
    SI (i_valid_field_n(g_iartout, $Tdpvgsm::idpart))
    ALORS
      SI ( i_test_field_ila_n(g_iartout,$Tdpvgsm::idpart,"LDmsisdn") == 0 )
      ALORS
        erreur = i_get_art_str(g_iartout, $Tdpvgsm::idpart, ptr_idpart)
        long = i_conv_ascii_dcb(ptr_idpart, pt_Buffer)
        #QC913
        erreur = i_EnvoiReqConsTabDist(TD_Msisdn, gmt_date_cra, pt_Buffer, long, 0, 1 )
      SINON
        SAUT FIN_DDE_IMSI
      FINSI
    SINON
      SAUT FIN_DDE_IMSI
    FINSI

    SI (erreur == 0)
    ALORS
      erreur = i_LireReqConsTabDist()
      SI (erreur != 0)
      ALORS
        SAUT FIN_DDE_IMSI
      FINSI
    FINSI
  FINSI

  instECCv_msisdn = i_LireEntierECCv( instMsisdn )
  res = i_LireInfoECC( instMsisdn, instECCv_msisdn )

  SI ( res != 0)
  ALORS
    res_IMSI = i_LireImsiInfo( res, 0, 8, pt_DDE_IMSI )

    SI i_strcmp(pt_DDE_IMSI, g_inull) != 0
    ALORS
      lg_imsi = i_conv_ascii_dcb(pt_DDE_IMSI, pt_dcb_IMSI)
#     trace1("lg_imsi dcb = <%d>", lg_imsi)
      erreur = i_memcpy_art_field_n(g_iartout13, $Tdistribution::bufIMSI, pt_dcb_IMSI, lg_imsi)
      erreur = i_set_art_fieldtab(g_iartout13, $Tdistribution::bufIMSI, 16, 0x0F)
      #QC913
      erreur = i_EnvoiReqConsTabDist(TD_Imsi, gmt_date_cra, g_iartout13.bufIMSI[], 8, 0, 1 )

      b_control_ECCfac = 1
# Controle de la presence des ECC de facturation
# ADV
      instVDIGSM = i_LireInstanceECC("VDIGSM")
      SI ( !instVDIGSM )
      ALORS
        trace("Pas d'instance pour VDIGSM !")
        erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "VDIGSM", 0)
        SAUT DISTRI_ERR
      FINSI

      instOLAGSM = i_LireInstanceECC("OLAGSM")
      SI ( !instOLAGSM )
      ALORS
        trace("Pas d'instance pour OLAGSM !")
        erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "OLAGSM", 0)
        SAUT DISTRI_ERR
      FINSI

      instOL2GSM = i_LireInstanceECC("OL2GSM")
      SI ( !instOL2GSM )
      ALORS
        trace("Pas d'instance pour OL2GSM !")
        erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "OL2GSM", 0)
        SAUT DISTRI_ERR
      FINSI

      instOL3GSM = i_LireInstanceECC("OL3GSM")
      SI ( !instOL3GSM )
      ALORS
        trace("Pas d'instance pour OL3GSM !")
        erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "OL3GSM", 0)
        SAUT DISTRI_ERR
      FINSI

      instOR5GSM = i_LireInstanceECC("OR5GSM")
      SI ( !instOR5GSM )
      ALORS
        trace("Pas d'instance pour OR5GSM !")
        erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "OR5GSM", 0)
        SAUT DISTRI_ERR
      FINSI
# QC783
      instOL2PMV = i_LireInstanceECC("OL2PMV")
      SI ( !instOL2PMV )
      ALORS
        trace("Pas d'instance pour OL2PMV !")
        erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "OL2PMV", 0)
        SAUT DISTRI_ERR
      FINSI

      instOL3PMV = i_LireInstanceECC("OL3PMV")
      SI ( !instOL3PMV )
      ALORS
        trace("<__LINE__>Pas d'instance pour OL3PMV !")
        erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "OL3PMV", 0)
        SAUT DISTRI_ERR
      FINSI

      instOLAPMV = i_LireInstanceECC("OLAPMV")
      SI ( !instOLAPMV )
      ALORS
        trace("<__LINE__>Pas d'instance pour OLAPMV !")
        erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "OLAPMV", 0)
        SAUT DISTRI_ERR
      FINSI

      instOR5PMV = i_LireInstanceECC("OR5PMV")
      SI ( !instOR5PMV )
      ALORS
        trace("<__LINE__>Pas d'instance pour OR5PMV !")
        erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "OR5PMV", 0)
        SAUT DISTRI_ERR
      FINSI

      instVDIPMV = i_LireInstanceECC("VDIPMV")
      SI ( !instVDIPMV )
      ALORS
        trace("<__LINE__>Pas d'instance pour VDIPMV !")
        erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "VDIPMV", 0)
        SAUT DISTRI_ERR
      FINSI
#/QC783

# MSF
# deja fait plus haut
# FE
      instFEGSM = i_LireInstanceECC("FEGSM")
      SI ( !instFEGSM )
      ALORS
        trace("Pas d'instance pour FEGSM !")
        erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "FEGSM", 0)
        SAUT DISTRI_ERR
      FINSI

#COMGSM deja fait plus haut
#FRCGSM deja fait plus haut

# SACHEM
      instSHMGSM = i_LireInstanceECC("SHMGSM")
      SI ( !instSHMGSM )
      ALORS
        trace("Pas d'instance pour SHMGSM !")
        erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "SHMGSM", 0)
        SAUT DISTRI_ERR
      FINSI

      instSHPGSM = i_LireInstanceECC("SHPGSM")
      SI ( !instSHPGSM )
      ALORS
        trace("Pas d'instance pour SHPGSM !")
        erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "SHPGSM", 0)
        SAUT DISTRI_ERR
      FINSI
# TRG
      instTRGGSM = i_LireInstanceECC("TRGGSM")
      SI ( !instTRGGSM )
      ALORS
        trace("Pas d'instance pour TRGGSM !")
        erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "TRGGSM", 0)
        SAUT DISTRI_ERR
      FINSI

#FREE   #G3R3 lot3 Curling Free
      instFREEGSM = i_LireInstanceECC ("FREEGSM")
      SI (!instFREEGSM)
      ALORS
        trace("Pas d'instance pour FREEGSM !")
        erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "FREEGSM", 0)
        SAUT DISTRI_ERR
      FINSI


# correction anomalie du 17/10/2010; QC1535
      erreur = i_LireReqConsTabDist()
      SI (erreur != 0)
      ALORS
        SAUT FIN_DDE_IMSI
      FINSI
      
      SI (i_LireInfoECC( instVDIGSM, 0 ) != 0)
      ALORS
        instIMSI = instVDIGSM
        SAUT FIN_RECHERCHE_ECC
      SINON
        SI (i_LireInfoECC( instOLAGSM, 0 ) != 0)
        ALORS
          instIMSI = instOLAGSM
          SAUT FIN_RECHERCHE_ECC
        SINON
          SI (i_LireInfoECC( instOL2GSM, 0 ) != 0)
          ALORS
            instIMSI = instOL2GSM
            SAUT FIN_RECHERCHE_ECC
          SINON
            SI (i_LireInfoECC( instOL3GSM, 0 ) != 0)
            ALORS
              instIMSI = instOL3GSM
              SAUT FIN_RECHERCHE_ECC
            SINON
              SI (i_LireInfoECC( instOR5GSM, 0 ) != 0)
              ALORS
                instIMSI = instOR5GSM
                SAUT FIN_RECHERCHE_ECC
              SINON
                SI (i_LireInfoECC( instMSFGSM, 0 ) != 0)
                ALORS
                  instIMSI = instMSFGSM
                  SAUT FIN_RECHERCHE_ECC
                SINON
                  SI (i_LireInfoECC(instCOMGSM, 0) != 0)
                  ALORS
                    instIMSI = instCOMGSM
                    SAUT FIN_RECHERCHE_ECC
                  SINON
                    SI (i_LireInfoECC(instFRCGSM, 0) != 0)
                    ALORS
                      instIMSI = instFRCGSM
                      SAUT FIN_RECHERCHE_ECC
                    SINON
                      SI (i_LireInfoECC( instSHMGSM, 0 ) != 0)
                      ALORS
                        instIMSI = instSHMGSM
                        SAUT FIN_RECHERCHE_ECC
                      SINON
                        SI (i_LireInfoECC( instSHPGSM, 0 ) != 0)
                        ALORS
                          instIMSI = instSHPGSM
                          SAUT FIN_RECHERCHE_ECC
                        SINON
                          SI (i_LireInfoECC( instTRGGSM, 0 ) != 0)
                          ALORS
                            instIMSI = instTRGGSM
                            SAUT FIN_RECHERCHE_ECC
                          SINON
                            SI (i_LireInfoECC( instFEGSM, 0 ) != 0)
                            ALORS
                              instIMSI = instFEGSM
                              SAUT FIN_RECHERCHE_ECC
                            SINON
                              instIMSI = -1
                              SAUT FIN_DDE_IMSI
                            FINSI
                          FINSI
                        FINSI
                      FINSI
                    FINSI
                  FINSI
                FINSI
              FINSI
            FINSI
          FINSI
        FINSI
      FINSI

      POINT FIN_RECHERCHE_ECC
      res = i_LireInfoECC( instIMSI, 0 )
      res_IMSI = i_LireImsiInfo( res, 0, 8, ptr_imsi_ascii_tmp )
      SI (res_IMSI == 0)
      ALORS
        puissance = 1
        indice = 7
        PartnerNetworkOperator = 0

        POINT BOUCLE_CODOP1
        InfoComp = i_LireEntierInfo(res, indice, 1) - 0x30
        SI ( InfoComp >= 0 ) && ( InfoComp <= 9 )
        ALORS
          PartnerNetworkOperator = PartnerNetworkOperator + (InfoComp * puissance)
          puissance = puissance * 0x10
          indice = indice - 1
        SINON
          PartnerNetworkOperator = 0xFFFF
          SAUT FIN_DDE_IMSI
        FINSI

        SI indice > 3
        ALORS
          SAUT BOUCLE_CODOP1
        FINSI
      FINSI
    FINSI
  FINSI
FINSI

POINT FIN_DDE_IMSI
instIMSI = -1
GValue = (ClientNetworkOperator * 0x10000) + PartnerNetworkOperator
erreur = i_set_art_field(g_iartout, $Tdpvgsm::GValue, GValue)


#-----------------------------------------------------------------------#
# CRA VPN
# recuperation du champ nbsvcIN (le nombre de valeur de la liste lstSVCIN)
# nbsvcIN donne le nombre des elements du tableau lstSVCIN dont chaque information
# est sur 2 octets donc 2 elements du lstSVCIN sont utilise l information
#-----------------------------------------------------------------------#
#QC958 evol : interrogation table externe "EtatCritere" = Activation
SI (i_strplcmp(i_get_tab_field(Activation,date_cra,"Filtrage_VPN"),"Actif", 0, 5) == 0)
ALORS
  nb_SVCIN = i_get_art_field (g_iartout, $Tdpvgsm::nbsvcIN)
  SI (nb_SVCIN > 0)
  ALORS
    i = 0
    POINT BOUCLE_lstSVCIN
    SI ( i < nb_SVCIN * 2)
    ALORS
      SI ( (i_get_art_fieldtab(g_iartout, $Tdpvgsm::lstSVCIN, i) == 0x00) &&
        (i_get_art_fieldtab(g_iartout, $Tdpvgsm::lstSVCIN, i+1) == 0x0E) )
      ALORS
        CRA_VPN = Oui
        SAUT CRAVPN
      FINSI
      i = i+2
      SAUT BOUCLE_lstSVCIN
    FINSI
  FINSI
FINSI

POINT CRAVPN
# recuperation du SCP du CRA (champ SCPIN)
SI (
  ((i_get_art_fieldtab(g_iartout, $Tdpvgsm::SCPIN, 0) == 0xa) &&
  (i_get_art_fieldtab(g_iartout, $Tdpvgsm::SCPIN, 1) == 0x1) &&
  (i_get_art_fieldtab(g_iartout, $Tdpvgsm::SCPIN, 2) == 0x0) &&
  (i_get_art_fieldtab(g_iartout, $Tdpvgsm::SCPIN, 3) == 0x1) &&
  (i_get_art_fieldtab(g_iartout, $Tdpvgsm::SCPIN, 4) == 0x4) &&
  (i_get_art_fieldtab(g_iartout, $Tdpvgsm::SCPIN, 5) == 0xf) )
  )
ALORS
  CRA_VPN = Oui
FINSI


SI ((type_distri == CRIT_SPEC) || (type_distri == CRIT_INCONNU))
ALORS
  NumOfFilter = 0x01000000 + type_cra * 0x10000

  #-----------------------------------------------------------------------#
  # AIGUILLAGE par type de CRA quelque soit son IMSI
  #-----------------------------------------------------------------------#

  #--------------------------------------------------------------
  #G3R3 lot3 Curling_Free
  #Filtrage des cras IMSI_FREE et (0x00 ou 0x01 ou 0x02 ou 0x90)
  #vers Free
  #--------------------------------------------------------------
#G3R4 lot1 Filtrage CRAs pour EIR
  SI (IMSI_FREE && (type_cra==0x00 || type_cra == 0x02 || type_cra == 0x90))
  ALORS
# 01XX0033
    NumOfFilter = NumOfFilter + 0x0033
#QC983
    SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
    ALORS
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    SINON
      SI Old_Family
      ALORS
        erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
      SINON
        erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
      FINSI
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    FINSI
#/QC983
    res = MiseAuFormat_Stockage_660004265("FREEGSM", instFREEGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    res = MiseAuFormat_Stockage_660004265("I2GGSM", instI2GGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    res = MiseAuFormat_Stockage_660004265("EIRGSM", instEIRGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

#G5R1
    res = MiseAuFormat_Stockage_660004265(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    SI (FlagBI2)
    ALORS
      res = MiseAuFormat_Stockage_660004265("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI


    SAUT FIN_DISTRI
  FINSI

  SI (IMSI_FREE && (type_cra==0x01))
  ALORS
# 01XX0036
    NumOfFilter = NumOfFilter + 0x0036
    trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
#QC983
    SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
    ALORS
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    SINON
      SI Old_Family
      ALORS
        erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
      SINON
        erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
      FINSI
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    FINSI
#/QC983
    res = MiseAuFormat_Stockage_660004265("FREEGSM", instFREEGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    res = MiseAuFormat_Stockage_660004265("I2GGSM", instI2GGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    res = MiseAuFormat_Stockage_660004265(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    SI (FlagBI2)
    ALORS
      res = MiseAuFormat_Stockage_660004265("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI

    SAUT FIN_DISTRI
  FINSI
#/G3R4 lot1

#G3R6 LICA-FULL MVNO OMEA
  SI (IMSI_MVNOFull1 == 1 && (type_cra == 0x00 || type_cra == 0x02 || type_cra == 0x90))
  ALORS

# 01XX0040
    NumOfFilter = NumOfFilter + 0x0040
    SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
    ALORS
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    SINON
      SI Old_Family
      ALORS
        erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
      SINON
        erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
      FINSI
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    FINSI

    res = MiseAuFormat_Stockage_660004265("FULL1GSM",  instFULL1, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    res = MiseAuFormat_Stockage_660004265("I2GGSM", instI2GGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    res = MiseAuFormat_Stockage_660004265("EIRGSM", instEIRGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    res = MiseAuFormat_Stockage_660004265(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    SI (FlagBI2)
    ALORS
      res = MiseAuFormat_Stockage_660004265("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI

    SAUT FIN_DISTRI
  FINSI


  SI (IMSI_MVNOFull1 == 1 && type_cra == 0x01)
  ALORS
# 01XX0041
    NumOfFilter = NumOfFilter + 0x0041
    SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
    ALORS
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    SINON
      SI Old_Family
      ALORS
        erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
      SINON
        erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
      FINSI
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    FINSI

    res = MiseAuFormat_Stockage_660004265("FULL1GSM", instFULL1, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    res = MiseAuFormat_Stockage_660004265("I2GGSM", instI2GGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    res = MiseAuFormat_Stockage_660004265(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    SI (FlagBI2)
    ALORS
      res = MiseAuFormat_Stockage_660004265("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI

    SAUT FIN_DISTRI
  FINSI


  SI (IMSI_MVNOFull2 == 1 && (type_cra == 0x00 || type_cra == 0x02 || type_cra == 0x90))
  ALORS

# 01XX0042
    NumOfFilter = NumOfFilter + 0x0042
    SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
    ALORS
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    SINON
      SI Old_Family
      ALORS
        erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
      SINON
        erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
      FINSI
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    FINSI

    res = MiseAuFormat_Stockage_660004265("FULL2GSM", instFULL2, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    res = MiseAuFormat_Stockage_660004265("I2GGSM", instI2GGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    res = MiseAuFormat_Stockage_660004265("EIRGSM", instEIRGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    res = MiseAuFormat_Stockage_660004265(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    SI (FlagBI2)
    ALORS
      res = MiseAuFormat_Stockage_660004265("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI

    SAUT FIN_DISTRI
  FINSI


  SI (IMSI_MVNOFull2 == 1 && type_cra == 0x01)
  ALORS
# 01XX0043
    NumOfFilter = NumOfFilter + 0x0043
    SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
    ALORS
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    SINON
      SI Old_Family
      ALORS
        erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
      SINON
        erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
      FINSI
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    FINSI
    res = MiseAuFormat_Stockage_660004265("FULL2GSM", instFULL2, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    res = MiseAuFormat_Stockage_660004265("I2GGSM", instI2GGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    res = MiseAuFormat_Stockage_660004265(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    SI (FlagBI2)
    ALORS
      res = MiseAuFormat_Stockage_660004265("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI

    SAUT FIN_DISTRI
  FINSI

#/G3R6 LICA-FULL MVNO OMEA

#------------------------------------------------------
#G3R3 lot3 Curling Free Filtre 0x0032 cra 0x08
#-----------------------------------------------------
  SI (type_cra == 0x08)
  ALORS
    SI (ITI_FREE)
    ALORS
      SI (i_valid_field_n(artout,$Tdpvgsm::local))
      ALORS
        erreur = i_get_art_str(g_iartout, $Tdpvgsm::local, str_local_ascii)
        trace2("__FILE__ __LINE__ str_local_ascii = %s =========",str_local_ascii,"")
        i_get_sub_str(str_local_ascii,0,7,ptr_res)
        i_get_sub_str(ptr_res,-1,-1,ptr_Fin)

        SI (i_strplcmp(ptr_res,"33654",0,5) == 0 && i_strcmp(ptr_Fin,"0") == 0)
        ALORS
# 01XX0032
          NumOfFilter = NumOfFilter + 0x0032
          trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
#QC983
          SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
          ALORS
            erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
          SINON
            SI Old_Family
            ALORS
              erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
            SINON
              erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
            FINSI
            erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
          FINSI
#/QC983
          res = MiseAuFormat_Stockage_660004265("FREEGSM", instFREEGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
          SI (res == STOCKAGE_KO)
          ALORS
            RETOUR STOCKAGE_KO
          FINSI

          res = MiseAuFormat_Stockage_660004265("I2GGSM", instI2GGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
          SI (res == STOCKAGE_KO)
          ALORS
            RETOUR STOCKAGE_KO
          FINSI

          res = MiseAuFormat_Stockage_660004265("EIRGSM", instEIRGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
          SI (res == STOCKAGE_KO)
          ALORS
            RETOUR STOCKAGE_KO
          FINSI

          res = MiseAuFormat_Stockage_660004265(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
          SI (res == STOCKAGE_KO)
          ALORS
            RETOUR STOCKAGE_KO
          FINSI

          SI (FlagBI2)
          ALORS
            res = MiseAuFormat_Stockage_660004265("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
            SI (res == STOCKAGE_KO)
            ALORS
              RETOUR STOCKAGE_KO
            FINSI
          FINSI

        SINON
          SAUT FIN_FREE
        FINSI
        SAUT FIN_DISTRI
      FINSI

    FINSI
  FINSI
  POINT FIN_FREE

#-----------------------------------------------------
#QC853 ajout filtre de protection item Curling Free
#------------------------------------------------------
  SI (IMSI_FREE && (type_cra != 0x00 && type_cra != 0x01 && type_cra != 0x02 && type_cra != 0x90))
  ALORS
    NumOfFilter = NumOfFilter + 0x0034
    trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
#QC983
    SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
    ALORS
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    SINON
      SI Old_Family
      ALORS
        erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
      SINON
        erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
      FINSI
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    FINSI
#/QC983
    res = MiseAuFormat_Stockage_660004265("RJPGSM", instRJPGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    res = MiseAuFormat_Stockage_660004265("I2GGSM", instI2GGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    res = MiseAuFormat_Stockage_660004265("EIRGSM", instEIRGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    res = MiseAuFormat_Stockage_660004265(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    SI (FlagBI2)
    ALORS
      res = MiseAuFormat_Stockage_660004265("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI

    SAUT FIN_DISTRI
  FINSI

  #/G3R3 lot3

#G3R6 LICA-FULL MVNO OMEA

  SI (IMSI_MVNOFull1 == 1 || IMSI_MVNOFull2 == 1 && (type_cra !=  0x00 && type_cra !=  0x01 && type_cra !=  0x02  && type_cra !=  0x90))
  ALORS
#01XX0044

    NumOfFilter = NumOfFilter + 0x0044
    trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

    SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
    ALORS
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    SINON
      SI Old_Family
      ALORS
        erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
      SINON
        erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
      FINSI
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    FINSI

    res = MiseAuFormat_Stockage_660004265("RJPGSM", instRJPGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    res = MiseAuFormat_Stockage_660004265("I2GGSM", instI2GGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    res = MiseAuFormat_Stockage_660004265("EIRGSM", instEIRGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    res = MiseAuFormat_Stockage_660004265(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    SI (FlagBI2)
    ALORS
      res = MiseAuFormat_Stockage_660004265("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI

    SAUT FIN_DISTRI
  FINSI

#/G3R6 LICA-FULL MVNO OMEA


# G5R3 CDR TAS entrant avec renvoi
  SI (i_valid_field_n(g_iartout, $Tdpvgsm::GMSCForwTerm))
  ALORS
    res = i_get_art_field(g_iartout, $Tdpvgsm::GMSCForwTerm)
  SINON
    res = -1
  FINSI
  SI (type_cra == 0x01) && (res == 1)
  ALORS
# 01XX0056
    NumOfFilter = NumOfFilter + 0x0056
    trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

    SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
    ALORS
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    SINON
      SI Old_Family
      ALORS
        erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
      SINON
        erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
      FINSI
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    FINSI

    res = MiseAuFormat_Stockage_660004265("RJPGSM", instRJPGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    res = MiseAuFormat_Stockage_660004265("I2GGSM", instI2GGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    SAUT FIN_DISTRI
  FINSI

# /G5R3 CDR TAS entrant avec renvoi

  #-----------------------------------------------------------------------#
  # type 06
  #-----------------------------------------------------------------------#
  SI (i_valid_field_n(g_iartout, $Tdpvgsm::GMSCForwTerm))
  ALORS
    res = i_get_art_field(g_iartout, $Tdpvgsm::GMSCForwTerm)
  FINSI
  SI (type_cra == 0x06) && (res == 1)
  ALORS
# 01XX0002
    NumOfFilter = NumOfFilter + 0x0002
    trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
#QC983
    SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
    ALORS
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    SINON
      SI Old_Family
      ALORS
        erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
      SINON
        erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
      FINSI
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    FINSI
#/QC983
    res = MiseAuFormat_Stockage_660004265("RJPGSM", instRJPGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

#G5R1
    res = MiseAuFormat_Stockage_660004265(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    SI (FlagBI2)
    ALORS
      res = MiseAuFormat_Stockage_660004265("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI

    res = MiseAuFormat_Stockage_660004265("I2GGSM", instI2GGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    SAUT FIN_DISTRI
  FINSI

  #-----------------------------------------------------------------------#
  # type 08
  #-----------------------------------------------------------------------#
  SI (type_cra == 0x08)
  ALORS

# 01XX0003
    NumOfFilter = NumOfFilter + 0x0003
    trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
#QC983
    SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
    ALORS
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    SINON
      SI Old_Family
      ALORS
        erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
      SINON
        erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
      FINSI
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    FINSI
#/QC983
    res = MiseAuFormat_Stockage_660004265("RJPGSM", instRJPGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    res = MiseAuFormat_Stockage_660004265("I2GGSM", instI2GGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    res = MiseAuFormat_Stockage_660004265("EIRGSM", instEIRGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    #G5R1
    res = MiseAuFormat_Stockage_660004265(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    SI (FlagBI2)
    ALORS
      res = MiseAuFormat_Stockage_660004265("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI

    SAUT FIN_DISTRI
  FINSI

#G3R8 lot1  BtelUSMS console
  #----------------------
  # type 10
  #---------------------

  SI (type_cra == 0x10)
  ALORS
    erreur = i_format_str2(ptr_ECM,"%s%s","ECN_",str_idpart_ascii)
    SI ( table_exp_reg_660004265(ptr_ECM, Dise_Ent_ShortID, date_cra) == 1)
    ALORS
#01xx0047
      NumOfFilter = NumOfFilter + 0x0047
      trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
#QC983
      SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
      ALORS
        erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
      SINON
        SI Old_Family
        ALORS
          erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
        SINON
          erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
        FINSI
        erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
      FINSI

      res = MiseAuFormat_Stockage_660004265("RJPGSM", instRJPGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI

#G5R1
      res = MiseAuFormat_Stockage_660004265(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI

      SI (FlagBI2)
      ALORS
        res = MiseAuFormat_Stockage_660004265("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI
      FINSI

      SAUT FIN_DISTRI

    FINSI

  FINSI
#Fin G3R8 lot1  BtelUSMS console


  #-----------------------------------------------------------------------#
  # type 10
  #-----------------------------------------------------------------------#
  SI (type_cra == 0x10)
  ALORS
    SI ( table_exp_reg_660004265(str_idpart_ascii, Dise_Ent_ShortID, date_cra) == 1)
    ALORS
      Dise_Ent_ShortID_VRAI = 1
    SINON
      Dise_Ent_ShortID_VRAI = 0
    FINSI
#G2R6 QC559 SMS_SURTAXE
# G2R6 QC632 (6 digits equivalent a 3 octets pour idpart)
    SI (PRESENCE_IDPART == 1)
    ALORS
      res = i_get_art_field(g_iartout, $Tdpvgsm::idpart -1)
      erreur = i_format_str2(ptr_SMS,"%s%s","SMS_MT_",str_idpart_ascii)
#QC603 suppression car calcul realise en debut de la fonction aiguillage2 ##  IND_EFF = i_get_art_field(g_iartout, $Tdpvgsm::indeff)
      pt_indeff_hex=i_get_art_fieldptr( g_iartout, $Tdpvgsm::indeff)
      erreur=i_ConvertirChaine(pt_indeff_hex,1,1,pt_indeff_ascii,1,3)
      SI (
        (res > 3 && i_get_tab_field(EFF_I2G, date_cra, pt_indeff_ascii)!= g_inull) ||
        (res <= 3 && i_get_tab_field(EFF_I2G, date_cra, pt_indeff_ascii)!= g_inull && table_exp_reg_660004265(ptr_SMS, "SMS_SURTAXE" , date_cra) == 1)
        )
      ALORS
        SMS_SURTAXE = 1
      SINON
        SMS_SURTAXE = 0
      FINSI
    FINSI
# type 10 : (Tous les cas 01XX0004 et 01XX0005 si RechercherTableExpReg(Dise_Ent_ShortID,ID_PART) = faux => Rejet)
    SI (Dise_Ent_ShortID_VRAI == 0)
    ALORS
      res = MiseAuFormat_Stockage_660004265("RJPGSM", instRJPGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI


      # type=10
      # G5R1
      res = MiseAuFormat_Stockage_660004265(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI

      SI (FlagBI2)
      ALORS
        res = MiseAuFormat_Stockage_660004265("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI
      FINSI

#G3R1 lot3 : nouveau filtrage ARTIST (et RechercherClefTable (MSP_ARTIST_DISE , REMOBID_PART) = faux)
      i_strcpy(pt_MSP,"")
      erreur=i_format_str2(pt_MSP,"%s%s","REMOB",str_idpart_ascii)
      SI ( (i_get_art_fieldlength(g_iartout, $Tdpvgsm::idpart) < 11 || i_get_art_fieldlength(g_iartout, $Tdpvgsm::MSISDN) < 11) && i_strcmp(i_get_tab_field("MSP_ARTIST_DISE",date_cra,pt_MSP),"Tous") != 0 )
      ALORS
# 01XX0004
        NumOfFilter = NumOfFilter + 0x0004
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
#QC983
        SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
        ALORS
          erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
        SINON
          SI Old_Family
          ALORS
            erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
          SINON
            erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
          FINSI
          erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
        FINSI
#/QC983
        res = MiseAuFormat_Stockage_660004265("ARTGSM", instARTGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI
      SINON
# 01XX0005
        NumOfFilter = NumOfFilter + 0x0005
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
#QC983
        SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
        ALORS
          erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
        SINON
          SI Old_Family
          ALORS
            erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
          SINON
            erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
          FINSI
          erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
        FINSI
#/QC983
      FINSI

      res = MiseAuFormat_Stockage_660004265("IRIGSM", instIRIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI

#G2R6 SMS_SURTAXE
      SI (SMS_SURTAXE == 1)
      ALORS
        res = MiseAuFormat_Stockage_660004265("I2GGSM", instI2GGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI

      FINSI
    FINSI


# type 10 : 2eme cas
    SI ( (Dise_Ent_ShortID_VRAI == 1) && (IND_EFF != 0x00) )
    ALORS
# 01XX0006
      NumOfFilter = NumOfFilter + 0x0006
      trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
#QC983
      SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
      ALORS
        erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
      SINON
        SI Old_Family
        ALORS
          erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
        SINON
          erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
        FINSI
        erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
      FINSI
#/QC983
      res = MiseAuFormat_Stockage_660004265("NVDGSM", instNVDGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI

      #type=10
      #G5R1
      res = MiseAuFormat_Stockage_660004265(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI

      SI (FlagBI2)
      ALORS
        res = MiseAuFormat_Stockage_660004265("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI
      FINSI

      res = MiseAuFormat_Stockage_660004265("IRIGSM", instIRIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI

#G2R6 SMS_SURTAXE
      SI (SMS_SURTAXE == 1)
      ALORS
        res = MiseAuFormat_Stockage_660004265("I2GGSM", instI2GGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI
      FINSI
    FINSI


# type 10 : 3eme cas
    SI ( (Dise_Ent_ShortID_VRAI == 1) && (IND_EFF == 0x00) )
    ALORS
# 01XX0007
      NumOfFilter = NumOfFilter + 0x0007
      trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
#QC983
      SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
      ALORS
        erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
      SINON
        SI Old_Family
        ALORS
          erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
        SINON
          erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
        FINSI
        erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
      FINSI
#/QC983
      res = MiseAuFormat_Stockage_660004265("MSFGSM", instMSFGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI

      #type=10
      #G5R1
      res = MiseAuFormat_Stockage_660004265(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI

      SI (FlagBI2)
      ALORS
        res = MiseAuFormat_Stockage_660004265("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI
      FINSI

      res = MiseAuFormat_Stockage_660004265("IRIGSM", instIRIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI

#G2R6 SMS_SURTAXE
      SI (SMS_SURTAXE == 1)
      ALORS
        res = MiseAuFormat_Stockage_660004265("I2GGSM", instI2GGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI
      FINSI

    FINSI
    SAUT FIN_DISTRI
  FINSI


  #-----------------------------------------------------------------------#
  # type 11 avec idpart appartenant a la liste des shortid
  #-----------------------------------------------------------------------#
  SI ((type_cra == 0x11) && (i_get_art_field(g_iartout, $Tdpvgsm::indeff) == 0x04))
  ALORS
    #shortid, taille <5 digit
    taille_idpart = i_get_art_fieldlength(g_iartout, $Tdpvgsm::idpart)
    SI ((taille_idpart > 0) && (taille_idpart < 6))
    ALORS
      trace2("str_idpart_ascii = <%s>", str_idpart_ascii, "")
      SI (str_idpart_ascii != g_inull)
      ALORS
        trace2("str_idpart ASCII <%s>", str_idpart_ascii, "")

        SI (i_get_tab_field(SMS_MO_STATUS4, date_cra, str_idpart_ascii) != g_inull)
        ALORS
# 01XX0008
          NumOfFilter = NumOfFilter + 0x0008
          trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
#QC983
          SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
          ALORS
            erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
          SINON
            SI Old_Family
            ALORS
              erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
            SINON
              erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
            FINSI
            erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
          FINSI
#/QC983
          res = MiseAuFormat_Stockage_660004265("RJPGSM", instRJPGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
          SI (res == STOCKAGE_KO)
          ALORS
            RETOUR STOCKAGE_KO
          FINSI
#G5R1
          res = MiseAuFormat_Stockage_660004265(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
          SI (res == STOCKAGE_KO)
          ALORS
            RETOUR STOCKAGE_KO
          FINSI

          SI (FlagBI2)
          ALORS
            res = MiseAuFormat_Stockage_660004265("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
            SI (res == STOCKAGE_KO)
            ALORS
              RETOUR STOCKAGE_KO
            FINSI
          FINSI

          SAUT FIN_DISTRI
        FINSI
      SINON
        SAUT DISTRI_ERR
      FINSI
    FINSI
  FINSI
# QC767 Demontage de l'ECC Platine PLTGSM

#G3R8 lot1  BtelUSMS console

  SI (type_cra == 0x11)
  ALORS
    OnLineFlag  = i_get_art_field(g_iartout, $Tdpvgsm::onlinePurUsFlag)
    SI (OnLineFlag == 0x50 || OnLineFlag == 0x51 || OnLineFlag == 0x52)
    ALORS
# 01xx0048
      NumOfFilter = NumOfFilter + 0x0048
      trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
      #QC983
      SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
      ALORS
        erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
      SINON
        SI Old_Family
        ALORS
          erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
        SINON
          erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
        FINSI
        erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
      FINSI
#/QC983
      res = MiseAuFormat_Stockage_660004265("RJPGSM", instRJPGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI

#G5R1
      res = MiseAuFormat_Stockage_660004265(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI

      SI (FlagBI2)
      ALORS
        res = MiseAuFormat_Stockage_660004265("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI
      FINSI

      SAUT FIN_DISTRI
    FINSI
  FINSI

#/G3R8 lot1 BtelUSMS console

  #-----------------------------------------------------------------------#
  # type 31
  #-----------------------------------------------------------------------#
  SI (type_cra == 0x31)
  ALORS
# 01XX000B
    NumOfFilter = NumOfFilter + 0x000B
    trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
#QC983
    SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
    ALORS
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    SINON
      SI Old_Family
      ALORS
        erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
      SINON
        erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
      FINSI
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    FINSI
#/QC983
    res = MiseAuFormat_Stockage_660004265("RJPGSM", instRJPGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI
#G3R1 lot3 : nouveau filtrage ARTIST

    res = MiseAuFormat_Stockage_660004265("I2GGSM", instI2GGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    res = MiseAuFormat_Stockage_660004265("IRIGSM", instIRIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

#G5R1
    res = MiseAuFormat_Stockage_660004265(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    SI (FlagBI2)
    ALORS
      res = MiseAuFormat_Stockage_660004265("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI

    SAUT FIN_DISTRI
  FINSI

  #-----------------------------------------------------------------------#
  # Type MMS 36
  #-----------------------------------------------------------------------#
  SI (type_cra == 0x36)
  ALORS
# 01XX000C
    NumOfFilter = NumOfFilter + 0x000C
    trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
#QC983
    SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
    ALORS
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    SINON
      SI Old_Family
      ALORS
        erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
      SINON
        erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
      FINSI
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    FINSI
#/QC983
    res = MiseAuFormat_Stockage_660004265("RJPGSM", instRJPGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

#G3R1 lot3 : nouveau filtrage ARTIST
    i_strcpy(pt_MSP,"")
    erreur=i_format_str2(pt_MSP,"%s%s","REMOB",str_idpart_ascii)
    SI ( i_strcmp(i_get_tab_field("MSP_ARTIST_DISE",date_cra,pt_MSP),"Tous") != 0 )
    ALORS
      res = MiseAuFormat_Stockage_660004265("ARTGSM", instARTGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI

    res = MiseAuFormat_Stockage_660004265("I2GGSM", instI2GGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    res = MiseAuFormat_Stockage_660004265("EIRGSM", instEIRGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

#G5R1
    res = MiseAuFormat_Stockage_660004265(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    SI (FlagBI2)
    ALORS
      res = MiseAuFormat_Stockage_660004265("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI

    SAUT FIN_DISTRI
  FINSI


  #-----------------------------------------------------------------------#
  # Filtrage des CRA 32, 33, 34, 35 et 37
  #-----------------------------------------------------------------------#

  SI ((type_cra == 0x32) || (type_cra == 0x33) || (type_cra == 0x34) ||
    (type_cra == 0x35) || (type_cra == 0x37))
  ALORS
# 01XX000D
    NumOfFilter = NumOfFilter + 0x000D
    trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
#QC983
    SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
    ALORS
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    SINON
      SI Old_Family
      ALORS
        erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
      SINON
        erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
      FINSI
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    FINSI
#/QC983
    res = MiseAuFormat_Stockage_660004265("RJPGSM", instRJPGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    res = MiseAuFormat_Stockage_660004265("I2GGSM", instI2GGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    res = MiseAuFormat_Stockage_660004265("EIRGSM", instEIRGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    #G5R1
    res = MiseAuFormat_Stockage_660004265(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    SI (FlagBI2)
    ALORS
      res = MiseAuFormat_Stockage_660004265("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI

    SAUT FIN_DISTRI
  FINSI

#---------------------------------------------------------------
# G5R3lot1 joynV2 RCS-e Interco: OF -> TIERS
# Filtre pour les cras PRIMS RCSe Type cra = 0xB1
#---------------------------------------------------------------
  SI (type_cra == 0xB1)
  ALORS

    trace("<<<__LINE__<<<__FILE__<< joynV2 - OF -> TIERS")
    SI (i_valid_field_n(g_iartout, $Tdpvgsm::GMSCForwTerm))
    ALORS
      res = i_get_art_field(g_iartout, $Tdpvgsm::GMSCForwTerm)
    SINON
      res = -1
    FINSI
    IND_EFF = i_get_art_field(g_iartout, $Tdpvgsm::indeff)

    SI ( res == 0x01 && IND_EFF == 0x00)
    ALORS
      optiers = 0
      SI (i_valid_field_n(g_iartout, $Tdpvgsm::MailIdpart))
      ALORS
        erreur = i_get_art_str(g_iartout, $Tdpvgsm::MailIdpart, pt_optiers)
        # QC1500 recherche DOM_OPE_TIERS dans MailIdpart apres @
        position = RECHERCHE_CARACTERE_660004265(pt_optiers,"@")
        SI (position >= 0)
        ALORS
          i_get_sub_str(pt_optiers,position + 1,-1, pt_optiers)
          trace2("<<<__LINE__<<<__FILE__<< joynV2 - OF -> TIERS : pt_optiers (MailIdpart pt_optiers apres @) = <%s>", pt_optiers, "")
          SI ( table_exp_reg_660004265(pt_optiers, DOM_OPE_TIERS , date_cra) == 1)
          ALORS
            optiers = 1
          FINSI
        FINSI
        trace1("<<<__LINE__<<<__FILE__<< joynV2 - OF -> TIERS : optiers = <%d>", optiers)
      FINSI
    FINSI

    SI (optiers == 1)
    ALORS
      # 01XX0054
      NumOfFilter = NumOfFilter + 0x0054
      trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

      SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
      ALORS
        erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
      SINON
        SI Old_Family
        ALORS
          erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
        SINON
          erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
        FINSI
        erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
      FINSI

      res = MiseAuFormat_Stockage_660004265("RJPGSM", instRJPGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI

      res = MiseAuFormat_Stockage_660004265("I2GGSM", instI2GGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI

      res = MiseAuFormat_Stockage_660004265(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI

      SI (FlagBI2)
      ALORS
        res = MiseAuFormat_Stockage_660004265("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI
      FINSI

      res = MiseAuFormat_Stockage_660004265("IRIGSM", instIRIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI

      SAUT FIN_DISTRI
    FINSI
  FINSI

#---------------------------------------------------------------
# G5R3lot1 joynV2 RCS-e Interco: TIERS -> OF
# Filtre pour les cras PRIMS RCSe Type cra = 0xB2
#---------------------------------------------------------------
  SI (type_cra == 0xB2)
  ALORS

    trace("<<<__LINE__<<<__FILE__<< joynV2 - TIERS -> OF")
    SI (i_valid_field_n(g_iartout, $Tdpvgsm::GMSCForwTerm))
    ALORS
      res = i_get_art_field(g_iartout, $Tdpvgsm::GMSCForwTerm)
    SINON
      res = -1
    FINSI
    IND_EFF = i_get_art_field(g_iartout, $Tdpvgsm::indeff)

    SI ( res == 0x01 && IND_EFF == 0x00)
    ALORS
      optiers = 0
      SI (i_valid_field_n(g_iartout, $Tdpvgsm::OriginatingIOI))
      ALORS
        erreur = i_get_art_str(g_iartout, $Tdpvgsm::OriginatingIOI, pt_optiers)
        SI ( table_exp_reg_660004265(pt_optiers, DOM_OPE_TIERS , date_cra) == 1)
        ALORS
          optiers = 1
        FINSI
        trace2("<<<__LINE__<<<__FILE__<< joynV2 - TIERS -> OF : pt_optiers (OriginatingIOI) = <%s>", pt_optiers, "")
        trace1("<<<__LINE__<<<__FILE__<< joynV2 - TIERS -> OF : optiers = <%d>", optiers)
      FINSI
    FINSI

    SI (optiers == 1)
    ALORS
      # 01XX0055
      NumOfFilter = NumOfFilter + 0x0055
      trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

      SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
      ALORS
        erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
      SINON
        SI Old_Family
        ALORS
          erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
        SINON
          erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
        FINSI
        erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
      FINSI

      res = MiseAuFormat_Stockage_660004265("RJPGSM", instRJPGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI

      res = MiseAuFormat_Stockage_660004265("I2GGSM", instI2GGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI

      res = MiseAuFormat_Stockage_660004265(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI

      SI (FlagBI2)
      ALORS
        res = MiseAuFormat_Stockage_660004265("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI
      FINSI

      res = MiseAuFormat_Stockage_660004265("IRIGSM", instIRIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI

      SAUT FIN_DISTRI
    FINSI
  FINSI

#---------------------------------------------------------------
#PKG3R8lot1 Filtre pour les cras PRIMS RCSe Type cra = 0xB1 ou 0xB2 1er cas
#---------------------------------------------------------------
#QC1133

  SI (type_cra == 0xB1) || (type_cra == 0xB2)
  ALORS

    SI (i_valid_field_n(g_iartout, $Tdpvgsm::GMSCForwTerm))
    ALORS
      res = i_get_art_field(g_iartout, $Tdpvgsm::GMSCForwTerm)
    FINSI
    IND_EFF = i_get_art_field(g_iartout, $Tdpvgsm::indeff)

    SI ( res == 0x01 && IND_EFF == 0x00)
    ALORS
      # 01XX0045
      NumOfFilter = NumOfFilter + 0x0045
      trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

      SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
      ALORS
        erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
      SINON
        SI Old_Family
        ALORS
          erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
        SINON
          erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
        FINSI
        erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
      FINSI

      res = MiseAuFormat_Stockage_660004265("RJPGSM", instRJPGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
#G5R1
      res = MiseAuFormat_Stockage_660004265(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI

      SI (FlagBI2)
      ALORS
        res = MiseAuFormat_Stockage_660004265("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI
      FINSI

      res = MiseAuFormat_Stockage_660004265("IRIGSM", instIRIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI

      SAUT FIN_DISTRI
    FINSI
  FINSI
#---------------------------------------------------------------
#PKG3R8lot1 Filtre pour les cras PRIMS RCSe Type cra = 0xB1 ou 0xB2 2cas
#---------------------------------------------------------------
#QC1133
  SI (type_cra == 0xB1) || (type_cra == 0xB2)
  ALORS
    SI (i_valid_field_n(g_iartout, $Tdpvgsm::GMSCForwTerm))
    ALORS
      res = i_get_art_field(g_iartout, $Tdpvgsm::GMSCForwTerm)
    FINSI

    SI (res == 0x01)
    ALORS
# 01XX0046
      NumOfFilter = NumOfFilter + 0x0046
      trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
      SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
      ALORS
        erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
      SINON
        SI Old_Family
        ALORS
          erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
        SINON
          erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
        FINSI
        erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
      FINSI

      res = MiseAuFormat_Stockage_660004265("RJPGSM", instRJPGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI

      #G5R1
      res = MiseAuFormat_Stockage_660004265(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI

      SI (FlagBI2)
      ALORS
        res = MiseAuFormat_Stockage_660004265("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI
      FINSI

      SAUT FIN_DISTRI
    FINSI
  FINSI


#/QC1133 pkG3R8lot1   Filtre pour les cras PRIMS RCSe


  #-----------------------------------------------------------------------#
  # G2R3 : filtrage des CRAs MIPC
  #-----------------------------------------------------------------------#

  SI (type_cra == 0xB1) || (type_cra == 0xB2)
  ALORS
# 01XX000E
    NumOfFilter = NumOfFilter + 0x000E
    trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
#QC983
    SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
    ALORS
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    SINON
      SI Old_Family
      ALORS
        erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
      SINON
        erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
      FINSI
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    FINSI
#/QC983
    res = MiseAuFormat_Stockage_660004265("RJPGSM", instRJPGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

#G5R1
    res = MiseAuFormat_Stockage_660004265(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    SI (FlagBI2)
    ALORS
      res = MiseAuFormat_Stockage_660004265("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI

    SAUT FIN_DISTRI
  FINSI


#G3R8 lot1 BtelU Sonnerie Simultan?e

  SI (type_cra == 0x02 && i_get_art_field(g_iartout, $Tdpvgsm::onlinePurUsFlag) == 0x55)
  ALORS

# 01XX0049
    NumOfFilter = NumOfFilter + 0x0049
    trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
#QC983
    SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
    ALORS
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    SINON
      SI Old_Family
      ALORS
        erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
      SINON
        erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
      FINSI

      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    FINSI
#/QC983
    res = MiseAuFormat_Stockage_660004265("RJPGSM", instRJPGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

#G5R1
    res = MiseAuFormat_Stockage_660004265(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    SI (FlagBI2)
    ALORS
      res = MiseAuFormat_Stockage_660004265("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI

    SAUT FIN_DISTRI
  FINSI


# QC1015
#G3R5 lot2  BtelU ; filtre 01XX0039
  SI (type_cra == 0x02 && i_get_art_field(g_iartout, $Tdpvgsm::onlinePurUsFlag) == 0x60)
  ALORS
# 01XX0039
    NumOfFilter = NumOfFilter + 0x0039
    trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
#QC983
    SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
    ALORS
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    SINON
      SI Old_Family
      ALORS
        erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
      SINON
        erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
      FINSI
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    FINSI
#/QC983
    res = MiseAuFormat_Stockage_660004265("RJPGSM", instRJPGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

#G5R1
    res = MiseAuFormat_Stockage_660004265(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    SI (FlagBI2)
    ALORS
      res = MiseAuFormat_Stockage_660004265("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI

    SAUT FIN_DISTRI
  FINSI
#/Fin G3R5 lot2
#/QC1015

  #-----------------------------------------------------------------------#
  # type 00  : V4t99.1 = 0x01 ou 0x02
  #-----------------------------------------------------------------------#
  SI (type_cra == 0x00) && ( ( GRETA_TAG == 0x01) || ( GRETA_TAG == 0x02) )
  ALORS
# 01XX0011
    NumOfFilter = NumOfFilter + 0x0011
    trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
#QC983
    SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
    ALORS
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    SINON
      SI Old_Family
      ALORS
        erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
      SINON
        erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
      FINSI
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    FINSI
#/QC983
    res = MiseAuFormat_Stockage_660004265("RJPGSM", instRJPGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    SAUT FIN_DISTRI
  FINSI

  #-----------------------------------------------------------------------#
  # IMSI_VPN1 (DISE + I2G, EIR, Symphonie, SCT, IRIS )
  #-----------------------------------------------------------------------#

  SI (IMSI_VPN1 == Oui)
  ALORS

# G2R6 lot3 Service AVME pour MIPC : impact alimentation CRA INCC
    SI (type_cra == 0x00)
    ALORS
#QC552 idemet a la place de local
      i_strcpy(ptr_valINCC,i_get_tab_field("VariableContexte",date_cra,"AX_IDEMET_INCC"))
      posINCC = RECHERCHE_CARACTERE_660004265(ptr_valINCC,"F")
      SI posINCC < 0
      ALORS
        posINCC = posINCC * (-1)
      FINSI
      i_get_sub_str(ptr_valINCC,0,posINCC - 1,ptr_valINCC)
      SI (i_strcmp(ptr_valINCC,str_idemet_ascii) == 0)
#/QC552
      ALORS
        erreur = i_format_str2(ptr_advme_id,"%s%s","AVME_",str_idpart_ascii)
        SI (i_get_tab_field("IDPART", date_cra, ptr_advme_id) != g_inull)
        ALORS
# 01XX0012
          NumOfFilter = NumOfFilter + 0x0012
          trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
#QC983
          SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
          ALORS
            erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
          SINON
            SI Old_Family
            ALORS
              erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
            SINON
              erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
            FINSI
            erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
          FINSI
#/QC983
          res = MiseAuFormat_Stockage_660004265("RJPGSM", instRJPGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
          SI (res == STOCKAGE_KO)
          ALORS
            RETOUR STOCKAGE_KO
          FINSI

          SAUT MADN

        FINSI
      FINSI
    FINSI
# /G2R6 lot3 Service AVME pour MIPC : impact alimentation CRA INCC

#G5R1
#                                                                     0     2    4    6    8    10 , 012345678910
    SI (i_strplcmp(pt_CodeTarifSVA, "G", 0, 1) == 0 && i_strplcmp(ptr_CetS_GRATUIT, "0", C_FiltreCetS_VPN, 1) == 0)
    ALORS
# 01XX0053
      NumOfFilter = NumOfFilter + 0x0053
      trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

      SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
      ALORS
        erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
      SINON
        SI Old_Family
        ALORS
          erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
        SINON
          erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
        FINSI
        erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
      FINSI

      res = MiseAuFormat_Stockage_660004265("RJPGSM", instRJPGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
      SAUT MADN
    FINSI

    SI (type_cra == 0x02 || type_cra == 0x06)
    ALORS
      SI (i_valid_field_n(artout, $Tdpvgsm::local))
      ALORS
        erreur = i_get_art_str(g_iartout, $Tdpvgsm::local, str_local_ascii)
        erreur = i_format_str2(str_MADN,"%s%s","MADN_",str_local_ascii)
        SI ( table_exp_reg_660004265(str_MADN, FILTRE_DISE_LOC , date_cra) == 1)
        ALORS
# 01XX0010
          NumOfFilter = NumOfFilter + 0x0010
          trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
#QC983
          SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
          ALORS
            erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
          SINON
            SI Old_Family
            ALORS
              erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
            SINON
              erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
            FINSI
            erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
          FINSI
#/QC983
          res = MiseAuFormat_Stockage_660004265("NVDGSM", instNVDGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
          SI (res == STOCKAGE_KO)
          ALORS
            RETOUR STOCKAGE_KO
          FINSI

          SAUT MADN

        FINSI
      FINSI
    FINSI

#G3R9 lot2 COME
    SI (type_cra == 0x02 || type_cra == 0x06)
    ALORS
      SI (i_strcmp(str_local_ascii,g_inull) != 0)
      ALORS
        erreur = i_format_str2(str_RVMV,"%s%s","RVMV_",str_local_ascii)
        SI ( table_exp_reg_660004265(str_RVMV, FILTRE_DISE_LOC , date_cra) == 1)
        ALORS
# 01XX0037
          NumOfFilter = NumOfFilter + 0x0037
          trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
#QC983
          SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
          ALORS
            erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
          SINON
            SI Old_Family
            ALORS
              erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
            SINON
              erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
            FINSI
            erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
          FINSI
#/QC983

          i_strcpy(ptr_valeurDATE, i_get_tab_field("VariableContexte", date_cra, "DATE_FRCOME"))
          i_get_sub_str(ptr_valeurDATE,2,-1,ptr_date_res)
          erreur = i_set_art_str (g_iartout7,$Conv_URS::DATE,ptr_date_res)
          date_table = i_get_art_field(g_iartout7, $Conv_URS::DATEN)

          SI (date_cra < date_table)
          ALORS
            res = MiseAuFormat_Stockage_660004265("NVDGSM", instNVDGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
            SI (res == STOCKAGE_KO)
            ALORS
              RETOUR STOCKAGE_KO
            FINSI
          SINON
            res = MiseAuFormat_Stockage_660004265("NVCGSM", instNVCGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
            SI (res == STOCKAGE_KO)
            ALORS
              RETOUR STOCKAGE_KO
            FINSI
          FINSI
          SAUT MADN
        FINSI
      FINSI
    FINSI
#\COME
#G3R3 lot2 COME
    SI (type_cra == 0x00)
    ALORS
      SI (i_strcmp(str_idpart_ascii,g_inull) != 0)
      ALORS
        erreur = i_format_str2(str_RVMV,"%s%s","RVMV_",str_idpart_ascii)
        SI ( table_exp_reg_660004265(str_RVMV, FILTRE_DISE_LOC , date_cra) == 1)
        ALORS
# 01XX0038
          NumOfFilter = NumOfFilter + 0x0038
          trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
#QC983
          SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
          ALORS
            erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
          SINON
            SI Old_Family
            ALORS
              erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
            SINON
              erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
            FINSI
            erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
          FINSI
          i_strcpy(ptr_valeurDATE, i_get_tab_field("VariableContexte", date_cra, "DATE_FRCOME"))
          i_get_sub_str(ptr_valeurDATE,2,-1,ptr_date_res)
          erreur = i_set_art_str (g_iartout7,$Conv_URS::DATE,ptr_date_res)
          date_table = i_get_art_field(g_iartout7, $Conv_URS::DATEN)

          SI (date_cra < date_table)
          ALORS
            res = MiseAuFormat_Stockage_660004265("NVDGSM", instNVDGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
            SI (res == STOCKAGE_KO)
            ALORS
              RETOUR STOCKAGE_KO
            FINSI
          SINON
            res = MiseAuFormat_Stockage_660004265("NVCGSM", instNVCGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
            SI (res == STOCKAGE_KO)
            ALORS
              RETOUR STOCKAGE_KO
            FINSI
          FINSI
          SAUT MADN
        FINSI
      FINSI
    FINSI
#\G3R9 lot2 COME
#\G3R4 lot3 Msg Accueil

#G3R9 lot3 COME Tous cras

# 01XX0013
    NumOfFilter = NumOfFilter + 0x0013
    trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
#QC983
    SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
    ALORS
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    SINON
      SI Old_Family
      ALORS
        erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
      SINON
        erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
      FINSI
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    FINSI
#/QC983
    i_strcpy(ptr_valeurDATE, i_get_tab_field("VariableContexte", date_cra, "DATE_FRCOME"))
    i_get_sub_str(ptr_valeurDATE,2,-1,ptr_date_res)
    erreur = i_set_art_str (g_iartout7,$Conv_URS::DATE,ptr_date_res)
    date_table = i_get_art_field(g_iartout7, $Conv_URS::DATEN)
    SI (date_cra < date_table)
    ALORS
      res = MiseAuFormat_Stockage_660004265("MSFGSM", instMSFGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    SINON
      i_strcpy(ptr_valeurDATE, i_get_tab_field("VariableContexte", date_cra, "DATE_COMEVPN1"))
      i_get_sub_str(ptr_valeurDATE,2,-1,ptr_date_res)
      erreur = i_set_art_str (g_iartout7,$Conv_URS::DATE,ptr_date_res)
      date_table = i_get_art_field(g_iartout7, $Conv_URS::DATEN)
      SI (date_cra < date_table)
      ALORS
        res = MiseAuFormat_Stockage_660004265("FRCGSM", instFRCGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI
      SINON
        res = MiseAuFormat_Stockage_660004265("COMGSM", instCOMGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI
      FINSI
      SAUT MADN
    FINSI
#/COME
    POINT MADN

    #G3R4 lot1 Filtrage CRAs pour EIR --------------------------------
    SI ( type_cra != 0x01)
    ALORS
      res = MiseAuFormat_Stockage_660004265("EIRGSM", instEIRGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI
    #\G3R4 lot1 Filtrage CRAs pour EIR --------------------------------

    res = MiseAuFormat_Stockage_660004265("I2GGSM", instI2GGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

# G5R1
    res = MiseAuFormat_Stockage_660004265(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    SI (FlagBI2)
    ALORS
      res = MiseAuFormat_Stockage_660004265("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI

    SAUT FIN_DISTRI
  FINSI

#debut G1R8 FFMv3 pour NVD et I2G

#-----------------------------------------------------------------------#
# 16)  IMSI_TPE et Amount=0 et GASCII4=W et (occurenceNb=Nb_CS=1 ou
#(Nb_CS=2 et GASCII9=W) ou (Nb_CS=3 et GASCII9=W et GASCII14=W))
# :(NVD - I2G)
#-----------------------------------------------------------------------#
# QC 134
  SI ( (IMSI_TPE == Oui) && ((type_cra == 0xA0) || (type_cra == 0x0F)) )
  ALORS
    Nb_CS = i_get_art_field(g_iartout, $Tdpvgsm::occurenceNb)
    erreur=i_get_art_str(g_iartout, $Tdpvgsm::GASCII, ptr_GASCII)
    i_get_sub_str(ptr_GASCII, 3, 3, ptr_GASCII4)
    i_get_sub_str(ptr_GASCII, 8, 8, ptr_GASCII9)
    i_get_sub_str(ptr_GASCII, 13, 13,ptr_GASCII14)
    erreur=i_get_art_str(g_iartout, $Tdpvgsm::Amount, ptr_Amount)
    SI ( (i_strcmp(ptr_Amount,"000000000000") == 0) && (i_strcmp(ptr_GASCII4, "W") != 0 ) )
    ALORS
      SI (    (Nb_CS == 1)
        || ((Nb_CS == 2) && (i_strcmp(ptr_GASCII9, "W")!=0)  )
        || ((Nb_CS == 3) && ((i_strcmp(ptr_GASCII9, "W")!=0) && (i_strcmp(ptr_GASCII14, "W")!=0)) )  )
      ALORS
# 01XX0015
        NumOfFilter = NumOfFilter + 0x0015
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

#QC983
        SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
        ALORS
          erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
        SINON
          SI Old_Family
          ALORS
            erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
          SINON
            erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
          FINSI
          erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
        FINSI
#/QC983

#G3R9 lot2 COME
        i_strcpy(ptr_valeurDATE, i_get_tab_field("VariableContexte", date_cra, "DATE_FRCOME"))
        i_get_sub_str(ptr_valeurDATE,2,-1,ptr_date_res)
        erreur = i_set_art_str (g_iartout7,$Conv_URS::DATE,ptr_date_res)
        date_table = i_get_art_field(g_iartout7, $Conv_URS::DATEN)
        SI (date_cra < date_table)
        ALORS
          res = MiseAuFormat_Stockage_660004265("NVDGSM", instNVDGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
          SI (res == STOCKAGE_KO)
          ALORS
            RETOUR STOCKAGE_KO
          FINSI
        SINON
          res = MiseAuFormat_Stockage_660004265("NVCGSM", instNVCGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
          SI (res == STOCKAGE_KO)
          ALORS
            RETOUR STOCKAGE_KO
          FINSI
        FINSI
#/G3R9 lot2 COME
        res = MiseAuFormat_Stockage_660004265("I2GGSM", instI2GGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI
        SAUT FIN_DISTRI
      FINSI
    FINSI
  FINSI
#fin G1R8 FFMv3

#G1R8 evol deplassement bloc
#-----------------------------------------------------------------------#
# 17)  type=A0 et Amount=0 et GASCII4=W et (occurenceNb=Nb_CS=1 ou
#(Nb_CS=2 et GASCII9=W) ou (Nb_CS=3 et GASCII9=W et GASCII14=W))
# :(NVD - I2G)
#-----------------------------------------------------------------------#
# QC 134 (deplacement du bloc)
  SI( type_cra == 0xA0)
  ALORS
    Nb_CS = i_get_art_field(g_iartout, $Tdpvgsm::occurenceNb)
    erreur=i_get_art_str(g_iartout, $Tdpvgsm::GASCII, ptr_GASCII)
    i_get_sub_str(ptr_GASCII, 3, 3, ptr_GASCII4)
    i_get_sub_str(ptr_GASCII, 8, 8, ptr_GASCII9)
    i_get_sub_str(ptr_GASCII, 13, 13,ptr_GASCII14)
    erreur=i_get_art_str(g_iartout, $Tdpvgsm::Amount, ptr_Amount)
    SI (i_strcmp(ptr_Amount,"000000000000") == 0)
    ALORS
      SI (i_strcmp(ptr_GASCII4, "W") != 0 && Nb_CS == 1)
      ALORS
        res = MiseAuFormat_Stockage_660004265("NVAGSM", instNVAGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI
        res = MiseAuFormat_Stockage_660004265("I2GGSM", instI2GGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI
        SAUT FIN_DISTRI
      SINON
        SI ((i_strcmp(ptr_GASCII4, "W") != 0 && i_strcmp(ptr_GASCII9, "W") != 0) && Nb_CS == 2)
        ALORS
# 01XX0017
          NumOfFilter = NumOfFilter + 0x0017
          trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
#QC983
          SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
          ALORS
            erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
          SINON
            SI Old_Family
            ALORS
              erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
            SINON
              erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
            FINSI
            erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
          FINSI
#/QC983

          res = MiseAuFormat_Stockage_660004265("NVAGSM", instNVAGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
          SI (res == STOCKAGE_KO)
          ALORS
            RETOUR STOCKAGE_KO
          FINSI
          res = MiseAuFormat_Stockage_660004265("I2GGSM", instI2GGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
          SI (res == STOCKAGE_KO)
          ALORS
            RETOUR STOCKAGE_KO
          FINSI
          SAUT FIN_DISTRI
        SINON
          SI ((i_strcmp(ptr_GASCII4, "W") != 0 && i_strcmp(ptr_GASCII9, "W") != 0 && i_strcmp(ptr_GASCII14, "W") != 0) && Nb_CS == 3)
          ALORS
            res = MiseAuFormat_Stockage_660004265("NVAGSM", instNVAGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
            SI (res == STOCKAGE_KO)
            ALORS
              RETOUR STOCKAGE_KO
            FINSI
            res = MiseAuFormat_Stockage_660004265("I2GGSM", instI2GGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
            SI (res == STOCKAGE_KO)
            ALORS
              RETOUR STOCKAGE_KO
            FINSI
            SAUT FIN_DISTRI
          FINSI
        FINSI
      FINSI
    FINSI
  FINSI

# evol G1R8
#-----------------------------------------------------------------------#
# 18)  type=A7 et Amount=0 et IMSI_TPE faux :(NVA - I2G)
#-----------------------------------------------------------------------#
#G1R8 QC192
  SI ( type_cra == 0xA7 && IMSI_TPE == Non )
  ALORS
    erreur=i_get_art_str(g_iartout, $Tdpvgsm::Amount, ptr_Amount)
    SI (i_strcmp(ptr_Amount,"000000000000") == 0)
    ALORS
# 01XX0018
      NumOfFilter = NumOfFilter + 0x0018
      trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
#QC983
      SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
      ALORS
        erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
      SINON
        SI Old_Family
        ALORS
          erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
        SINON
          erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
        FINSI
        erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
      FINSI
#/QC983

      res = MiseAuFormat_Stockage_660004265("NVAGSM", instNVAGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
      res = MiseAuFormat_Stockage_660004265("I2GGSM", instI2GGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
      SAUT FIN_DISTRI
    FINSI
  FINSI

#-----------------------------------------------------------------------#
# 19) : type=AF ou AE et Amount=0 et serviceID4=W et IMSI_TPE faux
# :(NVA - I2G)
#-----------------------------------------------------------------------#
#G1R8 QC192
  SI ( (type_cra == 0xAF || type_cra == 0xAE) && IMSI_TPE == Non )
  ALORS
    SI (i_valid_field_n(g_iartout,$Tdpvgsm::serviceID))
    ALORS
      erreur = i_get_art_str(g_iartout, $Tdpvgsm::serviceID, ptr_service)
      i_get_sub_str(ptr_service, 3, 3, ptr_extra)

      SI   (i_strcmp(ptr_extra, "W") == 0)
      ALORS
        erreur=i_get_art_str(g_iartout, $Tdpvgsm::Amount, ptr_Amount)
        SI (i_strcmp(ptr_Amount,"000000000000") == 0)
        ALORS
# 01XX0019
          NumOfFilter = NumOfFilter + 0x0019
          trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
          #QC983
          SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
          ALORS
            erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
          SINON
            SI Old_Family
            ALORS
              erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
            SINON
              erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
            FINSI
            erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
          FINSI
#/QC983
          res = MiseAuFormat_Stockage_660004265("NVAGSM", instNVAGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
          SI (res == STOCKAGE_KO)
          ALORS
            RETOUR STOCKAGE_KO
          FINSI

          res = MiseAuFormat_Stockage_660004265("I2GGSM", instI2GGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
          SI (res == STOCKAGE_KO)
          ALORS
            RETOUR STOCKAGE_KO
          FINSI
          SAUT FIN_DISTRI
        FINSI
      FINSI
    FINSI
  FINSI

#-----------------------------------------------------------------------#
# 20) : IMSI_TPE et V4t39.6 Amount=0 et V4t41.5 serviceID=W
# :(NVD - I2G)
#-----------------------------------------------------------------------#
  SI (IMSI_TPE == Oui)
  ALORS
    SI ( i_valid_field_n(g_iartout, $Tdpvgsm::serviceID) )
    ALORS
      erreur = i_get_art_str(g_iartout, $Tdpvgsm::serviceID, ptr_service)
      i_get_sub_str(ptr_service, 3, 3, ptr_extra)

      SI (i_strcmp(ptr_extra, "W") == 0)
      ALORS
        erreur=i_get_art_str(g_iartout, $Tdpvgsm::Amount, ptr_Amount)
        SI (i_strcmp(ptr_Amount,"000000000000") == 0)
        ALORS
# 01XX001A
          NumOfFilter = NumOfFilter + 0x001A
          trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
#QC983
          SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
          ALORS
            erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
          SINON
            SI Old_Family
            ALORS
              erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
            SINON
              erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
            FINSI
            erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
          FINSI
#/QC983
#G3R9 lot2 COME
          i_strcpy(ptr_valeurDATE, i_get_tab_field("VariableContexte", date_cra, "DATE_FRCOME"))
          i_get_sub_str(ptr_valeurDATE,2,-1,ptr_date_res)
          erreur = i_set_art_str (g_iartout7,$Conv_URS::DATE,ptr_date_res)
          date_table = i_get_art_field(g_iartout7, $Conv_URS::DATEN)
          SI (date_cra < date_table)
          ALORS
            res = MiseAuFormat_Stockage_660004265("NVDGSM", instNVDGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
            SI (res == STOCKAGE_KO)
            ALORS
              RETOUR STOCKAGE_KO
            FINSI
          SINON
            res = MiseAuFormat_Stockage_660004265("NVCGSM", instNVCGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
            SI (res == STOCKAGE_KO)
            ALORS
              RETOUR STOCKAGE_KO
            FINSI
          FINSI
          res = MiseAuFormat_Stockage_660004265("I2GGSM", instI2GGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
          SI (res == STOCKAGE_KO)
          ALORS
            RETOUR STOCKAGE_KO
          FINSI
          SAUT FIN_DISTRI
        FINSI
      FINSI
    FINSI
  FINSI


#--------------------------------------------------------------------------#
# G5R1lot2 C+S : IMSI_TPE = vrai et T3t73/V3t73 = G* Et CetS_GRATUIT.5 = 1
#--------------------------------------------------------------------------#
# Correction spec A41.2
#  SI (IMSI_TPE == Oui)
#  ALORS
#
#G5R1lot2
#    SI (i_strplcmp(pt_CodeTarifSVA, "G", 0, 1) == 0 && i_strplcmp(ptr_CetS_GRATUIT, "1", C_FiltreCetS_TPE, 1) == 0)
#    ALORS
## 01XX0051
#      NumOfFilter = NumOfFilter + 0x0051
#      trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
#
#      i_strcpy(ptr_valeurDATE, i_get_tab_field("VariableContexte", date_cra, "DATE_FRCOME"))
#      i_get_sub_str(ptr_valeurDATE,2,-1,ptr_date_res)
#      erreur = i_set_art_str (g_iartout7,$Conv_URS::DATE,ptr_date_res)
#      date_table = i_get_art_field(g_iartout7, $Conv_URS::DATEN)
#      SI (date_cra < date_table)
#      ALORS
#        res = MiseAuFormat_Stockage("MSFGSM", instMSFGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
#        SI (res == STOCKAGE_KO)
#        ALORS
#          RETOUR STOCKAGE_KO
#        FINSI
#
#      SINON
#        i_strcpy(ptr_valeurDATE, i_get_tab_field("VariableContexte", date_cra, "DATE_COMETPE"))
#        i_get_sub_str(ptr_valeurDATE,2,-1,ptr_date_res)
#        erreur = i_set_art_str (g_iartout7,$Conv_URS::DATE,ptr_date_res)
#        date_table = i_get_art_field(g_iartout7, $Conv_URS::DATEN)
#        SI (date_cra < date_table)
#        ALORS
#          res = MiseAuFormat_Stockage("FRCGSM", instFRCGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
#          SI (res == STOCKAGE_KO)
#          ALORS
#            RETOUR STOCKAGE_KO
#          FINSI
#        SINON
#          res = MiseAuFormat_Stockage("COMGSM", instCOMGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
#          SI (res == STOCKAGE_KO)
#          ALORS
#            RETOUR STOCKAGE_KO
#          FINSI
#        FINSI
#
#      FINSI
#
#      res = MiseAuFormat_Stockage("I2GGSM", instI2GGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
#      SI (res == STOCKAGE_KO)
#      ALORS
#        RETOUR STOCKAGE_KO
#      FINSI
#      res = MiseAuFormat_Stockage(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
#      SI (res == STOCKAGE_KO)
#      ALORS
#        RETOUR STOCKAGE_KO
#      FINSI
#      SI (FlagBI2)
#      ALORS
#        res = MiseAuFormat_Stockage("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
#        SI (res == STOCKAGE_KO)
#        ALORS
#          RETOUR STOCKAGE_KO
#        FINSI
#      FINSI
#
#    FINSI
#  FINSI


  SI (IMSI_TPE == Oui)
  ALORS

#--------------------------------------------------------------------------#
# G5R1lot2 C+S : IMSI_TPE = vrai et T3t73/V3t73 = G* Et CetS_GRATUIT.5 = 0
#--------------------------------------------------------------------------#
# QC1388 : ajout du SAUT G5R1_CetS
    SI (i_strplcmp(pt_CodeTarifSVA, "G", 0, 1) == 0 && i_strplcmp(ptr_CetS_GRATUIT, "0", C_FiltreCetS_TPE, 1) == 0)
    ALORS
# 01XX0052
      NumOfFilter = NumOfFilter + 0x0052
      trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

      SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
      ALORS
        erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
      SINON
        SI Old_Family
        ALORS
          erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
        SINON
          erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
        FINSI
        erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
      FINSI

      res = MiseAuFormat_Stockage_660004265("RJPGSM", instRJPGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI

      res = MiseAuFormat_Stockage_660004265("EIRGSM", instEIRGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
      SAUT G5R1_CetS
    FINSI

#--------------------------------------------------------------------------#
# 21 et 22 : IMSI_TPE (DISE - I2G, Symphonie, IRIS, EIR sauf type=46 ou A6)
#--------------------------------------------------------------------------#
    SI ((type_cra == 0xA6) || (type_cra == 0x46))
    ALORS
# 01XX001D
      NumOfFilter = NumOfFilter + 0x001D
      trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

      SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
      ALORS
        erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
      SINON
        SI Old_Family
        ALORS
          erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
        SINON
          erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
        FINSI
        erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
      FINSI
# QC1137
# G3R9 lot2 COME
      i_strcpy(ptr_valeurDATE, i_get_tab_field("VariableContexte", date_cra, "DATE_FRCOME"))
      i_get_sub_str(ptr_valeurDATE,2,-1,ptr_date_res)
      erreur = i_set_art_str (g_iartout7,$Conv_URS::DATE,ptr_date_res)
      date_table = i_get_art_field(g_iartout7, $Conv_URS::DATEN)
      SI (date_cra < date_table)
      ALORS
        res = MiseAuFormat_Stockage_660004265("MSFGSM", instMSFGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI
      SINON
        i_strcpy(ptr_valeurDATE, i_get_tab_field("VariableContexte", date_cra, "DATE_COMETPE"))
        i_get_sub_str(ptr_valeurDATE,2,-1,ptr_date_res)
        erreur = i_set_art_str (g_iartout7,$Conv_URS::DATE,ptr_date_res)
        date_table = i_get_art_field(g_iartout7, $Conv_URS::DATEN)
        SI (date_cra < date_table)
        ALORS
          res = MiseAuFormat_Stockage_660004265("FRCGSM", instFRCGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
          SI (res == STOCKAGE_KO)
          ALORS
            RETOUR STOCKAGE_KO
          FINSI
        SINON
          res = MiseAuFormat_Stockage_660004265("COMGSM", instCOMGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
          SI (res == STOCKAGE_KO)
          ALORS
            RETOUR STOCKAGE_KO
          FINSI
        FINSI
      FINSI
      SAUT G5R1_CetS
    FINSI

    SI ((type_cra != 0xA6) && (type_cra != 0x46))
    ALORS
# 01XX001B
      NumOfFilter = NumOfFilter + 0x001B
      trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
      SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
      ALORS
        erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
      SINON
        SI Old_Family
        ALORS
          erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
        SINON
          erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
        FINSI
        erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
      FINSI
# QC1137
#G3R9 lot 2 COME
      i_strcpy(ptr_valeurDATE, i_get_tab_field("VariableContexte", date_cra, "DATE_FRCOME"))
      i_get_sub_str(ptr_valeurDATE,2,-1,ptr_date_res)
      erreur = i_set_art_str (g_iartout7,$Conv_URS::DATE,ptr_date_res)
      date_table = i_get_art_field(g_iartout7, $Conv_URS::DATEN)
      SI (date_cra < date_table)
      ALORS
        res = MiseAuFormat_Stockage_660004265("MSFGSM", instMSFGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI
      SINON
        i_strcpy(ptr_valeurDATE, i_get_tab_field("VariableContexte", date_cra, "DATE_COMETPE"))
        i_get_sub_str(ptr_valeurDATE,2,-1,ptr_date_res)
        erreur = i_set_art_str (g_iartout7,$Conv_URS::DATE,ptr_date_res)
        date_table = i_get_art_field(g_iartout7, $Conv_URS::DATEN)
        SI (date_cra < date_table)
        ALORS
          res = MiseAuFormat_Stockage_660004265("FRCGSM", instFRCGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
          SI (res == STOCKAGE_KO)
          ALORS
            RETOUR STOCKAGE_KO
          FINSI
        SINON
          res = MiseAuFormat_Stockage_660004265("COMGSM", instCOMGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
          SI (res == STOCKAGE_KO)
          ALORS
            RETOUR STOCKAGE_KO
          FINSI
        FINSI
      FINSI

      res = MiseAuFormat_Stockage_660004265("EIRGSM", instEIRGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI

#G5R1
    POINT G5R1_CetS

    res = MiseAuFormat_Stockage_660004265(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    SI (FlagBI2)
    ALORS
      res = MiseAuFormat_Stockage_660004265("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI

    res = MiseAuFormat_Stockage_660004265("I2GGSM", instI2GGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    SAUT FIN_DISTRI
  FINSI

#G1R5 debut Evol FFMV2 et N&M I2G--------------------------------------------


  #-----------------------------------------------------------------------#
  # type 61, 62, 63  : flux MIB
  #-----------------------------------------------------------------------#
  SI (type_cra == 0x61) || (type_cra == 0x62) || (type_cra == 0x63)
  ALORS
# 01XX001F
    NumOfFilter = NumOfFilter + 0x001F
    trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter = de 1F a 21 <0x%x>", NumOfFilter)
#QC983
    SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
    ALORS
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    SINON
      SI Old_Family
      ALORS
        erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
      SINON
        erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
      FINSI
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    FINSI
#/QC983
#G3R9 lot2 COME
    i_strcpy(ptr_valeurDATE, i_get_tab_field("VariableContexte", date_cra, "DATE_FRCOME"))
    i_get_sub_str(ptr_valeurDATE,2,-1,ptr_date_res)
    erreur = i_set_art_str (g_iartout7,$Conv_URS::DATE,ptr_date_res)
    date_table = i_get_art_field(g_iartout7, $Conv_URS::DATEN)
    SI (date_cra < date_table)
    ALORS
      res = MiseAuFormat_Stockage_660004265("MSFGSM", instMSFGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    SINON
      i_strcpy(ptr_valeurDATE, i_get_tab_field("VariableContexte", date_cra, "DATE_COMEMIB"))
      i_get_sub_str(ptr_valeurDATE,2,-1,ptr_date_res)
      erreur = i_set_art_str (g_iartout7,$Conv_URS::DATE,ptr_date_res)
      date_table = i_get_art_field(g_iartout7, $Conv_URS::DATEN)
      SI (date_cra < date_table)
      ALORS
        res = MiseAuFormat_Stockage_660004265("FRCGSM", instFRCGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI
      SINON
        res = MiseAuFormat_Stockage_660004265("COMGSM", instCOMGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI
      FINSI
    FINSI
#/G3R9 lot2 COME

    res = MiseAuFormat_Stockage_660004265("EIRGSM", instEIRGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

#G5R1
    res = MiseAuFormat_Stockage_660004265(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    SI (FlagBI2)
    ALORS
      res = MiseAuFormat_Stockage_660004265("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI

    SAUT FIN_DISTRI
  FINSI


  #-----------------------------------------------------------------------#
  # type 40  : flux WHA
  #-----------------------------------------------------------------------#

  SI (type_cra == 0x40)
  ALORS
    # ne pas enlever le 1er caractere (le 0 deja enleve dans le pcode de dist de Tcb)
    SI (i_get_tab_field(SHORT_ID_Non_FAC, date_cra, str_idpart_ascii) != g_inull)
    ALORS
# 01XX0009
      NumOfFilter = NumOfFilter + 0x0009
      trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
      #QC983
      SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
      ALORS
        erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
      SINON
        SI Old_Family
        ALORS
          erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
        SINON
          erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
        FINSI
        erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
      FINSI
#/QC983
      res = MiseAuFormat_Stockage_660004265("RJPGSM", instRJPGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      REJET40 = Oui
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI

#G5R1
      res = MiseAuFormat_Stockage_660004265(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI

      SI (FlagBI2)
      ALORS
        res = MiseAuFormat_Stockage_660004265("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI
      FINSI

      SAUT FIN_DISTRI
    FINSI
  FINSI


#QC935 ajout de l'envoi des cra wifi communautaire vers I2G et deplacement du filtre 01xx0031
# G3R1 lot3 WIFICOM et WIFICOM SCOT
# G3R3 lot2 wifi communautaire (Wificom) ajout du filtre 0x1005
  SI ((type_cra == 0x80) &&  (i_get_art_field(g_iartout, $Tdpvgsm::chgcar) == 0x1003 || i_get_art_field(g_iartout, $Tdpvgsm::chgcar) == 0x1005))
  ALORS
# 01XX0031
    NumOfFilter = NumOfFilter + 0x0031
    trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
#QC983
    SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
    ALORS
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    SINON
      SI Old_Family
      ALORS
        erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
      SINON
        erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
      FINSI
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    FINSI
#/QC983
    res = MiseAuFormat_Stockage_660004265("RJPGSM", instRJPGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

#G5R1
    res = MiseAuFormat_Stockage_660004265(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    SI (FlagBI2)
    ALORS
      res = MiseAuFormat_Stockage_660004265("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI

    res = MiseAuFormat_Stockage_660004265("I2GGSM", instI2GGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

#G3R4 lot3 WIFI THEMIS
    SI (Hostspot_THEMIS == 1)
    ALORS
      res = MiseAuFormat_Stockage_660004265("TMIGSM", instTHEMISGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI
#/G3R4 lot3 WIFI THEMIS

    SAUT FIN_DISTRI
  FINSI


  #-----------------------------------------------------------------------#
  # tout flux  : IMSI a 55555555555555
  #-----------------------------------------------------------------------#
  SI (i_strplcmp(str_imsi_ascii, C_ptr_IMSI_55, 0, i_strlen(C_ptr_IMSI_55)) == 0)
  ALORS
# 01XX0014
    NumOfFilter = NumOfFilter + 0x0014
    trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
#QC983
    SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
    ALORS
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    SINON
      SI Old_Family
      ALORS
        erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
      SINON
        erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
      FINSI
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    FINSI
#/QC983
#G3R9 lot2 COME
    i_strcpy(ptr_valeurDATE, i_get_tab_field("VariableContexte", date_cra, "DATE_FRCOME"))
    i_get_sub_str(ptr_valeurDATE,2,-1,ptr_date_res)
    erreur = i_set_art_str (g_iartout7,$Conv_URS::DATE,ptr_date_res)
    date_table = i_get_art_field(g_iartout7, $Conv_URS::DATEN)
    SI (date_cra < date_table)
    ALORS
      res = MiseAuFormat_Stockage_660004265("MSFGSM", instMSFGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    SINON
      i_strcpy(ptr_valeurDATE, i_get_tab_field("VariableContexte", date_cra, "DATE_COME5555"))
      i_get_sub_str(ptr_valeurDATE,2,-1,ptr_date_res)
      erreur = i_set_art_str (g_iartout7,$Conv_URS::DATE,ptr_date_res)
      date_table = i_get_art_field(g_iartout7, $Conv_URS::DATEN)
      SI (date_cra < date_table)
      ALORS
        res = MiseAuFormat_Stockage_660004265("FRCGSM", instFRCGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI
      SINON
        res = MiseAuFormat_Stockage_660004265("COMGSM", instCOMGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI
      FINSI
    FINSI

#/G3R9 lot2 COME

    res = MiseAuFormat_Stockage_660004265("EIRGSM", instEIRGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    res = MiseAuFormat_Stockage_660004265("I2GGSM", instI2GGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

# G5R1
    res = MiseAuFormat_Stockage_660004265(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    SI (FlagBI2)
    ALORS
      res = MiseAuFormat_Stockage_660004265("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI

#G3R4 lot3 WIFI THEMIS

    SI (Hostspot_THEMIS == 1 && type_cra == 0x80)
    ALORS
      res = MiseAuFormat_Stockage_660004265("TMIGSM", instTHEMISGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI
#/G3R4 lot3 WIFI THEMIS
    SAUT FIN_DISTRI
  FINSI


  #-----------------------------------------------------------------------#
  # type 80  : flux WIFI
  #-----------------------------------------------------------------------#
  SI (type_cra == 0x80) && ( (i_get_art_field(g_iartout, $Tdpvgsm::chgcar) == 0x1002) || (i_get_art_field(g_iartout, $Tdpvgsm::chgcar) == 0x100E) )
  ALORS
# 01XX0022
    NumOfFilter = NumOfFilter + 0x0022
    trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
#QC983
    SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
    ALORS
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    SINON
      SI Old_Family
      ALORS
        erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
      SINON
        erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
      FINSI
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    FINSI
#/QC983

    res = MiseAuFormat_Stockage_660004265("DCHGSM", instDCHGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    res = MiseAuFormat_Stockage_660004265("EIRGSM", instEIRGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    res = MiseAuFormat_Stockage_660004265("I2GGSM", instI2GGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

#G5R1
    res = MiseAuFormat_Stockage_660004265(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    SI (FlagBI2)
    ALORS
      res = MiseAuFormat_Stockage_660004265("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI

    SI (Hostspot_THEMIS == 1)
    ALORS
      res = MiseAuFormat_Stockage_660004265("TMIGSM", instTHEMISGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI
#/G3R4 lot3 WIFI THEMIS

    SAUT FIN_DISTRI
  FINSI


  SI (type_cra == 0x80) &&  ( (i_get_art_field(g_iartout, $Tdpvgsm::chgcar) == 0x1001) || (i_get_art_field(g_iartout, $Tdpvgsm::chgcar) == 0x1004) )
  ALORS
# 01XX0023
    NumOfFilter = NumOfFilter + 0x0023
    trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
#QC983
    SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
    ALORS
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    SINON
      SI Old_Family
      ALORS
        erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
      SINON
        erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
      FINSI
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    FINSI
#/QC983
    res = MiseAuFormat_Stockage_660004265("RJPGSM", instRJPGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    res = MiseAuFormat_Stockage_660004265("IRIGSM", instIRIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    res = MiseAuFormat_Stockage_660004265("EIRGSM", instEIRGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    res = MiseAuFormat_Stockage_660004265("I2GGSM", instI2GGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI
#G5R1
    res = MiseAuFormat_Stockage_660004265(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    SI (FlagBI2)
    ALORS
      res = MiseAuFormat_Stockage_660004265("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI

    SI (Hostspot_THEMIS == 1)
    ALORS
      res = MiseAuFormat_Stockage_660004265("TMIGSM", instTHEMISGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI
#/G3R4 lot3 WIFI THEMIS
    SAUT FIN_DISTRI
  FINSI

  SI (type_cra == 0x80) &&  (i_get_art_field(g_iartout, $Tdpvgsm::chgcar) == 0x100D)
  ALORS
# 01XX0024
    NumOfFilter = NumOfFilter + 0x0024
    trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
#QC983
    SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
    ALORS
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    SINON
      SI Old_Family
      ALORS
        erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
      SINON
        erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
      FINSI
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    FINSI
#/QC983
    res = MiseAuFormat_Stockage_660004265("RJPGSM", instRJPGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    res = MiseAuFormat_Stockage_660004265("EIRGSM", instEIRGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    res = MiseAuFormat_Stockage_660004265("I2GGSM", instI2GGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

#G5R1
    res = MiseAuFormat_Stockage_660004265(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    SI (FlagBI2)
    ALORS
      res = MiseAuFormat_Stockage_660004265("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI

    res = MiseAuFormat_Stockage_660004265("IRIGSM", instIRIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

#G3R4 lot3 WIFI THEMIS
    SI (Hostspot_THEMIS == 1)
    ALORS
      res = MiseAuFormat_Stockage_660004265("TMIGSM", instTHEMISGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI
#/G3R4 lot3 WIFI THEMIS

    SAUT FIN_DISTRI
  FINSI

  #-----------------------------------------------------------------------#
  # type 50  : flux MLP (ex PILLOC)
  #-----------------------------------------------------------------------#
  SI (type_cra == 0x50)
  ALORS
# 01XX001E
    NumOfFilter = NumOfFilter + 0x001E
    trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
    erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)

#G3R9 lot2 COME

    i_strcpy(ptr_valeurDATE, i_get_tab_field("VariableContexte", date_cra, "DATE_FRCOME"))
    i_get_sub_str(ptr_valeurDATE,2,-1,ptr_date_res)
    erreur = i_set_art_str (g_iartout7,$Conv_URS::DATE,ptr_date_res)
    date_table = i_get_art_field(g_iartout7, $Conv_URS::DATEN)
    SI (date_cra < date_table)
    ALORS
      res = MiseAuFormat_Stockage_660004265("MSFGSM", instMSFGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    SINON
      i_strcpy(ptr_valeurDATE, i_get_tab_field("VariableContexte", date_cra, "DATE_COMEPILLOC"))
      i_get_sub_str(ptr_valeurDATE,2,-1,ptr_date_res)
      erreur = i_set_art_str (g_iartout7,$Conv_URS::DATE,ptr_date_res)
      date_table = i_get_art_field(g_iartout7, $Conv_URS::DATEN)
      SI (date_cra < date_table)
      ALORS
        res = MiseAuFormat_Stockage_660004265("FRCGSM", instFRCGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI
      SINON
        res = MiseAuFormat_Stockage_660004265("COMGSM", instCOMGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI
      FINSI
    FINSI

    res = MiseAuFormat_Stockage_660004265("EIRGSM", instEIRGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    res = MiseAuFormat_Stockage_660004265("ARTGSM", instARTGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI
#G5R1
    res = MiseAuFormat_Stockage_660004265(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    SI (FlagBI2)
    ALORS
      res = MiseAuFormat_Stockage_660004265("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI

    SAUT FIN_DISTRI
  FINSI

#---------------------------------------------------------------------#
# QC466 deplacement plus haut filtre type 00  : V4t99.1 = 0x01 ou 0x02
#---------------------------------------------------------------------#

  SI ((i_get_art_field(g_iartout, $Tdpvgsm::systype) == 0x03) && type_cra == 0x90)
  ALORS
    # 01XX0050
    NumOfFilter = NumOfFilter + 0x0050
    trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

    SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
    ALORS
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    SINON
      SI Old_Family
      ALORS
        erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
      SINON
        erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
      FINSI
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    FINSI

#QC1180 OBIWAN envoie vers REJET oublie
    res = MiseAuFormat_Stockage_660004265("RJPGSM", instRJPGSM, artout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

#G5R1
    res = MiseAuFormat_Stockage_660004265(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    SI (FlagBI2)
    ALORS
      res = MiseAuFormat_Stockage_660004265("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI

    SAUT FIN_DISTRI
  FINSI


  #-----------------------------------------------------------------------#
  # type 00  : DDEUR_IMSI <> 20801* et V3t4 = 80001
  #-----------------------------------------------------------------------#
#G3R7
  #SI (type_cra == 0x00) && ( i_strplcmp(str_imsi_ascii, C_ptr_IMSI_ORANGE, 0, 5) != 0  ) && ( i_strplcmp(pt_MSISDN, "80001", 0, 5) == 0  )
  SI ((type_cra == 0x00) && (IMSI_OrangeCo == Non) && ( i_strplcmp(pt_MSISDN, "80001", 0, 5) == 0))
  ALORS
# 01XX002B
    NumOfFilter = NumOfFilter + 0x002B
    trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
#QC983
    SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
    ALORS
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    SINON
      SI Old_Family
      ALORS
        erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
      SINON
        erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
      FINSI
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    FINSI
#/QC983
    res = MiseAuFormat_Stockage_660004265("RJPGSM", instRJPGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    res = MiseAuFormat_Stockage_660004265("I2GGSM", instI2GGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    res = MiseAuFormat_Stockage_660004265("EIRGSM", instEIRGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI
#G5R1
    res = MiseAuFormat_Stockage_660004265(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    SI (FlagBI2)
    ALORS
      res = MiseAuFormat_Stockage_660004265("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI

    SAUT FIN_DISTRI
  FINSI

  #-----------------------------------------------------------------------#
  # Filtrage des CRA 90 ou 91 avec IMSI = 64700.* et local = 64700.*
  #-----------------------------------------------------------------------#

# G3R4 filtrage des derniers CRA DCB pourI2G
# type = 0x91 => n'est plus recu par METEOR
  SI (type_cra == 0x90)
  ALORS
    #recuperation local
    SI (i_valid_field_n(artout, $Tdpvgsm::local))
    ALORS
      erreur = i_get_art_str(g_iartout, $Tdpvgsm::local, str_local_ascii)
      #------------------------------------------------------------------------------------------#
      #          si CRA de client OR emis sur le reseau OR                                       #
      #         les 5 premiers chiffres de V3t3 sont : 64700                                     #
      # C_ptr_local_REUNION "64700" et C_ptr_IMSI_REUNION  "64700" => CRA_IMSI_Reunion_Local_Reunion #
      #------------------------------------------------------------------------------------------#
      SI ( (!i_strplcmp(str_local_ascii, C_ptr_local_REUNION, 0, 5)) &&
        (! i_strplcmp(str_imsi_ascii, C_ptr_IMSI_REUNION, 0, 5)) )
      ALORS
        CRA_IMSI_Reunion_Local_Reunion= Oui
      FINSI
    FINSI
  FINSI

  SI (type_cra == 0x90 && CRA_IMSI_Reunion_Local_Reunion == Oui)
  ALORS
# 01XX0029 ou 01XX0035
#QC1406
    SI !i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
    ALORS
      SI Old_Family
      ALORS
        erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
      SINON
        erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
      FINSI
    FINSI

    # FILTRE_CB est vrai si V3t1.2 (tentite) == 0x0B filtrage de I2G
    SI (FILTRE_CB == Oui)
    ALORS
# 01XX0029
      NumOfFilter = NumOfFilter + 0x0029
      trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=01XX0029 <0x%x>", NumOfFilter)
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)

      res = MiseAuFormat_Stockage_660004265("RJPGSM", instRJPGSM, artout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI

    SINON
# 01XX0035
      NumOfFilter = NumOfFilter + 0x0035
      trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=01XX0035 <0x%x>", NumOfFilter)
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)

      res = MiseAuFormat_Stockage_660004265("RJPGSM", instRJPGSM, artout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI

      res = MiseAuFormat_Stockage_660004265("I2GGSM", instI2GGSM, artout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI

    FINSI
#/QC1406
#G5R1
    res = MiseAuFormat_Stockage_660004265(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    SI (FlagBI2)
    ALORS
      res = MiseAuFormat_Stockage_660004265("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI

    SAUT FIN_DISTRI
  FINSI

#/G3R4
# type = 0x91 => n'est plus recu par METEOR

  #-----------------------------------------------------------------------#
  # Traitement des appels d'URGENCE (IMSI_UR) IMSI_URGENCE
  #-----------------------------------------------------------------------#
  trace2("str_imsi_ascii = <%s>", str_imsi_ascii, "")
  SI (IMSI_URGENCE == Oui)
  ALORS
# 01XX000F
    NumOfFilter = NumOfFilter + 0x000F
    trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
#QC983
    SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
    ALORS
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    SINON
      SI Old_Family
      ALORS
        erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
      SINON
        erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
      FINSI
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    FINSI
#/QC983
    res = MiseAuFormat_Stockage_660004265("RJPGSM", instRJPGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI
    res = MiseAuFormat_Stockage_660004265("I2GGSM", instI2GGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    res = MiseAuFormat_Stockage_660004265("EIRGSM", instEIRGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

# G5R1
    res = MiseAuFormat_Stockage_660004265(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    SI (FlagBI2)
    ALORS
      res = MiseAuFormat_Stockage_660004265("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI

    SAUT FIN_DISTRI
  FINSI

  # pas de criteres de distributions particuliers
  nb_ecc = 0
FINSI


#-----------------------------------------------------------------------#
# AIGUILLAGE par IMSI
#-----------------------------------------------------------------------#


SI ((type_distri == CRIT_AIG_IMSI) || (nb_ecc == 0))
ALORS

  #-----------------------------------------------------------------------#
  #Application Secondaires
  #-----------------------------------------------------------------------#
#QC858
  instFRAERR = i_LireInstanceECC("FRAERR")
  SI ( !instFRAERR )
  ALORS
    erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "FRAERR", 0)
    trace("Pas d'instance pour FRAERR !")
    SAUT DISTRI_ERR
  FINSI


  instECDGSM = i_LireInstanceECC("ECDGSM")
  SI ( !instECDGSM )
  ALORS
    trace("Pas d'instance pour ECDGSM !")
    erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "ECDGSM", 0)
    SAUT DISTRI_ERR
  FINSI

  instSSMGSM = i_LireInstanceECC("SSMGSM")
  SI ( !instSSMGSM )
  ALORS
    trace("Pas d'instance pour SSMGSM !")
    erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "SSMGSM", 0)
    SAUT DISTRI_ERR
  FINSI

  instSSPGSM = i_LireInstanceECC("SSPGSM")
  SI ( !instSSPGSM )
  ALORS
    trace("Pas d'instance pour SSPGSM !")
    erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "SSPGSM", 0)
    SAUT DISTRI_ERR
  FINSI

  instMACDTE = i_LireInstanceECC("MACDTE")
  SI ( !instMACDTE )
  ALORS
    trace("Pas d'instance pour MACDTE !")
    erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "MACDTE", 0)
    SAUT DISTRI_ERR
  FINSI
  #
  #-----------------------------------------------------------------------#
  #  Identification par type
  #-----------------------------------------------------------------------#

  #-------< Call Type : UMTS Packet - GPRS >--------
# type = 0x91 => n'est plus recu par METEOR
  SI (type_cra == 0x90)
  ALORS

    #-----------------------------------------------------------------------#
    # IMSI de type REUNION (commence par 64700)                             #
    #-----------------------------------------------------------------------#
    SI(! i_strplcmp(str_imsi_ascii, "64700", 0, 5))
    ALORS
      IMSI_REUNION = Oui
    FINSI

    #-----------------------------------------------------------------------#
    # Type GPRS GGSN                                                        #
    #-----------------------------------------------------------------------#
    SI (i_get_art_field(g_iartout, $Tdpvgsm::tentite) == 0x07)
    ALORS
      TYPE_GPRS_GGSN = Oui

      #-----------------------------------------------------------------------#
      # table externe LISTE_GPRS_GGSN pour Orange Reunion                     #
      #   Verifie si les 5 premiers chiffres de l'imsi sont : 64700           #
      #-----------------------------------------------------------------------#

      # codage en dur de la valeur de la table externe LISTE_GPRS_GGSN

      SI(! i_strplcmp(str_imsi_ascii, "64700", 0, 5))
      ALORS
        CRA_OR_SUR_OF = Oui
      FINSI

      #-----------------------------------------------------------------------#
      #          si CRA de client OF emis sur le reseau OR                    #
      #         les 5 premiers chiffres de V3t3 sont : 64700                  #
      #-----------------------------------------------------------------------#
      SI ( (!i_strplcmp(str_local_ascii, C_ptr_IMSI_ORANGE, 0, 5)) &&
        (! i_strplcmp(str_imsi_ascii, C_ptr_local_REUNION, 0, 5)) )
      ALORS
        CRA_IMSI_Orange_local_Reunion = Oui
      FINSI

    FINSI

#G3R3 2GDT
    #-----------------------------------------------------------------------#
    # Type GPRS SGSN  (G3R3 2GDT)                                           #
    #-----------------------------------------------------------------------#
    SI (i_get_art_field(g_iartout, $Tdpvgsm::tentite) == 0x06)
    ALORS
      TYPE_GPRS_SGSN = Oui
    FINSI

    #-----------------------------------------------------------------------#
    # Filtrage des CRAs volume nul V4t20.10(TLV3.3)                         #
    #-----------------------------------------------------------------------#
    #QC873
    res=i_ConvertirChaine(i_get_art_fieldptr(g_iartout, $Tdpvgsm::totVolOut),6,1,pt_totVol_tmp,12,3)
    i_get_sub_str(pt_totVol_tmp,0, res -1 ,pt_totVolOut_ascii)

    res=i_ConvertirChaine(i_get_art_fieldptr(g_iartout, $Tdpvgsm::totVolIn),6,1,pt_totVol_tmp,12,3)
    i_get_sub_str(pt_totVol_tmp,0, res -1 ,pt_totVolIn_ascii)
    #/QC873

    SI  ( (i_strplcmp(pt_totVolOut_ascii, "0", 0, 1) == 0) &&
      (i_strplcmp(pt_totVolIn_ascii, "0", 0, 1) == 0) )
    ALORS
      TYPE_GPRS_volNULL = Oui
    FINSI

    #-----------------------------------------------------------------------#
    #          si CRA de client OR emis sur le reseau OR                    #
    #         les 5 premiers chiffres de V3t3 sont : 64700                  #
    #-----------------------------------------------------------------------#
    #recuperation local
    SI (i_valid_field_n(g_iartout, $Tdpvgsm::local))
    ALORS
      erreur = i_get_art_str(g_iartout, $Tdpvgsm::local, str_local_ascii)

      # FE_0017 codage en dur de la valeur de la table externe Reseau_OR

      SI(!i_strplcmp(str_local_ascii, "64700", 0, 5))
      ALORS
        CRA_REUNION = Oui
      FINSI
    FINSI

  FINSI

  # ---------------------------------------------------
  # Recherche IMSI ORANGE dans le referentiel
  # ---------------------------------------------------

  CRA_A_ENRICHIR = Non
  SI (i_strplcmp(str_imsi_ascii, C_ptr_IMSI_99, 0, i_strlen(C_ptr_IMSI_99)) == 0)
  ALORS
# Debut G3R0CwME
# Modification MSISDN pour appel au referentiel sans toucher au format pivot
    SI (type_cra == 0xA6) || (type_cra == 0xA0) || (type_cra == 0xAE) || (type_cra == 0xAF) || (type_cra == 0xA7)
    ALORS
      erreur = i_dup_art_id(g_iartout, g_iartout8)
      SI (g_iartout8.MSISDN[0] == 3) && (g_iartout8.MSISDN[1] == 3)
      ALORS
        SI (type_cra == 0xA6)
        ALORS
# G2R2 Facturation x euros
          SI (g_iartout8.MSISDN[2] != 6) && (g_iartout8.MSISDN[2] != 7)
          ALORS
            g_iartout8.MSISDN[1] = 1
          FINSI
        SINON
          g_iartout8.MSISDN[1] = 0
        FINSI
      FINSI
      #QC913
      erreur = i_EnvoiReqConsTabDist(TD_Msisdn, gmt_date_cra, g_iartout8.MSISDN[], 6, 0, 1 )
    SINON
      #QC913
      erreur = i_EnvoiReqConsTabDist(TD_Msisdn, gmt_date_cra, g_iartout.MSISDN[], 6, 0, 1 )
    FINSI

    # ---------------------------------------------------
    # Attente requete Table de Distribution
    # ---------------------------------------------------
    erreur = i_LireReqConsTabDist()
    SI (erreur != 0)
    ALORS
      # ---------------------------------------------------
      # Redistribution
      # ---------------------------------------------------
      CRA_a_redistribuer = Oui
      SAUT CRITERES_DISTRI
    FINSI

    instECCv_msisdn = i_LireEntierECCv( instMsisdn )
    res = i_LireInfoECC( instMsisdn, instECCv_msisdn )
    trace1("instECCv_msisdn = <%x>", instECCv_msisdn)
    SI ( res != 0)
    ALORS
      res_IMSI = i_LireImsiInfo( res, 0, 8, ptr_imsi_ascii_tmp )
      SI (res_IMSI)
      ALORS
        # ---------------------------------------------------
        # Redistribution
        # ---------------------------------------------------
        trace1("Erreur recuperation IMSI associe a MSISDN: erreur = <%d>",res_IMSI)
        CRA_A_ENRICHIR = Non
        CRA_a_redistribuer = Oui
        SAUT CRITERES_DISTRI
      FINSI
      CRA_A_ENRICHIR = Oui
      i_get_sub_str (ptr_imsi_ascii_tmp, 0, i_strlen(C_ptr_IMSI_99), ptr_IMSI_MSISDN)
      i_strcpy(str_imsi_ascii, ptr_IMSI_MSISDN)
      trace2(" Resultat de i_LireImsiInfo : <%s>", ptr_IMSI_MSISDN, "")

      lg_imsi = i_conv_ascii_dcb(ptr_IMSI_MSISDN, pt_dcb_IMSI)
      trace1("lg_imsi dcb = <%d>", lg_imsi)
      erreur = i_memcpy_art_field_n(g_iartout13, $Tdistribution::bufIMSI, pt_dcb_IMSI, lg_imsi)
      erreur = i_set_art_fieldtab(g_iartout13, $Tdistribution::bufIMSI, 16, 0x0F)

# G5R2 lot2 --- Recalcul de pt_MCCMNCx, IMSIy et IMSI_Transnational_M2M ----- avec IMSI trouve dans Referentiel MSISDN --------------------------
      #G5R2 lot2
      # MCCMNCx : 6 premiers caracteres de IMSI
      # rmq : IMSI = MCCMNC (5 digits) + MSIN commen?ant par xy, MSIN etant Mobile Subscriber Identifiant Number
      i_get_sub_str(ptr_IMSI_MSISDN, 0, 5, pt_MCCMNCx)

      # IMSIy : 7eme caractere de IMSI
      # rmq : IMSI = MCC/MNC/xy&..
      i_get_sub_str(ptr_IMSI_MSISDN, 6, 6, pt_IMSIy)

      # IMSI_Transnational_M2M : booleen vrai si
      # RechercherValeurClefTable(MVNO, "M2M_"+MCCMNCx) = "Tous"   ou   IMSIy appartient a la liste des valeurs (separees par "_") retournee par [RechercherValeurClefTable(MVNO, "M2M_"+MCCMNCx)]
      # table externe MVNO, nouvelles occurrences :
      #   M2M_901312; Tous   ;  Tous les IMSI commencant par 901312 sont transnationaux M2M
      #   M2M_901312; 1_2_5  ;  Seuls les IMSI 9013121*; 9013122* ; 90131215* sont transnationaux M2M
      erreur = i_format_str2(str_conteneur, "%s%s", "M2M_", pt_MCCMNCx)
      i_strcpy(ptr_res, i_get_tab_field("MVNO", date_cra, str_conteneur))
      # QC1441
      SI (i_strcmp(pt_IMSIy, "") != 0 && i_strcmp(ptr_res, "") != 0)
      ALORS
        SI ( i_strcmp(ptr_res,"Tous") == 0 || i_adequation_chaine_expreg(ptr_res, pt_IMSIy) == 0)
        ALORS
          IMSI_Transnational_M2M = Vrai
        SINON
          IMSI_Transnational_M2M = Faux
        FINSI
      SINON
        IMSI_Transnational_M2M = Faux
      FINSI
#/G5R2 lot2 ------------------------------------------------------------------------------------------------------------------------------------


#G5R2 lot1 Item Wholesale -> IMSI_OrangeCo n'est plus un critere pour ALICE
#G5R2 lot2 Rectification : pour Alice uniquement, mais pour d'autres oui ...
#
##-----#G5R1lot2 C+S ---=-Recalcul_de_IMSI_OrangeCo--+---requeteALICE-----avec_IMSI_trouve_Dans_Referentiel_MSISDN--------------------------
      #Recalcul de IMSI_OrangeCo avec l'IMSI trouve a partir de MSISDN
      SI (i_strplcmp(ptr_IMSI_MSISDN, C_ptr_IMSI_ORANGE, 0, i_strlen(C_ptr_IMSI_ORANGE)) == 0)
      ALORS
        IMSI_OrangeCo = Oui
      SINON
        SI (i_strplcmp (ptr_IMSI_MSISDN,"208", 0, 3) == 0)
        ALORS
          i_get_sub_str (ptr_IMSI_MSISDN, 0, 4, str_MNC)
          erreur=i_format_str2( str_conteneur, "%s%s", "L_", str_MNC)
          SI (i_get_tab_field("MVNO", date_cra, str_conteneur)) != g_inull
          ALORS
            IMSI_OrangeCo = Oui
          SINON
            IMSI_OrangeCo = Non
          FINSI
        FINSI
      FINSI
      #Recalcul de IMSI_ORANGE avec IMSI_OrangeCo recalcule
      SI IMSI_OrangeCo
      ALORS
        IMSI_ORANGE = Oui
      SINON
        SI ( (i_strplcmp(str_imsi_ascii, C_ptr_IMSI_Mobicarte_1, 0, i_strlen(C_ptr_IMSI_Mobicarte_1)) == 0) ||
          (i_strplcmp(str_imsi_ascii, C_ptr_IMSI_Mobicarte_2, 0, i_strlen(C_ptr_IMSI_Mobicarte_2)) == 0) ||
          (i_strplcmp(str_imsi_ascii, C_ptr_IMSI_Mobicarte_3, 0, i_strlen(C_ptr_IMSI_Mobicarte_3)) == 0) ||
          (i_strplcmp(str_imsi_ascii, C_ptr_IMSI_Mobicarte_4, 0, i_strlen(C_ptr_IMSI_Mobicarte_4)) == 0) )
        ALORS
          IMSI_ORANGE = Oui
        FINSI
      FINSI

      # trace1("<<<__LINE__<<<__FILE__<<< IMSI_OrangeCo=<%d>",IMSI_OrangeCo)

    SINON
      # ---------------------------------------------------
      # Redistribution
      # ---------------------------------------------------
      CRA_a_redistribuer = Oui
      SAUT CRITERES_DISTRI
    FINSI

  FINSI

  SI ( IMSI_OrangeCo == 1 ||  CRA_A_ENRICHIR == Oui)
  ALORS

    # ---------------------------------------------------
    # IMSI renseigne ou retrouver a partir du MSISDN
    # ---------------------------------------------------
    #---------------------------------------------------
    # Envoi Requetes Table de Distribution
    #---------------------------------------------------
    SI (CRA_A_ENRICHIR == Non)
    ALORS
      # ---------------------------------------------------
      # rechercher IMSI
      # ---------------------------------------------------
      #QC913
      erreur = i_EnvoiReqConsTabDist(TD_Imsi, gmt_date_cra, g_iartout.IMSI[], 8, 0, 1 )
      SI (erreur != 0)
      ALORS
        # ---------------------------------------------------
        # Redistribution
        # ---------------------------------------------------
        CRA_a_redistribuer = Oui
        SAUT CRITERES_DISTRI
      FINSI
    SINON
      # ---------------------------------------------------
      # rechercher IMSI a partir du MSISDN
      # ---------------------------------------------------
      #QC913
      erreur = i_EnvoiReqConsTabDist(TD_Imsi, gmt_date_cra, g_iartout13.bufIMSI[], 8, 0, 1 )

      SI (erreur != 0)
      ALORS
        # ---------------------------------------------------
        # Redistribution
        # ---------------------------------------------------
        CRA_a_redistribuer = Oui
        SAUT CRITERES_DISTRI
      FINSI
    FINSI
    SI (erreur == 0)
    ALORS

      instFRAERR = i_LireInstanceECC("FRAERR")
      SI ( !instFRAERR )
      ALORS
        erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "FRAERR", 0)
        trace("Pas d'instance pour FRAERR !")
        SAUT DISTRI_ERR
      FINSI

      instM1GGSM=i_LireInstanceECC("M1GGSM")
      SI( !instM1GGSM )
      ALORS
        erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "M1GGSM", 0)
        trace(" Pas d'instance pour M1GGSM !")
        SAUT DISTRI_ERR
      FINSI

      instCMOGSM = i_LireInstanceECC("CMOGSM")
      SI ( !instCMOGSM )
      ALORS
        erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "CMOGSM", 0)
        trace("Pas d'instance pour CMOGSM !")
        SAUT DISTRI_ERR
      FINSI

# poubelles NVD, NVA, NVS, NVF controlees plus haut (en entete)

# Controle de la presence des ECC de facturation

      SI (!b_control_ECCfac)
      ALORS
# ADV
        instVDIGSM = i_LireInstanceECC("VDIGSM")
        SI ( !instVDIGSM )
        ALORS
          trace("Pas d'instance pour VDIGSM !")
          erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "VDIGSM", 0)
          SAUT DISTRI_ERR
        FINSI

        instOLAGSM = i_LireInstanceECC("OLAGSM")
        SI ( !instOLAGSM )
        ALORS
          trace("Pas d'instance pour OLAGSM !")
          erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "OLAGSM", 0)
          SAUT DISTRI_ERR
        FINSI

        instOL2GSM = i_LireInstanceECC("OL2GSM")
        SI ( !instOL2GSM )
        ALORS
          trace("Pas d'instance pour OL2GSM !")
          erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "OL2GSM", 0)
          SAUT DISTRI_ERR
        FINSI

        instOL3GSM = i_LireInstanceECC("OL3GSM")
        SI ( !instOL3GSM )
        ALORS
          trace("Pas d'instance pour OL3GSM !")
          erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "OL3GSM", 0)
          SAUT DISTRI_ERR
        FINSI

        instOR5GSM = i_LireInstanceECC("OR5GSM")
        SI ( !instOR5GSM )
        ALORS
          trace("Pas d'instance pour OR5GSM !")
          erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "OR5GSM", 0)
          SAUT DISTRI_ERR
        FINSI

# MSF
#  deja fait plus haut
# FE
        instFEGSM = i_LireInstanceECC("FEGSM")
        SI ( !instFEGSM )
        ALORS
          trace("Pas d'instance pour FEGSM !")
          erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "FEGSM", 0)
          SAUT DISTRI_ERR
        FINSI
# SACHEM
        instSHMGSM = i_LireInstanceECC("SHMGSM")
        SI ( !instSHMGSM )
        ALORS
          trace("Pas d'instance pour SHMGSM !")
          erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "SHMGSM", 0)
          SAUT DISTRI_ERR
        FINSI

        instSHPGSM = i_LireInstanceECC("SHPGSM")
        SI ( !instSHPGSM )
        ALORS
          trace("Pas d'instance pour SHPGSM !")
          erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "SHPGSM", 0)
          SAUT DISTRI_ERR
        FINSI
# TRG
        instTRGGSM = i_LireInstanceECC("TRGGSM")
        SI ( !instTRGGSM )
        ALORS
          trace("Pas d'instance pour TRGGSM !")
          erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "TRGGSM", 0)
          SAUT DISTRI_ERR
        FINSI

#QC783 ECC du groupe PMV
        instOL2PMV = i_LireInstanceECC("OL2PMV")
        SI ( !instOL2PMV )
        ALORS
          trace("Pas d'instance pour OL2PMV !")
          erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "OL2PMV", 0)
          SAUT DISTRI_ERR
        FINSI

        instOL3PMV = i_LireInstanceECC("OL3PMV")
        SI ( !instOL3PMV )
        ALORS
          trace("<__LINE__>Pas d'instance pour OL3PMV !")
          erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "OL3PMV", 0)
          SAUT DISTRI_ERR
        FINSI

        instOLAPMV = i_LireInstanceECC("OLAPMV")
        SI ( !instOLAPMV )
        ALORS
          trace("<__LINE__>Pas d'instance pour OLAPMV !")
          erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "OLAPMV", 0)
          SAUT DISTRI_ERR
        FINSI

        instOR5PMV = i_LireInstanceECC("OR5PMV")
        SI ( !instOR5PMV )
        ALORS
          trace("<__LINE__>Pas d'instance pour OR5PMV !")
          erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "OR5PMV", 0)
          SAUT DISTRI_ERR
        FINSI

        instVDIPMV = i_LireInstanceECC("VDIPMV")
        SI ( !instVDIPMV )
        ALORS
          trace("<__LINE__>Pas d'instance pour VDIPMV !")
          erreur = i_PlvMessEmettre(7515, 2, artin, "", 2, 0xA072, "VDIPMV", 0)
          SAUT DISTRI_ERR
        FINSI
#/QC783
      FINSI

      # ---------------------------------------------------
      # Attente requete Table de Distribution
      # ---------------------------------------------------
      erreur = i_LireReqConsTabDist()
      SI (erreur != 0)
      ALORS
        # ---------------------------------------------------
        # Redistribution
        # ---------------------------------------------------
        CRA_a_redistribuer = Oui
        SAUT CRITERES_DISTRI
      FINSI

#################################################################################
############## Recuperation Sysfact et CodOp demandeur
#################################################################################

      # ---------------------------------------------------
      # Retrouver l'application principale
      # ---------------------------------------------------
      instIMSI = -1

      res=i_LireInfoECC( instVDIGSM, 0 )
      SI (res != 0)
      ALORS
        trace1("instVDISGSM = <%d>", instVDIGSM)
        instIMSI = instVDIGSM
        app_dest=i_LireEntierInfo( res, 1, 2)
        trace1("app_dest:<0x%x>",app_dest)
        SAUT CRITERES_DISTRI
      SINON
        res=i_LireInfoECC( instOLAGSM, 0 )
        SI (res != 0)
        ALORS
          trace1("instOLAGSM = <%d>", instOLAGSM)
          instIMSI = instOLAGSM
          app_dest=i_LireEntierInfo( res, 1, 2)
          trace1("app_dest:<0x%x>",app_dest)
          SAUT CRITERES_DISTRI
        SINON
          res=i_LireInfoECC( instOL2GSM, 0 )
          SI (res != 0)
          ALORS
            trace1("instOL2SM = <%d>", instOL2GSM)
            instIMSI = instOL2GSM
            app_dest=i_LireEntierInfo( res, 1, 2)
            trace1("app_dest:<0x%x>",app_dest)
            SAUT CRITERES_DISTRI
          SINON
            res=i_LireInfoECC( instOL3GSM, 0 )
            SI (res != 0)
            ALORS
              trace1("instOL3SM = <%d>", instOL3GSM)
              instIMSI = instOL3GSM
              app_dest=i_LireEntierInfo( res, 1, 2)
              trace1("app_dest:<0x%x>",app_dest)
              SAUT CRITERES_DISTRI
            SINON
              res=i_LireInfoECC( instOR5GSM, 0 )
              SI (res != 0)
              ALORS
                trace1("instOR5GSM = <%d>", instOR5GSM)
                instIMSI = instOR5GSM
                app_dest=i_LireEntierInfo( res, 1, 2)
                trace1("app_dest:<0x%x>",app_dest)
                SAUT CRITERES_DISTRI
              SINON
                # FE_0011 identification des CRA MVNO prepaid et postpaid
                # un CRA MVNO postpaid est de code ID fact =13
                # un CRA MVNOO prepaid est de code ID fact =14
                res=i_LireInfoECC( instMSFGSM, 0 )
                SI( res!=0 )
                ALORS
                  instIMSI = instMSFGSM
                  trace1("instMSGFSM = <%d>", instMSFGSM)
                  app_dest=i_LireEntierInfo( res, 1, 2)
                  trace1("app_dest:<0x%x>",app_dest)
                  SI(app_dest==0x3133)
                  ALORS
                    trace("CRA MVNO postpaye")
                    MVNO_postpaid=Oui
                    SAUT CRITERES_DISTRI
                  FINSI

                  SI(app_dest==0x3134)
                  ALORS
                    trace("CRA MVNO prepaye")
                    MVNO_prepaid=Oui
                    SAUT CRITERES_DISTRI
                  FINSI

                  SI(app_dest==0x3135)
                  ALORS
                    CORIOLIS = Oui
                    SAUT CRITERES_DISTRI
                  FINSI

                  SI(app_dest==0x3131)
                  ALORS
                    DISE_Entreprise = Oui
                    SAUT CRITERES_DISTRI
                  FINSI

                  SI (app_dest==0x3031) || (app_dest==0x3033) || (app_dest==0x3034) || (app_dest==0x3035) || (app_dest==0x3039)
                  ALORS
                    Grand_Public = Oui
                  FINSI

                  trace("ECC MSFGSM")
                  SAUT CRITERES_DISTRI
                  # FIN FE_0011
                SINON
#G3R9 lot2 COME
                  res=i_LireInfoECC( instFEGSM, 0 )
                  SI (res!= 0)
                  ALORS
                    trace1("instFEGSM = <%d>", instFEGSM)
                    instIMSI = instFEGSM
                    FE = 1
                    #SAUT CRITERES_DISTRI
                    app_dest=i_LireEntierInfo( res, 1, 2)
                    trace1("app_dest:<0x%x>",app_dest)
                    SI(app_dest==0x3136)
                    ALORS
                      trace("CRA FE duplique vers DISE")
                      FE_DISE = Oui
                      SAUT CRITERES_DISTRI
                    FINSI
                    SI (app_dest==0x3430)
                    ALORS
                      FEElligible = Oui
                      trace ("cra FE eligible duplique vers FRCOME")
                      SAUT CRITERES_DISTRI
                    FINSI
                    SAUT CRITERES_DISTRI
#/G3R9 lot2 COME
                  SINON
#G3R9 COME
                    SI (i_LireInfoECC(instCOMGSM, 0) != 0)
                    ALORS
                      trace1("instCOMGSM = <%d>", instCOMGSM)
                      instIMSI = instCOMGSM
                      COME = Oui
                      SAUT CRITERES_DISTRI
                    SINON
                      SI (i_LireInfoECC(instFRCGSM, 0) != 0)
                      ALORS
                        trace1("instFRCOGSM = <%d>", instFRCGSM)
                        instIMSI = instFRCGSM
                        FRCOME = Oui
                        SAUT CRITERES_DISTRI
                      SINON
#/G3R9 COME
                        SI (i_LireInfoECC( instSHMGSM, 0 ) != 0)
                        ALORS
                          trace1("instSHMGSM = <%d>", instSHMGSM)
                          instIMSI = instSHMGSM
                          SAUT CRITERES_DISTRI
                        SINON
                          SI (i_LireInfoECC( instSHPGSM, 0 ) != 0)
                          ALORS
                            trace1("instSHPGSM = <%d>", instSHPGSM)
                            instIMSI = instSHPGSM
                            SAUT CRITERES_DISTRI
                          SINON
                            SI (i_LireInfoECC( instTRGGSM, 0 ) != 0)
                            ALORS
                              trace1("instTRGGSM = <%d>", instTRGGSM)
                              instIMSI = instTRGGSM
                              SAUT CRITERES_DISTRI
                            SINON
                              instIMSI = -1
                              trace("pas de ECC destinatrice : redistribution")
                              CRA_a_redistribuer = Oui
                              SAUT CRITERES_DISTRI
                            FINSI
                          FINSI
                        FINSI
                      FINSI
                    FINSI
                  FINSI
                FINSI
              FINSI
            FINSI
          FINSI
        FINSI
      FINSI
    SINON
      # ---------------------------------------------------
      # Redistribution
      # ---------------------------------------------------
      CRA_a_redistribuer = Oui
      SAUT CRITERES_DISTRI
    FINSI
  SINON
    # ---------------------------------------------------
    # IMSI etrangers ou de tests -> pas de recherche
    # G3R6 MVNO_FULL ajout des conditions IMSI_MVNOFull1 et IMSI_MVNOFull2 == 0 , IMSI_FREE == 0
    # ---------------------------------------------------
    SI ( (i_strplcmp(str_imsi_ascii, C_ptr_IMSI_Mobicarte_1, 0, i_strlen(C_ptr_IMSI_Mobicarte_1)) != 0) &&
      (i_strplcmp(str_imsi_ascii, C_ptr_IMSI_Mobicarte_2, 0, i_strlen(C_ptr_IMSI_Mobicarte_2)) != 0) &&
      (i_strplcmp(str_imsi_ascii, C_ptr_IMSI_Mobicarte_3, 0, i_strlen(C_ptr_IMSI_Mobicarte_3)) != 0) &&
      (i_strplcmp(str_imsi_ascii, C_ptr_IMSI_Mobicarte_4, 0, i_strlen(C_ptr_IMSI_Mobicarte_4)) != 0) &&
      IMSI_MVNOFull1 == 0 && IMSI_MVNOFull2 == 0 && IMSI_FREE == 0)
    ALORS
      # ---------------------------------------------------
      # Imsis Etranger --> a envoyer vers PLMN
      # ---------------------------------------------------

      CLS_ETRANGER = Oui

#     instDCHGSM  controle plus haut

      SAUT CRITERES_DISTRI
    SINON
      # ---------------------------------------------------
      # Imsis de test - Mobicarte
      # ---------------------------------------------------
      IMSI_TEST = Oui
      SAUT CRITERES_DISTRI
    FINSI
  FINSI


  POINT CRITERES_DISTRI

  #G3R6   Filtrage des CRA GGSN hors MVNO pour EIR
  #Evaluation du booleen MVNO

  SI (MVNO_prepaid == Oui || MVNO_postpaid == Oui)
  ALORS
    MVNO = Oui
  FINSI

#G3R9 lot2 COME
  SI (COME == Oui || FRCOME == Oui)
  ALORS
    COMESI = Oui
    trace ("<<__LINE__>> ------------ COMESI ----------------")
  FINSI

  SI ( instIMSI != -1 )
  ALORS
    res = i_LireInfoECC( instIMSI, 0 )
    res_IMSI = i_LireImsiInfo( res, 0, 8, ptr_imsi_ascii_tmp )
    SI (res_IMSI == 0)
    ALORS
      puissance = 1
      indice = 2
      BillingPF = 0

      POINT BOUCLE_SYSFACT
      InfoComp = i_LireEntierInfo(res, indice, 1) - 0x30
      SI ( InfoComp >= 0 ) && ( InfoComp <= 9 )
      ALORS
        BillingPF = BillingPF + (InfoComp * puissance)
        puissance = puissance * 10
        indice = indice - 1
      SINON
        BillingPF = 0xFF
        SAUT FIN_BOUCLE_SYSFACT
      FINSI

      SI indice > 0
      ALORS
        SAUT BOUCLE_SYSFACT
      FINSI

      POINT FIN_BOUCLE_SYSFACT

      erreur = i_set_art_field(g_iartout, $Tdpvgsm::GFlag2, BillingPF)

      SI ((type_cra < 0xA0) || (type_cra > 0xAF))
      ALORS
        puissance = 1
        indice = 7
        ClientNetworkOperator = 0

        POINT BOUCLE_CODOP2
        InfoComp = i_LireEntierInfo(res, indice, 1) - 0x30
        SI ( InfoComp >= 0 ) && ( InfoComp <= 9 )
        ALORS
          ClientNetworkOperator = ClientNetworkOperator + (InfoComp * puissance)
          puissance = puissance * 0x10
          indice = indice - 1
        SINON
          ClientNetworkOperator = 0xFFFF
          SAUT FIN_BOUCLE_CODOP2
        FINSI

        SI indice > 3
        ALORS
          SAUT BOUCLE_CODOP2
        FINSI
      FINSI
    FINSI
  FINSI

  POINT FIN_BOUCLE_CODOP2

  GValue = (ClientNetworkOperator * 0x10000) + PartnerNetworkOperator
  erreur = i_set_art_field(g_iartout, $Tdpvgsm::GValue, GValue)


  ################################
  ### Critere distribution CRA_VPN
  ### pas de redistribution des CRA VPN
  SI (CRA_VPN == Oui)
  ALORS
    CRA_a_redistribuer = Non
  FINSI

  #trace1("<<__LINE__>> ==============DISE_Entreprise=<%d>====================",DISE_Entreprise)
  #trace1("<<__LINE__>> ==============FE=<%d>====================",FE)
  #trace1("<<__LINE__>> ==============MVNO_postpaid=<%d>====================",MVNO_postpaid)
  #trace1("<<__LINE__>> ==============MVNO_prepaid=<%d>====================",MVNO_prepaid)
  #trace1("<<__LINE__>> ==============CORIOLIS=<%d>====================",CORIOLIS)
  #trace1("<<__LINE__>> ==============COMESI=<%d>====================",COMESI)

  #G3R10 lot4 Valorisation Data_Roaming_Legacy et DataRoaming_LTE
  ## 3 valeurs possibles : ? LEGACY ?, ? LTE5C ? et ? LTECIBLE ?
  SI    ((DISE_Entreprise == Oui) || (FE == Oui) ||  (MVNO_postpaid == Oui) || (MVNO_prepaid == Oui) || (CORIOLIS == Oui) || (COMESI == Oui))
    && ((i_strplcmp(str_local_ascii, "20801", 0, 5) != 0)
    &&  (i_strplcmp(str_local_ascii, "20802", 0, 5) != 0)
    &&  (i_strplcmp(str_local_ascii, "20810", 0, 5) != 0)
    &&  (i_strplcmp(str_local_ascii, "20813", 0, 5) != 0)
    &&  (i_strplcmp(str_local_ascii, "20888", 0, 5) != 0)
    &&  (i_strplcmp(str_local_ascii, "20820", 0, 5) != 0))
  ALORS
    SI (i_get_art_field(g_iartout,$Tdpvgsm::tentite) == 0x07)
    ALORS
      DataRoaming_Legacy = Oui
    SINON
      SI (i_get_art_field(g_iartout,$Tdpvgsm::tentite) == 0x19)
      ALORS
        DataRoaming_LTE = Oui
      FINSI
    FINSI
  FINSI

  SI (i_valid_field_n(g_iartout, $Tdpvgsm::transactionType))
  ALORS
    erreur = i_get_art_str(g_iartout, $Tdpvgsm::transactionType, ptr_transactionType)
    i_get_sub_str(ptr_transactionType, 3, 3, ptr_transactionType)
    SI (i_strcmp(ptr_transactionType, "2") != 0)
    ALORS
      Flag_transType = Oui
    FINSI
  FINSI

  #trace1 ("<<__LINE__>> ========== FILTRE_CB = %d ==========================", FILTRE_CB)
  #trace1 ("<<__LINE__>> ============Flag_transType = %d ====================", Flag_transType)

#G4R10 lot4 valorisation de ptr_ARCHITECTURE
  SI (type_cra == 0x90)
  ALORS
    SI (b_4GPgw == Oui || TYPE_GPRS_GGSN == Oui)
    ALORS
      #trace ("<<__LINE__>> ======= CAS b_4GPgw ou GPRS_GGSN ============")
      i_strcpy (ptr_SGTQS, i_LireEECSGTQS(g_ieec))
      erreur = i_format_str2(ptr_archi,"%s%s","ARCHIT_",ptr_SGTQS)
      #trace2("<<__LINE__>> =============== ptr_archi = %s ================",ptr_archi,"")
      i_strcpy(ptr_ARCHITECTURE,i_get_tab_field("VariableContexte",date_cra,ptr_archi))
      SI (i_strcmp( ptr_ARCHITECTURE,g_inull) == 0 )
      ALORS
        i_strcpy(ptr_ARCHITECTURE,"LTECIBLE")
      FINSI
    SINON
      SI (FILTRE_CB == Oui && Flag_transType == Oui)
      ALORS
        #trace1 ("<<__LINE__>> ======= FILTRE_CB=%d ============",FILTRE_CB)
        #trace1("<<__LINE__>> ======= Flag_transType=%d ============",Flag_transType)

        erreur = i_format_str2(ptr_archiCB,"%s%s","ARCHIT_CB_",ptr_transactionType)
        i_strcpy(ptr_ARCHITECTURE,i_get_tab_field("VariableContexte",date_cra,ptr_archiCB))
        SI (i_strcmp( ptr_ARCHITECTURE,g_inull) == 0 )
        ALORS
          i_strcpy(ptr_ARCHITECTURE,"LTECIBLE")
        FINSI
      FINSI
    FINSI
  FINSI

#G4R10 lot4 valorisation de ptr_SEGMENT_CLIENT
# QC1271 GRP au lieu de GPR
# 4 valeurs possibles : GRP ,  MPR , MPO et ENT
  SI (type_cra == 0x90 && ((b_4GPgw == Oui || TYPE_GPRS_GGSN == Oui) || (FILTRE_CB == Oui && Flag_transType == Oui)))
  ALORS
    SI (instVDIGSM == instIMSI || instOR5GSM == instIMSI || instOLAGSM == instIMSI ||
      instOL2GSM == instIMSI || instOL3GSM == instIMSI)
    ALORS
      i_strcpy(ptr_SEGMENT_CLIENT,"GRP")
    SINON
      SI (MVNO_postpaid)
      ALORS
        i_strcpy(ptr_SEGMENT_CLIENT,"MPO")
      SINON
        SI (MVNO_prepaid)
        ALORS
          i_strcpy(ptr_SEGMENT_CLIENT,"MPR")
        SINON
          SI (DISE_Entreprise || CORIOLIS || COMESI || FE)
          ALORS
            i_strcpy(ptr_SEGMENT_CLIENT,"ENT")
          FINSI
        FINSI
      FINSI
    FINSI
  FINSI
  #trace2 ("<<__LINE__>> ============= ptr_ARCHITECTURE = <%s> =================",ptr_ARCHITECTURE,"")
  #trace2 ("<<__LINE__>> ============= ptr_SEGMENT_CLIENT = <%s> =================",ptr_SEGMENT_CLIENT,"")
## G3R10 lot4 variable C_FRA_APN_TRT[1-5]
##  Une valeur ? 0 indique un filtrage possible (cf. criteres exclusion des filtres)
## C_FRA_APN_TRT1  0  = 0eme caractere de ptr_ResFRAAPNTRT (retour table externe FRA_APN_TRT) -> envoi des CRA reseau locaux
## C_FRA_APN_TRT2  2  = 2eme caractere de ptr_ResFRAAPNTRT (retour table externe FRA_APN_TRT) -> envoi des CRA reseau locaux en roaming out
## C_FRA_APN_TRT3  4  = 4eme caractere de ptr_ResFRAAPNTRT (retour table externe FRA_APN_TRT) -> envoi des CRA DCB locaux
## C_FRA_APN_TRT4  6  = 6eme caractere de ptr_ResFRAAPNTRT (retour table externe FRA_APN_TRT) -> envoi des CRA DCB en roaming out
## C_FRA_APN_TRT5  8  = 8eme caractere de ptr_ResFRAAPNTRT (retour table externe FRA_APN_TRT) -> envoi des CRA vers ECC IRIS

  #trace2 ("<<__LINE__>> ============= ptr_accPointName3 = <%s> =================",ptr_accPointName3,"")

  SI (i_strlen(ptr_SEGMENT_CLIENT) > 0 &&  i_strlen(ptr_ARCHITECTURE) > 0)
  ALORS
    erreur = i_format_str2(ptr_FRAAPNTRT,"%s%s",ptr_SEGMENT_CLIENT,"_")
    erreur = i_format_str2(ptr_FRAAPNTRT,"%s%s",ptr_FRAAPNTRT,ptr_accPointName3)
    erreur = i_format_str2(ptr_FRAAPNTRT,"%s%s",ptr_FRAAPNTRT,"_")
    erreur = i_format_str2(ptr_FRAAPNTRT,"%s%s",ptr_FRAAPNTRT,ptr_ARCHITECTURE)
    i_strcpy(ptr_ResFRAAPNTRT,i_get_tab_field("FRA_APN_TRT",date_cra,ptr_FRAAPNTRT))

    #trace2("<<__LINE__>> ================ ptr_FRAAPNTRT = <%s> ===================",ptr_FRAAPNTRT,"")
    #trace2("<<__LINE__>> ================ ptr_ResFRAAPNTRT = <%s> ===================",ptr_ResFRAAPNTRT,"")

    ## format retourne par la table    "[01]:[01]:[01]:[01]:[01]"
    ## position dans ptr_ResFRAAPNTRT :  0    2    4    6    8
    ## numero booleen                 :  1    2    3    4    5

    SI (i_strcmp( ptr_ResFRAAPNTRT,g_inull) == 0 )
    ALORS
      erreur = i_format_str2(ptr_FRAAPNTRT,"%s%s",ptr_SEGMENT_CLIENT,"_")
      erreur = i_format_str2(ptr_FRAAPNTRT,"%s%s",ptr_FRAAPNTRT,"APN_DEFAUT")
      erreur = i_format_str2(ptr_FRAAPNTRT,"%s%s",ptr_FRAAPNTRT,"_")
      erreur = i_format_str2(ptr_FRAAPNTRT,"%s%s",ptr_FRAAPNTRT,ptr_ARCHITECTURE)
      i_strcpy(ptr_ResFRAAPNTRT,i_get_tab_field("FRA_APN_TRT",date_cra,ptr_FRAAPNTRT))
      #trace2("<<__LINE__>> ================ ptr_FRAAPNTRT = <%s> ===================",ptr_FRAAPNTRT,"")
      #trace2("<<__LINE__>> ================ ptr_ResFRAAPNTRT = <%s> ===================",ptr_ResFRAAPNTRT,"")
      ##format retourne par la table     "[01]:[01]:[01]:[01]:[01]"
      ## position dans ptr_ResFRAAPNTRT :  0    2    4    6    8
      ## numero booleen                 :  1    2    3    4    5

      SI (i_strcmp( ptr_ResFRAAPNTRT,g_inull) == 0 )
      ALORS
        ## pas de reponse donc pas de filtre = tout a 1
        i_strcpy(ptr_ResFRAAPNTRT,"1:1:1:1:1")
        #trace2("<<__LINE__>> ================ ptr_ResFRAAPNTRT, valeur par defaut tout a 1 = <%s> ===================",ptr_ResFRAAPNTRT,"")
      FINSI
    FINSI
  FINSI

  #/Fin G3R10 lot4
  #-----------------------------------------------------------------------#
  # Applications principales
  #-----------------------------------------------------------------------#
#G3R0CbME

#Debut FE_0012
  SI (CRA_IMSI_Orange_local_Reunion == Oui)
#Fin FE_0012
  ALORS
    res = MiseAuFormat_Stockage_660004265("RJPGSM", instRJPGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI

    SAUT ECC_SECONDAIRES
  FINSI

#DEBUT DISE
  #-----------------------------------------------------------------------#
  #                        Flux DISE (MSF)    filtre 0x02
  #-----------------------------------------------------------------------#
  SI (instMSFGSM == instIMSI)
  ALORS
    NumOfFilter = 0x02000000 + type_cra * 0x10000

############ Filtres communs a plusieurs types #############################################
    #-----------------------type_cra == Tous types ----------------------------------------
    SI (CRA_VPN == Oui)
    ALORS
# 02XX0101
      NumOfFilter = NumOfFilter  + 0x0101
      trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
      SAUT TRAIT_REJET_DISE
    FINSI
############ Fin Filtres communs a plusieurs types ##########################################

# --------------- recuperation champ local  (T3t3)
    SI (i_valid_field_n(g_iartout, $Tdpvgsm::local))
    ALORS
      erreur = i_get_art_str(g_iartout, $Tdpvgsm::local, str_local_ascii)
    FINSI

#-----------------------type_cra == 0x00 sortant ----------------------------------------
#QC844
    SI (type_cra == 0x00)
    ALORS

      SI (i_get_art_field(g_iartout, $Tdpvgsm::origine) == 0x01)
      ALORS
        i_strcpy(str_IDEMET_CMM, i_get_tab_field("VariableContexte", date_cra, "FILTRE_IDEMET_CMM"))
        SI (i_strlen(str_IDEMET_CMM))
        ALORS
          SI(! i_strplcmp(str_idemet_ascii, str_IDEMET_CMM, 0, i_strlen(str_IDEMET_CMM)))
          ALORS
# 02000001
            NumOfFilter = NumOfFilter + 0x0001
            trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
            SAUT TRAIT_NVDGSM
          FINSI
        FINSI
      FINSI

      SI ( (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x22) && (i_strplcmp(str_idpart_ascii, "3368900", 0, 7) == 0) )
      ALORS
# 02000002
        NumOfFilter = NumOfFilter + 0x0002
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_NVDGSM
      FINSI

      SI ( (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x11) || (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x12) )
      ALORS
        res = i_get_art_field (g_iartout, $Tdpvgsm::C_Key1)
        # 0x50=80, 0x52=82
        SI ( res == 0x50 || res == 0x52 )
        ALORS
# 02000003
          NumOfFilter = NumOfFilter + 0x0003
          trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
          SAUT TRAIT_NVDGSM
        FINSI
      FINSI

      SI ( (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x11) || (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x12) )
      ALORS
        res = i_get_art_field (g_iartout, $Tdpvgsm::C_Key1)
        # 0x54=84, 0x56=86
        SI ( res == 0x54 || res== 0x56 )
        ALORS
# 02000004
          NumOfFilter = NumOfFilter + 0x0004
          trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
          SAUT TRAIT_NVDGSM
        FINSI
      FINSI

      SI  (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x32)
      ALORS
# 02000005
        NumOfFilter = NumOfFilter + 0x0005
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_NVDGSM
      FINSI

      SI (i_get_art_field(g_iartout,$Tdpvgsm::tlserv)== 0x31 && i_get_art_field(g_iartout,$Tdpvgsm::occurenceNb)== 0x01)
      ALORS
# 02000006
        NumOfFilter = NumOfFilter + 0x0006
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_NVDGSM
      FINSI

      pt_res_table = i_get_tab_field(Activation, date_cra,"param_tag_mvno")
      SI ( i_get_art_field(g_iartout,$Tdpvgsm::tlserv)== 0x01 || i_get_art_field(g_iartout,$Tdpvgsm::tlserv)== 0x02 )
      ALORS
        SI (i_strplcmp(pt_res_table,"Desactive", 0, 9) == 0 && ( MVNO_postpaid == Oui  ||  MVNO_prepaid == Oui))
        ALORS
# 02000007
          NumOfFilter = NumOfFilter + 0x0007
          trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
          SAUT TRAIT_NVDGSM
        FINSI
      FINSI
# QC704
      SI (MVNO_prepaid == Oui) && (i_get_art_field(g_iartout,$Tdpvgsm::tlserv)== 0x11)
      ALORS
        SI i_valid_field_n(g_iartout,$Tdpvgsm::idpart)
        ALORS
          erreur = i_get_art_str(g_iartout, $Tdpvgsm::idpart, ptr_advme)
          erreur = i_format_str2(ptr_advme_id,"%s%s","SVI_MVNO_",ptr_advme)
          SI (i_get_tab_field("IDPART", date_cra, ptr_advme_id)!= g_inull)
          ALORS
            SAUT FIN_filtre_DISE_prepaye
          FINSI
        FINSI

        SI i_valid_field_n(g_iartout,$Tdpvgsm::C_DestNum1)
        ALORS
          erreur = i_get_art_str(g_iartout, $Tdpvgsm::C_DestNum1, ptr_advme)
          erreur = i_format_str2(ptr_advme_id,"%s%s","SVI_MVNO_",ptr_advme)
          SI (i_get_tab_field("IDPART", date_cra, ptr_advme_id)!= g_inull)
          ALORS
# 02000008
            NumOfFilter = NumOfFilter + 0x0008
            trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
            SAUT TRAIT_NVDGSM
          FINSI
        FINSI
      FINSI

      POINT FIN_filtre_DISE_prepaye

      date_table = 0
      i_strcpy(ptr_valeurDATE, i_get_tab_field("VariableContexte", date_cra, "DATE_MEP_PF_TN_KODIAK"))
      i_get_sub_str(ptr_valeurDATE,2,-1,ptr_date_res)
      erreur = i_set_art_str (g_iartout7,$Conv_URS::DATE,ptr_date_res)
      date_table = i_get_art_field(g_iartout7, $Conv_URS::DATEN)

      SI (((i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x33)||(i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x34)) && date_cra >= date_table)
      ALORS
# 02000009
        NumOfFilter = NumOfFilter + 0x0009
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_NVDGSM
      FINSI

      pt_res_table = i_get_tab_field(Activation, date_cra,"param_tag_mvno")
      SI  (i_strplcmp(pt_res_table,"Actif", 0, 5) == 0) &&
        (i_get_art_field(g_iartout,$Tdpvgsm::tlserv)== 0x11) &&
        ( ( MVNO_postpaid == Oui ) || ( MVNO_prepaid == Oui ) ) &&
        (i_get_tab_field( GRETA , date_cra, str_idpart_ascii) != g_inull)
      ALORS
# 0200000A
        NumOfFilter = NumOfFilter + 0x000A
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_NVDGSM
      FINSI

#QC844
      i_strcpy(str_IDEMET_CMM, i_get_tab_field("VariableContexte", date_cra, "FILTRE_IDEMET_CMM"))
      SI (i_strlen(str_IDEMET_CMM))
      ALORS
        SI(! i_strplcmp(str_idemet_ascii, str_IDEMET_CMM, 0, i_strlen(str_IDEMET_CMM)))
        ALORS
          SI (i_get_tab_field(GRETA, date_cra, str_idpart_ascii) != g_inull)
          ALORS
# 0200000B
            NumOfFilter = NumOfFilter + 0x000B
            trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
            SAUT TRAIT_NVDGSM
          FINSI
        FINSI
      FINSI

      erreur = i_get_art_str(g_iartout, $Tdpvgsm::idemet,ptr_Emettrice)
      erreur = i_get_art_str(g_iartout, $Tdpvgsm::idpart, ptr_advme)
      erreur = i_format_str2(ptr_advme_id,"%s%s","AVME_",ptr_advme)
      # dans la table VariableContexte : AX_IDEMET_INCC;33032000000FFFFFFF
      i_strcpy(ptr_valINCC,i_get_tab_field("VariableContexte",date_cra,"AX_IDEMET_INCC"))
      # dans la table VariableContexte : AX_IDEMET_VPN;33007000000FFFFFFF
      i_strcpy(ptr_valVPN,i_get_tab_field("VariableContexte",date_cra,"AX_IDEMET_VPN"))
      posINCC = RECHERCHE_CARACTERE_660004265(ptr_valINCC,"F")
      SI posINCC < 0
      ALORS
        posINCC = posINCC * (-1)
      FINSI
      posVPN = RECHERCHE_CARACTERE_660004265(ptr_valVPN,"F")
      SI posVPN < 0
      ALORS
        posVPN = posVPN * (-1)
      FINSI

      i_get_sub_str(ptr_valINCC,0,posINCC - 1,ptr_valINCC)
      i_get_sub_str(ptr_valVPN ,0,posVPN - 1,ptr_valVPN)

      SI (i_get_tab_field("IDPART", date_cra,ptr_advme_id)!= g_inull)
        && (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x11)
        && ( i_strcmp(ptr_valINCC,ptr_Emettrice)!=0)
        && (i_strcmp(ptr_valVPN,ptr_Emettrice)!= 0)
      ALORS
# 0200000C
        NumOfFilter = NumOfFilter + 0x000C
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_NVDGSM
      FINSI

      #G1R5 AVME pk -Fin filtrage des cra MSC type 0x00 pour IN-CC et VPN
      #G1R8 Modification pour MIPC (criteres de dist 5.2.1.2.1 pour DISE)
      SI (i_get_art_field(g_iartout, $Tdpvgsm::onlinePurUsFlag) == 0x3B) && (i_get_art_field(g_iartout, $Tdpvgsm::DUREE) == 0x00)
      ALORS
# 0200000D
        NumOfFilter = NumOfFilter + 0x000D
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVDGSM
      FINSI
#G3R4 lot3 Msg Accueil
      SI (i_strcmp(str_idpart_ascii,g_inull) != 0)
      ALORS
        erreur = i_format_str2(str_RVMV ,"%s%s","RVMV_",str_idpart_ascii)
        SI ( table_exp_reg_660004265(str_RVMV, FILTRE_DISE_LOC , date_cra) == 1)
        ALORS
#02000010
          NumOfFilter = NumOfFilter + 0x0010
          trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
          erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
          SAUT TRAIT_NVDGSM
        FINSI
      FINSI

#/G3R4 lot3 Msg Accueil
      SI (DISE_Entreprise == Oui || CORIOLIS == Oui)
      ALORS
        SI (  i_get_art_field(g_iartout,$Tdpvgsm::tlserv)== 0x11) && (i_get_tab_field( GRETA, date_cra, str_idpart_ascii) != g_inull)
        ALORS
# 0200000F
          NumOfFilter = NumOfFilter + 0x000F
          trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

          SAUT TRAIT_NVDGSM
        FINSI
      FINSI

      # FILTRE_CB est vrai si V3t1.2 (tentite) == 0x0B
      SI FILTRE_CB == Oui
      ALORS
# 0200000E
        NumOfFilter = NumOfFilter + 0x000E
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_REJET_DISE
      FINSI

#G5R1lot2 C+S
#G5R1lot2 (chaque poste represente respectivement lenvoi des IMSI : ADV, DISE, FE, Come, TPE, VPN), 1_1_1_1_1_1
#                                                                     0     2    4    6    8    10 , 012345678910
      SI (i_strplcmp(pt_CodeTarifSVA, "G", 0, 1) == 0 && i_strplcmp(ptr_CetS_GRATUIT, "0", C_FiltreCetS_DISE, 1) == 0)
      ALORS
# 02000011
        NumOfFilter = NumOfFilter + 0x0011
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVDGSM
      FINSI

# hors criteres d'exclusion, DISE
      SAUT TRAIT_DISE

    FINSI

#-----------------------type_cra == 0x01 Entrant ----------------------------------------
#QC844
    SI (type_cra == 0x01)
    ALORS
      SI (i_get_art_field(g_iartout, $Tdpvgsm::origine) == 0x01)
      ALORS

        i_strcpy(str_IDEMET_CMM, i_get_tab_field("VariableContexte", date_cra, "FILTRE_IDEMET_CMM"))
        SI (i_strlen(str_IDEMET_CMM))
        ALORS
          SI(! i_strplcmp(str_idemet_ascii, str_IDEMET_CMM, 0, i_strlen(str_IDEMET_CMM)))
          ALORS
# 0201000F (hors spec)
            NumOfFilter = NumOfFilter + 0x000F
            trace1("<<<__LINE__<<<__FILE__<<< hors spec NumOfFilter=<0x%x>", NumOfFilter)

            SAUT TRAIT_NVDGSM
          FINSI
        FINSI
      FINSI

      SI (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x18)
      ALORS
        SAUT TRAIT_DISE
      FINSI
      # implicit le filtrage des CRA VPN Roaming Out
# 02010001
      NumOfFilter = NumOfFilter + 0x0001
      trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

      SAUT TRAIT_NVDGSM

    FINSI

#-----------------------type_cra == 0x02 Renvoim ----------------------------------------
    SI (type_cra == 0x02)
    ALORS

      SI  (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x32)
      ALORS
# 02020001
        NumOfFilter = NumOfFilter + 0x0001
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVDGSM
      FINSI

      erreur = i_format_str2(str_MADN,"%s%s","MADN_",str_local_ascii)

      SI (table_exp_reg_660004265(str_local_ascii, FILTRE_DISE_LOC , date_cra) == 1)
      ALORS
# 02020002
        NumOfFilter = NumOfFilter + 0x0002
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVDGSM
      FINSI

      SI (table_exp_reg_660004265(str_MADN, FILTRE_DISE_LOC , date_cra) == 1)
      ALORS
# 02020003
        NumOfFilter = NumOfFilter + 0x0003
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVDGSM
      FINSI

      i_strcpy(ptr_valHCE,i_get_tab_field("VariableContexte",date_cra,"AX_IDEMET_HCE"))
      SI(i_strplcmp(str_idemet_ascii, ptr_valHCE, 0, 11 ) == 0) && (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x03) && (i_strplcmp(str_local_ascii,"33", 0, 2) == 0)
      ALORS
# 02020004
        NumOfFilter = NumOfFilter + 0x0004
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVDGSM
      FINSI

      i_strcpy(ptr_valORLCF,i_get_tab_field("VariableContexte",date_cra,"AX_IDEMET_ORLCF"))
      SI(i_strplcmp(str_idemet_ascii, ptr_valORLCF, 0, 11 ) == 0) && (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x03) && (i_strplcmp(str_local_ascii,"33", 0, 2) == 0)
      ALORS
# 02020005
        NumOfFilter = NumOfFilter + 0x0005
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVDGSM
      FINSI

# hors criteres d'exclusion, DISE
      SAUT TRAIT_DISE

    FINSI

#-----------------------type_cra == 0x04 Reach ----------------------------------------
#QC844, QC874 suppression filtre 02040001
    SI (type_cra == 0x04)
    ALORS
      res = i_get_art_field (g_iartout, $Tdpvgsm::C_Key1)
      SI  ( res == 0x2B || res == 0x37 || res == 0x5F) && (i_strplcmp(pt_CAMEL_DEST_NUMBER,"33", 0, 2) == 0)
      ALORS
# 02040002
        NumOfFilter = NumOfFilter + 0x0002
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVDGSM
      FINSI

      SI (i_strplcmp(str_local_ascii,"33", 0, 2) == 0)
      ALORS
# 02040003
        NumOfFilter = NumOfFilter + 0x0003
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVDGSM
      FINSI

# hors criteres d'exclusion, DISE
      SAUT TRAIT_DISE

    FINSI

#-----------------------type_cra == 0x05 Renvrea ----------------------------------------
    SI (type_cra == 0x05)
    ALORS

      SI (i_strplcmp(str_local_ascii,"33", 0, 2) == 0)
      ALORS
# 02050001
        NumOfFilter = NumOfFilter + 0x0001
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVDGSM
      FINSI

# hors criteres d'exclusion, DISE
      SAUT TRAIT_DISE
    FINSI

#-----------------------type_cra == 0x06 renvoig----------------------------------------
    SI ((type_cra == 0x06))
    ALORS

      erreur = i_format_str2(str_MADN,"%s%s","MADN_",str_local_ascii)
      SI (table_exp_reg_660004265(str_local_ascii, FILTRE_DISE_LOC , date_cra) == 1)
      ALORS
# 02060001
        NumOfFilter = NumOfFilter + 0x0001
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVDGSM
      FINSI

      SI (table_exp_reg_660004265(str_MADN, FILTRE_DISE_LOC , date_cra) == 1)
      ALORS
# 02060002
        NumOfFilter = NumOfFilter + 0x0002
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVDGSM
      FINSI

      SI  (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x32)
      ALORS
# 02060003
        NumOfFilter = NumOfFilter + 0x0003
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVDGSM
      FINSI
#QC844
      SI (i_get_art_field(g_iartout, $Tdpvgsm::origine) == 0x01)
      ALORS
        i_strcpy(str_IDEMET_CMM, i_get_tab_field("VariableContexte", date_cra, "FILTRE_IDEMET_CMM"))
        SI (i_strlen(str_IDEMET_CMM))
        ALORS
          SI(! i_strplcmp(str_idemet_ascii, str_IDEMET_CMM, 0, i_strlen(str_IDEMET_CMM)))

          ALORS
# 02060004
            NumOfFilter = NumOfFilter + 0x0004
            trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

            SAUT TRAIT_NVDGSM
          FINSI
        FINSI
      FINSI

# hors criteres d'exclusion, DISE
      SAUT TRAIT_DISE

    FINSI

#-----------------------type_cra == 0xA0 VOIP ---------------------------------------------
###G5R1lot2 C+S correction spec
##    SI (type_cra == 0xA0)
##    ALORS
##
##      SI (i_strplcmp(pt_CodeTarifSVA, "G", 0, 1) == 0 && i_strplcmp(ptr_CetS_GRATUIT, "0", C_FiltreCetS_DISE, 1) == 0)
##      ALORS
### 02A00002
##        NumOfFilter = NumOfFilter + 0x0002
##        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
##
##        SAUT TRAIT_NVDGSM
##      FINSI
##    FINSI
###-----------------------type_cra == 0xAE VOIP ----------------------------------------------
###G5R1lot2 C+S correction spec
##    SI (type_cra == 0xAE)
##    ALORS
##
##      SI (i_strplcmp(pt_CodeTarifSVA, "G", 0, 1) == 0 && i_strplcmp(ptr_CetS_GRATUIT, "0", C_FiltreCetS_DISE, 1) == 0)
##      ALORS
### 02AE0002
##        NumOfFilter = NumOfFilter + 0x0002
##        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
##
##        SAUT TRAIT_NVDGSM
##      FINSI
##    FINSI
###-----------------------type_cra == 0xA6 usage TV ----------------------------------------
    SI (type_cra == 0xA6)
    ALORS
# 02A60001
      NumOfFilter = NumOfFilter + 0x0001
      trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
      SAUT TRAIT_REJET_DISE
    FINSI

#-----------------------type_cra == 0xA0, 0xAE, 0xAF, 0xA7 VOIP ----------------------------
    SI (type_cra == 0xA0) || (type_cra == 0xAE) || (type_cra == 0xAF) || (type_cra == 0xA7)
    ALORS
# 02xx0001
      NumOfFilter = NumOfFilter + 0x0001
      trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
      SAUT TRAIT_REJET_DISE
    FINSI

#-----------------------type_cra == 0x40 WHA, CB -------------------------------------------
    SI (type_cra == 0x40)
    ALORS

      # FILTRE_CB est faux si V3t1.2 (tentite) != 0x0B
      SI ( FILTRE_CB == Non &&  i_strcmp( i_get_tab_field("Wha_funcard", date_cra, str_idpart_ascii),"Tous") == 0 )
      ALORS
# 02400001
        NumOfFilter = NumOfFilter + 0x0001
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVDGSM
      FINSI

      i_strcpy (pt_MSP,"")
      erreur=i_format_str2(pt_MSP,"%s%s","DISE", str_idpart_ascii)
      SI (i_strcmp (i_get_tab_field("MSP_ARTIST_DISE", date_cra, pt_MSP),"Tous") == 0)
      ALORS
# 02400002
        NumOfFilter = NumOfFilter + 0x0002
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVDGSM
      FINSI

# hors criteres d'exclusion, DISE
      SAUT TRAIT_DISE

    FINSI

#-----------------------type_cra == 0x70 USSD ----------------------------------------------
    SI (type_cra == 0x70)
    ALORS

      SI (i_get_tab_field(IDPART_USSD, date_cra, str_idpart_ascii) == g_inull) && (i_get_tab_field(IDPART_USSD, date_cra, str_idpart_ascii_min) == g_inull)
      ALORS
# 02700001
        NumOfFilter = NumOfFilter + 0x0001
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVDGSM
      FINSI

# hors criteres d'exclusion, DISE
      SAUT TRAIT_DISE

    FINSI

#-----------------------type_cra == 0x80 Wlan ----------------------------------------------
    SI (type_cra == 0x80)
    ALORS

      # FILTRE_CB est vrai si V3t1.2 (tentite) == 0x0B
      SI (FILTRE_CB == Oui)
      ALORS
# 02800001
        NumOfFilter = NumOfFilter + 0x0001
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_REJET_DISE
      FINSI

# hors criteres d'exclusion, DISE
      SAUT TRAIT_DISE

    FINSI

#-----------------------type_cra == 0x90 Paquetterm ----------------------------------------------
    SI (type_cra == 0x90)
    ALORS

      SI ( (i_strplcmp(i_get_art_fieldptr(g_iartout, $Tdpvgsm::accPointName3),"orange.acte", 0, 11) == 0) ||
        (i_strplcmp(i_get_art_fieldptr(g_iartout, $Tdpvgsm::accPointName3),"orangevo.acte", 0, 13) == 0) ||
        (i_strplcmp(i_get_art_fieldptr(g_iartout, $Tdpvgsm::accPointName3),"cbil.acte", 0, 9) == 0) )
      ALORS
# 02900001
        NumOfFilter = NumOfFilter + 0x0001
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVDGSM
      FINSI


#/G3R3 2GDT

      SI (TYPE_GPRS_volNULL == Oui)
      ALORS
# 02900003
        NumOfFilter = NumOfFilter + 0x0003
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVDGSM
      FINSI
#G3R10 lot4 debut
      #i_get_sub_str(i_get_art_fieldptr(g_iartout, $Tdpvgsm::accPointName3),0, i_get_art_field(g_iartout, $Tdpvgsm::accPointName3-1)-1,str_accPointName3)
      #erreur = i_format_str2(str_ENTaccPointName3, "%s_%s", "ENT", str_accPointName3)
      #FILTRE_CB est vrai si V3t1.2 (tentite) == 0x0B

##G3R10 lot4 Suppression filtre 02900002
##G3R10 lot4 suppression filtre 02900004
##G3R10 lot4 suppression filtre 02900005
##G3R10 lot4 suppression filtre 02900006
##G3R10 lot4 suppression filtre 02900010
##G3R10 lot4 suppression filtre 02900007
##G3R10 lot4 suppression filtre 02900009
##G3R10 lot4 suppression filtre 0290000B
##G3R10 lot4 suppression filtre 0290000C
##G3R10 lot4 suppression filtre 0290000D
##G3R10 lot4 suppression filtre 0290000E
##G3R10 lot4 suppression filtre 02900011
##G3R10 lot4 suppression filtre 02900012
##G3R10 lot4 suppression filtre 02900013

      #i_strcpy (str_ENTaccPointName3,g_inull)
      #erreur = i_format_str2(str_ENTaccPointName3, "%s_%s", "MVNO", str_accPointName3)

      # FILTRE_CB est vrai si V3t1.2 (tentite) == 0x0B
      #G3R5 lot1 Facturation B2B du roaming MVNO prepaye via DCB suppression de la condition || MVNO_prepaid == Oui

#02900030 cration G3R10 lot4
      SI (TYPE_GPRS_SGSN == Oui || b_4GSgw == Oui)
      ALORS
        NumOfFilter = NumOfFilter + 0x0030
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_NVDGSM
      FINSI

#02900031 -> 02900043   V3t1.2 = 0B Et RINT Faux Et FRA_APN_TRT.3 = 0 (usage national et ZB)
      SI (FILTRE_CB == Oui &&  RINT_Roaming_International == Non && i_strplcmp(ptr_ResFRAAPNTRT, "0", C_FRA_APN_TRT3, 1) == 0)
      ALORS
        NumOfFilter = NumOfFilter + 0x0043
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_NVDGSM
      FINSI

#02900032 -> 02900044   V3t1.2 = 0B Et RINT Vrai Et FRA_APN_TRT.4 = 0
      SI (FILTRE_CB == Oui &&  RINT_Roaming_International == Oui && i_strplcmp(ptr_ResFRAAPNTRT, "0", C_FRA_APN_TRT4, 1) == 0)
      ALORS
        NumOfFilter = NumOfFilter + 0x0044
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_NVDGSM
      FINSI

#02900033 -> 02900041     V3t1.2 <> 0B Et RINT  Faux Et FRA_APN_TRT.1 = 0 (usage national et ZB)
      SI (FILTRE_CB == Non &&  RINT_Roaming_International == Non && i_strplcmp(ptr_ResFRAAPNTRT, "0", C_FRA_APN_TRT1, 1) == 0)
      ALORS
        NumOfFilter = NumOfFilter + 0x0041
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_NVDGSM
      FINSI

#02900034 -> 02900042  V3t1.2 <> 0B Et RINT Vrai Et FRA_APN_TRT.2 = 0
      SI (FILTRE_CB == Non &&  RINT_Roaming_International == Oui && i_strplcmp(ptr_ResFRAAPNTRT, "0", C_FRA_APN_TRT2, 1) == 0)
      ALORS
        NumOfFilter = NumOfFilter + 0x0042
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_NVDGSM
      FINSI
#G3R7 LTE Fin

# hors criteres d'exclusion, DISE
      SAUT TRAIT_DISE
    FINSI
# type = 0x91 => n'est plus recu par METEOR

#
##-----------------------type_cra == autres type de CRAs -----------------------------------------
# 02XX0201
    NumOfFilter = NumOfFilter + 0x0201
    trace1("<<<__LINE__<<<__FILE__<<< 1) pcode different de la spec NumOfFilter=<0x%x>", NumOfFilter)
    erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    ##SAUT TRAIT_REJET_DISE  on va vers TRAIT_DISE a contrario de la spec

    # tous les autres type de CRAs
    SI (TYPE_GPRS_GGSN == Oui || TYPE_GPRS_volNULL == Oui)
    ALORS
# 02XX0202
      NumOfFilter = NumOfFilter + 0x0202
      trace1("<<<__LINE__<<<__FILE__<<< 2) pcode different de la spec NumOfFilter=<0x%x>", NumOfFilter)

      SAUT TRAIT_NVDGSM
    FINSI


    #----------< ECC principale MSFGSM >----------------------------------------------------
    POINT TRAIT_DISE
    res = MiseAuFormat_Stockage_660004265("MSFGSM", instMSFGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI
    SAUT ECC_SECONDAIRES

    #----------< poubelle NVDGSM >----------------------------------------------------------
    POINT TRAIT_NVDGSM
#QC983
    SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
    ALORS
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    SINON
      SI Old_Family
      ALORS
        erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
      SINON
        erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
      FINSI
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    FINSI
#/QC983
    res = MiseAuFormat_Stockage_660004265("NVDGSM", instNVDGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI
    SAUT ECC_SECONDAIRES

    #----------< ECC REJET >----------------------------------------------------------------
    POINT TRAIT_REJET_DISE
#QC983
    SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
    ALORS
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    SINON
      SI Old_Family
      ALORS
        erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
      SINON
        erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
      FINSI
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    FINSI
#/QC983
    res = MiseAuFormat_Stockage_660004265("RJPGSM", instRJPGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI
    SAUT ECC_SECONDAIRES

  FINSI
#Fin DISE

# Debut FE
  #-----------------------------------------------------#
  #                 Flux FEGSM      filtre=03           #
  #                                                     #
  #-----------------------------------------------------#
  SI (instFEGSM == instIMSI)
  ALORS
    NumOfFilter = 0x03000000 + type_cra * 0x10000

############ Filtres communs a plusieurs types #############################################
    #-----------------------type_cra == Tous types ----------------------------------------
    SI (CRA_VPN == Oui)
    ALORS
# 03XX0101
      NumOfFilter = NumOfFilter + 0x0101
      trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

      SAUT TRAIT_REJET_FE
    FINSI

##-----------------------type_cra == 0x00, 0x02, 0x04, 0x05, 0x06, 0x80, 0x90, 0x11, 0x30---
#   SI (type_cra == 0x00 || type_cra == 0x02 || type_cra == 0x04 || type_cra == 0x05 || type_cra == 0x06 || type_cra == 0x80 || type_cra == 0x90 || type_cra == 0x11 || type_cra == 0x30)
#ALORS
#     SI (i_get_art_field(g_iartout, $Tdpvgsm::DUREE) == 0x00)
#ALORS
## 03XX0301
#       NumOfFilter = NumOfFilter + 0x0301
#       trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
#       SAUT TRAIT_NVDGSM_FE
#     FINSI
#   FINSI
############# Fin Filtres communs a plusieurs types ##########################################

# --------------- recuperation champ local  (T3t3)
    SI (i_valid_field_n(g_iartout, $Tdpvgsm::local))
    ALORS
      erreur = i_get_art_str(g_iartout, $Tdpvgsm::local, str_local_ascii)
    FINSI

#-----------------------type_cra == 0x00 sortant ----------------------------------------
#QC844
    SI (type_cra == 0x00)
    ALORS

      SI (i_get_art_field(g_iartout, $Tdpvgsm::origine) == 0x01)
      ALORS
        i_strcpy(str_IDEMET_CMM, i_get_tab_field("VariableContexte", date_cra, "FILTRE_IDEMET_CMM"))
        SI (i_strlen(str_IDEMET_CMM))
        ALORS
          SI(! i_strplcmp(str_idemet_ascii, str_IDEMET_CMM, 0, i_strlen(str_IDEMET_CMM)))
          ALORS
# 03000001
            NumOfFilter = NumOfFilter + 0x0001
            trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
            erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
            SAUT TRAIT_NVDGSM_FE
          FINSI
        FINSI
      FINSI

      SI ( (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x22) && (i_strplcmp(str_idpart_ascii, "3368900", 0, 7) == 0) )
      ALORS
# 03000002
        NumOfFilter = NumOfFilter + 0x0002
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVDGSM_FE
      FINSI

      SI ( (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x11) || (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x12) )
      ALORS
        # G5R2 lot2 : Item Filtrage cras reseau BIV application FE (rajout valeur 95=0x5F de CAMEL_KEY)
        res = i_get_art_field (g_iartout, $Tdpvgsm::C_Key1)
        SI ( res == 0x50 || res == 0x52  || res == 0x5F )
        ALORS
# 03000003
          NumOfFilter = NumOfFilter + 0x0003
          trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

          SAUT TRAIT_NVDGSM_FE
        FINSI
      FINSI

      SI ( (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x11) || (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x12) )
      ALORS
        res = i_get_art_field (g_iartout, $Tdpvgsm::C_Key1)
        SI ( res == 0x54 || res == 0x56 )
        ALORS
# 03000004
          NumOfFilter = NumOfFilter + 0x0004
          trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

          SAUT TRAIT_NVDGSM_FE
        FINSI
      FINSI

      SI  (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x32)
      ALORS
# 03000005
        NumOfFilter = NumOfFilter + 0x0005
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVDGSM_FE
      FINSI

      SI (i_get_art_field(g_iartout,$Tdpvgsm::tlserv)== 0x31 && i_get_art_field(g_iartout,$Tdpvgsm::occurenceNb)== 0x01)
      ALORS
# 03000006
        NumOfFilter = NumOfFilter + 0x0006
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVDGSM_FE
      FINSI

      date_table = 0
      i_strcpy(ptr_valeurDATE, i_get_tab_field("VariableContexte", date_cra, "DATE_MEP_PF_TN_KODIAK"))
      i_get_sub_str(ptr_valeurDATE,2,-1,ptr_date_res)
      erreur = i_set_art_str (g_iartout7,$Conv_URS::DATE,ptr_date_res)
      date_table = i_get_art_field(g_iartout7, $Conv_URS::DATEN)

      SI (((i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x33)||(i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x34)) && date_cra >= date_table)
      ALORS
# 03000007
        NumOfFilter = NumOfFilter + 0x0007
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVDGSM_FE
      FINSI

      SI (i_get_art_field(g_iartout,$Tdpvgsm::tlserv)== 0x11) && (i_get_tab_field( GRETA, date_cra, str_idpart_ascii) != g_inull)
      ALORS
# 03000008
        NumOfFilter = NumOfFilter + 0x0008
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVDGSM_FE
      FINSI
#QC844
      i_strcpy(str_IDEMET_CMM, i_get_tab_field("VariableContexte", date_cra, "FILTRE_IDEMET_CMM"))
      SI (i_strlen(str_IDEMET_CMM))
      ALORS
        SI(! i_strplcmp(str_idemet_ascii, str_IDEMET_CMM, 0, i_strlen(str_IDEMET_CMM)))
        ALORS
          SI (i_get_tab_field(GRETA, date_cra, str_idpart_ascii) != g_inull)
          ALORS
# 03000009
            NumOfFilter = NumOfFilter + 0x0009
            trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

            SAUT TRAIT_NVDGSM_FE
          FINSI
        FINSI
      FINSI

      erreur = i_get_art_str(g_iartout, $Tdpvgsm::idemet,ptr_Emettrice)
      erreur = i_get_art_str(g_iartout, $Tdpvgsm::idpart, ptr_advme)
      erreur = i_format_str2(ptr_advme_id,"%s%s","AVME_",ptr_advme)
      i_strcpy(ptr_valINCC,i_get_tab_field("VariableContexte",date_cra,"AX_IDEMET_INCC"))
      i_strcpy(ptr_valVPN,i_get_tab_field("VariableContexte",date_cra,"AX_IDEMET_VPN"))

      posINCC = RECHERCHE_CARACTERE_660004265(ptr_valINCC,"F")
      SI posINCC < 0
      ALORS
        posINCC = posINCC * (-1)
      FINSI
      posVPN = RECHERCHE_CARACTERE_660004265(ptr_valVPN,"F")
      SI posVPN < 0
      ALORS
        posVPN = posVPN * (-1)
      FINSI

      i_get_sub_str(ptr_valINCC,0,posINCC - 1,ptr_valINCC)
      i_get_sub_str(ptr_valVPN ,0,posVPN - 1,ptr_valVPN)

      SI (i_get_tab_field("IDPART", date_cra,ptr_advme_id)!= g_inull)
        && (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x11)
        && ( i_strcmp(ptr_valINCC,ptr_Emettrice)!=0)
        && (i_strcmp(ptr_valVPN,ptr_Emettrice)!= 0)
      ALORS
# 0300000A
        NumOfFilter = NumOfFilter + 0x000A
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVDGSM_FE
      FINSI

      # onlinePurUsFlag = V4t47.1, DUREE = V3t1.6
      SI (i_get_art_field(g_iartout, $Tdpvgsm::onlinePurUsFlag) == 0x3B) && (i_get_art_field(g_iartout, $Tdpvgsm::DUREE) == 0x00)
      ALORS
# 0300000B
        NumOfFilter = NumOfFilter + 0x000B
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVDGSM_FE
      FINSI

      # FILTRE_CB est vrai si V3t1.2 (tentite) == 0x0B
      SI FILTRE_CB == Oui
      ALORS
# 0300000C
        NumOfFilter = NumOfFilter + 0x000C
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_REJET_FE
      FINSI

#G5R1lot2 C+S
      SI (i_strplcmp(pt_CodeTarifSVA, "G", 0, 1) == 0 && i_strplcmp(ptr_CetS_GRATUIT, "0", C_FiltreCetS_FE, 1) == 0)
      ALORS
# 0300000D
        NumOfFilter = NumOfFilter + 0x000D
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVDGSM_FE
      FINSI

# hors criteres d'exclusion, FEGSM
      SAUT TRAIT_FE

    FINSI

#-----------------------type_cra == 0x02 Renvoim ----------------------------------------
    SI (type_cra == 0x02)
    ALORS

      erreur = i_format_str2(str_MADN,"%s%s","MADN_",str_local_ascii)

      SI (table_exp_reg_660004265 (str_local_ascii, FILTRE_DISE_LOC , date_cra) == 1)
      ALORS
# 03020001
        NumOfFilter = NumOfFilter + 0x0001
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVDGSM_FE
      FINSI

      SI (table_exp_reg_660004265 (str_MADN, FILTRE_DISE_LOC , date_cra) == 1)
      ALORS
# 03020002
        NumOfFilter = NumOfFilter + 0x0002
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVDGSM_FE
      FINSI

      i_strcpy(ptr_valHCE,i_get_tab_field("VariableContexte",date_cra,"AX_IDEMET_HCE"))
      SI(i_strplcmp(str_idemet_ascii, ptr_valHCE, 0, 11 ) == 0) && (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x03) && (i_strplcmp(str_local_ascii,"33", 0, 2) == 0)
      ALORS
# 03020003
        NumOfFilter = NumOfFilter + 0x0003
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVDGSM_FE
      FINSI

      i_strcpy(ptr_valORLCF,i_get_tab_field("VariableContexte",date_cra,"AX_IDEMET_ORLCF"))
      SI(i_strplcmp(str_idemet_ascii, ptr_valORLCF, 0, 11 ) == 0) && (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x03) && (i_strplcmp(str_local_ascii,"33", 0, 2) == 0)
      ALORS
# 03020004
        NumOfFilter = NumOfFilter + 0x0004
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVDGSM_FE
      FINSI

# hors criteres d'exclusion, FEGSM
      SAUT TRAIT_FE

    FINSI

#-----------------------type_cra == 0x04 Reach ----------------------------------------
#QC844, QC874 suppression filtre 02040001
    SI (type_cra == 0x04)
    ALORS

      res = i_get_art_field (g_iartout, $Tdpvgsm::C_Key1)
      SI  ( res == 0x2B || res == 0x37 || res == 0x5F) && (i_strplcmp(pt_CAMEL_DEST_NUMBER,"33", 0, 2) == 0)
      ALORS
# 03040002
        NumOfFilter = NumOfFilter + 0x0002
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVDGSM_FE
      FINSI

      SI (i_strplcmp(str_local_ascii,"33", 0, 2) == 0)
      ALORS
# 03040003
        NumOfFilter = NumOfFilter + 0x0003
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVDGSM_FE
      FINSI

# hors criteres d'exclusion, FEGSM
      SAUT TRAIT_FE

    FINSI

#-----------------------type_cra == 0x05 Renvrea ----------------------------------------
    SI (type_cra == 0x05)
    ALORS

      SI (i_strplcmp(str_local_ascii,"33", 0, 2) == 0)
      ALORS
# 03050001
        NumOfFilter = NumOfFilter + 0x0001
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVDGSM_FE
      FINSI

# hors criteres d'exclusion, FEGSM
      SAUT TRAIT_FE

    FINSI

#-----------------------type_cra == 0x06 Renvoig ----------------------------------------
    SI (type_cra == 0x06)
    ALORS

      erreur = i_format_str2(str_MADN,"%s%s","MADN_",str_local_ascii)

      SI (table_exp_reg_660004265 (str_local_ascii, FILTRE_DISE_LOC , date_cra) == 1)
      ALORS
# 03060001
        NumOfFilter = NumOfFilter + 0x0001
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVDGSM_FE
      FINSI

      SI (table_exp_reg_660004265 (str_MADN, FILTRE_DISE_LOC , date_cra) == 1)
      ALORS
# 03060002
        NumOfFilter = NumOfFilter + 0x0002
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVDGSM_FE
      FINSI

      SI  (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x32)
      ALORS
# 03060003
        NumOfFilter = NumOfFilter + 0x0003
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVDGSM_FE
      FINSI
#QC844
      SI (i_get_art_field(g_iartout, $Tdpvgsm::origine) == 0x01)
      ALORS
        i_strcpy(str_IDEMET_CMM, i_get_tab_field("VariableContexte", date_cra, "FILTRE_IDEMET_CMM"))
        SI (i_strlen(str_IDEMET_CMM))
        ALORS
          SI(! i_strplcmp(str_idemet_ascii, str_IDEMET_CMM, 0, i_strlen(str_IDEMET_CMM)))   ALORS
# 03060004
            NumOfFilter = NumOfFilter + 0x0004
            trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

            SAUT TRAIT_NVDGSM_FE
          FINSI
        FINSI
      FINSI

# hors criteres d'exclusion, FEGSM
      SAUT TRAIT_FE

    FINSI
#G3R3 lot2 Exhaustivite des cras pour FE

## Correction spec
###---------------------------type_cra = 0xA0 VOIP -------------------------------------------
##    SI (type_cra == 0xA0)
##    ALORS
###G5R1lot2 C+S
##      SI (i_strplcmp(pt_CodeTarifSVA, "G", 0, 1) == 0 && i_strplcmp(ptr_CetS_GRATUIT, "0", C_FiltreCetS_FE, 1) == 0)
##      ALORS
### 03A00001
##        NumOfFilter = NumOfFilter + 0x0001
##        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
##
##        SAUT TRAIT_NVDGSM_FE
##      FINSI
##    FINSI
###---------------------------type_cra = 0xAE VOIP -------------------------------------------
##    SI (type_cra == 0xAE)
##    ALORS
###G5R1lot2 C+S
##      SI (i_strplcmp(pt_CodeTarifSVA, "G", 0, 1) == 0 && i_strplcmp(ptr_CetS_GRATUIT, "0", C_FiltreCetS_FE, 1) == 0)
##      ALORS
### 03AE0001
##        NumOfFilter = NumOfFilter + 0x0001
##        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
##
##        SAUT TRAIT_NVDGSM_FE
##      FINSI
##    FINSI
##---------------------------type_cra = 0x40 WHA, CB -----------------------------------------
    SI (type_cra == 0x40)
    ALORS
# 03400001
      SI ( FILTRE_CB == Non &&  i_strcmp( i_get_tab_field("Wha_funcard", date_cra, str_idpart_ascii),"Tous") == 0 )
      ALORS
        NumOfFilter = NumOfFilter + 0x0001
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVDGSM_FE
      FINSI

      i_strcpy (pt_MSP,"")
      erreur=i_format_str2(pt_MSP,"%s%s","DISE", str_idpart_ascii)
      SI ( i_strcmp(i_get_tab_field("MSP_ARTIST_DISE",date_cra,pt_MSP),"Tous") == 0 )
      ALORS
        NumOfFilter = NumOfFilter + 0x0002
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVDGSM_FE
      FINSI

# hors criteres d'exclusion, FEGSM
      SAUT TRAIT_FE
    FINSI
#---------------------------type_cra = 0x70------------------------------------------------
    SI (type_cra == 0x70)
    ALORS
      SI (i_get_tab_field(IDPART_USSD, date_cra, str_idpart_ascii) == g_inull) && (i_get_tab_field(IDPART_USSD, date_cra, str_idpart_ascii_min) == g_inull)
      ALORS
        NumOfFilter = NumOfFilter + 0x0001
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVDGSM_FE
      FINSI

# hors criteres d'exclusion, FEGSM
      SAUT TRAIT_FE
    FINSI
#/G3R3 lot2 Exhaustivite des cras pour FE
#-----------------------type_cra == 0x80 Wlan ----------------------------------------------
    SI (type_cra == 0x80)
    ALORS

      # FILTRE_CB est vrai si V3t1.2 (tentite) == 0x0B
      SI (FILTRE_CB == Oui)
      ALORS
# 03800001
        NumOfFilter = NumOfFilter + 0x0001
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_REJET_FE
      FINSI

# hors criteres d'exclusion, FEGSM
      SAUT TRAIT_FE

    FINSI

#-----------------------type_cra == 0x90 Paquetterm ----------------------------------------------
    SI (type_cra == 0x90)
    ALORS

      SI ( (i_strplcmp(i_get_art_fieldptr(g_iartout, $Tdpvgsm::accPointName3),"orange.acte", 0, 11) == 0) ||
        (i_strplcmp(i_get_art_fieldptr(g_iartout, $Tdpvgsm::accPointName3),"orangevo.acte", 0, 13) == 0) ||
        (i_strplcmp(i_get_art_fieldptr(g_iartout, $Tdpvgsm::accPointName3),"cbil.acte", 0, 9) == 0) )
      ALORS
# 03900001
        NumOfFilter = NumOfFilter + 0x0001
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVDGSM_FE
      FINSI

##G3R10 lot4 suppression filtre 03900002
##suppression filtre 03900004
##suppression filtre 03900005
##suppression filtre 03900006
##suppression filtre 03900007
##suppression filtre 03900008
##suppression filtre 03900009
##suppression filtre 0390000A
##suppression filtre 0390000B
##suppression filtre 0390000C


      SI (TYPE_GPRS_volNULL == Oui)
      ALORS
# 03900003
        NumOfFilter = NumOfFilter + 0x0003
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT  TRAIT_NVDGSM_FE
      FINSI

#cration G3R10 lot4
#03900030
      SI (TYPE_GPRS_SGSN == Oui || b_4GSgw == Oui)
      ALORS
        NumOfFilter = NumOfFilter + 0x0030
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_NVDGSM_FE
      FINSI

#03900031 -> 03900043  V3t1.2 = 0B Et RINT Faux Et FRA_APN_TRT.3 = 0 (usage national et ZB)
      SI (FILTRE_CB == Oui &&  RINT_Roaming_International == Non && i_strplcmp(ptr_ResFRAAPNTRT, "0", C_FRA_APN_TRT3, 1) == 0)
      ALORS
        NumOfFilter = NumOfFilter + 0x0043
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_NVDGSM_FE
      FINSI

#03900032 -> 03900044   V3t1.2 = 0B Et RINT Vrai Et FRA_APN_TRT.4 = 0
      SI (FILTRE_CB == Oui &&  RINT_Roaming_International == Oui && i_strplcmp(ptr_ResFRAAPNTRT, "0", C_FRA_APN_TRT4, 1) == 0)
      ALORS
        NumOfFilter = NumOfFilter + 0x0044
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_NVDGSM_FE
      FINSI

#03900033 -> 03900041    V3t1.2 <> 0B Et RINT  Faux Et FRA_APN_TRT.1 = 0 (usage national et ZB)
      SI (FILTRE_CB == Non &&  RINT_Roaming_International == Non && i_strplcmp(ptr_ResFRAAPNTRT, "0", C_FRA_APN_TRT1, 1) == 0)
      ALORS
        NumOfFilter = NumOfFilter + 0x0041
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_NVDGSM_FE
      FINSI

#03900034 -> 03900042  V3t1.2 <> 0B Et RINT Vrai Et FRA_APN_TRT.2 = 0
      SI (FILTRE_CB == Non &&  RINT_Roaming_International == Oui && i_strplcmp(ptr_ResFRAAPNTRT, "0", C_FRA_APN_TRT2, 1) == 0)
      ALORS
        NumOfFilter = NumOfFilter + 0x0042
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_NVDGSM_FE
      FINSI

#G3R7 LTE Fin
# hors criteres d'exclusion, FEGSM
      SAUT TRAIT_FE

    FINSI

#QC281
# type = 0x91 => n'est plus recu par METEOR

##-----------------------type_cra == 0x11 ou 0x30 ----------------------------------------------
##   SAUT TRAIT_FE implicite, le point TRAIT_FE est directement apres "autres types"

#-----------------------type_cra == autres type de CRAs -----------------------------------------
#QC854 modification exhaustivite des cras vers FE, suppression du cas type_cra != 0x50
# type = 0x91 => n'est plus recu par METEOR
    SI  (type_cra != 0x00 && type_cra != 0x02 && type_cra != 0x04
      && type_cra != 0x05 && type_cra != 0x06 && type_cra != 0x11
      && type_cra != 0x20 && type_cra != 0x22 && type_cra != 0x23
      && type_cra != 0x24 && type_cra != 0x25 && type_cra != 0x26
      && type_cra != 0x30 && type_cra != 0x40 && type_cra != 0x70
      && type_cra != 0x80 && type_cra != 0x90)
    ALORS
# 03XX0201
      NumOfFilter = NumOfFilter + 0x0201
      trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

      SAUT TRAIT_REJET_FE
    FINSI


    #----------< duplication des flux FE vers DISE - ECC principales FEGSM et MSFGSM>-------------------------------------------
    POINT TRAIT_FE

    res = MiseAuFormat_Stockage_660004265("FEGSM", instFEGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI
#------------------------------------------------------------------
#G3R9 Lot2 COME modification des criteres de duplication vers DISE
# si sysfact == 16 dupl vers DISE (FE_DISE == Oui)
# si sysfact == 40 dupl vers FRCOME (FEElligible == Oui)
#-------------------------------------------------------------------

    SI (FEElligible == Oui)
    ALORS
      res = MiseAuFormat_Stockage_660004265("FRCGSM", instFRCGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    SINON
      res = MiseAuFormat_Stockage_660004265("MSFGSM", instMSFGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI

    SAUT ECC_SECONDAIRES

    #----------< poubelle NVDGSM >----------------------------------------------------------
    POINT TRAIT_NVDGSM_FE
#QC983
    SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
    ALORS
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    SINON
      SI Old_Family
      ALORS
        erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
      SINON
        erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
      FINSI
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    FINSI
#/QC983


    res = MiseAuFormat_Stockage_660004265("NVDGSM", instNVDGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI
    SAUT ECC_SECONDAIRES

    #----------< poubelle RJPGSM >----------------------------------------------------------
    POINT TRAIT_REJET_FE
#QC983
    SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
    ALORS
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    SINON
      SI Old_Family
      ALORS
        erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
      SINON
        erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
      FINSI
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    FINSI
#/QC983
    res = MiseAuFormat_Stockage_660004265("RJPGSM", instRJPGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI
    SAUT ECC_SECONDAIRES

  FINSI
# Fin FEGSM


#====================================================================================================#
  #------------------------------------------------------------------#
  # flux COMESI   filtre 0x09
  # COMGSM, FRCGSM
  #------------------------------------------------------------------#
#======================================================================================================#

  SI (COMESI == Oui)
  ALORS
    SI (COME == Oui)
    ALORS
      NumOfFilter = 0x09000000 + type_cra * 0x10000
    SINON
      NumOfFilter = 0x0A000000 + type_cra * 0x10000
    FINSI
    ############ Filtres communs a plusieurs types #############################################
    #-----------------------type_cra == Tous types ----------------------------------------
    SI (CRA_VPN == Oui)
    ALORS
# 09XX0101 ou 0AXX0101
      NumOfFilter = NumOfFilter + 0x0101
      trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
      SAUT TRAIT_REJET_COMESI
    FINSI

    #-----------------------type_cra == 0x00 sortant ----------------------------------------
#QC844
    SI (type_cra == 0x00)
    ALORS

      SI (i_get_art_field(g_iartout, $Tdpvgsm::origine) == 0x01)
      ALORS
        i_strcpy(str_IDEMET_CMM, i_get_tab_field("VariableContexte", date_cra, "FILTRE_IDEMET_CMM"))
        SI (i_strlen(str_IDEMET_CMM))
        ALORS

          SI(! i_strplcmp(str_idemet_ascii, str_IDEMET_CMM, 0, i_strlen(str_IDEMET_CMM)))
          ALORS
# 09000002 ou 0A000002
            NumOfFilter = NumOfFilter + 0x0002
            trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
            SAUT TRAIT_NVCGSM
          FINSI
        FINSI
      FINSI

      SI ( (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x22) && (i_strplcmp(str_idpart_ascii, "3368900", 0, 7) == 0) )
      ALORS
# 09000003 ou 0A000003
        NumOfFilter = NumOfFilter + 0x0003
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_NVCGSM
      FINSI

      SI ( (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x11) || (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x12) )
      ALORS
        res = i_get_art_field (g_iartout, $Tdpvgsm::C_Key1)
        # 0x50=80, 0x52=82
        SI ( res == 0x50 || res == 0x52 )
        ALORS
# 09000004 ou 0A000004
          NumOfFilter = NumOfFilter + 0x0004
          trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
          SAUT TRAIT_NVCGSM
        FINSI
      FINSI

      SI ( (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x11) || (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x12) )
      ALORS
        res = i_get_art_field (g_iartout, $Tdpvgsm::C_Key1)
        # 0x54=84, 0x56=86
        SI ( res == 0x54 || res== 0x56 )
        ALORS
# 09000005 ou 0A000005
          NumOfFilter = NumOfFilter + 0x0005
          trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
          SAUT TRAIT_NVCGSM
        FINSI
      FINSI

      SI  (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x11)
      ALORS
# 09000006 ou 0A000006
        SI i_valid_field_n(g_iartout,$Tdpvgsm::idpart)
        ALORS
          erreur = i_get_art_str(g_iartout, $Tdpvgsm::idpart, ptr_advme)
          SI (i_get_tab_field("GRETA_TAG", date_cra, ptr_advme)!= g_inull)
          ALORS
            NumOfFilter = NumOfFilter + 0x0006
            trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
            SAUT TRAIT_NVCGSM
          FINSI
        FINSI
      FINSI

      i_strcpy(str_IDEMET_CMM, i_get_tab_field("VariableContexte", date_cra, "FILTRE_IDEMET_CMM"))
      SI (i_strlen(str_IDEMET_CMM))
      ALORS
        SI(! i_strplcmp(str_idemet_ascii, str_IDEMET_CMM, 0, i_strlen(str_IDEMET_CMM)))
        ALORS
          SI (i_get_tab_field(GRETA, date_cra, str_idpart_ascii) != g_inull)
          ALORS
# 09000007 ou 0A000007
            NumOfFilter = NumOfFilter + 0x0007
            trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
            SAUT TRAIT_NVCGSM
          FINSI
        FINSI
      FINSI

      erreur = i_get_art_str(g_iartout, $Tdpvgsm::idemet,ptr_Emettrice)
      erreur = i_get_art_str(g_iartout, $Tdpvgsm::idpart, ptr_advme)
      erreur = i_format_str2(ptr_advme_id,"%s%s","AVME_",ptr_advme)
      i_strcpy(ptr_valINCC,i_get_tab_field("VariableContexte",date_cra,"AX_IDEMET_INCC"))
      # dans la table VariableContexte : AX_IDEMET_VPN;33007000000FFFFFFF
      i_strcpy(ptr_valVPN,i_get_tab_field("VariableContexte",date_cra,"AX_IDEMET_VPN"))
      posINCC = RECHERCHE_CARACTERE_660004265(ptr_valINCC,"F")

      SI posINCC < 0
      ALORS
        posINCC = posINCC * (-1)
      FINSI
      posVPN = RECHERCHE_CARACTERE_660004265(ptr_valVPN,"F")

      SI posVPN < 0
      ALORS
        posVPN = posVPN * (-1)
      FINSI

      i_get_sub_str(ptr_valINCC,0,posINCC - 1,ptr_valINCC)
      i_get_sub_str(ptr_valVPN ,0,posVPN - 1,ptr_valVPN)

      SI (i_get_tab_field("IDPART", date_cra,ptr_advme_id)!= g_inull)
        && (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x11)
        && ( i_strcmp(ptr_valINCC,ptr_Emettrice)!=0)
        && (i_strcmp(ptr_valVPN,ptr_Emettrice)!= 0)
      ALORS
#09000008 ou 0A000008
        NumOfFilter = NumOfFilter + 0x0008
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_NVCGSM
      FINSI

      SI (i_get_art_field(g_iartout, $Tdpvgsm::onlinePurUsFlag) == 0x3B) && (i_get_art_field(g_iartout, $Tdpvgsm::DUREE) == 0x00)
      ALORS
#09000009 ou 0A000009
        NumOfFilter = NumOfFilter + 0x0009
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVCGSM
      FINSI

      SI (i_strcmp(str_idpart_ascii,g_inull) != 0)
      ALORS
        erreur = i_format_str2(str_RVMV ,"%s%s","RVMV_",str_idpart_ascii)
        SI ( table_exp_reg_660004265(str_RVMV, FILTRE_DISE_LOC , date_cra) == 1)
        ALORS
#09000010 ou 0A000010
          NumOfFilter = NumOfFilter + 0x0010
          trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
          erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
          SAUT TRAIT_NVCGSM
        FINSI
      FINSI

      # FILTRE_CB est vrai si V3t1.2 (tentite) == 0x0B
      SI FILTRE_CB == Oui
      ALORS
#09000011 ou 0A000011
        NumOfFilter = NumOfFilter + 0x0011
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_REJET_COMESI
      FINSI

#G5R1lot2 C+S
      SI (i_strplcmp(pt_CodeTarifSVA, "G", 0, 1) == 0 && i_strplcmp(ptr_CetS_GRATUIT, "0", C_FiltreCetS_COME, 1) == 0)
      ALORS
# 09000012 ou 0A000012
        NumOfFilter = NumOfFilter + 0x0012
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVCGSM
      FINSI

      SAUT TRAIT_COMSI
    FINSI

#0x01
    SI (type_cra == 0x01)
    ALORS
#09010012 ou 0A010012
      NumOfFilter = NumOfFilter + 0x0012
      trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
      SAUT TRAIT_NVCGSM
    FINSI
#0x02
    SI (type_cra == 0x02)
    ALORS
      SI (table_exp_reg_660004265(str_local_ascii, FILTRE_DISE_LOC , date_cra) == 1)
      ALORS
#09020013 ou 0A020013
        NumOfFilter = NumOfFilter + 0x0013
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVCGSM
      FINSI

      i_strcpy(ptr_valHCE,i_get_tab_field("VariableContexte",date_cra,"AX_IDEMET_HCE"))
      SI(i_strplcmp(str_idemet_ascii, ptr_valHCE, 0, 11 ) == 0) && (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x03) && (i_strplcmp(str_local_ascii,"33", 0, 2) == 0)
      ALORS
# 09020014 ou 0A020014
        NumOfFilter = NumOfFilter + 0x0014
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_NVCGSM
      FINSI

      i_strcpy(ptr_valORLCF,i_get_tab_field("VariableContexte",date_cra,"AX_IDEMET_ORLCF"))
      SI(i_strplcmp(str_idemet_ascii, ptr_valORLCF, 0, 11 ) == 0) && (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x03) && (i_strplcmp(str_local_ascii,"33", 0, 2) == 0)
      ALORS
# 09020015 ou 0A020015
        NumOfFilter = NumOfFilter + 0x0015
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVCGSM
      FINSI
      SAUT TRAIT_COMSI

    FINSI

#0x04 
# QC874 suppression filtre 09040016 ou 0A040016
    SI (type_cra == 0x04)
    ALORS

      res = i_get_art_field (g_iartout, $Tdpvgsm::C_Key1)
      SI  ( res == 0x2B || res == 0x37 || res == 0x5F) && (i_strplcmp(pt_CAMEL_DEST_NUMBER,"33", 0, 2) == 0)
      ALORS
# 09040018 ou 0A040017
        NumOfFilter = NumOfFilter + 0x0017
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_NVCGSM
      FINSI

      SI (i_strplcmp(str_local_ascii,"33", 0, 2) == 0)
      ALORS
# 09040018 ou 0A040018
        NumOfFilter = NumOfFilter + 0x0018
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_NVCGSM
      FINSI

      SAUT TRAIT_COMSI
    FINSI
#0x05
    SI (type_cra == 0x05)
    ALORS
      SI (i_strplcmp(str_local_ascii,"33", 0, 2) == 0)
      ALORS
# 09050019 ou 0A050019
        NumOfFilter = NumOfFilter + 0x0019
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_NVCGSM
      FINSI
      SAUT TRAIT_COMSI
    FINSI
#0x06
    SI (type_cra == 0x06)
    ALORS
      SI (table_exp_reg_660004265(str_local_ascii, FILTRE_DISE_LOC , date_cra) == 1)
      ALORS
# 09060020 ou 0A060020
        NumOfFilter = NumOfFilter + 0x0020
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_NVCGSM
      FINSI

      SI (i_get_art_field(g_iartout, $Tdpvgsm::origine) == 0x01)
      ALORS
        i_strcpy(str_IDEMET_CMM, i_get_tab_field("VariableContexte", date_cra, "FILTRE_IDEMET_CMM"))
        SI (i_strlen(str_IDEMET_CMM))
        ALORS
          SI(! i_strplcmp(str_idemet_ascii, str_IDEMET_CMM, 0, i_strlen(str_IDEMET_CMM)))
          ALORS
# 09060021 ou 0A060021
            NumOfFilter = NumOfFilter + 0x0021
            trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
            SAUT TRAIT_NVCGSM
          FINSI
        FINSI
      FINSI

      SAUT TRAIT_COMSI
    FINSI

#0xA0 Corrections spec
##    #-----------------------type_cra == 0xA0 VOIP -------------------------------------------
##    SI (type_cra == 0xA0)
##    ALORS
###G5R1lot2 C+S
##      SI (i_strplcmp(pt_CodeTarifSVA, "G", 0, 1) == 0 && i_strplcmp(ptr_CetS_GRATUIT, "0", C_FiltreCetS_COME, 1) == 0)
##      ALORS
### 09A00024 ou 0AA00024
##        NumOfFilter = NumOfFilter + 0x0024
##        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
##
##        SAUT TRAIT_NVCGSM
##      FINSI
##    FINSI
###0xAE
##    #-----------------------type_cra == 0xAE VOIP -------------------------------------------
##    SI (type_cra == 0xAE)
##    ALORS
###G5R1lot2 C+S
##      SI (i_strplcmp(pt_CodeTarifSVA, "G", 0, 1) == 0 && i_strplcmp(ptr_CetS_GRATUIT, "0", C_FiltreCetS_COME, 1) == 0)
##      ALORS
### 09AE0024 ou 0AAE0024
##        NumOfFilter = NumOfFilter + 0x0024
##        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
##
##        SAUT TRAIT_NVCGSM
##      FINSI
##    FINSI
###0xA6
    #-----------------------type_cra == 0xA6 usage TV ----------------------------------------
    SI (type_cra == 0xA6)
    ALORS
# 09A60022 ou 0AA60022
      NumOfFilter = NumOfFilter + 0x0022
      trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
      SAUT TRAIT_REJET_COMESI
    FINSI

    #-----------------------type_cra == 0xA0, 0xAE, 0xAF, 0xA7 VOIP ----------------------------
    SI (type_cra == 0xA0) || (type_cra == 0xAE) || (type_cra == 0xAF) || (type_cra == 0xA7)
    ALORS
#09XX0023 ou 0AXX0023
      NumOfFilter = NumOfFilter + 0x0023
      trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
      SAUT TRAIT_REJET_COMESI
    FINSI

#0x30(MMS)
    SI (type_cra == 0x30)
    ALORS
      SI (IND_EFF != 0x00)
      ALORS
# 09300024 ou 0A300024
        NumOfFilter = NumOfFilter + 0x0024
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_NVCGSM
      FINSI
      SAUT TRAIT_COMSI
    FINSI

#-------------------type_cra == 0x40 WHA --------------------------

    SI (type_cra == 0x40)
    ALORS
      SI ( FILTRE_CB == Non &&  i_strcmp( i_get_tab_field("Wha_funcard", date_cra, str_idpart_ascii),"Tous") == 0 )
      ALORS
# 09400025 ou 0A400025
        NumOfFilter = NumOfFilter + 0x0025
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_NVCGSM
      FINSI

      erreur = i_format_str2(str_COMESI,"%s%s","COME",str_idpart_ascii)
      SI (i_get_tab_field("MSP_ARTIST_DISE", date_cra, str_COMESI) != g_inull)
      ALORS
# 09400026 ou 0A400026
        NumOfFilter = NumOfFilter + 0x0026
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_NVCGSM
      FINSI
      SAUT TRAIT_COMSI
    FINSI


#-----------------------type_cra == 0x70 USSD ----------------------------------------------
    SI (type_cra == 0x70)
    ALORS
      SI (i_get_tab_field(IDPART_USSD, date_cra, str_idpart_ascii) == g_inull) && (i_get_tab_field(IDPART_USSD, date_cra, str_idpart_ascii_min) == g_inull)
      ALORS
# 09700027 ou 0A700027
        NumOfFilter = NumOfFilter + 0x0027
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_NVCGSM
      FINSI

# hors criteres d'exclusion, DISE
      SAUT TRAIT_COMSI
    FINSI

#------------------type cra == 0X80(Wlan)-----------------------------------------------
    SI (type_cra == 0x80)
    ALORS

      # FILTRE_CB est vrai si V3t1.2 (tentite) == 0x0B
      SI (FILTRE_CB == Oui)
      ALORS
# 09800028 ou 0A800028
        NumOfFilter = NumOfFilter + 0x0028
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_REJET_COMESI
      FINSI

      SAUT TRAIT_COMSI
    FINSI

#--------------type cra == 0X90(Paquetterm)--------------------------------------------
    SI (type_cra == 0x90)
    ALORS
      SI ( (i_strplcmp(i_get_art_fieldptr(g_iartout, $Tdpvgsm::accPointName3),"orange.acte", 0, 11) == 0) ||
        (i_strplcmp(i_get_art_fieldptr(g_iartout, $Tdpvgsm::accPointName3),"orangevo.acte", 0, 13) == 0) ||
        (i_strplcmp(i_get_art_fieldptr(g_iartout, $Tdpvgsm::accPointName3),"cbil.acte", 0, 9) == 0) )
      ALORS
# 09900029 ou 0A900029
        NumOfFilter = NumOfFilter + 0x0029
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_NVCGSM
      FINSI

      SI (TYPE_GPRS_volNULL == Oui)
      ALORS
# 09900030 ou 0A900030
        NumOfFilter = NumOfFilter + 0x0030
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_NVCGSM
      FINSI

      i_get_sub_str(i_get_art_fieldptr(g_iartout, $Tdpvgsm::accPointName3),0, i_get_art_field(g_iartout, $Tdpvgsm::accPointName3-1)-1,str_accPointName3)
      erreur = i_format_str2(str_ENTaccPointName3, "%s_%s", "ENT", str_accPointName3)

##G3R10 Lot4 suppression de filtre
##suppression de filtre09\0A900031
##suppression de filtre09\0A900032
##suppression de filtre09\0A900033
##suppression de filtre09\0A900034
##suppression de filtre09\0A900035
##suppression de filtre09\0A900036
##suppression de filtre09\0A900037
##suppression de filtre09\0A900038
##suppression de filtre09\0A900039

#cration fltres G3R10 lot4
#09900040 ou 0A900040
      SI (TYPE_GPRS_SGSN == Oui || b_4GSgw == Oui)
      ALORS
        NumOfFilter = NumOfFilter + 0x0040
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_NVCGSM
      FINSI

#09900041 -> 09900043 ou 0A900043  V3t1.2 = 0B Et RINT Faux Et FRA_APN_TRT.3 = 0 (usage national et ZB)
      SI (FILTRE_CB == Oui &&  RINT_Roaming_International == Non && i_strplcmp(ptr_ResFRAAPNTRT, "0", C_FRA_APN_TRT3, 1) == 0)
      ALORS
        NumOfFilter = NumOfFilter + 0x0043
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_NVCGSM
      FINSI

#09900042 -> 09900044 ou 0A900044  V3t1.2 = 0B Et RINT Vrai Et FRA_APN_TRT.4 = 0
      SI (FILTRE_CB == Oui &&  RINT_Roaming_International == Oui && i_strplcmp(ptr_ResFRAAPNTRT, "0", C_FRA_APN_TRT4, 1) == 0)
      ALORS
        NumOfFilter = NumOfFilter + 0x0044
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_NVCGSM
      FINSI

#09900043 -> 09900041 ou 0A900041    V3t1.2 <> 0B Et RINT  Faux Et FRA_APN_TRT.1 = 0 (usage national et ZB)
      SI (FILTRE_CB == Non &&  RINT_Roaming_International == Non && i_strplcmp(ptr_ResFRAAPNTRT, "0", C_FRA_APN_TRT1, 1) == 0)
      ALORS
        NumOfFilter = NumOfFilter + 0x0041
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_NVCGSM
      FINSI

#09900044 -> 09900042 ou 0A900042  V3t1.2 <> 0B Et RINT Vrai Et FRA_APN_TRT.2 = 0
      SI (FILTRE_CB == Non &&  RINT_Roaming_International == Oui && i_strplcmp(ptr_ResFRAAPNTRT, "0", C_FRA_APN_TRT2, 1) == 0)
      ALORS
        NumOfFilter = NumOfFilter + 0x0042
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_NVCGSM
      FINSI

      SAUT TRAIT_COMSI
    FINSI

    #----------< ECC principale COMSI >----------------------------------------------------
    POINT TRAIT_COMSI
    SI (COME == Oui)
    ALORS
      res = MiseAuFormat_Stockage_660004265("COMGSM", instCOMGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
      SAUT ECC_SECONDAIRES
    SINON
      res = MiseAuFormat_Stockage_660004265("FRCGSM", instFRCGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
      SAUT ECC_SECONDAIRES
    FINSI

    #----------< poubelle NVCGSM >----------------------------------------------------------
    POINT TRAIT_NVCGSM
#QC983
    SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
    ALORS
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    SINON
      SI Old_Family
      ALORS
        erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
      SINON
        erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
      FINSI
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    FINSI
#/QC983
    res = MiseAuFormat_Stockage_660004265("NVCGSM", instNVCGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI
    SAUT ECC_SECONDAIRES

    #----------< ECC REJET >----------------------------------------------------------------
    POINT TRAIT_REJET_COMESI
#QC983
    SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
    ALORS
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    SINON
      SI Old_Family
      ALORS
        erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
      SINON
        erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
      FINSI
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    FINSI
#/QC983
    res = MiseAuFormat_Stockage_660004265("RJPGSM", instRJPGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI
    SAUT ECC_SECONDAIRES
  FINSI
# Fin COMSI*******************************************


  #--------------------------5.2.1.1--------------------------------------#
  #                          ADV      filtre 0x06
  #  VDI, OR5, OLA, OL2, OL3
  #-----------------------------------------------------------------------#
  SI (  (instVDIGSM == instIMSI) || (instOR5GSM == instIMSI) ||
    (instOLAGSM == instIMSI) || (instOL2GSM == instIMSI) || (instOL3GSM == instIMSI) )
  ALORS
    NumOfFilter = 0x06000000 + type_cra * 0x10000

    #G5R2 lot1
    SI (i_strplcmp(i_get_tab_field(Activation,date_cra,"ACTIV_AP"),"Actif", 0, 5) == 0)
    ALORS
      ACTIV_AP = 1
    FINSI
    trace1("<<<__LINE__<<<__FILE__<<< ACTIV_AP = <%d>", ACTIV_AP)

    SI (ACTIV_AP == 1)
    ALORS
      SI (!i_valid_field_n(g_iartout, $Tdpvgsm::CodeTarifSVA))
      ALORS
        #G5R2 lot1
        SI ( type_cra == 0x00 && i_strcmp(pt_NumPart,"") && i_get_art_field(g_iartout,$Tdpvgsm::tlserv) != 0x22 && i_get_art_field(g_iartout,$Tdpvgsm::tlserv) != 0x31 )
          || ( (type_cra == 0x04 || type_cra == 0x08) && i_strcmp(pt_NumPart,"") )
          || ( type_cra != 0x00 && type_cra != 0x04 && type_cra != 0x08 && (i_valid_field_n(g_iartout, $Tdpvgsm::TypeEditeurSVA)) && i_strcmp(pt_NumPart,"") )
        ALORS
          long = i_conv_ascii_dcb(pt_NumPart, pt_Buffer)
          erreur = i_EnvoiReqConsTabDist(TD_SVA, gmt_date_cra, pt_Buffer, long, 0, 1 )
          SI (!erreur)
          ALORS
            erreur = i_LireReqConsTabDist()
            SI (erreur)
            ALORS
              SAUT FIN_SVA_3
            FINSI
            res = i_LireInfoECC(instAlice, 0)
            SI (res)
            ALORS
              erreur = i_LireChaineInfo( res, 0, 4, pt_CodeTarifSVA)
              erreur = i_LireChaineInfo( res, 4, 1, pt_TypeEditeurSVA)
              #        trace2("<<<__LINE__<<<__FILE__<< IC de ALICE pt_TypeEditeurSVA=<%s>, pt_CodeTarifSVA=<%s>", pt_TypeEditeurSVA, pt_CodeTarifSVA)
              SI (!erreur)
              ALORS
                SI (i_strplcmp(pt_CodeTarifSVA, "A", 1, 1) == 0)
                ALORS
                  b_mapTarif_AP = 1
                FINSI
                trace1("<<<__LINE__<<<__FILE__<<< b_mapTarif_AP = <%d>", b_mapTarif_AP)
                SI (b_mapTarif_AP == 1)
                ALORS
                  #QC1428
                  SI Old_Family
                  ALORS
                    SI (!i_valid_field_n(g_iartout, $Tdpvgsm::TypeEditeurSVA))
                    ALORS
                      erreur = i_ajout_tlv(g_iartout, "T3t72", "TypeEditeurSVA")
                      erreur = i_set_art_str(g_iartout, $Tdpvgsm::TypeEditeurSVA, pt_TypeEditeurSVA)
                    FINSI
                    erreur = i_ajout_tlv(g_iartout, "T3t73", "CodeTarifSVA")
                  SINON
                    SI (!i_valid_field_n(g_iartout, $Tdpvgsm::TypeEditeurSVA))
                    ALORS
                      erreur = i_ajoutChamp(g_iartout, "T3t72", "TypeEditeurSVA",1)
                      erreur = i_set_art_str(g_iartout, $Tdpvgsm::TypeEditeurSVA, pt_TypeEditeurSVA)
                    FINSI
                    erreur = i_ajoutChamp(g_iartout, "T3t73", "CodeTarifSVA",1)
                  FINSI
                  #/QC1428
                  erreur = i_set_art_str(g_iartout, $Tdpvgsm::CodeTarifSVA, pt_CodeTarifSVA)
                FINSI
              FINSI
            FINSI
          FINSI
        FINSI
      FINSI

      POINT FIN_SVA_3

      # CetS_GRATUIT apres interrogation du referentiel ALICE
      # chaque poste represente respectivement envoi des IMSI : ADV, DISE, FE, Come, TPE, VPN), 1_1_1_1_1_1
      #                                                          0     2    4    6    8    10 , 012345678910
      SI (i_strcmp(pt_CodeTarifSVA, "") != 0)
      ALORS
        erreur = i_format_str2(pt_cle,"%s%s","CetS_GRATUIT_",pt_CodeTarifSVA)
        i_strcpy(ptr_CetS_GRATUIT, i_get_tab_field("VariableContexte", date_cra, pt_cle))
      FINSI

      SI (i_strcmp(ptr_CetS_GRATUIT, "") == 0)
      ALORS
        ## pas de reponse donc pas de filtre = tout a 1
        i_strcpy(ptr_CetS_GRATUIT, "1_1_1_1_1_1")
        #trace2("<<__LINE__>> ================ ptr_CetS_GRATUIT, valeur par defaut tout a 1 = <%s> ===================",ptr_CetS_GRATUIT,"")
      FINSI

    FINSI

    SI (CRA_VPN == Oui)
    ALORS
# 06XX0102
      NumOfFilter = NumOfFilter + 0x0102
      trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
#QC983
      SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
      ALORS
        erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
      SINON
        SI Old_Family
        ALORS
          erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
        SINON
          erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
        FINSI
        erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
      FINSI
#/QC983
      SAUT TRAI_RJPGSM
    FINSI

    SI (i_valid_field_n(g_iartout, $Tdpvgsm::local))
    ALORS
      erreur = i_get_art_str(g_iartout, $Tdpvgsm::local, str_local_ascii)
      trace2("str_local_ascii = <%s>", str_local_ascii, "")
    FINSI

    #---------------------------------------------------------------#
    #   V3T1.2 (tentite) = 0x0B et V4T39.9 (flagPitOut) <> 1  #
    #---------------------------------------------------------------#
    SI (FILTRE_CB == Oui) && (i_get_art_field(g_iartout, $Tdpvgsm::flagPitOut) != 0x01)
    ALORS
# 06XX0101
      NumOfFilter = NumOfFilter + 0x0101
      trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

      SAUT TRAIT_NVAGSM
    FINSI

    SI (type_cra == 0x00)
    ALORS

      SI (i_strplcmp(str_idpart_ascii,"33674501300", 0, 11) == 0 )
      ALORS
# 06000001
        NumOfFilter = NumOfFilter + 0x0001
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVAGSM
      FINSI

      SI ( (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x22) &&
        (i_strplcmp(str_idpart_ascii,"3368900", 0, 7) == 0) )
      ALORS
# 06000002
        NumOfFilter = NumOfFilter + 0x0002
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVAGSM
      FINSI

      SI ( (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x11) ||
        (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x12) )
      ALORS
        SI ( (i_get_art_field (g_iartout, $Tdpvgsm::C_Key1) == 0x50) ||
          (i_get_art_field (g_iartout, $Tdpvgsm::C_Key1)== 0x52) )
        ALORS
# 06000004
          NumOfFilter = NumOfFilter + 0x0004
          trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

          SAUT TRAIT_NVAGSM
        FINSI
      FINSI

      #-----------------------------------------------------------------------#
      #     Filtre FE_0019
      #-----------------------------------------------------------------------#
      SI ( (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x11) ||
        (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x12) )
      ALORS
        SI ( (i_get_art_field (g_iartout, $Tdpvgsm::C_Key1) == 0x54) ||
          (i_get_art_field (g_iartout, $Tdpvgsm::C_Key1) == 0x56) )
        ALORS
# 06000005
          NumOfFilter = NumOfFilter + 0x0005
          trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

          SAUT TRAIT_NVAGSM
        FINSI
      FINSI

      SI ( table_exp_reg_660004265(str_idemet_ascii, PUSH_TO_TALK_ADV, date_cra) == 1)
      ALORS
# 06000003
        NumOfFilter = NumOfFilter + 0x0003
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVAGSM
      FINSI

      SI  i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x31
      ALORS
# 06000009
        NumOfFilter = NumOfFilter + 0x0009
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVAGSM
      FINSI

      SI ( FILTRE_CB == Oui)
      ALORS
        SI (i_get_tab_field(CSD_CB, date_cra, str_idpart_ascii) != g_inull)
        ALORS
# 06000007
          NumOfFilter = NumOfFilter + 0x0007
          trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

          SAUT TRAIT_REJET_ADV
        FINSI
      FINSI

      #----------------------------------------------------------------------------------#
      #      V3T1.2 (tentite) != 0x0B et RechercherClefTable(CSDMSC, V3T2 (idpart)) vrai #
      #----------------------------------------------------------------------------------#
      SI ( (i_get_tab_field(CSD_MSC, date_cra, str_idpart_ascii) != g_inull) &&
        (i_get_art_field(g_iartout, $Tdpvgsm::tentite) != 0x0B) )
      ALORS
# 06000008
        NumOfFilter = NumOfFilter + 0x0008
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_REJET_ADV
      FINSI

#G1R5 debut PK -GRETA DME suppresion de la solution temporaire GRETA pour ADV
      SI (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x11) && (i_get_tab_field(GRETA , date_cra, str_idpart_ascii) != g_inull)
      ALORS
# 06000006
        NumOfFilter = NumOfFilter + 0x0006
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVAGSM
      FINSI
#G5R1lot2
      SI (i_strplcmp(pt_CodeTarifSVA, "G", 0, 1) == 0 && i_strplcmp(ptr_CetS_GRATUIT, "0", C_FiltreCetS_ADV, 1) == 0)
      ALORS
# 06000010
        NumOfFilter = NumOfFilter + 0x0010
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVAGSM
      FINSI



#G1R5 -fin GRETA DME -PK suppression de la solution temporair GRETA pour ADV

      SAUT TRAIT_ADV
    FINSI


    SI (type_cra == 0x40)
    ALORS
      SI ( i_strcmp( i_get_tab_field("Wha_funcard", date_cra, str_idpart_ascii),"Tous") == 0 )
      ALORS
# 06400001
        NumOfFilter = NumOfFilter + 0x0001
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVAGSM
      FINSI
      #QC1020, QC1025
      SI (i_valid_field_n(g_iartout, $Tdpvgsm::balanceUnits) && i_get_art_field(g_iartout, $Tdpvgsm::tentite) != 0x0B)
      ALORS
        long = g_iartout.balanceUnits!NELEM
        SI long == 1
        ALORS
          res = i_get_art_fieldtab(g_iartout, $Tdpvgsm::balanceUnits, 0)
        SINON
          res = i_get_art_fieldtab(g_iartout, $Tdpvgsm::balanceUnits, long - 2) * 0x100 + i_get_art_fieldtab(g_iartout, $Tdpvgsm::balanceUnits, long - 1)
        FINSI
        SI res == 1
        ALORS
          flag_ADVPMV = Non
        SINON
          flag_ADVPMV = Oui
        FINSI
      SINON
        flag_ADVPMV = Non
      FINSI
      #/QC1025, /QC1020
      SAUT TRAIT_ADV

    FINSI

    SI (type_cra == 0x70)
    ALORS
# 06700001
      NumOfFilter = NumOfFilter + 0x0001
      trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

      SAUT TRAIT_NVAGSM
    FINSI

    SI (type_cra == 0x80)
    ALORS
      SI (i_get_tab_field(LISTE_CHARGING_CARAC, date_cra, ptr_chgcar_ascii) == g_inull)
      ALORS
# 06800001
        NumOfFilter = NumOfFilter + 0x0001
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_REJET_ADV
      FINSI


# test sur FILTRE_CB prioritaire sur appel table externe
      SI (FILTRE_CB == Oui)
      ALORS
        pt_res_table = i_get_tab_field(Activation, date_cra,"WIFICB_FP")
        SI (i_strplcmp(pt_res_table,"Desactive", 0, 9) == 0)
        ALORS
# 06800002
          NumOfFilter = NumOfFilter + 0x0002
          trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

          SAUT TRAIT_REJET_ADV
        FINSI
      FINSI

# test sur FILTRE_CB prioritaire sur appel table externe
      SI (FILTRE_CB == Non)
      ALORS
        pt_res_table = i_get_tab_field(Activation, date_cra,"WIFIFW_FP")
        SI (i_strplcmp(pt_res_table,"Desactive", 0, 9) == 0) && (i_strcmp(ptr_chgcar_ascii, "100B") != 0) && (i_strcmp(ptr_chgcar_ascii, "100F") != 0)
        ALORS
# 06800003
          NumOfFilter = NumOfFilter + 0x0003
          trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

          SAUT TRAIT_REJET_ADV
        FINSI
      FINSI
    FINSI

    SI  (type_cra == 0x90)
    ALORS
      SI ( (i_strplcmp(i_get_art_fieldptr(g_iartout, $Tdpvgsm::accPointName3),"orange.acte", 0, 11) == 0) ||
        (i_strplcmp(i_get_art_fieldptr(g_iartout, $Tdpvgsm::accPointName3),"cbil.acte", 0, 9) == 0) )
      ALORS
# 06900001
        NumOfFilter = NumOfFilter + 0x0001
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVAGSM
      FINSI

##G3R4 lot4 suppression filtres
##Suppression filtre 06xx0202
##Suppression filtre 06900004
##Suppression filtre 06900005
##Suppression filtre 06900006
##Suppression filtre 06900008
##Suppression filtre 06900009
##Suppression filtre 0690000A
##Suppression filtre 0690000B
##Suppression filtre 0690000C
##Suppression filtre 0690000D
##Suppression filtre 0690000E

##G3R10 lot4 creation de filtre
##06900030
      SI (TYPE_GPRS_SGSN == Oui || b_4GSgw == Oui)
      ALORS
        NumOfFilter = NumOfFilter + 0x0030
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_NVAGSM
      FINSI

#06900031 -> 06900043   V3T1.2= 0B Et RINT Faux Et FRA_APN_TRT.3 = 0 (traitement des CRAL et ZB)
      SI (FILTRE_CB == Oui &&  RINT_Roaming_International == Non && i_strplcmp(ptr_ResFRAAPNTRT, "0", C_FRA_APN_TRT3, 1) == 0)
      ALORS
        NumOfFilter = NumOfFilter + 0x0043
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_NVAGSM
      FINSI

#06900032
      SI (FILTRE_CB == Oui &&  RINT_Roaming_International == Non && i_get_art_field(g_iartout, $Tdpvgsm::chgcar) == 0x0900)
      ALORS
        NumOfFilter = NumOfFilter + 0x0032
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_NVAGSM
      FINSI

#06900033 -> 06900044    V3T1.2= 0B ET RINT Vrai ET FRA_APN_TRT.4 = 0
      SI (FILTRE_CB == Oui &&  RINT_Roaming_International == Oui && i_strplcmp(ptr_ResFRAAPNTRT, "0", C_FRA_APN_TRT4, 1) == 0)
      ALORS
        NumOfFilter = NumOfFilter + 0x0044
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_NVAGSM
      FINSI

#06900034 -> 06900041   V3T1.2<>0B Et T3t1/V3t1.17 <> 0900 Et RINT Faux Et FRA_APN_TRT.1 = 0 (usage national et ZB)
      SI (FILTRE_CB == Non &&  i_get_art_field(g_iartout, $Tdpvgsm::chgcar) != 0x0900 && RINT_Roaming_International == Non && i_strplcmp(ptr_ResFRAAPNTRT, "0", C_FRA_APN_TRT1, 1) == 0)
      ALORS
        NumOfFilter = NumOfFilter + 0x0041
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_NVAGSM
      FINSI

#06900035 -> 06900042  V3t1.2 <> 0B Et RINT Vrai Et FRA_APN_TRT.2 = 0
      SI (FILTRE_CB == Non && RINT_Roaming_International == Oui && i_strplcmp(ptr_ResFRAAPNTRT, "0", C_FRA_APN_TRT2, 1) == 0)
      ALORS
        NumOfFilter = NumOfFilter + 0x0042
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_NVAGSM
      FINSI

#/fin 0x90
    FINSI

#G3R0CbME
    SI (type_cra == 0x01)
    ALORS
# 06010001
      NumOfFilter = NumOfFilter + 0x0001
      trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

      SAUT TRAIT_NVAGSM
    FINSI

    SI (type_cra == 0x02)
    ALORS
      SI ( (i_get_art_field (g_iartout, $Tdpvgsm::C_Key1) == 0x50) ||
        (i_get_art_field (g_iartout, $Tdpvgsm::C_Key1)== 0x52) )
      ALORS
# 06020003
        NumOfFilter = NumOfFilter + 0x0003
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVAGSM
      FINSI
    FINSI

    SI ((type_cra == 0x02) || (type_cra == 0x06))
    ALORS
      SI ( (i_strplcmp(str_idpart_ascii,"33654175407", 0, 11) == 0) ||
        (i_strplcmp(str_idpart_ascii,"33654185408", 0, 11) == 0) ||
        (i_strplcmp(str_idpart_ascii,"33654185409", 0, 11) == 0) ||
        (i_strplcmp(str_local_ascii,"33654185408", 0, 11) == 0) ||
        (i_strplcmp(str_local_ascii,"33654295001", 0, 11) == 0) )
      ALORS
# 06020001 06020002 06060001 06060002
        NumOfFilter = NumOfFilter + 0x0001
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X> ou 0002", NumOfFilter)

        SAUT TRAIT_NVAGSM
      FINSI
    FINSI

    SI (type_cra == 0x04)
    ALORS
      SI ( ( (i_get_art_field (g_iartout, $Tdpvgsm::C_Key1) == 0x51) ||
        (i_get_art_field (g_iartout, $Tdpvgsm::C_Key1)== 0x53) ) &&
        ( (i_valid_field_n(g_iartout, $Tdpvgsm::local)==0) || (i_strplcmp(str_local_ascii,"33", 0, 2) == 0) ) )
      ALORS
# 06040001
        NumOfFilter = NumOfFilter + 0x0001
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVAGSM
      FINSI

      SI ( (i_get_art_field (g_iartout, $Tdpvgsm::C_Key1) == 0x2B) ||
        (i_get_art_field (g_iartout, $Tdpvgsm::C_Key1)== 0x37) ) &&
        (i_strplcmp(pt_CAMEL_DEST_NUMBER,"33", 0, 2) == 0)
      ALORS
#G1R5 debut PK GRETA DME - Suppression de la solution provisoire GRETA pour ADV
# 06040002
        NumOfFilter = NumOfFilter + 0x0002
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVAGSM
      FINSI
    FINSI
#G1R5 Fin PK GRETA DME - Suppression de la solution provisoire GRETA pour ADV

    SI ((type_cra == 0x04) || (type_cra == 0x05))
    ALORS
      SI (i_strplcmp(str_local_ascii,"33", 0, 2) == 0)
      ALORS
# 06040003 ou 06050001
        NumOfFilter = NumOfFilter + 0x0003
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X> ou 06050001", NumOfFilter)

        SAUT TRAIT_NVAGSM
      FINSI
    FINSI


#--------------------------- UsageTV (0xA6) ---------------------------
    SI (type_cra == 0xA6)
    ALORS
      UsageTV = Oui
## 06A60001
#     NumOfFilter = NumOfFilter + 0x0001
#     trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
      SAUT TRAIT_ADV
    FINSI

# Rejet si V4t39.4(balanceAmount) absent
    SI (type_cra == 0xA0)
    ALORS
      SI !(i_valid_field_n(g_iartout,$Tdpvgsm::balanceAmount))
      ALORS
# QC 380
# 06A00001
        NumOfFilter = NumOfFilter + 0x0001
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_REJET_ADV
      FINSI

#G5R1lot2
      SI (i_strplcmp(pt_CodeTarifSVA, "G", 0, 1) == 0 && i_strplcmp(ptr_CetS_GRATUIT, "0", C_FiltreCetS_ADV, 1) == 0)
      ALORS
# 06A00002
        NumOfFilter = NumOfFilter + 0x0002
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVAGSM
      FINSI

      SAUT TRAIT_ADV

    FINSI

#G5R1lot2
    SI (type_cra == 0xAE)
    ALORS
#G5R1lot2
      SI (i_strplcmp(pt_CodeTarifSVA, "G", 0, 1) == 0 && i_strplcmp(ptr_CetS_GRATUIT, "0", C_FiltreCetS_ADV, 1) == 0)
      ALORS
# 06AE0001
        NumOfFilter = NumOfFilter + 0x0001
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_NVAGSM
      FINSI

# hors criteres d'exclusion, ADV
      SAUT TRAIT_ADV

    FINSI

#   SI (type_cra == 0xAF) || (type_cra == 0xA7)
#   ALORS
## 06AE0001 06AF0001 06A70001
#       NumOfFilter = NumOfFilter + 0x0001
#       trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
#     SAUT TRAIT_ADV
#   FINSI

# SMSMO (type=0x11)
    SI (type_cra == 0x11)
    ALORS
      #ACTIVSG
      #-----------------------------------------------------------------------#
      #      SMSGratuit               #
      #  ADV : date_cra n'apartient pas a la table externe                    #
      #  NVA : date_cra apartient a la table externe                          #
      #-----------------------------------------------------------------------#

      pt_res_table = i_get_tab_field(Activation, date_cra,"SMSGratuit")
      trace2("pt_res_table ACTIVSG = <%s>", pt_res_table, "")
      SI (i_strplcmp(pt_res_table,"Actif", 0, 5) == 0)
      ALORS
        SI ( ( (i_get_art_field(g_iartout,$Tdpvgsm::idpart - 1) > 3) &&
          (i_strplcmp(str_idpart_ascii,"33", 0, 2) == 0) ) ||
          ( (i_get_art_field(g_iartout,$Tdpvgsm::idpart - 1) == 3) &&
          ( (i_strplcmp(str_idpart_ascii,"20601", 0, 5) == 0) ||
          (i_strplcmp(str_idpart_ascii,"20491", 0, 5) == 0) ) ) )
        ALORS
          SI (i_test_Horaire_660004265(g_iartout, $Tdpvgsm::DATE, ACTIVSG) == 1)
          ALORS
            trace(" date CRA appartient intervalle parametres: envoie NVAGSM")
# 06110001
            NumOfFilter = NumOfFilter + 0x0001
            trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

            SAUT TRAIT_NVAGSM
          FINSI
        FINSI
      FINSI

# G3R3 Filtrage SMS pour ADV (Activation = table externe "EtatCritere")
      pt_res_table = i_get_tab_field(Activation, date_cra,"Filtrage_SMS_ADV")
      trace2("pt_res_table EtatCritere avec cle=Filtrage_SMS_ADV = <%s>", pt_res_table, "")
      SI (
        #QC831 G3R3 lot2
        # equivaut a ADV_FILTRE
        ( (app_dest==0x3238 && instOLAGSM == instIMSI ) || (app_dest==0x3239 && instOL2GSM == instIMSI) || (app_dest==0x3330 && instOL3GSM == instIMSI) || (app_dest==0x3331 && instVDIGSM == instIMSI) || (app_dest==0x3332 && instOR5GSM == instIMSI))
        && (i_strplcmp(pt_res_table,"Actif", 0, 5) == 0)
        )
      ALORS
        erreur = i_format_str2(ptr_SMS,"%s%s","ADV_",str_idpart_ascii)
        SI (
          # equivaut a SMSMO_ADV_FILTRE==vrai
          # car type==0x11 et V3t3 commence par 33 et longueur idpart==11(format international)
          # et idpar==33[1234567]* et recherche SMS_SURTAXE==faux
          i_strplcmp(str_local_ascii,"33", 0, 2) == 0
          && i_strlen(str_idpart_ascii) == 11
          &&
          (
          i_strplcmp(str_idpart_ascii,"331", 0, 3) == 0
          || i_strplcmp(str_idpart_ascii,"332", 0, 3) == 0
          || i_strplcmp(str_idpart_ascii,"333", 0, 3) == 0
          || i_strplcmp(str_idpart_ascii,"334", 0, 3) == 0
          || i_strplcmp(str_idpart_ascii,"335", 0, 3) == 0
          || i_strplcmp(str_idpart_ascii,"336", 0, 3) == 0
          || i_strplcmp(str_idpart_ascii,"337", 0, 3) == 0
          )
          && table_exp_reg_660004265(ptr_SMS, "SMS_SURTAXE" , date_cra) == 0
          )
        ALORS
          # Envoi a NVS
# 06110002
          NumOfFilter = NumOfFilter + 0x0002
          trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

          SAUT TRAIT_NVSGSM
        FINSI
      FINSI
    FINSI

# MMSMO30 (0x30)
    SI (type_cra == 0x30)
    ALORS
      str_idpart = i_get_art_fieldptr(g_iartout, $Tdpvgsm::idpart)
      SI (i_strplcmp(str_idpart,"cartepostale@orang", 1, 18) == 0)
      ALORS
        erreur=i_set_art_fieldtab(g_iartout, $Tdpvgsm::idpart, 0, 3)
        erreur=i_set_art_fieldtab(g_iartout, $Tdpvgsm::idpart, 1, 3)
        erreur=i_set_art_fieldtab(g_iartout, $Tdpvgsm::idpart, 2, 6)
        erreur=i_set_art_fieldtab(g_iartout, $Tdpvgsm::idpart, 3, 8)
        erreur=i_set_art_fieldtab(g_iartout, $Tdpvgsm::idpart, 4, 0)
        erreur=i_set_art_fieldtab(g_iartout, $Tdpvgsm::idpart, 5, 0)
        erreur=i_set_art_fieldtab(g_iartout, $Tdpvgsm::idpart, 6, 4)
        erreur=i_set_art_fieldtab(g_iartout, $Tdpvgsm::idpart, 7, 2)
        erreur=i_set_art_fieldtab(g_iartout, $Tdpvgsm::idpart, 8, 0)
        erreur=i_set_art_fieldtab(g_iartout, $Tdpvgsm::idpart, 9, 0)
        erreur=i_set_art_fieldtab(g_iartout, $Tdpvgsm::idpart, 10, 4)
        erreur=i_set_art_fieldtab(g_iartout, $Tdpvgsm::idpart, 11, 0xf)
        erreur=i_resize_tlv(g_iartout, "T3t2", "idpart", 48)
        SAUT TRAIT_ADV
      SINON
        #-----------------------------------------------------------------------#
        #      MMSGratuit             Activation = table externe "EtatCritere"  #
        #  ADV : date_cra n'apartient pas a la table externe                    #
        #  NVA : date_cra apartient a la table externe                          #
        #-----------------------------------------------------------------------#

        pt_res_table = i_get_tab_field(Activation, date_cra,"MMSGratuit")
        SI ( (i_strplcmp(pt_res_table,"Actif", 0, 5) == 0)  && (i_valid_field_n(g_iartout, $Tdpvgsm::local)==0) )
        ALORS
          SI (i_get_art_field(g_iartout,$Tdpvgsm::idpart - 1) > 3)
          ALORS
            SI (i_test_Horaire_660004265(g_iartout, $Tdpvgsm::DATE, ACTIV_MMS) == 1)
            ALORS
# 06300001
              NumOfFilter = NumOfFilter + 0x0001
              trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

              SAUT TRAIT_NVAGSM
            FINSI
          FINSI
        FINSI
      FINSI
    FINSI

    # tous les autres type de CRAs
#G3R3   SI ((TYPE_GPRS_GGSN == Non) && (TYPE_GPRS_volNULL == Non))
    SI (TYPE_GPRS_volNULL == Non)
    ALORS
      SAUT TRAIT_ADV
    SINON
      #-----------------------------------------------------------------------#
      # filtre 13 : ggsn et/ou volume nul
      #-----------------------------------------------------------------------#
# 06910001 06910002 06XX0201
      NumOfFilter = NumOfFilter + 0x0201
      trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X> 06910001 ou 06910002 ou 06XX0201", NumOfFilter)

      SAUT TRAIT_NVAGSM
    FINSI

    POINT TRAIT_ADV

    SI (instVDIGSM == instIMSI)
    ALORS
      SI (UsageTV == Non && flag_ADVPMV == Non)
      ALORS
        trace("VDIGSM")
        res = MiseAuFormat_Stockage_660004265("VDIGSM", instVDIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI
      SINON
        trace("VDIPMV")
        res = MiseAuFormat_Stockage_660004265("VDIPMV", instVDIPMV, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI
      FINSI
    FINSI

    SI (instOR5GSM == instIMSI)
    ALORS
      SI (UsageTV == Non && flag_ADVPMV == Non)
      ALORS
        trace("OR5GSM")
        res = MiseAuFormat_Stockage_660004265("OR5GSM", instOR5GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI
      SINON
        trace("OR5PMV")
        res = MiseAuFormat_Stockage_660004265("OR5PMV", instOR5PMV, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI
      FINSI
    FINSI

    SI (instOLAGSM == instIMSI)
    ALORS
      SI (UsageTV == Non && flag_ADVPMV == Non)
      ALORS
        trace("OLAGSM")
        res = MiseAuFormat_Stockage_660004265("OLAGSM", instOLAGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI
      SINON
        trace("OLAPMV")
        res = MiseAuFormat_Stockage_660004265("OLAPMV", instOLAPMV, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI
      FINSI
    FINSI

    SI (instOL2GSM == instIMSI)
    ALORS
      SI (UsageTV == Non && flag_ADVPMV == Non)
      ALORS
        trace("OL2GSM")
        res = MiseAuFormat_Stockage_660004265("OL2GSM", instOL2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI
      SINON
        trace("OL2PMV")
        res = MiseAuFormat_Stockage_660004265("OL2PMV", instOL2PMV, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI
      FINSI
    FINSI

    SI (instOL3GSM == instIMSI)
    ALORS
      SI (UsageTV == Non && flag_ADVPMV == Non)
      ALORS
        trace("OL3GSM")
        res = MiseAuFormat_Stockage_660004265("OL3GSM", instOL3GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN, multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI
      SINON
        trace("OL3PMV")
        res = MiseAuFormat_Stockage_660004265("OL3PMV", instOL3PMV, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI
      FINSI
    FINSI

    SAUT ECC_SECONDAIRES

    #----------< poubelle NVAGSM >----------------------------------------------------------
    POINT TRAIT_NVAGSM
#QC983
    SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
    ALORS
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    SINON
      SI Old_Family
      ALORS
        erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
      SINON
        erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
      FINSI
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    FINSI
#/QC983


    res = MiseAuFormat_Stockage_660004265("NVAGSM", instNVAGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI
    SAUT ECC_SECONDAIRES

    #----------< poubelle NVSGSM >----------------------------------------------------------
    POINT TRAIT_NVSGSM
#QC983
    SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
    ALORS
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    SINON
      SI Old_Family
      ALORS
        erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
      SINON
        erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
      FINSI
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    FINSI
#/QC983
    res = MiseAuFormat_Stockage_660004265("NVSGSM", instNVSGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI
    SAUT ECC_SECONDAIRES

    #----------< poubelle REJET >----------------------------------------------------------
    POINT TRAIT_REJET_ADV
#QC983
    SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
    ALORS
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    SINON
      SI Old_Family
      ALORS
        erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
      SINON
        erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
      FINSI
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    FINSI
#/QC983
    res = MiseAuFormat_Stockage_660004265("RJPGSM", instRJPGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI
    SAUT ECC_SECONDAIRES

  FINSI

  #-----------------------------------------------------------------------#
  #                          SACHEM (SHP)  SacHem comPte mobile           #
  # G3R9 QC1155                                                           #
  #-----------------------------------------------------------------------#
  SI (instSHPGSM == instIMSI)
  ALORS
    NumOfFilter = 0x05000000 + type_cra * 0x10000
#----------------------- tout type -------------------------------------------------------
    SI (CRA_VPN == Oui)
    ALORS
# 05XX0101 (VPN=vrai)
      NumOfFilter = NumOfFilter + 0x0101
      trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

      SAUT TRAI_RJPGSM
    FINSI

# DEBUT G2R5 Facturation Xeuros CMO  DRE
    SI (type_cra == 0xA6)
    ALORS

      res=i_LireInfoECC( instSHPGSM, 0 )
      SI( res!=0 )
      ALORS
        trace1("instSHPGSM = <%d>", instSHPGSM)
        app_dest=i_LireEntierInfo( res, 1, 2)
        trace1("app_dest:<0x%x>",app_dest)

        SI(app_dest==0x3233)
        ALORS
          instOLAPMV = i_LireInstanceECC("OLAPMV")
          res = MiseAuFormat_Stockage_660004265("OLAPMV", instOLAPMV, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
          SI (res == STOCKAGE_KO)
          ALORS
            RETOUR STOCKAGE_KO
          SINON
            SAUT ECC_SECONDAIRES
          FINSI
        FINSI

        SI(app_dest==0x3234)
        ALORS
          instOL2PMV = i_LireInstanceECC("OL2PMV")
          res = MiseAuFormat_Stockage_660004265("OL2PMV", instOL2PMV, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
          SI (res == STOCKAGE_KO)
          ALORS
            RETOUR STOCKAGE_KO
          SINON
            SAUT ECC_SECONDAIRES
          FINSI
        FINSI

        SI(app_dest==0x3235)
        ALORS
          instOL3PMV = i_LireInstanceECC("OL3PMV")
          res = MiseAuFormat_Stockage_660004265("OL3PMV", instOL3PMV, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
          SI (res == STOCKAGE_KO)
          ALORS
            RETOUR STOCKAGE_KO
          SINON
            SAUT ECC_SECONDAIRES
          FINSI
        FINSI

        SI(app_dest==0x3236)
        ALORS
          instVDIPMV = i_LireInstanceECC("VDIPMV")
          res = MiseAuFormat_Stockage_660004265("VDIPMV", instVDIPMV, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
          SI (res == STOCKAGE_KO)
          ALORS
            RETOUR STOCKAGE_KO
          SINON
            SAUT ECC_SECONDAIRES
          FINSI
        FINSI

        SI(app_dest==0x3237)
        ALORS
          instOR5PMV = i_LireInstanceECC("OR5PMV")
          res = MiseAuFormat_Stockage_660004265("OR5PMV", instOR5PMV, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
          SI (res == STOCKAGE_KO)
          ALORS
            RETOUR STOCKAGE_KO
          SINON
            SAUT ECC_SECONDAIRES
          FINSI
        FINSI

      FINSI
    FINSI

# FIN G2R5 Facturation Xeuros CMO DRE

#-----------------------type_cra == VOIP (0xA0, 0xAE, 0xAF, 0xA7) ------------------------
    SI (type_cra == 0xA6) || (type_cra == 0xA0) || (type_cra == 0xAE) || (type_cra == 0xAF) || (type_cra == 0xA7)
    ALORS
# 05XX0001 et 05A60001
      NumOfFilter = NumOfFilter + 0x0001
      trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

      SAUT TRAI_RJPGSM
    FINSI

#-----------------------type_cra == 0x11 SMSMO -------------------------------------------
    SI (type_cra == 0x11)
    ALORS

      #-----------------------------------------------------------------------------#
      #      Transmission des CRA SMS MO temps reel sur le 5eme octet de V3t13.3    #
      #  CMO : le 5eme octet du champ V3t13.3 vaut 1, CRA facture en temps reel     #
      #  SHP : le 5eme octet du champ V3t13.3 vaut 0, CRA non facture en temps reel #
      #-----------------------------------------------------------------------------#

      SI(i_get_art_field(g_iartout,$Tdpvgsm::PrepaidMO)==0)
      ALORS

        SAUT TRAIT_SHPSSP
      SINON
# 05110001 (le 5eme octet du champ V4t13.3 vaut 1)
        NumOfFilter = NumOfFilter + 0x0001
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_CMO
      FINSI
    FINSI
#-----------------------type_cra == 0x00 sortant -----------------------------------------
    SI (type_cra == 0x00)
    ALORS
      SI (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x22 && i_strplcmp(str_idpart_ascii, "33689", 0, 5) != 0)
      ALORS

        SAUT TRAIT_SHPSSP
      SINON
# 05000001
        NumOfFilter = NumOfFilter + 0x0001
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_CMO
      FINSI
    FINSI
#----------------------- autres types !=0x11 et != 0x00 ----------------------------------
# 05XX0201
    NumOfFilter = NumOfFilter + 0x0201
    trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

    SAUT TRAIT_CMO


    POINT TRAIT_SHPSSP
    res = MiseAuFormat_Stockage_660004265("SHPGSM", instSHPGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI
    res = MiseAuFormat_Stockage_660004265("SSPGSM", instSSPGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI
    SAUT ECC_SECONDAIRES

    POINT TRAIT_CMO
    SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
    ALORS
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    SINON
      SI Old_Family
      ALORS
        erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
      SINON
        erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
      FINSI
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    FINSI
    res = MiseAuFormat_Stockage_660004265("CMOGSM", instCMOGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI
    SAUT ECC_SECONDAIRES

  FINSI

  #-----------------------------------------------------------------------#
  #                          SACHEM (SHM) SacHem Mobicarte                #
  # G3R9 QC1155                                                           #
  #-----------------------------------------------------------------------#
  SI (instSHMGSM == instIMSI)
  ALORS
    NumOfFilter = 0x04000000 + type_cra * 0x10000
#----------------------- tout type -------------------------------------------------------
    SI (CRA_VPN == Oui)
    ALORS
# 04XX0101
      NumOfFilter = NumOfFilter + 0x0101
      trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

      SAUT TRAI_RJPGSM
    FINSI
#-----------------------type_cra == 0x11 SMSMO ----------------------------------------
    SI (type_cra == 0x11)
    ALORS
      #-----------------------------------------------------------------------------#
      #      Transmission des CRA SMS MO temps reel sur le 5eme octet de V3t13.3    #
      #  M1G : le 5eme octet du champ V3t13.3 vaut 1, CRA facture en temps reel     #
      #  SHM : le 5eme octet du champ V3t13.3 vaut 0, CRA non facture en temps reel #
      #-----------------------------------------------------------------------------#

      #  codage en dur de la valeur de la table externe TempsReel
      SI(i_get_art_field(g_iartout,$Tdpvgsm::PrepaidMO) ==0 )
      ALORS
        SAUT TRAIT_SHMSSM
      SINON
# 04110001 (le 5eme octet du champ V4t13.3 vaut 1, CRA facture en temps reel)
        NumOfFilter = NumOfFilter + 0x0001
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAIT_M1G
      FINSI
    FINSI
#-----------------------type_cra == 0x00 sortant -----------------------------------------
    SI (type_cra == 0x00)
    ALORS
      SI (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x22 && i_strplcmp(str_idpart_ascii, "33689", 0, 5) != 0)
      ALORS
        SAUT TRAIT_SHMSSM
      SINON
# 04000001
        NumOfFilter = NumOfFilter + 0x0001
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAIT_M1G
      FINSI
    FINSI
#----------------------- autres types !=0x11 et != 0x00 ----------------------------------
# 04XX0201
    NumOfFilter = NumOfFilter + 0x0201
    trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

    SAUT TRAIT_M1G


    POINT TRAIT_SHMSSM
    res = MiseAuFormat_Stockage_660004265("SHMGSM", instSHMGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI
    res = MiseAuFormat_Stockage_660004265("SSMGSM", instSSMGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI
    SAUT ECC_SECONDAIRES

    POINT TRAIT_M1G
    SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
    ALORS
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    SINON
      SI Old_Family
      ALORS
        erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
      SINON
        erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
      FINSI
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    FINSI
    res = MiseAuFormat_Stockage_660004265("M1GGSM", instM1GGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI
    SAUT ECC_SECONDAIRES

  FINSI

  #-----------------------------------------------------------------------#
  #                           MOBICARTE (M1G)                             #
  #-----------------------------------------------------------------------#
  SI (IMSI_TEST == Oui)
  ALORS
    NumOfFilter = 0x04000000 + type_cra * 0x10000

    SI (CRA_VPN == Oui)
    ALORS
# 04XX0101
      NumOfFilter = NumOfFilter + 0x0101
      trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

      SAUT TRAI_RJPGSM
    FINSI

# 04XX0201
    NumOfFilter = NumOfFilter + 0x0201
    trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

    SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
    ALORS
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    SINON
      SI Old_Family
      ALORS
        erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
      SINON
        erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
      FINSI
      erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
    FINSI
    res = MiseAuFormat_Stockage_660004265("M1GGSM", instM1GGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI
    SAUT ECC_SECONDAIRES
  FINSI

  #-----------------------------------------------------------------------#
  #                                 TRG                                   #
  #-----------------------------------------------------------------------#
  SI (instTRGGSM == instIMSI)
  ALORS
    SI (CRA_VPN == Oui)
    ALORS
      SAUT TRAI_RJPGSM
    FINSI
# type = 0x91 => n'est plus recu par METEOR
    SI (type_cra == 0x90)
    ALORS
      SI (TYPE_GPRS_GGSN == Oui)
      ALORS
        SAUT TRAIT_REJET_TRG
      FINSI
    FINSI

    SI (type_cra == 0x40)
    ALORS
      SI (FILTRE_CB == Oui)
      ALORS
        REJET40 = Oui
        SAUT TRAIT_REJET_TRG
      FINSI
    FINSI

    res = MiseAuFormat_Stockage_660004265("TRGGSM", instTRGGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI
    SAUT ECC_SECONDAIRES

    #----------< poubelle REJET >----------------------------------------------------------
    POINT TRAIT_REJET_TRG
    res = MiseAuFormat_Stockage_660004265("RJPGSM", instRJPGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI
    SAUT ECC_SECONDAIRES

  FINSI

  #-----------------------------------------------------------------------#
  #                            FRAUDE (FRAERR)                            #
  #-----------------------------------------------------------------------#
  SI (i_LireRedistCpt() > 0)
  ALORS
    SI ( i_get_attr_val_n($E_Redistri2::DateDernierPass) != i_cur_date() )
    ALORS
      Date_curFRAERR = i_cur_date()
      Nb_jourFRAERR = Date_curFRAERR - i_get_attr_val_n( $E_Redistri2::DatePremierPass)
      SI (Nb_jourFRAERR >= 7)
      ALORS
        res = MiseAuFormat_Stockage_660004265("FRAERR", instFRAERR, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI
        CRA_FRAERR = Oui
        SAUT ECC_SECONDAIRES
      FINSI
    FINSI
  FINSI

  #-----------------------------------------------------------------------#
  #                flux pour les CRA Etrangers (DCHGSM)                   #
  # CLS_ETRANGER vrai si                                                  #
  #   IMSI_OrangeCo faux et CRA_A_ENRICHIR faux et                        #
  #   IMSI_Mobicarte_1("208990000000001") faux  et                        #
  #   IMSI_Mobicarte_2("208990000000002") faux  et                        #
  #   IMSI_Mobicarte_3("208990000000003") faux  et                        #
  #   IMSI_Mobicarte_4("208990000000004") faux  et                        #
  #   IMSI_MVNOFull1 faux et IMSI_MVNOFull2 faux et IMSI_FREE faux        #
  # G3R9 QC1155                                                           #
  #-----------------------------------------------------------------------#
  SI (CLS_ETRANGER == Oui)
  ALORS
    NumOfFilter = 0x08000000 + type_cra * 0x10000
    SI (FILTRE_CB == Non)
    ALORS
      #NumOfFilter = 0x08000000 + type_cra * 0x10000
      #0x00, 0x01, 0x02, 0x05, 0x80, 0x90
#     type = 0x91 => n'est plus recu par METEOR
      SI (type_cra == 0x00 || type_cra == 0x01 || type_cra == 0x02 || type_cra == 0x05 || type_cra == 0x80 || type_cra == 0x90)
      ALORS
#-----------------------type_cra == 0x00 sortant ----------------------------------------
        SI (type_cra == 0x00)
        ALORS

          #  codage en dur des valeurs des tables externes LISTE_SFR et LISTE_BYG
          # IMSI SFR si IMSI==20810.*
          # IMSI BYG si IMSI==20820.*
          SI((!i_strplcmp(str_imsi_ascii, "20820", 0, 5)) ||
            (!i_strplcmp(str_imsi_ascii, "20810", 0, 5)) )
          ALORS
            SI(i_valid_field_n(g_iartout,$Tdpvgsm::local))
            ALORS
              erreur = i_get_art_str(g_iartout, $Tdpvgsm::local, str_local_ascii)
            FINSI
            trace2("str_local_ascii:<%s> %s",str_local_ascii,"")
            SI ( (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x12) && (i_strplcmp(str_local_ascii, "20801", 0, 5) == 0) )
            ALORS
              SI (!i_strplcmp(str_imsi_ascii, "20820", 0, 5))
              ALORS
# 08000001  (IMSI==20820.*)BYG
                NumOfFilter = NumOfFilter + 0x0001
                trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
              SINON
# 08000002  (20810.*)SFR
                NumOfFilter = NumOfFilter + 0x0002
                trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
              FINSI

              SAUT TRAI_RJPGSM
            SINON
              SAUT TRAIT_DCHGSM
            FINSI
          FINSI

        FINSI
#-----------------------type_cra == 0x01 Entrant ----------------------------------------
        SI (type_cra == 0x01)
        ALORS
          SI ((i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x21) &&
            (i_strplcmp(str_idpart_ascii, "33689", 0, 5) == 0) &&
            (i_strplcmp(str_imsi_ascii, "20810", 0, 5)) &&
            (i_strplcmp(str_imsi_ascii, "20820", 0, 5)) )
          ALORS
# 08010001 (ID_TELESERVICE = 0x21 et ID_PART = "33689.*" et DDEUR_IMSI <> "20810.*" et DDEUR_IMSI <> "20820.*")
            NumOfFilter = NumOfFilter + 0x0001
            trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

            SAUT TRAI_RJPGSM
          SINON
            SAUT TRAIT_DCHGSM

          FINSI
        FINSI
#-----------------------type_cra == 0x90 Paquetterm      ------
# type = 0x91 => n'est plus recu par METEOR
        SI (type_cra == 0x90)
        ALORS

          SI ( IMSI_REUNION == Oui && CRA_REUNION == Oui || (IMSI_REUNION == Oui && (i_get_art_field(g_iartout, $Tdpvgsm::tentite) == 0x07 || i_get_art_field(g_iartout, $Tdpvgsm::tentite)== 0x19)))
          ALORS
            SI (IMSI_REUNION == Oui && CRA_REUNION == Oui)
            ALORS
# 08900001, 08910001 (DDEUR_IMSI = "64700.*" et ID_LOCAL = "64700.*")
              NumOfFilter = NumOfFilter + 0x0001
              trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

            SINON
# 08900002 08910002 (Cra Orange reunion sur OrangeFrance [DDEUR_IMSI = "64700.*" et (V3t1.2 = 0x07 ou V3t1.2 = 0x19)])
              NumOfFilter = NumOfFilter + 0x0002
              trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
            FINSI

            SAUT TRAI_RJPGSM
          SINON
            SAUT TRAIT_DCHGSM

          FINSI
          SAUT TRAIT_DCHGSM

        FINSI


        POINT TRAIT_DCHGSM

        res = MiseAuFormat_Stockage_660004265("DCHGSM", instDCHGSM, artout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI
        SAUT ECC_SECONDAIRES
      SINON
#-----------------------autres types que 0x00, 0x01, 0x02, 0x05, 0x80, 0x90 ------
# 08XX0201
        NumOfFilter = NumOfFilter + 0x0201
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

        SAUT TRAI_RJPGSM

      FINSI
    SINON
# 08XX0101 (V3t1.2 == 0x0B -FILTRE_CB-)
      NumOfFilter = NumOfFilter + 0x0101
      trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)

      SAUT TRAI_RJPGSM
    FINSI

  FINSI


  #-----------------------------------------------------------------------#
  #                flux poubelle (RJPGSM)                                 #
  #-----------------------------------------------------------------------#
  #Si CRA  a redistribue ne pas mettre en rejet mais verifie les secondaires
  # evolution Ajout numero filtre rejet
  SI (CRA_a_redistribuer == Non)
  ALORS
    SI ((NumOfFilter & 0x000000FF) == 0x00)
    ALORS
      SI CRA_VPN
      ALORS
# 99XX0001
        NumOfFilter = 0x99000101 + type_cra * 0x10000
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAI_RJPGSM
      SINON
# -1 (FFFFFFFF)
        NumOfFilter = -1
        trace1("<<<__LINE__<<<__FILE__<<< NumOfFilter=<0x%08X>", NumOfFilter)
        SAUT TRAI_RJPGSM
      FINSI
    FINSI
  FINSI

  POINT TRAI_RJPGSM
  SI (CRA_a_redistribuer == Oui)
  ALORS
    # G3R2 QC796 : mise a 1 du bit A de FormatDist car la redistribution est considere comme une appli principale (cf MiseAuFormat_Stockage)
    erreur = i_set_attr_val("FormatDist", 0x80)
    SAUT ECC_SECONDAIRES
  FINSI

  SI i_valid_field_n(g_iartout,$Tdpvgsm::FilterNumber)
  ALORS
    erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
  SINON
    SI Old_Family
    ALORS
      erreur = i_ajout_tlv(g_iartout, "T4t99.3","FilterNumber")
    SINON
      erreur = i_ajoutChamp(g_iartout, "T4t99.3","FilterNumber",1)
    FINSI
    erreur = i_set_art_field(g_iartout, $Tdpvgsm::FilterNumber, NumOfFilter)
  FINSI


  res = MiseAuFormat_Stockage_660004265("RJPGSM", instRJPGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
  SI (res == STOCKAGE_KO)
  ALORS
    RETOUR STOCKAGE_KO
  FINSI
  SAUT ECC_SECONDAIRES

  #-----------------------------------------------------------------------#
  # Applications secondaires
  #-----------------------------------------------------------------------#


  POINT ECC_SECONDAIRES

  #------FO339 DEBUT URSLYON PKH 16/11/2006 Evaluation du booleen CB_HORSPERI
  # SI CB_HORSPERI == 1 ont ne distribue pas a EIR,IRIS et SYM

# G3R9 lot2 COME: COMESI rendre dans l'equation de valorisation de CB_HORSPERI
# G3R10 lot4 suppression des types cras 0x90 et 0x91 pour la valorisationde CB_HORSPERI
  SI (type_cra == 0x00 || type_cra == 0x80)
  ALORS
    SI (FILTRE_CB == Oui && (FE == 1 || instMSFGSM == instIMSI || COMESI == Oui || instSHMGSM == instIMSI|| instSHPGSM == instIMSI))
    ALORS
      CB_HORSPERI = 1
    FINSI
  FINSI

#-------FO339 FIN Evaluation Booleen CB_HORSPERI

# mutualisation appel table Activation avec cle CSDCB_FS
  pt_res_table = i_get_tab_field(Activation, date_cra,"CSDCB_FS")
  SI (i_strplcmp(pt_res_table,"Desactive", 0, 9) == 0)
  ALORS
    CSDCB_FS_Desactive = Oui
  FINSI

  #-----------------------------------------------------------------------#
  #                        Flux C_BIGSM BI (BI1GSM, BI2GSM)
  #-----------------------------------------------------------------------#
  #G5R1
  SI ((i_LireRedistCpt() == 0) ||(CRA_FRAERR == Oui))
  ALORS
    res = MiseAuFormat_Stockage_660004265(C_BIGSM, instBIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI
  FINSI

  SI (FlagBI2)
  ALORS
    res = MiseAuFormat_Stockage_660004265("BI2GSM", instBI2GSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI
  FINSI

  #/G5R1

  #-----------------------------------------------------------------------#
  #                        Flux I2GGSM                                    #
  #-----------------------------------------------------------------------#


# G5R2 lot2 ajout IMSI_Transnational_M2M
# si ((                          criteres d'inclusion vrais                                                                                                                  ) et (                criteres d'exclusion faux               ))
# SI ((IMSI_ORANGE == Vrai || i_strplcmp(str_imsi_ascii, C_ptr_IMSI_55, 0, i_strlen(C_ptr_IMSI_55)) == 0 || IMSI_VPN1 == Vrai || IMSI_URGENCE == Vrai || CLS_ETRANGER == Vrai) && (i_LireRedistCpt() == 0 && IMSI_Transnational_M2M == Faux))
  SI (i_LireRedistCpt() == 0 && IMSI_Transnational_M2M == Faux)
  ALORS


# type_cra == 0x10
# algorithme supprime

# type_cra == 0x11
# G2R6 lot3, inclusion : V3t2 present; exclusion :RechercherClefTable(SMS_SURTAXES, SMS_MO_ + destinataire  V3t2  recipient party MSISDN )  = faux
# G2R6 QC632 : evolution I2G
    SI (type_cra == 0x11)
    ALORS
      SI (!i_valid_field_n(g_iartout, $Tdpvgsm::idpart))
      ALORS
        SAUT I2GGSM
      SINON
        res = i_get_art_field(g_iartout, $Tdpvgsm::idpart -1)
        erreur = i_format_str2(ptr_SMS,"%s%s","SMS_MO_",str_idpart_ascii)
        SI (res <= 3 && table_exp_reg_660004265(ptr_SMS, "SMS_SURTAXE" , date_cra) == 0)
        ALORS
          SAUT I2GGSM
        FINSI
      FINSI
    FINSI


# type_cra == 0x00
    SI (type_cra == 0x00)
    ALORS
# exclusion : RetournerValeurclefTable(EtatCritere,CSDCB_FS)= inActif Et V3t1.2 = 0B (filtre CB)
      SI (CSDCB_FS_Desactive == Oui && FILTRE_CB == Oui)
      ALORS
        SAUT I2GGSM
      FINSI
# exclusion : RetournerValeurclefTable(EtatCritere,CSDMSC_FS)= inActif Et V3t1.2 <> 0B
      SI (FILTRE_CB == Non)
      ALORS
        pt_res_table = i_get_tab_field(Activation, date_cra,"CSDMSC_FS")
        SI (i_strplcmp(pt_res_table,"Desactive", 0, 9) == 0)
        ALORS
          SAUT I2GGSM
        FINSI
      FINSI
# Si ID_TELESERVICE = 11 et RechercherClefTable(GRETA_TAG, T3t2/V3t2) = vrai)
      SI ( i_get_art_field(g_iartout,$Tdpvgsm::tlserv)== 0x11 && i_get_tab_field( GRETA , date_cra, str_idpart_ascii) != g_inull )
      ALORS
        SAUT I2GGSM
      FINSI

# G2R6 lot3 QC560 : Filtrage interco2G des CRA 0x00 non SMS
# G2R6 QC632 : evolution I2G
# G3R1C3 report G2R6 QC673 : pas de filtrage I2G si V3t33/SMSrecepMSISDN absent
# G3R3 lot3 SMS surtaxe ajout du critere IMSI_ORANGE vrai
      SI (IMSI_ORANGE == Oui && (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x22))
      ALORS
        SI (!i_valid_field_n(g_iartout, $Tdpvgsm::SMSrecepMSISDN))
        ALORS
          SAUT SMS_SURTAXE1
        FINSI
        res = i_get_art_field(g_iartout, $Tdpvgsm::SMSrecepMSISDN -1)
        erreur = i_get_art_str(g_iartout, $Tdpvgsm::SMSrecepMSISDN, ptr_SMSrecepMSISDN)
        erreur = i_format_str2(ptr_SMS,"%s%s","SMS_MO_",ptr_SMSrecepMSISDN)
        SI (res <= 3 && table_exp_reg_660004265(ptr_SMS, "SMS_SURTAXE" , date_cra) == 0)
        ALORS
          SAUT I2GGSM
        FINSI
      FINSI
    FINSI


    POINT SMS_SURTAXE1

# type_cra == 0x01
# G2R6 lot3 QC560 : Filtrage interco2G des CRA 0x01 non SMS
# G2R6 QC632 : evolution I2G
# G3R1C3 report G2R6 QC673 : pas de filtrage I2G si V3t33/SMSrecepMSISDN absent
# G3R3 lot3 SMS surtaxe ajout du critere IMSI_ORANGE vrai
    SI (type_cra == 0x01)
    ALORS
      SI (IMSI_ORANGE == Oui && (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x21))
      ALORS
        SI (!i_valid_field_n(g_iartout, $Tdpvgsm::SMSrecepMSISDN))
        ALORS
          SAUT SMS_SURTAXE2
        FINSI
        res = i_get_art_field(g_iartout, $Tdpvgsm::SMSrecepMSISDN -1)
        erreur = i_get_art_str(g_iartout, $Tdpvgsm::SMSrecepMSISDN, ptr_SMSrecepMSISDN)
        erreur = i_format_str2(ptr_SMS,"%s%s","SMS_MT_",ptr_SMSrecepMSISDN)
        SI (res <= 3 && table_exp_reg_660004265(ptr_SMS, "SMS_SURTAXE" , date_cra) == 0)
        ALORS
          SAUT I2GGSM
        FINSI
      FINSI
    FINSI


    POINT SMS_SURTAXE2


# type_cra == 0x70 ou 0x40
# G2R6 lot3 : exclusion : type_cra == 0x40
    SI (type_cra == 0x70 || type_cra == 0x40)
    ALORS
      SAUT I2GGSM
    FINSI
# type_cra == 0x80
    SI (type_cra == 0x80)
    ALORS
# FO392 : test sur FILTRE_CB prioritaire sur appel table externe
      SI (FILTRE_CB == Oui)
      ALORS
        pt_res_table = i_get_tab_field(Activation, date_cra,"WIFICB_FS")
        SI (i_strplcmp(pt_res_table,"Desactive", 0, 9) == 0)
        ALORS
          SAUT I2GGSM
        FINSI
      FINSI

      pt_res_table = i_get_tab_field(Activation, date_cra,"WIFIFW_FS")
      SI (FILTRE_CB == Non
        && (   i_get_tab_field(LISTE_CHARGING_CARAC, date_cra, ptr_chgcar_ascii) != g_inull
        && i_strplcmp(pt_res_table,"Desactive", 0, 9) == 0 ))
      ALORS
        SAUT I2GGSM
      FINSI
    FINSI

# type_cra == 0x90
# G3R4 Filtrage des derniers CRA DCB pour I2G
    SI (type_cra == 0x90)
    ALORS
# inclusion : (DDEUR_IMSI =  20801.*  et ID_LOCAL =  64700  et (V3t1.2 : tentite = 06 ou 07))
      #SI (IMSI_ORANGE == Oui && CRA_REUNION == Oui && (TYPE_GPRS_GGSN == Oui || TYPE_GPRS_SGSN == Oui))
      #G3R7 IMSI_OrangeCo au lieu de  IMSI_ORANGE
      #G3R7 LTE
      SI (IMSI_OrangeCo == Oui && CRA_REUNION == Oui && (TYPE_GPRS_GGSN == Oui || TYPE_GPRS_SGSN == Oui ||
        b_4GPgw == Oui || b_4GSgw == Oui  ))
      ALORS
        SAUT TRAIT_I2GGSM
      FINSI

# exclusion : V3t1.2 = 0B
# exclusion : V3t1.2 <> 0B et DDEUR_IMSI =  20801.*  et ID_LOCAL =  20801.*
      SI ( FILTRE_CB == Non && IMSI_OrangeCo == Oui && i_strplcmp(str_local_ascii, "20801", 0, 5) == 0 ) || (FILTRE_CB == Oui)
      ALORS
        SAUT I2GGSM
      FINSI
    FINSI

#/G3R4
# type = 0x91 => n'est plus recu par METEOR

# distribution vers I2G
    POINT TRAIT_I2GGSM
    res = MiseAuFormat_Stockage_660004265("I2GGSM", instI2GGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI
    trace("passage I2GGSM")
  FINSI

# pas de distribution vers I2G
  POINT I2GGSM


  #-----------------------------------------------------------------------#
  #                        EIR (secondaire d'ADV)                         #
  #-----------------------------------------------------------------------#
  # G5R2 lot2 ajout IMSI_Transnational_M2M
  SI (
    (
    instVDIGSM == instIMSI || instOR5GSM == instIMSI || instOLAGSM == instIMSI || instOL2GSM == instIMSI || instOL3GSM == instIMSI ||
    instTRGGSM == instIMSI || instSHMGSM == instIMSI || instSHPGSM == instIMSI || instMSFGSM == instIMSI || COMESI == Oui ||
    instFEGSM  == instIMSI || CRA_FRAERR == Oui      || CLS_ETRANGER == Oui
    )
    &&
    IMSI_Transnational_M2M == Faux
    )
  ALORS

    #G3R4 lot1 ------------------
    SI (type_cra == 0x01 || type_cra == 0x10 || type_cra == 0x31)
    ALORS
      SAUT FIN_EIRGSM
    FINSI
    #/G3R4 lo1 -------------------

    SI (type_cra == 0x00)
    ALORS
      SI CB_HORSPERI == 1
      ALORS
        SAUT FIN_EIRGSM
      FINSI

      SI (CSDCB_FS_Desactive == Oui) && (FILTRE_CB == Oui)
      ALORS
        SAUT FIN_EIRGSM
      FINSI

      SI (FILTRE_CB == Non)
      ALORS
        pt_res_table = i_get_tab_field(Activation, date_cra,"CSDMSC_FS")
        SI (i_strplcmp(pt_res_table,"Desactive", 0, 9) == 0)
        ALORS
          SAUT FIN_EIRGSM
        FINSI
      FINSI
    FINSI

    SI (type_cra == 0x80)
    ALORS
      SI CB_HORSPERI == 1
      ALORS
        SAUT FIN_EIRGSM
      FINSI

      SI (FILTRE_CB == Oui)
      ALORS
        pt_res_table = i_get_tab_field(Activation, date_cra,"WIFICB_FS")
        SI (i_strplcmp(pt_res_table,"Desactive", 0, 9) == 0)
        ALORS
          SAUT FIN_EIRGSM
        FINSI
      FINSI

      SI    (FILTRE_CB == Non)
      ALORS
        pt_res_table = i_get_tab_field(Activation, date_cra,"WIFIFW_FS")
        SI (   (i_get_tab_field(LISTE_CHARGING_CARAC, date_cra, ptr_chgcar_ascii) != g_inull) && (i_strplcmp(pt_res_table,"Desactive", 0, 9) == 0) )
        ALORS
          SAUT FIN_EIRGSM
        FINSI
      FINSI
    FINSI

#G3R4lot1 Filtrages CRAs pour EIR --------------------------------------

#G3R6
    SI (type_cra == 0x90)
    ALORS
      SI (FILTRE_CB == Oui)
      ALORS
        SAUT FIN_EIRGSM
      FINSI

      SI (i_get_art_field(g_iartout, $Tdpvgsm::tentite) == 0x06)
      ALORS
        SAUT FIN_EIRGSM
      FINSI

      SI (i_get_art_field(g_iartout, $Tdpvgsm::tentite) == 0x07 && MVNO == Non)
      ALORS
        SAUT FIN_EIRGSM
      FINSI

      #G3R7 LTE
      SI (b_4GPgw == Oui && MVNO == Non)
      ALORS
        SAUT FIN_EIRGSM
      FINSI

      SI (b_4GSgw == Oui)
      ALORS
        SAUT FIN_EIRGSM
      FINSI
      #G3R7 LTE Fin
    FINSI

# type = 0x91 => n'est plus recu par METEOR

#\G3R4 lot1 Filtrages CRAs pour EIR ------------------------------------------


    SI ((type_cra == 0xA6) ||(type_cra == 0x46))
    ALORS
      SAUT FIN_EIRGSM
    FINSI

    POINT TRAIT_EIRGSM

    res = MiseAuFormat_Stockage_660004265("EIRGSM", instEIRGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI
  FINSI

  POINT FIN_EIRGSM

  #-----------------------------------------------------------------------#
  #                        IRIS (IRIGSM)                                  #
  #-----------------------------------------------------------------------#
  SI ( instVDIGSM == instIMSI || instOR5GSM == instIMSI || instOLAGSM == instIMSI || instOL2GSM == instIMSI ||
    instOL3GSM == instIMSI || instTRGGSM == instIMSI || instSHMGSM == instIMSI ||
    instSHPGSM == instIMSI || instMSFGSM == instIMSI || instFEGSM  == instIMSI || IMSI_TEST == Oui ||  COMESI == Oui)
  ALORS
    pt_res_table = i_get_tab_field(Activation, date_cra,"CSDMSC_FS")
    SI (type_cra == 0x00)
    ALORS
      SI CB_HORSPERI == 1
      ALORS
        SAUT IRISGSM
      FINSI
      SI (FILTRE_CB == Non)
      ALORS
        SI ( i_get_tab_field(CSD_MSC, date_cra, str_idpart_ascii) != g_inull
          && (instOR5GSM == instIMSI || instOLAGSM == instIMSI || instOL2GSM == instIMSI || instOL3GSM == instIMSI || instVDIGSM == instIMSI) )
        ALORS
          SAUT IRISGSM
        FINSI
      FINSI

      SI ((i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x01) ||(i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x02))
      ALORS
        SAUT IRISGSM
      FINSI
#QC1125
      SI ((i_get_art_field(g_iartout, $Tdpvgsm::DUREE) == 1)  && (i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x22))
      ALORS
        SAUT IRISGSM
      FINSI
    FINSI

    SI (type_cra == 0x01)
    ALORS
      SI (i_get_art_field(g_iartout, $Tdpvgsm::DUREE) == 1 && i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x21)
      ALORS
        SAUT IRISGSM
      FINSI
    FINSI

    SI (type_cra == 0x04)
    ALORS
      SI (i_strplcmp(str_local_ascii, "33", 0, 2) == 0)
      ALORS
        SAUT IRISGSM
      FINSI
    FINSI

    SI (type_cra == 0x20 || type_cra == 0x21 || type_cra == 0x22 || type_cra == 0x23 || type_cra == 0x24 ||
      type_cra == 0x25 || type_cra == 0x26 || type_cra == 0x27 || type_cra == 0x28 || type_cra == 0x29 ||
      type_cra == 0x2A || type_cra == 0x2B || type_cra == 0x2C || type_cra == 0x2D || type_cra == 0x2E || type_cra == 0x2F)
    ALORS
      SAUT IRISGSM
    FINSI
#/QC1125

    SI (type_cra == 0xA6)
    ALORS
      SAUT IRISGSM
    FINSI

    SI (type_cra == 0x80)
    ALORS
      SI CB_HORSPERI == 1
      ALORS
        SAUT IRISGSM
      FINSI

      SI (FILTRE_CB == Non)
      ALORS
        pt_res_table = i_get_tab_field(Activation, date_cra,"WIFIFW_FP")
        SI ( i_strplcmp(pt_res_table,"Desactive", 0, 9) == 0
          &&  i_get_art_field(g_iartout, $Tdpvgsm::chgcar) != 0x100B && i_get_art_field(g_iartout, $Tdpvgsm::chgcar) != 0x100F
          && (instOR5GSM == instIMSI || instOLAGSM == instIMSI || instOL2GSM == instIMSI || instOL3GSM == instIMSI || instVDIGSM == instIMSI) )
        ALORS
          SAUT IRISGSM
        FINSI
      FINSI
    FINSI
# G2R1 lot4

#1 et 2 ------------------------------------------------------------
# criteres d'exclusion :
# 1) Si type = 0x90 et
# V4t44.2 (transactionType) <>  2  et V3t1.2 (tentite)= 0x0B (donc FILTRE_CB) et V4t20.2 commence par la chaine "SD" et
# date CRA < RechercherClefTable (VariableContexte ; DATE_ServiceStopSession)
# 2) Si type = 0x90 et
# V4t44.2 (transactionType) <>  2  et V3t1.2 (tentite)= 0x0B (donc FILTRE_CB) et V4t20.2 ne commence pas par la chaine "SD" et
# date CRA < RechercherClefTable (VariableContexte ; DATE_ServiceStopVolume)

#-------------#
#Filtre 1
#-------------#
#G3R10 Lot4 modifification des filtres pour IRIS QC1274
    SI (type_cra == 0x90)
    ALORS
      #Filtre1
      SI (i_strplcmp(i_get_art_fieldptr(g_iartout, $Tdpvgsm::accPointName3),"orange.acte", 0, 11) == 0)
      ALORS
        SAUT IRISGSM
      FINSI
      #Filtre2
      SI (i_get_art_field(g_iartout, $Tdpvgsm::tentite) == 0x07)
      ALORS
        SI  (instSHMGSM == instIMSI || instSHPGSM == instIMSI)
        ALORS
          i_get_sub_str(i_get_art_fieldptr(g_iartout, $Tdpvgsm::accPointName3), 0, i_get_art_field(g_iartout, $Tdpvgsm::accPointName3-1)-1, str_accPointName3)
          erreur = i_format_str2( pt_Buffer, "%s%s", "IRIS_", str_accPointName3 )
          SI ( i_get_tab_field("FRA_APN_TRT", date_cra, pt_Buffer) == g_inull )
          ALORS
            SAUT IRISGSM
          FINSI
        FINSI
      FINSI
      
      #Filtre3
      #G5R4 QC1329
      SI (FILTRE_CB == Oui)
      ALORS
        SAUT IRISGSM
      FINSI

      #Suppression filtre : SI (FILTRE_CB == Oui)
      #/G5R4 QC1329
      
      # Filtre5   GPRS_GGSN ? Vrai et V3t1.17 <> 0900 et RINT Faux et FRA_APN_TRT.5 = 0
      SI (TYPE_GPRS_GGSN == Oui && i_get_art_field(g_iartout, $Tdpvgsm::chgcar) != 0x0900 && RINT_Roaming_International == Non && i_strplcmp(ptr_ResFRAAPNTRT, "0", C_FRA_APN_TRT5, 1) == 0)
      ALORS
        SAUT IRISGSM
      FINSI
      # Filtre6
      SI (TYPE_GPRS_GGSN == Oui && RINT_Roaming_International == Oui)
      ALORS
        SAUT IRISGSM
      FINSI
      # Filtre7
      SI (TYPE_GPRS_SGSN == Oui || b_4GSgw == Oui)
      ALORS
        SAUT IRISGSM
      FINSI

      SI (b_4GPgw == Oui)
      ALORS
        i_strcpy(ptr_valeurDATE, i_get_tab_field("VariableContexte", date_cra, "DATE_FILTRE_IRIS_PGW"))
        i_get_sub_str(ptr_valeurDATE,2,-1,ptr_date_res)
        erreur = i_set_art_str (g_iartout7,$Conv_URS::DATE,ptr_date_res)
        date_table = i_get_art_field(g_iartout7, $Conv_URS::DATEN)
        SI (date_cra >= date_table)
        ALORS
          SAUT IRISGSM
        FINSI
      FINSI
    FINSI

# type = 0x91 => n'est plus recu par METEOR
#/G3R3 2GDT----------------------------------------------------------------------------------------------------

# stockage IRISGSM ------------------------------------------------------------
# Tous TYPE |Tous types inclus (cf ci-dessus) |GPRS_GGSN = vrai ou GPRS_VOL_NUL = vrai
#QC827 alimentation IRIS pour Tous cras sauf DC GGSN de volume
    #SI ( (TYPE_GPRS_GGSN == Non) && (TYPE_GPRS_volNULL == Non) )
    SI  (TYPE_GPRS_volNULL == Non)
    ALORS
      res = MiseAuFormat_Stockage_660004265("IRIGSM", instIRIGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI
  FINSI

  POINT IRISGSM

  #-----------------------------------------------------------------------#
  #                         Flux ARTIST16Y                                #
  #-----------------------------------------------------------------------#
  # G3R1 lot3 : modification filtrage ARTIST
  # QC718
  SI (i_LireRedistCpt() != 0)
  ALORS
    SAUT FIN_ARTIST
  FINSI

#-----------------------type_cra == 0x40 WHA, CB ------------------------------------------
  SI (type_cra == 0x40)
  ALORS
    #--------------------------------------------------------------------------------------------#
    #Critere d'exclusion de ARTIST16Y si RechercherClefTable(MSP_ARTIST_DISE,ARTISTID_part)=vrai #
    # avec prefixe = "ARTIST" et avec prefixe = "REMOB"  (2R1 lot3)                              #
    #--------------------------------------------------------------------------------------------#
    i_strcpy(pt_MSP,"")
    erreur=i_format_str2(pt_MSP,"%s%s","ARTIST",str_idpart_ascii)
    SI (i_strcmp(i_get_tab_field("MSP_ARTIST_DISE",date_cra,pt_MSP),"Tous") == 0)
    ALORS
      SAUT FIN_ARTIST
    FINSI
    i_strcpy(pt_MSP,"")
    erreur=i_format_str2(pt_MSP,"%s%s","REMOB",str_idpart_ascii)
    SI ( i_strcmp(i_get_tab_field("MSP_ARTIST_DISE",date_cra,pt_MSP),"Tous") == 0 )
    ALORS
      SAUT FIN_ARTIST
    FINSI
    SI (REJET40 == Non)
    ALORS
      res = MiseAuFormat_Stockage_660004265("ARTGSM", instARTGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI

#G2R3 filtre pour cra 0x11
  SINON
#-----------------------type_cra == 0x11 SMSMO ----------------------------------------
    SI (type_cra == 0x11)
    ALORS
      SI ((i_get_art_fieldlength(g_iartout, $Tdpvgsm::idpart)<11) || (i_get_art_fieldlength(g_iartout, $Tdpvgsm::MSISDN)<11))
      ALORS
        i_strcpy(pt_MSP,"")
        erreur=i_format_str2(pt_MSP,"%s%s","REMOB",str_idpart_ascii)
        SI ( i_strcmp(i_get_tab_field("MSP_ARTIST_DISE",date_cra,pt_MSP),"Tous") == 0 )
        ALORS
          SAUT FIN_ARTIST
        FINSI
        res = MiseAuFormat_Stockage_660004265("ARTGSM", instARTGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI
      FINSI
    FINSI
#-----------------------type_cra == 0x30 MMSMO30 ----------------------------------------
    SI (type_cra == 0x30)
    ALORS
      i_strcpy(pt_MSP,"")
      erreur=i_format_str2(pt_MSP,"%s%s","REMOB",str_idpart_ascii)
      SI ( i_strcmp(i_get_tab_field("MSP_ARTIST_DISE",date_cra,pt_MSP),"Tous") == 0 )
      ALORS
        SAUT FIN_ARTIST
      FINSI
      res = MiseAuFormat_Stockage_660004265("ARTGSM", instARTGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI
  FINSI

  POINT FIN_ARTIST

  #-----------------------------------------------------------------------#
  #                           ECD (ECDGSM)                                #
  #-----------------------------------------------------------------------#
  SI (i_LireRedistCpt() > 0)
  ALORS
#OGA 206 Debut
    SI ( i_get_attr_val_n($E_Redistri2::DateDernierPass) != i_cur_date() )
    ALORS
      Date_cur = i_cur_date()
#--FO370 URS_LYON DEBUT 7/12/06 Calcul du Nb_jour a partir de la date courante et non la deniere date de passage en redistri.
      Nb_jour = Date_cur - i_get_attr_val_n( $E_Redistri2::DatePremierPass)

      SI (( Nb_jour >= 1 ) && ( Nb_jour <= 6))
      ALORS
        erreur = i_set_attr_val_n( $E_Redistri2::c_eec, Nb_jour)
#OGA 206 Fin
        res = MiseAuFormat_Stockage_660004265("ECDGSM", instECDGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI
      FINSI
    FINSI
  FINSI
FINSI


#QC940
#--------------------------------------------------------------------#
#               Flux THEMIS                                          #
#--------------------------------------------------------------------#

# THEMIS recoit tous les cras 80

SI (type_cra == 0x80)
ALORS
  SI (Hostspot_THEMIS == 1)
  ALORS
# Flux SHVGSM
    trace1("Envoi vers TMIGSM, instance ECC THEMIS:<%d>",instTHEMISGSM)
    res = MiseAuFormat_Stockage_660004265("TMIGSM", instTHEMISGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
    SI (res == STOCKAGE_KO)
    ALORS
      RETOUR STOCKAGE_KO
    FINSI
  FINSI
FINSI
#/QC940

# Flux secondaires pour MVNO prepaid : SHVGSM et SSVGSM

#-------------------------------------------------------------------------#
#                  SHVGSM et SSVGSM pour MVNO prepaid                     #
#-------------------------------------------------------------------------#
SI (MVNO_prepaid==Oui)
ALORS
  trace("FE_0011 : Flux  secondaires de MVNO prepaid : SHVGSM et SSVGSM")

##################
#
# TYPE_CRA = 0x11 #########################
  SI (type_cra == 0x11)
  ALORS
    SI(i_get_art_field(g_iartout,$Tdpvgsm::PrepaidMO)==0)
    ALORS
# Flux SHVGSM
      instSHVGSM=i_LireInstanceECC("SHVGSM")
      trace1("Instance ECC SHVGSM:<%d>",instSHVGSM)
      res = MiseAuFormat_Stockage_660004265("SHVGSM", instSHVGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI

# Flux secondaire SSVGSM
      instSSVGSM=i_LireInstanceECC("SSVGSM")
      trace1("Instance ECC SSVGSM:<%d>",instSSVGSM)
      res = MiseAuFormat_Stockage_660004265("SSVGSM", instSSVGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI
  SINON
# TYPE_CRA = 0x00 #########################
    SI (type_cra == 0x00)
    ALORS
      #TELESERVICE = 0x22
      SI ((i_get_art_field(g_iartout,$Tdpvgsm::tlserv) == 0x22) &&
        (i_strplcmp(str_idpart_ascii, "33689", 0, 5)) != 0)
      ALORS
        # Flux SHVGSM
        instSHVGSM=i_LireInstanceECC("SHVGSM")
        trace1("Instance ECC SHVGSM:<%d>",instSHVGSM)
        res = MiseAuFormat_Stockage_660004265("SHVGSM", instSHVGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI

        # Flux secondaire SSVGSM
        instSSVGSM=i_LireInstanceECC("SSVGSM")
        trace1("Instance ECC SSVGSM:<%d>",instSSVGSM)
        res = MiseAuFormat_Stockage_660004265("SSVGSM", instSSVGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
        SI (res == STOCKAGE_KO)
        ALORS
          RETOUR STOCKAGE_KO
        FINSI
      FINSI
#---------------------------------------------------
      #TELESERVICE = 0x01 ou 0x02
      SI ( (i_get_art_field(g_iartout,$Tdpvgsm::tlserv)== 0x01) || (i_get_art_field(g_iartout,$Tdpvgsm::tlserv)== 0x02) )
      ALORS
        pt_res_table = i_get_tab_field(Activation, date_cra,"param_tag_mvno")
        SI (i_strplcmp(pt_res_table,"Actif", 0, 5) == 0)
        ALORS
          # Flux SHVGSM
          instSHVGSM=i_LireInstanceECC("SHVGSM")
          trace1("Instance ECC SHVGSM:<%d>",instSHVGSM)
          res = MiseAuFormat_Stockage_660004265("SHVGSM", instSHVGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
          SI (res == STOCKAGE_KO)
          ALORS
            RETOUR STOCKAGE_KO
          FINSI

          # Flux secondaire SSVGSM
          instSSVGSM=i_LireInstanceECC("SSVGSM")
          trace1("Instance ECC SSVGSM:<%d>",instSSVGSM)
          res = MiseAuFormat_Stockage_660004265("SSVGSM", instSSVGSM, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
          SI (res == STOCKAGE_KO)
          ALORS
            RETOUR STOCKAGE_KO
          FINSI
        FINSI
      FINSI
    FINSI
  FINSI

FINSI

#-----------------------------------------------------------------------#
#                         Flux MACDTE                                   #
#-----------------------------------------------------------------------#
# G2R5 : la variable fonctionnelle DataRoaming est utilisee uniquement pour filtrer les types 90 de MACDTE
# Pour alleger le code, elle est calculee ci-dessous
# G2R1_FE lot2 ajout de la condition FE == 1
# QC377
#G3R9 lot2 COME
SI (type_cra == 0x90)
ALORS
# QC391
# G3R7 LTE
  i_get_sub_str(i_get_art_fieldptr(g_iartout, $Tdpvgsm::accPointName3),0, i_get_art_field(g_iartout, $Tdpvgsm::accPointName3-1)-1,str_accPointName3)
  SI (DataRoaming_Legacy == Oui)
  ALORS
    # i_get_sub_str(i_get_art_fieldptr(g_iartout, $Tdpvgsm::accPointName3),0, i_get_art_field(g_iartout, $Tdpvgsm::accPointName3-1)-1,str_accPointName3)
    erreur = i_format_str2(str_ENTaccPointName3, "%s%s", "MACDTE_LEGACY_", str_accPointName3)
    #trace2("<<__LINE__ str_ENTaccPointName3 = %s ==================",str_ENTaccPointName3,"")
    SI (i_get_tab_field("FRA_APN_TRT", date_cra, str_ENTaccPointName3) == g_inull)
    ALORS
      trace ("<<__LINE__>> ========= MACDTE ==============")
      res = MiseAuFormat_Stockage_660004265("MACDTE", instMACDTE, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI
  FINSI

  SI (DataRoaming_LTE == Oui)
  ALORS
    i_strcpy(str_ENTaccPointName3,"")
    erreur = i_format_str2(str_ENTaccPointName3, "%s%s", "MACDTE_LTE_", str_accPointName3)
    SI (i_get_tab_field("FRA_APN_TRT", date_cra, str_ENTaccPointName3) == g_inull)
    ALORS
      trace ("<<__LINE__>> ========= MACDTE ==============")
      res = MiseAuFormat_Stockage_660004265("MACDTE", instMACDTE, g_iartout, date_fin_cra, date_trait_cra, type_cra, CRA_A_ENRICHIR, ptr_IMSI_MSISDN,multidistribution)
      SI (res == STOCKAGE_KO)
      ALORS
        RETOUR STOCKAGE_KO
      FINSI
    FINSI
  FINSI

FINSI

#
# FIN de la distribution
#
POINT FIN_DISTRI

SI ((CRA_a_redistribuer == Oui) && (CRA_FRAERR == Non))
ALORS
  SAUT DISTRI_REDISTRI
FINSI

RETOUR TRAI_OK

POINT DISTRI_ERR
RETOUR TRAI_KO

#-----------------------------------------------------------------------#
#Envoi en redistribution et mise a jour des compteurs de redistribution
#-----------------------------------------------------------------------#
POINT DISTRI_REDISTRI
EnvoiRedis = i_get_attr_val_n($E_Redistri2::EnvoiRedis)
SI ( EnvoiRedis != 1 )
ALORS
  SI (i_LireRedistCpt() > 0)
  ALORS
    erreur = i_set_attr_val_n( $E_Redistri2::DateDernierPass, i_cur_date())
  FINSI
# Optimisation duplication
# DRE-PSA 16/03/2009
  erreur = i_set_attr_val("FormatDist", 0x00)
  res = i_stocke_art(artin, 0, PT_REDIST|RD_TABLE1|RD_TABLE2, 0)
  erreur = i_set_attr_val_n( $E_Redistri2::EnvoiRedis, 1)
FINSI
RETOUR TRAI_REDISTRIBUTION

