Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Opne file on client computer

bartlomiej_lach
Participant
0 Likes
1,310

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,256

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

8 REPLIES 8
Read only

bartlomiej_lach
Participant
0 Likes
1,256

Hi!

Have anyone any idea?

Best regards

Bartek

Read only

Former Member
0 Likes
1,257

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

Read only

0 Likes
1,256

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

Read only

0 Likes
1,256

Hi,

do you look on the 2. FORM??

If you will only show a file take the 2. form.

Regards, Dieter

Read only

0 Likes
1,256

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

Read only

0 Likes
1,256

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

Read only

0 Likes
1,256

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

Read only

0 Likes
1,256

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