‎2006 Aug 30 11:47 AM
Hi!
I have the following requirement:-
- We have a Dialogue program in which we need to add a push button 'Attachment'.
- Clicking on that push button should allow me to browse through the screen and select the required file and attach it.
- After it is attached double clicking on that doc. should allow me to view that file.
Since I am very new in ABAP it would be great if someone could provide a helpful hand.Will be thankful to you.
Thanks and Regards
Sourabh Verma
‎2006 Aug 30 12:46 PM
Hi Sourabh,
here a little report wich shows files.
when you click an the Filename it will be shown
with the application.
REPORT ZGRO_TESTT MESSAGE-ID ZZ.
*
DATA: DIR TYPE STRING.
DATA: FILE_TABLE TYPE FILETABLE.
DATA: COUNT TYPE I.
*
DATA: APPL TYPE STRING.
*
DATA: APP1(80).
DATA: WA_FILE_TABLE(80).
DATA: CURSORFIELD(20).
*
START-OF-SELECTION.
*
<b>DIR = 'D:\'.</b> "Here your DIR
*
CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_LIST_FILES
EXPORTING
DIRECTORY = DIR
FILTER = '*.DOC' "update if you need
FILES_ONLY = 'X'
CHANGING
FILE_TABLE = FILE_TABLE
COUNT = COUNT.
*
LOOP AT FILE_TABLE INTO WA_FILE_TABLE.
*
CONCATENATE DIR WA_FILE_TABLE INTO APP1.
WRITE: / 'Datei:', APP1 COLOR COL_NEGATIVE HOTSPOT ON .
HIDE: APP1.
*
ENDLOOP.
*
END-OF-SELECTION.
*
AT LINE-SELECTION.
*
GET CURSOR FIELD CURSORFIELD.
*
CASE CURSORFIELD.
*
WHEN 'APP1'.
APPL = APP1.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>EXECUTE
EXPORTING
APPLICATION = APPL.
*
ENDCASE.
*
Hope it helps.
Regards, Dieter
‎2006 Aug 31 11:06 AM
Hi Dieter!
I tried running this report.But no output is coming.
‎2006 Aug 31 11:30 AM
Hi Sourabh,
do you update the field DIR = 'D:\'?
look at your workstation and go
to your Directory where the .DOC-Files are stored.
This Directory must be the DIR-Field in Abap.
F. Exampl. C:\TEMP\DOCFILES.
DIR must be 'C:\TEMP\DOCFILES\'.
Regards, Dieter
‎2006 Aug 31 12:16 PM
Hi Dieter!
This is how i ran the code.
REPORT Z57340TEST9 .
*REPORT ZGRO_TESTT MESSAGE-ID ZZ.
*
DATA: DIR TYPE STRING.
DATA: FILE_TABLE TYPE FILETABLE.
DATA: COUNT TYPE I.
*
DATA: APPL TYPE STRING.
*
DATA: APP1(80).
DATA: WA_FILE_TABLE(80).
DATA: CURSORFIELD(20).
*
START-OF-SELECTION.
*
DIR = 'C:\YServer'. "Here your DIR
*
CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_LIST_FILES
EXPORTING
DIRECTORY = DIR
FILTER = '*.DOC' "update if you need
FILES_ONLY = 'X'
CHANGING
FILE_TABLE = FILE_TABLE
COUNT = COUNT.
*
LOOP AT FILE_TABLE INTO WA_FILE_TABLE.
*
CONCATENATE DIR WA_FILE_TABLE INTO APP1.
WRITE: / 'Datei:', APP1 COLOR COL_NEGATIVE HOTSPOT ON .
HIDE: APP1.
*
ENDLOOP.
*
END-OF-SELECTION.
*
AT LINE-SELECTION.
*
GET CURSOR FIELD CURSORFIELD.
*
CASE CURSORFIELD.
*
WHEN 'APP1'.
APPL = APP1.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>EXECUTE
EXPORTING
APPLICATION = APPL.
*
ENDCASE.
*
Regards
Sourabh
‎2006 Aug 31 12:19 PM
Sorry Dieter!
This is the corrrect code.
REPORT Z57340TEST9 .
*REPORT ZGRO_TESTT MESSAGE-ID ZZ.
*
DATA: DIR TYPE STRING.
DATA: FILE_TABLE TYPE FILETABLE.
DATA: COUNT TYPE I.
*
DATA: APPL TYPE STRING.
*
DATA: APP1(80).
DATA: WA_FILE_TABLE(80).
DATA: CURSORFIELD(20).
*
START-OF-SELECTION.
*
DIR = 'C:\YServer.txt'. "Here your DIR
*
CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_LIST_FILES
EXPORTING
DIRECTORY = DIR
FILTER = '*.DOC' "update if you need
FILES_ONLY = 'X'
CHANGING
FILE_TABLE = FILE_TABLE
COUNT = COUNT.
*
LOOP AT FILE_TABLE INTO WA_FILE_TABLE.
*
CONCATENATE DIR WA_FILE_TABLE INTO APP1.
WRITE: / 'Datei:', APP1 COLOR COL_NEGATIVE HOTSPOT ON .
HIDE: APP1.
*
ENDLOOP.
*
END-OF-SELECTION.
*
AT LINE-SELECTION.
*
GET CURSOR FIELD CURSORFIELD.
*
CASE CURSORFIELD.
*
WHEN 'APP1'.
APPL = APP1.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>EXECUTE
EXPORTING
APPLICATION = APPL.
*
ENDCASE.
‎2006 Aug 31 12:25 PM
Hi Sourabh,
First i think <b>'C:\YServer.txt' is not a directory</b>!
I think DIR = <b>'C:\'</b> ist ok.
But do you looking for txt or doc files.
You can change <b>FILTER = '*.DOC'</b>
To <b>FILTER = '.'</b>, than you see all files.
Try it.
Regards, Dieter
‎2006 Sep 01 12:06 PM
Hi Sourabh,
do you have still any problems with
this topic?
Regards, Dieter
‎2006 Sep 01 12:39 PM
Hi Dieter!
Your help was indeed very helpful.Atleat I got some clue.But still my purpose is not excatly solved and I have to explore a lot.
Currently stuck up in some other issue.Will be requiring your help very shortly.
Thanks and Regards
Sourabh
‎2006 Sep 07 11:26 AM
Hi Dieter!
The code here gives me all the files that are in C:\.
Basically, I want the functionality through which i can browse through my desktop and select a particular file through C:\ or D:\ or Desktop ,depending on the requirement.
Secondly i should be able to save that file to my system and it should be visible to me as a icon.Clicking on that icon should open the file.
This is similar to attaching a file to a mail.
Thanks and regards
Sourabh