report zsgicnpv line-size 255 no standard page heading. include . ************************************************************************ * Author: Victor Voilevitch, November 2000 * Browser can be customized to the given UNIX system: constants: * ------------------------------------------ * 1. delays after unix command to complete standard & diagnostic output * (time to executing) = 4 seconds for ls command, 0.5 second otherwise: c_time type i value 4000000, "in microseconds c_tiny type i value 500000, "in microseconds * ------------------------------------------ * 2. positions of file|dir name in ls output listing: c_54 type i value 54, c_00 type i value 0. * e.g.: c_00 c_54 * drwxr--r-- ........ users * (plus program tries to calculate w_c54 automatically) * ------------------------------------------ * 3. see form ENTRY at the end of the report (optional): * - user name; * - action; ************************************************************************ * Memory IDs used: ZVV ZVZ ************************************************************************ * Version: 10/09/2003 ************************************************************************ types: t_dir(150) type c, "Directory/File Name t_cmd(200) type c, "Unix Command with Args etc t_cnm(49) type c, "Unix Command Name t_inf(255) type c, "Information String t_txt(65535) type c, "File Contents String t_cod(1) type c, "Code/Flag t_flt(20) type c, "Files pattern like *.* t_it type t_inf occurs 0, "Table of Information t_itx type t_txt occurs 0, "Contents of File t_11(11) type c. "line # ************************************************************************ *---- file names constants: c_log type t_dir value '/tmp/sgicsbinipivvva', c_diag type t_dir value '/tmp/soisisdinipivvva', u_root type t_dir value '/', *---- ruler c_ruler1(50) type c value '....+....1....+....2....+....3....+....4....+....5', c_ruler2(50) type c value '....+....6....+....7....+....8....+....9....+....0', c_10 type i value 10, c_11 type i value 11, *---- flags c_ok type t_cod value space, c_no type t_cod value space, c_err type t_cod value 'X', c_yes type t_cod value 'X', c_empty type t_cod value 'E', *---- UNIX commands etc. u_gt type t_cnm value '>', u_2gt type t_cnm value '2>', u_lsal type t_cnm value 'ls -al', u_pwd type t_cnm value 'pwd', u_logname type t_cnm value 'logname', u_date type t_cnm value 'date', u_meta(4) type c value '*?[]', *---- ls output objects etc. c_b(1) type c value 'b', "block device c_c(1) type c value 'c', "char device c_l(1) type c value 'l', "list ??? c_d(1) type c value 'd', "directory c_f(1) type c value '-', "file c_total(5) type c value 'total', "total info c_comment(1) type c value '/', "Comment c_allf(1) type c value '*', "all files c_allfx(3) type c value '*.*', "all files wrong c_cwd(1) type c value '.', "current dir c_prt(2) type c value '..'. "parent dir ************************************************************************ selection-screen: begin of line, comment 1(18) sshost for field p_host. parameters p_host like sy-host modif id ini. selection-screen: end of line, begin of line, comment 1(18) ssos for field p_os. parameters p_os like sy-opsys modif id ini. selection-screen: end of line, begin of line, comment 1(18) ssuser for field p_user. parameters p_user type t_cnm modif id ini. selection-screen: end of line, begin of line, comment 1(18) sshome for field p_home. parameters p_home type t_dir modif id ini. selection-screen: end of line, begin of line, comment 1(18) ssdir for field p_dir. parameters p_dir type t_dir default '/tmp' obligatory lower case. selection-screen: end of line, begin of line, comment 1(18) ssfltr for field p_fltr. parameters p_fltr type t_flt default c_allf lower case. selection-screen: end of line, begin of line, comment 1(40) ssinf for field p_inf. parameters p_inf as checkbox default c_yes. selection-screen: end of line. ************************************************************************ data: w_cwd type t_dir, "Current Dir w_prev type t_dir, "Previous Dir w_file type t_dir, "Current File w_filen like sy-tabix, "Current File Lines # w_obj type t_dir, "Current Object w_ret type t_cod, "Current Return Code w_msg(50) type c, "Message String w_fltr(20) type c, "Current File Pattern w_fnew like w_fltr, "New File Pattern w_ruler type t_inf, "Ruler w_email like t884t-txt, "e-mail address w_link(1) type c, "link used *-----------------------Unix w_os type t_cmd, "Unix command w_cmd type t_cmd, "Unix command with redirection w_d type i, "Offset of Object Name in ls w_c54 type i, "Offset determined automatically w_54done type t_cod value c_no, *-----------------------Uline w_uline like sy-uline, "Saved sy-uline w_unew like sy-uline, "New sy-uline w_trans(2) type c, "Replacement like '-|' *-----------------------Popups w_answer(1) type c, "Answer w_txt like t884t-txt, "Text Field To Modify w_srch like t884t-txt, "Search String *-----------------------List processing w_lsind like sy-lsind, "Current List w_ucomm like sy-ucomm, "Current User Command w_linno like sy-tabix, "Line Number w_colno like sy-fdpos, "Column Number w_start type t_cod value c_yes, ************************************************************************ it_log type t_it with header line, "Output it_diag type t_it with header line, "Diagnostic it_file type t_itx with header line, "File contents it_outp type t_it with header line. "File for output data: begin of it_list occurs 0, "Register of Lists listi like sy-listi, ucomm like sy-ucomm, fltr like c_yes, end of it_list. data: begin of it_cache occurs 0, "Cache of dirs cwd type t_dir, log type t_it, end of it_cache. ************************************************************************ define check_trailing_slash. shift &1 right deleting trailing space. if &1+149(1) = u_root. &1+149(1) = space. endif. shift &1 left deleting leading space. end-of-definition. ************************************************************************ define write_number. write &1 to &2 no-zero. shift &2 left deleting leading space. if &2 is initial. &2 = '0'. endif. end-of-definition. ************************************************************************ define show_message. message id sy-msgid type 'I' number sy-msgno with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. end-of-definition. ************************************************************************ ************************************************************************ ************************************************************************ ************************************************************************ initialization. message s398(00) with 'Author: Victor Voilevich.'. perform entry. sshost = 'Application server'. p_host = sy-host. ssos = 'Operating system'. p_os = sy-opsys. concatenate p_os 'user' into ssuser separated by space. get parameter id 'ZVZ' field p_user. if p_user is initial. perform get_user changing p_user. set parameter id 'ZVZ' field p_user. endif. sshome = 'Home Directory'. get parameter id 'ZVV' field p_home. if p_home is initial. perform get_home changing p_home. set parameter id 'ZVV' field p_home. endif. ssdir = 'Start Directory'. ssfltr = 'Files Pattern'. concatenate 'I am experienced' ssuser into ssinf separated by space. w_uline = w_unew = sy-uline. w_trans(1) = sy-uline(1). w_trans+1(1) = sy-vline. translate w_unew using w_trans. concatenate c_ruler1 c_ruler2 c_ruler1 c_ruler2 c_ruler1 c_ruler2 into w_ruler. clear sy-subrc. ************************************************************************ ************************************************************************ end-of-selection. w_cwd = p_dir. w_fltr = p_fltr. w_ret = c_ok. perform legend. "Create not-used basic list w_start = c_yes. perform ls using w_cwd changing w_ret. ************************************************************************ ************************************************************************ at selection-screen on p_dir. check_trailing_slash p_dir. if p_dir is initial. p_dir = u_root. endif. if p_dir ca u_meta. message e398(00) with 'Meta characters are not allowed here:' 'Use Files Pattern instead!'. endif. ************************************************************************ ************************************************************************ at selection-screen output. loop at screen. check screen-group1 = 'INI'. screen-input = '0'. screen-output = '1'. modify screen. endloop. set cursor field 'P_DIR'. ************************************************************************ ************************************************************************ at user-command. case sy-ucomm. *---- Diagnostics ----------------- when 'ERRO'. if w_start = c_yes. sy-lsind = sy-listi. endif. w_ucomm = sy-ucomm. perform write_diagnostic. *---- Directory Contents --------------- when 'LSAL'. sy-lsind = sy-listi. w_ucomm = sy-ucomm. perform: prepare_log, write_log. *---- File Contents --------------- when 'RFIL'. clear it_log. sy-lsind = w_lsind. w_ucomm = sy-ucomm. perform show_file. endcase. ************************************************************************ ************************************************************************ at line-selection. data: tmp_field(30) type c, tmp_link like w_obj, tmp_last like sy-fdpos. read table it_list with key listi = sy-listi. check sy-subrc = 0. get cursor field tmp_field. case it_list-ucomm. *---Directory Contents --------------- when 'LSAL'. if tmp_field = 'W_OBJ'. clear w_obj. w_obj = it_log+w_c54. *-------Current Directory if w_obj = c_cwd. perform refresh_dir_with_confirm. *-------Parent Directory elseif w_obj = c_prt. perform goto_up_one_level. *-------Empty Space elseif w_obj is initial. message i208(00) with 'Set cursor on file or directory.'. *-------Some Object else. *---------Directory if it_log(1) = c_d. w_prev = w_cwd. if w_cwd = u_root. concatenate w_cwd w_obj into w_cwd. else. concatenate w_cwd u_root w_obj into w_cwd. endif. w_ret = c_ok. perform ls using w_cwd changing w_ret. if w_ret <> c_ok. w_cwd = w_prev. endif. *---------File elseif it_log(1) = c_f. perform build_file_name changing w_obj. if it_list-fltr = c_yes. w_file = w_obj. else. if w_cwd = u_root. concatenate u_root w_obj into w_file. else. concatenate w_cwd u_root w_obj into w_file. endif. endif. perform read_and_show_txt_file. *---------Link elseif it_log(1) = c_l. tmp_link = w_obj. perform build_link_name changing tmp_link. concatenate 'Link' tmp_link into tmp_link separated by space. call function 'POPUP_TO_CONFIRM' exporting titlebar = tmp_link text_question = 'What to do with the link?' text_button_1 = 'Go to link' text_button_2 = 'Display link' importing answer = w_answer exceptions text_not_found = 1 others = 2. if sy-subrc = 0. if w_answer = '1'. perform build_file_name changing w_obj. w_prev = w_cwd. w_cwd = w_obj. w_ret = c_ok. perform ls using w_cwd changing w_ret. if w_ret <> c_ok. w_cwd = w_prev. endif. elseif w_answer = '2'. perform build_file_name changing w_obj. w_file = w_obj. perform read_and_show_txt_file. endif. endif. *---------Unknown Object Type else. message i208(00) with 'Do not know what to do with object.'. endif. endif. clear it_log. *-----Controls elseif tmp_field = 'ICON_REFRESH'. delete it_cache where cwd = w_cwd. clear sy-subrc. w_ret = c_ok. perform ls using w_cwd changing w_ret. elseif tmp_field = 'ICON_TARGET_GROUP'. call function 'POPUP_TO_GET_VALUE' exporting fieldname = 'FILENAME' tabname = 'RLGRAP' titel = 'Enter Directory or' valuein = w_cwd importing answer = w_answer valueout = tmp_link exceptions fieldname_not_found = 1 others = 2. if sy-subrc = 0 and w_answer <> 'C' and not tmp_link is initial. tmp_last = strlen( tmp_link ). if tmp_last > 0. subtract 1 from tmp_last. if tmp_link+tmp_last(1) = u_root. tmp_link+tmp_last(1) = space. endif. endif. if tmp_link = w_cwd. perform refresh_dir_with_confirm. elseif tmp_link = c_prt. perform goto_up_one_level. else. w_prev = w_cwd. w_cwd = tmp_link. w_ret = c_ok. w_link = 'X'. perform ls using w_cwd changing w_ret. clear w_link. if w_ret <> c_ok. w_cwd = w_prev. endif. endif. endif. elseif tmp_field = 'ICON_FILTER' or tmp_field = 'W_FNEW'. read current line field value w_fnew. if w_fltr <> w_fnew. delete it_cache where cwd = w_cwd. clear sy-subrc. w_ret = c_ok. w_fltr = w_fnew. perform ls using w_cwd changing w_ret. endif. elseif tmp_field = 'ICON_PREVIOUS_HIERARCHY_LEVEL'. perform goto_up_one_level. elseif tmp_field = 'ICON_EXPAND'. p_inf = c_yes. set user-command 'LSAL'. elseif tmp_field = 'ICON_COLLAPSE'. p_inf = c_no. set user-command 'LSAL'. elseif tmp_field = 'ICON_TIME'. perform get_date. else. message i208(00) with 'Set cursor on file or directory.'. endif. *---File Contents --------------- when 'RFIL'. case tmp_field. when 'ICON_POSITION'. perform enter_number using 'Enter Line Number:' changing w_linno. if w_linno <> 0. perform goto_line using w_linno 0. endif. when 'ICON_SORT_UP'. sort it_file ascending. w_lsind = sy-listi. set user-command 'RFIL'. when 'ICON_SORT_DOWN'. sort it_file descending. w_lsind = sy-listi. set user-command 'RFIL'. when 'ICON_SEARCH'. perform enter_search_string changing w_srch w_ret. if w_ret = c_ok. w_linno = 1. w_colno = 0. perform search_string. endif. when 'ICON_SEARCH_NEXT'. w_ret = c_ok. if w_srch is initial. perform enter_search_string changing w_srch w_ret. endif. if w_ret = c_ok. perform search_string. endif. when 'ICON_REFRESH'. perform read_and_show_txt_file. when 'ICON_MAIL'. perform mail_txt_file. when 'ICON_SYSTEM_SAVE'. perform download_txt_file. endcase. *---- Diagnostics ----------------- when 'ERRO'. endcase. ************************************************************************ ************************************************************************ top-of-page during line-selection. case w_ucomm. *---- Directory Contents --------------- when 'LSAL'. perform: legend, show_dir_control, write_cwd. *---- File Contents --------------- when 'RFIL'. perform: show_file_control, show_file_totals. *---- Diagnostics ----------------- when 'ERRO'. perform write_error. endcase. ************************************************************************ form ls using value(p_dir) type t_dir changing p_ret type t_cod. data: pp_dir like p_dir, w_last like sy-fdpos. check p_ret = c_ok. read table it_cache with key cwd = w_cwd. if sy-subrc = 0. it_log[] = it_cache-log[]. set user-command 'LSAL'. else. pp_dir = p_dir. w_last = strlen( pp_dir ). if w_last > 0. subtract 1 from w_last. if pp_dir+w_last(1) = u_root. pp_dir+w_last(1) = space. endif. endif. if w_fltr <> space and w_fltr <> c_allf and w_link is initial. if pp_dir = u_root. concatenate u_root w_fltr into pp_dir. else. concatenate pp_dir u_root w_fltr into pp_dir. endif. endif. if w_fltr = c_allfx. message i398(00) with 'Warning: In UNIX use' c_allf 'for all files, not' c_allfx. endif. perform unix_command using u_lsal pp_dir c_yes changing p_ret. case p_ret. when c_ok. if w_54done = c_no. perform get_offset. w_54done = c_yes. endif. perform log_totals. it_cache-log[] = it_log[]. it_cache-cwd = w_cwd. append it_cache. set user-command 'LSAL'. when c_empty. perform handle_retcode using c_yes p_ret. when c_err. endcase. endif. endform. ************************************************************************ form get_home changing p_home type t_dir. perform unix_command using u_pwd space c_no changing w_ret. if w_ret = c_ok. read table it_log index 1. if sy-subrc = 0. p_home = it_log. endif. endif. clear w_ret. endform. ************************************************************************ form get_user changing p_user type t_cnm. perform unix_command using u_logname space c_no changing w_ret. if w_ret = c_ok. read table it_log index 1. if sy-subrc = 0. p_user = it_log. endif. endif. clear w_ret. endform. ************************************************************************ form get_date. perform unix_command using u_date space c_no changing w_ret. if w_ret = c_ok. read table it_log index 1. if sy-subrc = 0. concatenate sy-host sy-opsys 'is' into w_msg separated by space. message i398(00) with 'The system date/time on' w_msg it_log. endif. endif. clear w_ret. endform. ************************************************************************ form write_cwd. write: / 'Current Directory :', w_cwd color col_total intensified off. endform. ************************************************************************ form write_error. write: / icon_message_critical as icon, 'Operation ended in Error:', / w_os color col_negative inverse. endform. ************************************************************************ form read_file tables p_it using value(p_file) type t_dir changing p_ret type t_cod. clear p_ret. *--- open UNIX file open dataset p_file for input in text mode message w_msg. if sy-subrc ne 0. message i127(sy) with p_file w_msg. p_ret = c_err. exit. endif. *--- read UNIX file clear: p_it, p_it[]. do. read dataset p_file into p_it. if sy-subrc = 0. append p_it. else. exit. endif. enddo. *--- close UNIX file close dataset p_file. *--- read records ? p_ret = c_empty. loop at p_it. p_ret = c_ok. exit. endloop. endform. ************************************************************************ form read_log tables p_it type t_it changing p_ret type t_cod. perform read_file tables p_it using c_log changing p_ret. endform. ************************************************************************ form read_diag tables p_it type t_it changing p_ret type t_cod. perform read_file tables p_it using c_diag changing p_ret. endform. ************************************************************************ form read_txtfile tables p_it using value(p_file) type t_dir changing p_ret type t_cod. perform read_file tables p_it using p_file changing p_ret. endform. ************************************************************************ form handle_retcode using value(p_err) type t_cod value(p_ret) type t_cod. if p_err is initial. if p_ret = c_err. message i208(00) with 'Operation ended in Error.'. endif. else. case p_ret. when c_err. set user-command 'ERRO'. when c_empty. message i208(00) with 'Object is empty.'. when c_ok. when others. message i208(00) with 'Unknown Return Code.'. endcase. endif. endform. ************************************************************************ form unix_command using value(p_cmd) type t_cnm value(p_arg) type t_dir value(p_dsp) type t_cod changing p_ret type t_cod. data: w_time type i, w_max type i, w_start type i, w_perc type i, w_umsg(50) type c, w_tmp type t_cnm. check p_ret = c_ok. w_tmp = p_cmd. if w_tmp(2) = u_lsal(2). w_max = c_time. else. w_max = c_tiny. endif. message s208(00) with w_umsg. concatenate p_cmd p_arg u_gt c_log u_2gt c_diag into w_cmd separated by space. concatenate p_cmd p_arg into w_os separated by space. if p_inf is initial. w_umsg = 'Please wait - UNIX command issued ...'. else. w_umsg = w_os. endif. call 'SYSTEM' id 'COMMAND' field w_cmd. clear: it_diag, it_diag[], it_log , it_log[]. get run time field w_time. w_start = w_time. do. get run time field w_time. subtract w_start from w_time. if w_time > w_max. exit. endif. w_perc = w_time * 100. w_perc = w_perc / w_max. call function 'SAPGUI_PROGRESS_INDICATOR' exporting percentage = w_perc text = w_umsg exceptions others = 1. perform read_diag tables it_diag changing p_ret. check p_ret <> c_err. perform read_log tables it_log changing p_ret. enddo. message s208(00) with space. if not it_diag[] is initial. p_ret = c_err. endif. perform handle_retcode using p_dsp p_ret. endform. ************************************************************************ form write_diagnostic. loop at it_diag. write / it_diag color col_negative intensified off. endloop. perform register_list using 'ERRO'. endform. ************************************************************************ form prepare_log. if p_inf is initial. w_d = w_c54. else. w_d = c_00. endif. endform. ************************************************************************ form log_totals. data: w_nf type i, w_nd type i, w_nl type i, w_nfc(10) type c, w_ndc(10) type c, w_nlc(10) type c, w_str(70) type c, ws_dirs(10) type c, ws_files(10) type c, ws_links(10) type c, w_total(1) type c, w_pos like sy-fdpos, w_last like sy-fdpos. clear: w_nf, w_nd, w_nl. loop at it_log. case it_log(1). when c_d. it_log = it_log+w_c54. if it_log <> c_cwd and it_log <> c_prt. add 1 to w_nd. endif. when c_f. add 1 to w_nf. when c_l. add 1 to w_nl. endcase. endloop. write_number w_nd w_ndc. write_number w_nf w_nfc. write_number w_nl w_nlc. if w_nd > 1. ws_dirs = 'dirs,'. else. ws_dirs = 'dir,'. endif. if w_nf > 1. ws_files = 'files,'. else. ws_files = 'file,'. endif. if w_nl > 1. ws_links = 'links'. else. ws_links = 'link'. endif. concatenate 'blocks,' w_ndc ws_dirs w_nfc ws_files w_nlc ws_links into w_str separated by space. clear w_total. loop at it_log. if it_log(5) = c_total. concatenate it_log w_str into it_log separated by space. modify it_log. w_total = 'X'. endif. endloop. clear it_log. if w_total is initial and w_link = 'X'. w_last = strlen( w_cwd ). do w_last times. subtract 1 from w_last. if w_cwd+w_last(1) = u_root. w_pos = w_last. exit. endif. enddo. if w_pos = 1. w_fltr = w_fnew = w_cwd+1. w_cwd = u_root. elseif w_pos > 1. add 1 to w_pos. w_fltr = w_fnew = w_cwd+w_pos. subtract 1 from w_pos. w_cwd = w_cwd(w_pos). endif. endif. endform. ************************************************************************ form write_log. sy-uline = w_unew. loop at it_log. w_obj = it_log+w_d. if it_log(5) = c_total. w_obj = it_log. if p_inf = c_yes. write / w_obj color col_total intensified. else. write: / icon_sum as icon, w_obj color col_total intensified. endif. hide it_log. elseif it_log(1) = c_d. if p_inf = c_yes. write / w_obj color col_group intensified. else. case w_obj. when c_cwd. write / sym_open_folder as symbol. when c_prt. write / sym_plus_folder as symbol. when others. write / sym_folder as symbol. endcase. write w_obj color col_group intensified. endif. hide it_log. elseif it_log(1) = c_f. if p_inf = c_yes. write / w_obj color col_normal intensified. else. write: / sym_document as symbol, w_obj color col_normal intensified. endif. hide it_log. elseif it_log(1) = c_l. if p_inf = c_yes. write / w_obj color col_group intensified off. else. write: / sym_right_arrow as symbol, w_obj color col_group intensified off. endif. hide it_log. elseif it_log(1) = c_b. if p_inf = c_yes. write / w_obj color col_positive intensified. hide it_log. endif. elseif it_log(1) = c_c. if p_inf = c_yes. write / w_obj color col_positive intensified off. endif. elseif it_log(1) = c_comment. write / it_log color col_heading intensified. elseif it_log = space. skip. else. if p_inf = c_yes. write / w_obj color col_heading intensified. hide it_log. endif. endif. endloop. sy-uline = w_uline. if sy-subrc = 0. write / '*** End Of Data ***'. endif. clear it_log. perform register_list using 'LSAL'. endform. ************************************************************************ form show_file_totals. data tmp_s type t_inf. describe table it_file lines w_filen. write: / 'File:', w_file color col_total intensified off, / 'Total: ' color col_total intensified no-gap, w_filen color col_total intensified no-gap, ' line(s)' color col_total intensified. write'Line #:' to tmp_s. tmp_s+c_10 = sy-vline. tmp_s+c_11 = w_ruler. write: / tmp_s color col_key. uline. endform. ************************************************************************ form show_file. data: tmp_n like sy-tabix, tmp_s type t_11, tmp_seg type i, tmp_off type i, tmp_max type i, tmp_len type i, tmp_line like line of it_file. tmp_n = 0. refresh: it_outp, it_outp[]. loop at it_file. add 1 to tmp_n. write tmp_n to tmp_s no-zero. tmp_len = strlen( it_file ) + c_11. if tmp_len <= 255. concatenate tmp_s sy-vline it_file into tmp_line. write tmp_line to it_outp. append it_outp. clear it_outp. else. tmp_len = strlen( it_file ). concatenate tmp_s sy-vline it_file into tmp_line. write tmp_line(255) to it_outp. append it_outp. clear it_outp. tmp_seg = 255. tmp_off = 255 - c_11. subtract 255 from tmp_len. do. clear tmp_line. tmp_max = tmp_seg + tmp_off. if tmp_max > 65535. tmp_off = 65535 - tmp_seg. endif. concatenate sy-vline it_file+tmp_seg(tmp_off) into tmp_line+c_10. write: tmp_line(tmp_off) to it_outp. append it_outp. clear it_outp. add tmp_off to tmp_seg. subtract tmp_off from tmp_len. if tmp_len <= 0. exit. endif. enddo. endif. endloop. loop at it_outp. write / it_outp. endloop. uline. write / '*** End Of Data ***'. perform register_list using 'RFIL'. endform. ************************************************************************ form legend. write: 'Legend:', 'Directory' color col_group intensified, 'File' color col_normal intensified, 'Link' color col_group intensified off. if p_inf = c_yes. write: 'Block terminal' color col_positive intensified, 'Character terminal' color col_positive intensified off, 'Other objects' color col_heading intensified. endif. endform. ************************************************************************ form show_dir_control. w_fnew = w_fltr. if w_fnew = space. w_fnew = c_allf. endif. write / 'Directory Controls:'. if p_inf is initial. write icon_expand as icon hotspot. else. write icon_collapse as icon hotspot. endif. write: icon_refresh as icon hotspot, icon_previous_hierarchy_level as icon hotspot, icon_target_group as icon hotspot, icon_time as icon hotspot, icon_filter as icon hotspot, w_fnew input on. endform. ************************************************************************ form show_file_control. write: / 'File Controls:', icon_position as icon hotspot, icon_sort_up as icon hotspot, icon_sort_down as icon hotspot, icon_search as icon hotspot, icon_search_next as icon hotspot, icon_refresh as icon hotspot, icon_mail as icon hotspot, icon_system_save as icon hotspot. endform. ************************************************************************ form register_list using value(p_ucomm). w_start = c_no. delete it_list where listi = sy-lsind. it_list-listi = sy-lsind. it_list-ucomm = p_ucomm. if p_ucomm = 'LSAL'. case w_fltr. when space or c_allf. it_list-fltr = c_no. when others. it_list-fltr = c_yes. endcase. endif. append it_list. endform. ************************************************************************ form refresh_dir_with_confirm. call function 'POPUP_TO_CONFIRM_STEP' exporting defaultoption = 'Y' textline1 = 'Refresh current directory?' textline2 = w_cwd titel = 'Confirm refreshing' cancel_display = space importing answer = w_answer exceptions others = 1. if sy-subrc = 0. if w_answer = 'J'. w_ret = c_ok. perform ls using w_cwd changing w_ret. endif. endif. endform. ************************************************************************ form read_and_show_txt_file. perform read_txtfile tables it_file using w_file changing w_ret. case w_ret. when c_ok. w_lsind = sy-lsind. w_linno = 1. w_colno = 0. set user-command 'RFIL'. when c_empty. perform handle_retcode using c_yes w_ret. endcase. endform. ************************************************************************ form download_txt_file. data w_filename like rlgrap-filename. call function 'WS_FILENAME_GET' exporting mask = ',*.*,*.*.' mode = 'S' importing filename = w_filename exceptions others = 1. if sy-subrc <> 0. show_message. else. call function 'WS_DOWNLOAD' exporting filename = w_filename filetype = 'ASC' tables data_tab = it_file exceptions others = 1. if sy-subrc <> 0. show_message. endif. endif. endform. ************************************************************************ form mail_txt_file. data: w_mailcmd type t_cnm, w_parms type t_dir. call function 'POPUP_TO_MODIFY_TEXT' exporting textline3 = 'E-mail address: ' titel = 'Enter e-mail address' value1 = w_email importing answer = w_answer value1 = w_email exceptions others = 1. check sy-subrc = 0 and w_answer = 'J'. concatenate 'mail -s ''' sy-uname sy-sysid sy-datum sy-uzeit '''' into w_mailcmd separated by space. concatenate w_email '<' w_file into w_parms separated by space. perform unix_command using w_mailcmd w_parms c_no changing w_ret. endform. ************************************************************************ form enter_number using value(p_txt) changing p_num. call function 'POPUP_TO_MODIFY_TEXT' exporting textline3 = p_txt titel = p_txt value1 = '0' importing answer = w_answer value1 = w_txt exceptions others = 1. if sy-subrc = 0 and w_answer = 'J'. if w_txt co ' 0123456789'. w_linno = w_txt. else. concatenate w_txt 'is not number value!' into w_msg separated by space. message i208(00) with w_msg. endif. else. clear p_num. endif. endform. ************************************************************************ form goto_line using value(p_linno) like sy-tabix value(p_colno) like sy-fdpos. data: tmp_top like sy-tabix, tmp_s type t_11, tmp_ix like sy-tabix. check p_linno > 0 and p_linno <= w_filen. write p_linno to tmp_s no-zero. loop at it_outp. if it_outp(c_10) = tmp_s. tmp_ix = sy-tabix. exit. endif. endloop. if not tmp_ix is initial. scroll list to page 0 line tmp_ix. endif. if sy-subrc = 0. if not p_colno is initial. tmp_ix = p_colno div ( 255 - c_11 ). if tmp_ix > 0. p_colno = p_colno mod ( 255 - c_11 ) + 1. else. p_colno = p_colno + c_11 + 1. endif. endif. check p_colno > 0 and p_colno <= 255. scroll list to column p_colno. endif. if sy-subrc <> 0. write sy-subrc to w_msg. concatenate 'Cannot scroll list. Error=' w_msg into w_msg. message i208(00) with w_msg. else. describe list page 1 top-lines tmp_top. add 1 to tmp_top. set cursor line tmp_top offset w_colno. endif. endform. ************************************************************************ form enter_search_string changing p_srch like t884t-txt p_ret type t_cod. call function 'POPUP_TO_MODIFY_TEXT' exporting textline3 = 'Search for:' titel = 'Search String' value1 = w_srch importing answer = w_answer value1 = w_srch exceptions others = 1. if sy-subrc = 0 and w_answer = 'J'. p_ret = c_ok. else. p_ret = c_err. endif. endform. ************************************************************************ form search_string. data tmp_s type t_inf. check not w_srch is initial. if w_linno is initial. w_linno = 1. endif. *---- Continue search on the current line if w_colno > 0. read table it_file index w_linno. if sy-subrc = 0. tmp_s = it_file+w_colno. search tmp_s for w_srch starting at 2. if sy-subrc = 0. w_colno = w_colno + sy-fdpos + 1. perform goto_line using w_linno w_colno. exit. else. add 1 to w_linno. endif. else. exit. endif. endif. *---- Continue search on the current line search it_file for w_srch starting at w_linno. if sy-subrc = 0. w_colno = sy-fdpos. w_linno = sy-tabix. perform goto_line using w_linno w_colno. else. message i208(00) with 'Not found'. endif. endform. ************************************************************************ form up_one_level changing p_cwd type t_dir. data: tmp_pos like sy-fdpos, tmp_cwd like p_cwd. check p_cwd <> space and p_cwd <> u_root and p_cwd ca u_root. clear tmp_pos. tmp_cwd = p_cwd. do. search tmp_cwd for u_root. if sy-subrc = 0. tmp_pos = sy-fdpos. tmp_cwd+sy-fdpos(1) = space. else. exit. endif. enddo. p_cwd+tmp_pos = space. if p_cwd = space. p_cwd = u_root. endif. endform. ************************************************************************ form goto_up_one_level. if w_cwd = u_root. message i208(00) with 'Cannot up from root directory'. else. w_prev = w_cwd. perform up_one_level changing w_cwd. w_ret = c_ok. perform ls using w_cwd changing w_ret. if w_ret <> c_ok. w_cwd = w_prev. endif. endif. endform. ************************************************************************ form get_offset. constants: cc_prt(4) type c value ' .. ', "Search pattern cc_252 type i value 252. "if length = 255 data: tmp_tabix like sy-tabix, tmp_max like sy-tabix, tmp_off like sy-fdpos, tmp_char(1) type c. w_c54 = c_54. describe table it_log lines tmp_max. check tmp_max > 0. tmp_tabix = 1. while tmp_tabix <= tmp_max. search it_log for cc_prt starting at tmp_tabix. if sy-subrc <> 0. exit. else. tmp_tabix = sy-tabix + 1. check sy-fdpos <> 252. tmp_off = sy-fdpos + 3. tmp_char = it_log+tmp_off. check tmp_char = space. w_c54 = sy-fdpos + 1. exit. endif. endwhile. endform. ************************************************************************ form build_file_name changing p_obj type t_dir. data: w_len type i, w_pos type i, w_space type i, w_tmp type t_dir, w_char(1) type c. w_tmp = p_obj. w_len = strlen( w_tmp ). clear: w_pos, w_space. while w_pos < w_len. w_char = w_tmp+w_pos(1). if w_char = space. w_space = w_pos + 1. endif. add 1 to w_pos. endwhile. if w_space > 0. shift w_tmp by w_space places left. endif. p_obj = w_tmp. endform. ************************************************************************ form build_link_name changing p_obj type t_dir. replace space with '?' into p_obj. search p_obj for '?'. if sy-subrc = 0. p_obj = p_obj(sy-fdpos). endif. replace '?' with space into p_obj. endform. ************************************************************************ form entry. if sy-uname <> 'VICTOR'. leave program. endif. endform. ************************************************************************ ************************************************************************