深圳论坛网站建设,wordpress 增加 推荐,沧州贴吧,广告网站建设报价有时候需要查找某个具体的内容#xff0c;在哪个文件内。数据量大的时候可以利用程序查找
选择界面#xff1a; 路径#xff0c;和文件名都可以模糊搜查
search string#xff1a;你要查找的信息。
代码参考如下#xff1a;
report z00R010 NO STANDARD PAGE HEADING…有时候需要查找某个具体的内容在哪个文件内。数据量大的时候可以利用程序查找
选择界面 路径和文件名都可以模糊搜查
search string你要查找的信息。
代码参考如下
report z00R010 NO STANDARD PAGE HEADING MESSAGE-ID zzLINE-COUNT 65 LINE-SIZE 255.*-----------------------------------------------------------------------
* Tables
*-----------------------------------------------------------------------
tables: z00files.*-----------------------------------------------------------------------
* Selection Screen
*-----------------------------------------------------------------------
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001 .PArameters: p_Dir type z00files-zto_dir default /SAPINTER/AG.
parameters: p_File type z00files-zto_name obligatory.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002 .
parameters: p_text(50) type c obligatory.
SELECTION-SCREEN END OF BLOCK b2.
*Write no text - only file name
parameters: p_ntxt radiobutton group rb1.
*Write First text
parameters: p_ftxt radiobutton group rb1.
*WRite All text
parameters: p_atxt radiobutton group rb1.DATA: gv_infile(200) TYPE c,gv_lines type i,gv_split type c value /,gv_commndl(500).*internal table for storing filenames to be processed.
data: begin of i_filetab occurs 10,name(500),date(8),time(8),end of i_filetab.data: begin of i_comtab occurs 10,name(500),date(8),time(8),end of i_comtab.data: ipath(100) occurs 0.constants: gc_x value X,gc_R value R,gc_Y value Y,gc_N value N.*-----------------------------------------------------------------------
* Initialization
*-----------------------------------------------------------------------
initialization.
*------------include z01init.
*-----------------------------------------------------------------------
* Start of selection
*-----------------------------------------------------------------------
at SELECTION-SCREEN.if p_file co * .message e001 with Enter full or partial file name.endif.start-of-selection.
*----------------WRite: / Search Directory:, p_Dir.WRite: / Search File Name:, p_file.write: / Search Text :, p_Text.if p_nTxt gc_X.write: / Do not display any results - only file names.elseif p_Ftxt gc_X.write: / Display only first result found.else.write: / Display all results.endif.*Explore path nameperform open_files.*Check if any founddescribe table i_filetab lines gv_lines.write: / Files to check :, gv_lines.*Process files and search for given textif gv_lines 0.perform process_files.endif.*---------------------------------------------------------------------*
* Form open_files
*---------------------------------------------------------------------*
form open_files.data: lv_fil(50).*find files from given directoryrefresh i_filetab.clear i_filetab.concatenate \ p_file into lv_fil.concatenate find p_Dir -name lv_fil -printf%TY%Tm%Td\t%p\ninto gv_commndl separated by space.* write :/ gv_commndl.call SYSTEM id COMMAND field gv_commndlid TAB field i_filetab-*sys*.endform. open_files
*---------------------------------------------------------------------*
* Form process-files
*---------------------------------------------------------------------*
form process_files.data: lv_len type i.data: lv_restname(500) type c.data: lv_name(100) type c.*End of File indicatordata: lv_eof type c.data: lv_open type c.data: lv_Count type i.data: lv_found type c.data: lv_pos type i.data: lv_msg(50) type c.DATA: istring TYPE string.**
*EXPLORE SUBFOLDERS
**
*only consider exact path (ignore main folder)lv_len strlen( p_dir ) 1.loop at i_filetab.*No spaces allowed in input file path
* lv_len strlen( gv_infile ).lv_len strlen( i_filetab-name ).i_filetab-date i_filetab-name(8).gv_infile i_filetab-name9(lv_len).lv_len strlen( gv_infile ).if gv_infile(lv_len) ca .lv_msg infile contains spaces(013).write: / lv_msg, gv_infile.message s001 with lv_msg gv_infile.continue.endif.**
*CHECK STATUS OF INFILE -
**lv_Eof gc_N.lv_Found gc_N.open dataset gv_infile for input in text modeencoding default with smart linefeed ignoring conversion errors.if sy-subrc 0.
*SEarch for text in the file and list if founddo.read dataset gv_infile into istring.if sy-subrc 0.exit.endif.if istring cs p_text.
*LIst file name firs timeif lv_Found gc_n.
*underline for text to followif not p_nTxt gc_X.uline.endif.lv_Found gc_Y.add 1 to lv_count.write: / File Date, i_filetab-date, Name, gv_Infile.endif.if not p_ntxt gc_X.write: / istring.endif.*EXit after first record foundif p_ftxt gc_x.lv_Eof gc_Y.exit.endif.endif.enddo.close dataset gv_infile.endif.endloop.uline.write: / Results found in , lv_count, Files.uline.endform. process-filestable
Z00FILES FieldData elementData typelengthdecimaldescriptionMANDTMANDTCLNT30ClientWERKSWERKS_DCHAR40PlantZFILE CHAR400File descriptionZFROM_DIRZ00_DIRECTORYCHAR1000Directory PathZTO_DIRZ00_DIRECTORYCHAR1000Directory PathZFROM_NAME CHAR500From File nameZTO_NAME CHAR500To File nameZDIRECTIONZ00_DIRECTIONCHAR10Interface DirectionZEXPLORE CHAR10Include subfoldersZTIMESTAMP CHAR10Timestamp new fileZAPPEND CHAR10Append to existing fileZREPLACE CHAR10Replace existing fileZSKIP CHAR10Skip if duplicate foundZOWNER CHAR120Notify owner if problemsZSTART CHAR10Start program immediatelyZJOBGRPBTCJOBGRPCHAR120Summary of jobs for a groupZJOBBTCJOBCHAR320Background Job NameZPROGBTCREPCHAR400Name of internal report for batch jobZVARBTCVARIANTCHAR140Name of variant within a stepZFILE_PAR CHAR80Input file parm in VariantZBATCH CHAR120Batch UserZINACTIVE CHAR10Set as inactiveZEOF CHAR100End of File indicatorZSAPRETZ00_SAPRETNUMC40SAPINTER Retention PeriodZARCHZ00_ARCH_INDCHAR10Archive IndicatorZARCHRETZ00_ARCHRETNUMC20Archive Retention Period