-
Notifications
You must be signed in to change notification settings - Fork 4
/
ExportAttendees.cbl
91 lines (82 loc) · 2.86 KB
/
ExportAttendees.cbl
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
identification division.
program-id. ExportAttendees.
environment division.
configuration section.
repository.
function all intrinsic.
input-output section.
file-control.
select CSVFile assign to CSVFileName
organization is line sequential.
select optional AttendeesFile assign to AttendeesFileName
organization is indexed
access mode is dynamic
record key is AuthCode.
data division.
file section.
fd CSVFile.
01 CSVFileOutputLine pic x(255) value spaces.
88 EndOfCSVFile value high-values.
fd AttendeesFile is global.
copy DD-Attendee replacing Attendee by
==AttendeeRecord is global.
88 EndOfAttendeesFile value high-values==.
working-storage section.
01 CountOfLinesProcessed pic 999 value zero.
01 AttendeesFileName pic x(20) value spaces.
01 CSVSourceFileName pic x(30) value spaces.
01 CommandLineArgumentCount pic 9 value zero.
procedure division.
accept CommandLineArgumentCount from argument-number
if CommandLineArgumentCount equal to 2 then
accept AttendeesFileName from argument-value
accept CSVFileName from argument-value
else
display "Usage: ExportAttendees <BAMS Data File> <CSV Output File>"
stop run
end-if
display "Reading from " trim(AttendeesFileName) " and writing to " trim(CSVFileName)
open output CSVFile
write CSVFileOutputLine from "AuthCode,Name,Email,AmountToPay,AmountPaid,DatePaid,Telephone,ArrivalDay,StayingLate,NumberOfKids,Diet"
open input AttendeesFile
read AttendeesFile next record
at end set EndOfAttendeesFile to true
end-read
perform until EndOfAttendeesFile
initialize CSVFileOutputLine
string
trim(AuthCode) delimited by size
","
trim(AttendeeName) delimited by size
","
trim(Email) delimited by size
","
trim(AmountToPay) delimited by size
","
trim(AmountPaid) delimited by size
","
trim(DatePaid) delimited by size
","
trim(Telephone) delimited by size
","
trim(ArrivalDay) delimited by size
","
trim(StayingTillMonday) delimited by size
","
trim(NumberOfKids) delimited by size
","
trim(Diet) delimited by size
into CSVFileOutputLine
end-string
write CSVFileOutputLine
add 1 to CountOfLinesProcessed
read AttendeesFile next record
at end set EndOfAttendeesFile to true
end-read
end-perform
close AttendeesFile
close CSVFile
display "Total attendees exported to CSV is " CountOfLinesProcessed
stop run
.
end program ExportAttendees.