Application Development 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: 

how to convert GUI_UPLOAD to open dataset

p244500
Active Contributor
0 Kudos

Hai

I write the data upload program.. using GUI_UPLOAD function. … this function does not support to the back ground program. I want to run that program using back ground program… but I don’t knw how to do it if u can plz tel me how to convert this….using open dataset??????????

This is my function

v_filename = dataset.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = v_filename

filetype = 'ASC'

has_field_separator = 'X'

TABLES

data_tab = it_as400

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 "+

OTHERS = 17. "+

CASE sy-subrc.

WHEN '1'. "+

WRITE: /'ERROR WHILE OPENING THE FILE'.

WHEN '2'. "+

WRITE: /'ERROR WHILE READING THE FILE'.

WHEN '3'. "+

WRITE: /'NO BATCH'.

WHEN '4'. "+

WRITE: /'ERROR IN FILE TRANSFERING'.

WHEN '5'. "+

WRITE: /'INVALID TYPE'.

WHEN '6'. "+

WRITE: /'NO AUTHORITY TO RUN THIS PROGRAM'.

WHEN '7'. "+

WRITE: /'UNKNOWN ERROR'.

WHEN '8'. "+

WRITE: /'BAD DATA FORMAT'.

WHEN '9'. "+

WRITE: /'HEADER NOT ALLOWED'.

WHEN '10'. "+

WRITE: /'SEPERATOR NOT ALLOWED'.

WHEN '11'. "+

WRITE: /'TOO LONG HEADER'.

WHEN '12'. "+

WRITE: /'UNKNOWN DP ERROR'.

WHEN '13'. "+

WRITE: /'ACCESS DENIED'.

WHEN '14'. "+

WRITE: /'DP OUT OF MEMORY'.

WHEN '15'. "+

WRITE: /'DISK IS FULL'.

WHEN '16'. "+

WRITE: /'DP TIME OUT'.

WHEN '17'. "+

WRITE: /'OTHERS'.

ENDCASE.

IF sy-subrc <> 0.

STOP.

ENDIF.

regard

nawa

4 REPLIES 4

Former Member
0 Kudos

Hi,

you can not access any file on the presentation server (your desktop) in the background mode..

Thanks and Best Regards,

Vikas Bittera.

varma_narayana
Active Contributor
0 Kudos

Hii

GUI_UPLOAD is for reading data from Local file. This will not be supported in Background.

But OPEN dataset is for reading data from Application server file. So it is not an Alternative for GUI_UPload.

Let me know if u want the logic to read the file from application server.

<b>reward if Helpful.</b>

Former Member
0 Kudos

Hi,

The syntax for OPEN DATASET is something like this.

OPEN DATASET w_file_name IN LEGACY BINARY MODE

BIG ENDIAN

FOR OUTPUT/INPUT.

But this will create a file on the application server only. It wil not be able to access the files from the local file system.

It will work in background but with the above mentioned limitation.

i hope this will help u.

~ Ramanath.

Former Member
0 Kudos

hI

IN THIS I HAD USED OPENDATSET

&----


*& Report ZSD_EXCEL_INT_APP

*&

&----


*&

*&

&----


REPORT ZSD_EXCEL_INT_APP.

parameter: file_nm type localfile.

types : begin of it_tab1,

f1(20),

f2(40),

f3(20),

end of it_tab1.

data : it_tab type table of ALSMEX_TABLINE with header line,

file type rlgrap-filename.

data : it_tab2 type it_tab1 occurs 1,

wa_tab2 type it_tab1,

w_message(100) TYPE c.

at selection-screen on value-request for file_nm.

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

EXPORTING

  • PROGRAM_NAME = SYST-REPID

  • DYNPRO_NUMBER = SYST-DYNNR

  • FIELD_NAME = ' '

STATIC = 'X'

  • MASK = ' '

CHANGING

file_name = file_nm

EXCEPTIONS

MASK_TOO_LONG = 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.

start-of-selection.

refresh it_tab2[].clear wa_tab2.

file = file_nm.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

filename = file

i_begin_col = '1'

i_begin_row = '1'

i_end_col = '10'

i_end_row = '35'

tables

intern = it_tab

EXCEPTIONS

INCONSISTENT_PARAMETERS = 1

UPLOAD_OLE = 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.

loop at it_tab.

case it_tab-col.

when '002'.

wa_tab2-f1 = it_tab-value.

when '004'.

wa_tab2-f2 = it_tab-value.

when '008'.

wa_tab2-f3 = it_tab-value.

endcase.

at end of row.

append wa_tab2 to it_tab2.

clear wa_tab2.

endat.

endloop.

data : p_file TYPE rlgrap-filename value 'TEST3.txt'.

OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

*--- Display error messages if any.

IF sy-subrc NE 0.

MESSAGE e001(zsd_mes).

EXIT.

ELSE.

*---Data is downloaded to the application server file path

LOOP AT it_tab2 INTO wa_tab2.

TRANSFER wa_tab2 TO p_file.

ENDLOOP.

ENDIF.

*--Close the Application server file (Mandatory).

CLOSE DATASET p_file.

loop at it_tab2 into wa_tab2.

write : / wa_tab2-f1,wa_tab2-f2,wa_tab2-f3.

endloop.

REWARD IF USEFULL