v2pay.rexx 29.11.2002 16:06:25
/**********************************************************************/
/* V2PAY: EDIFACT Format V2 to PAYMUL Format Conversion */
/* (c) Th. Schneider, February 2002 */
/**********************************************************************/
/* vs. 1.0 : 25.03.2002 : initial version */
/**********************************************************************/
pp_vers='1.0'
parse source processor .
if processor='Java' then do
fpath='J:\BH\EDIFACT\PAYMUL\' /* Donauland*/
fpath_v2=fpath'v2\'
fpath_log=fpath'log\'
fpath_data=fpath'data\'
end
else do /* CMS version */
fpath='B1' /* work disk in CMS */
fpath_v2='B1'
fpath_data='B1'
fpath_log='B1'
end
parse arg parms
if parms = '' then do /* Vor-Monatsdaten sind default input !*/
yyyymmdd=date('S')
yyyy=substr(yyyymmdd,1,4)
mm=substr(yyyymmdd,5,2)
mm=right(mm-1,2,'0') /* must be 2 digits! */
if mm=00 then do
yyyy=yyyy-1
mm=12
end
yy=substr(yyyy,3,2)
ffn='LOHN'!!yy!!mm /* Standard-Eingabe-Datei */
input_file=fileid(ffn,'v2',fpath_v2)
if exists(input_file)=0 then do
call abort('Eingabe-Datei: 'input_file 'noch nicht vorhanden!')
end
else say 'Eingabe von Datei:' input_file
opts='' /* default optionen hier eintragen */
/* opts=askfor('Optionen') */
end
else do
parse var parms input_file'(' opts ')'
end
Konto_Nr_1='' /* letzte Konto-Nummer */
fx=parsefid(input_file)
parse var fx fn ft fm
ffn=fn
call init_info fn,'NEW'
log_file=info_file
yy=substr(fn,5,2); yyyy='20'yy
mm=substr(fn,7,2)
Referenz='Provision 'yyyy'/'mm
EDI_Referenz='PROV'yyyy!!mm
/* Großbuchstaben, keine Sonderzeichen erlaubt */
if ft='' then do
ft='V2' /* use V2 as default file type */
input_file=fileid(fn,ft,fm)
end
if ft <> 'V2' then call abort 'Eingabedatei muß Datei-Typ "V2" haben!'
customer='DL' /* special display for Donauland */
numeric digits 15 /* for long integer calculations */
time1=time('R')
run_date=edate()
call info2 'V2PAY: V2 --> PAYMUL Konversion vs.'pp_vers ':' run_date
/* ... read in V2 definition file */
V2_def=fileid('V2','DEF')
call in_V2_definition V2_def
paymul_def=fileid('PAYMUL','DEF')
paymul_file=fileid(fn,'PAYMUL',fpath_data)
call info ' '
call info 'Eingabe-Datei (V2-Format) ....: 'input_file
call info 'Ausgabe_Datei (PAYMUL-Fonmat) :' paymul_file
call info 'LOG-File .....................:' log_file
call init_Kontroll_Summen
call start_EDI_composer paymul_file,paymul_def,opts
V2_file=input_file
call V2_Summen_bilden /* wir brauchen die Detail-Summe am Anfang */
/* fuer Segment MOA in Gruppe 5 */
call start_V2_file
has_data=0
EOF=0 /* EOF not yet reached */
count_V2=0
do forever
V2_type=in_V2()
if V2_type='' then leave /*EOF or error encountered */
if EOF then leave
has_data=1
if opt_detail then
call display_V2(V2_type) /* display V2 records currenlty for debug*/
count_V2=count_V2+1
select
when V2_type='00' then call Verarbeitung_00
when V2_type='01' then call Verarbeitung_01
when V2_type='02' then call Verarbeitung_02
when V2_type>='03' & V2_type<='09' then call Verarbeitung_03
when V2_type='99' then do
call Verarbeitung_99
leave /* NUR EIN BLOCK UNTERSTÜTZT */
end
otherwise call abort 'unzulaessige Satzart: 'V2_type
end
end
call PAYMUL_footer
call finish_EDI_composer
call finish_V2_file
if has_data = 0 then do
call info copies('*',60)
call info 'Eingabe-Datei:' input_file 'ist leer!!'
call info 'keine Verarbeitung moeglich!'
call info copies('*',60)
call pause
exit 81
end
call display_Summen_Block
if n_errors > 0 then do
stars=copies('*',80)
call info stars
call info0 n_errors 'Fehler festgestellt'
call info stars
if return_status=0 then return_status=4
end
call info 'Anzahl verwendete LINE-Segmente:' LIN_no
time2=time('E')
used=time2-time1
elapsed=format(used,,3)
call info 'V2 to EDIFACT PAYMUL Konversionng benoetigte',
elapsed 'Sekunden.'
call info0 n_warnings 'Warnungen'
call info0 n_errors 'Fehler'
return_status=0
if customer='DL' then do
ff_EDI=fileid(ffn,'PAYMUL',fpath_data)
ff_V2=fileid(ffn,'V2',fpath_v2)
ff_LOG=fileid(ffn,'LOG',fpath_log)
call info ' '
call info 'Gesicherte V2-Datei ...:' ff_V2
call info 'Gesicherte PAYMUL Datei:' ff_EDI
call info 'Gesicherte LOG-Datei :' ff_LOG
call info ' '
call pause ' Bitte irgendeine Taste druecken!'
parse source processor .
if processor <> 'CMS' then do
if paymul_file <> ff_EDI then call copyfile paymul_file,ff_EDI,0
call closelog
if log_file <> ff_LOG then call copyfile log_file,ff_LOG,0
end
else call closelog
end
exit return_status
PAYMUL_header:
call init_EDI_Segment 0,'UNH'
call Set_EDI_Val '0062',EDI_Referenz
call Set_EDI_Val 'S009.0065','PAYMUL'
call Set_EDI_Val 'S009.0052','D'
call Set_EDI_Val 'S009.0054','96A'
call Set_EDI_Val 'S009.0051','UN'
call write_EDI_Segment 0,'UNH'
call init_EDI_Segment 0,'BGM'
call Set_EDI_Val 'C002.1001','452'
call Set_EDI_Val '1004',EDI_Referenz
call write_EDI_Segment 0,'BGM'
call init_EDI_Segment 0,'DTM'
call Set_EDI_Val 'C507.2005','137'
/* Erstellungszeit der Nachricht */
Erstellungs_Datum=date('S') /* YYYYMMDD */
dts=datetime()
call Set_EDI_Val 'C507.2380',dts
e_erstellt_am=edate(Erstellungs_Datum) /* edited date */
call info 'Erstellungsdatum:' e_erstellt_am
call set_EDI_Val 'C507.2379','204'
call write_EDI_Segment 0,'DTM'
/* Segmentgruppe 1 wir von Donauland NICHT verwendet! */
Konto_Nr_DL=V2.9 /* Konto-Nummer Donauland */
BLZ_DL=V2.4 /* Bankleitzahl */
call info 'BLZ:' BLZ_DL 'Konto-Nr.:' Konto_Nr_DL
call init_EDI_Segment 2,'FII'
call Set_EDI_Val '3035','MR' /* message receiver! */
call set_EDI_Val 'C078.3194',Konto_Nr_DL
call set_EDI_Val 'C078.3192.1',V2.10 /* Name Absender */
call Set_EDI_Val 'C088.3433',BLZ_DL
/* Absender Bankleitzahl */
call info2 'Bank-Band von:' V2.10 'erstellt am:' e_erstellt_am
call write_EDI_Segment 2,'FII'
call init_EDI_Segment 3,'NAD'
call Set_EDI_Val '3035','MS'
call set_EDI_Val 'C080.3036.1','Buchgemeinschaft Donauland'
call set_EDI_Val 'C059.3042.1','Niederhofstr. 37'
call set_EDI_Val '3154','Wien'
call set_EDI_Val '3251','1201'
call write_EDI_Segment 3,'NAD'
call init_EDI_segment 3,'CTA'
call Set_EDI_Val '3139','MS' /* Message Sender */
call set_EDI_Val 'C056.3413','EDV Donauland'
call set_EDI_val 'C056.3412','Thomas Schneider'
call write_EDI_Segment 3,'CTA'
call init_EDI_Segment 3,'COM'
call Set_EDI_Val 'C076.3148','Thomas.Schneider@Donauland.at'
call Set_EDI_Val 'C076.3155','EM' /* E-mail */
call write_EDI_segment 3,'COM'
call init_EDI_Segment 3,'COM'
call Set_EDI_Val 'C076.3148','81102/638'
call Set_EDI_Val 'C076.3155','TE' /* Telefon */
call write_EDI_segment 3,'COM'
return
Verarbeitung_00:
If (count_V2=1 ) then call PAYMUL_header
return
Neues_LINE_Segment:
Lin_no=Lin_no+1
select
when lin_no=1 then call info 'Ueberweisungen: 'Summe_ueberweis
when lin_no=2 then
call info 'Post Bar-Ueberweisungen:' Summe_postbar
otherwise call abort 'maximal 2 LINE-Segmente erlaubt!'
end
call init_EDI_Segment 4,'LIN'
level='B';
Seq_No=0
call Set_EDI_Val '1082',LIN_no
EDI_Kontroll_Summe_2=EDI_Kontroll_Summe_2 + 1
/* EDI_Kontroll_Summe_2: Anzahl LIN-Abschnitte */
call write_EDI_Segment 4,'LIN'
call init_EDI_Segment 4,'DTM'
call Set_EDI_Val 'C507.2005','203'
Valuta_Datum=date('S')
call Set_EDI_Val 'C507.2380',Valuta_Datum
call Set_EDI_Val 'C507.2379','102'
call write_EDI_Segment 4,'DTM'
call init_EDI_Segment 4,'RFF'
call Set_EDI_Val 'C506.1153','AEK'
if postbar then AEK_Ref='Post 'yyyy'/'mm
else AEK_Ref='Ueberw.' yyyy'/'mm
call Set_EDI_Val 'C506.1154',AEK_Ref
call write_EDI_Segment 4,'RFF'
call init_EDI_Segment 4,'BUS'
call Set_EDI_Val 'C521.4027','1'
call set_EDI_Val 'C521.4025','COM' /* Commission=Provision */
call Set_EDI_Val '3279','DO'
call Set_EDI_Val '4487','1'
if postbar then bank_operation='CPP'
else bank_operation='TRF' /* Ueberweisung */
call Set_EDI_Val 'C551.4383',bank_operation
call write_EDI_Segment 4,'BUS'
call init_EDI_Segment 5,'MOA'
call Set_EDI_Val 'C516.5025','9'
select
when LIN_No = 1 then Summe_Line=Summe_Ueberweis
when LIN_No = 2 then Summe_Line=Summe_Postbar
otherwise call abort 'Sortierfehler, EDV-verstaendigen'
end
call Set_EDI_Val 'C516.5004',Summe_Line
call Set_EDI_Val 'C516.6345','EUR' /* currency */
call write_EDI_Segment 5,'MOA'
EDI_Kontroll_Summe_1=EDI_Kontroll_Summe_1 + Summe_Line
/* EDI_Kontroll_Summe_1: Summe MOA SegmentGruppe 5*/
call init_EDI_segment 6,'FII'
call set_EDI_Val '3035','OR'
call set_EDI_Val 'C078.3194',Konto_Nr_DL
call set_EDI_Val 'C078.3192.1','Buchgemeinschaft Donauland'
call set_EDI_Val 'C078.6345','EUR'
call set_EDI_Val 'C088.3433',BLZ_DL
call write_EDI_segment 6,'FII'
call init_EDI_Segment 10,'PRC'
call set_EDI_VAL 'C242.7187','11' /*info in unstrukt. Form*/
call write_EDI_Segment 10,'PRC'
call init_EDI_Segment 10,'FTX'
call Set_EDI_Val '4451','PMD' /* Payment Details */
call Set_EDI_Val 'C108.4440.1','Ueberweisung Donauland'
call Set_EDI_Val 'C108.4440.2',Referenz
call write_EDI_Segment 10,'FTX'
return
V2_Summen_bilden:
/*************************************************************/
/* verdammt, wir brauchen die Summe aller beträge am Anfang !*/
/*************************************************************/
V2_Summe=0
Summe_Ueberweis=0
Summe_Postbar=0
call open V2_file
do forever
V2_type=in_V2()
if V2_type='' then leave
if V2_type='01' then do
Betrag=V2.15 /* hat schon 2 Dezimalen */
V2_Summe=V2_Summe+Betrag
Belegart=V2.13 /* feld 13 ist belegart SA 01 */
select
when Belegart=43 then Summe_Ueberweis=Summe_Ueberweis+Betrag
when Belegart=15 then Summe_Postbar=Summe_Postbar+Betrag
otherwise do
call error 'unzulässige Belegart:' Belegart 'in SA 01'
call abort 'Verarbeitung nicht moeglich'
end
end
end
if V2_type='99' then leave
end
call info ' '
call info 'Summe Ueberweisungen .... :' fix(Summe_Ueberweis)
call info 'Summe Post-Bar ...........:' fix(Summe_postbar)
call info ' -------------'
call info 'Gesamt-Summe .............:' fix(V2_Summe)
call info ' ============='
call info ' '
if Summe_Postbar + Summe_Ueberweis <> V2_Summe
then call abort '*** fataler Summen-Fehler, EDV verständigen ***'
call close V2_file
return
fix:
parse arg amount
return format(amount,11,2)
Verarbeitung_01:
Belegart=V2.13
/* Entweder Uberweisung oder postbar (Post bar-Anweisung) */
if belegart=43 then ueberweisung=1
else ueberweisung=0
if belegart=15 then postbar=1
else postbar=0
if ueberweisung=0 & postbar=0 then
call abort('*** unzulaessige Belegart:' Belegart '***')
if LIN_No=0 then call neues_Line_segment
if lin_no=1 & Belegart=15 then call neues_Line_segment
return
Verarbeitung_02:
call init_EDI_Segment 11,'SEQ'
SEQ_No=SEQ_No + 1
EDI_Kontroll_Summe_3=EDI_Kontroll_Summe_3 +1
/* EDI_Kontroll_Summe_3: Anzahl SEQ-Abschnitte */
call Set_EDI_Val 'C286.1050',SEQ_No
if opt_short then call info ' SEQ No:' SEQ_no
call Set_EDI_Val 'C286.1159',V2.13
call Set_EDI_Val 'C286.1131','EBA'
call Set_EDI_Val 'C286.3055','137'
call write_EDI_segment 11,'SEQ'
/* Folgenummer source, codiert */
call init_EDI_Segment 11,'MOA'
call set_EDI_val 'C516.5025','9'
Detail_Betrag=V2.15 /* 2 decimal places */
call Set_EDI_Val 'C516.5004',Detail_Betrag
Detail_Waehrung='EUR'
call Set_EDI_Val 'C516.6345',Detail_Waehrung
Kontroll_Summe_1=Kontroll_Summe_1 + Detail_Betrag
Anzahl_Umsaetze = Anzahl_Umsaetze + 1
/* Bildung Gesamt-Summen fuer Summen-Block */
select
when Detail_Waehrung='ATS' then do
Anzahl_ATS=Anzahl_ATS+1
Summe_ATS=Summe_ATS+Detail_Betrag
end
when Detail_Waehrung='EUR' then do
Anzahl_EUR=Anzahl_EUR+1
Summe_EUR=Summe_EUR+Detail_Betrag
end
otherwise do
call error 'unzulässige Waehrung: 'Detail_Waehrung
end
end /* select */
call write_EDI_Segment 11,'MOA'
Konto_Nr=strip(V2.17,'L','0') /* ohne führende Nullen */
Name=strip(V2.30,'T',' ') /* ohne blanks */
Adr=strip(V2.31,'T',' ') /* adresse 1-zeilig*/
V2.16=right(V2.16,12,'0') /* fill with zeroes */
PLZ=Substr(V2.16,4,4) /* Postleitzahl (bei postbar) */
BLZ=Substr(V2.16,8,5) /* Bankleitzahl */
if opt_display then
call info 'Name:' Name 'Adr:' Adr 'BLZ:' BLZ 'Konto:' Konto_Nr
if Ueberweisung then do /* RFF + FII nur bei Ueberweisungen */
call init_EDI_Segment 11,'RFF'
call Set_EDI_Val 'C506.1153','PQ' /* Auftraggeber Referenz */
call Set_EDI_Val 'C506.1154',Referenz
call write_EDI_Segment 11,'RFF'
call init_EDI_Segment 12,'FII'
call Set_EDI_Val '3035','BF'
call Set_EDI_Val 'C078.3194',Konto_Nr /* Kontonummer Empfänger */
call Set_EDI_Val 'C078.3192.1',Name /* Name Emfaenger */
call Set_EDI_Val 'C078.3192.2',Adr /* Adresse Emfaenger */
call Set_EDI_Val 'C088.3433',BLZ /* BLZ */
call write_EDI_Segment 12,'FII'
end /* Ende ueberweisung */
if postbar then do
parse var Adr . ' ' Strasse /* vorne PLZ, weg damit */
Strasse=strip(Strasse) /* Straße nun ohne PLZ!!*/
/* NAD -Segment nur fuer POSTBAR-Anweisungen verwenden!!*/
/* strukturierte Form bevorzugt !!*/
/* ORT jetzt NICHT in unseren V2-Daten !!*/
call init_EDI_Segment 13,'NAD'
call Set_EDI_Val '3035','BE' /* Begünstigter */
call Set_EDI_Val 'C080.3036.1', Name
call Set_EDI_Val 'C059.3042.1', Strasse
call Set_EDI_Val '3251',PLZ
call write_EDI_Segment 13,'NAD'
end /* Ende postbar */
/* Segment-gruppe 14 wird nicht benötigt */
/* Segment-gruppe 15 wird nicht benötigt */
/* FTX bereits in SDegemtn-Gruppe 10, daher in Gruppe 16 nicht !!*/
/* Segmentgruppe 17 bis 23 wird nicht benötigt */
return
Verarbeitung_03: /* Text-Satz */
/* der textsatz enthaelt nur den Fixtext 'UEBERWEISUNG DONAULAND'*/
/* und wird daher nicht benoetigt */
return
Verarbeitung_99:
/* >>>>> check Kontrollsummen <<<<< */
if Kontroll_Summe_1 <> EDI_Kontroll_Summe_1 then do
call error '*** Kontroll-Summen Fehler ***'
call info 'Summe Detail-Betraege: 'Kontroll_Summe_1
call info 'Summe LIN_Abschnitte : 'EDI_Kontroll_Summe_1
end
else call info 'Kontroll-Summen ok!'
return
PAYMUL_footer:
call init_EDI_Segment 0,'CNT'
call Set_EDI_Val 'C270.6069','1'
call Set_EDI_Val 'C270.6066',EDI_Kontroll_Summe_1
call write_EDI_Segment 0,'CNT'
call init_EDI_Segment 0,'CNT'
call Set_EDI_Val 'C270.6069','2'
call Set_EDI_Val 'C270.6066',EDI_Kontroll_Summe_2
call write_EDI_Segment 0,'CNT'
call init_EDI_Segment 0,'CNT'
call Set_EDI_Val 'C270.6069','27'
call Set_EDI_Val 'C270.6066',EDI_Kontroll_Summe_3
call write_EDI_Segment 0,'CNT'
call init_EDI_segment 0,'UNT'
UNT_Counter=n_Segments+1 /* counter INCLUSIVE UNT-Segment!*/
call set_EDI_Val '0074',UNT_Counter
call set_EDI_Val '0062',EDI_Referenz
call write_EDI_Segment 0,'UNT'
return /* Ende PAYMUL-Footer */
display_POS_header:
call info ' '
call info ' Konto-Nr. .............:' Konto_Nr /* == V2.5 */
call info ' Konto-Auszug Nr........:' V2.23
call info ' Sammelauftrags-Referenz:' V2.3
call info ' Buchungs-Datum ........:' edate(Buchungs_Datum)
call info ' Valuta-Datum ..........:' edate(Valuta_Datum)
e_sum=EditDecimal(Summe_Line,14,2)
e_lin_no=right(LIN_no,5) /* 99999 is max value */
call info ' Position 'e_lin_no'.........:' e_sum Waehrung_Line
call info ' '
return
init_V2_fields:
parse arg RecType
select
when recType='00' then do /* Kopfsatz */
V2.='' /* blank als default */
V2.1='49' /* 49=Haben, 89=Soll */
V2.2A='000'
V2.2B='EUR' /* Waehrung auf Stelle 6-8 in V2 plus */
V2.2C=copies('0',8) /* lt. ORIGINAL = KontoKlasse */
V2.9=copies('0',11) /* NULL lt. V2-spec */
V2.12='00' /* Satzart 00 */
end
when RecType='01' then do /* Umsatzsatz 1 */
do ii=13 to 28
V2.ii=''
end
V2.13='40' /* Belegart */
V2.14='000' /* Nullfeld */
V2.20=copies(' ',7)
V2.24=2 /* Funktions-Schlüssel fix 2*/
V2.25=0 /* Formulartart fix 0 */
V2.28='01' /* Umsatzsatz 1*/
end
when RecType='02' then do /* Umsatzsatz 2 */
do ii=29 to 34
V2.ii=''
end
V2.29=V2.13
V2.30='' /* lt. Telefonat mit Fr. Machold, CA */
V2.32=' '
V2.34='02' /* Umsatzsatz 2 */
end
when RecType >= '03' & RecType <= '10' then do /* Textsatz */
do ii=35 to 39
V2.ii=''
end
V2.35=''
V2.36=''
V2.37=''
V2.38=''
V2.39=RecType /* Textsatz, Satzart 03 bis 10 */
end
when RecType='99' then do/* Summensatz */
do ii=40 to 53
V2.ii=''
end
V2.40 = V2.1 /* 49=Haben, 89=Soll */
V2.46 = 0 /* Anzahl der Umsaetze */
V2.51=copies('0',10)
V2.52 = 0 /* Feld 52 := Anzahl der Textzeilen */
V2.53='99' /* satzart 99 */
end
otherwise call abort 'unkown V2-rectype:' RecType 'in call init'
end /* select */
return
start_V2_file:
call open V2_file /* V2 is INPUT now, PAYMUL is output */
call init_V2_fields '00'
call init_V2_fields '01'
call init_V2_fields '02'
call init_V2_fields '03'
call init_V2_fields '99'
return
finish_V2_file:
call close V2_file
return
init_Kontroll_Summen:
Kontroll_Summe_1=0
Kontroll_Summe_2=0
Kontroll_Summe_3=0
n_Umsaetze=0
n_Text_Zeilen=0
Summe_ATS=0; Anzahl_ATS=0
Summe_EUR=0; AnzahL_EUR=0
BuchungsDatumVon=0
BuchungsDatumBis=0
EDI_Kontroll_Summe_1=0 /* pendants aus EDIFACT Datenstrom */
EDI_Kontroll_Summe_2=0
EDI_Kontroll_Summe_3=0
n_Summen_falsch=0 /* Zaehler falsche Kontroll-Summen */
n_pos=0 /* Zaehler Anzahl Positionen fuer display */
LIN_no=0;SEQ_no=0
Last_Type='';Last_Index=-1
erster_Vorsatz=1 /* Vorsatz ausgeben */
Anzahl_Umsaetze=0 /* Anzahl der Umsaetze */
return
display_Summen_Block:
call info ' '
e_anz=right(Anzahl_ATS,4)
e_betr=EditDecimal(Summe_ATS,14,2)
call info ' ATS-Summe: ' e_anz e_betr 'ATS'
e_anz=right(Anzahl_EUR,4)
e_betr=EditDecimal(Summe_EUR,14,2)
call info ' EUR-Summe: ' e_anz e_betr 'EUR'
call info ' '
e_anz=right(EDI_Kontroll_Summe_2,5)
e_betr=EditDecimal(EDI_Kontroll_Summe_1,14,2)
call info 'KONTROLL-Summe:' e_anz e_betr
return
dat628: procedure
arg yymmdd
return '20'yymmdd
datetime: procedure
date3=date('S')
time3=time('N') /* hh:mm:ss */
parse var time3 hh':'mm':'ss
hhmmss=hh!!mm!!ss
return date3!!hhmmss
/*********************************************************************/
/*%INCLUDE EDIFACT*/ /* EDIFACT parser & composer */
/*%INCLUDE in_V2*/ /* read V2 definitions into core */
/*%INCLUDE EDATE */ /* edited date */
/*%INCLUDE DECIMAL */ /* fixed point decimal routines */
/*%INCLUDE RexxFile */ /* File input / ouptut */
/*%INCLUDE STRFUN */ /* string functions */
/*%INCLUDE RexxMsg */ /* messaging routines*/