Précédent   Forum du club des développeurs et IT Pro > Autres langages > Autres langages > Cobol
Cobol Forum d'entraide sur la programmation en langage Cobol
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 26/04/2012, 18h26   #1
thomasaurelien
Candidat au titre de Membre du Club
 
Homme
Inscription : août 2011
Messages : 83
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France, Vosges (Lorraine)

Informations forums :
Inscription : août 2011
Messages : 83
Points : 11
Points : 11
Par défaut transfert fichier séquentiel

Bonjour, nous venons d'étudié les fichiers en cours (je suis en DUT informatique) et pour cela nous avons un exercice qui consiste à transféré des données d'un fichier séquentiel "propriétaire1.dat" à 2 fichier direct "proprio.dat" et "appart.dat". Pour la partie des infos des proprio cela n'as pas été trop dur mais je ne vois pas comment faire pour les infos d'un appart car ceux-ci ce trouve dans un tableau[5] appart.

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
       program-id. partie1.

       file-control.
           select f-proprietaire1
           assign to 'proprietaire1.dat'organization
           sequential.
           select f-proprio assign to 'proprio.dat' organization indexed
           access dynamic record key NumPropp.
           select f-appart assign to 'appart.dat' organization indexed
           access dynamic record key NumApparta
           alternate record key NumPropa
           duplicates.

       data division.

       file section.
       fd f-proprietaire1.
       1 Proprietaire1.
           2 NomProp pic x(20).
           2 PrenomProp pic x(20).
           2 VilleProp pic x(20).
           2 TelProp pic x(10).
           2 Tab.
               3 appart occurs 5.
                   4 nbpiece pic 99.
                   4 Etage pic 99.
                   4 NbPersMax pic 99.
                   4 tarifHT pic 9999.
                   4 tarifBS pic 9999.
                   4 vue pic x(20).
                   4 Ville pic x(20).
       fd f-proprio.
       1 Proprietaire.
           2 NumPropp pic 99.
           2 NomPropp pic x(20).
           2 PrenomPropp pic x(20).
           2 VillePropp pic x(20).
           2 TelPropp pic x(10).
       fd f-appart.
       1 Appartement.
           2 NumApparta pic 99.
           2 NumPropa pic 99.
           2 Nbpiecea pic 99.
           2 Etagea pic 99.
           2 NbPersMaxa pic 99.
           2 tarifHTa pic 9999.
           2 tarifBSa pic 9999.
           2 vuea pic x(20).
           2 Villea pic x(20).

       working-storage section.
       1 v-fin-f-proprietaire1 pic x value 'N'.
       88 fin-f-proprietaire1 value 'O' false 'N'.
       1 i pic 9 value 1.
       1 nump pic 99 value 1.
       1 numa pic 99 value 1.

       procedure division.
           open output f-appart
           open output f-proprio
           open input f-proprietaire1
           read f-proprietaire1 end set fin-f-proprietaire1 to true
           end-read
           perform until fin-f-proprietaire1

               perform mod-proprio
               perform test after varying i from 1 by 1 until i=5
                   perform mod-appart
               end-perform
               read f-proprietaire1 end set fin-f-proprietaire1 to true
               end-read
               compute nump = nump + 1

           end-perform
           close f-proprietaire1.
           close f-proprio.
           close f-appart.
           goback.

       mod-proprio.
       move nump to NumPropp
       move NomProp to NomPropp
       move PrenomProp to PrenomPropp
       move VilleProp to VillePropp
       move TelProp to TelPropp
       write proprietaire
       end-write.

       mod-appart.
       move Numa to NumApparta
       move nump to NumPropa
      *******
      *
      *Zone de transfert d'un appart
      ****
       write appartement
       end-write
       compute numa = numa + 1.

       end program partie1.
thomasaurelien est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/04/2012, 18h58   #2
Hédhili Jaïdane
Expert Confirmé
 
Homme
Consultant/Formateur/Développeur AS/400, iSeries, System i et Cobol
Inscription : juin 2007
Messages : 1 783
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : Tunisie

Informations professionnelles :
Activité : Consultant/Formateur/Développeur AS/400, iSeries, System i et Cobol

Informations forums :
Inscription : juin 2007
Messages : 1 783
Points : 2 713
Points : 2 713
Bonjour.

- d'abord, j'ajouterais, parce qu'un proprio peut ne pas avoir ses 5 apparts renseignés :
Code :
1
2
.... until i=5 or nbpiece(i) = 0
pour les "transferts" :
Code :
1
2
3
move i to NumApparta
move nbpiece(i) to nbpiecea
et je remplacerais bien volontiers le
Code :
1
2
compute nump = nump + 1
par :
__________________

Hédhili Jaïdane est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/04/2012, 20h40   #3
thomasaurelien
Candidat au titre de Membre du Club
 
Homme
Inscription : août 2011
Messages : 83
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France, Vosges (Lorraine)

Informations forums :
Inscription : août 2011
Messages : 83
Points : 11
Points : 11
Par défaut tableau fichier acces séquentiel

Merci pour l'aide sa marche nikel !

Je met résolu pour le topic
thomasaurelien est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Cette discussion est résolue.
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 09h05.


 
 
 
 
Partenaires

Hébergement Web