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

dump to application server

Former Member
0 Likes
703

Hye...

Please help me in placing the dump of a report (excel ) in application server.

Thanks in advance.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
567

Load this program in the system and check:

&----


*& Report ZAPPSERVER01

*&

&----


*&

*&

&----


REPORT ZAPPLSERVER message-id FB.

************************************************************************

Constants

constants :c_mask(80) type c value ',.,..', " Mask

c_file_type(10) type c value 'ASC', " File type

c_mode(1) type c value 'L'. " Mode

Internal tables *

data: begin of i_file occurs 0,

field(3000) type c,

end of i_file.

data : v_msg(100),

struct_file like i_file occurs 0.

Parameters

parameters: p_fpath type filename-FILEINTERN obligatory,

p_lpath type localfile,

p_upload as checkbox default 'X',

p_dload as checkbox,

p_delete as checkbox.

************************************************************************

Check selection-screen entries *

************************************************************************

At selection screen

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_lpath.

PERFORM get_file CHANGING p_lpath.

************************************************************************

Main *

************************************************************************

Start of selection

start-of-selection.

if p_upload = 'X'.

Upload to app server

perform upload_to_appserver.

endif.

if p_dload = 'X'.

Download to desktop

perform download_to_desktop.

endif.

if p_delete = 'X'.

Delete file on app server

delete dataset p_fpath.

if sy-subrc = 0.

message s000 with 'File deleted'.

endif.

endif.

************************************************************************

*----


Set file path of local machine

*----


FORM get_file CHANGING file_out.

DATA: l_filename TYPE localfile. "Local file for upload/download

CALL FUNCTION 'WS_FILENAME_GET'

EXPORTING

mask = c_mask

mode = c_mode

IMPORTING

filename = l_filename

EXCEPTIONS

inv_winsys = 01

no_batch = 02

selection_cancel = 03

selection_error = 04.

p_lpath = l_filename.

ENDFORM. "get_file

&----


*& Form UPLOAD_TO_APPSERVER

&----


Upload local file to app server

-


form upload_to_appserver .

data: l_lpath type string.

l_lpath = p_lpath.

refresh i_file.

clear i_file.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = l_lpath

FILETYPE = c_file_type

HAS_FIELD_SEPARATOR = ' '

HEADER_LENGTH = 0

READ_BY_LINE = 'X'

DAT_MODE = 'X'

CODEPAGE = ' '

IGNORE_CERR = ABAP_TRUE

REPLACEMENT = SPACE

CHECK_BOM = '#'

IMPORTING

FILELENGTH =

HEADER =

TABLES

DATA_TAB = i_file

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.

open dataset p_fpath for output in text mode encoding default

message v_msg.

if sy-subrc = 0.

loop at i_file. " into struct_file.

if not i_file is initial.

transfer i_file to p_fpath.

endif.

endloop.

else.

message e000 with 'File cannot be opened for output'.

endif.

close dataset p_fpath.

endform. " UPLOAD_TO_APPSERVER

&----


*& Form DOWNLOAD_TO_DESKTOP

&----


text

-


--> p1 text

<-- p2 text

-


form download_to_desktop .

open dataset p_fpath for input in text mode

encoding default

message v_msg.

if sy-subrc = 0.

refresh : i_file.

do.

read dataset p_fpath into i_file.

if sy-subrc = 0.

append i_file to i_file.

else.

exit.

endif.

enddo.

else.

message e000 with 'File cannot be opened'.

endif.

close dataset p_fpath.

call function 'DOWNLOAD'

EXPORTING

filename = p_lpath

TABLES

data_tab = i_file.

endform. " DOWNLOAD_TO_DESKTOP

pls reward if helps

3 REPLIES 3
Read only

Former Member
0 Likes
567

Hi,

Make ur question clear.

Regards,

Ramya

Read only

Former Member
0 Likes
568

Load this program in the system and check:

&----


*& Report ZAPPSERVER01

*&

&----


*&

*&

&----


REPORT ZAPPLSERVER message-id FB.

************************************************************************

Constants

constants :c_mask(80) type c value ',.,..', " Mask

c_file_type(10) type c value 'ASC', " File type

c_mode(1) type c value 'L'. " Mode

Internal tables *

data: begin of i_file occurs 0,

field(3000) type c,

end of i_file.

data : v_msg(100),

struct_file like i_file occurs 0.

Parameters

parameters: p_fpath type filename-FILEINTERN obligatory,

p_lpath type localfile,

p_upload as checkbox default 'X',

p_dload as checkbox,

p_delete as checkbox.

************************************************************************

Check selection-screen entries *

************************************************************************

At selection screen

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_lpath.

PERFORM get_file CHANGING p_lpath.

************************************************************************

Main *

************************************************************************

Start of selection

start-of-selection.

if p_upload = 'X'.

Upload to app server

perform upload_to_appserver.

endif.

if p_dload = 'X'.

Download to desktop

perform download_to_desktop.

endif.

if p_delete = 'X'.

Delete file on app server

delete dataset p_fpath.

if sy-subrc = 0.

message s000 with 'File deleted'.

endif.

endif.

************************************************************************

*----


Set file path of local machine

*----


FORM get_file CHANGING file_out.

DATA: l_filename TYPE localfile. "Local file for upload/download

CALL FUNCTION 'WS_FILENAME_GET'

EXPORTING

mask = c_mask

mode = c_mode

IMPORTING

filename = l_filename

EXCEPTIONS

inv_winsys = 01

no_batch = 02

selection_cancel = 03

selection_error = 04.

p_lpath = l_filename.

ENDFORM. "get_file

&----


*& Form UPLOAD_TO_APPSERVER

&----


Upload local file to app server

-


form upload_to_appserver .

data: l_lpath type string.

l_lpath = p_lpath.

refresh i_file.

clear i_file.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = l_lpath

FILETYPE = c_file_type

HAS_FIELD_SEPARATOR = ' '

HEADER_LENGTH = 0

READ_BY_LINE = 'X'

DAT_MODE = 'X'

CODEPAGE = ' '

IGNORE_CERR = ABAP_TRUE

REPLACEMENT = SPACE

CHECK_BOM = '#'

IMPORTING

FILELENGTH =

HEADER =

TABLES

DATA_TAB = i_file

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.

open dataset p_fpath for output in text mode encoding default

message v_msg.

if sy-subrc = 0.

loop at i_file. " into struct_file.

if not i_file is initial.

transfer i_file to p_fpath.

endif.

endloop.

else.

message e000 with 'File cannot be opened for output'.

endif.

close dataset p_fpath.

endform. " UPLOAD_TO_APPSERVER

&----


*& Form DOWNLOAD_TO_DESKTOP

&----


text

-


--> p1 text

<-- p2 text

-


form download_to_desktop .

open dataset p_fpath for input in text mode

encoding default

message v_msg.

if sy-subrc = 0.

refresh : i_file.

do.

read dataset p_fpath into i_file.

if sy-subrc = 0.

append i_file to i_file.

else.

exit.

endif.

enddo.

else.

message e000 with 'File cannot be opened'.

endif.

close dataset p_fpath.

call function 'DOWNLOAD'

EXPORTING

filename = p_lpath

TABLES

data_tab = i_file.

endform. " DOWNLOAD_TO_DESKTOP

pls reward if helps

Read only

Former Member
0 Likes
567

Hi,

Use the below coding to dump to application server.

--- Class defination -


CLASS cl_abap_char_utilities DEFINITION LOAD.

  • Assign '#' to ascii_tab

CONSTANTS: ascii_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.

DATA : e_os_message TYPE c.

DATA : v_string(5000).

DATA : v_target(128).

DATA: wa_output LIKE it_output.

FIELD-SYMBOLS: <f> , <delim>.

  • Assign delimiter field tab .

ASSIGN ascii_tab TO <delim>.

  • Get the file name on the application server depending on System ID and client

CONCATENATE '/userdata/' sy-sysid '/'

sy-mandt

'/interfaces/email_templates/OE/'

'download_output.xls'

INTO v_target.

  • Open file on application server for output

OPEN DATASET v_target FOR OUTPUT MESSAGE e_os_message

IN TEXT MODE ENCODING DEFAULT.

  • Check whether file opened on application server

IF sy-subrc EQ 0.

  • Pass heading to WA_OUTPUT

wa_output-matnr = 'Material Number'.

wa_output-zmdesc = 'Material Description'.

wa_output-ersda = 'Create date'.

wa_output-vkorg = 'Sales Org'.

wa_output-werks = 'Plant'.

wa_output-vtweg = 'DistChanl'.

wa_output-matkl = 'Mat Group'.

wa_output-zusg_type = 'Usg Type'.

wa_output-zlic_type = 'LicType'.

wa_output-zser_type = 'SerType'.

wa_output-zsvc_sale_type = 'SS Type'.

wa_output-zref_type = 'Ref Type'.

wa_output-mvgr5 = 'MatGroup5'.

wa_output-success_message = 'Success Messages'.

wa_output-error_message = 'Error Messages'.

  • Insert the header into it_output

INSERT wa_output INTO it_output INDEX 1.

LOOP AT it_output.

DO.

  • Assigns the next field in the current header to <f>.

ASSIGN COMPONENT sy-index OF STRUCTURE it_output TO <f>.

IF sy-subrc <> 0. " No fields left in the header structure.

EXIT. " Exits do loop and process next record in itab

ENDIF.

IF sy-index = 1. " If first field in header, assign to string

v_string = <f>.

ELSE. " Concatenate string, delimter, next field

CONCATENATE v_string <delim> <f> INTO v_string.

ENDIF.

ENDDO.

  • String is now delimited. Transfer to server.

TRANSFER v_string TO v_target.

ENDLOOP.

  • Close the file on the application server

CLOSE DATASET v_target.

ELSE.

  • If file is not opend give error

WRITE : 'FILE OPEN ERROR' .

ENDIF.