File download to presentation server in BACKGROUND
Hello,
i'm trying to download a simple list to the presentation server, but in a background process (part of an update rule for an infopackage). I´ve tried WS_Download and CALL METHOD o->gui_download etc but the job cancels with them since they seem only to run in frontend. Does anyone know of a more suitable function module?
Thanks,
Kev
Hi,
Tyr to download file to unix in background.
PARAMETERS: p_unix LIKE rlgrap-filename.
INITIALIZATION.
v_uzeit = sy-uzeit.
v_date = sy-datum.
v_client = sy-mandt.
v_sys = sy-sysid.
CONCATENATE c_str v_sys c_str4 v_client
c_str3 v_date c_str5 v_uzeit c_str6 INTO p_unix.
DATA: v_fnam LIKE rlgrap-filename,
v_filepht LIKE FILENAME-FILEINTERN, "File for p_unix
v_sys LIKE sy-sysid,
v_client LIKE sy-mandt,
v_date LIKE sy-datum,
v_uzeit LIKE sy-uzeit
FORM f3000_save_unix_file.
SORT i_output.
* Open the file in application server
OPEN DATASET p_unix FOR OUTPUT IN TEXT MODE.
IF sy-subrc <> 0.
MESSAGE s900 WITH p_unix. " File opening error
LEAVE LIST-PROCESSING.
ENDIF.
LOOP AT i_output INTO w_output.
TRANSFER w_output TO p_unix.
CLEAR w_output.
ENDLOOP.
IF sy-subrc = 0.
WRITE:/ text-075, p_unix, text-076. " File successfully created
ELSE.
WRITE:/ text-074, p_unix. " Error creating file
ENDIF.
* Closing the file
CLOSE DATASET p_unix.
ENDFORM. " f3000_save_unix_file
Also refer this link
http://www.sapdevelopment.co.uk/file/file_updown.htm
Try this might help u.
Similar Messages
-
XML file download to presentation server.
Hi Experts,
Here I have a question regarding file download to desktop.
I have a report which will generate xml file. Once it is generated i would like to download to desktop.
I tried with 'GUI_DOWNLOAD', but it is not working. It means the file is downlaoded to presentation server but when i opened it 'Page can't be displayed' message is comming.
Could you pleas help me to solve this issue.
Thanks in advance.
Regards,
Anil.GHello,
For processing XMLs always try to make use of the class CL_XML_DOCUMENT.
You can download the XML stream to a local file using the method of EXPORT_TO_FILE class CL_XML_DOCUMENT.
Further reading: [/people/uwe.schieferstein/blog/2010/10/17/visualizing-any-kind-of-xml-data-using-class-clxmldocument]
BR,
Suhas -
Upload and download of excel file in the application server in background
Hi all,
i want to download the excel file from application server into internal table and after processing i have to upload to excel file in the application server in the background mode..
i mean i'll schedule the program in background.
im using FM ALSM_EXCEL_TO_INTERNAL_TABLE its working fine in fore ground but not in back ground.
what method i have to follow ?Hi Ankit,
I think this is not possible to open a Excel-File from the application server because the Excel format before Office 2007 where a binary format (Suffix: .xls). The newer Office file format (Suffix: xlsx) is a zipped XML Format. To read the binary Excel-Format you need an OLE Connection between SAP GUI and Office. But at the application server in background you doesn't have this OLE Connection.
In my opinion you have two possibilities:
1. Convert all files in the CSV format. This file format can be read with open dataset.
2. Upload the files from the presentation server in forground. There are some funktion modules in the standard which can read the xls format. But they have some limits regarding the length of cells content.
My recommendation is solution no. 1. If you know an VBA expert, he can write an Excel-macro which converts all Excel Files in the CSV-Fomat.
Regards
Dirk -
How to transfer file from application server to presentation server in background?
Hi Experts,
How to transfer file from application server to presentation server in background?
Thanks in advance
NamitaThanks Raman and Challa,
We want to move file from application server to Shared folder, not on local machine. We checked FM which you guys have provided but those are not able to read file from application server.
We need this program to run in background so that we can use this in daily process chain.
Appreciate your inputs on this.
Thanks,
Namita -
File download from application server to presentation server
Hi,
We have requirment to upload a file to application server in .dbf format and then download it to presentation server. while downloading the file to presentation server some of the fields getting junk values. we are downloading file to excel sheet. some of the fields values are Russian texts. Those fields only getting junk values, all other fields are getting correct values.
Please advice.
Regards,
chandra.hi
sample code below should help you......
<u>Download to presentation server</u>
This program can be used to download files from Application server to presentaion server.
1)Maximum length of each field is considered to be 40 characters.
2)Maximum length of the field can be changed by specifying the length in selection screen parameter
3)First line of the Application server file should contain the description of each field.
4)Each field should be delimited by #.
*& Report ZDOWNLOADFILE *
REPORT ZDOWNLOADFILE
MESSAGE-ID B1 .
INCLUDES *
INCLUDE ZDOWNLOADFILE_TOP.
INCLUDE ZDOWNLOADFILE_FORM.
EVENT-AT SELECTION-SCREEN *
AT SELECTION-SCREEN ON pa_appl.
PERFORM check_file_exists USING pa_appl.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_appl.
PERFORM f4_dxfilename USING pa_appl.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_pres.
PERFORM f4_filename USING pa_pres.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_del.
PERFORM f4_dxfilename USING pa_del.
EVENT INITIALIZATION *
INITIALIZATION.
PERFORM initialization.
EVENT START-OF-SELECTION *
START-OF-SELECTION.
PERFORM determine_fields. "Determine number of columns
PERFORM build_itab. "Create internal table based on number
"of columns
PERFORM build_header. "To prepare header for the file
PERFORM download_data. "Download data to presentation server
PERFORM delete_files. "Delete files from application server
*& Include ZDOWNLOADFILE_TOP *
TYPES: BEGIN OF ty_header,
text(100) TYPE c,
END OF ty_header.
DATA: c_fnh_mask type dxfields-filemask value '.',
search_dir type dxfields-longpath value '/sapglobal/users'.
CLASS cl_abap_char_utilities DEFINITION LOAD.
Internal tables *
DATA: gt_header TYPE STANDARD TABLE OF ty_header,
gt_fieldcat TYPE lvc_t_fcat.
Work areas *
DATA: gs_header TYPE ty_header,
gs_fieldcat TYPE lvc_s_fcat.
DATA: wa_filename TYPE string.
DATA: wa_count(2) TYPE N,
wa_start(3) TYPE N,
wa_end(3) TYPE N,
wa_len(3) TYPE N.
DATA: wa_data(12000) TYPE c,
wa_off TYPE I,
itab_appl TYPE REF TO DATA,
itab_line TYPE REF TO DATA,
col(2) TYPE c.
DATA: wa_field(30) TYPE c.
DATA: lv_index TYPE sy-tabix.
DATA: gs_adrp type adrp,
gs_usr02 type usr02,
gs_usr21 type usr21,
gs_char50(50).
CONSTANTS: co_slash(1) value '/'.
FIELD-SYMBOLS: <itab> TYPE STANDARD TABLE,
<wa>,
<fs_line>,
<wa_line>.
SELECTION SCREEN *
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE text-f01.
PARAMETERS: pa_appl LIKE rlgrap-filename OBLIGATORY.
SELECTION-SCREEN END OF BLOCK B1.
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE text-f02.
PARAMETERS: pa_pres LIKE rlgrap-filename OBLIGATORY.
SELECTION-SCREEN END OF BLOCK B2.
SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE text-f03.
PARAMETERS: pa_del LIKE rlgrap-filename .
PARAMETERS: pa_deld AS CHECKBOX.
SELECTION-SCREEN END OF BLOCK B3.
SELECTION-SCREEN BEGIN OF BLOCK B4 WITH FRAME TITLE text-f04.
PARAMETERS: pa_len(3) TYPE c.
SELECTION-SCREEN END OF BLOCK B4.
*& Include ZDOWNLOADFILE_FORM *
*& Form f4_dxfilename
text
-->P_pa_appl text
form f4_dxfilename using p_file.
DATA: wa_file LIKE dxfields-longpath.
CLEAR: wa_file.
call function 'F4_DXFILENAME_TOPRECURSION'
exporting
i_location_flag = 'A'
i_server = ' '
i_path = search_dir
filemask = c_fnh_mask
fileoperation = 'R'
importing
o_path = wa_file
exceptions
rfc_error = 1
error_with_gui = 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.
else.
p_file = wa_file.
endif.
endform. " f4_dxfilename
*& Form f4_filename
text
-->P_pa_pres text
form f4_filename using p_data.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
IMPORTING
FILE_NAME = p_data
endform. " f4_filename
*& Form check_file_exists
text
-->P_pa_appl text
form check_file_exists using p_file.
DATA: wa_file LIKE rlgrap-filename.
wa_file = p_file.
OPEN DATASET wa_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc = 8.
MESSAGE E714
WITH text-m01 p_file text-m02.
ELSE.
CLOSE DATASET p_file.
ENDIF.
endform. " check_file_exists
*& Form build_header
text
--> p1 text
<-- p2 text
form build_header .
*Select user details
clear gs_usr21-persnumber.
select single persnumber
into (gs_usr21-persnumber)
from usr21
where bname = sy-uname.
concatenate sy-uname
co_slash
gs_adrp-name_text(36)
co_slash
into gs_char50.
condense gs_char50.
clear gs_usr02-class.
select single class
into (gs_usr02-class)
from usr02
where bname = sy-uname.
concatenate gs_char50
gs_usr02-class
into gs_char50.
condense gs_char50.
Write report technical name
write 'Name: ' TO gs_header+0(10).
gs_header+11(*) = sy-repid.
APPEND gs_header TO gt_header.
CLEAR: gs_header.
Write user data
write 'User: ' TO gs_header+0(10).
gs_header+11(*) = gs_char50.
CONCATENATE gs_header gs_char50 INTO
gs_header SEPARATED BY SPACE.
APPEND gs_header TO gt_header.
CLEAR: gs_header.
Write System data
write 'System: ' TO gs_header+0(10).
write: sy-sysid to gs_header+11(3).
write: co_slash to gs_header+14(1).
write: sy-mandt to gs_header+15(3).
APPEND gs_header TO gt_header.
CLEAR: gs_header.
Write System date and time
write 'System: ' TO gs_header+0(10).
write sy-datum to gs_header+11(10).
write sy-uzeit to gs_header+22(8).
APPEND gs_header TO gt_header.
CLEAR: gs_header.
Write Local date and time
write 'Local: ' TO gs_header+0(10).
write sy-datlo to gs_header+11(10).
write sy-timlo to gs_header+22(8).
APPEND gs_header TO gt_header.
CLEAR: gs_header.
APPEND gs_header TO gt_header.
endform. " build_header
*& Form determine_fields
text
--> p1 text
<-- p2 text
form determine_fields .
DATA: wa_data(600) TYPE c.
CLEAR: wa_count,wa_start,wa_end,wa_data.
wa_start = 0.
wa_end = 1.
OPEN DATASET pa_appl FOR INPUT IN TEXT MODE ENCODING DEFAULT.
READ DATASET pa_appl INTO wa_data.
wa_len = STRLEN( wa_data ).
DO wa_len TIMES.
IF wa_data+wa_start(wa_end) EQ
cl_abap_char_utilities=>horizontal_tab.
wa_count = wa_count + 1.
ENDIF.
wa_start = wa_start + 1.
ENDDO.
CLOSE DATASET pa_appl.
wa_count = wa_count + 1.
endform. " determine_fields
*& Form build_itab
text
--> p1 text
<-- p2 text
form build_itab .
DATA: wa_len(4) TYPE c.
CLEAR: wa_len.
IF pa_len IS INITIAL.
wa_len = 40.
ELSE.
wa_len = pa_len.
ENDIF.
col = 1.
DO wa_count TIMES.
CONCATENATE 'FIELD' col INTO wa_field.
gs_fieldcat-fieldname = wa_field.
gs_fieldcat-outputlen = wa_len.
gs_fieldcat-datatype = 'CHAR'.
gs_fieldcat-col_pos = col.
col = col + 1.
APPEND gs_fieldcat TO gt_fieldcat.
CLEAR: wa_field.
ENDDO.
*Create the internal table dynamically based on the file structure,
*this table will be used to download data through GUI_DOWNLOAD fm
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = gt_fieldcat
IMPORTING
EP_TABLE = itab_appl
*Assign the pointer to the field symbol
ASSIGN itab_appl->* TO <itab>.
CREATE DATA itab_line LIKE LINE OF <itab>.
*Create a work area for the dynamic internal table
ASSIGN itab_line->* TO <wa_line>.
col = 1.
OPEN DATASET pa_appl FOR INPUT IN TEXT MODE ENCODING DEFAULT.
DO.
READ DATASET pa_appl INTO wa_data.
IF sy-subrc <> 0.
CLOSE DATASET pa_appl.
RETURN.
ELSE.
wa_start = 0.
lv_index = 1.
DO wa_count TIMES.
ASSIGN COMPONENT lv_index OF STRUCTURE <wa_line> TO <fs_line>.
FIND cl_abap_char_utilities=>horizontal_tab
IN wa_data+wa_start(*) MATCH OFFSET wa_off.
IF sy-subrc = 0.
IF wa_off NE 0.
<fs_line> = wa_data+wa_start(wa_off).
ENDIF.
wa_start = wa_start + wa_off + 1.
lv_index = lv_index + 1.
ELSE.
<fs_line> = wa_data+wa_start(*).
ENDIF.
ENDDO.
APPEND <wa_line> TO <itab>.
CLEAR: <wa_line>,<fs_line>.
ENDIF.
ENDDO.
endform. " build_itab
*& Form download_data
text
--> p1 text
<-- p2 text
form download_data .
clear: wa_filename.
wa_filename = pa_pres.
call function 'GUI_DOWNLOAD'
exporting
filename = wa_filename
filetype = 'DAT'
tables
data_tab = gt_header
exceptions
access_denied = 15
call function 'GUI_DOWNLOAD'
exporting
filename = wa_filename
filetype = 'DAT'
append = 'X'
tables
data_tab = <itab>
exceptions
access_denied = 15
endform. " download_data
*& Form initialization
text
--> p1 text
<-- p2 text
form initialization .
REFRESH: gt_header,gt_fieldcat,gt_header.
endform. " initialization
*& Form delete_files
text
--> p1 text
<-- p2 text
form delete_files .
IF pa_deld EQ 'X'.
DELETE DATASET pa_appl.
ENDIF.
IF pa_del IS NOT INITIAL.
DELETE DATASET pa_del.
ENDIF.
endform. " delete_files
<b>reward points if helpful.</b>
thanks
vijay -
Reading file from the presentation server in the background
Hi,
I am trying to read a .csv file from the presentation server into an internal table in the background. what should I do for it? In the foreground it works fine.
I have declared a selection parameter 'p_file' that has the path of the file. It wokrs fine in the foreground and how to set it up in the background?
Any thoughts would be helpful. Thanks in advance,
VGhii
did you achieved the required functionality , i,e, accessing presentation server file i nbackground .
I too got the same requirement, can you explain the process.
There is no way you can do it... The best method is to put the file on Appln server and then call it in the background mode.
Regards,
Vishwa. -
CAN WE DOWNLOAD A REPORT TO PRESENTATION SERVER IN BACKGROUND
Hi
1. Can we download a report into presentation server in background mode and it should be saved in excel. If so plz let me know how to do.
2. When i look into spool SP01 the report is not in proper format because the report output width is more than 255 characters and now how should i solve the problem to make it in correct format. Can we do this or not?. If so how
Thanks in advance.Hi
when i wrote the
REPORT z_mm_rep_000047
LINE-SIZE 500
LINE-COUNT 65
MESSAGE-ID zca.
it is automatically increasing the width in the print settings when i increased to 500 from 255 but stil its not working. -
How to download data to the presentation server in background?
Hi,
I would like to download data to the presentation server in background.
Currently, the report uses FM GUI_DOWNLOAD to download in foreground.
However, this FM does not work in the background.
But please let me know how to download to the presentation server in background.
Thanks and regards,
AnishurModerator message - FAQ - Please search before asking - post locked
Rob -
Retrieving records to presentation server after Background Job.
Hi Friends,
Here i am working on a data updation program.I am passing the data in an excel and after updation all the error records are populating into another Excel file whose path also i am providing in the selection scree. This error excel file i am storing in the presentation server(user workstation).
Its working fine in foreground and creating error file in case of errors successfully.Initially i did not have a background execution option as its communicating presentation server.
but now user wants it to run in background, so i have given a background radiobutton on selecting this it will SUBMIT the same program again as a job.
This also working fine but as a batch job could not create the error log file in the front end.
So now i am thnking of a logic : I ll write the error log records in the Application server. Then i ll check whether the file has written completely in the application server by giving some delay (in 15 seconds it will check the appl server if the dataset has been created successfully).
Eg ;
Code for delay setting that i would like to know from you .
OPEN DATASET ERRLOG........
If sy-subrc EQ 0.
Loop.
Put the values into an internal table.
ENDLOOP.
Using GUI_DOWNLOAD download the content of int table to Excel file.
As of now i am having this logic to go further.
Already started R&D .
Would like to know from you how far this will be feasible and the way to set the delay to read the Error from appl server?
If you have any other idea please let me know.
Ask me on any clariffication on this issue.
Thanks & Regards,
SAM.Hi!
You can't see a presentation server while your program is running in the background. It is, because in this case there is no presentation, no user-display for the results. So all GUI related functions are unreachable, downloading also.
You might try to send the log, in email, or like a sapoffice mail.
You might try to set up a directory on a shared file server, and put the file there into user specified directories.
But forget downloading into presentation server.
Regards
Tamá -
How to validate a Particular Directory or file path in Presentation server.
Hi SAP gurus,
I am having a requirement where I want to download a file into the Presentation server.
The file path to download will be provided in a parameter.
What I want to do is to throw a message to the user if He/She provides a wrong Directory or File path.
For example :
Say the user is providing the file download path as " E:\test.txt", but there is no "E" drive or such directory in the presentation. So in this case I should be able to check the wrong Directory provided by the user and throw some message to the user saying there is no such Directory present. Please give a proper directory or similar messages.
I have found a FM: PFL_CHECK_DIRECTORY but i am not able to use it properly.
So do you have any FM or any method and its explanation to fulfill my requirement .Do it this way:
tables:
spfli.
parameters:
p_file type rlgrap-filename " File name
obligatory.
Data:
t_final_data like table of spfli.
at selection-screen on value-request for p_file.
call function 'F4_FILENAME'
exporting
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name = ' '
importing
file_name = p_file.
at selection-screen.
data:
lw_file type string. " File Path
lw_file = p_file.
select * from spfli into table t_final_data.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = lw_file
tables
data_tab = t_final_data.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
if sy-subrc <> 0.
message 'File not found' type 'E'.
endif.
With luck,
Pritam. -
PDF to be downloaded to appln server in background
Hi
To be more precise I am using the FM
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = gd_spool_nr
no_dialog = c_no
dst_device = c_device
IMPORTING
pdf_bytecount = gd_bytecount
TABLES
pdf = it_pdf_output
EXCEPTIONS
err_no_abap_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_destdevice = 5
user_cancelled = 6
err_spoolerror = 7
err_temseerror = 8
err_btcjob_open_failed = 9
err_btcjob_submit_failed = 10
err_btcjob_close_failed = 11
OTHERS = 12.
to convert the spool output to PDF and want this PDF to be downloaded to appln server in background.
any workaround?
IF KNOW PLS REPLY.
Thanks,
DeesanthHi Deshant,
Why can't???
Just now i tried this code. It is perfectly working fine.
Just copy paste below code and pass one abaplist spool number to the FM and execute in back ground. Infact it is working fine in both foreground and back ground. U have to change the file name also:-)
When i downloaded the file to local PC through transaction CG3Y, The pdf file is showing correct results.
Check this and get back.
DATA: it_pdf_output TYPE TABLE OF tline,
wa_pdf TYPE tline,
l_file(100) TYPE c VALUE '/usr/upi/out/test.pdf'.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = '29642'
*no_dialog = 'X'
*dst_device =
*IMPORTING
*pdf_bytecount = gd_bytecount
tables
pdf = it_pdf_output
EXCEPTIONS
err_no_abap_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_destdevice = 5
user_cancelled = 6
err_spoolerror = 7
err_temseerror = 8
err_btcjob_open_failed = 9
err_btcjob_submit_failed = 10
err_btcjob_close_failed = 11
OTHERS = 12.
CHECK NOT it_pdf_output[] IS INITIAL.
OPEN DATASET l_file IN TEXT MODE.
IF sy-subrc IS INITIAL.
LOOP AT it_pdf_output INTO wa_pdf.
TRANSFER wa_pdf TO l_file.
ENDLOOP.
CLOSE DATASET l_file.
WRITE: 'Data written to appl file', l_file.
ELSE.
WRITE: 'Not able to open file'.
ENDIF.
Thanks,
Vinod. -
How to delete a local file in the presentation server.
Hi All,
How to delete a local file in the presentation server. As we do using 'delete dataset dsn' in application server. How can i achieve this. My requirement is after uploading file using gui_upload, i want to delete that source file. Please let me know, how can i achieve this.
Thanks in advance.
Regards,
Vishaldata: l_rc type i.
data: f_name type string.
move 'c:\YourFile.txt' to f_name.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_DELETE
EXPORTING
FILENAME = f_name
CHANGING
RC = l_rc
EXCEPTIONS
FILE_DELETE_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
FILE_NOT_FOUND = 4
ACCESS_DENIED = 5
UNKNOWN_ERROR = 6
NOT_SUPPORTED_BY_GUI = 7
WRONG_PARAMETER = 8
others = 9
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF. -
"Bad data format" when reading txt file from the presentation server
Hello,
I have a piece of code which reads a txt file from the presentation server to an internal table like below:
DATA : lv_filename type string.
lv_filename = 'C:\abap\Test.txt'. "I created a folder called abap under C:\
CALL method CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
EXPORTING
FILENAME = lv_filename
CHANGING
DATA_TAB = lt_tsd. " lt_tab has the exact same fields as the Test.txt's. Test.txt has only one line, tab delimited.
When running this code, exception BAD_DATA_FORMAT is issued.
Is it because of the file encoding or delimiter or other reason?
Thanks,
YangHello,
If its tab delimited then use the has_field_seperator parameter and check
DATA : lv_filename type string.
lv_filename = 'C:\abap\Test.txt'. "I created a folder called abap under C:\
CALL method CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
EXPORTING
FILENAME = lv_filename
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = u2018Xu2019
CHANGING
DATA_TAB = lt_tsd.
Vikranth -
File Upload and Download From Presentation server
I have a requirement to provide a selection option to user to upload a big file from presentation server.
Not sure whther we can a upload the entire file at one short from presentation server. PLease provide some sample code to upload a huge file from presentation server and downlaod a file to presentation server.Hi,
Try this code for download----
TABLES:
kna1. " General Data in Customer Master
TYPES:
BEGIN OF type_s_kna1,
kunnr TYPE kna1-kunnr, " Customer Number
adrnr TYPE kna1-adrnr, " Address
anred TYPE kna1-anred, " Title
erdat TYPE kna1-erdat, " Date on which record created
ernam TYPE kna1-ernam, " Name of Person who Created the
" Object
END OF type_s_kna1.
DATA:
fs_kna1 TYPE type_s_kna1.
DATA:
t_kna1 LIKE
STANDARD TABLE
OF fs_kna1.
" Select-options----
SELECT-OPTIONS:
s_kunnr FOR kna1-kunnr. " Customer Number
AT SELECTION-SCREEN ON s_kunnr.
SELECT kunnr " Customer number
FROM kna1
INTO s_kunnr UP TO 1 ROWS.
ENDSELECT.
IF sy-subrc NE 0.
MESSAGE 'No such customer exists' TYPE 'S'.
ENDIF. " IF SY-SUBRC NE 0
START-OF-SELECTION.
PERFORM customer_selection.
FORM customer_selection .
SELECT kunnr " Customer Number
adrnr " Address
anred " Title
erdat " Date of record creation
ernam " Person who created object
FROM kna1
INTO TABLE t_kna1
WHERE kunnr IN s_kunnr.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
filename = 'C:\TEMP\CUSTOMER.TXT'
FILETYPE = 'ASC'
write_field_separator = 'X'
HEADER = '00'
WRITE_LF = 'X'
col_select = 'X'
col_select_mask = 'XXXXX'
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
IMPORTING
FILELENGTH =
TABLES
data_tab = t_kna1
EXCEPTIONS
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF. " IF SY-SUBRC NE 0
ENDFORM. " FORM CUSTOMER_SELECTION.
for upload----
" Table declarations----
TABLES:
bkpf. " Accounting Document Header
TYPES:
BEGIN OF type_s_bkpf,
bukrs TYPE bkpf-bukrs, " Company code
belnr TYPE bkpf-belnr, " Accounting Document Number
gjahr TYPE bkpf-gjahr, " Fiscal Year
blart TYPE bkpf-blart, " Document type
bldat TYPE bkpf-bldat, " Document Date in Document
END OF type_s_bkpf.
DATA:
fs_bkpf TYPE type_s_bkpf.
DATA:
fname(10) TYPE c VALUE 'ACCOUNTING' .
DATA:
t_bkpf LIKE
STANDARD TABLE
OF fs_bkpf.
*" Select-options----
SELECT-OPTIONS:
s_bukrs FOR bkpf-bukrs, " Company code
s_gjahr FOR bkpf-gjahr. " Fiscal year
OPEN DATASET fname FOR OUTPUT IN BINARY MODE .
PERFORM account_selection.
LOOP AT t_bkpf INTO fs_bkpf.
TRANSFER fs_bkpf TO fname.
ENDLOOP. " LOOP T_BKPF
CLOSE DATASET fname.
FORM account_selection .
SELECT bukrs " Company code
belnr " Accounting document number
gjahr " Fiscal year
blart " Document year
bldat " Document date
FROM bkpf
INTO TABLE t_bkpf
WHERE bukrs IN s_bukrs
AND gjahr IN s_gjahr.
ENDFORM. " FORM ACCOUNT_SELECTION
also try
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:\TEMP\CUSTOMER.TXT'
FILETYPE = 'ASC'
has_field_separator = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
IMPORTING
FILELENGTH =
HEADER =
TABLES
data_tab = t_kna1
EXCEPTIONS
disk_full = 15
dp_timeout = 16
OTHERS = 17
IF sy-subrc EQ 0.
PERFORM customer_display.
ELSE.
MESSAGE 'No customer file exists'(006) TYPE 'S'.
ENDIF. " IF SU-SUBRC EQ 0
Regards,
jaya
Edited by: Jayapradha Neeli on May 28, 2009 11:38 AM -
How to get pdf file from sap presentation server using java connector
Hi Friends,
with the below code i am able to get po details in pdf in presentation server.
DATA : w_url TYPE string
VALUE 'C:\Documents and Settings\1011\Solutions\web\files\podet.pdf'.
CALL FUNCTION 'ECP_PDF_DISPLAY'
EXPORTING
purchase_order = i_ponum
IMPORTING
PDF_BYTECOUNT =
pdf = file " data in Xsting format
*Converting Xstring to binary_tab
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = file
APPEND_TO_TABLE = ' '
IMPORTING
OUTPUT_LENGTH =
TABLES
binary_tab = it_bin " data in binary format
**Downloading into PDF file
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
filename = w_url
filetype = 'BIN'
TABLES
data_tab = it_bin
when i am using java connector , to retirve the file from presentation server , the follwoing error i am getting...
init:
deps-jar:
compile-single:
run-single:
com.sap.mw.jco.JCO$Exception: (104) RFC_ERROR_SYSTEM_FAILURE: Error in Control Framework
at com.sap.mw.jco.rfc.MiddlewareRFC$Client.nativeExecute(Native Method)
at com.sap.mw.jco.rfc.MiddlewareRFC$Client.execute(MiddlewareRFC.java:1244)
at com.sap.mw.jco.JCO$Client.execute(JCO.java:3842)
at com.sap.mw.jco.JCO$Client.execute(JCO.java:3287)
at PdfGen.<init>(PdfGen.java:35)
at PdfGen.main(PdfGen.java:78)
Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)
i debugged too, problem with <b>gui_download......</b>
I am very glad to all with your suggestions!!
Regards,
Madhu..!!Hi
You can try to create an external command (transaction SM69).......sorry I've forgotten,,,,they works on application
How do you call CL_GUI_FRONTEND_SERVICES=>EXECUTE?
Max
Edited by: max bianchi on Oct 13, 2011 10:27 AM
Maybe you are looking for
-
CR Server: Login loop when I run a report
Post Author: Marcotte CA Forum: General I have CR Server XI installed on my server. I can log into the Central Management Console and Infoview from the client. I can load objects and run the sample reports. I can set up users and security. I can
-
Exit button not working in Safari
Has anyone run into this, specifically with Safari? I created a module in Captivate 8, that has a close button on the skin. The module has been uploaded to my clients LMS and it closes no problem on all other browsers except Safari. I tried creating
-
How do I get a song off my itunes onto my iphone 4 ?
How do I get a song off my itunes onto my iphone 4 ?
-
Hi All, I would like to come out a CUA strategy for a ECC three system landscape (D,Q,P). As i understand the best practice is to have CUA master on each landscape, D, Q and P, but as far as i know this is helpful on complex environment, and the othe
-
Hi. My Face Time continuisely shuts itself down after about a minute of use. Can anyone suggest what might be causing this and how I can sort it out. This only happens on my MacBook Pro and not on any of my other devices.