report znadar_filez line-size 1023 no standard page heading.
tables: sscrfields.
selection-screen begin of block b01 with frame.
parameters: local_f like rlgrap-filename,
host_f like rlgrap-filename,
p_ascii radiobutton group tip default 'X',
p_binar radiobutton group tip.
selection-screen function key 1.
selection-screen function key 2.
selection-screen function key 3.
selection-screen end of block b01.
data: begin of itab occurs 0,
reg(65534),
end of itab, titulo(1023).
at line-selection.
perform list_filez.
at user-command.
if sy-pfkey = 'L100'.
perform user_input.
endif.
at selection-screen.
if sscrfields-ucomm = 'FC01'. perform to_host. endif.
if sscrfields-ucomm = 'FC02'. perform to_local. endif.
if sscrfields-ucomm = 'FC03'. perform view_filez. endif.
initialization.
include <icon>.
move '@49@ A Host' to sscrfields-functxt_01. "ICON_EXPORT
move '@48@ A Local' to sscrfields-functxt_02. "ICON_IMPORT
move '@10@ Filez' to sscrfields-functxt_03. "ICON_IMPORT
end-of-selection.
perform get_directory.
form view_filez.
if not host_f is initial.
leave to list-processing. new-page no-heading no-title.
perform: read_host, list_filez.
elseif not local_f is initial.
leave to list-processing. new-page no-heading no-title.
perform: read_local, list_filez.
endif.
endform.
form list_filez.
data: posi type i occurs 0 with header line,
cortar(1), ch type i, cl type i, al(1), ah type i,
di like itab-reg, si like di.
field-symbols: <h>.
sy-lsind = sy-lsind - 1.
set pf-status space.
read line 1.
if sy-subrc eq 0.
if sy-lisel ca 'Xx.|'.
cortar = 'X'.
translate sy-lisel using 'X|x|.|'.
titulo = sy-lisel.
modify line 1.
ch = strlen( titulo ). cl = 1.
do ch times.
ah = sy-index - 1.
al = titulo+ah(cl).
if al ca 'Xx|'. posi = ah. append posi. endif.
enddo.
endif.
else.
clear cortar.
endif.
titulo(1023) = '.'.
write / titulo input on.
loop at itab.
if cortar = 'X'.
translate itab-reg using ' ¬'.
clear di.
ch = 0. write: / ''.
loop at posi.
ah = 0.
ah = posi - ch.
if ah > 0.
si = itab-reg.
si = si+ch(ah). concatenate di si sy-vline into di.
else. di = sy-vline.
endif.
ah = ch = posi.
endloop.
ch = strlen( itab-reg ).
if ch > ah.
si = itab-reg. translate si using '¬ '.
ch = strlen( itab-reg ). ah = ch - ah.
si = si+posi(ah). concatenate di si into di.
endif.
translate di using '¬ '.
write: / di.
else.
write: / itab-reg.
endif.
endloop.
endform.
form to_local.
perform: read_host, write_local.
endform.
form to_host.
perform: read_local, write_host.
endform.
form write_host.
open dataset host_f for output in text mode.
if sy-subrc ne 0. message e398(00) with 'Host File Not Found'. endif.
loop at itab. transfer itab-reg to host_f. endloop.
endform.
form write_local.
call function 'WS_DOWNLOAD'
exporting
filename = local_f
filetype = 'ASC'
tables
data_tab = itab
exceptions
file_open_error = 1
file_write_error = 2
invalid_filesize = 3
invalid_table_width = 4
invalid_type = 5
no_batch = 6
unknown_error = 7
gui_refuse_filetransfer = 8
others = 9.
if sy-subrc ne 0. message e398(00) with 'Host File Not Found'. endif.
endform.
form read_host.
clear itab. refresh itab.
if p_ascii = 'X'.
open dataset host_f in text mode.
else.
open dataset host_f in binary mode.
endif.
if sy-subrc ne 0. message e398(00) with 'Host File Not Found'. endif.
do.
read dataset host_f into itab-reg.
if sy-subrc ne 0. exit. endif.
append itab.
enddo.
endform.
form read_local.
clear itab. refresh itab.
call function 'WS_UPLOAD'
exporting
filename = local_f
filetype = 'ASC'
tables
data_tab = itab
exceptions
conversion_error = 1
file_open_error = 2
file_read_error = 3
invalid_table_width = 4
invalid_type = 5
no_batch = 6
unknown_error = 7
gui_refuse_filetransfer = 8
others = 9.
if sy-subrc ne 0. message e398(00) with 'Local File Not Found'. endif.
endform.
*--- Plagio de la AL11
data: globaldirectory(75) type c,
strlen like sy-fdpos.
data: begin of searchpoints occurs 10,
dirname(75) type c, " name of directory.
sp_name(75) type c, " name of entry. (may end with *)
sp_cs(10) type c, " ContainsString pattern for name.
end of searchpoints,
all_gen value '*', " generic filename shall select all
no_cs value ' '. " no MUST_ContainString
data: begin of file_list occurs 100,
dirname(75) type c, " name of directory. (possibly truncated.)
name(75) type c, " name of entry. (possibly truncated.)
type(10) type c, " type of entry.
len(8) type p, " length in bytes.
owner(8) type c, " owner of the entry.
mtime(6) type p, " last modification date, seconds since 1970
mode(9) type c, " like "rwx-r-x--x": protection mode.
useable(1) type c,
subrc(4) type c,
errno(3) type c,
errmsg(40) type c,
mod_date type d,
mod_time(8) type c, " hh:mm:ss
seen(1) type c,
changed(1) type c,
end of file_list,
srt(1) value 'T'.
data: begin of file,
dirname(75) type c, " name of directory. (possibly truncated.)
name(75) type c, " name of entry. (possibly truncated.)
type(10) type c, " type of entry.
len(8) type p, " length in bytes.
owner(8) type c, " owner of the entry.
mtime(6) type p, " last modification date, seconds since 1970
mode(9) type c, " like "rwx-r-x--x": protection mode.
useable(1) type c,
subrc(4) type c,
errno(3) type c,
errmsg(40) type c,
mod_date type d,
mod_time(8) type c, " hh:mm:ss
seen(1) type c,
changed(1) type c,
end of file,
sap_no(1) value ' ',
sap_yes(1) value 'X'.
data: h_list_index type p. " hided with each data line; otherwise 0
form get_directory.
set pf-status 'L100' of program 'RSWATCH0'.
set titlebar '100' of program 'RSWATCH0'.
refresh file_list.
refresh searchpoints.
searchpoints-sp_name = all_gen .
searchpoints-sp_cs = no_cs .
append searchpoints.
loop at searchpoints.
perform fill_file_list using searchpoints-dirname
searchpoints-sp_name
searchpoints-sp_cs.
endloop.
srt = 'N'.
sort file_list by name ascending mtime descending.
perform show_file_list.
endform. "GET_DIRECTORY.
form fill_file_list using a_dir_name a_generic_name a_must_cs.
" Routine von M. Mittelstein
data: errcnt(2) type p value 0.
if a_dir_name is initial. a_dir_name = '/'. endif.
call 'C_DIR_READ_FINISH'
id 'ERRNO' field file_list-errno
id 'ERRMSG' field file_list-errmsg.
call 'C_DIR_READ_START' id 'DIR' field a_dir_name
id 'FILE' field a_generic_name
id 'ERRNO' field file-errno
id 'ERRMSG' field file-errmsg.
if sy-subrc <> 0.
message e204(s1) with file_list-errmsg file-errmsg.
endif.
do.
clear file.
call 'C_DIR_READ_NEXT'
id 'TYPE' field file-type
id 'NAME' field file-name
id 'LEN' field file-len
id 'OWNER' field file-owner
id 'MTIME' field file-mtime
id 'MODE' field file-mode
id 'ERRNO' field file-errno
id 'ERRMSG' field file-errmsg.
file-dirname = a_dir_name.
move sy-subrc to file-subrc.
case sy-subrc.
when 0.
clear: file-errno, file-errmsg.
case file-type(1).
when 'F'. " normal file.
perform filename_useable using file-name file-useable.
when 'f'. " normal file.
perform filename_useable using file-name file-useable.
when others. " directory, device, fifo, socket,...
move sap_no to file-useable.
endcase.
if file-len = 0.
move sap_no to file-useable.
endif.
when 1. exit.
when others.
add 1 to errcnt.
if errcnt > 10. exit. endif.
if sy-subrc = 5.
file-type = file-owner = file-mode = '???'.
endif.
move sap_no to file-useable.
endcase.
perform p6_to_date_time_tz(rstr0400) using file-mtime
file-mod_time
file-mod_date.
if a_must_cs = no_cs.
move-corresponding file to file_list.
append file_list.
else.
if file-name cs a_must_cs.
move-corresponding file to file_list.
append file_list.
endif.
endif.
enddo.
call 'C_DIR_READ_FINISH'
id 'ERRNO' field file_list-errno
id 'ERRMSG' field file_list-errmsg.
if sy-subrc <> 0.
write: / 'C_DIR_READ_FINISH', 'SUBRC', sy-subrc.
endif.
if srt = 'T'.
sort file_list by mtime descending name ascending.
else.
sort file_list by name ascending mtime descending.
endif.
endform.
form show_file_list.
data: cflag(1) value 'X'.
******************************************************************CAS***
* Liste der Fehlerprotokolldateien ausgeben.
new-page no-title.
sy-lsind = 1.
loop at file_list.
perform flip_flop(rsora000) using cflag.
write: / file_list-useable,
file_list-seen,
file_list-changed,
file_list-name(30),
file_list-len,
file_list-owner,
file_list-mod_date dd/mm/yyyy,
file_list-mod_time.
h_list_index = sy-tabix.
hide: h_list_index. " , FILE_LIST-DIRNAME, FILE_LIST-NAME.
endloop.
clear: h_list_index, file_list-dirname, file_list-name.
endform.
form filename_useable using a_name a_useable.
data l_name(75).
l_name = a_name.
if l_name(4) = 'core'.
a_useable = sap_no.
else.
a_useable = 'X'.
endif.
endform.
form user_input.
data curpage like sy-cpage.
case sy-pfkey.
when 'L100'.
case sy-ucomm.
when 'DIRL'.
perform show_dir_list in program rswatch0.
when 'ATTR'.
if h_list_index > 0.
perform show_file_details.
else.
message s208(s1). " Cursor befand sich auerhalb der Liste
endif.
when 'DISP'.
if h_list_index > 0.
read table file_list index h_list_index.
if file_list-dirname <> globaldirectory.
perform show_file_contents.
if file_list-type(1) = 'D' or file_list-type(1) = 'd'.
case file_list-name.
when '.'. "stay where ever you are
when '..'. "go up
when others. "go down
strlen = strlen( searchpoints-dirname ).
if strlen > 1. "never go higher than root
case sy-opsys.
when 'VMS'. "nothing
when 'Windows NT'.
write '\' to searchpoints-dirname+strlen.
strlen = strlen + 1.
when others. "UNIX
write '/' to searchpoints-dirname+strlen.
strlen = strlen + 1.
endcase.
endif.
write file_list-name to searchpoints-dirname+strlen.
endcase.
perform get_directory. "here we go again
else.
modify current line
field value file_list-seen from sap_yes
file_list-changed from sap_no.
move sap_yes to file_list-seen.
move sap_no to file_list-changed.
modify file_list index h_list_index.
endif.
endif.
else.
message s208(s1). " Cursor befand sich auerhalb der Liste
endif.
when 'UPDA'.
perform update_file_list in program rswatch0.
curpage = sy-cpage.
perform show_file_list.
scroll list index sy-lsind to page curpage.
when 'NAME'.
srt = 'N'.
sort file_list by name ascending mtime descending.
perform show_file_list.
when 'TIME'.
srt = 'T'.
sort file_list by mtime descending name ascending.
perform show_file_list.
endcase.
clear h_list_index.
when 'L200'.
case sy-ucomm.
* -> L200 + ATTR
when 'ATTR'.
perform show_file_details.
* -> L200 + DIRL
when 'DIRL'.
perform show_dir_list in program rswatch0.
endcase.
endcase.
endform.
form show_file_details.
******************************************************************CAS***
* Details zu einer Fehlerprotokolldatei
set pf-status 'L300' of program 'RSWATCH0'.
set titlebar '300' of program 'RSWATCH0'.
read table file_list index h_list_index.
write: / 'Directory......'(019), file_list-dirname,
/ 'Name...........'(001), file_list-name,
/ 'Typ............'(002), file_list-type,
/ 'Lnge..........'(003), file_list-len,
/ 'Erzeuger.......'(004), file_list-owner,
/ 'Letzte nderung'(005), file_list-mod_date dd/mm/yyyy,
file_list-mod_time,
/ 'Mode...........'(006), file_list-mode,
/ 'Verwendbar.....'(007), file_list-useable,
/ 'Fehlernummer...'(008), file_list-errno,
/ 'Fehlermeldung..'(009), file_list-errmsg.
endform.
form show_file_contents.
data: buffer(255) type c,
path_name(151) type c.
set pf-status 'L200' of program 'RSWATCH0'.
set titlebar '200' of program 'RSWATCH0'.
if file_list-useable = sap_yes.
path_name = file_list-dirname.
strlen = strlen( searchpoints-dirname ).
if strlen > 1. "never go higher than root
if sy-opsys <> 'VMS'.
path_name+75(1) = '/'.
endif.
endif.
path_name+76(75) = file_list-name.
condense path_name no-gaps.
open dataset path_name in text mode.
do.
read dataset path_name into buffer.
if sy-subrc <> 0.
exit.
else.
write buffer.
endif.
enddo.
close dataset path_name.
else.
if file_list-type(1) = 'D' or file_list-type(1) = 'd'.
else.
write: /
'Der Inhalt dieser Datei kann nicht angezeigt werden.'(018).
endif.
endif.
endform.