151
SAP File Explorer by António César Software Developer, SAP Senior Consultant I started as an IBM AS400 software developer in COBOL and RPG, having changed later for SAP. My main focus lies in software development for IS-U, I’ve worked as a software developer for different companies. You can reach me at my e-mail [email protected]. With SAP File Explorer I tried to mimic the Windows Explorer in the SAP environment. It’s main purpose is to access the server system files using t he SAP GUI, much in the way transaction AL11 does but with a friendlier user interface This is a testing tool and not much effort was put in the authority issues, so you may want to consider some changes in this if you plan to use it otherwise. Some other considerations regarding this tool As a testing tool it hasn’t undergone a serious or extensive testing procedure yet so, some polishing may be required as well. Also, as the main reason for working with files in SAP is to interface with external tools and providers, this tool main purpose is to function as a F4 Help Input to other applications, and that’s the reason why I created it as a function module. And as it uses SAP HTML controls it will only work on front- end platforms on which Microsoft Internet Explorer version 4.0 (or higher) is installed, and as it was created in release 6.20, compatibility issues may arise in previous releases regarding the GUI controls. Note: This document is structured in two parts, the fist one is a brief manual on how to work with the tool, the second one is where you can find the coding and instructions on how to implement it.

SAP File Explorer

  • Upload
    ajcesar

  • View
    1.564

  • Download
    17

Embed Size (px)

DESCRIPTION

Managing files in the SAP Environment.

Citation preview

Page 1: SAP File Explorer

SAP File Explorer

by António César

Software Developer, SAP Senior

Consultant

I started as an IBM AS400 software

developer in COBOL and RPG, having

changed later for SAP. My main focus lies

in software development for IS-U, I’ve

worked as a software developer for different

companies. You can reach me at my e-mail

[email protected].

With SAP File Explorer I tried to mimic the Windows Explorer

in the SAP environment.

It’s main purpose is to access the server system files using the

SAP GUI, much in the way transaction AL11 does but with a

friendlier user interface

This is a testing tool and not much effort was put in the

authority issues, so you may want to consider some changes in

this if you plan to use it otherwise.

Some other considerations regarding this tool

As a testing tool it hasn’t undergone a serious or extensive

testing procedure yet so, some polishing may be required as

well.

Also, as the main reason for working with files in SAP is to

interface with external tools and providers, this tool main

purpose is to function as a F4 Help Input to other applications,

and that’s the reason why I created it as a function module.

And as it uses SAP HTML controls it will only work on front-

end platforms on which Microsoft Internet Explorer version 4.0

(or higher) is installed, and as it was created in release 6.20,

compatibility issues may arise in previous releases regarding the

GUI controls.

Note: This document is structured in two parts, the fist one is a brief

manual on how to work with the tool, the second one is where you can

find the coding and instructions on how to implement it.

Page 2: SAP File Explorer

SAP File Explorer Release.620

19 March 2009 Pag. 2

PART 1 – Using SAP File Explorer

Introducing SAP File Explorer GUI

The tool consists of a function module that can be

called with no parameters passed or by passing a

defined path like for example “/tmp/” for an

UNIX or AIX system or “c:\temp\” for a

Windows system.

The default path will always be the root and the

desired displayed path will be shown as a child of

the root dir in the respective sequence.

Initiating the test for example in the Function

Modules test environment, passing the path

“/tmp/ADM/” as parameter as shown below.

Figure 1 – Function Modules test environment, note that the UNIX and AIX systems are case sensitive so in case a wrong path is

passed the default root path is displayed

The SAP File Explorer will open in the desired path as shown below.

Figure 2 – SAP File Explorer screen, the folder displayed is ADM in “/tmp/”, note that “/” is the root folder

Page 3: SAP File Explorer

SAP File Explorer Release.620

19 March 2009 Pag. 3

Tool Details

The SAP File Explorer consists of a single screen,

with a layout similar to the Windows Explorer

and contain the fallowing elements:

Address, Tree Panel, User Options and Folder

Panel.

These elements comprise themselves other

sub elements discussed later on.

Figure 3 – SAP File Explorer elements

These element will be discussed later on in more

detail.

- Address

Seen at the top left, shows the complete path

address of the folder currently being displayed in

the Folder Panel and changes according to the

folder, note that it will only change if you double

click the desired folder, selecting it is not enough.

- Tree Panel

Seen at the left, shows the tree structure of the

server file system, and starts always by the root

folder, in this case “/”.

- User Options

At the bottom left, are the tree options user have,

the Cancel (F12), the Continue (F8) and Local PC

(F5).

- Folder Panel

At the right pane, shows the content of the folder

selected on the Tree Panel. By default if no path is

passed to the function module, this panel will

display the root folder.

Note: The SAP File Explorer screen consist of a single

Custom Control element, used to output the Folder

Panel ALV Grid. The Tree Panel is displayed using

class cl_gui_docking_container - dock_at_left.

Page 4: SAP File Explorer

SAP File Explorer Release.620

19 March 2009 Pag. 4

Element Depiction

Address

Figure 4 – Address display

Much in the way of Windows Explorer, it shows

the folder complete path of the folder displayed

on the right Folder Panel, and will change

according to the one being displayed at any

specific moment.

Tree Panel

Figure 5 – Tree Panel pane

The Tree Panel is the main interaction element of

the SAP File Explorer tool and is composed of

two other elements.

- Tree Header

Shows the operation system your SAP server is

running on, in this case an AIX server. It also

serves to change to the Search screen when

clicked which will be discussed later on.

- Tree Panel

This panel as said before in combination with the

Folder Panel will be your main interaction

elements in the tool and works much like the one

in Windows Explorer.

It was build using class cl_gui_alv_tree, to which

I removed the columns displayed.

If you click the arrow left of each folder, the

related folder will expand showing all sub folders,

or none if it’s empty or contain only files, as the

case seen in figure 6.

Figure 6 – Folder expander arrow

Page 5: SAP File Explorer

SAP File Explorer Release.620

19 March 2009 Pag. 5

If you double click the folder icon, as seen in

figure 7, the Tree Panel and the clicked folder will

remain unchanged but the Folder Panel will

display the content of that folder and the Address

will display the complete path to that specific

folder as seen in figure 8. Note that if you double

click the name of the folder instead (doc in the

example figure 7), it wont work.

Figure 7 – Folder Icon

Figure 8 – Folder content display

If you click in the Tree Header, the screen will

change to the Search Screen, as seen in figure 9.

The Search Screen will be discussed later on.

Figure 9 – Tree Header

Page 6: SAP File Explorer

SAP File Explorer Release.620

19 March 2009 Pag. 6

Figure 10 - Search Screen

Folder Panel

Figure 11 – Folder Panel detail

Page 7: SAP File Explorer

SAP File Explorer Release.620

19 March 2009 Pag. 7

Figure 11 shows the detail of the Folder Panel,

this is the second most important element of the

tool and is where the content of the folder is

displayed.

It’s a simplified ALV Grid build using class

cl_gui_alv_grid, so it retains some of the

restrictions of the normal grids like for example

the single cell selection.

This panel is comprised of the Column headers

and the column contents.

It as five columns and they are:

- Icon

This column displays the most appropriated icon I

could find within SAP to display the related item.

(This icon display is set in an include form named

“prepare_display_layout”, feel free to change it if

you think it’s not appropriated…)

- Name

This column displays the names of the files or

folders respectively.

- Size

Shows the size of the file or folder in bytes.

- Type

Shows the type of the item displayed, if it is a

folder for example it will display “File Folder”, if

it is a PDF file it will display “Adobe Acrobat

Document” and so on.(This is also done in the

“prepare_display_layout” form)

- Date Modified

This is a time stamp type of field and shows the

date and time the item was last modified.

As you can see by figure 10 this column headers

change according to the screen you are in, on the

search screen the columns are slightly different,

and will be discussed later.

Similar to Windows Explorer these column

headers also serve another purpose, they can be

used to sort ascending and descending the content

of the folder when clicked.

Figure 12 – Column sort descending and ascending

As you can see in figure 12, the current sort

column and order is recognized by the red arrow

at the top right of the respective column and the

mouse pointer will change to a small arrow when

clicking the column header.

This sort however is done automatically by the

class cl_gui_alv_grid, which basically means you

have no control whatsoever over it, and as you

will notice, the sort done when presenting the

folder content for the first time will some times be

different from the one done by the column

because within the program I used in fact 3

columns to do the sort.

The only way to return to the previous sort order

is by double clicking again the folder in the Tree

Panel, which basically refreshes the display.

The Folder Panel will also serve to open the items

displayed.

If you double click the folder “doc” for example,

as seen in figure 13 the folder content will be

displayed as seen in figure 8.

In this case as this is an ALV Grid, it’s irrelevant

where you double click in that line, you can

double click the icon, the name “doc” the size

“4.096 B” and so on, the result will always be the

same.

If in the other hand you intend to enhance the

Folder Panel functionalities, you can always

assign different operations depending on where

you double click by using the parameter

“fuw_e_column” in the form

“double_click_handler”.

Page 8: SAP File Explorer

SAP File Explorer Release.620

19 March 2009 Pag. 8

Figure 13 – Folder Panel, folder double click

If instead you double click an item as seen in

figure 14, either a file or application, the SAP File

Explorer will attempt to open that item in the

front-end environment, as seen in figure 15.

Figure 14 - Folder Panel, item double click

Figure 15 – Folder Panel file display

Some considerations regarding this functionality.

The file will be displayed or the application will

be executed using the method “EXECUTE” of the

class “CL_GUI_FRONTEND_SERVICES” which

basically means that it will only work if your front

end is prepared to deal with the respective item.

If for instance you’re trying to open a PDF

document in the SAP File Explorer and you do

not have Adobe Acrobat Reader or similar

installed in you front-end computer, the document

will not be displayed.

The same will happen if the file does not have an

application associated.

Figure 16 - Folder Panel file display

Page 9: SAP File Explorer

SAP File Explorer Release.620

19 March 2009 Pag. 9

If for example you need to display a file like the

one seen in figure 16, you need create the

association for that kind of file with the correct

application, lets say notepad for instance, in your

front end computer prior to try it on SAP File

Explorer.

Search Screen

Figure 17 – Search Screen Elements

As seen back in figure 9, if you click the Tree

Header, the screen changes to the Search Screen,

which as the name states serves to search and will

be blank when first accessed as seen in figure 10.

This screen contains the fallowing elements.

- Back Button

Takes you back to the Tree Panel. The displayed

folder in the Tree Panel and in the Folder panel

may change depending on the one selected in the

Search Screen.

- Search Folder

Is the field where you select the folder where you

what to perform the search. By default the field

will take the folder that you where displaying

back in the Folder Pane as the search folder but

you can always change it directly in the Search

Screen.

It’s always assumed that the search will be

performed in the folder and all sub folders, so be

careful on where you perform your search as it

may take a considerable amount of time if done in

the root folder for example.

- Search Pattern

It’s where you specify what you want to search. If

your SAP server is running on a UNIX or AIX

system the uppercase or lowercase are relevant.

You can use wildcards but not especial characters

like “\, /, @, #, §” and so on.

Page 10: SAP File Explorer

SAP File Explorer Release.620

19 March 2009 Pag. 10

- Search Button

Performs the search, the same happens if you

press return.

- Search Result Display

The panel list all the files, folders, applications or

otherwise items found matching your search

pattern.

The Search Panel is similar in all functionalities to

the Folder Panel, meaning, you can open files or

folder with double click, you can sort by clicking

the columns headers, being the only difference the

column path which displays the complete path to

that specific item.

Note: To keep the program as simple as possible, as to

dynamic SAP Dynpro programming concerns anyway,

the Search Screen left panel was created using SAP

HTML functionalities in the forms “html_prepare” and

“html_show”.

After concluding your search if you’ve found the

item you where looking for, you can return to the

Tree Panel and yet, the Search Result Display

panel, will remain as long as you do not refresh

the display by double clicking a folder on the Tree

Panel, as seen in Figure 18.

And this is particularly useful because you can

use Drag & Drop functionalities to manage your

files.

Figure 18 - Search Result Display panel with the Tree Panel

Drad & Drop - Copy or Move

As stated before, you can use Drag & Drop

functionalities to move or copy your files from

folder to folder.

Some considerations regarding Drag & Drop:

The fist consideration you need to take regarding

drag & drop in SAP File Explorer is the focus,

meaning, as there is two different objects in the

main screen, the Tree and the ALV Grid (Tree

Panel and Folder Panel) you need to set the focus

on the item you want to drag by clicking on it.

Page 11: SAP File Explorer

SAP File Explorer Release.620

19 March 2009 Pag. 11

So, to Drag & Drop an item you need to do it in

two steps, first you select the item you want to

move or copy by clicking on it and then you click it

again and drag it. If you try to do it in one click

like in the windows environment for instance it

wont work unless the item was already selected.

To move you just need to drag the item to the

desired folder however to copy it, you have to

press the keyboard key (Ctrl) while dragging.

As a security precaution I only programmed the

Drag & Drop for files or applications, not for

folders, but that can be easily changed in the forms

“handle_tree_on_drop” and

“handle_ltree_on_drop”.

Drag & Drop works from Folder Panel to Tree

Panel and within Folder panel itself as long as you

drag the item to a sub folder of the displayed

folder.

As you can not copy or move folders in SAP File

Explorer the Drag is not active for the tree, you can

only drop items onto the tree folders.

That can be changed by passing “X” to the

“dragsrc” parameter for the ADD method in form

“start_drad_drop”.

Drag & Drop wont work when moving or coping

items to the same folder, this is self imposed in the

code and you can change it in the fallowing forms

“handle_tree_on_drop” and

“handle_ltree_on_drop” and

“handle_grid_on_drop”, for the copy that is, be

careful though to correctly manage the different

versions of the item when doing so.

Figure 19 – Mouse Pointer on Move

Figure 20 – Mouse Pointer on Copy (Ctrl Key pressed)

User Options

Figure 21 – User Options

From left to right the user options are:

Figure 22 – Button “Local PC (F5)”

Figure 22 shows button Local PC, this is an On

and Off kind of button that opens and closes

another tree panel but this time to display your

local machine.

This second tree functions exactly the same way

as the server tree and is exactly what you see if

you use Windows Explorer for example.

This may seam redundant as you can manage your

files in a much more practical way by using the

Windows Explorer in the first place, the problem

is when you need to manage files across the two

different platforms as there is no way yet to Drag

& Drop from SAP to external systems. None that

I’m aware of anyway, (correct me if I’m wrong

please!...)

So, the reason behind this second tree is just to be

able to transfer files back and forward between

your front-end computer and the SAP server

computer.

Figure 23 shows the screen when the local pc tree

is displayed.

Page 12: SAP File Explorer

SAP File Explorer Release.620

19 March 2009 Pag. 12

Figure 23 – Local PC display

As you can see in figure 23, once the button Local

PC is pressed the second tree is displayed

showing your local PC.

By default the root folder will always be the

system drive “C:\” but all other accessible drives

are displayed as well and can be browsed.

As for the Folder Panel it now displays the C

drive content but you can freely navigate between

the two systems by double clicking the desired

folder in any of the trees and the Folder Panel will

always display the contend of the selected folder.

Notice as well that the Address has now changed

to display the local pc path. It will also change

accordingly to the selected folder regardless of

which tree folder you double clicked.

Note: The Folder Panel and the Address are refreshed

only when you double click one folder, either in the

Tree Panels or in the Folder Panel, they won’t change

however if you just select the folder with one click.

The Tree Header now displays your PC name, in

this example XP051401

This second Tree Panel retains all functionalities

of the first Tree Panel, mainly:

- Expand and collapse of the folder by clicking

the arrow to the left of the folder.

- Display of the folder content on the Folder

Panel by double clicking it.

- Drag & Drop.

- Change to the Search Screen to search your

local pc by clicking the Tree Header as seen

in figure 24.

The Folder Panel itself also keeps all

functionalities, like the Drag & Drop, the double

click to open files or folders, the sort and when

searching your local pc it will display the search

result as well, as you can see in figure 24.

As for the search screen it also retains all

functionalities as the first one in figure 17 like

Drag & Drop double click to open files or folders

and the sort

The Back Button, the Search Folder Field, the

Search Pattern Field and the Search Button all

work in the same way as for the first screen but

this time for your local pc.

Page 13: SAP File Explorer

SAP File Explorer Release.620

19 March 2009 Pag. 13

Figure 24 – Searching the local pc

Figure 25 – Button Continue (F8)

The Second button on the user options will end

the SAP File Explorer and transfer to the

Exporting Parameters of the function the Path and

Name of the file you selected on the Folder panel.

In this case you just need to select the desired file,

and that is valid for any of the screen, either the

browser screen or the search screen and for any of

the systems Local or Remote.

If for example I’ve pressed keyboard F8 key or

Button Continue in the example of Figure 24 the

result would be Figure 27.

Figure 27 – Function end result display

Page 14: SAP File Explorer

PART 2 – Create SAP File Explorer

SAP File Explorer consist of a function group

with a single function module that calls a single

screen.

I kept this screen as simple as possible as well, it’s

a modal dialog box and consist of a single custom

control named CCONT01

The sizes where calculated to the best fit within

the screen with the docking container, and are the

same for the screen and the control.

Fallowing is a list of all the objects and code required.

Structures

You’ll need to create the fallowing two structures, the first is the internal table for folders and the second is

for the ALV Grid, so it’s advisable that you create the Data Elements for the fields because it’s there that the

columns in the ALV get the names from, that is also the reason way the icon field doesn’t need one.

ZXIS_0X_FILE

Short description: SAP File Explorer List

Field structure

Number of fields: 18

Sum of the field lengths: 1042

Field Name Type Length Data Element Text Domain

DIRNAME CHAR 600 ZXIS_DIRNAME Path CHAR600

NAME CHAR 300 ZXIS_FILNAME Name CHAR300

TYPE_ID CHAR 1 ZXIS_TYPE_ID Type ID CHAR1

FILE_ID CHAR 4 ZXIS_FILE_ID File Id CHAR4

TYPE CHAR 10 ZXIS_TYPE_F Type CHAR10

LEN CHAR 16 ZXIS_LEN Size CHAR16

OWNER CHAR 8 ZXIS_OWNER Owner CHAR8

MTIME CHAR 6 ZXIS_MTIME Mode Time CHAR6

MODE CHAR 9 ZXIS_CMODE Mode CHAR9

USEABLE CHAR 1 ZXIS_USEABLE Useable CHAR1

SUBRC CHAR 4 ZXIS_SUBRC Error CHAR4

ERRNO CHAR 3 ZXIS_ERRNO Error Number CHAR3

ERRMSG CHAR 40 ZXIS_ERRMSG Error Message CHAR40

DATE CHAR 20 ZXIS_DATE Date Modified CHAR20

MOD_DATE CHAR 10 ZXIS_MOD_DATE Date CHAR10

MOD_TIME CHAR 8 ZXIS_MOD_TIME Time CHAR8

SEEN CHAR 1 ZXIS_SEEN Seen CHAR1

CHANGED CHAR 1 ZXIS_CHANGED Changed CHAR1

Page 15: SAP File Explorer

ZXIS_0X_FILE_D

Short description: SAP File Explorer ALV

Field structure

Number of fields: 11

Sum of the field lengths: 1043

Field Name Type Length Data Element Text Domain

ICON CHAR 40 Icon

NAME CHAR 300 ZXIS_FILNAME Name CHAR300

TYPE_ID CHAR 1 ZXIS_TYPE_ID Type ID CHAR1

FILE_ID CHAR 4 ZXIS_FILE_ID File Id CHAR4

TYPE_F CHAR 10 ZXIS_TYPE_F Type CHAR10

TYPE CHAR 50 ZXIS_TYPE_L Type CHAR50

LEN CHAR 16 ZXIS_LEN Size CHAR16

DATE CHAR 20 ZXIS_DATE Date Modified CHAR20

CHANGED CHAR 1 ZXIS_CHANGED Changed CHAR1

SEEN CHAR 1 ZXIS_SEEN Seen CHAR1

DIRNAME CHAR 600 ZXIS_DIRNAME Path CHAR600

Function Group

- ZXIS_X_00_FILE_SERVICES

*******************************************************************

* System-defined Include-files. *

*******************************************************************

include lzxis_x_00_file_servicestop. " Global Data

include lzxis_x_00_file_servicesuxx. " Function Modules

*******************************************************************

* User-defined Include-files (if necessary). *

*******************************************************************

include lzxis_x_00_file_servicesf01. " Subprograms

include lzxis_x_00_file_serviceso01. " PBO-Modules

include lzxis_x_00_file_servicesi01. " PAI-Modules

Function Group Text Symbols

001 File

002 System Folders Display

003 Please select a Search pattern!

004 Folders on # System

005 directory

006 Directory

007 Directory of

008 Please select a folder!

Page 16: SAP File Explorer

009 Windows NT

010 The use of the fallowing characters is not allowed:

011 Please select in the right panel a folder or file!

012 Open

013 For security reasons Drag & Drop

014 is only permitted for Files!

015 Cannot Copy or Move to the same Folder!

016 Error transferring file!

017 Replace File

018 File already exists in target folder, replace?

019 Yes

020 No

021 Replace current file

022 Cancel Drag & Drop Operation

023 Operation Cancelled

024 Local PC

025 Local Disk (#)

026 CDROM Drive (#)

027 Remote Drive (#)

100 Text Document

101 Configuration Settings

102 SAP GUI Shortcut

103 API File

104 TP0 File

105 PAR File

106 TQL File

107 BCK File

108 File Folder

109 CFG File

110 Log File

111 ECO File

112 TPP File

113 Microsoft Office Word Document

114 Internet Document Set

115 Setup Information

116 REC File

117 TRC File

118 LST File

119 SAV File

120 TMP File

121 ELG File

Page 17: SAP File Explorer

122 WLG File

123 HTML Document

124 HyperText Template

125 Internet Shortcut

126 XML Document

127 Help File

128 System file

129 Windows Command Script

130 PID File

131 TAG File

132 DEV File

133 PCI File

134 Security Catalog

135 SMP File

136 OPT File

137 AIX File

138 Application Extension

139 Device driver

140 TrueType Font file

141 OLD File

142 DMP File

143 ICA File

144 PKS File

145 BUF File

146 PCF File

147 OUT File

148 HOT File

149 PKCS Certificates

150 Application

151 SAR File

152 MS-DOS Batch File

153 TAR File

154 ORA File

155 DBA File

156 SH File

157 BAK File

158 PFB File

159 Microsoft Office PowerPoint Presentation

160 Microsoft Office Word Template

161 TPL File

162 Outlook Express Mail Message

Page 18: SAP File Explorer

163 Rich Text Format

164 Adobe Acrobat Document

165 TPS File

166 OTF Document

167 TIF Image Document

168 Icon

169 GIF Image

170 Write Document

171 PRD File

172 PRN File

173 XPM File

174 Microsoft Visio Document

175 Bitmap Image

176 PNG Image

177 Microsoft Office Excel Worksheet

178 JPEG Image

179 XWD File

180 XBM File

181 Compressed (zipped) Folder

182 DAT File

183 MON File

184 INP File

185 PFL File

186 CAR File

187 MSS File

188 ASP File

189 CCS File

190 SC1 File

191 EXT File

192 LIB File

193 HTTP File

194 Video Clip

195 Wave Sound

196 AU Format Sound

197 MP3 Format Sound

198 SQL File

199 File

200 Executable Jar File

201 Microsoft Office Excel Comma Separated Values File

Page 19: SAP File Explorer

Function Module

- Z_X_IS_GET_FILE_TREE_XXXX

Function group ZXIS_X_00_FILE_SERVICES

Short text SAP File Explorer

Import Parameters

Parameter Name Type Associated Type Optional Short Text

FIW_PATH TYPE C X Remote Server Path

Export Parameters

Parameter Name Type Associated Type Short Text

FEW_NAME TYPE C File Name

FEW_PATH TYPE C Path

FEW_PATH_NAME TYPE C File and Path

Exceptions

Exception Short text

NOT_FOUND Not Found

Source Code

function z_x_is_get_file_tree_xxxx.

*"----------------------------------------------------------------------

*"*"Local interface:

*" IMPORTING

*" REFERENCE(FIW_PATH) TYPE C OPTIONAL

*" EXPORTING

*" REFERENCE(FEW_NAME) TYPE C

*" REFERENCE(FEW_PATH) TYPE C

*" REFERENCE(FEW_PATH_NAME) TYPE C

*" EXCEPTIONS

*" NOT_FOUND

*"----------------------------------------------------------------------

*-----------------------------------------------------------------------

* Author: António César Date: 28/01/2009

*-----------------------------------------------------------------------

data:

lw_file_name type localfile.

* Initialization Output

perform initialization.

* Check Search Path

Page 20: SAP File Explorer

if not ( fiw_path ca c_excp_chr ).

w_server_path = fiw_path.

lw_file_name = c_wlchar.

if w_server_path is initial.

if sy-opsys = 'Windows NT'(009).

w_server_path = c_win_root.

elseif sy-opsys = c_aix.

w_server_path = c_slash.

elseif sy-opsys = c_unix.

w_server_path = c_slash.

endif.

endif.

w_dysp_path = w_file_path = w_server_path.

clear: w_act, w_loc, w_src.

w_dct = c_x.

* Get File System Data

perform get_file_list using c_slash

lw_file_name.

* Call File Display

call screen c_sc_0100 starting at 14 2 ending at 160 24.

* Assign Output Fields

few_name = w_file_name.

few_path = w_file_path.

few_path_name = w_file_path_name.

else.

* The following characters are not allowed

message id c_msgig_fsev type c_msgty_w number c_msgno_001

with c_excp_chr

raising not_found.

endif.

endfunction.

Page 21: SAP File Explorer

Screen

- 100

It’s a Modal Dialog Box with Lines/Columns – 24/110

Elements

CCONT01

OK_CODE

Flow Logic

* Process Before Output

process before output.

module status_0100.

module output_prepare.

* Process After Input

process after input.

module user_command_0100.

module exit_0100 at exit-command.

As stated before the screen consists of a single custom control with 24/110

Page 22: SAP File Explorer

Figure 28 – Screen 100

Gui Status

- ST_0100

It’s a dialog box status with only 3 buttons.

Figure 29 – Status ST_0100

Page 23: SAP File Explorer

Gui Title

- TL_0100

The “&’s” in the Address are replaced in run time with the path.

Figure 30 – Title TL_0100

Top Include

- LZXIS_X_00_FILE_SERVICESTOP

*-----------------------------------------------------------------------

* Author: António César Date: 28/01/2009

*-----------------------------------------------------------------------

function-pool zxis_x_00_file_services. "MESSAGE-ID ..

* --- Classes ---

class:

* D&D Object Handler

cl_dragdropobj definition deferred,

* Event Handler

cl_event_handler definition deferred,

* Local Event Handler

cl_local_event_handler definition deferred,

* Definition of Control Framework

cl_gui_cfw definition load.

data:

o_dataobj type ref to cl_dragdropobj,

* Grid Drag/Drop Control

o_dd_grid type ref to cl_dragdrop,

* Tree Drag/Drop Control

o_dd_tree type ref to cl_dragdrop,

* Event Handler

o_eventh type ref to cl_event_handler,

* Local Event Handler

o_eventhl type ref to cl_local_event_handler,

Page 24: SAP File Explorer

* File container

o_file_cont type ref to cl_gui_custom_container,

* ALV Grid

o_grid type ref to cl_gui_alv_grid,

* Frontend Services

o_gui_serv type ref to cl_gui_frontend_services,

* HTML Control

o_html_control type ref to cl_gui_html_viewer,

* Tree Control

o_tree type ref to cl_gui_alv_tree,

* Local PC Tree Control

o_treel type ref to cl_gui_alv_tree,

* Docking Container

o_tree_cont type ref to cl_gui_docking_container,

* Local PC Docking Container

o_tree_contl type ref to cl_gui_docking_container.

* --- Includes ---

include:

<list>.

* --- Type Pools ---

type-pools:

cndp, cntl, slis, cnht.

* --- Types ---

types:

begin of t_buftab_t,

data1(7900) type c,

end of t_buftab_t,

begin of t_file,

dirname type char600,

name type char300,

type_id type char1,

type type char10,

len(16) type p,

owner type char8,

mtime(6) type p,

mode type char9,

useable type char1,

subrc type char4,

errno type char3,

errmsg type char40,

mod_date type d,

mod_time type char8,

seen type char1,

Page 25: SAP File Explorer

changed type char1,

end of t_file,

begin of t_node,

node_key type tv_nodekey,

dirname type char600,

name type char300,

drive type char300,

end of t_node,

begin of t_drv,

drive type char300,

type type char20,

desc type char300,

end of t_drv.

* --- Internal Tables ---

data:

i_buftab_t type standard table of t_buftab_t,

i_drv type standard table of t_drv,

i_file_list type standard table of zxis_0x_file,

i_file_list_d type standard table of zxis_0x_file_d,

i_html type standard table of char255,

i_kpath type standard table of sdokpath,

i_log_list type standard table of zxis_0x_file,

i_log_listl type standard table of zxis_0x_file,

i_node type standard table of t_node,

i_nodel type standard table of t_node,

i_query_table type standard table of w3query,

i_lquery_table type standard table of w3query,

i_sort type standard table of lvc_s_sort.

data:

begin of i_server_data occurs 0,

line type char300,

end of i_server_data.

* --- Fields ---

data:

ok_code type fcode,

w_act type flag,

w_action type char256,

w_dct type flag,

w_dd_target_name type char255,

w_dest type flag,

w_dest_path type localfile,

w_drive type string,

Page 26: SAP File Explorer

w_dropeffect type i,

w_dysp_path type char200,

w_file_dest type string,

w_file_name type char200,

w_file_path type char200,

w_file_path_name type char200,

w_find_path type char200,

w_handle_grid type i,

w_handle_tree type i,

w_html_line type char255,

w_lnode_key type lvc_nkey,

w_loc type flag,

w_lpath_name type char200,

w_nnode_key type lvc_nkey,

w_node_key type tv_nodekey,

w_path_name type char200,

w_pcname type string,

w_perf type flag,

w_platform type i,

w_return type char200,

w_returns type string,

w_search_name type char200,

w_search_path type char200,

w_server_path type char200,

w_src type flag,

w_srcd type flag,

w_srcl type flag,

w_strlen type syfdpos,

w_type type string,

w_unixcomm type char200.

* --- Constants ---

constants:

c_0 type char1 value '0',

c_1 type char1 value '1',

c_10 type char2 value '10',

c_100 type char3 value '100',

c_12 type char2 value '12',

c_17 type char2 value '17',

c_2 type char1 value '2',

c_25 type char2 value '25',

c_3 type n value '3',

c_30 type char2 value '30',

c_4 type char1 value '4',

c_45 type char2 value '45',

c_5 type char1 value '5',

c_a type char1 value 'A',

Page 27: SAP File Explorer

c_abstamp type char10 value 'ABAPSTAMP',

c_aix type char10 value 'AIX',

c_asc type char10 value 'ASC',

c_ascd type char10 value 'ASCENDING',

c_at type char1 value '@',

c_atsp type char2 value '@ ',

c_back type char10 value 'BACK',

c_back_slash type char1 value '\',

c_bin type char10 value 'BIN',

c_bss type char2 value '\/',

c_card type char1 value '#',

c_cchar type char1 value '"',

c_cdrom type char10 value 'CDROM',

c_command type char10 value 'COMMAND',

c_cont type char10 value 'CONT',

c_core type char10 value 'core',

c_ctmp type char20 value 'C:\WINDOWS\Temp\',

c_custcont type char10 value 'CCONT01',

c_d type char1 value 'D',

c_date type char10 value 'DATE',

c_ddot type char2 value '..',

c_dir type char10 value 'DIR',

c_dira type char10 value 'DIRA',

c_dirb type char10 value 'DIRB',

c_dirc type char10 value 'DIRC',

c_dirl type char10 value 'dir',

c_dirname type char10 value 'DIRNAME',

c_dname type char10 value '-name',

c_dot type char1 value '.',

c_dprint type char10 value '-print',

c_editm_dt type char20 value '____.__.__',

c_editm_rr type char20 value 'RR_.___.___.___ B',

c_err2 type char3 value ' 2',

c_errmsg type char10 value 'ERRMSG',

c_errno type char10 value 'ERRNO',

c_errptrn type char25 value '@"#£$§%&/{([)]=}?¨+`´~^ºª',

c_excp_chr type char5 value '|;,<>',

c_f type char1 value 'F',

c_file type char10 value 'FILE',

c_file_disp type tabname value 'ZXIS_0X_FILE_D',

c_file_id type char10 value 'FILE_ID',

c_filr type char10 value 'file, regu',

c_findl type char10 value 'find',

c_firc type char10 value 'FIRC',

c_fixed type char10 value 'FIXED',

c_fl type char1 value 'f',

c_folder type char10 value 'Folder',

Page 28: SAP File Explorer

c_fu type char1 value 'F',

c_icon type char10 value 'ICON',

c_len type char10 value 'LEN',

c_line type char6 value 'LINE',

c_locl type char6 value 'LOCL',

c_mode type char10 value 'MODE',

c_msgig_fsev type symsgid value 'ZX_IS0_FSERV',

c_msgno_000 type symsgno value '000',

c_msgno_001 type symsgno value '001',

c_msgno_003 type symsgno value '003',

c_msgno_017 type symsgno value '017',

c_msgno_019 type symsgno value '019',

c_msgno_020 type symsgno value '020',

c_msgty_a type symsgty value 'A',

c_msgty_e type symsgty value 'E',

c_msgty_i type symsgty value 'I',

c_msgty_s type symsgty value 'S',

c_msgty_w type symsgty value 'W',

c_msgty_x type symsgty value 'X',

c_mtime type char10 value 'MTIME',

c_name type char10 value 'NAME',

c_numbers type char10 value '0123456789',

c_opcode type char10 value 'OPCODE',

c_owner type char10 value 'OWNER',

c_qstmrk type char3 value '???',

c_r type char1 value 'R',

c_remote type char10 value 'REMOTE',

c_sap_no type char1 value ' ',

c_sap_yes type char1 value 'X',

c_sbs type char2 value '/\',

c_sc_0100 type char4 value '0100',

c_search type char10 value 'SEARCH',

c_searchl type char10 value 'Search',

c_slash type char1 value '/',

c_spat type char2 value ' @',

c_ss type char2 value '/s',

c_st_0100 type char10 value 'ST_0100',

c_tab type char10 value 'TAB',

c_tabname type tabname value 'SDOKPATH',

c_tl_0100 type char10 value 'TL_0100',

c_trslash type char2 value '/ ',

c_trslashl type char2 value '\ ',

c_tstamp type char10 value 'TIMESTAMP',

c_type type char10 value 'TYPE',

c_type_id type char10 value 'TYPE_ID',

c_unix type char10 value 'UNIX',

c_utc type char4 value 'UTC+',

Page 29: SAP File Explorer

c_vdot type char2 value ':',

c_win_root type char3 value 'C:\',

c_wlchar type char1 value '*',

c_wroot type char2 value ':\',

c_x type char1 value 'X',

c_z type char1 value 'Z'.

* --- Includes ---

include:

* Classes

lzxis_x_00_file_servicescl0.

Classes Include

- LZXIS_X_00_FILE_SERVICESCL0

This should be included at the end of TOP Include as seen above, the easier way is to create it in the object

navigator (SE80), in the function group tree right click in the includes node and select create and give the

include name.

*----------------------------------------------------------------------*

***INCLUDE LZXIS_X_00_FILE_SERVICESCL0 .

*----------------------------------------------------------------------*

*-----------------------------------------------------------------------

* Author: António César Date: 28/01/2009

*-----------------------------------------------------------------------

*-----------------------------------------------------------------------

* CLASS cl_event_handler DEFINITION

*-----------------------------------------------------------------------

class cl_event_handler definition.

public section.

methods:

* Handle Node Double Click

handle_node_double_click

for event node_double_click of cl_gui_alv_tree

importing node_key,

* Handle Header Click

handle_header_click

for event header_click of cl_gui_alv_tree

importing fieldname,

* Handle Expand no Children

handle_expand_no_children

for event expand_nc of cl_gui_alv_tree

Page 30: SAP File Explorer

importing node_key,

* Handle Tree on Drop

handle_on_drop

for event on_drop of cl_gui_alv_tree

importing node_key drag_drop_object,

* Grid Double-click control

handle_double_click

for event double_click of cl_gui_alv_grid

importing e_row e_column es_row_no,

* Grid Drag control

handle_ondrag

for event ondrag of cl_gui_alv_grid

importing e_row e_column es_row_no e_dragdropobj,

* Handle Grid on Drop

handle_on_grid_drop

for event ondrop of cl_gui_alv_grid

importing e_row e_column es_row_no e_dragdropobj,

* Grid Drop Complete control

handle_ondropcomplete

for event ondropcomplete of cl_gui_alv_grid

importing e_row e_column es_row_no e_dragdropobj,

* Handle SAP Event

handle_on_sapevent

for event sapevent of cl_gui_html_viewer

importing action frame getdata postdata query_table.

endclass. "cl_event_handler DEFINITION

*-----------------------------------------------------------------------

* CLASS cl_local_event_handler DEFINITION

*-----------------------------------------------------------------------

class cl_local_event_handler definition.

public section.

methods:

* Handle Node Double Click

handle_node_double_click

for event node_double_click of cl_gui_alv_tree

importing node_key,

* Handle Header Click

Page 31: SAP File Explorer

handle_header_click

for event header_click of cl_gui_alv_tree

importing fieldname,

* Handle Expand no Children

handle_expand_no_children

for event expand_nc of cl_gui_alv_tree

importing node_key,

* Handle Tree on Drop

handle_on_drop

for event on_drop of cl_gui_alv_tree

importing node_key drag_drop_object,

* Handle SAP Event

handle_on_sapevent

for event sapevent of cl_gui_html_viewer

importing action frame getdata postdata query_table.

endclass. "cl_local_event_handler DEFINITION

*-----------------------------------------------------------------------

* CLASS cl_dragdropobj DEFINITION

*-----------------------------------------------------------------------

class cl_dragdropobj definition.

public section.

data:

l_file_list_d type zxis_0x_file_d,

w_index type i.

endclass. "cl_dragdropobj DEFINITION

*-----------------------------------------------------------------------

* CLASS cl_event_handler IMPLEMENTATION

*-----------------------------------------------------------------------

class cl_event_handler implementation.

* Handle Node Double Click

method handle_node_double_click.

w_node_key = node_key.

* Display Files

perform node_double_click using w_node_key.

endmethod. "handle_node_double_click

* Handle Header Click

Page 32: SAP File Explorer

method handle_header_click.

* Search Pattern

perform set_search_pattern.

endmethod. "handle_header_click

* Handle Expand no Children

method handle_expand_no_children.

w_node_key = node_key.

* Get next dir

perform expand_no_children.

endmethod. "handle_expand_no_children

* Handle Tree on Drop

method handle_on_drop.

perform handle_tree_on_drop using node_key

changing drag_drop_object.

endmethod. "handle_on_drop

* Grid Double-click control

method handle_double_click .

* Grid Double-click handler

perform double_click_handler using e_row e_column es_row_no .

endmethod . "handle_double_click

* Grid Drag control

method handle_ondrag.

* Handle Grid Drag control

perform on_drag_handler using e_row e_column es_row_no

changing e_dragdropobj.

endmethod . "handle_ondrag

* Handle Grid on Drop

method handle_on_grid_drop.

* Handle Grid on Drop

perform handle_grid_on_drop using e_row e_column es_row_no

changing e_dragdropobj.

Page 33: SAP File Explorer

endmethod . "handle_ondrag

* Grid Drop Complete control

method handle_ondropcomplete.

* Handle Grid Drop Complete control

perform on_dropcomplete_handler using e_row e_column es_row_no

changing e_dragdropobj.

endmethod . "handle_ondropcomplete

* Handle SAP Event

method handle_on_sapevent.

clear: w_action, w_dct.

w_action = action.

i_query_table = query_table.

case w_action.

when c_back.

* Back to Folder Tree

perform back_to_tree.

when c_search.

* Search

perform folder_search.

endcase.

endmethod. "handle_on_sapevent

endclass. "cl_event_handler IMPLEMENTATION

*-----------------------------------------------------------------------

* CLASS cl_local_event_handler IMPLEMENTATION

*-----------------------------------------------------------------------

class cl_local_event_handler implementation.

* Handle Node Double Click

method handle_node_double_click.

w_lnode_key = node_key.

* Display Files

perform lnode_double_click using w_lnode_key.

Page 34: SAP File Explorer

endmethod. "handle_node_double_click

* Handle Header Click

method handle_header_click.

* Search Pattern

perform set_lsearch_pattern.

endmethod. "handle_header_click

* Handle Expand no Children

method handle_expand_no_children.

w_lnode_key = node_key.

* Get next dir

perform lexpand_no_children.

endmethod. "handle_expand_no_children

* Handle Tree on Drop

method handle_on_drop.

perform handle_ltree_on_drop using node_key

changing drag_drop_object.

endmethod. "handle_on_drop

* Handle SAP Event

method handle_on_sapevent.

clear: w_action, w_dct.

w_action = action.

i_lquery_table = query_table.

case w_action.

when c_back.

* Back to Folder Tree

perform back_to_loc_tree.

when c_search.

* Search Local PC

perform loc_folder_search.

endcase.

Page 35: SAP File Explorer

endmethod. "handle_on_sapevent

endclass. "cl_local_event_handler IMPLEMENTATION

Forms Include

- LZXIS_X_00_FILE_SERVICESF01

*-----------------------------------------------------------------------

***INCLUDE LZXIS_X_00_FILE_SERVICESF01 .

*-----------------------------------------------------------------------

*-----------------------------------------------------------------------

* Author: António César Date: 28/01/2009

*-----------------------------------------------------------------------

*-----------------------------------------------------------------------

* Form initialization

*-----------------------------------------------------------------------

form initialization .

* Initialize Data

perform clear_data.

endform. " initialization

*-----------------------------------------------------------------------

* Form clear_data

*-----------------------------------------------------------------------

form clear_data .

clear:

o_dataobj, o_dd_grid, o_dd_tree, o_eventh, o_eventhl, o_file_cont,

o_grid, o_gui_serv, o_html_control, o_tree, o_treel, o_tree_cont,

o_tree_contl.

clear:

i_buftab_t, i_drv, i_file_list, i_file_list_d, i_html, i_kpath,

i_log_list, i_log_listl, i_node, i_nodel, i_query_table,

i_lquery_table, i_sort.

clear:

ok_code, w_act, w_action, w_dct, w_dd_target_name, w_dest,

w_dest_path, w_drive, w_dropeffect, w_dysp_path, w_file_dest,

w_file_name, w_file_path, w_file_path_name, w_find_path,

w_handle_grid, w_handle_tree, w_html_line, w_lnode_key, w_loc,

w_lpath_name, w_nnode_key, w_node_key, w_path_name, w_pcname,

w_perf, w_platform, w_return, w_returns, w_search_name,

Page 36: SAP File Explorer

w_search_path, w_server_path, w_src, w_srcd, w_srcl, w_strlen,

w_type, w_unixcomm.

endform. " clear_data

*-----------------------------------------------------------------------

* Form initiate_gui

*-----------------------------------------------------------------------

form initiate_gui .

if w_file_path is initial.

w_file_path = w_server_path.

endif.

endform. " initiate_gui

*-----------------------------------------------------------------------

* Form grid_prepare

*-----------------------------------------------------------------------

form grid_prepare .

* Check Object is Bound

if o_file_cont is bound.

call method o_file_cont->free.

clear: o_file_cont.

endif.

* Create the File container

create object o_file_cont

exporting

container_name = c_custcont

exceptions

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

* Create Grid Control

create object o_grid

exporting

i_parent = o_file_cont

Page 37: SAP File Explorer

exceptions

error_cntl_create = 1

error_cntl_init = 2

error_cntl_link = 3

error_dp_create = 4

others = 5.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

endform. " grid_prepare

*-----------------------------------------------------------------------

* Form output_prepare

*-----------------------------------------------------------------------

form output_prepare .

data:

li_events type standard table of cntl_simple_event.

data:

ll_event type cntl_simple_event.

data:

lw_repid type sy-repid,

lw_dynnr type sy-dynnr,

lw_flag type as4flag,

lw_ext type i value '300'.

lw_repid = sy-repid.

lw_dynnr = sy-dynnr.

w_act = c_x.

* Create the Tree container

create object o_tree_cont

exporting

repid = lw_repid

dynnr = lw_dynnr

side = o_tree_cont->dock_at_left

extension = lw_ext

exceptions

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

Page 38: SAP File Explorer

lifetime_dynpro_dynpro_link = 5.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

lw_flag = c_x.

* Create Tree Control

create object o_tree

exporting

parent = o_tree_cont

item_selection = lw_flag

no_toolbar = lw_flag

no_html_header = lw_flag

exceptions

cntl_system_error = 1

create_error = 2

failed = 3

illegal_node_selection_mode = 4

illegal_column_name = 5

lifetime_error = 6.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

* Set Tree Layout

perform set_tree_layout.

if w_src is initial.

* Initiate Drag & Drop

perform start_drad_drop.

* Set ALV Display Layout

perform set_grid_layout.

endif.

* Define the events which will be passed to the backend

* Node double click

ll_event-eventid = cl_gui_column_tree=>eventid_node_double_click.

ll_event-appl_event = c_x.

append ll_event to li_events.

* Header click

Page 39: SAP File Explorer

ll_event-eventid = cl_gui_column_tree=>eventid_header_click.

ll_event-appl_event = c_x.

append ll_event to li_events.

* Expand no Children

ll_event-eventid = cl_gui_column_tree=>eventid_expand_no_children.

ll_event-appl_event = c_x.

append ll_event to li_events.

* Set Events

call method o_tree->set_registered_events

exporting

events = li_events

exceptions

cntl_error = 1

cntl_system_error = 2

illegal_event_combination = 3.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

* Assign event handlers in the application class to each desired event

create object o_eventh.

set handler o_eventh->handle_node_double_click for o_tree.

set handler o_eventh->handle_header_click for o_tree.

set handler o_eventh->handle_expand_no_children for o_tree.

set handler o_eventh->handle_on_drop for o_tree.

set handler o_eventh->handle_double_click for o_grid.

set handler o_eventh->handle_ondrag for o_grid.

set handler o_eventh->handle_on_grid_drop for o_grid.

set handler o_eventh->handle_ondropcomplete for o_grid.

endform. " output_prepare

*-----------------------------------------------------------------------

* Form set_tree_layout

*-----------------------------------------------------------------------

form set_tree_layout .

data:

li_fieldcat type standard table of lvc_s_fcat.

data:

ll_header type treev_hhdr.

Page 40: SAP File Explorer

field-symbols:

<lf_fieldcat> type lvc_s_fcat.

* Setup the header

ll_header-tooltip = 'System Folders Display'(002).

ll_header-heading = 'Folders on # System'(004).

ll_header-width = c_30.

replace c_card with sy-opsys into ll_header-heading.

condense ll_header-heading.

* ALV control service modules

call function 'LVC_FIELDCATALOG_MERGE'

exporting

i_structure_name = c_tabname

changing

ct_fieldcat = li_fieldcat.

* Prepare Tree Field Catalog

loop at li_fieldcat assigning <lf_fieldcat>.

<lf_fieldcat>-no_out = c_x.

endloop.

* Sets Tree Table for First Display

call method o_tree->set_table_for_first_display

exporting

is_hierarchy_header = ll_header

changing

it_outtab = i_kpath

it_fieldcatalog = li_fieldcat.

endform. " set_tree_layout

*-----------------------------------------------------------------------

* Form set_local_tree_layout

*-----------------------------------------------------------------------

form set_local_tree_layout .

data:

li_fieldcat type standard table of lvc_s_fcat.

data:

ll_header type treev_hhdr.

field-symbols:

<lf_fieldcat> type lvc_s_fcat.

Page 41: SAP File Explorer

clear: w_pcname.

* Get Computer Name

call method o_gui_serv->get_computer_name

changing

computer_name = w_pcname

exceptions

cntl_error = 1

error_no_gui = 2

not_supported_by_gui = 3

others = 4.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

call method cl_gui_cfw=>flush.

perform get_local_drive changing w_drive.

* Setup the header

ll_header-tooltip = 'Local PC'(024).

concatenate 'Local PC'(024) w_pcname

into ll_header-heading separated by space.

ll_header-width = c_30.

* ALV control service modules

call function 'LVC_FIELDCATALOG_MERGE'

exporting

i_structure_name = c_tabname

changing

ct_fieldcat = li_fieldcat.

* Prepare Tree Field Catalog

loop at li_fieldcat assigning <lf_fieldcat>.

<lf_fieldcat>-no_out = c_x.

endloop.

* Sets Tree Table for First Display

call method o_treel->set_table_for_first_display

exporting

is_hierarchy_header = ll_header

changing

it_outtab = i_kpath

it_fieldcatalog = li_fieldcat.

Page 42: SAP File Explorer

endform. " set_local_tree_layout

*-----------------------------------------------------------------------

* Form set_grid_layout

*-----------------------------------------------------------------------

form set_grid_layout .

data:

li_fieldcat type standard table of lvc_s_fcat,

li_fieldcatalog type standard table of lvc_s_fcat.

data:

ll_layout type lvc_s_layo.

data:

lw_structure_name type tabname.

field-symbols:

<lf_fieldcat> type lvc_s_fcat.

clear: ll_layout.

* Prepare screen layout

ll_layout-no_hgridln = c_x.

ll_layout-no_merging = c_x.

ll_layout-no_rowmark = c_x.

ll_layout-no_toolbar = c_x.

ll_layout-no_vgridln = c_x.

ll_layout-sel_mode = c_a.

ll_layout-s_dragdrop-row_ddid = w_handle_grid.

ll_layout-sgl_clk_hd = c_x.

lw_structure_name = c_file_disp.

* Prepare Field Catalog

call function 'LVC_FIELDCATALOG_MERGE'

exporting

i_structure_name = lw_structure_name

changing

ct_fieldcat = li_fieldcat

exceptions

inconsistent_interface = 1

program_error = 2

others = 3.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

Page 43: SAP File Explorer

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

loop at li_fieldcat assigning <lf_fieldcat>.

<lf_fieldcat>-no_out = c_x.

* Icon - Output column 1

if <lf_fieldcat>-fieldname = c_icon.

clear: <lf_fieldcat>-no_out.

<lf_fieldcat>-col_pos = c_1.

<lf_fieldcat>-icon = c_x.

<lf_fieldcat>-outputlen = c_3.

<lf_fieldcat>-lowercase = c_x.

endif.

if w_srcd is initial.

* Name - Output column 2

if <lf_fieldcat>-fieldname = c_name.

clear: <lf_fieldcat>-no_out.

<lf_fieldcat>-col_pos = c_2.

<lf_fieldcat>-outputlen = c_45.

<lf_fieldcat>-lowercase = c_x.

endif.

* Size - Output column 3

if <lf_fieldcat>-fieldname = c_len.

clear: <lf_fieldcat>-no_out.

<lf_fieldcat>-col_pos = c_3.

<lf_fieldcat>-outputlen = c_12.

<lf_fieldcat>-just = c_r.

<lf_fieldcat>-lowercase = c_x.

endif.

* Type - Output column 4

if <lf_fieldcat>-fieldname = c_type.

clear: <lf_fieldcat>-no_out.

<lf_fieldcat>-col_pos = c_4.

<lf_fieldcat>-outputlen = c_25.

<lf_fieldcat>-lowercase = c_x.

endif.

* Date - Output column 5

if <lf_fieldcat>-fieldname = c_date.

clear: <lf_fieldcat>-no_out.

<lf_fieldcat>-col_pos = c_5.

<lf_fieldcat>-outputlen = c_17.

<lf_fieldcat>-lowercase = c_x.

Page 44: SAP File Explorer

endif.

else.

* Name - Output column 2

if <lf_fieldcat>-fieldname = c_name.

clear: <lf_fieldcat>-no_out.

<lf_fieldcat>-col_pos = c_2.

<lf_fieldcat>-outputlen = c_30.

<lf_fieldcat>-lowercase = c_x.

endif.

* Size - Output column 3

if <lf_fieldcat>-fieldname = c_len.

clear: <lf_fieldcat>-no_out.

<lf_fieldcat>-col_pos = c_3.

<lf_fieldcat>-outputlen = c_10.

<lf_fieldcat>-just = c_r.

<lf_fieldcat>-lowercase = c_x.

endif.

* Date - Output column 4

if <lf_fieldcat>-fieldname = c_date.

clear: <lf_fieldcat>-no_out.

<lf_fieldcat>-col_pos = c_4.

<lf_fieldcat>-outputlen = c_17.

<lf_fieldcat>-lowercase = c_x.

endif.

* Path Name - Output column 5

if <lf_fieldcat>-fieldname = c_dirname.

clear: <lf_fieldcat>-no_out.

<lf_fieldcat>-col_pos = c_5.

<lf_fieldcat>-outputlen = c_100.

<lf_fieldcat>-lowercase = c_x.

endif.

endif.

endloop.

clear: w_srcd.

* Prepare layout

perform prepare_display_layout.

** Get active

* CALL METHOD o_grid->get_frontend_fieldcatalog

* IMPORTING

* et_fieldcatalog = li_fieldcatalog.

Page 45: SAP File Explorer

if li_fieldcatalog[] is initial.

* Set sorting Criteria

perform set_sort using c_type_id c_file_id c_name space c_ascd.

* Sets File Table for First Display

call method o_grid->set_table_for_first_display

exporting

i_structure_name = lw_structure_name

is_layout = ll_layout

changing

it_outtab = i_file_list_d

it_fieldcatalog = li_fieldcat

it_sort = i_sort

exceptions

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

others = 4.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

else.

* Set sorting Criteria

perform set_sort using c_type_id c_file_id c_name space c_ascd.

* Set Sort Criteria

call method o_grid->set_sort_criteria

exporting

it_sort = i_sort

exceptions

no_fieldcatalog_available = 1

others = 2.

if sy-subrc <> 0.

message id sy-msgid type c_msgty_s number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

* Refresh Table Display

call method o_grid->refresh_table_display

exceptions

finished = 1

Page 46: SAP File Explorer

others = 2.

if sy-subrc <> 0.

message id sy-msgid type c_msgty_s number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

endif.

endform. " set_grid_layout

*-----------------------------------------------------------------------

* Form start_drad_drop

*-----------------------------------------------------------------------

form start_drad_drop .

* Define Drop Effect

w_dropeffect = cl_dragdrop=>move + cl_dragdrop=>copy.

* Create Tree D&D control

create object o_dd_tree.

* Insert a New type into Behaviour

call method o_dd_tree->add

exporting

flavor = c_line

dragsrc = ' '

droptarget = c_x

effect = w_dropeffect

exceptions

already_defined = 1

obj_invalid = 2

others = 3.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

* Returns the Handle Known at the Frontend

call method o_dd_tree->get_handle

importing

handle = w_handle_tree

exceptions

obj_invalid = 1

others = 2.

if sy-subrc <> 0.

Page 47: SAP File Explorer

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

* Create Grid D&D control

create object o_dd_grid.

* Insert a New type into Behaviour

call method o_dd_grid->add

exporting

flavor = c_line

dragsrc = c_x

droptarget = c_x

effect = w_dropeffect

exceptions

already_defined = 1

obj_invalid = 2

others = 3.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

* Returns the Handle Known at the Frontend

call method o_dd_grid->get_handle

importing

handle = w_handle_grid

exceptions

obj_invalid = 1

others = 2.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

endform. " start_drad_drop

*-----------------------------------------------------------------------

* Form prepare_display_layout

*-----------------------------------------------------------------------

form prepare_display_layout .

data:

ll_file_list type zxis_0x_file,

ll_file_list_d type zxis_0x_file_d.

Page 48: SAP File Explorer

data:

lw_extenc type char5,

lw_lenght type i.

clear: i_file_list_d, ll_file_list_d, ll_file_list.

loop at i_file_list into ll_file_list.

move-corresponding ll_file_list to ll_file_list_d.

clear: ll_file_list_d-file_id, ll_file_list_d-type_f,

ll_file_list_d-date.

concatenate ll_file_list-mod_date ll_file_list-mod_time

into ll_file_list_d-date separated by space.

ll_file_list_d-type_f = c_bin.

case ll_file_list_d-type_id.

when 'D'.

ll_file_list_d-icon = '@IH@'.

ll_file_list_d-type = 'File Folder'(108).

when 'F'.

clear: lw_lenght, lw_extenc.

lw_lenght = strlen( ll_file_list_d-name ).

if lw_lenght > 5.

lw_lenght = lw_lenght - 5.

lw_extenc = ll_file_list_d-name+lw_lenght(5).

else.

shift ll_file_list_d-name left deleting leading space.

lw_extenc = ll_file_list_d-name.

endif.

if lw_extenc cs '.txt'.

ll_file_list_d-icon = '@EQ@'.

ll_file_list_d-file_id = 'TXT'.

ll_file_list_d-type_f = c_asc.

ll_file_list_d-type = 'Text Document'(100).

elseif lw_extenc cs '.ini'.

ll_file_list_d-icon = '@EQ@'.

ll_file_list_d-file_id = 'INI'.

ll_file_list_d-type_f = c_asc.

ll_file_list_d-type = 'Configuration Settings'(101).

elseif lw_extenc cs '.sap'.

ll_file_list_d-icon = '@E3@'.

Page 49: SAP File Explorer

ll_file_list_d-file_id = 'SAP'.

ll_file_list_d-type = 'SAP GUI Shortcut'(102).

elseif lw_extenc cs '.api'.

ll_file_list_d-icon = '@EQ@'.

ll_file_list_d-file_id = 'API'.

ll_file_list_d-type = 'API File'(103).

elseif lw_extenc cs '.tp0'.

ll_file_list_d-icon = '@EQ@'.

ll_file_list_d-file_id = 'TP0'.

ll_file_list_d-type = 'TP0 File'(104).

elseif lw_extenc cs '.par'.

ll_file_list_d-icon = '@EQ@'.

ll_file_list_d-file_id = 'PAR'.

ll_file_list_d-type = 'PAR File'(105).

elseif lw_extenc cs '.tql'.

ll_file_list_d-icon = '@EQ@'.

ll_file_list_d-file_id = 'TQL'.

ll_file_list_d-type = 'TQL File'(106).

elseif lw_extenc cs '.bck'.

ll_file_list_d-icon = '@EQ@'.

ll_file_list_d-file_id = 'BCK'.

ll_file_list_d-type = 'BCK File'(107).

elseif lw_extenc cs '.cfg'.

ll_file_list_d-icon = '@EQ@'.

ll_file_list_d-file_id = 'CFG'.

ll_file_list_d-type_f = c_asc.

ll_file_list_d-type = 'CFG File'(109).

elseif lw_extenc cs '.log'.

ll_file_list_d-icon = '@DR@'.

ll_file_list_d-file_id = 'LOG'.

ll_file_list_d-type_f = c_asc.

ll_file_list_d-type = 'Log File'(110).

elseif lw_extenc cs '.eco'.

ll_file_list_d-icon = '@9P@'.

ll_file_list_d-file_id = 'ECO'.

ll_file_list_d-type = 'ECO File'(111).

elseif lw_extenc cs '.tpp'.

ll_file_list_d-icon = '@9P@'.

ll_file_list_d-file_id = 'TPP'.

ll_file_list_d-type = 'TPP File'(112).

elseif lw_extenc cs '.doc'.

ll_file_list_d-icon = '@J7@'.

ll_file_list_d-file_id = 'DOC'.

ll_file_list_d-type = 'Microsoft Office Word Document'(113).

elseif lw_extenc cs '.its'.

ll_file_list_d-icon = '@IZ@'.

ll_file_list_d-file_id = 'ITS'.

Page 50: SAP File Explorer

ll_file_list_d-type = 'Internet Document Set'(114).

elseif lw_extenc cs '.inf'.

ll_file_list_d-icon = '@9E@'.

ll_file_list_d-file_id = 'INF'.

ll_file_list_d-type = 'Setup Information'(115).

elseif lw_extenc cs '.rec'.

ll_file_list_d-icon = '@I5@'.

ll_file_list_d-file_id = 'REC'.

ll_file_list_d-type = 'REC File'(116).

elseif lw_extenc cs '.trc'.

ll_file_list_d-icon = '@96@'.

ll_file_list_d-file_id = 'TRC'.

ll_file_list_d-type = 'TRC File'(117).

elseif lw_extenc cs '.lst'.

ll_file_list_d-icon = '@DH@'.

ll_file_list_d-file_id = 'LST'.

ll_file_list_d-type = 'LST File'(118).

elseif lw_extenc cs '.sav'.

ll_file_list_d-icon = '@96@'.

ll_file_list_d-file_id = 'SAV'.

ll_file_list_d-type = 'SAV File'(119).

elseif lw_extenc cs '.tmp'.

ll_file_list_d-icon = '@9D@'.

ll_file_list_d-file_id = 'TMP'.

ll_file_list_d-type = 'TMP File'(120).

elseif lw_extenc cs '.elg'.

ll_file_list_d-icon = '@KK@'.

ll_file_list_d-file_id = 'ELG'.

ll_file_list_d-type = 'ELG File'(121).

elseif lw_extenc cs '.wlg'.

ll_file_list_d-icon = '@9O@'.

ll_file_list_d-file_id = 'WLG'.

ll_file_list_d-type = 'WLG File'(122).

elseif lw_extenc cs '.htm'.

ll_file_list_d-icon = '@J4@'.

ll_file_list_d-file_id = 'HTM'.

ll_file_list_d-type = 'HTML Document'(123).

elseif lw_extenc cs '.htt'.

ll_file_list_d-icon = '@IY@'.

ll_file_list_d-file_id = 'HTT'.

ll_file_list_d-type = 'HyperText Template'(124).

elseif lw_extenc cs '.url'.

ll_file_list_d-icon = '@8S@'.

ll_file_list_d-file_id = 'URL'.

ll_file_list_d-type = 'Internet Shortcut'(125).

elseif lw_extenc cs '.xml'.

ll_file_list_d-icon = '@IZ@'.

Page 51: SAP File Explorer

ll_file_list_d-file_id = 'XML'.

ll_file_list_d-type = 'XML Document'(126).

elseif lw_extenc cs '.hlp'.

ll_file_list_d-icon = '@5E@'.

ll_file_list_d-file_id = 'HLP'.

ll_file_list_d-type = 'Help File'(127).

elseif lw_extenc cs '.sys'.

ll_file_list_d-icon = '@O8@'.

ll_file_list_d-file_id = 'SYS'.

ll_file_list_d-type = 'System file'(128).

elseif lw_extenc cs '.cmd'.

ll_file_list_d-icon = '@IF@'.

ll_file_list_d-file_id = 'CMD'.

ll_file_list_d-type = 'Windows Command Script'(129).

elseif lw_extenc cs '.pid'.

ll_file_list_d-icon = '@IF@'.

ll_file_list_d-file_id = 'PID'.

ll_file_list_d-type = 'PID File'(130).

elseif lw_extenc cs '.tag'.

ll_file_list_d-icon = '@IF@'.

ll_file_list_d-file_id = 'TAG'.

ll_file_list_d-type = 'TAG File'(131).

elseif lw_extenc cs '.dev'.

ll_file_list_d-icon = '@O8@'.

ll_file_list_d-file_id = 'DEV'.

ll_file_list_d-type = 'DEV File'(132).

elseif lw_extenc cs '.pci'.

ll_file_list_d-icon = '@O8@'.

ll_file_list_d-file_id = 'PCI'.

ll_file_list_d-type = 'PCI File'(133).

elseif lw_extenc cs '.cat'.

ll_file_list_d-icon = '@O8@'.

ll_file_list_d-file_id = 'CAT'.

ll_file_list_d-type = 'Security Catalog'(134).

elseif lw_extenc cs '.smp'.

ll_file_list_d-icon = '@O8@'.

ll_file_list_d-file_id = 'SMP'.

ll_file_list_d-type = 'SMP File'(135).

elseif lw_extenc cs '.opt'.

ll_file_list_d-icon = '@O8@'.

ll_file_list_d-file_id = 'OPT'.

ll_file_list_d-type = 'OPT File'(136).

elseif lw_extenc cs '.aix'.

ll_file_list_d-icon = '@O8@'.

ll_file_list_d-file_id = 'AIX'.

ll_file_list_d-type = 'AIX File'(137).

elseif lw_extenc cs '.dll'.

Page 52: SAP File Explorer

ll_file_list_d-icon = '@O8@'.

ll_file_list_d-file_id = 'DLL'.

ll_file_list_d-type = 'Application Extension'(138).

elseif lw_extenc cs '.drv'.

ll_file_list_d-icon = '@O8@'.

ll_file_list_d-file_id = 'DRV'.

ll_file_list_d-type = 'Device driver'(139).

elseif lw_extenc cs '.ttf'.

ll_file_list_d-icon = '@AI@'.

ll_file_list_d-file_id = 'TTF'.

ll_file_list_d-type = 'TrueType Font file'(140).

elseif lw_extenc cs '.old'.

ll_file_list_d-icon = '@DH@'.

ll_file_list_d-file_id = 'OLD'.

ll_file_list_d-type = 'OLD File'(141).

elseif lw_extenc cs '.dmp'.

ll_file_list_d-icon = '@DH@'.

ll_file_list_d-file_id = 'DMP'.

ll_file_list_d-type = 'DMP File'(142).

elseif lw_extenc cs '.ica'.

ll_file_list_d-icon = '@GA@'.

ll_file_list_d-file_id = 'ICA'.

ll_file_list_d-type = 'ICA File'(143).

elseif lw_extenc cs '.pks'.

ll_file_list_d-icon = '@DH@'.

ll_file_list_d-file_id = 'PKS'.

ll_file_list_d-type = 'PKS File'(144).

elseif lw_extenc cs '.buf'.

ll_file_list_d-icon = '@NB@'.

ll_file_list_d-file_id = 'BUF'.

ll_file_list_d-type = 'BUF File'(145).

elseif lw_extenc cs '.pcf'.

ll_file_list_d-icon = '@AI@'.

ll_file_list_d-file_id = 'PCF'.

ll_file_list_d-type = 'PCF File'(146).

elseif lw_extenc cs '.out'.

ll_file_list_d-icon = '@AI@'.

ll_file_list_d-file_id = 'OUT'.

ll_file_list_d-type = 'OUT File'(147).

elseif lw_extenc cs '.hot'.

ll_file_list_d-icon = '@9N@'.

ll_file_list_d-file_id = 'HOT'.

ll_file_list_d-type = 'HOT File'(148).

elseif lw_extenc cs '.spc'.

ll_file_list_d-icon = '@9P@'.

ll_file_list_d-file_id = 'SPC'.

ll_file_list_d-type = 'PKCS Certificates'(149).

Page 53: SAP File Explorer

elseif lw_extenc cs '.exe'.

ll_file_list_d-icon = '@9X@'.

ll_file_list_d-file_id = 'EXE'.

ll_file_list_d-type = 'Application'(150).

elseif lw_extenc cs '.sar'.

ll_file_list_d-icon = '@9Y@'.

ll_file_list_d-file_id = 'SAR'.

ll_file_list_d-type = 'SAR File'(151).

elseif lw_extenc cs '.bat'.

ll_file_list_d-icon = '@9U@'.

ll_file_list_d-file_id = 'BAT'.

ll_file_list_d-type_f = c_asc.

ll_file_list_d-type = 'MS-DOS Batch File'(152).

elseif lw_extenc cs '.tar'.

ll_file_list_d-icon = '@9U@'.

ll_file_list_d-file_id = 'TAR'.

ll_file_list_d-type = 'TAR File'(153).

elseif lw_extenc cs '.ora'.

ll_file_list_d-icon = '@9U@'.

ll_file_list_d-file_id = 'ORA'.

ll_file_list_d-type = 'ORA File'(154).

elseif lw_extenc cs '.dba'.

ll_file_list_d-icon = '@9U@'.

ll_file_list_d-file_id = 'DBA'.

ll_file_list_d-type = 'DBA File'(155).

elseif lw_extenc cs '.sh'.

ll_file_list_d-icon = '@9U@'.

ll_file_list_d-file_id = 'SH'.

ll_file_list_d-type = 'SH File'(156).

elseif lw_extenc cs '.bak'.

ll_file_list_d-icon = '@9V@'.

ll_file_list_d-file_id = 'BAK'.

ll_file_list_d-type_f = c_asc.

ll_file_list_d-type = 'BAK File'(157).

elseif lw_extenc cs '.pfb'.

ll_file_list_d-icon = '@AI@'.

ll_file_list_d-file_id = 'PFB'.

ll_file_list_d-type = 'PFB File'(158).

elseif lw_extenc cs '.ppt'.

ll_file_list_d-icon = '@J5@'.

ll_file_list_d-file_id = 'PPT'.

ll_file_list_d-type = 'Microsoft Office PowerPoint Presentation'(159).

elseif lw_extenc cs '.dot'.

ll_file_list_d-icon = '@J6@'.

ll_file_list_d-file_id = 'DOT'.

ll_file_list_d-type = 'Microsoft Office Word Template'(160).

elseif lw_extenc cs '.tpl'.

Page 54: SAP File Explorer

ll_file_list_d-icon = '@A7@'.

ll_file_list_d-file_id = 'TPL'.

ll_file_list_d-type = 'TPL File'(161).

elseif lw_extenc cs '.eml'.

ll_file_list_d-icon = '@J8@'.

ll_file_list_d-file_id = 'EML'.

ll_file_list_d-type = 'Outlook Express Mail Message'(162).

elseif lw_extenc cs '.rtf'.

ll_file_list_d-icon = '@J9@'.

ll_file_list_d-file_id = 'RTF'.

ll_file_list_d-type = 'Rich Text Format'(163).

elseif lw_extenc cs '.pdf'.

ll_file_list_d-icon = '@IT@'.

ll_file_list_d-file_id = 'PDF'.

ll_file_list_d-type = 'Adobe Acrobat Document'(164).

elseif lw_extenc cs '.ps'.

ll_file_list_d-icon = '@IT@'.

ll_file_list_d-file_id = 'PS'.

ll_file_list_d-type = 'TPS File'(165).

elseif lw_extenc cs '.otf'.

ll_file_list_d-icon = '@OA@'.

ll_file_list_d-file_id = 'OTF'.

ll_file_list_d-type = 'OTF Document'(166).

elseif lw_extenc cs '.tif'.

ll_file_list_d-icon = '@JA@'.

ll_file_list_d-file_id = 'TIF'.

ll_file_list_d-type = 'TIF Image Document'(167).

elseif lw_extenc cs '.ico'.

ll_file_list_d-icon = '@GZ@'.

ll_file_list_d-file_id = 'ICO'.

ll_file_list_d-type = 'Icon'(168).

elseif lw_extenc cs '.gif'.

ll_file_list_d-icon = '@IW@'.

ll_file_list_d-file_id = 'GIF'.

ll_file_list_d-type = 'GIF Image'(169).

elseif lw_extenc cs '.wri'.

ll_file_list_d-icon = '@JB@'.

ll_file_list_d-file_id = 'WRI'.

ll_file_list_d-type = 'Write Document'(170).

elseif lw_extenc cs '.prd'.

ll_file_list_d-icon = '@EW@'.

ll_file_list_d-file_id = 'PRD'.

ll_file_list_d-type = 'PRD File'(171).

elseif lw_extenc cs '.prn'.

ll_file_list_d-icon = '@0X@'.

ll_file_list_d-file_id = 'PRN'.

ll_file_list_d-type = 'PRN File'(172).

Page 55: SAP File Explorer

elseif lw_extenc cs '.xpm'.

ll_file_list_d-icon = '@EU@'.

ll_file_list_d-file_id = 'XPM'.

ll_file_list_d-type = 'XPM File'(173).

elseif lw_extenc cs '.vsd'.

ll_file_list_d-icon = '@JE@'.

ll_file_list_d-file_id = 'VSD'.

ll_file_list_d-type = 'Microsoft Visio Document'(174).

elseif lw_extenc cs '.bmp'.

ll_file_list_d-icon = '@IU@'.

ll_file_list_d-file_id = 'BMP'.

ll_file_list_d-type = 'Bitmap Image'(175).

elseif lw_extenc cs '.png'.

ll_file_list_d-icon = '@IU@'.

ll_file_list_d-file_id = 'PNG'.

ll_file_list_d-type = 'PNG Image'(176).

elseif lw_extenc cs '.xls'.

ll_file_list_d-icon = '@J2@'.

ll_file_list_d-file_id = 'XLS'.

ll_file_list_d-type = 'Microsoft Office Excel Worksheet'(177).

elseif lw_extenc cs '.csv'.

ll_file_list_d-icon = '@J2@'.

ll_file_list_d-file_id = 'CSV'.

ll_file_list_d-type = 'Microsoft Office Excel Comma Separated Values File'(201).

elseif lw_extenc cs '.jpg'.

ll_file_list_d-icon = '@J0@'.

ll_file_list_d-file_id = 'JPG'.

ll_file_list_d-type = 'JPEG Image'(178).

elseif lw_extenc cs '.xwd'.

ll_file_list_d-icon = '@J0@'.

ll_file_list_d-file_id = 'XWD'.

ll_file_list_d-type = 'XWD File'(179).

elseif lw_extenc cs '.xbm'.

ll_file_list_d-icon = '@NI@'.

ll_file_list_d-file_id = 'XBM'.

ll_file_list_d-type = 'XBM File'(180).

elseif lw_extenc cs '.zip'.

ll_file_list_d-icon = '@12@'.

ll_file_list_d-file_id = 'ZIP'.

ll_file_list_d-type = 'Compressed (zipped) Folder'(181).

elseif lw_extenc cs '.dat'.

ll_file_list_d-icon = '@IF@'.

ll_file_list_d-file_id = 'DAT'.

ll_file_list_d-type = 'DAT File'(182).

elseif lw_extenc cs '.mon'.

ll_file_list_d-icon = '@IF@'.

ll_file_list_d-file_id = 'MON'.

Page 56: SAP File Explorer

ll_file_list_d-type = 'MON File'(183).

elseif lw_extenc cs '.inp'.

ll_file_list_d-icon = '@IF@'.

ll_file_list_d-file_id = 'INP'.

ll_file_list_d-type = 'INP File'(184).

elseif lw_extenc cs '.pfl'.

ll_file_list_d-icon = '@IF@'.

ll_file_list_d-file_id = 'PFL'.

ll_file_list_d-type = 'PFL File'(185).

elseif lw_extenc cs '.car'.

ll_file_list_d-icon = '@IF@'.

ll_file_list_d-file_id = 'CAR'.

ll_file_list_d-type = 'CAR File'(186).

elseif lw_extenc cs '.mss'.

ll_file_list_d-icon = '@IF@'.

ll_file_list_d-file_id = 'MSS'.

ll_file_list_d-type = 'MSS File'(187).

elseif lw_extenc cs '.asp'.

ll_file_list_d-icon = '@9U@'.

ll_file_list_d-file_id = 'ASP'.

ll_file_list_d-type = 'ASP File'(188).

elseif lw_extenc cs '.ccs'.

ll_file_list_d-icon = '@9U@'.

ll_file_list_d-file_id = 'CCS'.

ll_file_list_d-type = 'CCS File'(189).

elseif lw_extenc cs '.sc1'.

ll_file_list_d-icon = '@9U@'.

ll_file_list_d-file_id = 'SC1'.

ll_file_list_d-type = 'SC1 File'(190).

elseif lw_extenc cs '.ext'.

ll_file_list_d-icon = '@O8@'.

ll_file_list_d-file_id = 'EXT'.

ll_file_list_d-type = 'EXT File'(191).

elseif lw_extenc cs '.lib'.

ll_file_list_d-icon = '@DH@'.

ll_file_list_d-file_id = 'LIB'.

ll_file_list_d-type = 'LIB File'(192).

elseif lw_extenc cs '.http'.

ll_file_list_d-icon = '@IX@'.

ll_file_list_d-file_id = 'HTP'.

ll_file_list_d-type = 'HTTP File'(193).

elseif lw_extenc cs '.avi'.

ll_file_list_d-icon = '@5L@'.

ll_file_list_d-file_id = 'AVI'.

ll_file_list_d-type = 'Video Clip'(194).

elseif lw_extenc cs '.wav'.

ll_file_list_d-icon = '@5L@'.

Page 57: SAP File Explorer

ll_file_list_d-file_id = 'WAV'.

ll_file_list_d-type = 'Wave Sound'(195).

elseif lw_extenc cs '.snd'.

ll_file_list_d-icon = '@5L@'.

ll_file_list_d-file_id = 'SND'.

ll_file_list_d-type = 'AU Format Sound'(196).

elseif lw_extenc cs '.mp3'.

ll_file_list_d-icon = '@5L@'.

ll_file_list_d-file_id = 'MP3'.

ll_file_list_d-type = 'MP3 Format Sound'(197).

elseif lw_extenc cs '.sql'.

ll_file_list_d-icon = '@PO@'.

ll_file_list_d-file_id = 'SQL'.

ll_file_list_d-type = 'SQL File'(198).

elseif lw_extenc cs '.jar'.

ll_file_list_d-icon = '@N5@'.

ll_file_list_d-file_id = 'JAR'.

ll_file_list_d-type = 'Executable Jar File'(200).

else.

ll_file_list_d-icon = '@O9@'.

shift lw_extenc right deleting trailing space.

search ll_file_list_d-name for c_dot.

if sy-subrc is initial.

ll_file_list_d-file_id = lw_extenc+2(3).

ll_file_list_d-type_f = c_asc.

ll_file_list_d-type = 'File'(199).

else.

ll_file_list_d-file_id = 'ANY'.

ll_file_list_d-type_f = c_asc.

ll_file_list_d-type = 'File'(199).

endif.

endif.

when others.

ll_file_list_d-icon = '@IH@'.

endcase.

append ll_file_list_d to i_file_list_d.

endloop.

clear: lw_lenght.

describe table i_file_list_d lines lw_lenght.

Page 58: SAP File Explorer

if lw_lenght is initial.

clear: ll_file_list_d.

ll_file_list_d-type_id = 'Z'.

ll_file_list_d-file_id = 'ZZZ'.

while lw_lenght < c_25.

append ll_file_list_d to i_file_list_d.

lw_lenght = lw_lenght + 1.

endwhile.

endif.

endform. " prepare_display_layout

*-----------------------------------------------------------------------

* Form free_control

*-----------------------------------------------------------------------

form free_control .

* Free containers

call method o_tree_cont->free.

call method o_file_cont->free.

* Clear Data

perform clear_data.

set screen 0. leave screen.

endform. " free_control

*-----------------------------------------------------------------------

* Form get_file_list

*-----------------------------------------------------------------------

form get_file_list using fuw_path type any

fuw_file type any.

data:

ll_file type t_file,

ll_file_list type zxis_0x_file.

data:

lw_path_name type localfile,

lw_file_name type localfile,

lw_errcnt type p,

lw_date type char8,

lw_length3(16) type p.

w_path_name = fuw_path.

lw_path_name = fuw_path.

lw_file_name = fuw_file.

Page 59: SAP File Explorer

clear: ll_file, i_file_list, ll_file_list.

refresh: i_file_list.

perform check_path_name changing lw_path_name

lw_file_name.

* End of directory read (initialize)

call 'C_DIR_READ_FINISH' id c_errno field ll_file-errno

id c_errmsg field ll_file-errmsg.

call 'C_DIR_READ_START' id c_dir field lw_path_name

id c_file field lw_file_name

id c_errno field ll_file-errno

id c_errmsg field ll_file-errmsg.

if sy-subrc <> 0.

* Access Error

message id c_msgig_fsev type c_msgty_s number c_msgno_003

with ll_file-errmsg.

else.

do.

clear ll_file.

call 'C_DIR_READ_NEXT'

id c_type field ll_file-type

id c_name field ll_file-name

id c_len field ll_file-len

id c_owner field ll_file-owner

id c_mtime field ll_file-mtime

id c_mode field ll_file-mode

id c_errno field ll_file-errno

id c_errmsg field ll_file-errmsg.

ll_file-dirname = lw_path_name.

move sy-subrc to ll_file-subrc.

case sy-subrc.

when 0.

clear: ll_file-errno, ll_file-errmsg.

case ll_file-type(1).

when c_fu. " normal file.

perform filename_useable

Page 60: SAP File Explorer

using ll_file-name ll_file-useable.

when c_fl. " normal file.

perform filename_useable

using ll_file-name ll_file-useable.

when others. " directory, device, fifo, socket.

move c_sap_no to ll_file-useable.

endcase.

if ll_file-len = 0.

move c_sap_no to ll_file-useable.

endif.

when 1.

exit.

when others. " SY-SUBRC >= 2

add 1 to lw_errcnt.

if lw_errcnt > 10.

exit.

endif.

if sy-subrc = 5.

move: c_qstmrk to ll_file-type,

c_qstmrk to ll_file-owner,

c_qstmrk to ll_file-mode.

endif.

move c_sap_no to ll_file-useable.

endcase.

perform date_time_tz using ll_file-mtime

ll_file-mod_time

ll_file-mod_date.

if ll_file-subrc = 0.

if ll_file-type = 'directory'(005).

ll_file-type = 'Directory'(006).

ll_file-type_id = c_d.

if ll_file-name = c_dot.

ll_file_list-file_id = c_dira.

elseif ll_file-name(2) = c_ddot.

ll_file_list-file_id = c_dirb.

Page 61: SAP File Explorer

else.

ll_file_list-file_id = c_dirc.

endif.

elseif ll_file-type = c_filr.

ll_file-type = 'File'(001).

ll_file-type_id = c_fu.

ll_file_list-file_id(1) = c_fu.

else.

ll_file-type = space.

ll_file-type_id = c_z.

ll_file_list-file_id(1) = c_z.

endif.

lw_length3 = ll_file-len.

lw_date = ll_file-mod_date.

move-corresponding ll_file to ll_file_list.

ll_file_list-date = lw_date.

write lw_length3 to ll_file_list-len

using edit mask c_editm_rr.

shift ll_file_list-len left deleting leading ' .'.

shift ll_file_list-len right deleting trailing space.

write lw_date to ll_file_list-mod_date

using edit mask c_editm_dt.

if ll_file-name(1) = c_dot

or ll_file-name(2) = c_ddot.

clear: ll_file.

else.

ll_file_list-seen = c_r.

append ll_file_list to i_file_list.

endif.

endif.

enddo.

sort i_file_list ascending by type_id file_id name.

endif.

endform. " get_file_list

*-----------------------------------------------------------------------

Page 62: SAP File Explorer

* Form get_loc_file_list

*-----------------------------------------------------------------------

form get_loc_file_list using fuw_path type any

fuw_file type any.

data:

li_file_tab type standard table of file_info.

data:

ll_file_list type zxis_0x_file,

ll_file_tab type file_info.

data:

lw_count type i,

lw_path_name type string,

lw_file_name type string,

lw_date type char8,

lw_list type abap_bool value c_x.

w_lpath_name = fuw_path.

lw_path_name = fuw_path.

lw_file_name = fuw_file.

if lw_path_name is initial.

lw_path_name = c_win_root.

endif.

w_file_path = w_server_path = w_search_path

= lw_path_name.

clear: i_file_list, ll_file_list.

refresh: i_file_list.

* Get Folders in a Given Directory

call method o_gui_serv->directory_list_files

exporting

directory = lw_path_name

filter = lw_file_name

directories_only = lw_list

changing

file_table = li_file_tab

count = lw_count

exceptions

cntl_error = 1

directory_list_files_failed = 2

wrong_parameter = 3

error_no_gui = 4

Page 63: SAP File Explorer

not_supported_by_gui = 5

others = 6.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

loop at li_file_tab into ll_file_tab.

clear: ll_file_list.

ll_file_list-dirname = lw_path_name.

ll_file_list-name = ll_file_tab-filename.

ll_file_list-type_id = c_d.

ll_file_list-file_id = c_dirc.

ll_file_list-type = 'Directory'(006).

ll_file_list-len = ll_file_tab-filelength.

ll_file_list-mtime = ll_file_tab-createtime.

ll_file_list-date = ll_file_tab-createdate.

ll_file_list-mod_time = ll_file_tab-createtime.

ll_file_list-seen = c_f.

lw_date = ll_file_tab-createdate.

write lw_date to ll_file_list-mod_date

using edit mask c_editm_dt.

append ll_file_list to i_file_list.

endloop.

clear: li_file_tab, lw_count.

* Get Files in a Given Directory

call method o_gui_serv->directory_list_files

exporting

directory = lw_path_name

filter = lw_file_name

files_only = lw_list

changing

file_table = li_file_tab

count = lw_count

exceptions

cntl_error = 1

directory_list_files_failed = 2

wrong_parameter = 3

error_no_gui = 4

not_supported_by_gui = 5

others = 6.

Page 64: SAP File Explorer

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

loop at li_file_tab into ll_file_tab.

clear: ll_file_list.

ll_file_list-dirname = lw_path_name.

ll_file_list-name = ll_file_tab-filename.

ll_file_list-type_id = c_f.

ll_file_list-file_id = c_firc.

ll_file_list-type = 'File'(001).

ll_file_list-len = ll_file_tab-filelength.

ll_file_list-mtime = ll_file_tab-createtime.

ll_file_list-date = ll_file_tab-createdate.

ll_file_list-mod_time = ll_file_tab-createtime.

ll_file_list-seen = c_f.

lw_date = ll_file_tab-createdate.

write lw_date to ll_file_list-mod_date

using edit mask c_editm_dt.

append ll_file_list to i_file_list.

endloop.

sort i_file_list ascending by type_id file_id name.

endform. " get_loc_file_list

*-----------------------------------------------------------------------

* Form search_loc_pc

*-----------------------------------------------------------------------

form search_loc_pc tables fti_file_list structure zxis_0x_file

using fuw_path type any

fuw_file type any.

data:

li_file_tab type standard table of file_info,

li_folder_list type standard table of zxis_0x_file.

data:

ll_file_list type zxis_0x_file,

ll_folder_list type zxis_0x_file,

ll_file_tab type file_info.

Page 65: SAP File Explorer

data:

lw_count type i,

lw_chag_name type zxis_dirname,

lw_path_name type string,

lw_file_name type string,

lw_date type char8,

lw_list type abap_bool value c_x.

clear: fti_file_list.

refresh: fti_file_list.

lw_chag_name = fuw_path.

lw_file_name = fuw_file.

if lw_chag_name is initial.

lw_chag_name = c_win_root.

endif.

shift lw_chag_name right deleting trailing space.

if lw_chag_name+599(1) = c_back_slash.

lw_chag_name+599(1) = space.

endif.

shift lw_chag_name left deleting leading space.

ll_folder_list-dirname = lw_chag_name.

append ll_folder_list to li_folder_list.

clear: ll_folder_list.

lw_path_name = lw_chag_name.

* Get all sub folders

perform get_folders tables li_folder_list

using lw_path_name.

loop at li_folder_list into ll_folder_list.

clear: lw_path_name, li_file_tab, lw_count.

lw_path_name = ll_folder_list-dirname.

* Get Folders in a Given Directory

call method o_gui_serv->directory_list_files

exporting

directory = lw_path_name

filter = lw_file_name

directories_only = lw_list

changing

file_table = li_file_tab

count = lw_count

exceptions

Page 66: SAP File Explorer

cntl_error = 1

directory_list_files_failed = 2

wrong_parameter = 3

error_no_gui = 4

not_supported_by_gui = 5

others = 6.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

loop at li_file_tab into ll_file_tab.

clear: ll_file_list.

ll_file_list-dirname = lw_path_name.

ll_file_list-name = ll_file_tab-filename.

ll_file_list-type_id = c_d.

ll_file_list-file_id = c_dirc.

ll_file_list-type = 'Directory'(006).

ll_file_list-len = ll_file_tab-filelength.

ll_file_list-mtime = ll_file_tab-createtime.

ll_file_list-date = ll_file_tab-createdate.

ll_file_list-mod_time = ll_file_tab-createtime.

ll_file_list-seen = c_f.

lw_date = ll_file_tab-createdate.

write lw_date to ll_file_list-mod_date

using edit mask c_editm_dt.

append ll_file_list to fti_file_list.

endloop.

clear: li_file_tab, lw_count.

* Get Files in a Given Directory

call method o_gui_serv->directory_list_files

exporting

directory = lw_path_name

filter = lw_file_name

files_only = lw_list

changing

file_table = li_file_tab

count = lw_count

exceptions

cntl_error = 1

directory_list_files_failed = 2

Page 67: SAP File Explorer

wrong_parameter = 3

error_no_gui = 4

not_supported_by_gui = 5

others = 6.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

loop at li_file_tab into ll_file_tab.

clear: ll_file_list.

ll_file_list-dirname = lw_path_name.

ll_file_list-name = ll_file_tab-filename.

ll_file_list-type_id = c_f.

ll_file_list-file_id = c_firc.

ll_file_list-type = 'File'(001).

ll_file_list-len = ll_file_tab-filelength.

ll_file_list-mtime = ll_file_tab-createtime.

ll_file_list-date = ll_file_tab-createdate.

ll_file_list-mod_time = ll_file_tab-createtime.

ll_file_list-seen = c_f.

lw_date = ll_file_tab-createdate.

write lw_date to ll_file_list-mod_date

using edit mask c_editm_dt.

append ll_file_list to fti_file_list.

endloop.

endloop.

endform. " search_loc_pc

*-----------------------------------------------------------------------

* Form get_folders

*-----------------------------------------------------------------------

form get_folders tables fti_file_list structure zxis_0x_file

using fuw_path type any.

data:

li_file_tab type standard table of file_info,

li_folder_list type standard table of zxis_0x_file.

data:

ll_folder_list type zxis_0x_file,

ll_file_tab type file_info.

Page 68: SAP File Explorer

data:

lw_count type i,

lw_path_name type string,

lw_file_name type string,

lw_list type abap_bool value c_x.

lw_path_name = fuw_path.

lw_file_name = c_wlchar.

* Get Folders in a Given Directory

call method o_gui_serv->directory_list_files

exporting

directory = lw_path_name

filter = lw_file_name

directories_only = lw_list

changing

file_table = li_file_tab

count = lw_count

exceptions

cntl_error = 1

directory_list_files_failed = 2

wrong_parameter = 3

error_no_gui = 4

not_supported_by_gui = 5

others = 6.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

if li_file_tab[] is not initial.

loop at li_file_tab into ll_file_tab.

clear: ll_folder_list.

concatenate

lw_path_name

ll_file_tab-filename

into ll_folder_list-dirname separated by c_back_slash.

append ll_folder_list to li_folder_list.

endloop.

append lines of li_folder_list to fti_file_list.

loop at li_folder_list into ll_folder_list.

* Get recursive all sub folders

perform get_folders tables fti_file_list

Page 69: SAP File Explorer

using ll_folder_list-dirname.

endloop.

else.

exit.

endif.

endform. " get_folders

*-----------------------------------------------------------------------

* Form check_path_name

*-----------------------------------------------------------------------

form check_path_name changing fcw_path_name type any

fcw_file_name type any.

data:

ll_file_list type zxis_0x_file.

data:

lw_file_type type char10,

lw_errno type char3,

lw_errmsg type char40,

lw_length type i,

lw_length1 type i.

if fcw_path_name is initial.

if sy-opsys = 'Windows NT'(009).

fcw_path_name = c_win_root.

elseif sy-opsys = c_aix.

fcw_path_name = c_slash.

elseif sy-opsys = c_unix.

fcw_path_name = c_slash.

endif.

else.

if sy-opsys = 'Windows NT'(009).

if fcw_path_name+1(2) <> c_wroot.

clear: fcw_path_name.

fcw_path_name(3) = c_win_root.

endif.

elseif sy-opsys = c_aix.

if fcw_path_name(1) <> c_slash.

concatenate

c_slash

fcw_path_name

into fcw_path_name.

endif.

elseif sy-opsys = c_unix.

if fcw_path_name(1) <> c_slash.

Page 70: SAP File Explorer

concatenate

c_slash

fcw_path_name

into fcw_path_name.

endif.

endif.

endif.

call 'C_DIR_READ_FINISH' id c_errno field ll_file_list-errno

id c_errmsg field ll_file_list-errmsg.

call 'C_DIR_READ_START' id c_dir field fcw_path_name

id c_file field fcw_file_name

id c_errno field lw_errno

id c_errmsg field lw_errmsg.

call 'C_DIR_READ_NEXT' id c_type field lw_file_type.

if lw_errno <> 0.

* No such file or directory

if lw_errno = c_err2.

if sy-opsys = 'Windows NT'(009).

fcw_path_name = c_win_root.

elseif sy-opsys = c_aix.

fcw_path_name = c_slash.

elseif sy-opsys = c_unix.

fcw_path_name = c_slash.

endif.

w_file_path = w_server_path = fcw_path_name.

endif.

* Access Error

message id c_msgig_fsev type c_msgty_s number c_msgno_003

with lw_errmsg.

else.

if lw_file_type = 'directory'(005).

lw_length = strlen( fcw_path_name ).

lw_length1 = lw_length - 1.

if lw_length1 < c_0.

lw_length1 = c_0.

endif.

if fcw_path_name+lw_length1(1) <> c_slash.

if sy-opsys = c_aix or sy-opsys = c_unix.

fcw_path_name+lw_length(1) = c_slash.

Page 71: SAP File Explorer

elseif sy-opsys = 'Windows NT'(009)

and not fcw_path_name+lw_length1(1) = c_back_slash.

fcw_path_name+lw_length(1) = c_back_slash.

endif.

endif.

elseif lw_file_type = c_filr.

if fcw_file_name = c_wlchar.

if not sy-opsys = 'Windows NT'(009).

perform split_name changing fcw_path_name

fcw_file_name.

endif.

endif.

endif.

endif.

endform. " check_path_name

*-----------------------------------------------------------------------

* Form filename_useable

*-----------------------------------------------------------------------

form filename_useable using fuw_file_name type any

fuw_file_useable type any.

data:

lw_name type char300.

lw_name = fuw_file_name.

if lw_name(4) = c_core.

fuw_file_useable = c_sap_no.

else.

fuw_file_useable = c_sap_yes.

endif.

endform. " filename_useable

*-----------------------------------------------------------------------

* Form date_time_tz

*-----------------------------------------------------------------------

form date_time_tz using fuw_file_mtime type any

fuw_file_mod_time type any

fuw_file_mod_date type any.

data:

Page 72: SAP File Explorer

lw_opcode type x,

lw_timestamp type i,

lw_date type d,

lw_time type t,

lw_tz type systzonlo,

lw_timestring type char10,

lw_abapstamp type char14,

lw_abaptstamp type timestamp.

lw_timestamp = fuw_file_mtime.

if sy-zonlo = space.

lw_tz = sy-tzone.

concatenate c_utc lw_tz into lw_tz.

else.

lw_tz = sy-zonlo.

endif.

lw_opcode = c_3.

call 'RstrDateConv' id c_opcode field lw_opcode

id c_tstamp field lw_timestamp

id c_abstamp field lw_abapstamp.

lw_abaptstamp = lw_abapstamp.

convert time stamp lw_abaptstamp

time zone lw_tz

into date lw_date

time lw_time.

if sy-subrc <> 0.

lw_date = lw_abapstamp(8).

lw_time = lw_abapstamp+8.

endif.

write: lw_time(2) to lw_timestring(2),

c_vdot to lw_timestring+2(1),

lw_time+2(2) to lw_timestring+3(2),

c_vdot to lw_timestring+5(1),

lw_time+4(2) to lw_timestring+6(2).

move lw_timestring to fuw_file_mod_time.

move lw_date to fuw_file_mod_date.

endform. " date_time_tz

*-----------------------------------------------------------------------

Page 73: SAP File Explorer

* Form split_name

*-----------------------------------------------------------------------

form split_name changing fcw_path_name type any

fcw_file_name type any.

data:

lw_subrc type sysubrc.

fcw_file_name = fcw_path_name.

clear: lw_subrc, fcw_path_name.

while lw_subrc is initial.

search fcw_file_name for c_slash.

if sy-subrc is initial.

w_strlen = sy-fdpos + 1.

concatenate

fcw_path_name

fcw_file_name(w_strlen)

into fcw_path_name.

move space to fcw_file_name(w_strlen).

shift fcw_file_name left deleting leading space.

else.

lw_subrc = sy-subrc.

endif.

endwhile.

endform. " split_name

*-----------------------------------------------------------------------

* Form split_lname

*-----------------------------------------------------------------------

form split_lname changing fcw_path_name type any

fcw_file_name type any.

data:

lw_subrc type sysubrc.

fcw_file_name = fcw_path_name.

clear: lw_subrc, fcw_path_name.

while lw_subrc is initial.

Page 74: SAP File Explorer

search fcw_file_name for c_back_slash.

if sy-subrc is initial.

w_strlen = sy-fdpos + 1.

concatenate

fcw_path_name

fcw_file_name(w_strlen)

into fcw_path_name.

move space to fcw_file_name(w_strlen).

shift fcw_file_name left deleting leading space.

else.

lw_subrc = sy-subrc.

endif.

endwhile.

endform. " split_lname

*-----------------------------------------------------------------------

* Form tree_prepare

*-----------------------------------------------------------------------

form tree_prepare .

data:

ll_node type t_node,

ll_node_layout type lvc_s_layn.

data:

lw_node_text type lvc_value,

lw_node_key type lvc_nkey,

lw_relationship type i.

lw_node_key = space.

lw_node_text = c_slash.

lw_relationship = c_0.

ll_node_layout-isfolder = c_x.

ll_node_layout-expander = c_x.

ll_node_layout-dragdropid = w_handle_tree.

* Add Node to Table

call method o_tree->add_node

exporting

i_relat_node_key = lw_node_key

Page 75: SAP File Explorer

i_relationship = lw_relationship

is_node_layout = ll_node_layout

i_node_text = lw_node_text

importing

e_new_node_key = w_nnode_key

exceptions

relat_node_not_found = 1

node_not_found = 2

others = 3.

if sy-subrc <> 0.

message id sy-msgid type c_msgty_s number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

else.

* Send data to frontend

call method o_tree->frontend_update.

read table i_node into ll_node

with key node_key = w_nnode_key

name = lw_node_text.

if sy-subrc is not initial.

clear: ll_node.

ll_node-node_key = w_nnode_key.

ll_node-name = lw_node_text.

append ll_node to i_node.

endif.

endif.

endform. " tree_prepare

*-----------------------------------------------------------------------

* Form local_tree_prepare

*-----------------------------------------------------------------------

form local_tree_prepare .

data:

ll_drv type t_drv,

ll_node type t_node,

ll_node_layout type lvc_s_layn.

data:

lw_node_text type lvc_value,

lw_node_key type lvc_nkey,

lw_relationship type i.

Page 76: SAP File Explorer

loop at i_drv into ll_drv.

clear: lw_node_key, lw_node_text, lw_relationship, ll_node_layout.

lw_node_text = ll_drv-desc.

lw_relationship = c_0.

ll_node_layout-isfolder = c_x.

ll_node_layout-expander = c_x.

ll_node_layout-dragdropid = w_handle_tree.

ll_node_layout-n_image = '@G6@'.

ll_node_layout-exp_image = '@G6@'.

* Add Node to Table

call method o_treel->add_node

exporting

i_relat_node_key = lw_node_key

i_relationship = lw_relationship

is_node_layout = ll_node_layout

i_node_text = lw_node_text

importing

e_new_node_key = w_lnode_key

exceptions

relat_node_not_found = 1

node_not_found = 2

others = 3.

if sy-subrc <> 0.

message id sy-msgid type c_msgty_s number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

else.

* Send data to frontend

call method o_treel->frontend_update.

read table i_nodel into ll_node

with key node_key = w_lnode_key

name = lw_node_text.

if sy-subrc is not initial.

clear: ll_node.

ll_node-node_key = w_lnode_key.

ll_node-name = lw_node_text.

ll_node-drive = ll_drv-drive.

append ll_node to i_nodel.

endif.

endif.

endloop.

* Get Local File System Data

clear: ll_drv, w_lnode_key.

Page 77: SAP File Explorer

read table i_drv into ll_drv with key type = c_fixed.

read table i_nodel into ll_node

with key dirname = space

drive = ll_drv-drive.

w_lnode_key = ll_node-node_key.

endform. " local_tree_prepare

*-----------------------------------------------------------------------

* Form getto_dest_path

*-----------------------------------------------------------------------

form getto_dest_path using fuw_path type char200

changing fcw_key type tv_nodekey.

types:

begin of lt_path_tab,

dirname type localfile,

end of lt_path_tab.

data:

li_path_tab type standard table of lt_path_tab.

data:

ll_node type t_node,

ll_path_tab type lt_path_tab.

data:

lw_path type localfile,

lw_ppath type localfile,

lw_file type char1 value c_wlchar,

lw_node_key type tv_nodekey.

* Get dir names

split fuw_path at c_slash into table li_path_tab.

delete li_path_tab where dirname is initial.

lw_path = c_slash.

* Get path

loop at li_path_tab into ll_path_tab.

concatenate

lw_path

ll_path_tab-dirname

c_slash

into lw_path.

Page 78: SAP File Explorer

condense lw_path no-gaps.

* Find Path

w_find_path = lw_path.

if lw_ppath is initial.

lw_ppath = c_slash.

endif.

* Find Routine

perform get_file_list using lw_path

lw_file.

* Log displayed folders

perform add_table_lines.

read table i_node into ll_node

with key name = ll_path_tab-dirname

dirname = lw_ppath.

if sy-subrc is initial.

lw_node_key = ll_node-node_key.

endif.

* Add Folders

perform add_node using lw_node_key.

lw_ppath = lw_path.

endloop.

if w_src is initial.

* Set ALV Display Layout

perform set_grid_layout.

endif.

* Change node

if lw_node_key is not initial.

fcw_key = lw_node_key.

elseif w_node_key is not initial.

fcw_key = w_node_key.

endif.

endform. " getto_dest_path

*-----------------------------------------------------------------------

* Form expand_node

*-----------------------------------------------------------------------

form expand_node using fuw_key type tv_nodekey.

Page 79: SAP File Explorer

data:

lw_node_key type tv_nodekey.

lw_node_key = fuw_key.

* Expands all Root Nodes

call method o_tree->expand_node

exporting

i_node_key = lw_node_key

exceptions

failed = 1

illegal_level_count = 2

cntl_system_error = 3

node_not_found = 4

cannot_expand_leaf = 5

others = 6.

if sy-subrc <> 0.

message id sy-msgid type c_msgty_s number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

else.

* Send data to frontend

call method o_tree->frontend_update.

call method cl_gui_cfw=>flush.

endif.

endform. " expand_node

*-----------------------------------------------------------------------

* Form expand_local_node

*-----------------------------------------------------------------------

form expand_local_node using fuw_key type tv_nodekey.

data:

lw_node_key type tv_nodekey.

lw_node_key = fuw_key.

* Expands all Root Nodes

call method o_treel->expand_node

exporting

i_node_key = lw_node_key

exceptions

failed = 1

illegal_level_count = 2

cntl_system_error = 3

Page 80: SAP File Explorer

node_not_found = 4

cannot_expand_leaf = 5

others = 6.

if sy-subrc <> 0.

message id sy-msgid type c_msgty_s number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

else.

* Send data to frontend

call method o_treel->frontend_update.

call method cl_gui_cfw=>flush.

endif.

endform. " expand_local_node

*-----------------------------------------------------------------------

* Form node_double_click

*-----------------------------------------------------------------------

form node_double_click using fuw_node_key type tv_nodekey.

data:

ll_node type t_node,

ll_file_list type zxis_0x_file.

data:

lw_length type i,

lw_length1 type i,

lw_path_name type localfile,

lw_path type localfile,

lw_file type char1 value c_wlchar,

lw_node_key type tv_nodekey.

lw_node_key = fuw_node_key.

read table i_node into ll_node

with key node_key = lw_node_key.

if sy-subrc is initial.

lw_path_name = ll_node-dirname.

lw_length = strlen( lw_path_name ).

lw_length1 = lw_length - 1.

if lw_length1 < c_0.

lw_length1 = c_0.

endif.

Page 81: SAP File Explorer

if lw_path_name+lw_length1(1) <> c_slash.

if sy-opsys = c_aix or sy-opsys = c_unix.

lw_path_name+lw_length(1) = c_slash.

endif.

endif.

if ll_node-name <> c_slash.

concatenate

lw_path_name

ll_node-name

c_slash

into lw_path.

else.

lw_path = lw_path_name.

endif.

* Find Path

w_find_path = lw_path.

w_file_path = lw_path.

w_dysp_path = lw_path.

* Find Routine

perform get_file_list using lw_path

lw_file.

read table i_log_list into ll_file_list

with key dirname = lw_path.

if sy-subrc is not initial

and ll_node-name <> c_slash.

* Log displayed folders

perform add_table_lines.

* Add Folders

perform add_node using lw_node_key.

endif.

* Set ALV Display Layout

perform set_grid_layout.

endif.

set handler o_eventh->handle_double_click for o_grid.

set handler o_eventh->handle_ondrag for o_grid.

set handler o_eventh->handle_on_grid_drop for o_grid.

set handler o_eventh->handle_ondropcomplete for o_grid.

Page 82: SAP File Explorer

endform. " node_double_click

*-----------------------------------------------------------------------

* Form lnode_double_click

*-----------------------------------------------------------------------

form lnode_double_click using fuw_node_key type tv_nodekey.

data:

ll_node type t_node,

ll_file_list type zxis_0x_file.

data:

lw_length type i,

lw_length1 type i,

lw_path_name type localfile,

lw_path type localfile,

lw_file type char1 value c_wlchar,

lw_node_key type tv_nodekey.

lw_node_key = fuw_node_key.

read table i_nodel into ll_node

with key node_key = lw_node_key.

if sy-subrc is initial.

if ll_node-dirname is not initial.

lw_path_name = ll_node-dirname.

lw_length = strlen( lw_path_name ).

lw_length1 = lw_length - 1.

if lw_length1 < c_0.

lw_length1 = c_0.

endif.

if lw_path_name+lw_length1(1) <> c_back_slash.

lw_path_name+lw_length(1) = c_back_slash.

endif.

concatenate

lw_path_name

ll_node-name

c_back_slash

into lw_path.

else.

lw_path = ll_node-drive.

endif.

Page 83: SAP File Explorer

* Find Path

w_find_path = lw_path.

w_file_path = lw_path.

w_dysp_path = lw_path.

* Find Routine

perform get_loc_file_list using lw_path

lw_file.

read table i_log_listl into ll_file_list

with key dirname = lw_path.

if sy-subrc is not initial

and ll_node-name <> c_back_slash.

* Log displayed folders

perform add_ltable_lines.

* Add Folders

perform local_add_node using lw_node_key.

endif.

* Set ALV Display Layout

perform set_grid_layout.

endif.

endform. " lnode_double_click

*-----------------------------------------------------------------------

* Form set_search_pattern

*-----------------------------------------------------------------------

form set_search_pattern .

* Initialize Screen

clear:

i_file_list, i_file_list_d, w_dct, i_node, i_log_list, i_kpath,

i_buftab_t, i_query_table, i_html.

w_perf = c_r.

w_srcd = c_x.

call method o_tree_cont->free.

if w_loc is initial.

w_find_path = w_file_path.

Page 84: SAP File Explorer

else.

w_find_path = w_path_name.

clear:

i_file_list, i_file_list_d, w_dct, i_nodel, i_log_listl, i_kpath,

i_buftab_t, i_query_table, i_html.

call method o_tree_contl->free.

endif.

endform. " set_search_pattern

*-----------------------------------------------------------------------

* Form set_lsearch_pattern

*-----------------------------------------------------------------------

form set_lsearch_pattern .

* Initialize Screen

clear:

i_file_list, i_file_list_d, w_dct, i_nodel, i_log_listl, i_kpath,

i_buftab_t, i_lquery_table, i_html.

w_find_path = w_file_path.

w_perf = c_f.

w_srcl = w_srcd = c_x.

call method o_tree_contl->free.

endform. " set_lsearch_pattern

*-----------------------------------------------------------------------

* Form expand_no_children

*-----------------------------------------------------------------------

form expand_no_children.

data:

ll_node type t_node.

data:

lw_length type i,

lw_length1 type i,

lw_path_name type localfile,

lw_path type localfile,

lw_file type char1 value c_wlchar.

read table i_node into ll_node

Page 85: SAP File Explorer

with key node_key = w_node_key.

if sy-subrc is initial.

lw_path_name = ll_node-dirname.

lw_length = strlen( lw_path_name ).

lw_length1 = lw_length - 1.

if lw_length1 < c_0.

lw_length1 = c_0.

endif.

if lw_path_name+lw_length1(1) <> c_slash.

if sy-opsys = c_aix or sy-opsys = c_unix.

lw_path_name+lw_length(1) = c_slash.

endif.

endif.

concatenate

lw_path_name

ll_node-name

c_slash

into lw_path.

* Find Path

w_file_path = lw_path.

w_find_path = lw_path.

* Find Routine

perform get_file_list using lw_path

lw_file.

* Log displayed folders

perform add_table_lines.

* Add Folders

perform add_node using w_node_key.

endif.

endform. " expand_no_children

*-----------------------------------------------------------------------

* Form lexpand_no_children

*-----------------------------------------------------------------------

form lexpand_no_children.

data:

Page 86: SAP File Explorer

ll_node type t_node.

data:

lw_length type i,

lw_length1 type i,

lw_path_name type localfile,

lw_path type localfile,

lw_file type char1 value c_wlchar.

read table i_nodel into ll_node

with key node_key = w_lnode_key.

if sy-subrc is initial.

if ll_node-dirname is not initial.

lw_path_name = ll_node-dirname.

lw_length = strlen( lw_path_name ).

lw_length1 = lw_length - 1.

if lw_length1 < c_0.

lw_length1 = c_0.

endif.

if lw_path_name+lw_length1(1) <> c_back_slash.

lw_path_name+lw_length(1) = c_back_slash.

endif.

concatenate

lw_path_name

ll_node-name

c_back_slash

into lw_path.

else.

lw_path = ll_node-drive.

endif.

* Find Path

w_file_path = lw_path.

w_find_path = lw_path.

* Find Routine

perform get_loc_file_list using lw_path

lw_file.

* Log displayed folders

perform add_ltable_lines.

* Add Folders

Page 87: SAP File Explorer

perform local_add_node using w_lnode_key.

endif.

endform. " lexpand_no_children

*-----------------------------------------------------------------------

* Form double_click_handler

*-----------------------------------------------------------------------

form double_click_handler using fuw_e_row type lvc_s_row

fuw_e_column type lvc_s_col

fuw_es_row_no type lvc_s_roid.

data:

ll_file_list_d type zxis_0x_file_d.

read table i_file_list_d into ll_file_list_d

index fuw_es_row_no-row_id .

* Handle Server grid double click

if ll_file_list_d-seen = c_r.

perform handle_grid_double_click

using fuw_e_row fuw_e_column fuw_es_row_no .

* Handle Local PC grid double click

elseif ll_file_list_d-seen = c_f.

perform handle_lgrid_double_click

using fuw_e_row fuw_e_column fuw_es_row_no .

endif.

endform. " double_click_handler

*-----------------------------------------------------------------------

* Form handle_grid_double_click

*-----------------------------------------------------------------------

form handle_grid_double_click using fuw_e_row type lvc_s_row

fuw_e_column type lvc_s_col

fuw_es_row_no type lvc_s_roid.

data:

ll_node type t_node,

ll_file_list type zxis_0x_file,

ll_file_list_d type zxis_0x_file_d.

data:

lw_length type i,

lw_length1 type i,

Page 88: SAP File Explorer

lw_path_name type localfile,

lw_path type localfile,

lw_file type char1 value c_wlchar,

lw_node_key type tv_nodekey.

read table i_file_list_d into ll_file_list_d

index fuw_es_row_no-row_id .

if sy-subrc is initial.

read table i_node into ll_node

with key name = ll_file_list_d-name

dirname = ll_file_list_d-dirname.

if sy-subrc is initial.

lw_node_key = ll_node-node_key.

else.

lw_node_key = w_node_key.

endif.

endif.

if ll_file_list_d-type_id = c_d.

lw_path_name = ll_file_list_d-dirname.

lw_length = strlen( lw_path_name ).

lw_length1 = lw_length - 1.

if lw_length1 < c_0.

lw_length1 = c_0.

endif.

if lw_path_name+lw_length1(1) <> c_slash.

if sy-opsys = c_aix or sy-opsys = c_unix.

lw_path_name+lw_length(1) = c_slash.

endif.

endif.

concatenate

lw_path_name

ll_file_list_d-name

c_slash

into lw_path.

* Find Path

w_find_path = lw_path.

w_file_path = lw_path.

w_dysp_path = lw_path.

Page 89: SAP File Explorer

* Find Routine

perform get_file_list using lw_path

lw_file.

read table i_log_list into ll_file_list

with key dirname = lw_path.

if sy-subrc is not initial.

* Log displayed folders

perform add_table_lines.

* Add Folders

if w_action <> c_search.

perform add_node using lw_node_key.

endif.

endif.

* Expand Node Dir

if w_action <> c_search.

perform expand_node using lw_node_key.

endif.

* Set ALV Display Layout

perform set_grid_layout.

elseif ll_file_list_d-type_id = c_f.

concatenate

ll_file_list_d-dirname

ll_file_list_d-name

into lw_path_name.

* Show File

perform display_file using lw_path_name

ll_file_list_d.

endif.

* Change Window Address

set titlebar c_tl_0100 with w_file_path.

endform. " handle_grid_double_click

*-----------------------------------------------------------------------

* Form handle_lgrid_double_click

*-----------------------------------------------------------------------

form handle_lgrid_double_click using fuw_e_row type lvc_s_row

fuw_e_column type lvc_s_col

Page 90: SAP File Explorer

fuw_es_row_no type lvc_s_roid.

data:

ll_node type t_node,

ll_file_list type zxis_0x_file,

ll_file_list_d type zxis_0x_file_d.

data:

lw_length type i,

lw_length1 type i,

lw_path_name type localfile,

lw_path type localfile,

lw_file type char1 value c_wlchar,

lw_node_key type tv_nodekey.

read table i_file_list_d into ll_file_list_d

index fuw_es_row_no-row_id .

if sy-subrc is initial.

read table i_nodel into ll_node

with key name = ll_file_list_d-name

dirname = ll_file_list_d-dirname.

if sy-subrc is initial.

lw_node_key = ll_node-node_key.

else.

lw_node_key = w_lnode_key.

endif.

endif.

if ll_file_list_d-type_id = c_d.

lw_path_name = ll_file_list_d-dirname.

lw_length = strlen( lw_path_name ).

lw_length1 = lw_length - 1.

if lw_length1 < c_0.

lw_length1 = c_0.

endif.

if lw_path_name+lw_length1(1) <> c_back_slash.

lw_path_name+lw_length(1) = c_back_slash.

endif.

concatenate

lw_path_name

ll_file_list_d-name

Page 91: SAP File Explorer

c_back_slash

into lw_path.

* Find Path

w_find_path = lw_path.

w_file_path = lw_path.

w_dysp_path = lw_path.

* Find Routine

perform get_loc_file_list using lw_path

lw_file.

read table i_log_listl into ll_file_list

with key dirname = lw_path.

if sy-subrc is not initial.

* Log displayed folders

perform add_ltable_lines.

* Add Folders

if w_action <> c_search.

perform local_add_node using lw_node_key.

endif.

endif.

* Expand Node Dir

if w_action <> c_search.

perform expand_local_node using lw_node_key.

endif.

* Set ALV Display Layout

perform set_grid_layout.

elseif ll_file_list_d-type_id = c_f.

concatenate

ll_file_list_d-dirname

ll_file_list_d-name

into lw_path_name.

* Show File

perform display_loc_file using lw_path_name

ll_file_list_d.

endif.

* Change Window Address

set titlebar c_tl_0100 with w_file_path.

Page 92: SAP File Explorer

endform. " handle_lgrid_double_click

*-----------------------------------------------------------------------

* Form add_node

*-----------------------------------------------------------------------

form add_node using fuw_node_key type lvc_nkey.

data:

ll_node type t_node,

ll_node_layout type lvc_s_layn,

ll_file_list type zxis_0x_file.

data:

lw_node_key type lvc_nkey,

lw_rnode_key type lvc_nkey,

lw_relationship type int4,

lw_node_text type lvc_value,

lw_length type i,

lw_path_name type localfile.

loop at i_file_list into ll_file_list

where type_id = c_d.

read table i_node into ll_node

with key dirname = ll_file_list-dirname

name = ll_file_list-name.

if sy-subrc is not initial.

clear: ll_node.

lw_path_name = ll_file_list-dirname.

lw_length = strlen( lw_path_name ).

if lw_length > 1.

translate lw_path_name using c_trslash.

condense lw_path_name.

endif.

lw_node_key = fuw_node_key.

lw_relationship = cl_gui_column_tree=>relat_last_child.

lw_node_text = ll_file_list-name.

ll_node_layout-isfolder = c_x.

ll_node_layout-expander = c_x.

ll_node_layout-dragdropid = w_handle_tree.

* Add Node to Table

Page 93: SAP File Explorer

call method o_tree->add_node

exporting

i_relat_node_key = lw_node_key

i_relationship = lw_relationship

is_node_layout = ll_node_layout

i_node_text = lw_node_text

importing

e_new_node_key = lw_rnode_key

exceptions

relat_node_not_found = 1

node_not_found = 2

others = 3.

if sy-subrc <> 0.

message id sy-msgid type c_msgty_s number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

else.

* Send data to frontend

call method o_tree->frontend_update.

read table i_node into ll_node

with key node_key = lw_rnode_key

name = lw_node_text

dirname = ll_file_list-dirname.

if sy-subrc is not initial.

clear: ll_node.

ll_node-node_key = lw_rnode_key.

ll_node-dirname = ll_file_list-dirname.

ll_node-name = lw_node_text.

append ll_node to i_node.

endif.

endif.

endif.

endloop.

endform. " add_node

*-----------------------------------------------------------------------

* Form local_add_node

*-----------------------------------------------------------------------

form local_add_node using fuw_node_key type lvc_nkey.

data:

ll_node type t_node,

ll_node_layout type lvc_s_layn,

Page 94: SAP File Explorer

ll_file_list type zxis_0x_file.

data:

lw_node_key type lvc_nkey,

lw_rnode_key type lvc_nkey,

lw_relationship type int4,

lw_node_text type lvc_value,

lw_length type i,

lw_path_name type localfile.

loop at i_file_list into ll_file_list

where type_id = c_d.

read table i_nodel into ll_node

with key dirname = ll_file_list-dirname

name = ll_file_list-name.

if sy-subrc is not initial.

clear: ll_node.

lw_path_name = ll_file_list-dirname.

lw_length = strlen( lw_path_name ).

if lw_length > 1.

translate lw_path_name using c_trslashl.

condense lw_path_name.

endif.

lw_node_key = fuw_node_key.

lw_relationship = cl_gui_column_tree=>relat_last_child.

lw_node_text = ll_file_list-name.

ll_node_layout-isfolder = c_x.

ll_node_layout-expander = c_x.

ll_node_layout-dragdropid = w_handle_tree.

* Add Node to Table

call method o_treel->add_node

exporting

i_relat_node_key = lw_node_key

i_relationship = lw_relationship

is_node_layout = ll_node_layout

i_node_text = lw_node_text

importing

e_new_node_key = lw_rnode_key

exceptions

relat_node_not_found = 1

node_not_found = 2

Page 95: SAP File Explorer

others = 3.

if sy-subrc <> 0.

message id sy-msgid type c_msgty_s number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

else.

* Send data to frontend

call method o_treel->frontend_update.

read table i_nodel into ll_node

with key node_key = lw_rnode_key

name = lw_node_text

dirname = ll_file_list-dirname.

if sy-subrc is not initial.

clear: ll_node.

ll_node-node_key = lw_rnode_key.

ll_node-dirname = ll_file_list-dirname.

ll_node-name = lw_node_text.

append ll_node to i_nodel.

endif.

endif.

endif.

endloop.

endform. " local_add_node

*-----------------------------------------------------------------------

* Form add_table_lines

*-----------------------------------------------------------------------

form add_table_lines .

data:

ll_log_list type zxis_0x_file.

read table i_log_list into ll_log_list

with key dirname = w_file_path.

if sy-subrc is not initial.

append lines of i_file_list to i_log_list.

sort i_log_list by dirname ascending.

endif.

endform. " add_table_lines

*-----------------------------------------------------------------------

Page 96: SAP File Explorer

* Form add_ltable_lines

*-----------------------------------------------------------------------

form add_ltable_lines .

data:

ll_log_list type zxis_0x_file.

read table i_log_listl into ll_log_list

with key dirname = w_file_path.

if sy-subrc is not initial.

append lines of i_file_list to i_log_listl.

sort i_log_listl by dirname ascending.

endif.

endform. " add_ltable_lines

*-----------------------------------------------------------------------

* Form display_file

*-----------------------------------------------------------------------

form display_file using fuw_path_name type localfile

ful_file_list type zxis_0x_file_d.

data:

lw_platform type i,

lw_subrc type sysubrc.

* Returns Platform

call method cl_gui_frontend_services=>get_platform

receiving

platform = lw_platform

exceptions

error_no_gui = 1

cntl_error = 2

not_supported_by_gui = 3

others = 4.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

if lw_platform <> cl_gui_frontend_services=>platform_windows95

and lw_platform <> cl_gui_frontend_services=>platform_windows98

and lw_platform <> cl_gui_frontend_services=>platform_windowsxp.

* Desktop System is not Windows

message id c_msgig_fsev type c_msgty_i number c_msgno_019.

Page 97: SAP File Explorer

exit.

else.

* Get Download Path

if w_dest_path is initial.

perform get_dest_dir.

endif.

* Deletes a File

if ful_file_list-file_id = 'ANY'.

concatenate w_dest_path ful_file_list-name '.txt'

into w_file_dest.

else.

concatenate w_dest_path ful_file_list-name c_dot

ful_file_list-file_id

into w_file_dest.

endif.

* Deletes a File

call method cl_gui_frontend_services=>file_delete

exporting

filename = w_file_dest

changing

rc = lw_platform

exceptions

file_delete_failed = 1

cntl_error = 2

error_no_gui = 3

file_not_found = 4

access_denied = 5

unknown_error = 6

not_supported_by_gui = 7

wrong_parameter = 8

others = 9.

if sy-subrc <> 0.

* MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

* WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

* Transfer File

perform gui_transf_unix_pc using fuw_path_name

ful_file_list

changing lw_subrc.

if lw_subrc is initial.

if ful_file_list-file_id = 'ANY'.

Page 98: SAP File Explorer

concatenate w_dest_path ful_file_list-name '.txt'

into w_file_dest.

else.

concatenate w_dest_path ful_file_list-name c_dot

ful_file_list-file_id

into w_file_dest.

endif.

* Starts an Application or Opens a Document in the Client

call method cl_gui_frontend_services=>execute

exporting

document = w_file_dest

exceptions

cntl_error = 1

error_no_gui = 2

bad_parameter = 3

file_not_found = 4

path_not_found = 5

file_extension_unknown = 6

error_execute_failed = 7

synchronous_failed = 8

not_supported_by_gui = 9

others = 10.

if sy-subrc <> 0.

message id sy-msgid type c_msgty_i number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

* It´s not possible to open the file

message id c_msgig_fsev type c_msgty_i number c_msgno_020

with 'Open'(012) w_file_dest.

exit.

endif.

endif.

endif.

endform. " display_file

*-----------------------------------------------------------------------

* Form display_loc_file

*-----------------------------------------------------------------------

form display_loc_file using fuw_path_name type localfile

ful_file_list type zxis_0x_file_d.

data:

lw_platform type i.

Page 99: SAP File Explorer

* Returns Platform

call method cl_gui_frontend_services=>get_platform

receiving

platform = lw_platform

exceptions

error_no_gui = 1

cntl_error = 2

not_supported_by_gui = 3

others = 4.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

if lw_platform <> cl_gui_frontend_services=>platform_windows95

and lw_platform <> cl_gui_frontend_services=>platform_windows98

and lw_platform <> cl_gui_frontend_services=>platform_windowsxp.

* Desktop System is not Windows

message id c_msgig_fsev type c_msgty_i number c_msgno_019.

exit.

else.

w_file_dest = fuw_path_name.

* Starts an Application or Opens a Document in the Client

call method cl_gui_frontend_services=>execute

exporting

document = w_file_dest

exceptions

cntl_error = 1

error_no_gui = 2

bad_parameter = 3

file_not_found = 4

path_not_found = 5

file_extension_unknown = 6

error_execute_failed = 7

synchronous_failed = 8

not_supported_by_gui = 9

others = 10.

if sy-subrc <> 0.

message id sy-msgid type c_msgty_i number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

* It´s not possible to open the file

message id c_msgig_fsev type c_msgty_i number c_msgno_020

Page 100: SAP File Explorer

with 'Open'(012) w_file_dest.

exit.

endif.

endif.

endform. " display_loc_file

*-----------------------------------------------------------------------

* Form get_dest_dir

*-----------------------------------------------------------------------

form get_dest_dir.

data:

lw_dir type char200,

lw_directory type string,

lw_rc type i.

clear: w_returns.

* Returns the Path to the TEMP Directory

call method cl_gui_frontend_services=>get_temp_directory

changing

temp_dir = w_returns

exceptions

cntl_error = 1

error_no_gui = 2

not_supported_by_gui = 3

others = 4.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

else.

call method cl_gui_cfw=>flush.

lw_dir = w_returns.

endif.

shift lw_dir right deleting trailing space.

if lw_dir is not initial

and lw_dir+199(1) <> c_back_slash.

concatenate

w_returns

c_back_slash

into w_return.

endif.

Page 101: SAP File Explorer

if w_return is not initial.

w_dest_path = w_return.

else.

lw_directory = c_ctmp.

* Creates a Directory in the Client

call method cl_gui_frontend_services=>directory_create

exporting

directory = lw_directory

changing

rc = lw_rc

exceptions

directory_create_failed = 1

cntl_error = 2

error_no_gui = 3

directory_access_denied = 4

directory_already_exists = 5

path_not_found = 6

unknown_error = 7

not_supported_by_gui = 8

wrong_parameter = 9

others = 10.

if sy-subrc <> c_0.

message id sy-msgid type c_msgty_s number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

w_dest_path = lw_directory.

endif.

endform. " get_dest_dir

*-----------------------------------------------------------------------

* Form gui_transf_unix_pc

*-----------------------------------------------------------------------

form gui_transf_unix_pc using fuw_path_name type localfile

ful_file_list type zxis_0x_file_d

changing fcw_subrc type any.

data:

lw_file_path type char200.

clear: lw_file_path, fcw_subrc.

lw_file_path = w_dest_path.

shift lw_file_path right deleting trailing space.

Page 102: SAP File Explorer

if lw_file_path+199(1) <> c_back_slash.

clear: lw_file_path.

lw_file_path = w_dest_path.

concatenate lw_file_path c_back_slash into lw_file_path.

else.

clear: lw_file_path.

lw_file_path = w_dest_path.

endif.

* Get file data

perform open_file using fuw_path_name

ful_file_list

changing fcw_subrc.

if fcw_subrc is initial.

* Transfer file localy

perform save_local using ful_file_list

space

changing fcw_subrc.

endif.

endform. " gui_transf_unix_pc

*-----------------------------------------------------------------------

* Form open_file

*-----------------------------------------------------------------------

form open_file using fuw_file type any

ful_file_list type zxis_0x_file_d

changing fcw_subrc type any.

data:

ll_buftab_t type t_buftab_t.

clear: i_buftab_t, ll_buftab_t.

refresh: i_buftab_t.

if ful_file_list-type_f = c_bin.

* Open in binary mode

open dataset fuw_file for input in binary mode.

else.

* Open in text mode

open dataset fuw_file for input in text mode encoding default.

endif.

if sy-subrc <> 0.

* Error opening the file

fcw_subrc = c_1.

Page 103: SAP File Explorer

message id c_msgig_fsev type c_msgty_i number c_msgno_017

with fuw_file.

else.

do.

read dataset fuw_file into ll_buftab_t.

if sy-subrc = 0.

append ll_buftab_t to i_buftab_t.

elseif sy-subrc = 4.

append ll_buftab_t to i_buftab_t.

exit.

endif.

enddo.

close dataset fuw_file.

endif.

endform. " open_file

*-----------------------------------------------------------------------

* Form save_local

*-----------------------------------------------------------------------

form save_local using ful_file_list type zxis_0x_file_d

fuw_file type any

changing fcw_subrc type any.

data:

lw_filetp type char10.

if fuw_file is initial.

if ful_file_list-file_id = 'ANY'.

concatenate w_dest_path ful_file_list-name '.txt'

into w_file_dest.

else.

concatenate w_dest_path ful_file_list-name c_dot

ful_file_list-file_id

into w_file_dest.

endif.

else.

w_file_dest = fuw_file.

endif.

if o_gui_serv is not bound.

create object o_gui_serv.

endif.

lw_filetp = ful_file_list-type_f.

Page 104: SAP File Explorer

if i_buftab_t[] is not initial.

* Download Data to Client PC

call method o_gui_serv->gui_download

exporting

filename = w_file_dest

filetype = lw_filetp

confirm_overwrite = c_x

changing

data_tab = i_buftab_t

exceptions

file_write_error = 1

no_batch = 2

gui_refuse_filetransfer = 3

invalid_type = 4

no_authority = 5

unknown_error = 6

header_not_allowed = 7

separator_not_allowed = 8

filesize_not_allowed = 9

header_too_long = 10

dp_error_create = 11

dp_error_send = 12

dp_error_write = 13

unknown_dp_error = 14

access_denied = 15

dp_out_of_memory = 16

disk_full = 17

dp_timeout = 18

file_not_found = 19

dataprovider_exception = 20

control_flush_error = 21

not_supported_by_gui = 22

error_no_gui = 23

others = 24.

if sy-subrc <> 0.

fcw_subrc = c_1.

message id sy-msgid type c_msgty_s number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

endif.

endform. " save_local

*-----------------------------------------------------------------------

* Form upload_local

Page 105: SAP File Explorer

*-----------------------------------------------------------------------

form upload_local using ful_file_list type zxis_0x_file_d

fuw_file type any

changing fcw_subrc type any.

data:

lw_filetp type char10.

w_file_dest = fuw_file.

lw_filetp = ful_file_list-type_f.

clear: i_buftab_t.

refresh: i_buftab_t.

* Upload Data from Client PC

call method o_gui_serv->gui_upload

exporting

filename = w_file_dest

changing

data_tab = i_buftab_t

exceptions

file_open_error = 1

file_read_error = 2

no_batch = 3

gui_refuse_filetransfer = 4

invalid_type = 5

no_authority = 6

unknown_error = 7

bad_data_format = 8

header_not_allowed = 9

separator_not_allowed = 10

header_too_long = 11

unknown_dp_error = 12

access_denied = 13

dp_out_of_memory = 14

disk_full = 15

dp_timeout = 16

not_supported_by_gui = 17

error_no_gui = 18

others = 19.

if sy-subrc <> 0.

fcw_subrc = c_1.

message id sy-msgid type c_msgty_s number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

Page 106: SAP File Explorer

endform. " upload_local

*-----------------------------------------------------------------------

* Form search_prepare

*-----------------------------------------------------------------------

form search_prepare .

data:

li_events type standard table of cntl_simple_event.

data:

ll_event type cntl_simple_event.

data:

lw_repid type sy-repid,

lw_dynnr type sy-dynnr,

lw_ext type i value '300'.

lw_repid = sy-repid.

lw_dynnr = sy-dynnr.

w_dct = c_x.

* Create the Search container

create object o_tree_cont

exporting

repid = lw_repid

dynnr = lw_dynnr

side = o_tree_cont->dock_at_left

extension = lw_ext

exceptions

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

* Create HTML View Control

create object o_html_control

exporting

parent = o_tree_cont

exceptions

cntl_error = 1

Page 107: SAP File Explorer

cntl_install_error = 2

dp_install_error = 3

dp_error = 4

others = 5 .

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

* Register event

ll_event-eventid = o_html_control->m_id_sapevent.

ll_event-appl_event = c_x.

append ll_event to li_events.

* Set Events

call method o_html_control->set_registered_events

exporting

events = li_events

exceptions

cntl_error = 1

cntl_system_error = 2

illegal_event_combination = 3.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

* Assign event handlers in the application class to each desired event

create object o_eventh.

set handler o_eventh->handle_on_sapevent for o_html_control.

set handler o_eventh->handle_double_click for o_grid.

* Set ALV Display Layout

perform set_grid_layout.

endform. " search_prepare

*-----------------------------------------------------------------------

* Form lsearch_prepare

*-----------------------------------------------------------------------

form lsearch_prepare .

data:

li_events type standard table of cntl_simple_event.

Page 108: SAP File Explorer

data:

ll_event type cntl_simple_event.

data:

lw_repid type sy-repid,

lw_dynnr type sy-dynnr,

lw_ext type i value '300'.

lw_repid = sy-repid.

lw_dynnr = sy-dynnr.

w_dct = c_x.

* Create the Search container

create object o_tree_contl

exporting

repid = lw_repid

dynnr = lw_dynnr

side = o_tree_cont->dock_at_left

extension = lw_ext

exceptions

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

* Create HTML View Control

create object o_html_control

exporting

parent = o_tree_contl

exceptions

cntl_error = 1

cntl_install_error = 2

dp_install_error = 3

dp_error = 4

others = 5 .

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

Page 109: SAP File Explorer

* Register event

ll_event-eventid = o_html_control->m_id_sapevent.

ll_event-appl_event = c_x.

append ll_event to li_events.

* Set Events

call method o_html_control->set_registered_events

exporting

events = li_events

exceptions

cntl_error = 1

cntl_system_error = 2

illegal_event_combination = 3.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

* Assign event handlers in the application class to each desired event

create object o_eventhl.

set handler o_eventhl->handle_on_sapevent for o_html_control.

set handler o_eventh->handle_double_click for o_grid.

* Set ALV Display Layout

perform set_grid_layout.

endform. " lsearch_prepare

*-----------------------------------------------------------------------

* Form html_prepare

*-----------------------------------------------------------------------

form html_prepare.

data:

ll_html type char255.

data:

lw_find_path type char200.

clear: i_html, lw_find_path.

Page 110: SAP File Explorer

lw_find_path = w_find_path.

append '<HTML><HEAD><TITLE>Search File</TITLE></HEAD> ' to i_html.

append '<FORM method=post action=SAPEVENT:BACK> ' to i_html.

append '<INPUT TYPE=submit ' to i_html.

append 'VALUE=" Folder Tree "> ' to i_html.

append '<BODY BGCOLOR="#EFFFFF" TEXT=BLACK> ' to i_html.

append '</FORM> ' to i_html.

append '<FORM method=get action="SAPEVENT:SEARCH"> ' to i_html.

append '<P>Look in folder:<BR> ' to i_html.

append '<INPUT TYPE=text NAME=Folder SIZE=31 VALUE= ' to i_html.

concatenate c_cchar lw_find_path c_cchar into ll_html.

condense ll_html.

append ll_html to i_html.

append '><BR><BR><BR><HR> ' to i_html.

append '<P>Search pattern<BR> ' to i_html.

append '<P>All or part of the file name:<BR> ' to i_html.

append '<INPUT TYPE=text NAME=Search SIZE=31 VALUE= ' to i_html.

concatenate c_cchar w_search_name c_cchar into ll_html.

condense ll_html no-gaps.

append ll_html to i_html.

append '><P><INPUT TYPE=submit VALUE="Search"></FORM> ' to i_html.

append '</BODY></HTML> ' to i_html.

endform. " html_prepare

*-----------------------------------------------------------------------

* Form html_show

*-----------------------------------------------------------------------

form html_show .

* Loads the data from the ABAP program through DP

call method o_html_control->load_data

importing

assigned_url = w_html_line

changing

data_table = i_html

exceptions

dp_invalid_parameter = 1

dp_error_general = 2

cntl_error = 3

others = 4.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

Page 111: SAP File Explorer

* Shows the Web page for the URL specified

call method o_html_control->show_url

exporting

url = w_html_line

exceptions

cntl_error = 1

cnht_error_not_allowed = 2

cnht_error_parameter = 3

dp_error_general = 4

others = 5.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

endform. " html_show

*-----------------------------------------------------------------------

* Form back_to_tree

*-----------------------------------------------------------------------

form back_to_tree .

clear:

w_act, w_srcd, w_search_path, i_file_list, i_node,

i_log_list, i_kpath, i_buftab_t, i_query_table, i_html.

w_dct = w_src = c_x.

w_file_path = w_dysp_path = w_path_name.

call method o_tree_cont->free.

endform. " back_to_tree

*-----------------------------------------------------------------------

* Form back_to_loc_tree

*-----------------------------------------------------------------------

form back_to_loc_tree .

clear:

w_loc, w_srcd, w_search_path, w_srcl, i_file_list, i_nodel,

i_log_listl, i_kpath, i_buftab_t, i_lquery_table, i_html.

w_src = w_act = w_dct = c_x.

w_file_path = w_dysp_path = w_lpath_name.

Page 112: SAP File Explorer

call method o_tree_contl->free.

* Prepare Grid Output

if w_src is initial.

perform grid_prepare.

endif.

* Display Local PC

perform display_local.

endform. " back_to_loc_tree

*-----------------------------------------------------------------------

* Form folder_search

*-----------------------------------------------------------------------

form folder_search .

data:

ll_query_table type w3query.

data:

lw_search_ptrn type char200,

lw_file_path type char200.

w_act = c_x.

w_dct = c_x.

clear: ll_query_table.

read table i_query_table into ll_query_table

with key name = c_folder.

if ll_query_table-value is not initial.

w_file_path = lw_file_path = ll_query_table-value.

else.

* Please select a folder!

message id c_msgig_fsev type c_msgty_w number c_msgno_000

with 'Please select a folder!'(008).

endif.

clear: ll_query_table.

read table i_query_table into ll_query_table

with key name = c_searchl.

if ll_query_table-value is not initial.

lw_search_ptrn = ll_query_table-value.

else.

* Please select a folder!

Page 113: SAP File Explorer

message id c_msgig_fsev type c_msgty_w number c_msgno_000

with 'Please select a Search pattern!'(003).

endif.

if lw_search_ptrn ca c_errptrn.

* The use of the fallowing characters is not allowed:

message id c_msgig_fsev type c_msgty_i number c_msgno_000

with 'The use of the fallowing characters is not allowed:'(010)

c_errptrn.

else.

if lw_file_path is not initial

and lw_search_ptrn is not initial.

* Search File

perform search_results using lw_file_path

lw_search_ptrn.

endif.

endif.

endform. " folder_search

*-----------------------------------------------------------------------

* Form loc_folder_search

*-----------------------------------------------------------------------

form loc_folder_search .

data:

ll_query_table type w3query.

data:

lw_search_ptrn type char200,

lw_file_path type char200.

w_loc = c_x.

w_dct = c_x.

clear: ll_query_table.

read table i_lquery_table into ll_query_table

with key name = c_folder.

if ll_query_table-value is not initial.

w_file_path = lw_file_path = ll_query_table-value.

else.

* Please select a folder!

message id c_msgig_fsev type c_msgty_w number c_msgno_000

with 'Please select a folder!'(008).

endif.

Page 114: SAP File Explorer

clear: ll_query_table.

read table i_lquery_table into ll_query_table

with key name = c_searchl.

if ll_query_table-value is not initial.

lw_search_ptrn = ll_query_table-value.

else.

* Please select a folder!

message id c_msgig_fsev type c_msgty_w number c_msgno_000

with 'Please select a Search pattern!'(003).

endif.

if lw_search_ptrn ca c_errptrn.

* The use of the fallowing characters is not allowed:

message id c_msgig_fsev type c_msgty_i number c_msgno_000

with 'The use of the fallowing characters is not allowed:'(010)

c_errptrn.

else.

if lw_file_path is not initial

and lw_search_ptrn is not initial.

* Search File

perform local_search using lw_file_path

lw_search_ptrn.

endif.

endif.

endform. " loc_folder_search

*-----------------------------------------------------------------------

* Form search_results

*-----------------------------------------------------------------------

form search_results using fuw_search_path type any

fuw_search_ptrn type any.

data:

li_file_list type standard table of zxis_0x_file.

data:

lw_path_name type char200.

w_path_name = fuw_search_path.

if sy-opsys = c_unix

or sy-opsys = c_aix.

clear: w_search_path, w_search_name,

i_server_data.

refresh: i_server_data, i_file_list, i_file_list_d.

Page 115: SAP File Explorer

w_search_path = fuw_search_path.

w_search_name = fuw_search_ptrn.

concatenate

c_findl

w_search_path

c_dname

w_search_name

c_dprint

into w_unixcomm separated by space.

* Executing the system commands witin ABAP

call 'SYSTEM' id c_command field w_unixcomm

id c_tab field i_server_data-*sys*.

loop at i_server_data.

lw_path_name = i_server_data-line.

perform split_name changing lw_path_name

w_file_name.

perform get_file_list using lw_path_name

w_file_name.

append lines of i_file_list to li_file_list.

clear: i_file_list.

endloop.

elseif sy-opsys = 'Windows NT'(009).

clear: w_search_path, w_search_name,

i_server_data.

refresh: i_server_data, i_file_list, i_file_list_d.

w_search_path = fuw_search_path.

w_search_name = fuw_search_ptrn.

translate w_search_path using c_sbs.

concatenate

c_dirl

c_at

w_search_path

w_search_name

c_at

c_ss

into w_unixcomm.

Page 116: SAP File Explorer

translate w_unixcomm using c_atsp.

* Executing the system commands witin ABAP.

call 'SYSTEM' id c_command field w_unixcomm

id c_tab field i_server_data-*sys*.

loop at i_server_data.

clear: w_file_name.

if i_server_data-line(14) = 'Directory of'(007).

clear: lw_path_name.

lw_path_name = i_server_data-line+16(284).

translate lw_path_name using c_spat.

translate lw_path_name using c_bss.

search lw_path_name for c_at.

lw_path_name+sy-fdpos(1) = c_slash.

translate lw_path_name using c_atsp.

elseif i_server_data-line(2) ca c_numbers.

clear: w_file_name.

w_file_name = i_server_data-line+39(261).

endif.

if not w_file_name is initial.

perform get_file_list using lw_path_name

w_file_name.

append lines of i_file_list to li_file_list.

clear: i_file_list.

endif.

endloop.

endif.

sort i_file_list by dirname name ascending.

clear: i_file_list.

append lines of li_file_list to i_file_list.

* Prepare layout

perform prepare_display_layout.

clear: i_file_list.

* Refresh Table Display

call method o_grid->refresh_table_display

exceptions

finished = 1

others = 2.

Page 117: SAP File Explorer

if sy-subrc <> 0.

message id sy-msgid type c_msgty_s number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

endform. " search_results

*-----------------------------------------------------------------------

* Form local_search

*-----------------------------------------------------------------------

form local_search using fuw_search_path type any

fuw_search_ptrn type any.

data:

li_file_list type standard table of zxis_0x_file.

clear: w_search_path, w_search_name.

refresh: i_file_list, i_file_list_d.

w_file_path = w_lpath_name = fuw_search_path.

w_search_path = fuw_search_path.

w_search_name = fuw_search_ptrn.

* Search in Local PC

perform search_loc_pc tables li_file_list

using w_search_path

w_search_name.

clear: i_file_list.

append lines of li_file_list to i_file_list.

sort i_file_list by dirname name ascending.

* Prepare layout

perform prepare_display_layout.

clear: i_file_list.

* Refresh Table Display

call method o_grid->refresh_table_display

exceptions

finished = 1

others = 2.

if sy-subrc <> 0.

message id sy-msgid type c_msgty_s number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

Page 118: SAP File Explorer

endform. " local_search

*-----------------------------------------------------------------------

* Form assign_fields

*-----------------------------------------------------------------------

form assign_fields .

data:

ll_file_list_d type zxis_0x_file_d.

data:

lw_row type i,

lw_value type char200,

lw_col type i,

lw_path_name type localfile,

lw_length type i,

lw_length1 type i.

clear:

w_file_name, w_file_path, w_file_path_name.

* Get Selected Value

call method o_grid->get_current_cell

importing

e_row = lw_row

e_value = lw_value

e_col = lw_col.

read table i_file_list_d into ll_file_list_d index lw_row.

if sy-subrc is not initial.

* Please select in the right panel a folder or file!

message id c_msgig_fsev type c_msgty_w number c_msgno_000

with 'Please select in the right panel a folder or file!'(011).

else.

lw_path_name = ll_file_list_d-dirname.

lw_length = strlen( lw_path_name ).

lw_length1 = lw_length - 1.

if lw_length1 < c_0.

lw_length1 = c_0.

endif.

* Get path

if ll_file_list_d-type_id = c_d.

Page 119: SAP File Explorer

* For Server Paths

if ll_file_list_d-seen = c_r.

if lw_path_name+lw_length1(1) <> c_slash.

if sy-opsys = c_aix or sy-opsys = c_unix.

lw_path_name+lw_length(1) = c_slash.

endif.

endif.

concatenate

lw_path_name

ll_file_list_d-name

c_slash

into w_file_path.

w_file_path_name = w_file_path.

* For Local Paths

elseif ll_file_list_d-seen = c_f.

if lw_path_name+lw_length1(1) <> c_back_slash.

lw_path_name+lw_length(1) = c_back_slash.

endif.

concatenate

lw_path_name

ll_file_list_d-name

c_back_slash

into w_file_path.

endif.

* Get File and path

elseif ll_file_list_d-type_id = c_f.

lw_path_name = ll_file_list_d-dirname.

* For Server Paths and Name

if ll_file_list_d-seen = c_r.

if lw_path_name+lw_length1(1) <> c_slash.

if sy-opsys = c_aix or sy-opsys = c_unix.

lw_path_name+lw_length(1) = c_slash.

endif.

endif.

* For Local Paths and Name

elseif ll_file_list_d-seen = c_f.

if lw_path_name+lw_length1(1) <> c_back_slash.

lw_path_name+lw_length(1) = c_back_slash.

endif.

endif.

Page 120: SAP File Explorer

concatenate

lw_path_name

ll_file_list_d-name

into w_file_path_name.

w_file_name = ll_file_list_d-name.

w_file_path = lw_path_name.

endif.

if o_tree_contl is bound.

call method o_tree_contl->free

exceptions

cntl_error = 1

cntl_system_error = 2

others = 3.

if sy-subrc <> 0.

* MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

* WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

endif.

call method o_tree_cont->free.

call method o_file_cont->free.

set screen 0. leave screen.

endif.

endform. " assign_fields

*-----------------------------------------------------------------------

*& Form display_local_pc

*-----------------------------------------------------------------------

form display_local_pc .

if w_loc is initial.

* Returns Platform

call method cl_gui_frontend_services=>get_platform

receiving

platform = w_platform

exceptions

error_no_gui = 1

cntl_error = 2

not_supported_by_gui = 3

others = 4.

Page 121: SAP File Explorer

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

endif.

if w_platform <> cl_gui_frontend_services=>platform_windows95

and w_platform <> cl_gui_frontend_services=>platform_windows98

and w_platform <> cl_gui_frontend_services=>platform_windowsxp.

* Desktop System is not Windows

message id c_msgig_fsev type c_msgty_i number c_msgno_019.

exit.

else.

* Prepare Grid Output

if w_src is initial and w_loc is initial.

perform grid_prepare.

endif.

* Display Local PC

perform display_local.

endif.

endform. " display_local_pc

*-----------------------------------------------------------------------

* Form display_local

*-----------------------------------------------------------------------

form display_local .

data:

li_events type standard table of cntl_simple_event.

data:

ll_drv type t_drv,

ll_event type cntl_simple_event.

data:

lw_repid type sy-repid,

lw_dynnr type sy-dynnr,

lw_flag type as4flag,

lw_ext type i value '300'.

if w_loc is not initial.

clear:

w_act, w_src, w_loc, w_srcl, w_search_path, i_file_list, i_node,

i_nodel, i_log_list, i_kpath, i_buftab_t, i_lquery_table, i_html.

Page 122: SAP File Explorer

w_dct = c_x.

w_file_path = w_dysp_path = w_path_name.

* Free containers

call method o_tree_cont->free.

call method o_tree_contl->free.

else.

lw_repid = sy-repid.

lw_dynnr = sy-dynnr.

w_loc = c_x.

clear: i_file_list.

if o_gui_serv is not bound.

create object o_gui_serv.

endif.

* Create Local PC Tree container

create object o_tree_contl

exporting

repid = lw_repid

dynnr = lw_dynnr

side = o_tree_cont->dock_at_left

extension = lw_ext

exceptions

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

lw_flag = c_x.

* Create Local PC Tree Control

create object o_treel

exporting

parent = o_tree_contl

item_selection = lw_flag

no_toolbar = lw_flag

no_html_header = lw_flag

exceptions

Page 123: SAP File Explorer

cntl_system_error = 1

create_error = 2

failed = 3

illegal_node_selection_mode = 4

illegal_column_name = 5

lifetime_error = 6.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

* Set Local Tree Layout

perform set_local_tree_layout.

* Get Local File System Data

read table i_drv into ll_drv with key type = c_fixed.

w_dysp_path = ll_drv-drive.

perform get_loc_file_list using ll_drv-drive

c_wlchar.

* Prepare Local tree for First Output

perform local_tree_prepare.

* Add Folders

perform local_add_node using w_lnode_key.

* Expand Root Dir

perform expand_local_node using w_lnode_key.

if w_src is initial.

* Initiate Drag & Drop

perform start_drad_drop.

* Set ALV Display Layout

perform set_grid_layout.

endif.

* Define the events which will be passed to the backend

* Node double click

ll_event-eventid = cl_gui_column_tree=>eventid_node_double_click.

ll_event-appl_event = c_x.

append ll_event to li_events.

* Header click

ll_event-eventid = cl_gui_column_tree=>eventid_header_click.

ll_event-appl_event = c_x.

Page 124: SAP File Explorer

append ll_event to li_events.

* Expand no Children

ll_event-eventid = cl_gui_column_tree=>eventid_expand_no_children.

ll_event-appl_event = c_x.

append ll_event to li_events.

* Set Events

call method o_treel->set_registered_events

exporting

events = li_events

exceptions

cntl_error = 1

cntl_system_error = 2

illegal_event_combination = 3.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

* Assign event handlers in the application class to each desired event

create object o_eventhl.

set handler o_eventhl->handle_node_double_click for o_treel.

set handler o_eventhl->handle_header_click for o_treel.

set handler o_eventhl->handle_expand_no_children for o_treel.

set handler o_eventhl->handle_on_drop for o_treel.

set handler o_eventh->handle_double_click for o_grid.

set handler o_eventh->handle_ondrag for o_grid.

set handler o_eventh->handle_on_grid_drop for o_grid.

set handler o_eventh->handle_ondropcomplete for o_grid.

endif.

endform. " display_local

*-----------------------------------------------------------------------

* Form handle_tree_on_drop

*-----------------------------------------------------------------------

form handle_tree_on_drop

using fuw_node_key type lvc_nkey

changing fco_object type ref to cl_dragdropobject.

data:

ll_node type t_node.

data:

Page 125: SAP File Explorer

lw_folder_name type char200,

lw_path_name type char200,

lw_target_path type char200.

* Check if Source and target folders are different

lw_path_name = o_dataobj->l_file_list_d-dirname.

w_dest = c_r.

if o_dataobj->l_file_list_d-seen = c_r.

if lw_path_name <> c_slash.

shift lw_path_name right deleting trailing space.

if lw_path_name+199(1) = c_slash.

lw_path_name+199(1) = space.

endif.

shift lw_path_name left deleting leading space.

perform split_name changing lw_path_name

lw_folder_name.

else.

lw_folder_name = lw_path_name.

endif.

elseif o_dataobj->l_file_list_d-seen = c_f.

if lw_path_name <> c_win_root.

shift lw_path_name right deleting trailing space.

if lw_path_name+199(1) = c_back_slash.

lw_path_name+199(1) = space.

endif.

shift lw_path_name left deleting leading space.

perform split_lname changing lw_path_name

lw_folder_name.

else.

lw_folder_name = lw_path_name.

endif.

endif.

read table i_node into ll_node with key node_key = fuw_node_key.

* Get target file name

concatenate

ll_node-dirname

ll_node-name

c_slash

into lw_target_path.

if ll_node-name = lw_folder_name

and lw_target_path = o_dataobj->l_file_list_d-dirname.

Page 126: SAP File Explorer

* Cannot Copy or Move to the same Folder!

message id c_msgig_fsev type c_msgty_s number c_msgno_000

with 'Cannot Copy or Move to the same Folder!'(015).

call method fco_object->abort.

else.

clear: w_dd_target_name.

* Get target file name

concatenate

ll_node-dirname

ll_node-name

c_slash

o_dataobj->l_file_list_d-name

into w_dd_target_name.

endif.

endform. " handle_tree_on_drop

*-----------------------------------------------------------------------

* Form handle_ltree_on_drop

*-----------------------------------------------------------------------

form handle_ltree_on_drop

using fuw_node_key type lvc_nkey

changing fco_object type ref to cl_dragdropobject.

data:

ll_node type t_node.

data:

lw_folder_name type char200,

lw_path_name type char200,

lw_target_path type char200.

* Check if Source and target folders are different

lw_path_name = o_dataobj->l_file_list_d-dirname.

w_dest = c_f.

if o_dataobj->l_file_list_d-seen = c_r.

if lw_path_name <> c_slash.

shift lw_path_name right deleting trailing space.

if lw_path_name+199(1) = c_slash.

lw_path_name+199(1) = space.

endif.

shift lw_path_name left deleting leading space.

Page 127: SAP File Explorer

perform split_name changing lw_path_name

lw_folder_name.

else.

lw_folder_name = lw_path_name.

endif.

elseif o_dataobj->l_file_list_d-seen = c_f.

if lw_path_name <> c_win_root.

shift lw_path_name right deleting trailing space.

if lw_path_name+199(1) = c_back_slash.

lw_path_name+199(1) = space.

endif.

shift lw_path_name left deleting leading space.

perform split_lname changing lw_path_name

lw_folder_name.

else.

lw_folder_name = lw_path_name.

endif.

endif.

read table i_nodel into ll_node with key node_key = fuw_node_key.

* Get target file name

concatenate

ll_node-dirname

ll_node-name

c_back_slash

into lw_target_path.

if ll_node-name = lw_folder_name

and lw_target_path = o_dataobj->l_file_list_d-dirname.

* Cannot Copy or Move to the same Folder!

message id c_msgig_fsev type c_msgty_s number c_msgno_000

with 'Cannot Copy or Move to the same Folder!'(015).

call method fco_object->abort.

else.

clear: w_dd_target_name.

* Get target file name

concatenate

ll_node-dirname

ll_node-name

c_back_slash

o_dataobj->l_file_list_d-name

into w_dd_target_name.

Page 128: SAP File Explorer

endif.

endform. " handle_ltree_on_drop

*-----------------------------------------------------------------------

* Form on_drag_handler

*-----------------------------------------------------------------------

form on_drag_handler using ful_row type lvc_s_row

ful_column type lvc_s_col

ful_row_no type lvc_s_roid

changing fco_object type ref to cl_dragdropobject.

data:

ll_file_list_d type zxis_0x_file_d.

read table i_file_list_d into ll_file_list_d index ful_row.

* Handle Server grid drag

if ll_file_list_d-seen = c_r.

perform on_grid_drag using ful_row ful_column ful_row_no

changing fco_object.

* Handle Local PC grid drag

elseif ll_file_list_d-seen = c_f.

perform on_grid_drag using ful_row ful_column ful_row_no

changing fco_object.

endif.

endform. " on_drag_handler

*-----------------------------------------------------------------------

* Form handle_grid_on_drop

*-----------------------------------------------------------------------

form handle_grid_on_drop using ful_row type lvc_s_row

ful_column type lvc_s_col

ful_row_no type lvc_s_roid

changing fco_object type ref to cl_dragdropobject.

data:

ll_file_list_d type zxis_0x_file_d.

data:

lw_folder_name type char200,

lw_path_name type char200,

lw_target_path type char200.

* Check if Source and target folders are different

Page 129: SAP File Explorer

lw_path_name = o_dataobj->l_file_list_d-dirname.

if o_dataobj->l_file_list_d-seen = c_r.

w_dest = c_r.

if lw_path_name <> c_slash.

shift lw_path_name right deleting trailing space.

if lw_path_name+199(1) = c_slash.

lw_path_name+199(1) = space.

endif.

shift lw_path_name left deleting leading space.

perform split_name changing lw_path_name

lw_folder_name.

else.

lw_folder_name = lw_path_name.

endif.

read table i_file_list_d into ll_file_list_d index ful_row.

* Get target file name

concatenate

ll_file_list_d-dirname

ll_file_list_d-name

c_slash

into lw_target_path.

if ll_file_list_d-dirname = o_dataobj->l_file_list_d-dirname.

* Cannot Copy or Move to the same Folder!

message id c_msgig_fsev type c_msgty_s number c_msgno_000

with 'Cannot Copy or Move to the same Folder!'(015).

call method fco_object->abort.

else.

clear: w_dd_target_name.

* Get target file name

concatenate

ll_file_list_d-dirname

ll_file_list_d-name

c_slash

o_dataobj->l_file_list_d-name

into w_dd_target_name.

endif.

elseif o_dataobj->l_file_list_d-seen = c_f.

Page 130: SAP File Explorer

w_dest = c_f.

if lw_path_name <> c_win_root.

shift lw_path_name right deleting trailing space.

if lw_path_name+199(1) = c_back_slash.

lw_path_name+199(1) = space.

endif.

shift lw_path_name left deleting leading space.

perform split_lname changing lw_path_name

lw_folder_name.

else.

lw_folder_name = lw_path_name.

endif.

read table i_file_list_d into ll_file_list_d index ful_row.

* Get target file name

concatenate

ll_file_list_d-dirname

ll_file_list_d-name

c_back_slash

into lw_target_path.

if ll_file_list_d-dirname = o_dataobj->l_file_list_d-dirname.

* Cannot Copy or Move to the same Folder!

message id c_msgig_fsev type c_msgty_s number c_msgno_000

with 'Cannot Copy or Move to the same Folder!'(015).

call method fco_object->abort.

else.

clear: w_dd_target_name.

* Get target file name

concatenate

ll_file_list_d-dirname

ll_file_list_d-name

c_back_slash

o_dataobj->l_file_list_d-name

into w_dd_target_name.

endif.

endif.

endform. " handle_grid_on_drop

Page 131: SAP File Explorer

*-----------------------------------------------------------------------

* Form on_grid_drag

*-----------------------------------------------------------------------

form on_grid_drag using ful_row type lvc_s_row

ful_column type lvc_s_col

ful_row_no type lvc_s_roid

changing fco_object type ref to cl_dragdropobject.

data:

ll_file_list_d type zxis_0x_file_d.

* Read dragged item

read table i_file_list_d index ful_row-index into ll_file_list_d.

if ll_file_list_d-type_id = c_d.

* For security reasons Drag & Drop is only permitted for Files

message id c_msgig_fsev type c_msgty_s number c_msgno_000

with 'For security reasons Drag & Drop'(013)

'is only permitted for Files!'(014).

call method fco_object->abort.

elseif ll_file_list_d-type_id = c_f.

* Create and fill dataobject for events ONDROP and ONDROPCOMPLETE

create object o_dataobj.

move ll_file_list_d to o_dataobj->l_file_list_d.

* Remember also the row index in case of effect 'move'

move ful_row-index to o_dataobj->w_index.

* Assign data object to the refering event parameter

fco_object->object = o_dataobj.

endif.

endform. " on_grid_drag

*-----------------------------------------------------------------------

* Form on_dropcomplete_handler

*-----------------------------------------------------------------------

form on_dropcomplete_handler

using ful_row type lvc_s_row

ful_column type lvc_s_col

ful_row_no type lvc_s_roid

changing fco_object type ref to cl_dragdropobject.

data:

ll_file_list_d type zxis_0x_file_d.

read table i_file_list_d into ll_file_list_d index ful_row.

Page 132: SAP File Explorer

* Handle Server grid dropcomplete

if ll_file_list_d-seen = c_r.

* Transfer server to server

if w_dest = c_r.

perform on_grid_dropcomplete using ful_row ful_column

ful_row_no

changing fco_object.

* Transfer server to local

elseif w_dest = c_f.

perform on_grid_dropcompletf using ful_row ful_column

ful_row_no

changing fco_object.

endif.

* Handle Local PC grid dropcomplete

elseif ll_file_list_d-seen = c_f.

* Transfer local to server

if w_dest = c_r.

perform on_lgrid_dropcompletr using ful_row ful_column

ful_row_no

changing fco_object.

* Transfer local to local

elseif w_dest = c_f.

perform on_lgrid_dropcomplete using ful_row ful_column

ful_row_no

changing fco_object.

endif.

endif.

endform. " on_dropcomplete_handler

*-----------------------------------------------------------------------

* Form on_grid_dropcomplete

*-----------------------------------------------------------------------

form on_grid_dropcomplete

using ful_row type lvc_s_row

ful_column type lvc_s_col

ful_row_no type lvc_s_roid

changing fco_object type ref to cl_dragdropobject.

data:

lw_path_name type char200,

lw_subrc type sysubrc.

Page 133: SAP File Explorer

* Catch-Statement to make sure drag&drop-Operation is aborted properly

catch system-exceptions move_cast_error = 1.

o_dataobj ?= fco_object->object.

concatenate

o_dataobj->l_file_list_d-dirname

o_dataobj->l_file_list_d-name

into lw_path_name.

* Get source file data

perform open_file using lw_path_name

o_dataobj->l_file_list_d

changing lw_subrc.

if lw_subrc is not initial.

* Error transferring file!

message id c_msgig_fsev type c_msgty_s number c_msgno_000

with 'Error transferring file!'(016).

call method fco_object->abort.

else.

* Copy file data

perform save_file using w_dd_target_name

o_dataobj->l_file_list_d

changing lw_subrc.

if lw_subrc is not initial.

if lw_subrc = c_2.

* Operation Cancelled

message id c_msgig_fsev type c_msgty_s number c_msgno_000

with 'Operation Cancelled'(023).

call method fco_object->abort.

else.

* Error transferring file!

message id c_msgig_fsev type c_msgty_s number c_msgno_000

with 'Error transferring file!'(016).

call method fco_object->abort.

endif.

else.

* In case of move, delete source file

if fco_object->effect = cl_dragdrop=>move.

delete dataset lw_path_name.

Page 134: SAP File Explorer

* Find Path

w_find_path = o_dataobj->l_file_list_d-dirname.

w_file_path = o_dataobj->l_file_list_d-dirname.

* Find Routine

perform get_file_list using o_dataobj->l_file_list_d-dirname

c_wlchar.

* Set ALV Display Layout

perform set_grid_layout.

* Change Window Address

set titlebar c_tl_0100 with w_file_path.

endif.

endif.

endif.

endcatch.

if sy-subrc is not initial.

* Error transferring file!

message id c_msgig_fsev type c_msgty_s number c_msgno_000

with 'Error transferring file!'(016).

call method fco_object->abort.

endif.

endform. " on_grid_dropcomplete

*-----------------------------------------------------------------------

* Form on_grid_dropcompletf

*-----------------------------------------------------------------------

form on_grid_dropcompletf

using ful_row type lvc_s_row

ful_column type lvc_s_col

ful_row_no type lvc_s_roid

changing fco_object type ref to cl_dragdropobject.

data:

lw_path_name type char200,

lw_subrc type sysubrc.

* Catch-Statement to make sure drag&drop-Operation is aborted properly

catch system-exceptions move_cast_error = 1.

o_dataobj ?= fco_object->object.

concatenate

Page 135: SAP File Explorer

o_dataobj->l_file_list_d-dirname

o_dataobj->l_file_list_d-name

into lw_path_name.

* Get source file data

perform open_file using lw_path_name

o_dataobj->l_file_list_d

changing lw_subrc.

if lw_subrc is not initial.

* Error transferring file!

message id c_msgig_fsev type c_msgty_s number c_msgno_000

with 'Error transferring file!'(016).

call method fco_object->abort.

else.

* Transfer file localy

perform save_local using o_dataobj->l_file_list_d

w_dd_target_name

changing lw_subrc.

if lw_subrc is not initial.

if lw_subrc = c_2.

* Operation Cancelled

message id c_msgig_fsev type c_msgty_s number c_msgno_000

with 'Operation Cancelled'(023).

call method fco_object->abort.

else.

* Error transferring file!

message id c_msgig_fsev type c_msgty_s number c_msgno_000

with 'Error transferring file!'(016).

call method fco_object->abort.

endif.

else.

* In case of move, delete source file

if fco_object->effect = cl_dragdrop=>move.

delete dataset lw_path_name.

* Find Path

w_find_path = o_dataobj->l_file_list_d-dirname.

w_file_path = o_dataobj->l_file_list_d-dirname.

* Find Routine

perform get_file_list using o_dataobj->l_file_list_d-dirname

c_wlchar.

Page 136: SAP File Explorer

* Set ALV Display Layout

perform set_grid_layout.

* Change Window Address

set titlebar c_tl_0100 with w_file_path.

endif.

endif.

endif.

endcatch.

if sy-subrc is not initial.

* Error transferring file!

message id c_msgig_fsev type c_msgty_s number c_msgno_000

with 'Error transferring file!'(016).

call method fco_object->abort.

endif.

endform. " on_grid_dropcompletf

*-----------------------------------------------------------------------

* Form on_lgrid_dropcompletr

*-----------------------------------------------------------------------

form on_lgrid_dropcompletr

using ful_row type lvc_s_row

ful_column type lvc_s_col

ful_row_no type lvc_s_roid

changing fco_object type ref to cl_dragdropobject.

data:

lw_path_name type char200,

lw_source_file type string,

lw_rc type i,

lw_subrc type sysubrc.

* Catch-Statement to make sure drag&drop-Operation is aborted properly

catch system-exceptions move_cast_error = 1.

o_dataobj ?= fco_object->object.

concatenate

o_dataobj->l_file_list_d-dirname

o_dataobj->l_file_list_d-name

into lw_path_name.

* Upload local file

Page 137: SAP File Explorer

perform upload_local using o_dataobj->l_file_list_d

lw_path_name

changing lw_subrc.

if lw_subrc is initial.

* Copy file data

perform save_file using w_dd_target_name

o_dataobj->l_file_list_d

changing lw_subrc.

endif.

if lw_subrc is not initial.

if lw_subrc = c_2.

* Operation Cancelled

message id c_msgig_fsev type c_msgty_s number c_msgno_000

with 'Operation Cancelled'(023).

call method fco_object->abort.

else.

* Error transferring file!

message id c_msgig_fsev type c_msgty_s number c_msgno_000

with 'Error transferring file!'(016).

call method fco_object->abort.

endif.

else.

* In case of move, delete source file

if fco_object->effect = cl_dragdrop=>move.

lw_source_file = lw_path_name.

* Deletes a File

call method cl_gui_frontend_services=>file_delete

exporting

filename = lw_source_file

changing

rc = lw_rc

exceptions

file_delete_failed = 1

cntl_error = 2

error_no_gui = 3

file_not_found = 4

access_denied = 5

unknown_error = 6

not_supported_by_gui = 7

wrong_parameter = 8

others = 9.

Page 138: SAP File Explorer

if sy-subrc <> 0.

message id sy-msgid type c_msgty_s number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

* Find Path

w_find_path = o_dataobj->l_file_list_d-dirname.

w_file_path = o_dataobj->l_file_list_d-dirname.

* Find Routine

perform get_loc_file_list using o_dataobj->l_file_list_d-dirname

c_wlchar.

* Set ALV Display Layout

perform set_grid_layout.

* Change Window Address

set titlebar c_tl_0100 with w_file_path.

endif.

endif.

endcatch.

if sy-subrc is not initial.

* Error transferring file!

message id c_msgig_fsev type c_msgty_s number c_msgno_000

with 'Error transferring file!'(016).

call method fco_object->abort.

endif.

endform. " on_lgrid_dropcompletr

*-----------------------------------------------------------------------

* Form on_lgrid_dropcomplete

*-----------------------------------------------------------------------

form on_lgrid_dropcomplete

using ful_row type lvc_s_row

ful_column type lvc_s_col

ful_row_no type lvc_s_roid

changing fco_object type ref to cl_dragdropobject.

data:

lw_path_name type char200,

lw_source_file type string,

lw_rc type i,

lw_subrc type sysubrc.

Page 139: SAP File Explorer

* Catch-Statement to make sure drag&drop-Operation is aborted properly

catch system-exceptions move_cast_error = 1.

o_dataobj ?= fco_object->object.

concatenate

o_dataobj->l_file_list_d-dirname

o_dataobj->l_file_list_d-name

into lw_path_name.

* Copy file data

perform save_loc_file using w_dd_target_name

o_dataobj->l_file_list_d

changing lw_subrc.

if lw_subrc is not initial.

if lw_subrc = c_2.

* Operation Cancelled

message id c_msgig_fsev type c_msgty_s number c_msgno_000

with 'Operation Cancelled'(023).

call method fco_object->abort.

else.

* Error transferring file!

message id c_msgig_fsev type c_msgty_s number c_msgno_000

with 'Error transferring file!'(016).

call method fco_object->abort.

endif.

else.

* In case of move, delete source file

if fco_object->effect = cl_dragdrop=>move.

lw_source_file = lw_path_name.

* Deletes a File

call method cl_gui_frontend_services=>file_delete

exporting

filename = lw_source_file

changing

rc = lw_rc

exceptions

file_delete_failed = 1

cntl_error = 2

error_no_gui = 3

file_not_found = 4

access_denied = 5

unknown_error = 6

Page 140: SAP File Explorer

not_supported_by_gui = 7

wrong_parameter = 8

others = 9.

if sy-subrc <> 0.

message id sy-msgid type c_msgty_s number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

* Find Path

w_find_path = o_dataobj->l_file_list_d-dirname.

w_file_path = o_dataobj->l_file_list_d-dirname.

* Find Routine

perform get_loc_file_list using o_dataobj->l_file_list_d-dirname

c_wlchar.

* Set ALV Display Layout

perform set_grid_layout.

* Change Window Address

set titlebar c_tl_0100 with w_file_path.

endif.

endif.

endcatch.

if sy-subrc is not initial.

* Error transferring file!

message id c_msgig_fsev type c_msgty_s number c_msgno_000

with 'Error transferring file!'(016).

call method fco_object->abort.

endif.

endform. " on_lgrid_dropcomplete

*-----------------------------------------------------------------------

* Form save_file

*-----------------------------------------------------------------------

form save_file using fuw_file type any

ful_file_list type zxis_0x_file_d

changing fcw_subrc type any.

data:

ll_buftab_t type t_buftab_t.

data:

lw_answer type char1.

Page 141: SAP File Explorer

if i_buftab_t[] is initial.

fcw_subrc = c_1.

else.

if ful_file_list-type_f = c_bin.

* Open in binary mode

open dataset fuw_file for input in binary mode.

else.

* Open in text mode

open dataset fuw_file for input in text mode encoding default.

endif.

* Confirm replace file

if sy-subrc is initial.

call function 'POPUP_TO_CONFIRM'

exporting

titlebar = 'Replace File'(017)

text_question = 'File already exists in target folder, replace?'(018)

text_button_1 = 'Yes'(019)

text_button_2 = 'No'(020)

default_button = c_2

display_cancel_button = space

iv_quickinfo_button_1 = 'Replace current file'(021)

iv_quickinfo_button_2 = 'Cancel Drag & Drop Operation'(022)

importing

answer = lw_answer

exceptions

text_not_found = 1

others = 2.

if sy-subrc <> 0.

lw_answer = c_2.

fcw_subrc = c_2.

endif.

endif.

if lw_answer <> c_2.

if ful_file_list-type_f = c_bin.

* Open in binary mode

open dataset fuw_file for output in binary mode.

else.

* Open in text mode

open dataset fuw_file for output in text mode encoding default.

endif.

if sy-subrc <> 0.

Page 142: SAP File Explorer

fcw_subrc = c_1.

else.

loop at i_buftab_t into ll_buftab_t.

transfer ll_buftab_t to fuw_file.

if sy-subrc is not initial.

fcw_subrc = c_1.

exit.

endif.

endloop.

close dataset fuw_file.

endif.

else.

fcw_subrc = c_2.

endif.

endif.

endform. " save_file

*-----------------------------------------------------------------------

* Form save_loc_file

*-----------------------------------------------------------------------

form save_loc_file using fuw_file type any

ful_file_list type zxis_0x_file_d

changing fcw_subrc type any.

data:

lw_answer type char1,

lw_file type string,

lw_result type abap_bool,

lw_source_file type string,

lw_target_file type string.

lw_file = fuw_file.

* Checks if a File Exists

call method o_gui_serv->file_exist

exporting

file = lw_file

receiving

result = lw_result

exceptions

cntl_error = 1

error_no_gui = 2

wrong_parameter = 3

not_supported_by_gui = 4

Page 143: SAP File Explorer

others = 5.

* Confirm replace file

if sy-subrc is initial and lw_result is not initial.

call function 'POPUP_TO_CONFIRM'

exporting

titlebar = 'Replace File'(017)

text_question = 'File already exists in target folder, replace?'(018)

text_button_1 = 'Yes'(019)

text_button_2 = 'No'(020)

default_button = c_2

display_cancel_button = space

iv_quickinfo_button_1 = 'Replace current file'(021)

iv_quickinfo_button_2 = 'Cancel Drag & Drop Operation'(022)

importing

answer = lw_answer

exceptions

text_not_found = 1

others = 2.

if sy-subrc <> 0.

lw_answer = c_2.

fcw_subrc = c_2.

endif.

endif.

if lw_answer <> c_2.

concatenate

ful_file_list-dirname

ful_file_list-name

into lw_source_file.

lw_target_file = fuw_file.

lw_result = c_x.

* Copies a File

call method o_gui_serv->file_copy

exporting

source = lw_source_file

destination = lw_target_file

overwrite = lw_result

exceptions

cntl_error = 1

error_no_gui = 2

wrong_parameter = 3

disk_full = 4

access_denied = 5

Page 144: SAP File Explorer

file_not_found = 6

destination_exists = 7

unknown_error = 8

path_not_found = 9

disk_write_protect = 10

drive_not_ready = 11

not_supported_by_gui = 12

others = 13.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

else.

fcw_subrc = c_2.

endif.

endform. " save_loc_file

*-----------------------------------------------------------------------

* Form set_sort

*-----------------------------------------------------------------------

form set_sort using fuw_field1 type any

fuw_field2 type any

fuw_field3 type any

fuw_field4 type any

fuw_order type any.

data:

ll_sort type lvc_s_sort.

data:

lw_up type char1,

lw_down type char1.

* Set Sort Criteria

if fuw_order = c_ascd.

lw_up = c_x.

sort i_file_list_d ascending

by (fuw_field1) (fuw_field2) (fuw_field3) (fuw_field4).

else.

lw_down = c_x.

sort i_file_list_d descending

by (fuw_field1) (fuw_field2) (fuw_field3) (fuw_field4).

endif.

Page 145: SAP File Explorer

clear: i_sort.

if fuw_field1 is not initial.

ll_sort-spos = c_1.

ll_sort-fieldname = fuw_field1.

ll_sort-up = lw_up.

ll_sort-down = lw_down.

append ll_sort to i_sort.

clear: ll_sort.

endif.

if fuw_field2 is not initial.

ll_sort-spos = c_2.

ll_sort-fieldname = fuw_field2.

ll_sort-up = lw_up.

ll_sort-down = lw_down.

append ll_sort to i_sort.

clear: ll_sort.

endif.

if fuw_field3 is not initial.

ll_sort-spos = c_3.

ll_sort-fieldname = fuw_field3.

ll_sort-up = lw_up.

ll_sort-down = lw_down.

append ll_sort to i_sort.

clear: ll_sort.

endif.

if fuw_field4 is not initial.

ll_sort-spos = c_4.

ll_sort-fieldname = fuw_field4.

ll_sort-up = lw_up.

ll_sort-down = lw_down.

append ll_sort to i_sort.

clear: ll_sort.

endif.

endform. " set_sort

*-----------------------------------------------------------------------

* Form get_local_drive

*-----------------------------------------------------------------------

form get_local_drive changing fcw_drive type string.

data:

ll_drv type t_drv.

Page 146: SAP File Explorer

data:

lw_abcde type syabcde,

lw_drv type char3 value ' :\',

lw_tra type char2 value 'A ',

lw_trb type char2 value 'B ',

lw_trn type char2.

lw_abcde = sy-abcde.

translate lw_abcde using lw_tra.

translate lw_abcde using lw_trb.

condense lw_abcde no-gaps.

clear: i_drv.

while lw_abcde is not initial.

lw_drv(1) = lw_abcde(1).

w_drive = lw_drv.

clear: lw_trn.

lw_trn(1) = w_drive(1).

translate lw_abcde using lw_trn.

condense lw_abcde no-gaps.

* Get Drive Type

call method o_gui_serv->get_drive_type

exporting

drive = w_drive

changing

drive_type = w_type

exceptions

cntl_error = 1

bad_parameter = 2

error_no_gui = 3

not_supported_by_gui = 4

others = 5.

if sy-subrc = 0.

call method cl_gui_cfw=>flush.

if w_type is not initial.

ll_drv-drive = w_drive.

ll_drv-type = w_type.

if ll_drv-type = c_fixed.

ll_drv-desc = 'Local Disk (#)'(025).

replace c_card with ll_drv-drive(2) into ll_drv-desc.

Page 147: SAP File Explorer

elseif ll_drv-type = c_cdrom.

ll_drv-desc = 'CDROM Drive (#)'(026).

replace c_card with ll_drv-drive(2) into ll_drv-desc.

elseif ll_drv-type = c_remote.

ll_drv-desc = 'Remote Drive (#)'(027).

replace c_card with ll_drv-drive(2) into ll_drv-desc.

endif.

append ll_drv to i_drv.

endif.

endif.

clear: w_drive, w_type, ll_drv.

endwhile.

endform. " get_local_drive

*-----------------------------------------------------------------------

* Form check_local_tree

*-----------------------------------------------------------------------

form check_local_tree .

if w_loc is not initial.

clear:

w_loc, w_search_path, i_file_list, i_nodel,

i_log_listl, i_kpath, i_buftab_t, i_lquery_table, i_html.

w_act = w_src = w_dct = c_x.

w_file_path = w_dysp_path = w_lpath_name.

call method o_tree_contl->free.

if w_srcl is initial.

clear: w_loc.

* Prepare Grid Output

if w_src is initial.

perform grid_prepare.

endif.

* Display Local PC

perform display_local.

else.

* Prepare Grid Output

perform grid_prepare.

perform lsearch_prepare.

Page 148: SAP File Explorer

* Prepare HTML Output

w_find_path = w_lpath_name.

perform html_prepare.

* Display HTML

perform html_show.

endif.

endif.

endform. " check_local_tree

PBO-Modules Include

- LZXIS_X_00_FILE_SERVICESO01

*----------------------------------------------------------------------*

***INCLUDE LZXIS_X_00_FILE_SERVICESO01 .

*----------------------------------------------------------------------*

*-----------------------------------------------------------------------

* Author: António César Date: 28/01/2009

*-----------------------------------------------------------------------

*-----------------------------------------------------------------------

* Module status_0100 OUTPUT

*-----------------------------------------------------------------------

module status_0100 output.

* Get Initial Parameter Values

perform initiate_gui.

set pf-status c_st_0100.

set titlebar c_tl_0100 with w_dysp_path.

endmodule. " status_0100 OUTPUT

*-----------------------------------------------------------------------

* Module output_prepare OUTPUT

*-----------------------------------------------------------------------

module output_prepare output.

if w_act is initial.

* Get File System Data

if i_file_list[] is initial.

w_server_path = w_file_path.

perform get_file_list using c_slash

c_wlchar.

endif.

Page 149: SAP File Explorer

* Prepare Grid Output

if w_src is initial.

perform grid_prepare.

endif.

* Prepare Display Output

perform output_prepare.

* Prepare tree for First Output

perform tree_prepare.

* Add Folders

perform add_node using w_nnode_key.

* Set Display path

perform getto_dest_path using w_server_path

changing w_nnode_key.

* Expand Root Dir

perform expand_node using w_nnode_key.

* Log displayed folders

perform add_table_lines.

* Check Local

perform check_local_tree.

elseif w_dct is initial.

* Prepare Search Display Output

if w_perf = c_r.

* Prepare Grid Output

perform grid_prepare.

* Prepare Search Output

perform search_prepare.

* Prepare HTML Output

w_find_path = w_path_name.

perform html_prepare.

* Display HTML

perform html_show.

if w_loc is not initial.

if w_srcl is initial.

clear: w_loc.

* Display Local PC

Page 150: SAP File Explorer

perform display_local.

else.

perform lsearch_prepare.

* Prepare HTML Output

w_find_path = w_lpath_name.

perform html_prepare.

* Display HTML

perform html_show.

endif.

endif.

elseif w_perf = c_f.

* Prepare Grid Output

perform grid_prepare.

perform lsearch_prepare.

* Prepare HTML Output

perform html_prepare.

* Display HTML

perform html_show.

endif.

endif.

endmodule. " output_prepare OUTPUT

PAI-Modules Include

- LZXIS_X_00_FILE_SERVICESI01

*----------------------------------------------------------------------*

***INCLUDE LZXIS_X_00_FILE_SERVICESI01 .

*----------------------------------------------------------------------*

*-----------------------------------------------------------------------

* Author: António César Date: 28/01/2009

*-----------------------------------------------------------------------

*-----------------------------------------------------------------------

* Module user_command_0100 INPUT

*-----------------------------------------------------------------------

module user_command_0100 input.

case ok_code.

when c_cont.

* Get exporting data

Page 151: SAP File Explorer

perform assign_fields.

when c_locl.

* Display Local PC

perform display_local_pc.

endcase.

endmodule. " user_command_0100 INPUT

*-----------------------------------------------------------------------

* Module exit_0100 INPUT

*-----------------------------------------------------------------------

module exit_0100 input.

perform free_control.

endmodule. " exit_0100 INPUT

The creation should be easy, but if you have any

questions or suggestions for improvement please

drop me a mail, you can find it at the very

beginning of this document.

It will be a hell of a mess for you to copy the code

from here though as PDF files don’t retain much

of the formatting spaces or even page breaks!!!

Anyway…. Have fun!!!