REGISTRE ENTIER erreur_800005743
REGISTRE ENTIER codeserv_800005743
REGISTRE ENTIER code_rejet_800005743
REGISTRE ENTIER info_800005743

# ---------------------------------------------------------------------------
#
# FICHIER     : Trtmcp.src
#
#
# DESCRIPTION : Pcode traitement Mes Contacts RI2G(Trtmcp)
#
# HISTORIQUE  : 29/05/2008 RHE - Creation
# 10/07/08 -BEA- FO 43
# 24/07/08 - DRE - FO QC66
#
# ---------------------------------------------------------------------------

############################################################################
# Declarations + Initialisations
############################################################################


erreur_800005743 = 0
codeserv_800005743 = 0
code_rejet_800005743 = 0
info_800005743 = 0

###################################################################
# DEBUT DES TRAITEMENTS
###################################################################


#trace("Debut du traitement Trtmcp")
erreur_800005743 = i_dup_art(g_iartin, "Trtmcp", g_iartout)

#FO 43
# Debut FO QC66
# controle de la date
SI (i_valid_field_n(g_iartout, $Trtmcp::DATE2) )
ALORS
	info_800005743 = i_get_art_field( g_iartout, $Trtmcp::DATE2)
	SI(info_800005743 == -1)
	  ALORS
	  code_rejet_800005743 = 0x5062
	  erreur_800005743 = i_PlvMessEmettre(7202,2,g_iartout,"",2,code_rejet_800005743,codeserv_800005743,0)
	  SAUT STOCKE_ERRONE
	FINSI
FINSI
# FIN FO QC66
#	Valeurs de CODESERV

codeserv_800005743 = i_get_art_field(g_iartout, $Trtmcp::CODESERV)
#trace1("************ codeserv: <%x>", codeserv)

SI( (codeserv_800005743 != 0x2400) &&  (codeserv_800005743 != 0x2401) && (codeserv_800005743 != 0xA401))
  ALORS
  code_rejet_800005743 = 0x50A2
  erreur_800005743 = i_PlvMessEmettre(7200,2,g_iartout,"",2,code_rejet_800005743,codeserv_800005743,0)
  SAUT STOCKE_ERRONE
FINSI


#	Presence de champs si MER (pour calcul Metachamps Dduree et Tax)

info_800005743 = i_get_art_field( g_iartin, $Trtmcp::TAP12) & 0x70
#trace1("TAP12_BCD: %d",info)
SI (info_800005743 == 0x10)
  ALORS
  SI !(i_valid_field_n(g_iartin, $Trtmcp::T3traa))
    ALORS
    code_rejet_800005743 = 0x50A2
    erreur_800005743 = i_PlvMessEmettre(7201,2,g_iartout,"",2,code_rejet_800005743,codeserv_800005743,0)
    SAUT STOCKE_ERRONE
  FINSI
FINSI

SAUT STOCKE_OK

############################################################################
#	STOCKAGE DE L'ARTICLE
############################################################################

POINT	STOCKE_ERRONE
erreur_800005743 = i_make_art_rej(g_iartout, g_iartout, code_rejet_800005743)
erreur_800005743 = i_stocke_art(g_iartout,0, PT_ERRONE,0)
#trace("Stockage errone de l'article")
RETOUR TRAIT_OK

POINT 	STOCKE_OK
erreur_800005743 = i_stocke_art(g_iartout,0,PT_OK,0)
#trace("Fin traitement Trtmcp")

RETOUR TRAIT_OK
