2009 Apr 27 7:09 AM
Hi Experts!
I have one question. How can I open file which is on Unix server on client computer. I have to say that I don't know file type, it could be pdf, excel file or ordinary text file. In dependence of file type I would like to open it in proper program on user computer.
I found following function modules: GUI_RUN, WS_EXECUTE. With files which are saved on user computer everything is ok but when I pass path for Unix i.e. '/usr/sap/tmp/test.txt' functions are not able to find them.
Maybe there is possibility to use one of these functions but I don't know how, if not could you give me other?
Thanks in advance.
Baru
2009 Apr 27 9:06 AM
Hi,
here a short example for output and input
TABLES: MARA.
*
DATA: DATEI_A(30) TYPE C VALUE '/usr/sap/tmp/test.txt'.
*
TYPES: BEGIN OF IMARA,
MATNR LIKE MARA-MATNR,
MTART LIKE MARA-MATNR,
END OF IMARA.
*
DATA: ITAB TYPE TABLE OF IMARA WITH HEADER LINE.
DATA: ITAB_READ TYPE TABLE OF IMARA WITH HEADER LINE.
*
START-OF-SELECTION.
*
SELECT MATNR MTART INTO TABLE ITAB FROM MARA UP TO 20 ROWS.
*
PERFORM DATEI_AUSGEBEN.
PERFORM DATEI_EINLESEN.
*
************************************************************************
FORM DATEI_AUSGEBEN.
*
OPEN DATASET DATEI_A FOR OUTPUT IN TEXT MODE encoding default.
IF SY-SUBRC NE 0. EXIT. ENDIF.
*
LOOP AT ITAB.
*
TRANSFER ITAB TO DATEI_A.
*
ENDLOOP.
*
CLOSE DATASET DATEI_A.
IF SY-SUBRC NE 0. EXIT. ENDIF.
*
ENDFORM. "DATEI_AUSGEBEN
************************************************************************
FORM DATEI_EINLESEN.
*
OPEN DATASET DATEI_A FOR INPUT IN TEXT MODE encoding default.
IF SY-SUBRC NE 0. EXIT. ENDIF.
*
DO.
*
READ DATASET DATEI_A INTO ITAB_READ.
*
IF SY-SUBRC <> 0. EXIT. ENDIF.
*
APPEND ITAB_READ.
*
ENDDO.
*
CLOSE DATASET DATEI_A.
*
IF SY-SUBRC NE 0. EXIT. ENDIF.
*
LOOP AT ITAB_READ. WRITE: / ITAB_READ. ENDLOOP.
*
ENDFORM. "DATEI_EINLESEN
************************************************************************
Another way is to search in this forum for open/close/read DATASET.
Regards, Dieter
Hi Experts!
I have one question. How can I open file which is on Unix server on client computer. I have to say that I don't know file type, it could be pdf, excel file or ordinary text file. In dependence of file type I would like to open it in proper program on user computer.
I found following function modules: GUI_RUN, WS_EXECUTE. With files which are saved on user computer everything is ok but when I pass path for Unix i.e. '/usr/sap/tmp/test.txt' functions are not able to find them.
Maybe there is possibility to use one of these functions but I don't know how, if not could you give me other?
Thanks in advance.
Baru
2009 Apr 27 8:57 AM
2009 Apr 27 9:06 AM
Hi,
here a short example for output and input
TABLES: MARA.
*
DATA: DATEI_A(30) TYPE C VALUE '/usr/sap/tmp/test.txt'.
*
TYPES: BEGIN OF IMARA,
MATNR LIKE MARA-MATNR,
MTART LIKE MARA-MATNR,
END OF IMARA.
*
DATA: ITAB TYPE TABLE OF IMARA WITH HEADER LINE.
DATA: ITAB_READ TYPE TABLE OF IMARA WITH HEADER LINE.
*
START-OF-SELECTION.
*
SELECT MATNR MTART INTO TABLE ITAB FROM MARA UP TO 20 ROWS.
*
PERFORM DATEI_AUSGEBEN.
PERFORM DATEI_EINLESEN.
*
************************************************************************
FORM DATEI_AUSGEBEN.
*
OPEN DATASET DATEI_A FOR OUTPUT IN TEXT MODE encoding default.
IF SY-SUBRC NE 0. EXIT. ENDIF.
*
LOOP AT ITAB.
*
TRANSFER ITAB TO DATEI_A.
*
ENDLOOP.
*
CLOSE DATASET DATEI_A.
IF SY-SUBRC NE 0. EXIT. ENDIF.
*
ENDFORM. "DATEI_AUSGEBEN
************************************************************************
FORM DATEI_EINLESEN.
*
OPEN DATASET DATEI_A FOR INPUT IN TEXT MODE encoding default.
IF SY-SUBRC NE 0. EXIT. ENDIF.
*
DO.
*
READ DATASET DATEI_A INTO ITAB_READ.
*
IF SY-SUBRC <> 0. EXIT. ENDIF.
*
APPEND ITAB_READ.
*
ENDDO.
*
CLOSE DATASET DATEI_A.
*
IF SY-SUBRC NE 0. EXIT. ENDIF.
*
LOOP AT ITAB_READ. WRITE: / ITAB_READ. ENDLOOP.
*
ENDFORM. "DATEI_EINLESEN
************************************************************************
Another way is to search in this forum for open/close/read DATASET.
Regards, Dieter
2009 Apr 27 9:13 AM
Hi!
Sorry but you showed me how to save information in file on Unix, but I want to display on user's screen in proper program file which is already saved on Unix. I know path and so one. I just need to diplsy it on the screen.
Bartek
2009 Apr 27 9:17 AM
Hi,
do you look on the 2. FORM??
If you will only show a file take the 2. form.
Regards, Dieter
2009 Apr 27 9:37 AM
Hi!
You have to understand that I odn't want to have it in table. I just wan tot open this file in appriopriate program on user's PC. Maybe something according below logic:
1. Read file from Unix to some temporart memory on user's PC
2. Open file in proper program on the screen.
3. Then program should go furthrer.
Best regards
Bartek
2009 Apr 27 9:43 AM
Hi,
what do you mean by proper program? is this abap or a windows program?
If abap read it as i have shown and show the entries from the internal table.
if a windows program read it in abap, download it on your PC and open your
windows-program with this file.
Regards, Dieter
2009 Apr 27 10:09 AM
Hi!
I want to open it in Windows program. The problem is that I dont' know where on the PC he will be able to save it. But do you know maybe function to download file from Unix to local file in Windows.
Best regards
Bartek
2009 Apr 27 10:22 AM
Hi,
sorry, but do you search in this forum for GUI_DOWNLOAD or
CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD.
There are a lot of examples.
Try it. If you then get problems with your code, post it here.
Regards, Dieter
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |