v2pay.nrx 29.11.2002 16:06:32
/*====================================================================*/
/* generated by the classic REXX to NetRexx converter */
/* (c) Thomas.Schneider@Donauland.at */
/*====================================================================*/
/* orig. REXX source: v2pay */
/* generated at: 2002-11-22 17:34:14 */
/* with: rex_nrx.nrx vs. 4.00 pre 21 */
/* Rexx2Nrx options: verbose1 nologo nolist nostats */
/* Vars Localized: NO */
/* IO-method used : 3 ( RexxFile Object oriented ) */
/*====================================================================*/
import Rexx2Nrx.Rexx2RT.RexxTime
import Rexx2Nrx.Rexx2RT.RexxFile
import Rexx2Nrx.Rexx2RT.RexxMsg
import Rexx2Nrx.Rexx2RT.strfun
import Rexx2Nrx.Rexx2RT.StrFunc
class v2pay uses RexxMsg, RexxFile
properties public static
/* ... Declare Global Exposed File-Descriptors */
FD_ffn = RexxFile Null
FD_fn = RexxFile Null
FD_V2_file = RexxFile Null
FD_data_file = RexxFile Null
FD_output_file = RexxFile Null
/* ... Declare Global File-Names */
ffn = Rexx ''
fn = Rexx ''
V2_file = Rexx ''
data_file = Rexx ''
output_file = Rexx ''
/* ... Declare Global Numbers */
count_V2 = int 0
return_status = int 4
LIN_no = int 0
level = Rexx 'B'
Seq_No = int 0
EDI_Kontroll_Summe_2 = int 0
EDI_Kontroll_Summe_3 = int 0
Anzahl_Umsaetze = int 0
Anzahl_ATS = int 0
Anzahl_EUR = int 0
UNT_Counter = int 0
n_Segments = int 0
Last_Index = int 0
line_no = int 0
linelen = int 0
nn = int 0
n_Segment_types = int 0
n_Groups = int 0
freq = int 0
ii_Segment = int 0
ii_Table = int 0
ii_Elem = int 0
stack_level = int 0
Group_No = int 0
ii_Seg = int 0
seg_no = int 0
nv = int 0
Current_Level = int 0
Current_Seq_No = int 0
Segment_No = int 0
n_Fields = int 0
FieldFreq = int 0
bufsize = int 0
nd = int 0
ij = int 0
nj = int 0
Current_Seq_End = int 0
Group_Level0 = int 0
pos1 = int 1
ic6 = int 0
nn_V2 = int 0
n_Record_Types = int 0
n_V2_in = int 0
n_V2_out = int 0
ii_V2 = int 0
ii_V2_Record = int 0
ii_V2_Field = int 0
ivv1 = int 1
ivv2 = int 0
ir = int 0
n_digs = int 0
idec1 = int 0
nint = int 0
/* ... Declare Global Decimals */
used = Rexx 0
Summe_ueberweis = Rexx 0
Summe_postbar = Rexx 0
Summe_Line = Rexx 0
/* ... Declare Global Strings */
pp_vers = Rexx '1.0'
processor = Rexx ''
fpath = Rexx 'J:\\BH\\EDIFACT\\PAYMUL\\'
fpath_v2 = Rexx ''
fpath_log = Rexx ''
fpath_data = Rexx ''
parms = Rexx ''
yyyymmdd = Rexx ''
yyyy = Rexx ''
mm = Rexx ''
yy = Rexx ''
input_file = Rexx ''
opts = Rexx ''
Konto_Nr_1 = Rexx ''
fx = Rexx ''
ft = Rexx 'V2'
log_file = Rexx ''
Referenz = Rexx ''
EDI_Referenz = Rexx ''
customer = Rexx 'DL'
time1 = Rexx ''
run_date = Rexx ''
V2_def = Rexx ''
paymul_def = Rexx ''
paymul_file = Rexx ''
has_data = Rexx 0
EOF = Rexx 0
V2_type0 = Rexx ''
opt_detail = Rexx 0
stars = Rexx ''
time2 = Rexx ''
elapsed = Rexx ''
ff_EDI = Rexx ''
ff_V2 = Rexx ''
ff_LOG = Rexx ''
Erstellungs_Datum = Rexx ''
dts = Rexx ''
e_erstellt_am = Rexx ''
Konto_Nr_DL = Rexx ''
BLZ_DL = Rexx ''
Valuta_Datum = Rexx ''
postbar = Rexx 1
AEK_Ref = Rexx ''
bank_operation = Rexx 'CPP'
EDI_Kontroll_Summe_1 = Rexx ''
V2_Summe = Rexx 0
Betrag = Rexx ''
Belegart = Rexx ''
ueberweisung = Rexx 1
opt_short = Rexx 0
Detail_Betrag = Rexx ''
Detail_Waehrung = Rexx 'EUR'
Kontroll_Summe_1 = Rexx ''
Summe_ATS = Rexx ''
Summe_EUR = Rexx ''
Konto_Nr = Rexx ''
Name = Rexx ''
Adr = Rexx ''
PLZ = Rexx ''
BLZ = Rexx ''
opt_display = Rexx 0
Strasse = Rexx ''
e_sum = Rexx ''
e_lin_no = Rexx ''
Kontroll_Summe_2 = Rexx 0
Kontroll_Summe_3 = Rexx 0
n_Umsaetze = Rexx 0
n_Text_Zeilen = Rexx 0
BuchungsDatumVon = Rexx 0
BuchungsDatumBis = Rexx 0
n_Summen_falsch = Rexx 0
n_pos = Rexx 0
Last_Type = Rexx ''
erster_Vorsatz = Rexx 1
e_anz = Rexx ''
e_betr = Rexx ''
line = Rexx ''
escape_char = Rexx '?'
Field_delim = Rexx ':'
Data_delim = Rexx '+'
Segment_delim = Rexx "'"
editypes = Rexx 'S D F T E C R LV SG *'
editypes1 = Rexx 'S D F T E C'
editables = Rexx ''
trace_defs = Rexx 0
opt_CRLF = Rexx 1
type = Rexx ''
ii_Field = Rexx 0
ii_Data = Rexx 0
ii_Cond = Rexx 0
edi_tables = Rexx ''
ii_Code = Rexx ''
list = Rexx ''
seg1 = Rexx ''
debug = Rexx 0
opt_verbose = Rexx 0
opt_all = Rexx 0
opt_trace = Rexx 0
opt_group = Rexx 0
opt_show = Rexx 0
Current_Group_No = Rexx ''
Current_List = Rexx ''
Segment = Rexx ''
seg_tag = Rexx ''
head = Rexx ''
seg_data = Rexx ''
tail = Rexx ''
seg_type = Rexx ''
seg_tag_data = Rexx ''
SegmentId = Rexx ''
SegmentName = Rexx ''
DataList = Rexx ''
iv1 = Rexx 1
DataId = Rexx ''
DataName = Rexx ''
Data0 = Rexx ''
FieldList = Rexx ''
FieldId = Rexx ''
FieldName = Rexx ''
FieldVal = Rexx ''
buffer = Rexx ''
time11 = Rexx ''
trace_Segments = Rexx 0
used_Segments = Rexx ''
flag1 = Rexx 0
time12 = Rexx ''
e_elapsed = Rexx ''
Segment_type = Rexx ''
Segment_Data = Rexx ''
etc = Rexx ''
dx = Rexx ''
codes = Rexx ''
found = Rexx 0
list2 = Rexx ''
iic = Rexx ''
group_list0 = Rexx ''
Segment_Group = Rexx ''
expected_Segment = Rexx ''
c1 = Rexx ''
header = Rexx ' ## LV GRP SEG IND DATA FIELD VALUE'
no = Rexx ''
lev = Rexx ''
grp = Rexx ''
seg = Rexx ''
ind = Rexx ''
dat = Rexx ''
fld = Rexx ''
val = Rexx ''
Data_Id = Rexx ''
Field_Id0 = Rexx ''
index1 = Rexx 1
vv = Rexx ''
seg_members = Rexx ''
Current_Group = Rexx ''
Current_SegType = Rexx ''
cur_type = Rexx ''
field_list = Rexx ''
field_data0 = Rexx ''
jj_field = Rexx ''
subscript = Rexx ''
data1 = Rexx ''
array_script = Rexx ''
arr_data = Rexx ''
form6 = Rexx ''
length6 = Rexx ''
max_length6 = Rexx ''
Var_length6 = Rexx 'V'
V2_types = Rexx 'RT F C *'
ii_V2_Code = Rexx ''
e_id = Rexx ''
e_name = Rexx ''
e_form = Rexx ''
e_val = Rexx ''
rec_data = Rexx ''
a_type = Rexx ''
a_id = Rexx ''
a_name = Rexx ''
a_form = Rexx ''
a_val = Rexx ''
a_class = Rexx ''
a_len = Rexx ''
a_dec = Rexx 0
V2_rec = Rexx ''
V2_rec_type = Rexx ''
a_loc = Rexx 1
n_dec = Rexx ''
f_int = Rexx ''
f_dec = Rexx ''
f_val = Rexx ''
num_val = Rexx ''
numericv = Rexx ''
numeric0 = Rexx ''
decv = Rexx ''
intv = Rexx ''
editv = Rexx ''
/* ... Declare Global Stems / Arrays */
V2 = Rexx '' /*Stem!*/
edi_type = Rexx '' /*Stem!*/
edi_id = Rexx '' /*Stem!*/
edi_name = Rexx '' /*Stem!*/
edi_req = Rexx '' /*Stem!*/
edi_freq = Rexx 0 /*Stem!*/
edi_members = Rexx '' /*Stem!*/
edi_codes = Rexx '' /*Stem!*/
edi_Segment = Rexx 0 /*Stem!*/
edi_Groups = Rexx '' /*Stem!*/
Group_List = Rexx '' /*Stem!*/
Group_Level = Rexx 0 /*Stem!*/
Group_Nest = Rexx 0 /*Stem!*/
edi_form = Rexx '' /*Stem!*/
edi_note = Rexx '' /*Stem!*/
seg_Def = Rexx 0 /*Stem!*/
Field_Level = Rexx 0 /*Stem!*/
Field_Group = Rexx 0 /*Stem!*/
Field_Segment_No = Rexx 0 /*Stem!*/
Field_Data = Rexx 0 /*Stem!*/
Field_No = Rexx 0 /*Stem!*/
Field_Value = Rexx '' /*Stem!*/
data = Rexx '' /*Stem!*/
Field_val = Rexx '' /*Stem!*/
Field_id = Rexx '' /*Stem!*/
Field_ix = Rexx 0 /*Stem!*/
Segment_Stem = Rexx '' /*Stem!*/
V2_type = Rexx '' /*Stem!*/
V2_id = Rexx '' /*Stem!*/
V2_name = Rexx '' /*Stem!*/
V2_req = Rexx '' /*Stem!*/
V2_freq = Rexx 1 /*Stem!*/
V2_field1 = Rexx 0 /*Stem!*/
V2_field2 = Rexx 0 /*Stem!*/
V2_codes = Rexx '' /*Stem!*/
V2_RT = Rexx 0 /*Stem!*/
V2_Record = Rexx 0 /*Stem!*/
V2_form = Rexx '' /*Stem!*/
V2_note = Rexx '' /*Stem!*/
/* ... Declare Global other Variables */
fm = Rexx ''
LogFile = Rexx 'INFO_FILE'
n_errors = int 0
n_warnings = Rexx 'N_WARNINGS'
Buchungs_Datum = Rexx 'BUCHUNGS_DATUM'
Waehrung_Line = Rexx 'WAEHRUNG_LINE'
$2A = Rexx ''
$2B = Rexx ''
$2C = Rexx ''
ii = int 0
id = Rexx 0
req = Rexx ''
form = Rexx ''
note = Rexx ''
iw = int 0
iv = int 0
jj = int 0
kk = int 0
ifreq = int 0
ix = int 0
jjc = int 0
il = int 0
iz = int 0
iy = Rexx 0
definition_file = Rexx 'DEFINITION_FILE'
iws = int 0
jf = int 0
ia = int 0
letters = Rexx 'LETTERS'
ivv = int 0
method main(args=String[]) static
arg=Rexx(args) -- program arguments as single string
arg=arg -- avoid NetRexx warning
pp_vers = '1.0'
parse source processor .
if processor = 'Java' then do
fpath = 'J:\\BH\\EDIFACT\\PAYMUL\\'
fpath_v2 = fpath||'v2\\'
fpath_log = fpath||'log\\'
fpath_data = fpath||'data\\'
end
else do
fpath = 'B1'
fpath_v2 = 'B1'
fpath_data = 'B1'
fpath_log = 'B1'
end /*if*/
parse arg parms
if parms = '' then do
yyyymmdd = RexxTime.date('S')
yyyy = yyyymmdd.substr(1,4)
mm = yyyymmdd.substr(5,2)
mm = (mm - 1).right(2,'0')
if mm = 00 then do
yyyy = yyyy - 1
mm = 12
end /*if*/
yy = yyyy.substr(3,2)
ffn = 'LOHN' || yy || mm
FD_ffn = RexxFile.FD(ffn)
input_file = RexxFile.fileid(ffn,'v2',fpath_v2)
if RexxFile.exists(input_file) = 0 then do
RexxMsg.abort('Eingabe-Datei: '||input_file -
'noch nicht vorhanden!')
end
else do
say 'Eingabe von Datei:' input_file
end /*if*/
opts = ''
end
else do
parse parms input_file '(' opts ')'
end /*if*/
Konto_Nr_1 = ''
fx = RexxFile.parsefid(input_file)
parse fx fn ft fm
ffn = fn
FD_ffn = RexxFile.FD(ffn)
RexxMsg.init_info(fn,'NEW')
log_file = LogFile
yy = fn.substr(5,2)
yyyy = '20'||yy
mm = fn.substr(7,2)
Referenz = 'Provision '||yyyy||'/'||mm
EDI_Referenz = 'PROV'||yyyy || mm
if ft = '' then do
ft = 'V2'
input_file = RexxFile.fileid(fn,ft,fm)
end /*if*/
if ft <> 'V2' then do
RexxMsg.abort('Eingabedatei muß Datei-Typ "V2" haben!')
end /*if*/
customer = 'DL'
numeric digits 15
time1 = RexxTime.time('R')
run_date = RexxTime.edate()
RexxMsg.info2('V2PAY: V2 --> PAYMUL Konversion vs.'||pp_vers ':' -
run_date)
V2_def = RexxFile.fileid('V2','DEF')
in_V2_definition(V2_def)
paymul_def = RexxFile.fileid('PAYMUL','DEF')
paymul_file = RexxFile.fileid(fn,'PAYMUL',fpath_data)
RexxMsg.info(' ')
RexxMsg.info('Eingabe-Datei (V2-Format) ....: '||input_file)
RexxMsg.info('Ausgabe_Datei (PAYMUL-Fonmat) :' paymul_file)
RexxMsg.info('LOG-File .....................:' log_file)
init_Kontroll_Summen()
start_EDI_composer(paymul_file,paymul_def,opts)
V2_file = input_file
FD_V2_file = RexxFile.FD(V2_file)
V2_Summen_bilden()
start_V2_file()
has_data = 0
EOF = 0
count_V2 = 0
loop forever
V2_type0 = in_V2()
if V2_type0 = '' then do
leave
end /*if*/
if EOF then do
leave
end /*if*/
has_data = 1
if opt_detail then do
display_V2(V2_type0)
end /*if*/
count_V2 = count_V2 + 1
select
when V2_type0 = '00' then do
Verarbeitung_00()
end /*when*/
when V2_type0 = '01' then do
Verarbeitung_01()
end /*when*/
when V2_type0 = '02' then do
Verarbeitung_02()
end /*when*/
when (V2_type0 >= '03') & (V2_type0 <= '09') then do
Verarbeitung_03()
end /*when*/
when V2_type0 = '99' then do
Verarbeitung_99()
leave
end /*when*/
otherwise do
RexxMsg.abort('unzulaessige Satzart: '||V2_type0)
end /* otherwise */
end /* select */
end /* loop */
PAYMUL_footer()
finish_EDI_composer()
finish_V2_file()
if has_data = 0 then do
RexxMsg.info('*'.copies(60))
RexxMsg.info('Eingabe-Datei:' input_file 'ist leer!!')
RexxMsg.info('keine Verarbeitung moeglich!')
RexxMsg.info('*'.copies(60))
pause()
exit 81
end /*if*/
display_Summen_Block()
if n_errors > 0 then do
stars = '*'.copies(80)
RexxMsg.info(stars)
RexxMsg.info0(n_errors 'Fehler festgestellt')
RexxMsg.info(stars)
if return_status = 0 then do
return_status = 4
end /*if*/
end /*if*/
RexxMsg.info('Anzahl verwendete LINE-Segmente:' LIN_no)
time2 = RexxTime.time('E')
used = time2 - time1
elapsed = used.format(null,3)
RexxMsg.info('V2 to EDIFACT PAYMUL Konversionng benoetigte' -
elapsed 'Sekunden.')
RexxMsg.info0(n_warnings 'Warnungen')
RexxMsg.info0(n_errors 'Fehler')
return_status = 0
if customer = 'DL' then do
ff_EDI = RexxFile.fileid(ffn,'PAYMUL',fpath_data)
ff_V2 = RexxFile.fileid(ffn,'V2',fpath_v2)
ff_LOG = RexxFile.fileid(ffn,'LOG',fpath_log)
RexxMsg.info(' ')
RexxMsg.info('Gesicherte V2-Datei ...:' ff_V2)
RexxMsg.info('Gesicherte PAYMUL Datei:' ff_EDI)
RexxMsg.info('Gesicherte LOG-Datei :' ff_LOG)
RexxMsg.info(' ')
pause(' Bitte irgendeine Taste druecken!')
parse source processor .
if processor <> 'CMS' then do
if paymul_file <> ff_EDI then do
RexxFile.copyfile(paymul_file,ff_EDI,0)
end /*if*/
RexxMsg.closelog()
if log_file <> ff_LOG then do
RexxFile.copyfile(log_file,ff_LOG,0)
end /*if*/
end
else do
RexxMsg.closelog()
end /*if*/
end /*if*/
exit return_status
method PAYMUL_header() static public ;
init_EDI_Segment(0,'UNH')
Set_EDI_Val('0062',EDI_Referenz)
Set_EDI_Val('S009.0065','PAYMUL')
Set_EDI_Val('S009.0052','D')
Set_EDI_Val('S009.0054','96A')
Set_EDI_Val('S009.0051','UN')
write_EDI_Segment(0,'UNH')
init_EDI_Segment(0,'BGM')
Set_EDI_Val('C002.1001','452')
Set_EDI_Val('1004',EDI_Referenz)
write_EDI_Segment(0,'BGM')
init_EDI_Segment(0,'DTM')
Set_EDI_Val('C507.2005','137')
Erstellungs_Datum = RexxTime.date('S')
dts = datetime()
Set_EDI_Val('C507.2380',dts)
e_erstellt_am = RexxTime.edate(Erstellungs_Datum)
RexxMsg.info('Erstellungsdatum:' e_erstellt_am)
Set_EDI_Val('C507.2379','204')
write_EDI_Segment(0,'DTM')
Konto_Nr_DL = V2[9]
BLZ_DL = V2[4]
RexxMsg.info('BLZ:' BLZ_DL 'Konto-Nr.:' Konto_Nr_DL)
init_EDI_Segment(2,'FII')
Set_EDI_Val('3035','MR')
Set_EDI_Val('C078.3194',Konto_Nr_DL)
Set_EDI_Val('C078.3192.1',V2[10])
Set_EDI_Val('C088.3433',BLZ_DL)
RexxMsg.info2('Bank-Band von:' V2[10] 'erstellt am:' e_erstellt_am)
write_EDI_Segment(2,'FII')
init_EDI_Segment(3,'NAD')
Set_EDI_Val('3035','MS')
Set_EDI_Val('C080.3036.1','Buchgemeinschaft Donauland')
Set_EDI_Val('C059.3042.1','Niederhofstr. 37')
Set_EDI_Val('3154','Wien')
Set_EDI_Val('3251','1201')
write_EDI_Segment(3,'NAD')
init_EDI_Segment(3,'CTA')
Set_EDI_Val('3139','MS')
Set_EDI_Val('C056.3413','EDV Donauland')
Set_EDI_Val('C056.3412','Thomas Schneider')
write_EDI_Segment(3,'CTA')
init_EDI_Segment(3,'COM')
Set_EDI_Val('C076.3148','Thomas.Schneider@Donauland.at')
Set_EDI_Val('C076.3155','EM')
write_EDI_Segment(3,'COM')
init_EDI_Segment(3,'COM')
Set_EDI_Val('C076.3148','81102/638')
Set_EDI_Val('C076.3155','TE')
write_EDI_Segment(3,'COM')
return
method Verarbeitung_00() static public ;
if count_V2 = 1 then do
PAYMUL_header()
end /*if*/
return
method Neues_LINE_Segment() static public ;
LIN_no = LIN_no + 1
select
when LIN_no = 1 then do
RexxMsg.info('Ueberweisungen: '||Summe_ueberweis)
end /*when*/
when LIN_no = 2 then do
RexxMsg.info('Post Bar-Ueberweisungen:' Summe_postbar)
end /*when*/
otherwise do
RexxMsg.abort('maximal 2 LINE-Segmente erlaubt!')
end /* otherwise */
end /* select */
init_EDI_Segment(4,'LIN')
level = Rexx 'B'
Seq_No = 0
Set_EDI_Val('1082',LIN_no)
EDI_Kontroll_Summe_2 = EDI_Kontroll_Summe_2 + 1
write_EDI_Segment(4,'LIN')
init_EDI_Segment(4,'DTM')
Set_EDI_Val('C507.2005','203')
Valuta_Datum = RexxTime.date('S')
Set_EDI_Val('C507.2380',Valuta_Datum)
Set_EDI_Val('C507.2379','102')
write_EDI_Segment(4,'DTM')
init_EDI_Segment(4,'RFF')
Set_EDI_Val('C506.1153','AEK')
if postbar then do
AEK_Ref = 'Post '||yyyy||'/'||mm
end
else do
AEK_Ref = 'Ueberw.' yyyy||'/'||mm
end /*if*/
Set_EDI_Val('C506.1154',AEK_Ref)
write_EDI_Segment(4,'RFF')
init_EDI_Segment(4,'BUS')
Set_EDI_Val('C521.4027','1')
Set_EDI_Val('C521.4025','COM')
Set_EDI_Val('3279','DO')
Set_EDI_Val('4487','1')
if postbar then do
bank_operation = 'CPP'
end
else do
bank_operation = 'TRF'
end /*if*/
Set_EDI_Val('C551.4383',bank_operation)
write_EDI_Segment(4,'BUS')
init_EDI_Segment(5,'MOA')
Set_EDI_Val('C516.5025','9')
select
when LIN_no = 1 then do
Summe_Line = Summe_ueberweis
end /*when*/
when LIN_no = 2 then do
Summe_Line = Summe_postbar
end /*when*/
otherwise do
RexxMsg.abort('Sortierfehler, EDV-verstaendigen')
end /* otherwise */
end /* select */
Set_EDI_Val('C516.5004',Summe_Line)
Set_EDI_Val('C516.6345','EUR')
write_EDI_Segment(5,'MOA')
EDI_Kontroll_Summe_1 = EDI_Kontroll_Summe_1 + Summe_Line
init_EDI_Segment(6,'FII')
Set_EDI_Val('3035','OR')
Set_EDI_Val('C078.3194',Konto_Nr_DL)
Set_EDI_Val('C078.3192.1','Buchgemeinschaft Donauland')
Set_EDI_Val('C078.6345','EUR')
Set_EDI_Val('C088.3433',BLZ_DL)
write_EDI_Segment(6,'FII')
init_EDI_Segment(10,'PRC')
Set_EDI_Val('C242.7187','11')
write_EDI_Segment(10,'PRC')
init_EDI_Segment(10,'FTX')
Set_EDI_Val('4451','PMD')
Set_EDI_Val('C108.4440.1','Ueberweisung Donauland')
Set_EDI_Val('C108.4440.2',Referenz)
write_EDI_Segment(10,'FTX')
return
method V2_Summen_bilden() static public ;
V2_Summe = 0
Summe_ueberweis = 0
Summe_postbar = 0
FD_V2_file.open()
loop forever
V2_type0 = in_V2()
if V2_type0 = '' then do
leave
end /*if*/
if V2_type0 = '01' then do
Betrag = V2[15]
V2_Summe = V2_Summe + Betrag
Belegart = V2[13]
select
when Belegart = 43 then do
Summe_ueberweis = Summe_ueberweis + Betrag
end /*when*/
when Belegart = 15 then do
Summe_postbar = Summe_postbar + Betrag
end /*when*/
otherwise do
do
RexxMsg.error('unzulässige Belegart:' Belegart -
'in SA 01')
RexxMsg.abort('Verarbeitung nicht moeglich')
end
end /* otherwise */
end /* select */
end /*if*/
if V2_type0 = '99' then do
leave
end /*if*/
end /* loop */
RexxMsg.info(' ')
RexxMsg.info('Summe Ueberweisungen .... :' fix(Summe_ueberweis))
RexxMsg.info('Summe Post-Bar ...........:' fix(Summe_postbar))
RexxMsg.info(' -------------')
RexxMsg.info('Gesamt-Summe .............:' fix(V2_Summe))
RexxMsg.info(' =============')
RexxMsg.info(' ')
if (Summe_postbar + Summe_ueberweis) <> V2_Summe then do
RexxMsg.abort('*** fataler Summen-Fehler, EDV verständigen ***')
end /*if*/
FD_V2_file.close()
return
method fix(amount = Rexx '') static public returns Rexx;
return amount.format(11,2)
method Verarbeitung_01() static public ;
Belegart = V2[13]
if Belegart = 43 then do
ueberweisung = 1
end
else do
ueberweisung = 0
end /*if*/
if Belegart = 15 then do
postbar = 1
end
else do
postbar = 0
end /*if*/
if (ueberweisung = 0) & (postbar = 0) then do
RexxMsg.abort('*** unzulaessige Belegart:' Belegart '***')
end /*if*/
if LIN_no = 0 then do
Neues_LINE_Segment()
end /*if*/
if (LIN_no = 1) & (Belegart = 15) then do
Neues_LINE_Segment()
end /*if*/
return
method Verarbeitung_02() static public ;
init_EDI_Segment(11,'SEQ')
Seq_No = Seq_No + 1
EDI_Kontroll_Summe_3 = EDI_Kontroll_Summe_3 + 1
Set_EDI_Val('C286.1050',Seq_No)
if opt_short then do
RexxMsg.info(' SEQ No:' Seq_No)
end /*if*/
Set_EDI_Val('C286.1159',V2[13])
Set_EDI_Val('C286.1131','EBA')
Set_EDI_Val('C286.3055','137')
write_EDI_Segment(11,'SEQ')
init_EDI_Segment(11,'MOA')
Set_EDI_Val('C516.5025','9')
Detail_Betrag = V2[15]
Set_EDI_Val('C516.5004',Detail_Betrag)
Detail_Waehrung = 'EUR'
Set_EDI_Val('C516.6345',Detail_Waehrung)
Kontroll_Summe_1 = Kontroll_Summe_1 + Detail_Betrag
Anzahl_Umsaetze = Anzahl_Umsaetze + 1
select
when Detail_Waehrung = 'ATS' then do
Anzahl_ATS = Anzahl_ATS + 1
Summe_ATS = Summe_ATS + Detail_Betrag
end /*when*/
when Detail_Waehrung = 'EUR' then do
Anzahl_EUR = Anzahl_EUR + 1
Summe_EUR = Summe_EUR + Detail_Betrag
end /*when*/
otherwise do
do
RexxMsg.error('unzulässige Waehrung: '||Detail_Waehrung)
end
end /* otherwise */
end /* select */
write_EDI_Segment(11,'MOA')
Konto_Nr = V2[17].strip('L','0')
Name = V2[30].strip('T',' ')
Adr = V2[31].strip('T',' ')
V2[16] = V2[16].right(12,'0')
PLZ = V2[16].substr(4,4)
BLZ = V2[16].substr(8,5)
if opt_display then do
RexxMsg.info('Name:' Name 'Adr:' Adr 'BLZ:' BLZ 'Konto:' Konto_Nr)
end /*if*/
if ueberweisung then do
init_EDI_Segment(11,'RFF')
Set_EDI_Val('C506.1153','PQ')
Set_EDI_Val('C506.1154',Referenz)
write_EDI_Segment(11,'RFF')
init_EDI_Segment(12,'FII')
Set_EDI_Val('3035','BF')
Set_EDI_Val('C078.3194',Konto_Nr)
Set_EDI_Val('C078.3192.1',Name)
Set_EDI_Val('C078.3192.2',Adr)
Set_EDI_Val('C088.3433',BLZ)
write_EDI_Segment(12,'FII')
end /*if*/
if postbar then do
parse Adr . ' ' Strasse
Strasse = Strasse.strip()
init_EDI_Segment(13,'NAD')
Set_EDI_Val('3035','BE')
Set_EDI_Val('C080.3036.1',Name)
Set_EDI_Val('C059.3042.1',Strasse)
Set_EDI_Val('3251',PLZ)
write_EDI_Segment(13,'NAD')
end /*if*/
return
method Verarbeitung_03() static public ;
return
method Verarbeitung_99() static public ;
if Kontroll_Summe_1 <> EDI_Kontroll_Summe_1 then do
RexxMsg.error('*** Kontroll-Summen Fehler ***')
RexxMsg.info('Summe Detail-Betraege: '||Kontroll_Summe_1)
RexxMsg.info('Summe LIN_Abschnitte : '||EDI_Kontroll_Summe_1)
end
else do
RexxMsg.info('Kontroll-Summen ok!')
end /*if*/
return
method PAYMUL_footer() static public ;
init_EDI_Segment(0,'CNT')
Set_EDI_Val('C270.6069','1')
Set_EDI_Val('C270.6066',EDI_Kontroll_Summe_1)
write_EDI_Segment(0,'CNT')
init_EDI_Segment(0,'CNT')
Set_EDI_Val('C270.6069','2')
Set_EDI_Val('C270.6066',EDI_Kontroll_Summe_2)
write_EDI_Segment(0,'CNT')
init_EDI_Segment(0,'CNT')
Set_EDI_Val('C270.6069','27')
Set_EDI_Val('C270.6066',EDI_Kontroll_Summe_3)
write_EDI_Segment(0,'CNT')
init_EDI_Segment(0,'UNT')
UNT_Counter = n_Segments + 1
Set_EDI_Val('0074',UNT_Counter)
Set_EDI_Val('0062',EDI_Referenz)
write_EDI_Segment(0,'UNT')
return
method display_POS_header() static public ;
RexxMsg.info(' ')
RexxMsg.info(' Konto-Nr. .............:' Konto_Nr)
RexxMsg.info(' Konto-Auszug Nr........:' V2[23])
RexxMsg.info(' Sammelauftrags-Referenz:' V2[3])
RexxMsg.info(' Buchungs-Datum ........:' RexxTime.edate(-
Buchungs_Datum))
RexxMsg.info(' Valuta-Datum ..........:' RexxTime.edate(-
Valuta_Datum))
e_sum = EditDecimal(Summe_Line,14,2)
e_lin_no = Rexx(LIN_no).right(5)
RexxMsg.info(' Position '||e_lin_no||'.........:' e_sum -
Waehrung_Line)
RexxMsg.info(' ')
return
method init_V2_fields(RecType = Rexx '') static public ;
select
when RecType = '00' then do
V2 = ''
V2[1] = '49'
V2[$2A] = '000'
V2[$2B] = 'EUR'
V2[$2C] = '0'.copies(8)
V2[9] = '0'.copies(11)
V2[12] = '00'
end /*when*/
when RecType = '01' then do
loop ii = 13 to 28
V2[ii] = ''
end /* loop ii */
V2[13] = '40'
V2[14] = '000'
V2[20] = ' '.copies(7)
V2[24] = 2
V2[25] = 0
V2[28] = '01'
end /*when*/
when RecType = '02' then do
loop ii = 29 to 34
V2[ii] = ''
end /* loop ii */
V2[29] = V2[13]
V2[30] = ''
V2[32] = ' '
V2[34] = '02'
end /*when*/
when (RecType >= '03') & (RecType <= '10') then do
loop ii = 35 to 39
V2[ii] = ''
end /* loop ii */
V2[35] = ''
V2[36] = ''
V2[37] = ''
V2[38] = ''
V2[39] = RecType
end /*when*/
when RecType = '99' then do
loop ii = 40 to 53
V2[ii] = ''
end /* loop ii */
V2[40] = V2[1]
V2[46] = 0
V2[51] = '0'.copies(10)
V2[52] = 0
V2[53] = '99'
end /*when*/
otherwise do
RexxMsg.abort('unkown V2-rectype:' RecType 'in call init')
end /* otherwise */
end /* select */
return
method start_V2_file() static public ;
FD_V2_file.open()
init_V2_fields('00')
init_V2_fields('01')
init_V2_fields('02')
init_V2_fields('03')
init_V2_fields('99')
return
method finish_V2_file() static public ;
FD_V2_file.close()
return
method init_Kontroll_Summen() static public ;
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
EDI_Kontroll_Summe_2 = 0
EDI_Kontroll_Summe_3 = 0
n_Summen_falsch = 0
n_pos = 0
LIN_no = 0
Seq_No = 0
Last_Type = ''
Last_Index = - 1
erster_Vorsatz = 1
Anzahl_Umsaetze = 0
return
method display_Summen_Block() static public ;
RexxMsg.info(' ')
e_anz = Rexx(Anzahl_ATS).right(4)
e_betr = EditDecimal(Summe_ATS,14,2)
RexxMsg.info(' ATS-Summe: ' e_anz e_betr 'ATS')
e_anz = Rexx(Anzahl_EUR).right(4)
e_betr = EditDecimal(Summe_EUR,14,2)
RexxMsg.info(' EUR-Summe: ' e_anz e_betr 'EUR')
RexxMsg.info(' ')
e_anz = Rexx(EDI_Kontroll_Summe_2).right(5)
e_betr = EditDecimal(EDI_Kontroll_Summe_1,14,2)
RexxMsg.info('KONTROLL-Summe:' e_anz e_betr)
return
method dat628(yymmdd = Rexx '') static public returns Rexx;
/* ... Rexx Procedure (nothing exposed) */
yymmdd=yymmdd.upper()
return '20'||yymmdd
method datetime() static public returns Rexx;
/* ... Declare Local REXX variables: */
date3 = Rexx ''
time3 = Rexx ''
hh = Rexx ''
mm0 = Rexx ''
ss = Rexx ''
hhmmss = Rexx ''
/* ... End of local REXX variable declarations */
/* ... Rexx Procedure (nothing exposed) */
date3 = RexxTime.date('S')
time3 = RexxTime.time('N')
parse time3 hh ':' mm0 ':' ss
hhmmss = hh || mm0 || ss
return date3 || hhmmss
method in_EDI_definition(def = Rexx '') static public ;
FD_def = RexxFile.FD(def)
FD_def.open()
line_no = 0
loop while FD_def.lines() > 0
line = FD_def.linein().strip()
line_no = line_no + 1
if strfun.char1(line,1) = '*' then do
iterate
end /*if*/
if line = '' then do
iterate
end /*if*/
loop while strfun.lastchar(line) = '-'
linelen = line.length()
line = line.substr(1,linelen - 1) || FD_def.linein().strip()
line_no = line_no + 1
end /* loop */
linelen = line.length()
parse_EDI_definition_line()
end /* loop */
FD_def.close()
if n_errors > 0 then do
RexxMsg.info0(n_errors 'errors in EDIFACT definition:' def)
RexxMsg.info('please correct errors and try again!')
exit 98
end /*if*/
return
method init_EDI() static public ;
escape_char = '?'
Field_delim = ':'
Data_delim = '+'
Segment_delim = "'"
edi_type = ''
edi_id = ''
edi_name = ''
edi_req = ''
edi_freq = 0
edi_members = ''
edi_codes = ''
editypes = 'S D F T E C R LV SG *'
editypes1 = 'S D F T E C'
editables = ''
edi_Segment = 0
edi_Groups = ''
nn = 0
n_Segment_types = 0
level = 0
n_Groups = 0
Group_List = ''
Group_Level = 0
Group_Nest = 0
trace_defs = 0
parse source processor .
opt_CRLF = 1
return
method parse_EDI_definition_line() static public ;
parse line type ':' id ':' Name ':' req ':' form ':' note
if type = 'R' then do
if ii <> ii_Field then do
RexxMsg.error('invalid position of Repetion record,' -
'Repetition ignored')
return
end /*if*/
parse line . ':' freq ':' .
edi_freq[ii_Field] = freq
return
end /*if*/
freq = 0
if editypes1.wordpos(type) > 0 then do
nn = nn + 1
ii = nn
edi_type[ii] = type
edi_id[ii] = id
edi_name[ii] = Name
edi_form[ii] = form
edi_req[ii] = req
edi_freq[ii] = freq
edi_note[ii] = note
end /*if*/
if editypes.wordpos(type) = 0 then do
RexxMsg.error('illegal line-type:' type 'expected:' editypes)
return
end /*if*/
select
when type = 'S' then do
if lookup(id) <> 0 then do
RexxMsg.warning('Duplicate defined Segment:' id)
end /*if*/
edi_Segment[id] = ii
ii_Segment = ii
ii_Data = 0
ii_Field = 0
ii_Table = 0
ii_Elem = 0
ii_Cond = 0
n_Segment_types = n_Segment_types + 1
end /*when*/
when type = 'D' then do
ii_Data = ii
if ii_Segment = 0 then do
RexxMsg.error('Segment definition missing, line ignored')
end /*if*/
edi_members[ii_Segment] = edi_members[ii_Segment]||' '||ii_Data
ii_Field = ii_Data
ii_Table = 0
ii_Elem = 0
ii_Cond = 0
end /*when*/
when type = 'F' then do
ii_Field = ii
if ii_Data = 0 then do
RexxMsg.error('parent Data definition missing, line'-
'ignored')
return
end /*if*/
edi_members[ii_Data] = edi_members[ii_Data]||' '||ii_Field
end /*when*/
when type = 'T' then do
ii_Table = ii
edi_tables = edi_tables||' '||ii_Table
end /*when*/
when type = 'E' then do
ii_Elem = ii
edi_members[ii_Table] = edi_members[ii_Table]||' '||ii_Elem
end /*when*/
when type = 'C' then do
if ii_Field = 0 then do
ii_Field = ii_Data
end /*if*/
ii_Code = ii
edi_codes[ii_Field] = edi_codes[ii_Field]||' '||ii
end /*when*/
when type = 'LV' then do
level = id.toint()
stack_level = level
if trace_defs then do
RexxMsg.info('')
RexxMsg.infos('Level' level||':')
RexxMsg.infos('========')
end /*if*/
end /*when*/
when type = 'SG' then do
Group_No = id.toint()
list = Name
if trace_defs then do
RexxMsg.infos('Segment Group:' Group_No '=' list)
end /*if*/
n_Groups = Rexx(Group_No).max(n_Groups)
Group_List[n_Groups] = list
Group_Level[n_Groups] = level
loop iw = 1 to list.words()
seg1 = list.word(iw)
ii_Seg = edi_Segment[seg1].toint()
if ii_Seg = 0 then do
RexxMsg.warning('Segment:' seg1 'of Segment-Group:' -
Group_No 'Level:' level 'not defined!')
end /*if*/
edi_Groups[seg1] = (edi_Groups[seg1]||' '||Group_No).strip()
end /* loop iw */
end /*when*/
otherwise do
do
RexxMsg.error('invalid type: '||type 'ignored')
end
end /* otherwise */
end /* select */
return
method lookup(id1 = Rexx '') static public returns int;
id1=id1.upper()
return edi_Segment[id1]
method init_EDI_properties() static public ;
parse source processor .
seg_no = 0
seg_Def = 0
Field_Level = 0
Field_Group = 0
Field_Segment_No = 0
Field_Data = 0
Field_No = 0
Field_Value = ''
iv = 0
nv = 0
nv = 0
debug = 0
opt_short = 0
opt_verbose = 0
opt_all = 0
opt_trace = 0
opt_group = 0
opt_display = 0
opt_detail = 0
opt_show = 0
Current_Group_No = - 1
Current_Level = 0
Current_List = ''
Current_Seq_No = 0
return
method parse_EDI_Segment() static public ;
seg_no = seg_no + 1
Segment_No = seg_no
split(Segment,Data_delim)
seg_tag = head
seg_data = tail
split(seg_tag,Field_delim)
seg_type = head
seg_tag_data = tail
ii_Segment = lookup(seg_type)
if ii_Segment = 0 then do
RexxMsg.error('unknown Segment type:' seg_type 'ignored')
return
end /*if*/
if seg_tag_data <> '' then do
RexxMsg.error('Segment tag data:'||seg_tag_data -
'currently ignored!')
end /*if*/
SegmentId = edi_id[ii_Segment]
SegmentName = edi_name[ii_Segment]
if opt_short | opt_all then do
RexxMsg.info(' ')
RexxMsg.info('Segment: '||SegmentId SegmentName||':')
RexxMsg.info(' (#'||seg_no||'::'||Segment||')')
end
else if opt_trace then do
RexxMsg.info('#'||seg_no||'::'||Segment)
end /*if*/
fetch_Segment_group()
if opt_group | opt_short then do
stack_level = Current_Level
RexxMsg.infos(' LV:' Current_Level 'SG:' Current_Group_No -
'I:' Current_Seq_No 'Seg:' Segment)
end /*if*/
DataList = edi_members[ii_Segment]
if debug then do
RexxMsg.info('DataList:' DataList)
end /*if*/
nv = 0
iv = 0
iv1 = 1
loop jj = 1 to DataList.words()
ii_Data = DataList.word(jj)
DataId = edi_id[ii_Data]
DataName = edi_name[ii_Data]
split(seg_data,Data_delim)
Data0 = head
seg_data = tail
if opt_all | (opt_short & (Data0 <> '')) then do
RexxMsg.info(' Data: '||DataId DataName||':' Data0)
end /*if*/
FieldList = edi_members[ii_Data]
if debug then do
RexxMsg.info(' FieldList:' FieldList)
end /*if*/
n_Fields = FieldList.words()
if n_Fields > 0 then do
loop kk = 1 to n_Fields
ii_Field = FieldList.word(kk)
FieldId = edi_id[ii_Field]
FieldName = edi_name[ii_Field]
FieldFreq = edi_freq[ii_Field].toint()
if opt_all | (opt_short & (FieldVal <> '')) then do
RexxMsg.info(' Field:' FieldId FieldName||':' -
FieldVal)
end /*if*/
iv = iv + 1
Field_Level[iv] = Current_Level
Field_Group[iv] = Current_Group_No
Field_Segment_No[iv] = seg_no
Field_Data[iv] = ii_Data
Field_No[iv] = ii_Field
if FieldFreq = 0 then do
split(Data0,Field_delim)
FieldVal = head
Data0 = tail
Field_Value[iv] = FieldVal
check_Field(ii_Field,FieldVal)
end
else do
Field_Value[iv] = Data0
loop ifreq = 1 to FieldFreq
split(Data0,Field_delim)
FieldVal = head
Data0 = tail
if opt_short | opt_all then do
RexxMsg.info(' index:' ifreq 'value:' FieldVal)
end /*if*/
Field_Value[iv,ifreq] = FieldVal
Data0 = tail
end /* loop ifreq */
end /*if*/
end /* loop kk */
end
else do
iv = iv + 1
Field_Level[iv] = Current_Level
Field_Group[iv] = Current_Group_No
Field_Segment_No[iv] = seg_no
Field_Data[iv] = ii_Data
Field_No[iv] = 0
Field_Value[iv] = Data0
check_Field(ii_Data,Data0)
Data0 = ''
end /*if*/
if Data0 <> '' then do
RexxMsg.error('superfluos Data:' Data0 'ignored.')
end /*if*/
end /* loop jj */
nv = iv
return
method start_EDI_parser(data_file1 = Rexx '',defn_file = Rexx -
'',options = Rexx '') static public ;
FD_defn_file = RexxFile.FD(defn_file)
data_file = data_file1
FD_data_file = RexxFile.FD(data_file)
init_EDI()
in_EDI_definition(defn_file)
init_EDI_properties()
set_opts(options)
FD_data_file.open()
fx = RexxFile.parsefid(data_file)
parse fx fn ft fm
buffer = ''
seg_no = 0
n_Segments = 0
time11 = RexxTime.time('R')
trace_Segments = 0
EOF = 0
used_Segments = ''
line_no = 0
return
method start_EDI_composer(data_file0 = Rexx '',defn_file = Rexx -
'',options = Rexx '') static public ;
FD_defn_file = RexxFile.FD(defn_file)
init_EDI()
in_EDI_definition(defn_file)
init_EDI_properties()
set_opts(options)
output_file = data_file0
FD_output_file = RexxFile.FD(output_file)
FD_output_file.scratch()
buffer = ''
seg_no = 0
n_Segments = 0
time11 = RexxTime.time('R')
trace_Segments = 0
EOF = 0
used_Segments = ''
line_no = 0
return
method set_opts(opt_string = Rexx '') static public ;
opt_string=opt_string.upper()
if opt_string.substr(1,2) = 'NO' then do
opt_string = opt_string.substr(3)
flag1 = 0
end
else do
flag1 = 1
end /*if*/
if opt_string.wordpos('CRLF') > 0 then do
opt_CRLF = flag1
end /*if*/
if opt_string.wordpos('DEBUG') > 0 then do
debug = flag1
end /*if*/
if opt_string.wordpos('SHORT') > 0 then do
opt_short = flag1
end /*if*/
if opt_string.wordpos('ALL') > 0 then do
opt_all = flag1
end /*if*/
if opt_string.wordpos('TRACE') > 0 then do
opt_trace = flag1
end /*if*/
if opt_string.wordpos('DISPLAY') > 0 then do
opt_display = flag1
end /*if*/
if opt_string.wordpos('DETAIL') > 0 then do
opt_detail = flag1
end /*if*/
if opt_string.wordpos('SHOW') > 0 then do
opt_show = flag1
end /*if*/
if opt_string.wordpos('GROUP') > 0 then do
opt_group = flag1
end /*if*/
if opt_string.wordpos('VERBOSE') > 0 then do
opt_verbose = flag1
end /*if*/
return
method finish_EDI_parser() static public ;
FD_data_file.close()
time12 = RexxTime.time('E')
elapsed = time12 - time11
e_elapsed = elapsed.format(null,2)
if opt_verbose then do
RexxMsg.info0(n_Segments 'Segments read')
RexxMsg.info0(nv 'Fields parsed')
RexxMsg.info('EDIFACT parser used:' e_elapsed 'seconds')
end /*if*/
used_Segments = used_Segments.strip()
if opt_show then do
display_EDI_Fields()
end /*if*/
return
method finish_EDI_composer() static public ;
FD_output_file.close()
RexxMsg.info0(n_Segments 'EDI-Segments generated')
RexxMsg.info('File: ' output_file 'closed.')
time12 = RexxTime.time('E')
elapsed = time12 - time11
e_elapsed = elapsed.format(null,2)
if opt_verbose then do
RexxMsg.info('EDIFACT composer used:' e_elapsed 'seconds')
end /*if*/
return
method next_Segment() static public ;
bufsize = 8 * 1024
loop while buffer.pos("'") = 0
if EOF then do
leave
end /*if*/
if FD_data_file.chars() > 0 then do
if processor = 'CMS' then do
buffer = buffer || FD_data_file.linein()
end
else do
buffer = buffer || FD_data_file.charin(bufsize)
end /*if*/
end
else do
EOF = 1
end /*if*/
end /* loop */
split(buffer,Segment_delim)
Segment = head
buffer = tail
line = Segment
line_no = line_no + 1
if Segment = '' then do
return
end /*if*/
n_Segments = n_Segments + 1
if trace_Segments then do
RexxMsg.info(line_no||'. Segment:' Segment)
end /*if*/
if used_Segments.wordpos(Segment_type) = 0 then do
used_Segments = used_Segments||' '||Segment_type
end /*if*/
if EOF then do
return
end /*if*/
split(Segment,Data_delim)
Segment_type = head
Segment_Data = tail
data = ''
etc = Segment_Data
nd = 0
Field_val = ''
Field_id = ''
Field_ix = 0
ij = 0
loop while etc <> ''
nd = nd + 1
parse etc $$__1 $$__1 '+' etc
/* ... pending assignments from ARG/PARSE */
data[nd]=$$__1
/* ... end pending assignments from ARG/PARSE */
loop id = 1 to nd
dx = data[id]
ix = 0
loop while dx <> ''
ij = ij + 1
ix = ix + 1
parse dx $$__2 $$__2 ':' dx
/* ... pending assignments from ARG/PARSE */
Field_val[ix]=$$__2
/* ... end pending assignments from ARG/PARSE */
Field_id[ij] = id
Field_ix[ij] = ix
end /* loop */
nj = ij
end /* loop id */
end /* loop */
n_Fields = ij
parse_EDI_Segment()
return
method check_Field(ii1 = Rexx '',val1 = Rexx '') static public ;
codes = edi_codes[ii1]
check_form(ii1,val1)
if (val1 <> '') & (codes <> '') then do
found = 0
loop jjc = 1 to codes.words()
ii_Code = codes.word(jjc)
if val1 = edi_id[ii_Code] then do
found = 1
leave jjc
end /*if*/
end /* loop jjc */
if found = 0 then do
RexxMsg.error('invalid Value: '||val1 'of:' edi_id[-
ii1] edi_name[ii1])
RexxMsg.info('expected: '||code_list(codes))
return
end /*if*/
if opt_all | opt_short then do
RexxMsg.info(' Code:' edi_id[ii_Code]-
'meaning:' edi_name[ii_Code])
end /*if*/
end /*if*/
return
method code_list(list1 = Rexx '') static public returns Rexx;
list2 = ''
loop il = 1 to list1.words()
iic = list1.word(il)
if il = 1 then do
list2 = edi_id[iic]
end
else do
list2 = list2||', '||edi_id[iic]
end /*if*/
end /* loop il */
return list2
method fetch_Segment_group() static public ;
group_list0 = edi_Groups[seg_type]
if group_list0.words() = 1 then do
Current_Group_No = group_list0
Current_Level = Group_Level[Current_Group_No].toint()
Current_List = Group_List[Current_Group_No]
Current_Seq_No = Current_List.wordpos(seg_type)
Current_Seq_End = Current_List.words()
Group_Nest[Current_Level] = Current_Group_No
Segment_Group = Current_Group_No
Group_Level0 = Current_Level
return
end /*if*/
loop ix = Current_Seq_No to Current_Seq_End
expected_Segment = Current_List.word(ix)
if seg_type = expected_Segment then do
Current_Seq_No = ix
return
end /*if*/
end /* loop ix */
loop iz = Current_Level by - 1 to 1
iy = Group_Nest[iz]
expected_Segment = Group_List[iy].word(1)
if seg_type = expected_Segment then do
Current_Group_No = iy
Current_Level = Group_Level[Current_Group_No].toint()
Current_List = Group_List[Current_Group_No]
Current_Seq_No = 1
Current_Seq_End = Current_List.words()
Group_Nest[Current_Level] = Current_Group_No
Segment_Group = Current_Group_No
Group_Level0 = Current_Level
return
end /*if*/
end /* loop iz */
loop iy = Current_Group_No + 1 to n_Groups
list = Group_List[iy]
expected_Segment = list.word(1)
if seg_type = expected_Segment then do
Current_Group_No = iy
Current_Level = Group_Level[Current_Group_No].toint()
Current_List = Group_List[Current_Group_No]
Current_Seq_No = 1
Current_Seq_End = Current_List.words()
Group_Nest[Current_Level] = Current_Group_No
Segment_Group = Current_Group_No
Group_Level0 = Current_Level
return
end /*if*/
end /* loop iy */
RexxMsg.error('unable to determine Segment-Group of Segment:' -
seg_type)
RexxMsg.info('possible Segment Groups are:' edi_Groups[seg_type])
RexxMsg.abort('please correct definition file:' definition_file)
return
method split(string = Rexx '',delim = Rexx '') static public ;
pos1 = 1
loop until c1 <> escape_char
pos1 = string.pos(delim,pos1)
if pos1 = 0 then do
pos1 = string.length() + 1
leave
end /*if*/
c1 = strfun.char1(string,pos1 - 1)
if c1 = escape_char then do
string = string.substr(1,pos1 - 2) || string.substr(pos1)
iterate
end
else do
leave
end /*if*/
end /* loop */
head = string.substr(1,pos1 - 1)
tail = string.substr(pos1 + 1)
return
method display_EDI_Fields() static public ;
header = ' ## LV GRP SEG IND DATA FIELD VALUE'
RexxMsg.info1(header)
loop iv = 1 to nv
no = Rexx(iv).right(5)
lev = Field_Level[iv].right(2)
grp = Segment_Group.left(3)
seg = Segment_type.left(3)
ind = Field_Segment_No[iv].right(3)
ii_Data = Field_Data[iv]
dat = edi_id[ii_Data].left(4)
ii_Field = Field_No[iv]
fld = edi_id[ii_Field].left(5)
val = Field_Value[iv]
RexxMsg.info(no lev grp seg ind dat fld val)
end /* loop iv */
RexxMsg.info('')
return
method EDI_Val(vid = Rexx '') static public returns Rexx;
parse vid Data_Id '.' Field_Id0 '.' index1
vv = ''
found = 0
loop iv = iv1 to nv
if Field_Segment_No[iv] <> Segment_No then do
leave iv
end /*if*/
ii_Data = Field_Data[iv]
ii_Field = Field_No[iv]
if edi_id[ii_Data] = Data_Id then do
if Field_Id0 = '' then do
vv = Field_Value[iv]
found = 1
leave iv
end /*if*/
if edi_id[ii_Field] = Field_Id0 then do
freq = edi_freq[ii_Field].toint()
if freq = 0 then do
if index1 <> '' then do
RexxMsg.error('Data:' Data_Id 'Field:' Field_Id0 -
'is NOT indexed, index:' index1 'ignored')
end /*if*/
vv = Field_Value[iv]
end
else do
if index1 = '' then do
RexxMsg.error('Data:' Data_Id 'Field:' Field_Id0 -
'missing index, index 1 assumed')
index1 = 1
end /*if*/
if (index1 < 1) | (index1 > freq) then do
RexxMsg.error('Data:' Data_Id 'Field:' Field_Id0 -
'index:' index1 'out of bounds!')
return ''
end /*if*/
vv = Field_Value[iv,index1]
if opt_all then do
RexxMsg.info(' index:' index1 'Value:' vv)
end /*if*/
end /*if*/
found = 1
leave iv
end /*if*/
end /*if*/
end /* loop iv */
if found = 0 then do
RexxMsg.error('Cannot find field: '||vid 'of segment:' -
Segment_type 'in Group:' Segment_Group)
end /*if*/
return vv
method init_EDI_segment(group2 = Rexx '',type2 = Rexx '')-
static public ;
ii_Segment = lookup(type2)
if ii_Segment = 0 then do
RexxMsg.abort('undefined Segment:' type2 'encountered.')
end /*if*/
seg_members = edi_members[ii_Segment]
Current_Group = group2
Current_SegType = type2
Segment_Stem = ''
return
method write_EDI_segment(group3 = Rexx '',type3 = Rexx '')-
static public ;
if group3 <> Current_Group then do
RexxMsg.abort('Group:' group3 'is not current group:' -
Current_Group)
end /*if*/
if type3 <> Current_SegType then do
RexxMsg.abort('Segment:' type3 'is not current segment Type:' -
Current_SegType)
end /*if*/
ii_Segment = lookup(type3)
seg_members = edi_members[ii_Segment]
seg_data = type3
loop iws = 1 to seg_members.words()
ii_Data = seg_members.word(iws)
Data0 = Field_Data(ii_Data)
if Data0.pos(Data_delim) > 0 then do
Data0 = strfun.changestr(Data0,Data_delim,escape_char || -
Data_delim)
end /*if*/
seg_data = seg_data || Data_delim || Data0
end /* loop iws */
seg_data = seg_data.strip('T',Data_delim)
seg_data = seg_data || Segment_delim
if opt_CRLF then do
FD_output_file.lineout(seg_data)
end
else do
FD_output_file.charout(seg_data)
end /*if*/
n_Segments = n_Segments + 1
return
method Field_Data(jj_data = Rexx '') static public returns Rexx;
jj_data=jj_data.upper()
cur_type = edi_type[jj_data]
if (cur_type = 'F') | ((cur_type = 'D') & (edi_members[-
jj_data] = '')) then do
Field_Id0 = edi_id[jj_data]
Data0 = Segment_Stem[Field_Id0]
return Data0
end /*if*/
if cur_type <> 'D' then do
RexxMsg.abort('unexpected type:' cur_type 'at index:' jj_data -
'(only "F" or "D" expected)')
end /*if*/
Data_Id = edi_id[jj_data]
field_list = edi_members[jj_data]
field_data0 = ''
loop jf = 1 to field_list.words()
jj_field = field_list.word(jf)
Field_Id0 = edi_id[jj_field]
subscript = Data_Id||'.'||Field_Id0
FieldFreq = edi_freq[jj_field].toint()
if FieldFreq > 0 then do
data1 = array_value(Data_Id,Field_Id0,FieldFreq)
end
else do
data1 = Segment_Stem[subscript]
if data1.pos(Field_delim) > 0 then do
data1 = strfun.changestr(data1,Field_delim,escape_char -
|| Field_delim)
end /*if*/
end /*if*/
if jf = 1 then do
field_data0 = data1
end
else do
field_data0 = field_data0 || Field_delim || data1
end /*if*/
end /* loop jf */
field_data0 = field_data0.strip('T',Field_delim)
if opt_trace then do
RexxMsg.info('EDI Field:' subscript '=' field_data0)
end /*if*/
return field_data0
method array_value(a_Data_id = Rexx '',a_Field_id = Rexx '',a_freq -
= int 0) static public returns Rexx;
array_script = a_Data_id||'.'||a_Field_id
if Segment_Stem[array_script] <> '' then do
RexxMsg.abort('Field: '||array_script 'is an array, index'-
'missing')
end /*if*/
arr_data = ''
loop ia = 1 to a_freq
subscript = array_script||'.'||ia
data1 = Segment_Stem[subscript]
if data1.pos(Field_delim) > 0 then do
data1 = strfun.changestr(data1,Field_delim,escape_char || -
Field_delim)
end /*if*/
if ia = 1 then do
arr_data = data1
end
else do
arr_data = arr_data || Field_delim || data1
end /*if*/
end /* loop ia */
return arr_data
method Set_EDI_Val(Field_id4 = Rexx '',new_val4 = Rexx '')-
static public ;
Segment_Stem[Field_id4] = new_val4
return
method check_form(ii6 = Rexx '',val6 = Rexx '') static public ;
form6 = edi_form[ii6]
ic6 = form6.verify(letters)
length6 = form6.substr(ic6)
form6 = form6.substr(1,ic6 - 1)
if length6.substr(1,2) = '..' then do
max_length6 = length6.substr(3)
Var_length6 = 'V'
end
else do
max_length6 = length6
Var_length6 = 'F'
end /*if*/
if val6.length() > max_length6 then do
RexxMsg.error('Field too long: '||edi_id[ii6] edi_name[-
ii6] '=' val6)
RexxMsg.info('expected form:' form '( max. length:' -
max_length6||')')
end /*if*/
return
method in_V2_definition(def = Rexx '') static public ;
FD_def = RexxFile.FD(def)
init_V2()
FD_def.open()
line_no = 0
loop while FD_def.lines() > 0
line = FD_def.linein().strip()
line_no = line_no + 1
if strfun.char1(line,1) = '*' then do
iterate
end /*if*/
if line = '' then do
iterate
end /*if*/
loop while strfun.lastchar(line) = '-'
linelen = line.length()
line = line.substr(1,linelen - 1) || FD_def.linein().strip()
line_no = line_no + 1
end /* loop */
linelen = line.length()
parse_V2_definition_line()
end /* loop */
FD_def.close()
return
method init_V2() static public ;
V2_type = ''
V2_id = ''
V2_name = ''
V2_req = ''
V2_freq = 1
V2_field1 = 0
V2_field2 = 0
V2_codes = ''
V2_types = 'RT F C *'
V2_RT = 0
nn_V2 = 0
V2_Record = 0
n_Record_Types = 0
n_V2_in = 0
n_V2_out = 0
return
method parse_V2_definition_line() static public ;
parse line type ':' id ':' Name ':' req ':' form ':' note
freq = 1
if V2_types.wordpos(type) > 0 then do
nn_V2 = nn_V2 + 1
ii_V2 = nn_V2
V2_type[ii_V2] = type
V2_id[ii_V2] = id
V2_name[ii_V2] = Name
V2_form[ii_V2] = form
V2_req[ii_V2] = req
V2_freq[ii_V2] = freq
V2_note[ii_V2] = note
end /*if*/
if V2_types.wordpos(type) = 0 then do
RexxMsg.error('illegal line-type:' type 'expected:' V2_types)
return
end /*if*/
select
when type = 'RT' then do
if V2_lookup(id) <> 0 then do
RexxMsg.warning('Duplicate defined Record-Type:' id)
end /*if*/
V2_Record[id] = ii_V2
ii_V2_Record = ii_V2
ii_V2_Field = 0
ii_V2_Code = 0 = 0
n_Record_Types = n_Record_Types + 1
V2_field1[ii_V2_Record] = ii_V2 + 1
end /*when*/
when type = 'F' then do
ii_V2_Field = ii_V2
V2_field2[ii_V2_Record] = ii_V2
end /*when*/
when type = 'C' then do
if ii_V2_Field = 0 then do
RexxMsg.error('Code-record without preceeding Field'-
'definition')
return
end /*if*/
ii_V2_Code = ii_V2
V2_codes[ii_V2_Field] = V2_codes[ii_V2_Field]||' '||ii_V2
end /*when*/
otherwise do
do
RexxMsg.error('invalid type: '||type 'ignored')
end
end /* otherwise */
end /* select */
return
method V2_lookup(id1 = Rexx '') static public returns int;
id1=id1.upper()
return V2_Record[id1]
method display_V2(rec_id2 = Rexx '') static public ;
if rec_id2 = '' then do
ivv1 = 1
ivv2 = nn_V2
end
else do
ir = V2_lookup(rec_id2)
if ir = 0 then do
RexxMsg.abort('unknown V2-record-id:' rec_id2)
end /*if*/
RexxMsg.info2('Record: ' V2_name[ir])
ivv1 = V2_field1[ir].toint()
ivv2 = V2_field2[ir].toint()
end /*if*/
loop ivv = ivv1 to ivv2
type = V2_type[ivv]
select
when type = 'RT' then do
RexxMsg.info2('Record: ' V2_name[ivv])
end /*when*/
when type = 'F' then do
id = V2_id[ivv]
e_id = V2_id[ivv].right(2)
e_name = V2_name[ivv].left(30)
e_form = V2_form[ivv].left(6)
e_val = V2[id]
RexxMsg.info(e_id ':' e_name ':' e_form ':' e_val)
end /*when*/
otherwise do
end /* otherwise */
end /* select */
end /* loop ivv */
return
method out_V2(rec_id = Rexx '') static public ;
if opt_display then do
display_V2(rec_id)
end /*if*/
ir = V2_lookup(rec_id)
if ir = 0 then do
RexxMsg.abort('unknown V2-record-id:' rec_id 'in out_V2!')
end /*if*/
ivv1 = V2_field1[ir].toint()
ivv2 = V2_field2[ir].toint()
rec_data = ''
loop ivv = ivv1 to ivv2
a_type = V2_type[ivv]
if a_type <> 'F' then do
iterate ivv
end /*if*/
a_id = V2_id[ivv]
a_name = V2_name[ivv]
a_form = V2_form[ivv]
a_val = V2[a_id].strip()
a_class = a_form.substr(1,1)
a_len = a_form.substr(2)
if a_len.pos('.') > 0 then do
parse a_len a_len '.' a_dec
end /*if*/
select
when a_class = 'n' then do
a_val = a_val.right(a_len,'0')
end /*when*/
when a_class = 'a' then do
a_val = a_val.left(a_len)
end /*when*/
when a_class = 'd' then do
a_val = a_val.right(a_len)
end /*when*/
otherwise do
do
RexxMsg.error('invalid Type:' a_class -
'for field: '||a_name 'in record type:' rec_id)
RexxMsg.info('only "a" and "n" allowed!')
RexxMsg.abort('please correct V2.DEF')
end
end /* otherwise */
end /* select */
rec_data = rec_data || a_val
end /* loop ivv */
FD_V2_file.lineout(rec_data)
n_V2_out = n_V2_out + 1
return
method in_V2() static public returns Rexx;
if FD_V2_file.lines() = 0 then do
return ''
end /*if*/
V2_rec = FD_V2_file.linein()
V2_rec_type = V2_rec.substr(119,2)
ir = V2_lookup(V2_rec_type)
if ir = 0 then do
RexxMsg.abort('unknown V2-record-type:' V2_rec_type -
'in file:' V2_file)
end /*if*/
ivv1 = V2_field1[ir].toint()
ivv2 = V2_field2[ir].toint()
a_loc = 1
loop ivv = ivv1 to ivv2
a_type = V2_type[ivv]
if a_type <> 'F' then do
iterate ivv
end /*if*/
a_id = V2_id[ivv]
a_name = V2_name[ivv]
a_form = V2_form[ivv]
a_val = V2[a_id].strip()
a_class = a_form.substr(1,1)
a_len = a_form.substr(2)
if a_len.pos('.') > 0 then do
parse a_len a_len '.' a_dec
end
else do
a_dec = 0
end /*if*/
a_val = V2_rec.substr(a_loc,a_len)
select
when a_class = 'n' then do
a_val = a_val.strip('L','0')
if a_val.length() < (a_dec + 1) then do
a_val = a_val.right(a_dec + 1,'0')
end /*if*/
if a_dec > 0 then do
n_dec = a_dec
n_digs = a_val.length()
f_int = a_val.substr(1,n_digs - 2)
f_dec = a_val.substr(n_digs - 1,2)
f_val = f_int||'.'||f_dec
a_val = f_val
end
else do
V2[a_id] = a_val
end /*if*/
if StrFunc.datatype(a_val) <> 'NUM' then do
RexxMsg.error('V2 field:' a_id||':' a_name '=' a_val -
'is NOT numeric, ZERO assumed!')
a_val = 0
end /*if*/
V2[a_id] = a_val
end /*when*/
when a_class = 'a' then do
V2[a_id] = a_val.strip('T',' ')
end /*when*/
when a_class = 'd' then do
V2[a_id] = a_val
end /*when*/
otherwise do
do
RexxMsg.error('invalid Type:' a_class -
'for field: '||a_name 'in record type:' V2_rec_type)
RexxMsg.info('only "d", "a" and "n" allowed!')
RexxMsg.abort('please correct V2.DEF')
end
end /* otherwise */
end /* select */
a_loc = a_loc + a_len
end /* loop ivv */
n_V2_in = n_V2_in + 1
return V2_rec_type
method edate(idate = Rexx '') static public returns Rexx;
/* ... Declare Local REXX variables: */
x_date = Rexx ''
dd = Rexx ''
mm0 = Rexx ''
yy0 = Rexx ''
cc = Rexx '20'
yyyy0 = Rexx ''
/* ... End of local REXX variable declarations */
/* ... Rexx Procedure (nothing exposed) */
select
when (idate = '') | (idate = 0) then do
x_date = RexxTime.date('E')
parse x_date dd '/' mm0 '/' yy0
cc = '20'
yyyy0 = cc || yy0
end /*when*/
when idate.length() = 6 then do
yy0 = idate.substr(1,2)
mm0 = idate.substr(3,2)
dd = idate.substr(5,2)
if yy0 < 50 then do
cc = '20'
end
else do
cc = '19'
end /*if*/
yyyy0 = cc || yy0
end /*when*/
when idate.length() = 8 then do
yyyy0 = idate.substr(1,4)
yy0 = yyyy0.substr(3,2)
mm0 = idate.substr(5,2)
dd = idate.substr(7,2)
end /*when*/
otherwise do
do
RexxMsg.error('invalid date: '||idate 'encountered.')
RexxMsg.abort('please correct source program!')
end
end /* otherwise */
end /* select */
x_date = dd||'.'||mm0||'.'||yyyy0
return x_date
method Decimal(comma_val = Rexx '',ndig = int 0,ndec = int 0)-
static public returns Rexx;
comma_val = comma_val.strip()
if comma_val.pos(',') > 0 then do
num_val = strfun.changestr(comma_val,',','.')
numericv = num_val.format(ndig - ndec,ndec)
end
else if comma_val.pos('.') > 0 then do
numericv = comma_val.format(ndig - ndec,ndec)
end
else do
numericv = comma_val||'.'||'0'.copies(ndec)
end /*if*/
numeric0 = strfun.changestr(numericv,'.','')
return numeric0.strip()
method EditDecimal(numv = Rexx '',ndigs = int 0,ndec = int 0)-
static public returns Rexx;
numv = numv.right(ndigs,'0')
idec1 = ndigs - ndec + 1
nint = ndigs - ndec
decv = numv.substr(idec1,ndec)
intv = numv.substr(1,nint)
intv = intv + 0
editv = (intv||'.'||decv).right(ndigs + 1)
return editv
method Decimal2(numv = Rexx '') static public returns Rexx;
return numv / 100