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: 

Uploading internal table to Application Server

Former Member
0 Kudos

hi all,

i want to upload the internal table data to aaplication server,

thanks in advance.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

U put tht internal table to a file..Plz use GUI_DOWNLOAD..

After tht u can apply this following step u can send it easily without much coding..

call method : CL_GUI_FRONTEND_SERVICES=>FILE_COPY EXPORTING source = 'C:\TEST\TEXT.TXT'

DESTINATION = 'C:\TEST\TEXT3.TXT'

OVERWRITE = 'X'.

Give the source file path tht u download using GUI_DOWNLOAD..

Destination u can give the path name of server..Ask Basis people abt the path..

A simple coding of oneline can help u to do this...try this

Reward if useful!!!!!!!!!!!!1

6 REPLIES 6

Former Member
0 Kudos

Hi

see this sample program where i had transferd data from EXCEL TO INTERNAL TABLE THEN TO APPLICATION SERVER

&----


*& 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.

Former Member
0 Kudos

DATA: file TYPE string VALUE `flights.dat`,

wa TYPE spfli.

FIELD-SYMBOLS TYPE x.

OPEN DATASET file FOR OUTPUT IN BINARY MODE.

call funcation gui_upload

<b>

TRANSFER TO file.</b>

ENDSELECT.

CLOSE DATASET file.

Former Member
0 Kudos

Hi,

U put tht internal table to a file..Plz use GUI_DOWNLOAD..

After tht u can apply this following step u can send it easily without much coding..

call method : CL_GUI_FRONTEND_SERVICES=>FILE_COPY EXPORTING source = 'C:\TEST\TEXT.TXT'

DESTINATION = 'C:\TEST\TEXT3.TXT'

OVERWRITE = 'X'.

Give the source file path tht u download using GUI_DOWNLOAD..

Destination u can give the path name of server..Ask Basis people abt the path..

A simple coding of oneline can help u to do this...try this

Reward if useful!!!!!!!!!!!!1

Former Member
0 Kudos

HI,

see this example.

PARAMETERS: p_file LIKE rlgrap-filename OBLIGATORY.

DATA : ITAB LIKE VBAP OCCURS 0 WITH HEADER LINE.

DATA FNAME(60) VALUE 'myfile'.

DATA : S_FILE TYPE STRING.

DATA: TXT(100).

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

  • To select the File in the system.

CALL FUNCTION 'F4_FILENAME'

IMPORTING

file_name = p_file.

START-OF-SELECTION.

S_FILE = P_FILE.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = S_FILE

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

TABLES

DATA_TAB = itab.

OPEN DATASET FNAME FOR OUTPUT IN BINARY MODE.

TRANSFER itab TO FNAME.

CLOSE DATASET FNAME.

OPEN DATASET FNAME FOR INPUT IN BINARY MODE.

DO.

READ DATASET FNAME INTO txt.

WRITE: / txt.

IF SY-SUBRC <> 0.

EXIT.

ENDIF.

ENDDO.

CLOSE DATASET FNAME.

rgds,

bharat.

Former Member
0 Kudos

Hi,

You can use Open DataSet and Close Dateset Statment for this purpose:

OPEN DATASET FULLFNAME FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

where FullfName will consist of the Path for the Application Server.

(Refer to Transaction AL11 )

Then use Transfer Statement to transfer the contents of the Internal Table to the File

Loop at ws_out.

TRANSFER ws_out TO fullfname.

EndLoop.

Finally

CLOSE DATASET FULLFNAME.

Hope this of help to you.

Thanks and regards,

pavithra

Former Member
0 Kudos

Hi

If you are concerned about coding the field names in your concatenate statement, you can do something like this. Here it will add the fields of the internal table, one by one.

report zrich_0001.

parameters: d1 type localfile default '/usr/sap/TST/SYS/Data1.txt'.

data: begin of itab occurs 0,

fld1(20) type c,

fld2(20) type c,

end of itab.

data: str type string.

field-symbols: <fs>.

itab-fld1 = 'ABC'.

itab-fld2 = 'DEF'.

append itab.

itab-fld1 = 'GHI'.

itab-fld2 = 'JKL'.

append itab.

start-of-selection.

open dataset d1 for output in text mode encoding default.

loop at itab.

do.

assign component sy-index of structure itab to <fs>.

if sy-subrc <> 0.

exit.

endif.

if sy-index = 1.

str = <fs> .

else.

concatenate str <fs> into str

separated by cl_abap_char_utilities=>horizontal_tab.

endif.

enddo.

transfer str to d1.

endloop.

close dataset d1.

<b>Reward if usefull</b>