Up ! Sap IDoc

Ce programme présente l'échange de données au format IDoc de Sap.

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

Mode compilé

Commande de compilation

upscmp Source=formatidoc.upl

Commande d'exécution

formatidoc

Mode interprété

upssng Source=formatidoc.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) Retourner Nul Ou Enregistrement
/***********************************************************************************/
Debut
Si O==Nul Alors Fin Si
Retourner MonEnregistrementEmploye;
Fin Fonction

Fonction DecoderEnregistrementEmploye(Ligne : Caractere) Retourner Nul Ou Enregistrement
/************************************************************************************/
Debut
Si Ligne.Gauche(6)==MarqueurEntete Alors Fin Si
Si Ligne.Gauche(5)==MarqueurEmploye 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");

MesChampsEntete=ListeDe(Champ(Nul, 0, 6, ChampTypeCaractere, MarqueurEntete));
MonEnregistrementEntete=Enregistrement("Entete", Nul, MesChampsEntete);
MesChampsEmploye=ListeDe(Champ(Nul,0, 5, ChampTypeCaractere, MarqueurEmploye));
MesChampsEmploye+=Champ("Nom", 5, 20, ChampTypeCaractere);
MesChampsEmploye+=Champ("Numero", 30, 5, ChampTypeEntier);
MesChampsEmploye+=Champ("Salaire", 40, 10, ChampTypeReel);
MesChampsEmploye+=Champ("DateDEmbauche", 50, 20, ChampTypeDate);
MonEnregistrementEmploye=Enregistrement("Employe", Employe, MesChampsEmploye);

F=Fichier("/tmp/essai.idoc", EcritureTexte);
F.Ecrire(MarqueurEntete+"\n");
E=EchangeIdoc(IFlux(F), 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.idoc", LectureTexte);
E=EchangeIdoc(IFlux(F), EncoderEnregistrementEmploye,DecoderEnregistrementEmploye);
LE=Nul;
PasFini=Vrai;
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.idoc", LectureTexte);
E=EchangeIdoc(IFlux(F), 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.idoc", LectureTexte);
E=EchangeIdoc(IFlux(F), 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.idoc", LectureTexte);
E=EchangeIdoc(IFlux(F), 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.idoc", LectureTexte);
E=EchangeIdoc(IFlux(F), 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

EDI_DC Z2EDPscott0 7724 1000.0 12/1/1980 00:00:00 Z2EDPallen0 7832 2000.0 13/2/1981 00:00:00 Z2EDPsmith0 7948 1400.0 14/3/1982 00:00:00 Z2EDPking0 7964 2000.0 15/4/1983 00:00:00 Z2EDPscott1 7725 1001.0 12/1/1980 00:00:00 Z2EDPallen1 7833 2001.0 13/2/1981 00:00:00 Z2EDPsmith1 7949 1401.0 14/3/1982 00:00:00 Z2EDPking1 7965 2001.0 15/4/1983 00:00:00 Z2EDPscott2 7726 1002.0 12/1/1980 00:00:00 Z2EDPallen2 7834 2002.0 13/2/1981 00:00:00 Z2EDPsmith2 7950 1402.0 14/3/1982 00:00:00 Z2EDPking2 7966 2002.0 15/4/1983 00:00:00 Z2EDPscott3 7727 1003.0 12/1/1980 00:00:00 Z2EDPallen3 7835 2003.0 13/2/1981 00:00:00 Z2EDPsmith3 7951 1403.0 14/3/1982 00:00:00 Z2EDPking3 7967 2003.0 15/4/1983 00:00:00 Z2EDPscott4 7728 1004.0 12/1/1980 00:00:00 Z2EDPallen4 7836 2004.0 13/2/1981 00:00:00 Z2EDPsmith4 7952 1404.0 14/3/1982 00:00:00 Z2EDPking4 7968 2004.0 15/4/1983 00:00:00 Z2EDPscott5 7729 1005.0 12/1/1980 00:00:00 Z2EDPallen5 7837 2005.0 13/2/1981 00:00:00 Z2EDPsmith5 7953 1405.0 14/3/1982 00:00:00 Z2EDPking5 7969 2005.0 15/4/1983 00:00:00 Z2EDPscott6 7730 1006.0 12/1/1980 00:00:00 Z2EDPallen6 7838 2006.0 13/2/1981 00:00:00 Z2EDPsmith6 7954 1406.0 14/3/1982 00:00:00 Z2EDPking6 7970 2006.0 15/4/1983 00:00:00 Z2EDPscott7 7731 1007.0 12/1/1980 00:00:00 Z2EDPallen7 7839 2007.0 13/2/1981 00:00:00 Z2EDPsmith7 7955 1407.0 14/3/1982 00:00:00 Z2EDPking7 7971 2007.0 15/4/1983 00:00:00 Z2EDPscott8 7732 1008.0 12/1/1980 00:00:00 Z2EDPallen8 7840 2008.0 13/2/1981 00:00:00 Z2EDPsmith8 7956 1408.0 14/3/1982 00:00:00 Z2EDPking8 7972 2008.0 15/4/1983 00:00:00 Z2EDPscott9 7733 1009.0 12/1/1980 00:00:00 Z2EDPallen9 7841 2009.0 13/2/1981 00:00:00 Z2EDPsmith9 7957 1409.0 14/3/1982 00:00:00 Z2EDPking9 7973 2009.0 15/4/1983 00:00:00 Z2EDPscott10 7734 1010.0 12/1/1980 00:00:00 Z2EDPallen10 7842 2010.0 13/2/1981 00:00:00 Z2EDPsmith10 7958 1410.0 14/3/1982 00:00:00 Z2EDPking10 7974 2010.0 15/4/1983 00:00:00

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