Up ! Edi for Administration, Commerce and Transport

Ce programme présente l'échange de données au format Edi for Administraction, Commerce and Transport (EDIFACT).

Le fichier source est ${UPS_HOME}/upsedi/demo/${UPS_LANGUAGE}/formatedf.upl.

Mode compilé

Commande de compilation

upscmp Source=formatedf.upl

Commande d'exécution

formatedf

Mode interprété

upssng Source=formatedf.upl

Fichier source

Source Composant "Exemple d'emploi de l'import/export" Version 4.0.0;

ImporterModule
/************/
Constante
/*******/
Type Employe Defaut
/*****************/ Fin Type

Variable
/******/
Procedure CreerListeDEmployes()
/*****************************/
Variable
Debut
Pour I=0 JusquA 10 Faire Fin Pour
Fin Procedure

Procedure ListerEmployes()
/************************/
Variable
Debut
Pour E=LE.ParcoursAuDebut() JusquA LE.DernierElement() Faire Fin Pour
Fin Procedure

Fonction EncoderEnregistrementEmploye(O : Nul Ou Objet, G : Nul Ou GroupeMessagesEdifact Sortie) Retourner Nul Ou MessageEdifact
/**************************************************************************************************************************/
Debut G=Nul;
Si O==Nul Alors Fin Si
Retourner MonMessageEdifact;
Fin Fonction

Fonction DecoderEnregistrementEmploye(M : Nul Ou MessageEdifact, ? : Nul Ou GroupeMessagesEdifact) Retourner Nul Ou Type
/******************************************************************************************************************/
Debut
Si M.NomMessage==EtiquetteEmploye Alors Fin Si
Retourner Nul;
Fin Fonction

Fonction CritereEmploye(O : Nul Ou Objet) Retourner Booleen
/*********************************************************/
Variable
/******/
Debut
Si O==Nul Alors Fin Si
E=Employe(O);
Retourner E.Nom Comme "scott*";
Fin Fonction

Principal
/*******/
Variable
/******/
Debut
Ecran.Ecrire("Base de données");
Ecran.Ecrire("===============");
CreerListeDEmployes();
ListerEmployes();
Ecran.Ecrire("\n");

MonEnteteEdifact.SeparateurEtiquette=":";
MonEnteteEdifact.SeparateurValeurComposite=":";
MonEnteteEdifact.SymboleVirgule=",";
MonEnteteEdifact.SymboleVersion=Nul;
MonEnteteEdifact.NiveauSyntaxique="UNOB";
MonEnteteEdifact.VersionSyntaxique=2;
MonEnteteEdifact.LibelleEmetteur=NomProgramme;
MonEnteteEdifact.CodeEmetteur=Nul; MonEnteteEdifact.LibelleRecepteur=NomProgramme;
MonEnteteEdifact.CodeRecepteur=Nul;
MonEnteteEdifact.AdresseRecepteur=Nul;
MonEnteteEdifact.DateProduction=DateSysteme();
MonEnteteEdifact.CodeControle="CC";
MonEnteteEdifact.MotDePasse="motdepasse";
MonEnteteEdifact.IdentifiantApplication=Nul;
MonEnteteEdifact.CodePriorite="A";
MonEnteteEdifact.AccuseReception=Vrai;
MonEnteteEdifact.IdentifiantAccordCommunication="AC";
MonEnteteEdifact.ModeTest=Vrai;
MesElementsEdifact=ListeDe(ValeurElementaire("Nom", 20, Faux, ChampTypeCaractere, Faux));
MesElementsEdifact+=ValeurElementaire("Numero", 4, Vrai, ChampTypeEntier, Faux);
MesElementsEdifact+=ValeurElementaire("Salaire", 10, Faux, ChampTypeReel, Faux);
MesElementsEdifact+=ValeurElementaire("DateDEmbauche", 11, Faux, ChampTypeDate, Faux);
MesSegmentsEdifact=ListeDe(SegmentMessage("Employe", MesElementsEdifact));
MonMessageEdifact=MessageEdifact("Employe", "TM", "VM", "RM", "CC");
MonMessageEdifact.ListeSegments=MesSegmentsEdifact;

F=Fichier("/tmp/essai.edf", EcritureTexte);
E=EchangeEdifact(IFlux(F),MonEnteteEdifact,EncoderEnregistrementEmploye,DecoderEnregistrementEmploye);
Pour E2=LE.ParcoursAuDebut() JusquA LE.DernierElement() Pas LE.Suivant() Faire Fin Pour E=Nul;
F.Fermer();

Ecran.Ecrire("Importation complète");
Ecran.Ecrire("====================");
F=Fichier("/tmp/essai.edf", LectureTexte);
E=EchangeEdifact(IFlux(F),MonEnteteEdifact,EncoderEnregistrementEmploye,DecoderEnregistrementEmploye);
LE=Nul;
TantQue PasFini Faire Fin TantQue
E=Nul;
F.Fermer();
ListerEmployes();
Ecran.Ecrire("\n");

Ecran.Ecrire("A partir du 20èm rang");
Ecran.Ecrire("=====================");
F=Fichier("/tmp/essai.edf", LectureTexte);
E=EchangeEdifact(IFlux(F),MonEnteteEdifact,EncoderEnregistrementEmploye,DecoderEnregistrementEmploye);
E.FiltrerAPartirDe(20);
LE=Nul;
PasFini=Vrai;
TantQue PasFini Faire Fin TantQue
E=Nul;
F.Fermer();
ListerEmployes();
Ecran.Ecrire("\n");

Ecran.Ecrire("20 premiers rangs");
Ecran.Ecrire("=================");
F=Fichier("/tmp/essai.edf", LectureTexte);
E=EchangeEdifact(IFlux(F),MonEnteteEdifact,EncoderEnregistrementEmploye,DecoderEnregistrementEmploye);
E.FiltrerJusquA(20);
LE=Nul;
PasFini=Vrai;
TantQue PasFini Faire Fin TantQue
E=Nul;
F.Fermer();
ListerEmployes();
Ecran.Ecrire("\n");

Ecran.Ecrire("Entre 10 et 30èm rang");
Ecran.Ecrire("=====================");
F=Fichier("/tmp/essai.edf", LectureTexte);
E=EchangeEdifact(IFlux(F),MonEnteteEdifact,EncoderEnregistrementEmploye,DecoderEnregistrementEmploye);
E.FiltrerEntre(10,30);
LE=Nul;
PasFini=Vrai;
TantQue PasFini Faire Fin TantQue
E=Nul;
F.Fermer();
ListerEmployes();
Ecran.Ecrire("\n");

Ecran.Ecrire("scott uniquement");
Ecran.Ecrire("================");
F=Fichier("/tmp/essai.edf", LectureTexte);
E=EchangeEdifact(IFlux(F),MonEnteteEdifact,EncoderEnregistrementEmploye,DecoderEnregistrementEmploye);
E.FiltrerSelon(CritereEmploye);
LE=Nul;
PasFini=Vrai;
TantQue PasFini Faire Fin TantQue
E=Nul;
F.Fermer();
ListerEmployes();
Ecran.Ecrire("\n");
Fin Principal

Fichier de données

UNA+:+:+,+ + 'UNB+UNOB:2+test5::+test5::+051019:2243+CC+motdepasse:++A+1+AC+1' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+scott0+7724+1000,0+800112:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+allen0+7832+2000,0+810213:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+smith0+7948+1400,0+820314:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+king0+7964+2000,0+830415:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+scott1+7725+1001,0+800112:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+allen1+7833+2001,0+810213:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+smith1+7949+1401,0+820314:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+king1+7965+2001,0+830415:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+scott2+7726+1002,0+800112:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+allen2+7834+2002,0+810213:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+smith2+7950+1402,0+820314:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+king2+7966+2002,0+830415:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+scott3+7727+1003,0+800112:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+allen3+7835+2003,0+810213:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+smith3+7951+1403,0+820314:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+king3+7967+2003,0+830415:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+scott4+7728+1004,0+800112:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+allen4+7836+2004,0+810213:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+smith4+7952+1404,0+820314:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+king4+7968+2004,0+830415:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+scott5+7729+1005,0+800112:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+allen5+7837+2005,0+810213:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+smith5+7953+1405,0+820314:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+king5+7969+2005,0+830415:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+scott6+7730+1006,0+800112:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+allen6+7838+2006,0+810213:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+smith6+7954+1406,0+820314:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+king6+7970+2006,0+830415:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+scott7+7731+1007,0+800112:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+allen7+7839+2007,0+810213:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+smith7+7955+1407,0+820314:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+king7+7971+2007,0+830415:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+scott8+7732+1008,0+800112:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+allen8+7840+2008,0+810213:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+smith8+7956+1408,0+820314:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+king8+7972+2008,0+830415:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+scott9+7733+1009,0+800112:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+allen9+7841+2009,0+810213:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+smith9+7957+1409,0+820314:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+king9+7973+2009,0+830415:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+scott10+7734+1010,0+800112:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+allen10+7842+2010,0+810213:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+smith10+7958+1410,0+820314:0000'UNT+1+Employe' UNH+Employe+TM:VM:RM:CC:++0:C'Employe+king10+7974+2010,0+830415:0000'UNT+1+Employe' UNZ+44+CC'

Résultat de l'exécution

Base de données =============== scott0 7,724 1,000.0000 12/01/1980 00:00:00 allen0 7,832 2,000.0000 13/02/1981 00:00:00 smith0 7,948 1,400.0000 14/03/1982 00:00:00 king0 7,964 2,000.0000 15/04/1983 00:00:00 scott1 7,725 1,001.0000 12/01/1980 00:00:00 allen1 7,833 2,001.0000 13/02/1981 00:00:00 smith1 7,949 1,401.0000 14/03/1982 00:00:00 king1 7,965 2,001.0000 15/04/1983 00:00:00 scott2 7,726 1,002.0000 12/01/1980 00:00:00 allen2 7,834 2,002.0000 13/02/1981 00:00:00 smith2 7,950 1,402.0000 14/03/1982 00:00:00 king2 7,966 2,002.0000 15/04/1983 00:00:00 scott3 7,727 1,003.0000 12/01/1980 00:00:00 allen3 7,835 2,003.0000 13/02/1981 00:00:00 smith3 7,951 1,403.0000 14/03/1982 00:00:00 king3 7,967 2,003.0000 15/04/1983 00:00:00 scott4 7,728 1,004.0000 12/01/1980 00:00:00 allen4 7,836 2,004.0000 13/02/1981 00:00:00 smith4 7,952 1,404.0000 14/03/1982 00:00:00 king4 7,968 2,004.0000 15/04/1983 00:00:00 scott5 7,729 1,005.0000 12/01/1980 00:00:00 allen5 7,837 2,005.0000 13/02/1981 00:00:00 smith5 7,953 1,405.0000 14/03/1982 00:00:00 king5 7,969 2,005.0000 15/04/1983 00:00:00 scott6 7,730 1,006.0000 12/01/1980 00:00:00 allen6 7,838 2,006.0000 13/02/1981 00:00:00 smith6 7,954 1,406.0000 14/03/1982 00:00:00 king6 7,970 2,006.0000 15/04/1983 00:00:00 scott7 7,731 1,007.0000 12/01/1980 00:00:00 allen7 7,839 2,007.0000 13/02/1981 00:00:00 smith7 7,955 1,407.0000 14/03/1982 00:00:00 king7 7,971 2,007.0000 15/04/1983 00:00:00 scott8 7,732 1,008.0000 12/01/1980 00:00:00 allen8 7,840 2,008.0000 13/02/1981 00:00:00 smith8 7,956 1,408.0000 14/03/1982 00:00:00 king8 7,972 2,008.0000 15/04/1983 00:00:00 scott9 7,733 1,009.0000 12/01/1980 00:00:00 allen9 7,841 2,009.0000 13/02/1981 00:00:00 smith9 7,957 1,409.0000 14/03/1982 00:00:00 king9 7,973 2,009.0000 15/04/1983 00:00:00 scott10 7,734 1,010.0000 12/01/1980 00:00:00 allen10 7,842 2,010.0000 13/02/1981 00:00:00 smith10 7,958 1,410.0000 14/03/1982 00:00:00 king10 7,974 2,010.0000 15/04/1983 00:00:00 Importation complète ==================== scott0 7,724 1,000.0000 12/01/1980 00:00:00 allen0 7,832 2,000.0000 13/02/1981 00:00:00 smith0 7,948 1,400.0000 14/03/1982 00:00:00 king0 7,964 2,000.0000 15/04/1983 00:00:00 scott1 7,725 1,001.0000 12/01/1980 00:00:00 allen1 7,833 2,001.0000 13/02/1981 00:00:00 smith1 7,949 1,401.0000 14/03/1982 00:00:00 king1 7,965 2,001.0000 15/04/1983 00:00:00 scott2 7,726 1,002.0000 12/01/1980 00:00:00 allen2 7,834 2,002.0000 13/02/1981 00:00:00 smith2 7,950 1,402.0000 14/03/1982 00:00:00 king2 7,966 2,002.0000 15/04/1983 00:00:00 scott3 7,727 1,003.0000 12/01/1980 00:00:00 allen3 7,835 2,003.0000 13/02/1981 00:00:00 smith3 7,951 1,403.0000 14/03/1982 00:00:00 king3 7,967 2,003.0000 15/04/1983 00:00:00 scott4 7,728 1,004.0000 12/01/1980 00:00:00 allen4 7,836 2,004.0000 13/02/1981 00:00:00 smith4 7,952 1,404.0000 14/03/1982 00:00:00 king4 7,968 2,004.0000 15/04/1983 00:00:00 scott5 7,729 1,005.0000 12/01/1980 00:00:00 allen5 7,837 2,005.0000 13/02/1981 00:00:00 smith5 7,953 1,405.0000 14/03/1982 00:00:00 king5 7,969 2,005.0000 15/04/1983 00:00:00 scott6 7,730 1,006.0000 12/01/1980 00:00:00 allen6 7,838 2,006.0000 13/02/1981 00:00:00 smith6 7,954 1,406.0000 14/03/1982 00:00:00 king6 7,970 2,006.0000 15/04/1983 00:00:00 scott7 7,731 1,007.0000 12/01/1980 00:00:00 allen7 7,839 2,007.0000 13/02/1981 00:00:00 smith7 7,955 1,407.0000 14/03/1982 00:00:00 king7 7,971 2,007.0000 15/04/1983 00:00:00 scott8 7,732 1,008.0000 12/01/1980 00:00:00 allen8 7,840 2,008.0000 13/02/1981 00:00:00 smith8 7,956 1,408.0000 14/03/1982 00:00:00 king8 7,972 2,008.0000 15/04/1983 00:00:00 scott9 7,733 1,009.0000 12/01/1980 00:00:00 allen9 7,841 2,009.0000 13/02/1981 00:00:00 smith9 7,957 1,409.0000 14/03/1982 00:00:00 king9 7,973 2,009.0000 15/04/1983 00:00:00 scott10 7,734 1,010.0000 12/01/1980 00:00:00 allen10 7,842 2,010.0000 13/02/1981 00:00:00 smith10 7,958 1,410.0000 14/03/1982 00:00:00 king10 7,974 2,010.0000 15/04/1983 00:00:00 A partir du 20èm rang ===================== king4 7,968 2,004.0000 15/04/1983 00:00:00 scott5 7,729 1,005.0000 12/01/1980 00:00:00 allen5 7,837 2,005.0000 13/02/1981 00:00:00 smith5 7,953 1,405.0000 14/03/1982 00:00:00 king5 7,969 2,005.0000 15/04/1983 00:00:00 scott6 7,730 1,006.0000 12/01/1980 00:00:00 allen6 7,838 2,006.0000 13/02/1981 00:00:00 smith6 7,954 1,406.0000 14/03/1982 00:00:00 king6 7,970 2,006.0000 15/04/1983 00:00:00 scott7 7,731 1,007.0000 12/01/1980 00:00:00 allen7 7,839 2,007.0000 13/02/1981 00:00:00 smith7 7,955 1,407.0000 14/03/1982 00:00:00 king7 7,971 2,007.0000 15/04/1983 00:00:00 scott8 7,732 1,008.0000 12/01/1980 00:00:00 allen8 7,840 2,008.0000 13/02/1981 00:00:00 smith8 7,956 1,408.0000 14/03/1982 00:00:00 king8 7,972 2,008.0000 15/04/1983 00:00:00 scott9 7,733 1,009.0000 12/01/1980 00:00:00 allen9 7,841 2,009.0000 13/02/1981 00:00:00 smith9 7,957 1,409.0000 14/03/1982 00:00:00 king9 7,973 2,009.0000 15/04/1983 00:00:00 scott10 7,734 1,010.0000 12/01/1980 00:00:00 allen10 7,842 2,010.0000 13/02/1981 00:00:00 smith10 7,958 1,410.0000 14/03/1982 00:00:00 king10 7,974 2,010.0000 15/04/1983 00:00:00 20 premiers rangs ================= scott0 7,724 1,000.0000 12/01/1980 00:00:00 allen0 7,832 2,000.0000 13/02/1981 00:00:00 smith0 7,948 1,400.0000 14/03/1982 00:00:00 king0 7,964 2,000.0000 15/04/1983 00:00:00 scott1 7,725 1,001.0000 12/01/1980 00:00:00 allen1 7,833 2,001.0000 13/02/1981 00:00:00 smith1 7,949 1,401.0000 14/03/1982 00:00:00 king1 7,965 2,001.0000 15/04/1983 00:00:00 scott2 7,726 1,002.0000 12/01/1980 00:00:00 allen2 7,834 2,002.0000 13/02/1981 00:00:00 smith2 7,950 1,402.0000 14/03/1982 00:00:00 king2 7,966 2,002.0000 15/04/1983 00:00:00 scott3 7,727 1,003.0000 12/01/1980 00:00:00 allen3 7,835 2,003.0000 13/02/1981 00:00:00 smith3 7,951 1,403.0000 14/03/1982 00:00:00 king3 7,967 2,003.0000 15/04/1983 00:00:00 scott4 7,728 1,004.0000 12/01/1980 00:00:00 allen4 7,836 2,004.0000 13/02/1981 00:00:00 smith4 7,952 1,404.0000 14/03/1982 00:00:00 king4 7,968 2,004.0000 15/04/1983 00:00:00 Entre 10 et 30èm rang ===================== allen2 7,834 2,002.0000 13/02/1981 00:00:00 smith2 7,950 1,402.0000 14/03/1982 00:00:00 king2 7,966 2,002.0000 15/04/1983 00:00:00 scott3 7,727 1,003.0000 12/01/1980 00:00:00 allen3 7,835 2,003.0000 13/02/1981 00:00:00 smith3 7,951 1,403.0000 14/03/1982 00:00:00 king3 7,967 2,003.0000 15/04/1983 00:00:00 scott4 7,728 1,004.0000 12/01/1980 00:00:00 allen4 7,836 2,004.0000 13/02/1981 00:00:00 smith4 7,952 1,404.0000 14/03/1982 00:00:00 king4 7,968 2,004.0000 15/04/1983 00:00:00 scott5 7,729 1,005.0000 12/01/1980 00:00:00 allen5 7,837 2,005.0000 13/02/1981 00:00:00 smith5 7,953 1,405.0000 14/03/1982 00:00:00 king5 7,969 2,005.0000 15/04/1983 00:00:00 scott6 7,730 1,006.0000 12/01/1980 00:00:00 allen6 7,838 2,006.0000 13/02/1981 00:00:00 smith6 7,954 1,406.0000 14/03/1982 00:00:00 king6 7,970 2,006.0000 15/04/1983 00:00:00 scott7 7,731 1,007.0000 12/01/1980 00:00:00 allen7 7,839 2,007.0000 13/02/1981 00:00:00 scott uniquement ================ scott0 7,724 1,000.0000 12/01/1980 00:00:00 scott1 7,725 1,001.0000 12/01/1980 00:00:00 scott2 7,726 1,002.0000 12/01/1980 00:00:00 scott3 7,727 1,003.0000 12/01/1980 00:00:00 scott4 7,728 1,004.0000 12/01/1980 00:00:00 scott5 7,729 1,005.0000 12/01/1980 00:00:00 scott6 7,730 1,006.0000 12/01/1980 00:00:00 scott7 7,731 1,007.0000 12/01/1980 00:00:00 scott8 7,732 1,008.0000 12/01/1980 00:00:00 scott9 7,733 1,009.0000 12/01/1980 00:00:00 scott10 7,734 1,010.0000 12/01/1980 00:00:00