DEFINITION Multidistribution_Non_660004603 0
DEFINITION DISTRIBUTION_INCONNU_660004603 1
DEFINITION TRAI_KO_660004603 -1
DEFINITION MODULE_DISTR_660004603 0xA000
DEFINITION ERR_SYNTAX_660004603 0x070
DEFINITION ERR_DUPL_660004603 0x0D0
DEFINITION ERR_DISTR_660004603 0x110
DEFINITION ERR_TAB_660004603 0x0A0
DEFINITION GGSN_660004603 19
DEFINITION SGSN_660004603 18
REGISTRE ENTIER erreur_660004603
REGISTRE ENTIER flag_rdt_660004603
REGISTRE ENTIER recordtype_660004603
REGISTRE ENTIER cause_660004603
REGISTRE ENTIER seqNum_660004603
REGISTRE ENTIER ic_cellId_660004603
REGISTRE ENTIER date_art_660004603
REGISTRE ENTIER date_fin_660004603
REGISTRE ENTIER partial_type_indicator_660004603
REGISTRE ENTIER valid_chp_660004603
REGISTRE ENTIER cellIdFor1st_present_660004603
REGISTRE ENTIER chargingCharac_present_660004603
REGISTRE ENTIER iPBinV4Ad_present_660004603
REGISTRE ENTIER iPBinV6Ad_present_660004603
REGISTRE ENTIER iPTextV4Ad_present_660004603
REGISTRE ENTIER iPTextV6Ad_present_660004603
REGISTRE ENTIER present_660004603
REGISTRE ENTIER NB_VolDo_660004603
REGISTRE ENTIER indice_660004603
REGISTRE ENTIER indiceUp_660004603
REGISTRE ENTIER SomVolDo_660004603
REGISTRE ENTIER NB_VolUp_660004603
REGISTRE ENTIER SomVolUp_660004603
REGISTRE ENTIER indQosNegoTS1_660004603
REGISTRE ENTIER indQosNegoTS2_660004603
REGISTRE ENTIER indQosNegoTS3_660004603
REGISTRE ENTIER indQosNego1_660004603
REGISTRE ENTIER indQosNego2_660004603
REGISTRE ENTIER indQosNego3_660004603
REGISTRE ENTIER indDataVol1_660004603
REGISTRE ENTIER indDataVol2_660004603
REGISTRE ENTIER indDataVol3_660004603
REGISTRE ENTIER indDataVol4_660004603
REGISTRE ENTIER res_660004603
REGISTRE ENTIER code_rejet_660004603
REGISTRE ENTIER EFFICACE_660004603
REGISTRE ENTIER MODULE_660004603
REGISTRE ENTIER ERREUR_660004603
REGISTRE ENTIER indice_duptab_660004603
REGISTRE ENTIER UMTS_660004603
REGISTRE ENTIER dig1_660004603
REGISTRE ENTIER dig2_660004603
REGISTRE ENTIER qoSIVolGprsUp_val_660004603
REGISTRE ENTIER GPRS_660004603
REGISTRE ENTIER Service3GDT_660004603
REGISTRE ENTIER date_3GDT_660004603
REGISTRE ENTIER date_table_660004603
REGISTRE ENTIER rattype_660004603
REGISTRE ENTIER present_ratType_660004603
REGISTRE ENTIER present_qoSI1Used_660004603
REGISTRE ENTIER present_qoSI2Used_660004603
REGISTRE ENTIER present_qoSI3Used_660004603
REGISTRE ENTIER WLAN_660004603
REGISTRE ENTIER RoamingIN_660004603
REGISTRE ENTIER RoamingOUT_660004603
REGISTRE ENTIER longueur_660004603
REGISTRE ENTIER flag_KeyTADIC_660004603
REGISTRE POINTEUR pt_TADIG_660004603
REGISTRE POINTEUR pt_MCCMNC_660004603
REGISTRE POINTEUR pt_pLMNid_660004603
REGISTRE POINTEUR pt_servedIMSI_660004603
REGISTRE POINTEUR pt_res_5_660004603
REGISTRE POINTEUR pt_MCCMNC_DCB_660004603
REGISTRE POINTEUR pt_val_idemet_660004603
REGISTRE POINTEUR pt_SGTQS_660004603
REGISTRE POINTEUR pt_BUFFER_660004603
REGISTRE POINTEUR ptr_valeurDATE_660004603
REGISTRE POINTEUR ptr_date_res_660004603
#########################################################################
#    Article Tbgw_gsn -- Module de Distribution
#
#    Creation
# g_iartin Tbgw_gsn
# g_iartout Tdpvgsm
# g_iartout3 Conv_URS
# g_iartout11 Rejet
# g_iartout12 : sauvegarde de l'article IN (g_iartin)
#
#########################################################################
#
# correction ano TT 0007
# 16/04/08 URS G1R7 lot 2
# 03/06/08 URS G1R7 QC87 : mauvaise alimentation du T4t20.6
# 13/06/08 URS G1R7 QC94 : renforcement de l'algo pour enrichissement du T4t20.6
# 07/07/08 URS G1R7 QC135 : modif enrichissement T3t3 GGSN (longueur de UserLocationInformation passe de 11 a 8 octets)
# 11/02/09 DRE G2R2 lot1 item differenciation des equipements xGSN par l'idemet spec version A5.0
# 11/06/2010 - JLG - G2R6C800 : appel fonction aiguillage2, creation enveloppe E_Redistri2,
#                               ajout champ T3t55 (GFlag2) et T3t56 (GValue)
# 22/11/2010 - JLG - G3R1lot4 Verification/Correction des variables (constantes, entiers, pointeurs)
# 13/01/2011 - PSA - G3R2 : ajout champ T3t99
# 23/02/2011 - PKH - G3R3 : lot1 item 3GDT DIRECT TUNNEL
# 10/03/2011 - JLG - G3R2C4 fusion G3R2C3 avec G3R1C600 (ajout champ T3t99)
# 24/03/2011 - JLG - G3R3C1 fusion G3R2C5 (pointeurs+QC826) avec G3R3C0 (lot1 item 3GDT DIRECT TUNNEL)
# 29/03/2011 - PKH - G3R3 : lot2 QC825 valorisation du champs V3t5 IMEI  par criteres technique et non par duplication
# 03/05/2011 - PKH - G3R3 : QC825 reprise de correction mauvaise valorisation du champ V3t5 IMEI
# 12/05/2011 - PKH - QC866 modification de l algo pour les booleens UMTS et GPRS
# 13/05/2011 - PKH - QC865 mettre 0xFF par defaut SI GGSN==1 et ratType absent et Service3GDT == 0 dans T3t1.10(systype)
# 25/07/2011 - PKH - G3R4 lot2 Identification du code operateur de roaming TADIG
# 07/09/2011 - JLG - G3R4 integration modif G3R3C11 QC928 [3GDT] Prise en compte de toutes les valeurs du champ ratType
# 09/09/2011 - JLG - G3R4 QC918 modif suite a evol format du champ T3t59 du Dpvgsm
# 14/09/2011 - JLG - QC921, 929 : TCB pb d'alimentation de V3T51 avec la valeur de retour de la table MCCMNC_TADIG
# 17/10/2011 - JLG - G3R4C5 QC951 Evolution recherche TADIG de DC ggsn avec PLMNId sur 5 ou 6 octets
# 26/10/2011 - PKH - QC953 Evolution traitement des cras RoamingOUT et RoamingIN avec l'Item TADIG
# 26/10/2011 - PKH - QC954 Evolution des conditions de test pour  enrichir le champ V4T20.5
# 03/11/2011 - PKH-JLG - QC954 2eme Evolution des conditions de test pour  enrichir le champ V4T20.5
# 26/12/2011 - PKH - G3R5 lot2 Modification du traitement des cras partiels
# 19/01/2012 - PKH - QC997 V4t20.6 PartialType mal aliment? pour les valeurs de cause 0 et 4
# 29/02/2012 - JLG -G3R6 QC1005 modif alarme retour aiguillage
# 10/01/2013 - PKH - G3R9 lot1 cra OBIWAN traiement des cra WLAN (rattype == 3)
# 18/06/2013 - JLG - G3R10 lot3 : Evolutions CRAs Sgsn et Ggsn
# 11/02/2014 - JLG -G5R1 QC1331, Built 3 : Changement Marque Audit
# 02/07/2014 - JLG -G5R1 QC1405, champ eec du DPV si g_ieec > 500  
##############################################



# variables pour les indices des TimeStamp de QoS negociated

# QC94
#G3R3
#G3R4 lot2
#G3R4 lot2

#G3R3

# Initialisations
EFFICACE_660004603 = 1
MODULE_660004603 = MODULE_DISTR_660004603
ERREUR_660004603 = 0
code_rejet_660004603 = 0
# QC94

#G3R3
GPRS_660004603 = 0
UMTS_660004603 = 0
Service3GDT_660004603 = 0
date_3GDT_660004603 = 0
date_table_660004603 = 0
rattype_660004603 = 0
present_ratType_660004603 = 0
present_qoSI1Used_660004603 = 0
present_qoSI2Used_660004603 = 0
present_qoSI3Used_660004603 = 0

longueur_660004603 = 0
flag_KeyTADIC_660004603 = 0
WLAN_660004603 = 0
pt_TADIG_660004603 = "pt_TADIG333333333333333333333333333333333333333333333333333333333333333333333333333333333"
pt_MCCMNC_660004603 = "pt_MCCMNC85858585858588585858585858585858585858585858585858585858585858585858585858585858"
pt_pLMNid_660004603 = "pt_pLMNid949494949494949494949494949494949494949494949494949494949494949494949494949494949"
pt_servedIMSI_660004603 = "pt_servedIMSI454545454545454545454545455454545454455454455445454545455445454554544554"
pt_res_5_660004603 = "pt_res_597979799797997979797979797977979799797979797979797979797979797979797979797979797979"
pt_MCCMNC_DCB_660004603 = "pt_MCCMNC_DCB8888888888888888888888888888888888888888888888888888888888888888888888888"
pt_val_idemet_660004603 = "idemet1234445556788"
indice_duptab_660004603 = 0
pt_SGTQS_660004603 = "pt_SGTQS111111111111111111111111111111111"
pt_BUFFER_660004603 = "pt_BUFFER2222222222222222222222222222222222222222222222222222222222222222222222222222222"
ptr_valeurDATE_660004603 = "ptr_valeurDATE6576576576576576576575675657567556755675657556755675565756575675567556"
ptr_date_res_660004603 = "ptr_date_res9191991919919119911919191919991919919991919919191199191919991919191991919"

trace("## debut PCode de distribution Tbgw_gsn ##")

#initialisation pointeurs
i_strcpy(pt_SGTQS_660004603,"")
i_strcpy(pt_BUFFER_660004603,"")
i_strcpy(pt_val_idemet_660004603,"")
i_strcpy(ptr_valeurDATE_660004603,"")
i_strcpy(ptr_date_res_660004603,"")

i_strcpy(pt_MCCMNC_660004603,"")
i_strcpy(pt_TADIG_660004603,"")
#i_strcpy(pt_pLMNid,"") fait plus bas
#i_strcpy(pt_servedIMSI,"") fait plus bas
i_strcpy (pt_res_5_660004603,"")
i_strcpy (pt_MCCMNC_DCB_660004603,"")

trace("## debut PCode de distribution Tbgw_gsn ##")

##################################################################################
# Identification de la provenance de l'article
# flag_rdt : nb de passage en redistribution (lecture de l'enveloppe obligatoire)
##################################################################################
flag_rdt_660004603 = -1
flag_rdt_660004603 = i_LireRedistCpt()
SI (flag_rdt_660004603 == 0)
ALORS
  erreur_660004603 = i_add_opt( "E_Redistri2" )
FINSI
erreur_660004603 = i_set_attr_val_n( $E_Redistri2::EnvoiRedis, 0)

#initialisation du recordtype
recordtype_660004603 = i_get_art_field(g_iartin,$Tbgw_gsn::recordType)

erreur_660004603 = i_cree_art("Conv_URS",g_iartout3)

#QC688====================================
date_3GDT_660004603 = i_get_art_field(g_iartin,$Tbgw_gsn::recOpenTime)
i_strcpy(ptr_valeurDATE_660004603,i_get_tab_field("VariableContexte",date_3GDT_660004603,"DATE_Service3GDTimei"))
SI ( i_strcmp( ptr_valeurDATE_660004603,g_inull) != 0 )
ALORS
  i_get_sub_str(ptr_valeurDATE_660004603,2,-1,ptr_date_res_660004603)
  erreur_660004603 = i_set_art_str (g_iartout3,$Conv_URS::DATE,ptr_date_res_660004603)
  date_table_660004603 = i_get_art_field(g_iartout3, $Conv_URS::DATEN)
  SI (date_3GDT_660004603 >= date_table_660004603)
  ALORS
    Service3GDT_660004603 = 1
  FINSI
FINSI

present_ratType_660004603 = i_valid_field_n(g_iartin,$Tbgw_gsn::ratType)
present_qoSI1Used_660004603 = i_valid_field_n(g_iartin,$Tbgw_gsn::qoSI1Used)
present_qoSI2Used_660004603 = i_valid_field_n(g_iartin,$Tbgw_gsn::qoSI2Used)
present_qoSI3Used_660004603 = i_valid_field_n(g_iartin,$Tbgw_gsn::qoSI3Used)

SI (present_ratType_660004603)
ALORS
  rattype_660004603 = i_get_art_field(g_iartin, $Tbgw_gsn::ratType)
FINSI

#G3R9 lot1 OBIWAN
#G3R10
SI (rattype_660004603 == 3 && recordtype_660004603 == GGSN_660004603)
ALORS
     WLAN_660004603 = 1
FINSI

SI (rattype_660004603 == 2 || !present_ratType_660004603)
ALORS
   GPRS_660004603 = 1
FINSI

SI (rattype_660004603 == 1 || rattype_660004603 == 5)
ALORS
  UMTS_660004603 = 1
FINSI
#/G3R10

#####################################################################
# Creation DPV TLV
#####################################################################

trace("[Dist] Tbgw_gsn : debut Distribution")

# sauvegarde de l'article original dans le g_iartout12
erreur_660004603 = i_dup_art_id(g_iartin , g_iartout12)

date_fin_660004603=i_get_art_field(g_iartin,$Tbgw_gsn::dfin)
erreur_660004603= i_incr_redist_dist_660004265(date_fin_660004603)

###############################################
# ajout du T3t4/MSISDN
###############################################
# modification du premier octet du servedMSISDN
SI ( i_valid_field_n(g_iartin,$Tbgw_gsn::servedMSISDN) )
ALORS
  dig1_660004603 = i_get_art_fieldtab(g_iartin,$Tbgw_gsn::servedMSISDN, 0)
  dig2_660004603 = i_get_art_fieldtab(g_iartin,$Tbgw_gsn::servedMSISDN, 1)
  SI ( ((dig1_660004603 == 1) && (dig2_660004603 == 9)) || ((dig1_660004603 == 9) && (dig2_660004603 == 1)) )
  ALORS
    erreur_660004603 = i_set_art_fieldtab(g_iartout12,$Tbgw_gsn::servedMSISDN, 0, 1)
    erreur_660004603 = i_set_art_fieldtab(g_iartout12,$Tbgw_gsn::servedMSISDN, 1, 1)
  SINON
    SI ( ((dig1_660004603 == 1) && (dig2_660004603 == 0)) || ((dig1_660004603 == 1) && (dig2_660004603 == 8)) )
    ALORS
      erreur_660004603 = i_set_art_fieldtab(g_iartout12,$Tbgw_gsn::servedMSISDN, 0, 1)
      erreur_660004603 = i_set_art_fieldtab(g_iartout12,$Tbgw_gsn::servedMSISDN, 1, 2)
    SINON
      SI ( ((dig1_660004603 == 1) && (dig2_660004603 == 2)) || ((dig1_660004603 == 1) && (dig2_660004603 == 0x0A)) )
      ALORS
        erreur_660004603 = i_set_art_fieldtab(g_iartout12,$Tbgw_gsn::servedMSISDN, 0, 1)
        erreur_660004603 = i_set_art_fieldtab(g_iartout12,$Tbgw_gsn::servedMSISDN, 1, 4)
      SINON
        SI ( ((dig1_660004603 == 0) && (dig2_660004603 == 1)) || ((dig1_660004603 == 8) && (dig2_660004603 == 1)) )
        ALORS
          erreur_660004603 = i_set_art_fieldtab(g_iartout12,$Tbgw_gsn::servedMSISDN, 0, 2)
          erreur_660004603 = i_set_art_fieldtab(g_iartout12,$Tbgw_gsn::servedMSISDN, 1, 1)
        SINON
          SI ( ((dig1_660004603 == 2) && (dig2_660004603 == 1)) || ((dig1_660004603 == 0x0A) && (dig2_660004603 == 1)) )
          ALORS
            erreur_660004603 = i_set_art_fieldtab(g_iartout12,$Tbgw_gsn::servedMSISDN, 0, 4)
            erreur_660004603 = i_set_art_fieldtab(g_iartout12,$Tbgw_gsn::servedMSISDN, 1, 1)
          FINSI
        FINSI
      FINSI
    FINSI
  FINSI
FINSI
###########

SI( (i_valid_field_n(g_iartin,$Tbgw_gsn::serviceKey)
  + i_valid_field_n(g_iartin,$Tbgw_gsn::levelOfCAMServ)
  + i_valid_field_n(g_iartin,$Tbgw_gsn::defTransHand)) == 0 )
ALORS
# duplication sans T4t18.5
  SI (UMTS_660004603)
  ALORS
#   cas UMTS
    indice_duptab_660004603 = 3
  SINON
    SI ( recordtype_660004603 == SGSN_660004603 )
    ALORS
#     GPRS SGSN
      indice_duptab_660004603 = 3
    SINON
      SI (WLAN_660004603 != 0)
      ALORS
# WLAN
        indice_duptab_660004603 = 3
      SINON
#     GPRS GGSN
        indice_duptab_660004603 = 1
      FINSI
    FINSI
  FINSI
SINON
# duplication avec T4t18.5
  SI (UMTS_660004603)
  ALORS
#   cas UMTS
    indice_duptab_660004603 = 2
  SINON
    SI ( recordtype_660004603 == SGSN_660004603 )
    ALORS
#     GPRS SGSN
      indice_duptab_660004603 = 2
    SINON
      SI (WLAN_660004603)
      ALORS
# WLAN        
        indice_duptab_660004603 = 2
      SINON
#     GPRS GGSN
        indice_duptab_660004603 = 0
      FINSI
    FINSI
  FINSI
FINSI
erreur_660004603 = i_dup_art_tab_choix(g_iartout12,g_iartout,"Tdpvgsm", indice_duptab_660004603)
SI (erreur_660004603 != 0)
ALORS
  trace("[Dist] Tbgw_gsn :Erreur de duplication")
  ERREUR_660004603 = ERR_DUPL_660004603
  code_rejet_660004603 = MODULE_660004603 + ERREUR_660004603 + EFFICACE_660004603
  erreur_660004603= i_PlvMessEmettre(8706 ,2, g_iartin, "", 2, code_rejet_660004603, "Tdpvgsm", 0)
  SAUT STOCKE_ERRONE
FINSI
# fin de la duplication hors table commune TLV27 TLV28
#####################################################################


###############################################
# ajout du T3t3/local
###############################################
## SGSN ##
# traitement anterieur a la G1R7
SI (recordtype_660004603 == SGSN_660004603)
ALORS
  SI ( i_valid_field_n(g_iartin,$Tbgw_gsn::pLMNIdentifier) )
  ALORS
    erreur_660004603 = i_ajout_tlv(g_iartout,"T3t3","")
    # resize a 7 octets car plMNId sur 3 octets, et cellId et locationArea sur 2octets
    erreur_660004603 = i_resize_tlv(g_iartout,"T3t3","local",7*8)
    # creation du cellIdFor1st avec le pLMNIdentifier, locatioarea et cellIdentifier
    # suppression du "F" du pLMNIdnetifier puis concatenation
    # 0x02F810 convertit en 0x208F01, donc il reste ? supprimer le "F" qui est en 4eme position
    erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 0, i_get_art_fieldtab(g_iartin,$Tbgw_gsn::pLMNIdentifier, 0))
    erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 1, i_get_art_fieldtab(g_iartin,$Tbgw_gsn::pLMNIdentifier, 1))
    erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 2, i_get_art_fieldtab(g_iartin,$Tbgw_gsn::pLMNIdentifier, 2))
    erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 3, i_get_art_fieldtab(g_iartin,$Tbgw_gsn::pLMNIdentifier, 4))
    erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 4, i_get_art_fieldtab(g_iartin,$Tbgw_gsn::pLMNIdentifier, 5))
    SI ( i_valid_field_n(g_iartin,$Tbgw_gsn::locationArea) )
    ALORS
      erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 5, i_get_art_fieldtab(g_iartin,$Tbgw_gsn::locationArea, 0))
      erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 6, i_get_art_fieldtab(g_iartin,$Tbgw_gsn::locationArea, 1))
      erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 7, i_get_art_fieldtab(g_iartin,$Tbgw_gsn::locationArea, 2))
      erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 8, i_get_art_fieldtab(g_iartin,$Tbgw_gsn::locationArea, 3))
      erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 9, i_get_art_fieldtab(g_iartin,$Tbgw_gsn::cellIdentifier, 0))
      erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 10, i_get_art_fieldtab(g_iartin,$Tbgw_gsn::cellIdentifier, 1))
      erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 11, i_get_art_fieldtab(g_iartin,$Tbgw_gsn::cellIdentifier, 2))
      erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 12, i_get_art_fieldtab(g_iartin,$Tbgw_gsn::cellIdentifier, 3))
    SINON
      # si locationArea absent, alors on concatene le plMNIdentifier avec "00000000"
      erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 5, 0)
      erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 6, 0)
      erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 7, 0)
      erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 8, 0)
      erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 9, 0)
      erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 10, 0)
      erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 11, 0)
      erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 12, 0)
    FINSI
    erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 13, 0xF)
  FINSI

#===========test syntaxique du cellIdFor1st==========================
  valid_chp_660004603 = i_valid_field_n(g_iartout, $Tdpvgsm::local)
  SI (valid_chp_660004603)
  ALORS
    erreur_660004603 = i_test_field_ila_n(g_iartout, $Tdpvgsm::local, "Lmap")
    SI (erreur_660004603)
    ALORS
      trace("Tbgw_gsn : Le champ cellIdFor1st presente une syntaxe errone")
      ERREUR_660004603 = ERR_SYNTAX_660004603
      code_rejet_660004603 = MODULE_660004603 + ERREUR_660004603 + EFFICACE_660004603
      erreur_660004603=i_PlvMessEmettre(8702, 2, g_iartin, "", 3, code_rejet_660004603,"cellIdFor1st", "MAP")
      SAUT STOCKE_ERRONE
    FINSI
  FINSI
  SAUT FIN_LOCAL
FINSI

## GGSN ##
# ajout G1R7
SI (recordtype_660004603 == GGSN_660004603)
ALORS
  SI ( i_valid_field_n(g_iartin,$Tbgw_gsn::pLMNIdentifier) )
  ALORS
    erreur_660004603 = i_ajout_tlv(g_iartout,"T3t3","")

    erreur_660004603 = i_resize_tlv(g_iartout,"T3t3","local",7*8)
    # creation du cellIdFor1st avec le pLMNIdentifier et userLocationInformation
    # suppression du "F" du pLMNIdnetifier puis concatenation
    # 0x02F810 convertit en 0x208F01, donc il reste ? supprimer le "F" qui est en 4eme position
    erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 0, i_get_art_fieldtab(g_iartin,$Tbgw_gsn::pLMNIdentifier, 0))
    erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 1, i_get_art_fieldtab(g_iartin,$Tbgw_gsn::pLMNIdentifier, 1))
    erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 2, i_get_art_fieldtab(g_iartin,$Tbgw_gsn::pLMNIdentifier, 2))
    erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 3, i_get_art_fieldtab(g_iartin,$Tbgw_gsn::pLMNIdentifier, 4))
    erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 4, i_get_art_fieldtab(g_iartin,$Tbgw_gsn::pLMNIdentifier, 5))
# G1R7 : QC135
    SI ( i_get_art_field(g_iartin,$Tbgw_gsn::userLocInfo - 1) == 8 )
    ALORS
      erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 5, i_get_art_fieldtab(g_iartin,$Tbgw_gsn::userLocInfoDCB, 8))
      erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 6, i_get_art_fieldtab(g_iartin,$Tbgw_gsn::userLocInfoDCB, 9))
      erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 7, i_get_art_fieldtab(g_iartin,$Tbgw_gsn::userLocInfoDCB, 10))
      erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 8, i_get_art_fieldtab(g_iartin,$Tbgw_gsn::userLocInfoDCB, 11))
      erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 9, i_get_art_fieldtab(g_iartin,$Tbgw_gsn::userLocInfoDCB, 12))
      erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 10, i_get_art_fieldtab(g_iartin,$Tbgw_gsn::userLocInfoDCB, 13))
      erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 11, i_get_art_fieldtab(g_iartin,$Tbgw_gsn::userLocInfoDCB, 14))
      erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 12, i_get_art_fieldtab(g_iartin,$Tbgw_gsn::userLocInfoDCB, 15))
    SINON
      # si locationArea absent, alors on concatene le plMNIdentifier avec "00000000"
      erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 5, 0)
      erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 6, 0)
      erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 7, 0)
      erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 8, 0)
      erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 9, 0)
      erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 10, 0)
      erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 11, 0)
      erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 12, 0)
    FINSI
    erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::local, 13, 0xF)
  FINSI

#===========test syntaxique du cellIdFor1st==========================
  valid_chp_660004603 = i_valid_field_n(g_iartout, $Tdpvgsm::local)
  SI (valid_chp_660004603)
  ALORS
    erreur_660004603 = i_test_field_ila_n(g_iartout, $Tdpvgsm::local, "Lmap")
    SI (erreur_660004603)
    ALORS
      trace("Tbgw_gsn : Le champ cellIdFor1st presente une syntaxe errone")
      ERREUR_660004603 = ERR_SYNTAX_660004603
      code_rejet_660004603 = MODULE_660004603 + ERREUR_660004603 + EFFICACE_660004603
      erreur_660004603=i_PlvMessEmettre(8702, 2, g_iartin, "", 3, code_rejet_660004603,"userLocationInformation", "MAP")
      SAUT STOCKE_ERRONE
    FINSI
  FINSI
  SAUT FIN_LOCAL
FINSI

POINT FIN_LOCAL

##############
# T3t1.1 (type)
erreur_660004603 = i_set_art_field(g_iartout,$Tdpvgsm::type,0x90)

#G3R4 lot2 evaluation de RoamingIN, RoamingOUT

# T3t1.2 (tentite); variables fonctionnelles RoamingIN, RoamingOUT
#tentite=0x06 si T3t2/recordType = SGSN
#tentite=0x07  si T3t2/recordType = GGSN
RoamingIN_660004603=0
RoamingOUT_660004603=0

## SGSN ##
SI (recordtype_660004603 == SGSN_660004603)
ALORS
  erreur_660004603 = i_set_art_field(g_iartout,$Tdpvgsm::tentite,6)
  i_strcpy(pt_servedIMSI_660004603,"")
  erreur_660004603 = i_get_art_str(g_iartin, $Tbgw_gsn::servedIMSI, pt_servedIMSI_660004603)
  SI (i_strlen(pt_servedIMSI_660004603) > 6)
  ALORS
    i_get_sub_str (pt_servedIMSI_660004603, 0, 5, pt_servedIMSI_660004603)
  FINSI
  i_get_sub_str(pt_servedIMSI_660004603,0,4,pt_res_5_660004603)
  SI (i_strplcmp( pt_servedIMSI_660004603, "208", 0, 3) !=0 && i_strcmp(pt_servedIMSI_660004603, "") !=0)
  ALORS
    RoamingIN_660004603 = 1
  FINSI
FINSI

## GGSN ##
SI (recordtype_660004603 == GGSN_660004603)
ALORS
  erreur_660004603 = i_set_art_field(g_iartout,$Tdpvgsm::tentite,7)
  
  #QC951 on se sert du champ local (tableau DCB) de Conv_URS pour convertir le champ Tbgw_gsn::pLMNIdentifier
  erreur_660004603 = i_set_art_fieldtab(g_iartout3,$Conv_URS::local, 0, i_get_art_fieldtab(g_iartin,$Tbgw_gsn::pLMNIdentifier, 0))
  erreur_660004603 = i_set_art_fieldtab(g_iartout3,$Conv_URS::local, 1, i_get_art_fieldtab(g_iartin,$Tbgw_gsn::pLMNIdentifier, 1))
  erreur_660004603 = i_set_art_fieldtab(g_iartout3,$Conv_URS::local, 2, i_get_art_fieldtab(g_iartin,$Tbgw_gsn::pLMNIdentifier, 2))
  erreur_660004603 = i_set_art_fieldtab(g_iartout3,$Conv_URS::local, 3, i_get_art_fieldtab(g_iartin,$Tbgw_gsn::pLMNIdentifier, 4))
  erreur_660004603 = i_set_art_fieldtab(g_iartout3,$Conv_URS::local, 4, i_get_art_fieldtab(g_iartin,$Tbgw_gsn::pLMNIdentifier, 5))
  erreur_660004603 = i_set_art_fieldtab(g_iartout3,$Conv_URS::local, 5, i_get_art_fieldtab(g_iartin,$Tbgw_gsn::pLMNIdentifier, 3))
  #/QC951
  i_strcpy(pt_pLMNid_660004603,"")
  erreur_660004603 = i_get_art_str(g_iartout3, $Conv_URS::local, pt_pLMNid_660004603)
  SI (i_strplcmp( pt_pLMNid_660004603, "208", 0, 3) !=0 && i_strcmp(pt_pLMNid_660004603, "") !=0)
  ALORS
    RoamingOUT_660004603 = 1
  FINSI
FINSI
trace3 (">>__FILE__>>__LINE__>> === RoamingIN = <%d>, RoamingOUT = <%d> ===",RoamingIN_660004603,RoamingOUT_660004603,0)

#G3R4 Lot2
SI RoamingOUT_660004603
ALORS
  #Cas T3t1.2 = 0x07, recordtype = GGSN
  # pt_MCCMNC contiendra la valeur de retour TADIG_MCCMNC
  i_strcpy(pt_MCCMNC_660004603,i_get_tab_field("MCCMNC_TADIG", date_fin_660004603, pt_pLMNid_660004603))
  SI (i_strcmp( pt_MCCMNC_660004603, g_inull)  != 0)
  ALORS
    flag_KeyTADIC_660004603 = 1
    erreur_660004603 = i_recupererValeur(pt_MCCMNC_660004603,pt_TADIG_660004603,5,'-')
    SI (i_strcmp (pt_MCCMNC_660004603,g_inull) == 0)
    ALORS
      # si retour MCCMNC null (fictive) alors = cle (pt_pLMNid)
      i_strcpy(pt_MCCMNC_660004603,pt_pLMNid_660004603)
    FINSI
  SINON
    trace ("<<__LINE__>> ========= Erreur cas 0x07 envoie en errone ============")
    ERREUR_660004603 = ERR_TAB_660004603
    code_rejet_660004603 = MODULE_660004603 + ERREUR_660004603 + EFFICACE_660004603
    erreur_660004603=i_PlvMessEmettre(7518, 2, g_iartin, "", 3, code_rejet_660004603,"Tbgw_gsn - MCCMNC_TADIC", pt_pLMNid_660004603)
    SAUT STOCKE_ERRONE
  FINSI
FINSI

SI RoamingIN_660004603
ALORS
  #Cas T3t1.2 = 0x06, recordtype = SGSN
  # cle (pt_servedIMSI = servedIMSI sur 6 caracteres), pt_MCCMNC contiendra la valeur de retour TADIG_MCCMNC
  i_strcpy(pt_MCCMNC_660004603,i_get_tab_field("MCCMNC_TADIG", date_fin_660004603, pt_servedIMSI_660004603))
  SI (i_strcmp( pt_MCCMNC_660004603, g_inull)  != 0)
  ALORS
    # pt_MCCMNC contiend au depart l'ensemble TADIG_MCCMNC
    # pt_MCCMNC contiendra la partie MCCMNC et pt_TADIG la partie TADIG apres i_recupererValeur
    flag_KeyTADIC_660004603 = 1
    erreur_660004603 = i_recupererValeur(pt_MCCMNC_660004603,pt_TADIG_660004603,5,'-')
    SI (i_strcmp (pt_MCCMNC_660004603,g_inull) == 0)
    ALORS
      # si retour MCCMNC null (fictive) alors = cle (pt_servedIMSI sur 6 caracteres)
      i_strcpy(pt_MCCMNC_660004603,pt_servedIMSI_660004603)
    FINSI
  SINON
    #cle (pt_res_5 = servedIMSI sur 5 caracteres) ,  pt_MCCMNC contiendra la valeur de retour TADIG_MCCMNC
    i_strcpy(pt_MCCMNC_660004603,i_get_tab_field("MCCMNC_TADIG", date_fin_660004603, pt_res_5_660004603))
    SI (i_strcmp( pt_MCCMNC_660004603, g_inull)  != 0)
    ALORS
      # pt_MCCMNC contiend au depart l'ensemble TADIG_MCCMNC
      # pt_MCCMNC contiendra la partie MCCMNC et pt_TADIG la partie TADIG apres i_recupererValeur
      flag_KeyTADIC_660004603 = 1
      erreur_660004603 = i_recupererValeur(pt_MCCMNC_660004603,pt_TADIG_660004603,5,'-')
      SI (i_strcmp (pt_MCCMNC_660004603,g_inull) == 0)
      ALORS
        # si retour MCCMNC null (fictive) alors = cle (pt_servedIMSI sur 5 caracteres)
        i_strcpy(pt_MCCMNC_660004603,pt_res_5_660004603)
      FINSI
#QC953 ne va pas dans les errone et pas emission alarme     
    FINSI
  FINSI
FINSI
trace2("<<__LINE__>>=============== pt_MCCMNC = %s pt_TADIG = %s ===================",pt_MCCMNC_660004603,pt_TADIG_660004603)

#/G3R4 Lot2

#############
# T3t1.14/tterm  :- ::MSET :ff:1
cause_660004603=i_get_art_field(g_iartin,$Tbgw_gsn::cause)
# cas particulier GGSN et cause = 100 => tterm = 4
SI (cause_660004603 == 100 && recordtype_660004603 == GGSN_660004603)
ALORS
  erreur_660004603 = i_set_art_field(g_iartout,$Tdpvgsm::tterm,0x04)
SINON
# autres cas
  SI (cause_660004603 == 0)
  ALORS
    erreur_660004603 = i_set_art_field(g_iartout,$Tdpvgsm::tterm,0)
  FINSI
  SI (cause_660004603 == 4)
  ALORS
    erreur_660004603 = i_set_art_field(g_iartout,$Tdpvgsm::tterm,0x10)
  FINSI
  SI (cause_660004603 == 5)
  ALORS
    erreur_660004603 = i_set_art_field(g_iartout,$Tdpvgsm::tterm,0x0A)
  FINSI
  SI (cause_660004603 >= 16 && cause_660004603 <= 20)
  ALORS
    erreur_660004603 = i_set_art_field(g_iartout,$Tdpvgsm::tterm,(cause_660004603-5))
  FINSI
  SI (cause_660004603 == 101)
  ALORS
    erreur_660004603 = i_set_art_field(g_iartout,$Tdpvgsm::tterm,0x1D)
  FINSI
FINSI

#############
# T3t1/idemet
date_art_660004603 = i_get_art_field(g_iartin,$Tbgw_gsn::recOpenTime)

#DRE 11/02/09 G2R2
i_strcpy (pt_SGTQS_660004603,i_LireEECSGTQS(g_ieec))
erreur_660004603 = i_format_str2(pt_BUFFER_660004603,"%s%s","AX_IDEMET_",pt_SGTQS_660004603)

pt_val_idemet_660004603 = i_get_tab_field("VariableContexte",date_art_660004603,pt_BUFFER_660004603)
SI ( i_strcmp( pt_val_idemet_660004603,g_inull) != 0 )
ALORS
  erreur_660004603 = affectation_tab_660004265(g_iartout,$Tdpvgsm::idemet,pt_val_idemet_660004603)
SINON
#DRE 11/02/09 G2R2
  erreur_660004603 = affectation_tab_660004265(g_iartout,$Tdpvgsm::idemet,"33024000000FFFFFFF")
FINSI

##################################
## calcul de la valeur de "seqNum"
#QC954
#interro de la table variablecontexte 

SI (!i_valid_field_n(g_iartin,$Tbgw_gsn::seqNum))
ALORS
  seqNum_660004603 = 1
SINON
  SI ( recordtype_660004603 == GGSN_660004603)
  ALORS
    erreur_660004603 = i_format_str2(pt_BUFFER_660004603,"%s%s","Filtre_GGSN_",pt_SGTQS_660004603)
    SI ( i_get_tab_field("VariableContexte",date_art_660004603,pt_BUFFER_660004603) == g_inull )
    ALORS
      seqNum_660004603 = i_get_art_field(g_iartin,$Tbgw_gsn::seqNum) - 1
    SINON
      seqNum_660004603 = i_get_art_field(g_iartin,$Tbgw_gsn::seqNum)
    FINSI
  SINON
    seqNum_660004603 = i_get_art_field(g_iartin,$Tbgw_gsn::seqNum)
  FINSI
FINSI

#  --- champ partial type indicator
#  si cause = normal ou anormal =>  partial_type_indicator = 3
#  sinon si sequenceNumber = 1 => partial_type_indicator = 1
#  sinon partial_type_indicator = 2
SI (( cause_660004603 == 0 ) || ( cause_660004603 == 4 ))
ALORS
  partial_type_indicator_660004603 = 3
SINON
  SI ( seqNum_660004603 == 1 )
  ALORS
    partial_type_indicator_660004603 = 1
  SINON
    partial_type_indicator_660004603 = 2
  FINSI
FINSI
erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::PartialType, partial_type_indicator_660004603)

#G3R10 T3t1.10 (systype)
SI (recordtype_660004603 == GGSN_660004603)
ALORS
  SI (Service3GDT_660004603 && GPRS_660004603)
  ALORS
    erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::systype, 0x00)
  SINON
    SI (Service3GDT_660004603 && UMTS_660004603)
    ALORS
      erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::systype, 0x01)
    SINON
      SI (WLAN_660004603)
      ALORS
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::systype, 0x03)
      SINON
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::systype, 0xFF)
      FINSI
    FINSI
  FINSI
SINON
  SI (UMTS_660004603)
  ALORS
    erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::systype, 0x01)
  SINON
    erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::systype, 0x00)
  FINSI
FINSI
#/G3R10

# Mise a jour du champ T3t1/origine en fonction du cellIdFor1st
# (ce champ est la concatenation du pLMNIdentifier + locationAreaCode + cellIdentifier)
# et c'est dans le champ "Tdpvgsm::local" que l'on a cree ce cellIdFor1st
ic_cellId_660004603 = $Tdpvgsm::local
# --- valeur du champ origine fonction du champ cellIdFor1st
cellIdFor1st_present_660004603 = i_valid_field_n(g_iartout, ic_cellId_660004603)
SI (cellIdFor1st_present_660004603)
ALORS
# --- Si cellIdFor1st = 20801*
  SI ( ((i_get_art_fieldtab(g_iartout, ic_cellId_660004603, 0) == 2 ) &&
    (i_get_art_fieldtab(g_iartout, ic_cellId_660004603, 1) == 0 ) &&
    (i_get_art_fieldtab(g_iartout, ic_cellId_660004603, 2) == 8 ) &&
    (i_get_art_fieldtab(g_iartout, ic_cellId_660004603, 3) == 0 ) &&
    (i_get_art_fieldtab(g_iartout, ic_cellId_660004603, 4) == 1 )))
  ALORS
    erreur_660004603 = i_set_art_field(g_iartout,$Tdpvgsm::origine,0)
  SINON
    erreur_660004603 = i_set_art_field(g_iartout,$Tdpvgsm::origine,1)
  FINSI
FINSI

#------mise a jour de champ chgcar
chargingCharac_present_660004603 = i_valid_field_n(g_iartin,$Tbgw_gsn::chargingCharac)
SI (chargingCharac_present_660004603)
ALORS
  erreur_660004603 = i_set_art_field(g_iartout,$Tdpvgsm::chgcar,i_get_art_field(g_iartin,$Tbgw_gsn::chargingCharac))
FINSI

#QC825 retirer le champ IMEI de la table de dupl.
#Crer le champ dans le pcode
#G3R3 T3t5(IMEI)
SI (recordtype_660004603 == SGSN_660004603 || (recordtype_660004603 == GGSN_660004603 && Service3GDT_660004603))
ALORS
  SI (i_valid_field_n(g_iartin,$Tbgw_gsn::iMEI))
  ALORS
    erreur_660004603 = i_ajout_tlv(g_iartout,"T3t5","")
    erreur_660004603 = i_dup_chp_1val(g_iartin, g_iartout, $Tbgw_gsn::iMEI, $Tdpvgsm::IMEI)
  FINSI
FINSI
#/G3R3

###########################
## creation du T3t20

#------mise a jour de champ PDPaddr
present_660004603 = i_valid_field_n(g_iartin,$Tbgw_gsn::T3t11)
SI (present_660004603)
ALORS
  erreur_660004603 = i_ajout_tlv(g_iartout,"T4t20.1","")
  trace("## ajout T4t20.1")
  iPBinV4Ad_present_660004603 = i_valid_field_n(g_iartin,$Tbgw_gsn::servediPBinV4Ad)
  SI (iPBinV4Ad_present_660004603)
  ALORS
    erreur_660004603 = i_dup_chp_tab(g_iartin,g_iartout,$Tbgw_gsn::servediPBinV4Ad,$Tdpvgsm::PDPaddr,0)
    erreur_660004603 = i_resize_tlv(g_iartout,"T4t20.1","PDPaddr",i_get_art_field(g_iartin,$Tbgw_gsn::servediPBinV4Ad-1))
  SINON
    iPBinV6Ad_present_660004603 = i_valid_field_n(g_iartin,$Tbgw_gsn::servediPBinV6Ad)
    SI (iPBinV6Ad_present_660004603)
    ALORS
      erreur_660004603 = i_dup_chp_tab(g_iartin,g_iartout,$Tbgw_gsn::servediPBinV6Ad,$Tdpvgsm::PDPaddr,0)
    FINSI
  FINSI

  iPTextV4Ad_present_660004603 = i_valid_field_n(g_iartin,$Tbgw_gsn::servediPTexV4Ad)
  SI (iPTextV4Ad_present_660004603)
  ALORS
    erreur_660004603 = i_dup_chp_tab(g_iartin,g_iartout,$Tbgw_gsn::servediPTexV4Ad,$Tdpvgsm::PDPaddr,0)
    erreur_660004603 = i_resize_tlv(g_iartout,"T4t20.1","PDPaddr",i_get_art_field(g_iartin,$Tbgw_gsn::servediPTexV4Ad-1))
  SINON
    iPTextV6Ad_present_660004603 = i_valid_field_n(g_iartin,$Tbgw_gsn::servediPTexV6Ad)
    SI (iPTextV6Ad_present_660004603)
    ALORS
      erreur_660004603 = i_dup_chp_tab(g_iartin,g_iartout,$Tbgw_gsn::servediPTexV6Ad,$Tdpvgsm::PDPaddr,0)
    FINSI
  FINSI
FINSI

#------mise a jour de champ T4t20.2
present_660004603 = i_valid_field_n(g_iartin,$Tbgw_gsn::accessPtNameNI)
SI (present_660004603)
ALORS
  erreur_660004603 = i_ajout_tlv(g_iartout,"T4t20.2","")
  trace("## ajout T4t20.2")
  erreur_660004603 = i_resize_tlv(g_iartout, "T4t20.2", "accPointName3", i_get_art_field(g_iartin,$Tbgw_gsn::accessPtNameNI-1))
  erreur_660004603 = i_dup_chp_tab(g_iartin,g_iartout,$Tbgw_gsn::accessPtNameNI,$Tdpvgsm::accPointName3,0)
FINSI

#------mise a jour de champ T4t20.3
erreur_660004603 = i_ajout_tlv(g_iartout,"T4t20.3","")
trace("## ajout T4t20.3")
present_660004603 = i_valid_field_n(g_iartin,$Tbgw_gsn::accessPtNameOI)
SI (present_660004603)
ALORS
  erreur_660004603 = i_resize_tlv(g_iartout, "T4t20.3", "accPointName4", i_get_art_field(g_iartin,$Tbgw_gsn::accessPtNameOI-1))
  erreur_660004603 = i_dup_chp_tab(g_iartin,g_iartout,$Tbgw_gsn::accessPtNameOI,$Tdpvgsm::accPointName4,0)
SINON
# cas GGSN, accesspointnameOI = "void"
  erreur_660004603 = i_resize_tlv(g_iartout, "T4t20.3", "accPointName4", 4)
  erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::accPointName4,0,0x76)
  erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::accPointName4,1,0x6F)
  erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::accPointName4,2,0x69)
  erreur_660004603 = i_set_art_fieldtab(g_iartout,$Tdpvgsm::accPointName4,3,0x64)
FINSI

#------mise a jour de champ T4t20.4
erreur_660004603 = i_ajout_tlv(g_iartout,"T4t20.4","")
trace("## ajout T4t20.4")
present_660004603 = i_valid_field_n(g_iartin,$Tbgw_gsn::chargingID)
SI (present_660004603)
ALORS
  erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::chargingID, i_get_art_field(g_iartin,$Tbgw_gsn::chargingID))
SINON
  erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::chargingID, 0xFFFFFFFF)
FINSI

#------mise a jour de champ T4t20.5
erreur_660004603 = i_ajout_tlv(g_iartout,"T4t20.5","")
trace("## ajout T4t20.5")
erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::SeqNum, seqNum_660004603)

#------mise a jour de champ T4t20.6
erreur_660004603 = i_ajout_tlv(g_iartout,"T4t20.6","")
trace("## ajout T4t20.6")
# G1R7
# QC87
# QC94
SI (recordtype_660004603 == GGSN_660004603)
ALORS
  SI (cause_660004603 == 0 || cause_660004603 == 4)
  ALORS
    erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::PartialType, 0x03)
  SINON
    SI ( i_get_art_field(g_iartout,$Tdpvgsm::SeqNum) == 0x01 )
    ALORS
      erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::PartialType, 0x01)
    SINON
      erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::PartialType, 0x02)
    FINSI
  FINSI
SINON
  SI (recordtype_660004603 == SGSN_660004603)
  ALORS
    #G3R5 lot2 trait cras partiels
    #QC997 
    SI (cause_660004603 == 0 || cause_660004603 == 4 || cause_660004603 == 5 || cause_660004603 == 19 || cause_660004603 == 20)
    ALORS
      erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::PartialType, 0x03)
    SINON
      #G3R5 lot2 trait cras partiels
      SI (( i_get_art_field(g_iartin,$Tbgw_gsn::seqNum) == 0x01 || !i_valid_field_n(g_iartin,$Tbgw_gsn::seqNum)) && !i_valid_field_n(g_iartin,$Tbgw_gsn::sgsnchange))
      ALORS
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::PartialType, 0x01)
      SINON
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::PartialType, 0x02)
      FINSI
    FINSI
  FINSI
FINSI

#------mise a jour de champ RecEntId1
present_660004603 = i_valid_field_n(g_iartin,$Tbgw_gsn::T3t32)
SI (present_660004603)
ALORS
  erreur_660004603 = i_ajout_tlv(g_iartout,"T4t20.7","")
  trace("## ajout T4t20.7")
  iPBinV4Ad_present_660004603 = i_valid_field_n(g_iartin,$Tbgw_gsn::ggsniPBinV4Ad)
  SI (iPBinV4Ad_present_660004603)
  ALORS
    erreur_660004603 = i_dup_chp_tab(g_iartin,g_iartout,$Tbgw_gsn::ggsniPBinV4Ad,$Tdpvgsm::RecEntId1,0)
    erreur_660004603 = i_resize_tlv(g_iartout,"T4t20.7","RecEntId1",i_get_art_field(g_iartin,$Tbgw_gsn::ggsniPBinV4Ad-1))
  SINON
    iPBinV6Ad_present_660004603 = i_valid_field_n(g_iartin,$Tbgw_gsn::ggsniPBinV6Ad)
    SI (iPBinV6Ad_present_660004603)
    ALORS
      erreur_660004603 = i_dup_chp_tab(g_iartin,g_iartout,$Tbgw_gsn::ggsniPBinV6Ad,$Tdpvgsm::RecEntId1,0)
    FINSI
  FINSI

  iPTextV4Ad_present_660004603 = i_valid_field_n(g_iartin,$Tbgw_gsn::ggsniPTextV4Ad)
  SI (iPTextV4Ad_present_660004603)
  ALORS
    erreur_660004603 = i_dup_chp_tab(g_iartin,g_iartout,$Tbgw_gsn::ggsniPTextV4Ad,$Tdpvgsm::RecEntId1,0)
    erreur_660004603 = i_resize_tlv(g_iartout,"T4t20.7","RecEntId1",i_get_art_field(g_iartin,$Tbgw_gsn::ggsniPTextV4Ad-1))
  SINON
    iPTextV6Ad_present_660004603 = i_valid_field_n(g_iartin,$Tbgw_gsn::ggsniPTextV6Ad)
    SI (iPTextV6Ad_present_660004603)
    ALORS
      erreur_660004603 = i_dup_chp_tab(g_iartin,g_iartout,$Tbgw_gsn::ggsniPTextV6Ad,$Tdpvgsm::RecEntId1,0)
    FINSI
  FINSI
FINSI

#----mise a jour de champ RecEntId2
present_660004603 = i_valid_field_n(g_iartin,$Tbgw_gsn::T3t34)
SI (present_660004603)
ALORS
  erreur_660004603 = i_ajout_tlv(g_iartout,"T4t20.8","")
  trace("## ajout T4t20.8")
  iPBinV4Ad_present_660004603 = i_valid_field_n(g_iartin,$Tbgw_gsn::sgsn1iPBinV4Ad)
  SI (iPBinV4Ad_present_660004603)
  ALORS
    erreur_660004603 = i_dup_chp_tab(g_iartin,g_iartout,$Tbgw_gsn::sgsn1iPBinV4Ad,$Tdpvgsm::RecEntId2,0)
    erreur_660004603 = i_resize_tlv(g_iartout,"T4t20.8","RecEntId2",i_get_art_field(g_iartin,$Tbgw_gsn::sgsn1iPBinV4Ad-1))
  SINON
    iPBinV6Ad_present_660004603 = i_valid_field_n(g_iartin,$Tbgw_gsn::sgsn1iPBinV6Ad)
    SI (iPBinV6Ad_present_660004603)
    ALORS
      erreur_660004603 = i_dup_chp_tab(g_iartin,g_iartout,$Tbgw_gsn::sgsn1iPBinV6Ad,$Tdpvgsm::RecEntId2,0)
    FINSI
  FINSI

  iPTextV4Ad_present_660004603 = i_valid_field_n(g_iartin,$Tbgw_gsn::sgsn1iPTextV4Ad)
  SI (iPTextV4Ad_present_660004603)
  ALORS
    erreur_660004603 = i_dup_chp_tab(g_iartin,g_iartout,$Tbgw_gsn::sgsn1iPTextV4Ad,$Tdpvgsm::RecEntId2,0)
    erreur_660004603 = i_resize_tlv(g_iartout,"T4t20.8","RecEntId2",i_get_art_field(g_iartin,$Tbgw_gsn::sgsn1iPTextV4Ad-1))
  SINON
    iPTextV6Ad_present_660004603 = i_valid_field_n(g_iartin,$Tbgw_gsn::sgsn1iPTextV6Ad)
    SI (iPTextV6Ad_present_660004603)
    ALORS
      erreur_660004603 = i_dup_chp_tab(g_iartin,g_iartout,$Tbgw_gsn::sgsn1iPTextV6Ad,$Tdpvgsm::RecEntId2,0)
    FINSI
  FINSI
FINSI

#------mise a jour de champ RecEntId3
present_660004603 = i_valid_field_n(g_iartin,$Tbgw_gsn::T3t36)
SI (present_660004603)
ALORS
  erreur_660004603 = i_ajout_tlv(g_iartout,"T4t20.9","")
  trace("## ajout T4t20.9")
  iPBinV4Ad_present_660004603 = i_valid_field_n(g_iartin,$Tbgw_gsn::sgsn2iPBinV4Ad)
  SI (iPBinV4Ad_present_660004603)
  ALORS
    erreur_660004603 = i_dup_chp_tab(g_iartin,g_iartout,$Tbgw_gsn::sgsn2iPBinV4Ad,$Tdpvgsm::RecEntId3,0)
    erreur_660004603 = i_resize_tlv(g_iartout,"T4t20.9","RecEntId3",i_get_art_field(g_iartin,$Tbgw_gsn::sgsn2iPBinV4Ad-1))
  SINON
    iPBinV6Ad_present_660004603 = i_valid_field_n(g_iartin,$Tbgw_gsn::sgsn2iPBinV6Ad)
    SI (iPBinV6Ad_present_660004603)
    ALORS
      erreur_660004603 = i_dup_chp_tab(g_iartin,g_iartout,$Tbgw_gsn::sgsn2iPBinV6Ad,$Tdpvgsm::RecEntId3,0)
    FINSI
  FINSI

  iPTextV4Ad_present_660004603 = i_valid_field_n(g_iartin,$Tbgw_gsn::sgsn2iPTextV4Ad)
  SI (iPTextV4Ad_present_660004603)
  ALORS
    erreur_660004603 = i_dup_chp_tab(g_iartin,g_iartout,$Tbgw_gsn::sgsn2iPTextV4Ad,$Tdpvgsm::RecEntId3,0)
    erreur_660004603 = i_resize_tlv(g_iartout,"T4t20.9","RecEntId3",i_get_art_field(g_iartin,$Tbgw_gsn::sgsn2iPTextV4Ad-1))
  SINON
    iPTextV6Ad_present_660004603 = i_valid_field_n(g_iartin,$Tbgw_gsn::sgsn2iPTextV6Ad)
    SI (iPTextV6Ad_present_660004603)
    ALORS
      erreur_660004603 = i_dup_chp_tab(g_iartin,g_iartout,$Tbgw_gsn::sgsn2iPTextV6Ad,$Tdpvgsm::RecEntId3,0)
    FINSI
  FINSI
FINSI


# Mise a jour du champ V4t20.10.1 et V4t20.10.2 par la somme des Volumes
# la somme des volumes est tronquee au 4 premiers octets de poids faibles
#-------------------------------------------------------------------------

erreur_660004603 = i_ajout_tlv(g_iartout,"T4t20.10","")
trace("## ajout T4t20.10")

# on affecte les indices des qos negociated et les changeTime associes
# indices des QoS negociated et des changeTime
indQosNego1_660004603 = -1
indQosNego2_660004603 = -1
indQosNego3_660004603 = -1
indQosNegoTS1_660004603 = 0
indQosNegoTS2_660004603 = 0
indQosNegoTS3_660004603 = 0
# ces variables indiquent les cases du tableau des datavolumes qui sont significatives (associees avec un qos negociated)
indDataVol1_660004603 = -1
indDataVol2_660004603 = -1
indDataVol3_660004603 = -1
indDataVol4_660004603 = -1

SI (i_valid_field_n(g_iartin,$Tbgw_gsn::qoSI0Used))
ALORS
  indQosNego1_660004603 = $Tbgw_gsn::qoSI0Used
  indQosNegoTS1_660004603 = $Tbgw_gsn::qoSI1ChgTime
  indDataVol1_660004603 = 0
SINON
  SI (i_valid_field_n(g_iartin,$Tbgw_gsn::qoSI1Used))
  ALORS
    indQosNego1_660004603 = $Tbgw_gsn::qoSI1Used
    indQosNegoTS1_660004603 = $Tbgw_gsn::qoSI2ChgTime
    indDataVol1_660004603 = 1
  SINON
    SI (i_valid_field_n(g_iartin,$Tbgw_gsn::qoSI2Used))
    ALORS
      indQosNego1_660004603 = $Tbgw_gsn::qoSI2Used
      indQosNegoTS1_660004603 = $Tbgw_gsn::qoSI3ChgTime
      indDataVol1_660004603 = 2
    SINON
      SI (i_valid_field_n(g_iartin,$Tbgw_gsn::qoSI3Used))
      ALORS
        indQosNego1_660004603 = $Tbgw_gsn::qoSI3Used
        indQosNegoTS1_660004603 = $Tbgw_gsn::qoSI4ChgTime
        indDataVol1_660004603 = 3
      FINSI
    FINSI
  FINSI
FINSI

SI (i_valid_field_n(g_iartin,$Tbgw_gsn::qoSI1Used) && indQosNego1_660004603 != $Tbgw_gsn::qoSI1Used)
ALORS
  indQosNego2_660004603 = $Tbgw_gsn::qoSI1Used
  indQosNegoTS2_660004603 = $Tbgw_gsn::qoSI2ChgTime
  indDataVol2_660004603 = 1
SINON
  SI( i_valid_field_n(g_iartin,$Tbgw_gsn::qoSI2Used) && (indQosNego1_660004603 != $Tbgw_gsn::qoSI2Used) )
  ALORS
    indQosNego2_660004603 = $Tbgw_gsn::qoSI2Used
    indQosNegoTS2_660004603 = $Tbgw_gsn::qoSI3ChgTime
    indDataVol2_660004603 = 2
  SINON
    SI (i_valid_field_n(g_iartin,$Tbgw_gsn::qoSI3Used) && indQosNego1_660004603 != $Tbgw_gsn::qoSI3Used)
    ALORS
      indQosNego2_660004603 = $Tbgw_gsn::qoSI3Used
      indQosNegoTS2_660004603 = $Tbgw_gsn::qoSI4ChgTime
      indDataVol2_660004603 = 3
    FINSI
  FINSI
FINSI

SI (i_valid_field_n(g_iartin,$Tbgw_gsn::qoSI2Used) && indQosNego2_660004603 != $Tbgw_gsn::qoSI2Used)
ALORS
  indQosNego3_660004603 = $Tbgw_gsn::qoSI2Used
  indQosNegoTS3_660004603 = $Tbgw_gsn::qoSI3ChgTime
  indDataVol3_660004603 = 2
SINON
  SI (i_valid_field_n(g_iartin,$Tbgw_gsn::qoSI3Used) && indQosNego2_660004603 != $Tbgw_gsn::qoSI3Used)
  ALORS
    indQosNego3_660004603 = $Tbgw_gsn::qoSI3Used
    indQosNegoTS3_660004603 = $Tbgw_gsn::qoSI4ChgTime
    indDataVol3_660004603 = 3
  FINSI
FINSI

NB_VolUp_660004603 = i_get_art_field(g_iartin, $Tbgw_gsn::qoSIVolGprsUp -1)/4

indiceUp_660004603 = 0
SomVolUp_660004603=0

POINT BOUCLE_UP

SI (indiceUp_660004603 < NB_VolUp_660004603)
ALORS
# SGSN : on additionne que les volumes des datavolumes qui sont associes ? un qos negociated
  SI (recordtype_660004603 == SGSN_660004603)
  ALORS
    SI (indiceUp_660004603 == indDataVol1_660004603 || indiceUp_660004603 == indDataVol2_660004603 || indiceUp_660004603 == indDataVol3_660004603 || indiceUp_660004603 == indDataVol4_660004603)
    ALORS
      qoSIVolGprsUp_val_660004603 = i_get_art_fieldtab(g_iartin, $Tbgw_gsn::qoSIVolGprsUp, indiceUp_660004603)
# Troncature du resultat au 4 octets de poids faibles
      SomVolUp_660004603 = (qoSIVolGprsUp_val_660004603+SomVolUp_660004603)&0xFFFFFFFF
      indiceUp_660004603 = indiceUp_660004603 + 1
      SAUT BOUCLE_UP
    SINON
      indiceUp_660004603 = indiceUp_660004603 + 1
      SAUT BOUCLE_UP
    FINSI
  SINON
    qoSIVolGprsUp_val_660004603 = i_get_art_fieldtab(g_iartin, $Tbgw_gsn::qoSIVolGprsUp, indiceUp_660004603)
# Troncature du resultat au 4 octets de poids faibles
    SomVolUp_660004603 = (qoSIVolGprsUp_val_660004603+SomVolUp_660004603)&0xFFFFFFFF
    indiceUp_660004603 = indiceUp_660004603 + 1
    SI(indiceUp_660004603 < 3)
    ALORS
      SAUT BOUCLE_UP
    FINSI
  FINSI
FINSI

#On ne fait la duplication de la somme que s il y a au moins un element
SI (indiceUp_660004603 > 0)
ALORS

# Initialisation des 2 premiers octets a 0x00
  erreur_660004603 = i_set_art_fieldtab(g_iartout, $Tdpvgsm::totVolOut, 0, 0)
  erreur_660004603 = i_set_art_fieldtab(g_iartout, $Tdpvgsm::totVolOut, 1, 0)
  erreur_660004603 = i_set_art_fieldtab(g_iartout, $Tdpvgsm::totVolOut, 2, (SomVolUp_660004603&0xFF000000)>>24)
  erreur_660004603 = i_set_art_fieldtab(g_iartout, $Tdpvgsm::totVolOut, 3, (SomVolUp_660004603&0xFF0000)>>16)
  erreur_660004603 = i_set_art_fieldtab(g_iartout, $Tdpvgsm::totVolOut, 4, (SomVolUp_660004603&0xFF00)>>8)
  erreur_660004603 = i_set_art_fieldtab(g_iartout, $Tdpvgsm::totVolOut, 5, SomVolUp_660004603&0xFF)
FINSI

#Mise a jour du champ  V4t20.10.2 par la somme des Vol Down
NB_VolDo_660004603 = i_get_art_field(g_iartin, $Tbgw_gsn::qoSIVolGprsDo -1)/4

indice_660004603 = 0
SomVolDo_660004603=0

POINT BOUCLE_Do
SI (indice_660004603 < NB_VolDo_660004603)
ALORS
# SGSN : on additionne que les volumes des datavolumes qui sont associes ? un qos negociated
  SI (recordtype_660004603 == SGSN_660004603)
  ALORS
    SI( (indice_660004603 == indDataVol1_660004603)
      || (indice_660004603 == indDataVol2_660004603)
      || (indice_660004603 == indDataVol3_660004603)
      || (indice_660004603 == indDataVol4_660004603) )
    ALORS
      qoSIVolGprsUp_val_660004603 = i_get_art_fieldtab(g_iartin,$Tbgw_gsn::qoSIVolGprsDo, indice_660004603)
# Troncature du resultat au 4 octets de poids faibles
      SomVolDo_660004603 = (qoSIVolGprsUp_val_660004603 + SomVolDo_660004603)&0xFFFFFFFF
      indice_660004603 = indice_660004603 + 1
      SAUT BOUCLE_Do
    SINON
      indice_660004603 = indice_660004603 + 1
      SAUT BOUCLE_Do
    FINSI
  SINON
    qoSIVolGprsUp_val_660004603 = i_get_art_fieldtab(g_iartin,$Tbgw_gsn::qoSIVolGprsDo, indice_660004603)
# Troncature du resultat au 4 octets de poids faibles
    SomVolDo_660004603 = (qoSIVolGprsUp_val_660004603 + SomVolDo_660004603)&0xFFFFFFFF
    indice_660004603 = indice_660004603 + 1
    SI( indice_660004603 < 3 )
    ALORS
      SAUT BOUCLE_Do
    FINSI
  FINSI
FINSI

#On ne fait la duplication de la somme que s il ya au moins un element
SI (indice_660004603 > 0)
ALORS
# Initialisation des 2 premiers octets a 0x00
  erreur_660004603 = i_set_art_fieldtab(g_iartout, $Tdpvgsm::totVolIn, 0, 0)
  erreur_660004603 = i_set_art_fieldtab(g_iartout, $Tdpvgsm::totVolIn, 1, 0)

  erreur_660004603 = i_set_art_fieldtab(g_iartout, $Tdpvgsm::totVolIn, 2, (SomVolDo_660004603&0xFF000000)>>24)
  erreur_660004603 = i_set_art_fieldtab(g_iartout, $Tdpvgsm::totVolIn, 3, (SomVolDo_660004603&0xFF0000)>>16)
  erreur_660004603 = i_set_art_fieldtab(g_iartout, $Tdpvgsm::totVolIn, 4, (SomVolDo_660004603&0xFF00)>>8)
  erreur_660004603 = i_set_art_fieldtab(g_iartout, $Tdpvgsm::totVolIn, 5, SomVolDo_660004603&0xFF)
FINSI


######################
# T3t21 
######################

# G3R10
SI (GPRS_660004603 && !WLAN_660004603)
ALORS
  SI (i_valid_field_n(g_iartin, $Tbgw_gsn::qoSRequested) || i_valid_field_n(g_iartin, $Tbgw_gsn::qoSI1Used) || i_valid_field_n(g_iartin, $Tbgw_gsn::qoSI2Used) || i_valid_field_n(g_iartin, $Tbgw_gsn::qoSI3Used))
  ALORS
    # T3t21 present
    
    # Calcul de T4t21.1 commun SGSN et GGSN
    SI (GPRS_660004603 && i_valid_field_n(g_iartin, $Tbgw_gsn::qoSRequested))
    ALORS
      # T4t21.1 present
      # V4t21.1.1   Delay(T4t17.1/qoSIRequested)
      # V4t21.1.2   Mean(T4t17.1/qoSRequested)
      # V4t21.1.3   Peak(T4t17.1/qoSRequested)
      # V4t21.1.4   Prec(T4t17.1/qoSrequested)
      # V4t21.1.5   Reliab(T4t17.1/qoSRequested)
      erreur_660004603 = i_ajout_tlv(g_iartout,"T4t21.1","")
      erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoSReqDelay, Delay_660004265($Tbgw_gsn::qoSRequested))
      erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoSReqMean, Mean_660004265($Tbgw_gsn::qoSRequested))
      erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoSReqPeak, Peak_660004265($Tbgw_gsn::qoSRequested))
      erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoSReqPrec, Prec_660004265($Tbgw_gsn::qoSRequested))
      erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoSReqReliab, Reliab_660004265($Tbgw_gsn::qoSRequested))
    FINSI
    SI (recordtype_660004603 == SGSN_660004603)
    ALORS
    
      # cas SGSN
      
      # Calcul de T4t21.2
      SI(indQosNego1_660004603 == -1)
      ALORS
        present_660004603 = 0
      SINON
        present_660004603 = i_valid_field_n(g_iartin, indQosNego1_660004603)
      FINSI
      SI (present_660004603)
      ALORS
        # T4t21.2 present (qoS1Delay, qoS1Mean, qoS1Peak, qoS1Prec, qoS1Reliab, qoS1VolOut, qoS1VolIn, qoS1TimeStamp)
        erreur_660004603 = i_ajout_tlv(g_iartout,"T4t21.2","")
        
        #V4t21.2.1 --> V4t21.2.5  (qoS1Delay, qoS1Mean, qoS1Peak, qoS1Prec, qoS1Reliab)
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS1Delay, Delay_660004265(indQosNego1_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS1Mean, Mean_660004265(indQosNego1_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS1Peak, Peak_660004265(indQosNego1_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS1Prec, Prec_660004265(indQosNego1_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS1Reliab, Reliab_660004265(indQosNego1_660004603))
        
        res_660004603 = i_get_art_fieldtab(g_iartin,$Tbgw_gsn::qoSIVolGprsUp, indDataVol1_660004603)
        SI (res_660004603 != -1)
        ALORS
          #V4t21.2.6 qoS1VolOut
          erreur_660004603 = i_resize_tlv(g_iartout,"T4t21.2","qoS1VolOut",6)
          erreur_660004603 = Valeur_totVol_660004265($Tdpvgsm::qoS1VolOut, res_660004603)
        FINSI
        
        res_660004603 = i_get_art_fieldtab(g_iartin,$Tbgw_gsn::qoSIVolGprsDo, indDataVol1_660004603)
        SI (res_660004603 != -1)
        ALORS
          #V4t21.2.7 qoS1VolIn
          erreur_660004603 = i_resize_tlv(g_iartout,"T4t21.2","qoS1VolIn",6)
          erreur_660004603 = Valeur_totVol_660004265($Tdpvgsm::qoS1VolIn, res_660004603)
        FINSI
        #V4t21.2.8 qoS1TimeStamp
        erreur_660004603 = i_resize_tlv(g_iartout,"T4t21.2","qoS1TimeStamp",7)
        erreur_660004603 = i_set_art_field(g_iartout,$Tdpvgsm::qoS1TimeStamp,i_get_art_field(g_iartin, indQosNegoTS1_660004603))
      FINSI
      
      # Calcul de T4t21.3
      SI (indQosNego2_660004603 == -1)
      ALORS
        present_660004603 = 0
      SINON
        present_660004603 = i_valid_field_n(g_iartin, indQosNego2_660004603)
      FINSI
      SI (present_660004603)
      ALORS
        # T4t21.3 present (qoS2Delay, qoS2Mean, qoS2Peak, qoS2Prec, qoS2Reliab, qoS2VolOut, qoS2VolIn, qoS2TimeStamp)
        erreur_660004603 = i_ajout_tlv(g_iartout,"T4t21.3","")
        
        #V4t21.3.1 --> V4t21.3.5 (qoS2Delay, qoS2Mean, qoS2Peak, qoS2Prec, qoS2Reliab)
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS2Delay, Delay_660004265(indQosNego2_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS2Mean, Mean_660004265(indQosNego2_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS2Peak, Peak_660004265(indQosNego2_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS2Prec, Prec_660004265(indQosNego2_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS2Reliab, Reliab_660004265(indQosNego2_660004603))
        
        res_660004603 = i_get_art_fieldtab(g_iartin,$Tbgw_gsn::qoSIVolGprsUp, indDataVol2_660004603)
        SI (res_660004603 != -1)
        ALORS
          #V4t21.3.6 qoS2VolOut
          erreur_660004603 = i_resize_tlv(g_iartout,"T4t21.3","qoS2VolOut",6)
          erreur_660004603 = Valeur_totVol_660004265($Tdpvgsm::qoS2VolOut, res_660004603)
        FINSI
        res_660004603 = i_get_art_fieldtab(g_iartin,$Tbgw_gsn::qoSIVolGprsDo, indDataVol2_660004603)
        SI (res_660004603 != -1)
        ALORS
          #V4t21.3.7 qoS2VolIn
          erreur_660004603 = i_resize_tlv(g_iartout,"T4t21.3","qoS2VolIn",6)
          erreur_660004603 = Valeur_totVol_660004265($Tdpvgsm::qoS2VolIn, res_660004603)
        FINSI
        #V4t21.3.8 qoS2TimeStamp
        erreur_660004603 = i_resize_tlv(g_iartout,"T4t21.3","qoS2TimeStamp",7)
        erreur_660004603 = i_set_art_field(g_iartout,$Tdpvgsm::qoS2TimeStamp,i_get_art_field(g_iartin, indQosNegoTS2_660004603))
      FINSI
      
      # Calcul de T4t21.4
      SI (indQosNego3_660004603 == -1)
      ALORS
        present_660004603 = 0
      SINON
        present_660004603 = i_valid_field_n(g_iartin, indQosNego3_660004603)
      FINSI
      SI (present_660004603)
      ALORS
        # T4t21.4 present (qoS3Delay, qoS3Mean, qoS3Peak, qoS3Prec, qoS3Reliab, qoS3VolOut, qoS3VolIn, qoS3TimeStamp)
        erreur_660004603 = i_ajout_tlv(g_iartout,"T4t21.4","")
        
        # V4t21.4.1 --> V4t21.4.5 (qoS3Delay, qoS3Mean, qoS3Peak, qoS3Prec, qoS3Reliab)
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS3Delay, Delay_660004265(indQosNego3_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS3Mean, Mean_660004265(indQosNego3_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS3Peak, Peak_660004265(indQosNego3_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS3Prec, Prec_660004265(indQosNego3_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS3Reliab, Reliab_660004265(indQosNego3_660004603))

        res_660004603 = i_get_art_fieldtab(g_iartin,$Tbgw_gsn::qoSIVolGprsUp, indDataVol3_660004603)
        SI (res_660004603 != -1)
        ALORS
          #V4t21.4.6 qoS3VolOut
          erreur_660004603 = i_resize_tlv(g_iartout,"T4t21.4","qoS3VolOut",6)
          erreur_660004603 = Valeur_totVol_660004265($Tdpvgsm::qoS3VolOut, res_660004603)
        FINSI
        
        res_660004603 = i_get_art_fieldtab(g_iartin,$Tbgw_gsn::qoSIVolGprsDo, indDataVol3_660004603)
        SI (res_660004603 != -1)
        ALORS
          #V4t21.4.7 qoS3VolIn
          erreur_660004603 = i_resize_tlv(g_iartout,"T4t21.4","qoS3VolIn",6)
          erreur_660004603 = Valeur_totVol_660004265($Tdpvgsm::qoS3VolIn, res_660004603)
        FINSI
        #V4t21.4.8 qoS3TimeStamp
        erreur_660004603 = i_resize_tlv(g_iartout,"T4t21.4","qoS3TimeStamp",7)
        erreur_660004603 = i_set_art_field(g_iartout,$Tdpvgsm::qoS3TimeStamp,i_get_art_field(g_iartin, indQosNegoTS3_660004603))
      FINSI
    SINON
    	
    	# cas GGSN

      # Calcul de T4t21.2
      SI (i_valid_field_n(g_iartin, $Tbgw_gsn::qoSI1Used))
      ALORS
        # T4t21.2 present (qoS1Delay, qoS1Mean, qoS1Peak, qoS1Prec, qoS1Reliab, qoS1VolOut, qoS1VolIn, qoS1TimeStamp)
        erreur_660004603 = i_ajout_tlv(g_iartout,"T4t21.2","")
        
        #V4t21.2.1 --> V4t21.2.5  (qoS1Delay, qoS1Mean, qoS1Peak, qoS1Prec, qoS1Reliab)
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS1Delay, Delay_660004265($Tbgw_gsn::qoSI1Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS1Mean, Mean_660004265($Tbgw_gsn::qoSI1Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS1Peak, Peak_660004265($Tbgw_gsn::qoSI1Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS1Prec, Prec_660004265($Tbgw_gsn::qoSI1Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS1Reliab, Reliab_660004265($Tbgw_gsn::qoSI1Used))
        # V4t21.2.6 qoS1VolOut
        res_660004603 = i_get_art_fieldtab(g_iartin,$Tbgw_gsn::qoSIVolGprsUp, 0)
        SI (res_660004603 != -1)
        ALORS
          erreur_660004603 = i_resize_tlv(g_iartout,"T4t21.2","qoS1VolOut",6)
          erreur_660004603 = Valeur_totVol_660004265($Tdpvgsm::qoS1VolOut, res_660004603)
        FINSI
        #V4t21.2.7 qoS1VolIn
        res_660004603 = i_get_art_fieldtab(g_iartin,$Tbgw_gsn::qoSIVolGprsDo, 0)
        SI (res_660004603 != -1)
        ALORS  
          erreur_660004603 = i_resize_tlv(g_iartout,"T4t21.2","qoS1VolIn",6)
          erreur_660004603 = Valeur_totVol_660004265($Tdpvgsm::qoS1VolIn, res_660004603)
        FINSI
        # V4t21.2.8 qoS1TimeStamp
        SI (i_valid_field_n(g_iartin, $Tbgw_gsn::qoSI1ChgTime))
        ALORS
          res_660004603 = i_get_art_field(g_iartin, $Tbgw_gsn::qoSI1ChgTime)
          erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS1TimeStamp, res_660004603)
        FINSI
      FINSI
      
      # Calcul de T4t21.3
      SI (i_valid_field_n(g_iartin, $Tbgw_gsn::qoSI2Used))
      ALORS
        # T4t21.3 present (qoS2Delay, qoS2Mean, qoS2Peak, qoS2Prec, qoS2Reliab, qoS2VolOut, qoS2VolIn, qoS2TimeStamp)
        erreur_660004603 = i_ajout_tlv(g_iartout,"T4t21.3","")

        #V4t21.3.1 --> V4t21.3.5  (qoS2Delay, qoS2Mean, qoS2Peak, qoS2Prec, qoS2Reliab)
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS2Delay, Delay_660004265($Tbgw_gsn::qoSI2Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS2Mean, Mean_660004265($Tbgw_gsn::qoSI2Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS2Peak, Peak_660004265($Tbgw_gsn::qoSI2Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS2Prec, Prec_660004265($Tbgw_gsn::qoSI2Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS2Reliab, Reliab_660004265($Tbgw_gsn::qoSI2Used))
        # V4t21.3.6 qoS2VolOut
        res_660004603 = i_get_art_fieldtab(g_iartin, $Tbgw_gsn::qoSIVolGprsUp, 1)
        SI (res_660004603 != -1)
        ALORS
          erreur_660004603 = i_resize_tlv(g_iartout,"T4t21.3","qoS2VolOut",6)
          erreur_660004603 = Valeur_totVol_660004265($Tdpvgsm::qoS2VolOut, res_660004603)
        SINON
          trace("[Dist] Tbgw_gsn :Probleme de recuperation du deuxieme element du qoSIVolGprsUp du Tbgw_gsn")
        FINSI
        # V4t21.3.7 qoS2VolIn
        res_660004603 = i_get_art_fieldtab(g_iartin, $Tbgw_gsn::qoSIVolGprsDo, 1)
        SI (res_660004603 != -1)
        ALORS
          erreur_660004603 = i_resize_tlv(g_iartout,"T4t21.3","qoS2VolIn",6)
          erreur_660004603 = Valeur_totVol_660004265($Tdpvgsm::qoS2VolIn, res_660004603)
        SINON
          trace("[Dist] Tbgw_gsn :Probleme de recuperation du deuxieme element du qoSIVolGprsDo du Tbgw_gsn")
        FINSI
        # V4t21.3.8 qoS2TimeStamp
        SI (i_valid_field_n(g_iartin, $Tbgw_gsn::qoSI2ChgTime))
        ALORS
          res_660004603 = i_get_art_field(g_iartin, $Tbgw_gsn::qoSI2ChgTime)
          erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS2TimeStamp, res_660004603)
        FINSI
      FINSI

      # Calcul de T4t21.4
      SI (i_valid_field_n(g_iartin, $Tbgw_gsn::qoSI3Used))
      ALORS
        # T4t21.4 present (qoS3Delay, qoS3Mean, qoS3Peak, qoS3Prec, qoS3Reliab, qoS3VolOut, qoS3VolIn, qoS3TimeStamp)
        erreur_660004603 = i_ajout_tlv(g_iartout,"T4t21.4","")

        #V4t21.4.1 --> V4t21.4.5  (qoS3Delay, qoS3Mean, qoS3Peak, qoS3Prec, qoS3Reliab)
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS3Delay, Delay_660004265($Tbgw_gsn::qoSI3Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS3Mean, Mean_660004265($Tbgw_gsn::qoSI3Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS3Peak, Peak_660004265($Tbgw_gsn::qoSI3Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS3Prec, Prec_660004265($Tbgw_gsn::qoSI3Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS3Reliab, Reliab_660004265($Tbgw_gsn::qoSI3Used))
        # V4t21.4.6 qoS3VolOut
        res_660004603 = i_get_art_fieldtab(g_iartin, $Tbgw_gsn::qoSIVolGprsUp, 2)
        SI (res_660004603 != -1)
        ALORS
          erreur_660004603 = i_resize_tlv(g_iartout,"T4t21.4","qoS3VolOut",6)
          erreur_660004603 = Valeur_totVol_660004265($Tdpvgsm::qoS3VolOut, res_660004603)
        FINSI
        # V4t21.4.7 qoS3VolIn
        res_660004603 = i_get_art_fieldtab(g_iartin, $Tbgw_gsn::qoSIVolGprsDo, 2)
        SI (res_660004603 != -1)
        ALORS
          erreur_660004603 = i_resize_tlv(g_iartout,"T4t21.4","qoS3VolIn",6)
          erreur_660004603 = Valeur_totVol_660004265($Tdpvgsm::qoS3VolIn, res_660004603)
        FINSI
        # V4t21.4.8 qoS3TimeStamp
        SI (i_valid_field_n(g_iartin, $Tbgw_gsn::qoSI3ChgTime))
        ALORS
          res_660004603 = i_get_art_field(g_iartin, $Tbgw_gsn::qoSI3ChgTime)
          erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS3TimeStamp, res_660004603)
        FINSI
      FINSI
      
    FINSI

  FINSI
FINSI


######################
# T3t22 
######################

SI (UMTS_660004603 && !WLAN_660004603)
ALORS
  SI (i_valid_field_n(g_iartin, $Tbgw_gsn::qoSRequested) || i_valid_field_n(g_iartin, $Tbgw_gsn::qoSI1Used) || i_valid_field_n(g_iartin, $Tbgw_gsn::qoSI2Used) || i_valid_field_n(g_iartin, $Tbgw_gsn::qoSI3Used))
  ALORS
    # T3t22 present
    
    # Calcul de T4t22.1 commun GGSN et SGSN
    SI (i_valid_field_n(g_iartin,$Tbgw_gsn::qoSRequested))
    ALORS
      #T4t22.1 present
      erreur_660004603 = i_ajout_tlv(g_iartout,"T4t22.1","")
      #V4t22.1.1     , V4t22.1.2    ,V4t22.1.3  , V4t22.1.4 ,V4t22.1.5 ,V4t22.1.6    ,V4t22.1.7     , V4t22.1.8, V4t22.1.9    ,V4t22.1.10   ,V4t22.1.11    ,V4t22.1.12  ,V4t22.1.13
      #qoSAllocRetPri,qoSTrafficClas,qoSDelivOrd,qoSDelivErr,qoSMaxSize,qoSMaxSRateUp,qoSMaxSRateDow, qoSResBER,qoSSDUErrRatio,qoSTransDelay,qoSTrafficHand,qoSBitRateUp,qoSBitRateDown
      erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoSAllocRetPri, RetentionPriority_660004265($Tbgw_gsn::qoSRequested))
      erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoSTrafficClas, TrafficClass_660004265($Tbgw_gsn::qoSRequested))
      erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoSDelivOrd, order_660004265($Tbgw_gsn::qoSRequested))
      erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoSDelivErr, DeliveryError_660004265($Tbgw_gsn::qoSRequested))
      erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoSMaxSize, MaxSduSize_660004265($Tbgw_gsn::qoSRequested))
      erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoSMaxSRateUp, MaxBitRateForUI_660004265($Tbgw_gsn::qoSRequested))
      erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoSMaxSRateDow, MaxBitRateForDI_660004265($Tbgw_gsn::qoSRequested))
      erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoSResBER, ResidualBer_660004265($Tbgw_gsn::qoSRequested))
      erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoSSDUErrRatio, SDUErrorRatio_660004265($Tbgw_gsn::qoSRequested))
      erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoSTransDelay, TransferDelay_660004265($Tbgw_gsn::qoSRequested))
      erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoSTrafficHand, TrafficHandlingPriority_660004265($Tbgw_gsn::qoSRequested))
      erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoSBitRateUp, GuaranBitRateUI_660004265($Tbgw_gsn::qoSRequested))
      erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoSBitRateDown, GuaranBitRateDI_660004265($Tbgw_gsn::qoSRequested))
    FINSI
    
    SI (recordtype_660004603 == SGSN_660004603)
    ALORS
      # cas SGSN
      
      # Calcul de T4t22.2
      SI(indQosNego1_660004603 == -1)
      ALORS
        present_660004603 = 0
      SINON
        present_660004603 = i_valid_field_n(g_iartin, indQosNego1_660004603)
      FINSI
      SI (present_660004603)
      ALORS
        #T4t22.2 present 
        #  V4t22.2.1    ,     V4t22.2.2 ,   V4t22.2.3 ,   V4t22.2.4 ,   V4t22.2.5,   V4t22.2.6   ,   V4t22.2.7   ,  V4t22.2.8,   V4t22.2.9   ,    V4t22.2.10 ,   V4t22.2.11  ,  V4t22.2.12   ,  V4t22.2.13   , V4t22.2.14, V4t22.2.15, V4t22.2.16
        #(qoS1AllocRetPr, qoS1TrafficCla, qoS1DelivOrd, qoS1DelivErr, qoS1MaxSize, qoS1MaxSRateUp, qoS1MaxSRateDo, qoS1ResBER, qoS1SDUErrRati, qoS1TransDelay, qoS1TrafficHan, qoS1GuarRateUp, qoS1GuarRateDo, qoS1VOLOut, qoS1VOLIn,  qoS1UMTSTime)
        erreur_660004603 = i_ajout_tlv(g_iartout,"T4t22.2","")
        #  V4t22.2.1    ,     V4t22.2.2 ,   V4t22.2.3 ,   V4t22.2.4 ,   V4t22.2.5,   V4t22.2.6   ,   V4t22.2.7   ,  V4t22.2.8,   V4t22.2.9   ,    V4t22.2.10 ,   V4t22.2.11  ,  V4t22.2.12   ,  V4t22.2.13   
        #(qoS1AllocRetPr, qoS1TrafficCla, qoS1DelivOrd, qoS1DelivErr, qoS1MaxSize, qoS1MaxSRateUp, qoS1MaxSRateDo, qoS1ResBER, qoS1SDUErrRati, qoS1TransDelay, qoS1TrafficHan, qoS1GuarRateUp, qoS1GuarRateDo)
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS1AllocRetPr, RetentionPriority_660004265(indQosNego1_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS1TrafficCla, TrafficClass_660004265(indQosNego1_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS1DelivOrd, order_660004265(indQosNego1_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS1DelivErr, DeliveryError_660004265(indQosNego1_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS1MaxSize, MaxSduSize_660004265(indQosNego1_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS1MaxSRateUp, MaxBitRateForUI_660004265(indQosNego1_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS1MaxSRateDo, MaxBitRateForDI_660004265(indQosNego1_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS1ResBER, ResidualBer_660004265(indQosNego1_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS1SDUErrRati, SDUErrorRatio_660004265(indQosNego1_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS1TransDelay, TransferDelay_660004265(indQosNego1_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS1TrafficHan, TrafficHandlingPriority_660004265(indQosNego1_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS1GuarRateUp, GuaranBitRateUI_660004265(indQosNego1_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS1GuarRateDo, GuaranBitRateDI_660004265(indQosNego1_660004603))
        # V4t22.2.14 qoS1VOLOut
        res_660004603 = i_get_art_fieldtab(g_iartin,$Tbgw_gsn::qoSIVolGprsUp, indDataVol1_660004603)
        SI (res_660004603 != -1)
        ALORS
          erreur_660004603 = i_resize_tlv(g_iartout,"T4t22.2","qoS1VOLOut",6)
          erreur_660004603 = Valeur_totVol_660004265($Tdpvgsm::qoS1VOLOut, res_660004603)
        FINSI
        # V4t22.2.15 qoS1VOLIn
        res_660004603 = i_get_art_fieldtab(g_iartin,$Tbgw_gsn::qoSIVolGprsDo, indDataVol1_660004603)
        SI (res_660004603 != -1)
        ALORS
          erreur_660004603 = i_resize_tlv(g_iartout,"T4t22.2","qoS1VOLIn",6)
          erreur_660004603 = Valeur_totVol_660004265($Tdpvgsm::qoS1VOLIn, res_660004603)
        FINSI
        # V4t22.2.16 qoS1UMTSTime
        erreur_660004603 = i_resize_tlv(g_iartout,"T4t22.2","qoS1UMTSTime",7)
        erreur_660004603 = i_set_art_field(g_iartout,$Tdpvgsm::qoS1UMTSTime,i_get_art_field(g_iartin, indQosNegoTS1_660004603))
      FINSI
      
      # Calcul de T4t22.3
      SI(indQosNego2_660004603 == -1)
      ALORS
        present_660004603 = 0
      SINON
        present_660004603 = i_valid_field_n(g_iartin, indQosNego2_660004603)
      FINSI
      SI (present_660004603)
      ALORS
        #T4t22.3 present
        #  V4t22.3.1    ,     V4t22.3.2 ,   V4t22.3.3 ,   V4t22.3.4 ,   V4t22.3.5,   V4t22.3.6   ,   V4t22.3.7   ,  V4t22.3.8,   V4t22.3.9   ,    V4t22.3.10 ,   V4t22.3.11  ,  V4t22.3.12   ,  V4t22.3.13   , V4t22.3.14, V4t22.3.15, V4t22.3.16
        #(qoS2AllocRetPr, qoS2TrafficCla, qoS2DelivOrd, qoS2DelivErr, qoS2MaxSize, qoS2MaxSRateUp, qoS2MaxSRateDo, qoS2ResBER, qoS2SDUErrRati, qoS2TransDelay, qoS2TrafficHan, qoS2GuarRateUp, qoS2GuarRateDo, qoS2VOLOut, qoS2VOLIn,  qoS2UMTSTimeS)
        erreur_660004603 = i_ajout_tlv(g_iartout,"T4t22.3","")
        #  V4t22.3.1    ,     V4t22.3.2 ,   V4t22.3.3 ,   V4t22.3.4 ,   V4t22.3.5,   V4t22.3.6   ,   V4t22.3.7   ,  V4t22.3.8,   V4t22.3.9   ,    V4t22.3.10 ,   V4t22.3.11  ,  V4t22.3.12   ,  V4t22.3.13   
        #(qoS2AllocRetPr, qoS2TrafficCla, qoS2DelivOrd, qoS2DelivErr, qoS2MaxSize, qoS2MaxSRateUp, qoS2MaxSRateDo, qoS2ResBER, qoS2SDUErrRati, qoS2TransDelay, qoS2TrafficHan, qoS2GuarRateUp, qoS2GuarRateDo)
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS2AllocRetPr, RetentionPriority_660004265(indQosNego2_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS2TrafficCla, TrafficClass_660004265(indQosNego2_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS2DelivOrd, order_660004265(indQosNego2_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS2DelivErr, DeliveryError_660004265(indQosNego2_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS2MaxSize, MaxSduSize_660004265(indQosNego2_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS2MaxSRateUp, MaxBitRateForUI_660004265(indQosNego2_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS2MaxSRateDo, MaxBitRateForDI_660004265(indQosNego2_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS2ResBER, ResidualBer_660004265(indQosNego2_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS2SDUErrRati, SDUErrorRatio_660004265(indQosNego2_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS2TransDelay, TransferDelay_660004265(indQosNego2_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS2TrafficHan, TrafficHandlingPriority_660004265(indQosNego2_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS2GuarRateUp, GuaranBitRateUI_660004265(indQosNego2_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS2GuarRateDo, GuaranBitRateDI_660004265(indQosNego2_660004603))
        # V4t22.3.14 qoS2VOLOut
        res_660004603 = i_get_art_fieldtab(g_iartin,$Tbgw_gsn::qoSIVolGprsUp, indDataVol2_660004603)
        SI (res_660004603 != -1)
        ALORS
          erreur_660004603 = i_resize_tlv(g_iartout,"T4t22.3","qoS2VOLOut",6)
          erreur_660004603 = Valeur_totVol_660004265($Tdpvgsm::qoS2VOLOut, res_660004603)
        FINSI
        # V4t22.3.15 qoS2VOLIn
        res_660004603 = i_get_art_fieldtab(g_iartin,$Tbgw_gsn::qoSIVolGprsDo, indDataVol2_660004603)
        SI (res_660004603 != -1)
        ALORS
          erreur_660004603 = i_resize_tlv(g_iartout,"T4t22.3","qoS2VOLIn",6)
          erreur_660004603 = Valeur_totVol_660004265($Tdpvgsm::qoS2VOLIn, res_660004603)
        FINSI
        # V4t22.3.16 qoS2UMTSTimeS
        erreur_660004603 = i_resize_tlv(g_iartout,"T4t22.3","qoS2UMTSTimeS",7)
        erreur_660004603 = i_set_art_field(g_iartout,$Tdpvgsm::qoS2UMTSTimeS,i_get_art_field(g_iartin, indQosNegoTS2_660004603))
      FINSI
      
      # Calcul de T4t22.4
      SI(indQosNego3_660004603 == -1)
      ALORS
        present_660004603 = 0
      SINON
        present_660004603 = i_valid_field_n(g_iartin, indQosNego3_660004603)
      FINSI
      SI (present_660004603)
      ALORS
        #T4t22.4 present
        #  V4t22.4.1    ,     V4t22.4.2 ,   V4t22.4.3 ,   V4t22.4.4 ,   V4t22.4.5,   V4t22.4.6   ,   V4t22.4.7   ,  V4t22.4.8,   V4t22.4.9   ,    V4t22.4.10 ,   V4t22.4.11  ,  V4t22.4.12   ,  V4t22.4.13   , V4t22.4.14, V4t22.4.15, V4t22.4.16
        #(qoS3AllocRetPr, qoS3TrafficCla, qoS3DelivOrd, qoS3DelivErr, qoS3MaxSize, qoS3MaxSRateUp, qoS3MaxSRateDo, qoS3ResBER, qoS3SDUErrRati, qoS3TransDelay, qoS3TrafficHan, qoS3GuarRateUp, qoS3GuarRateDo, qoS3VOLOut, qoS3VOLIn,  qoS3UMTSTime)
        erreur_660004603 = i_ajout_tlv(g_iartout,"T4t22.4","")
        #  V4t22.4.1    ,     V4t22.4.2 ,   V4t22.4.3 ,   V4t22.4.4 ,   V4t22.4.5,   V4t22.4.6   ,   V4t22.4.7   ,  V4t22.4.8,   V4t22.4.9   ,    V4t22.4.10 ,   V4t22.4.11  ,  V4t22.4.12   ,  V4t22.4.13 
        #(qoS3AllocRetPr, qoS3TrafficCla, qoS3DelivOrd, qoS3DelivErr, qoS3MaxSize, qoS3MaxSRateUp, qoS3MaxSRateDo, qoS3ResBER, qoS3SDUErrRati, qoS3TransDelay, qoS3TrafficHan, qoS3GuarRateUp, qoS3GuarRateDo
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS3AllocRetPr, RetentionPriority_660004265(indQosNego3_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS3TrafficCla, TrafficClass_660004265(indQosNego3_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS3DelivOrd, order_660004265(indQosNego3_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS3DelivErr, DeliveryError_660004265(indQosNego3_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS3MaxSize, MaxSduSize_660004265(indQosNego3_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS3MaxSRateUp, MaxBitRateForUI_660004265(indQosNego3_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS3MaxSRateDo, MaxBitRateForDI_660004265(indQosNego3_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS3ResBER, ResidualBer_660004265(indQosNego3_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS3SDUErrRati, SDUErrorRatio_660004265(indQosNego3_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS3TransDelay, TransferDelay_660004265(indQosNego3_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS3TrafficHan, TrafficHandlingPriority_660004265(indQosNego3_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS3GuarRateUp, GuaranBitRateUI_660004265(indQosNego3_660004603))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS3GuarRateDo, GuaranBitRateDI_660004265(indQosNego3_660004603))
        #V4t22.4.14 qoS3VOLOut
        res_660004603  =  i_get_art_fieldtab(g_iartin,$Tbgw_gsn::qoSIVolGprsUp, indDataVol3_660004603)
        SI (res_660004603 != -1)
        ALORS
          erreur_660004603 = i_resize_tlv(g_iartout,"T4t22.4","qoS3VOLOut",6)
          erreur_660004603 = Valeur_totVol_660004265($Tdpvgsm::qoS3VOLOut, res_660004603)
        FINSI
        # V4t22.4.15 qoS3VOLIn
        res_660004603 = i_get_art_fieldtab(g_iartin,$Tbgw_gsn::qoSIVolGprsDo, indDataVol3_660004603)
        SI (res_660004603 != -1)
        ALORS
          erreur_660004603 = i_resize_tlv(g_iartout,"T4t22.4","qoS3VOLIn",6)
          erreur_660004603 = Valeur_totVol_660004265($Tdpvgsm::qoS3VOLIn, res_660004603)
        FINSI
        #- V4t22.4.16 qoS3UMTSTime
        erreur_660004603 = i_resize_tlv(g_iartout,"T4t22.4","qoS3UMTSTime",7)
        erreur_660004603 = i_set_art_field(g_iartout,$Tdpvgsm::qoS3UMTSTime,i_get_art_field(g_iartin, indQosNegoTS3_660004603))
      FINSI
      
    SINON
    	
    	# cas GGSN

      # Calcul de T4t22.2
      SI (i_valid_field_n(g_iartin,$Tbgw_gsn::qoSI1Used))
      ALORS
        #T4t22.2 present 
        #  V4t22.2.1    ,     V4t22.2.2 ,   V4t22.2.3 ,   V4t22.2.4 ,   V4t22.2.5,   V4t22.2.6   ,   V4t22.2.7   ,  V4t22.2.8,   V4t22.2.9   ,    V4t22.2.10 ,   V4t22.2.11  ,  V4t22.2.12   ,  V4t22.2.13   , V4t22.2.14, V4t22.2.15, V4t22.2.16
        #(qoS1AllocRetPr, qoS1TrafficCla, qoS1DelivOrd, qoS1DelivErr, qoS1MaxSize, qoS1MaxSRateUp, qoS1MaxSRateDo, qoS1ResBER, qoS1SDUErrRati, qoS1TransDelay, qoS1TrafficHan, qoS1GuarRateUp, qoS1GuarRateDo, qoS1VOLOut, qoS1VOLIn,  qoS1UMTSTime)
        erreur_660004603 = i_ajout_tlv(g_iartout,"T4t22.2","")
        
        #  V4t22.2.1    ,     V4t22.2.2 ,   V4t22.2.3 ,   V4t22.2.4 ,   V4t22.2.5,   V4t22.2.6   ,   V4t22.2.7   ,  V4t22.2.8,   V4t22.2.9   ,    V4t22.2.10 ,   V4t22.2.11  ,  V4t22.2.12   ,  V4t22.2.13   
        #(qoS1AllocRetPr, qoS1TrafficCla, qoS1DelivOrd, qoS1DelivErr, qoS1MaxSize, qoS1MaxSRateUp, qoS1MaxSRateDo, qoS1ResBER, qoS1SDUErrRati, qoS1TransDelay, qoS1TrafficHan, qoS1GuarRateUp, qoS1GuarRateDo)
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS1AllocRetPr, RetentionPriority_660004265($Tbgw_gsn::qoSI1Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS1TrafficCla, TrafficClass_660004265($Tbgw_gsn::qoSI1Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS1DelivOrd, order_660004265($Tbgw_gsn::qoSI1Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS1DelivErr, DeliveryError_660004265($Tbgw_gsn::qoSI1Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS1MaxSize, MaxSduSize_660004265($Tbgw_gsn::qoSI1Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS1MaxSRateUp, MaxBitRateForUI_660004265($Tbgw_gsn::qoSI1Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS1MaxSRateDo, MaxBitRateForDI_660004265($Tbgw_gsn::qoSI1Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS1ResBER, ResidualBer_660004265($Tbgw_gsn::qoSI1Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS1SDUErrRati, SDUErrorRatio_660004265($Tbgw_gsn::qoSI1Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS1TransDelay, TransferDelay_660004265($Tbgw_gsn::qoSI1Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS1TrafficHan, TrafficHandlingPriority_660004265($Tbgw_gsn::qoSI1Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS1GuarRateUp, GuaranBitRateUI_660004265($Tbgw_gsn::qoSI1Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS1GuarRateDo, GuaranBitRateDI_660004265($Tbgw_gsn::qoSI1Used))
        # V4t22.2.14 qoS1VOLOut
        res_660004603 = i_get_art_fieldtab(g_iartin,$Tbgw_gsn::qoSIVolGprsUp, 0)
        SI (res_660004603 != -1)
        ALORS
          erreur_660004603 = i_resize_tlv(g_iartout,"T4t22.2","qoS1VOLOut",6)
          erreur_660004603 = Valeur_totVol_660004265($Tdpvgsm::qoS1VOLOut, res_660004603)
        FINSI
        # V4t22.2.15 qoS1VOLIn
        res_660004603 = i_get_art_fieldtab(g_iartin,$Tbgw_gsn::qoSIVolGprsDo, 0)
        SI (res_660004603 != -1)
        ALORS
          erreur_660004603 = i_resize_tlv(g_iartout,"T4t22.2","qoS1VOLIn",6)
          erreur_660004603 = Valeur_totVol_660004265($Tdpvgsm::qoS1VOLIn, res_660004603)
        FINSI
        # V4t22.2.16 qoS1UMTSTime
        erreur_660004603 = i_resize_tlv(g_iartout,"T4t22.2","qoS1UMTSTime",7)
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS1UMTSTime, i_get_art_field(g_iartin, $Tbgw_gsn::qoSI1ChgTime))
      FINSI

      # Calcul de T4t22.3
      SI (i_valid_field_n(g_iartin,$Tbgw_gsn::qoSI2Used))
      ALORS
        #T4t22.3 present 
        #  V4t22.3.1    ,     V4t22.3.2 ,   V4t22.3.3 ,   V4t22.3.4 ,   V4t22.3.5,   V4t22.3.6   ,   V4t22.3.7   ,  V4t22.3.8,   V4t22.3.9   ,    V4t22.3.10 ,   V4t22.3.11  ,  V4t22.3.12   ,  V4t22.3.13   , V4t22.3.14, V4t22.3.15, V4t22.3.16
        #(qoS2AllocRetPr, qoS2TrafficCla, qoS2DelivOrd, qoS2DelivErr, qoS2MaxSize, qoS2MaxSRateUp, qoS2MaxSRateDo, qoS2ResBER, qoS2SDUErrRati, qoS2TransDelay, qoS2TrafficHan, qoS2GuarRateUp, qoS2GuarRateDo, qoS2VOLOut, qoS2VOLIn,  qoS2UMTSTimeS)
        erreur_660004603 = i_ajout_tlv(g_iartout,"T4t22.3","")
        
        #  V4t22.3.1    ,     V4t22.3.2 ,   V4t22.3.3 ,   V4t22.3.4 ,   V4t22.3.5,   V4t22.3.6   ,   V4t22.3.7   ,  V4t22.3.8,   V4t22.3.9   ,    V4t22.3.10 ,   V4t22.3.11  ,  V4t22.3.12   ,  V4t22.3.13   
        #(qoS2AllocRetPr, qoS2TrafficCla, qoS2DelivOrd, qoS2DelivErr, qoS2MaxSize, qoS2MaxSRateUp, qoS2MaxSRateDo, qoS2ResBER, qoS2SDUErrRati, qoS2TransDelay, qoS2TrafficHan, qoS2GuarRateUp, qoS2GuarRateDo)
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS2AllocRetPr, RetentionPriority_660004265($Tbgw_gsn::qoSI2Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS2TrafficCla, TrafficClass_660004265($Tbgw_gsn::qoSI2Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS2DelivOrd, order_660004265($Tbgw_gsn::qoSI2Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS2DelivErr, DeliveryError_660004265($Tbgw_gsn::qoSI2Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS2MaxSize, MaxSduSize_660004265($Tbgw_gsn::qoSI2Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS2MaxSRateUp, MaxBitRateForUI_660004265($Tbgw_gsn::qoSI2Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS2MaxSRateDo, MaxBitRateForDI_660004265($Tbgw_gsn::qoSI2Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS2ResBER, ResidualBer_660004265($Tbgw_gsn::qoSI2Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS2SDUErrRati, SDUErrorRatio_660004265($Tbgw_gsn::qoSI2Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS2TransDelay, TransferDelay_660004265($Tbgw_gsn::qoSI2Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS2TrafficHan, TrafficHandlingPriority_660004265($Tbgw_gsn::qoSI2Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS2GuarRateUp, GuaranBitRateUI_660004265($Tbgw_gsn::qoSI2Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS2GuarRateDo, GuaranBitRateDI_660004265($Tbgw_gsn::qoSI2Used))
        # V4t22.3.14 qoS2VOLOut
        res_660004603 = i_get_art_fieldtab(g_iartin,$Tbgw_gsn::qoSIVolGprsUp, 1)
        SI (res_660004603 != -1)
        ALORS
          erreur_660004603 = i_resize_tlv(g_iartout,"T4t22.3","qoS2VOLOut",6)
          erreur_660004603 = Valeur_totVol_660004265($Tdpvgsm::qoS2VOLOut, res_660004603)
        FINSI
        # V4t22.3.15 qoS2VOLIn
        res_660004603 = i_get_art_fieldtab(g_iartin,$Tbgw_gsn::qoSIVolGprsDo, 1)
        SI (res_660004603 != -1)
        ALORS
          erreur_660004603 = i_resize_tlv(g_iartout,"T4t22.3","qoS2VOLIn",6)
          erreur_660004603 = Valeur_totVol_660004265($Tdpvgsm::qoS2VOLIn, res_660004603)
        FINSI
        # V4t22.3.16 qoS2UMTSTimeS
        erreur_660004603 = i_resize_tlv(g_iartout,"T4t22.3","qoS2UMTSTimeS",7)
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS2UMTSTimeS, i_get_art_field(g_iartin, $Tbgw_gsn::qoSI2ChgTime))
      FINSI
      
      # Calcul de T4t22.4
      SI (i_valid_field_n(g_iartin,$Tbgw_gsn::qoSI3Used))
      ALORS
        #T4t22.4 present 
        #  V4t22.4.1    ,     V4t22.4.2 ,   V4t22.4.3 ,   V4t22.4.4 ,   V4t22.4.5,   V4t22.4.6   ,   V4t22.4.7   ,  V4t22.4.8,   V4t22.4.9   ,    V4t22.4.10 ,   V4t22.4.11  ,  V4t22.4.12   ,  V4t22.4.13   , V4t22.4.14, V4t22.4.15, V4t22.4.16
        #(qoS3AllocRetPr, qoS3TrafficCla, qoS3DelivOrd, qoS3DelivErr, qoS3MaxSize, qoS3MaxSRateUp, qoS3MaxSRateDo, qoS3ResBER, qoS3SDUErrRati, qoS3TransDelay, qoS3TrafficHan, qoS3GuarRateUp, qoS3GuarRateDo, qoS3VOLOut, qoS3VOLIn,  qoS3UMTSTime)
        erreur_660004603 = i_ajout_tlv(g_iartout,"T4t22.4","")
        
        #  V4t22.4.1    ,     V4t22.4.2 ,   V4t22.4.3 ,   V4t22.4.4 ,   V4t22.4.5,   V4t22.4.6   ,   V4t22.4.7   ,  V4t22.4.8,   V4t22.4.9   ,    V4t22.4.10 ,   V4t22.4.11  ,  V4t22.4.12   ,  V4t22.4.13   
        #(qoS3AllocRetPr, qoS3TrafficCla, qoS3DelivOrd, qoS3DelivErr, qoS3MaxSize, qoS3MaxSRateUp, qoS3MaxSRateDo, qoS3ResBER, qoS3SDUErrRati, qoS3TransDelay, qoS3TrafficHan, qoS3GuarRateUp, qoS3GuarRateDo)
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS3AllocRetPr, RetentionPriority_660004265($Tbgw_gsn::qoSI3Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS3TrafficCla, TrafficClass_660004265($Tbgw_gsn::qoSI3Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS3DelivOrd, order_660004265($Tbgw_gsn::qoSI3Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS3DelivErr, DeliveryError_660004265($Tbgw_gsn::qoSI3Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS3MaxSize, MaxSduSize_660004265($Tbgw_gsn::qoSI3Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS3MaxSRateUp, MaxBitRateForUI_660004265($Tbgw_gsn::qoSI3Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS3MaxSRateDo, MaxBitRateForDI_660004265($Tbgw_gsn::qoSI3Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS3ResBER, ResidualBer_660004265($Tbgw_gsn::qoSI3Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS3SDUErrRati, SDUErrorRatio_660004265($Tbgw_gsn::qoSI3Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS3TransDelay, TransferDelay_660004265($Tbgw_gsn::qoSI3Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS3TrafficHan, TrafficHandlingPriority_660004265($Tbgw_gsn::qoSI3Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS3GuarRateUp, GuaranBitRateUI_660004265($Tbgw_gsn::qoSI3Used))
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS3GuarRateDo, GuaranBitRateDI_660004265($Tbgw_gsn::qoSI3Used))
        # V4t22.4.14 qoS3VOLOut
        res_660004603 = i_get_art_fieldtab(g_iartin,$Tbgw_gsn::qoSIVolGprsUp, 2)
        SI (res_660004603 != -1)
        ALORS
          erreur_660004603 = i_resize_tlv(g_iartout,"T4t22.4","qoS3VOLOut",6)
          erreur_660004603 = Valeur_totVol_660004265($Tdpvgsm::qoS3VOLOut, res_660004603)
        FINSI
        # V4t22.4.15 qoS3VOLIn
        res_660004603 = i_get_art_fieldtab(g_iartin,$Tbgw_gsn::qoSIVolGprsDo, 2)
        SI (res_660004603 != -1)
        ALORS
          erreur_660004603 = i_resize_tlv(g_iartout,"T4t22.4","qoS3VOLIn",6)
          erreur_660004603 = Valeur_totVol_660004265($Tdpvgsm::qoS3VOLIn, res_660004603)
        FINSI
        # V4t22.4.16 qoS3UMTSTime
        erreur_660004603 = i_resize_tlv(g_iartout,"T4t22.4","qoS3UMTSTime",7)
        erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::qoS3UMTSTime, i_get_art_field(g_iartin, $Tbgw_gsn::qoSI3ChgTime))
      FINSI
      
    FINSI
    
  FINSI
FINSI
#/G3R10

#G3R4Lot2
#T3t51
SI RoamingOUT_660004603
ALORS
  erreur_660004603 = i_ajout_tlv(g_iartout,"T3t51","")
  longueur_660004603 = i_conv_ascii_dcb (pt_MCCMNC_660004603, pt_MCCMNC_DCB_660004603)
  erreur_660004603 = i_memcpy_art_field_n(g_iartout,$Tdpvgsm::servPlatRoaInf,pt_MCCMNC_DCB_660004603, longueur_660004603)
  #trace1("<<__LINE__ << ------longueur = <%d> -------------",longueur)
FINSI

# QC918
#T3t59
SI (RoamingOUT_660004603 || (RoamingIN_660004603 && flag_KeyTADIC_660004603 == 1))
ALORS
  erreur_660004603 = i_ajout_tlv(g_iartout,"T3t59","")
  erreur_660004603 = i_set_art_str(g_iartout,$Tdpvgsm::LocalTADIG,"     ")
  SI RoamingOUT_660004603
  ALORS
    # on est forcement en RoamingOUT
    erreur_660004603=i_set_art_str(g_iartout,$Tdpvgsm::LocalTADIG,pt_TADIG_660004603)
  SINON
    # on est forcement en RoamingIN
    longueur_660004603 = i_conv_ascii_dcb (pt_MCCMNC_660004603, pt_MCCMNC_DCB_660004603)
    erreur_660004603 = i_memcpy_art_field_n(g_iartout,$Tdpvgsm::PrefixIMSIclt,pt_MCCMNC_DCB_660004603, longueur_660004603)
  FINSI
FINSI
#/G3R4Lot2

#####################################################################
# Mise a jour du champ "Ajout CE" du DPV TLV
#####################################################################
# QC1331
#erreur=set_timeInCE_EEC(0)
########### Date_Audit
erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::timeInCE,  i_DHgetLocalTime(4, 7, i_date_audit()))
########### eec
# QC1405
SI (g_ieec > 500)
ALORS
  erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::eec, g_ieec - 500)
SINON
  erreur_660004603 = i_set_art_field(g_iartout, $Tdpvgsm::eec, g_ieec)
FINSI
#/QC1405


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

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

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

# QC1005
erreur_660004603 = aiguillage2_660004590 (g_iartin, g_iartout, DISTRIBUTION_INCONNU_660004603, Multidistribution_Non_660004603)
SI (erreur_660004603 == TRAI_KO_660004603)
ALORS
  trace("<<<__LINE__<<<__FILE__<<< Erreur retour fonction aiguillage2")
  SAUT STOCKE_ERRONE
FINSI

trace("[Dist] Tbgw_gsn : Fin Distribution OK")
RETOUR TRAIT_OK

POINT STOCKE_ERRONE
trace("[Dist] Tbgw_gsn : fin Distribution stockage en ERRONE")
erreur_660004603 = i_make_art_rej(g_iartin, g_iartout11, code_rejet_660004603)
erreur_660004603 = i_stocke_art(g_iartout11,0,PT_ERRONE,0)
RETOUR TRAIT_OK
# --------------------------- Tbgw_gsn_dis.src ----------------------------------------------------
