File to be stored in application server
Hi all
Can anybody provide me sample code for storing file on application server.
very urgent.
regrd
Mona
Edited by: Alvaro Tejada Galindo on Apr 14, 2008 6:17 PM
: a program to create a file on the application server *
with the following fields,
*"Parameter............................................................
PARAMETERS:
p_bukrs TYPE bkpf-bukrs, " Company code
p_gjahr TYPE bkpf-gjahr. " Fiscal Year
*"Data declaration ....................................................
DATA:
w_file TYPE localfile VALUE 'aa.txt'.
structure declaration to hold accounting document header *
DATA:
BEGIN OF fs_bkpf,
bukrs LIKE bkpf-bukrs, " Company code
belnr LIKE bkpf-belnr, " Accounting document number
gjahr LIKE bkpf-gjahr, " Fiscal Year
blart LIKE bkpf-blart, " Document type
bldat LIKE bkpf-bldat, " Document date in document
END OF fs_bkpf.
Internal table to hold to hold accounting document data *
DATA:
t_bkpf LIKE STANDARD TABLE OF fs_bkpf.
PERFORM get_bkpf_data.
PERFORM download_to_sap.
*& Form get_bkpf_data
This subroutine used to fetches data from bkpf *
There are no interface parameters to be passed to this subroutine. *
FORM get_bkpf_data .
SELECT bukrs " Company code
belnr " Accounting document number
gjahr " Fiscal Year
blart " Document type
bldat " Document date in document
FROM bkpf
INTO TABLE t_bkpf
WHERE bukrs = p_bukrs
AND gjahr = p_gjahr .
ENDFORM. " get_bkpf_data
*& Form download_to_sap
This subroutine used to download file on application server *
There are no interface parameters to be passed to this subroutine. *
FORM download_to_sap .
OPEN DATASET w_file " Opening the file
FOR OUTPUT IN TEXT MODE
ENCODING DEFAULT.
LOOP AT t_bkpf INTO fs_bkpf.
TRANSFER fs_bkpf TO w_file.
ENDLOOP. " Loop at t_bkpf INTO fs_bkpf
CLOSE DATASET w_file. " Closing the file
ENDFORM.
Similar Messages
-
Create a Document with an original file stored on application server
Hello,
I start with document managment system : i am able to create new document (CV01N) manually, add a local file and check-in this file.
Now we need to store file which are stored on the SAP Application Server.
Firstly, in the GUI of transaction CV01N, i don't know how to browse file on application server. All files i can't attach as original, are files i can access from my computer.
Is it possible to access also on application server files ?
Moreover, i have to define function module which have to
- Create a document (DMS)
- Attach an orginial file which is stored on application server
- Check-in the file
This function module will be called from a web application
I define this kind of function and run it correctly with a local file (stored on my computer) : i call BAPI "BAPI_DOCUMENT_CREATE2" and "BAPI_DOCUMENT_CHECKIN2"
But i don't how to do with a file stored on application server. I see also note 504692 and try a program like ZZUZTEST_TEST_CHECKIN which use FM CVAPI_DOC_CHECKIN but it return an error Error uploading E:\usr\sap\TD1\DVEBMGS00\data\FACTURE.txt" (this path and file exist on application server and is really the file i want to checkin)
Please could you confirm what i search, is possible or not.
If possible, could help me with some explanations and guidelines and perhaps a sample ?
Thank you very much.
Regards,
Eric
The function used
FUNCTION Z_TEST_CHECKIN.
Checkin the first original of a document info record *
from the application server and/or in the background *
data : w_host like BAPI_DOC_AUX-HOSTNAME.
data: lf_line(255).
data: ls_draw like DRAW,
ls_message_cvapi like messages,
lt_files_cvapi type standard table of CVAPI_DOC_FILE,
lt_files_cvapi_header like CVAPI_DOC_FILE.
data: lt_originals LIKE cvapi_doc_file OCCURS 0 WITH HEADER LINE,
vo_originals LIKE cvapi_doc_file OCCURS 0 WITH HEADER LINE.
ls_draw-dokar = 'ZFT'.
ls_Draw-doknr = '0000000000000004500000032'.
ls_Draw-dokvr = '00'.
ls_Draw-doktl = '000'.
Read Originals contained in the document info record
CALL FUNCTION 'CVAPI_DOC_GETDETAIL'
EXPORTING
pf_batchmode = 'X'
pf_hostname = ' '
pf_dokar = ls_draw-dokar
pf_doknr = ls_draw-doknr
pf_dokvr = ls_draw-dokvr
pf_doktl = ls_draw-doktl
pf_active_files = 'X'
IMPORTING
psx_draw = ls_draw
TABLES
pt_files = vo_originals
EXCEPTIONS
not_found = 1
no_auth = 2
error = 3
OTHERS = 4.
IF sy-subrc <> 0.
WRITE 'Error returned by CVAPI_DOC_GETDETAIL'. "#EC NOTEXT
EXIT.
ENDIF.
Check if we can really access the file from the application server
read table vo_originals index 1.
open dataset vo_originals-filename for input in text mode ENCODING DEFAULT.
if not sy-subrc is initial.
message e500(26) with vo_originals-filename 'not found'.
endif.
read dataset vo_originals-filename into lf_line.
if not sy-subrc is initial.
message e500(26) with vo_originals-filename 'read error'.
endif.
lt_originals = vo_originals.
lt_originals-STORAGE_CAT = 'SAP-SYSTEM'.
append lt_originals.
w_host = sy-host.
CALL FUNCTION 'CVAPI_DOC_CHECKIN'
EXPORTING
PF_DOKAR = ls_draw-dokar
PF_DOKNR = ls_draw-doknr
PF_DOKVR = ls_draw-dokvr
PF_DOKTL = ls_draw-doktl
PS_DOC_STATUS =
PF_FTP_DEST = 'SAPFTPA'
PF_HTTP_DEST = 'SAPHTTPA'
*PF_HOSTNAME = w_host
PS_API_CONTROL =
PF_REPLACE = ' '
PF_CONTENT_PROVIDE = 'SRV'
IMPORTING
PSX_MESSAGE = ls_message_cvapi
TABLES
PT_FILES_X = lt_originals
PT_COMP_X =
PT_CONTENT =
IF ls_message_cvapi-msg_type CA 'EA'.
ROLLBACK WORK.
MESSAGE ID '26' TYPE 'I' NUMBER '000'
WITH ls_message_cvapi-msg_txt.
ELSE.
COMMIT WORK and wait.
ENDIF.
ENDFUNCTION.This is a bit tricky. I spent lots of hours about this .
You have to set PF_HOSTNAME with your name of your AS and gives the path to the file on the server.
You wrote
*PF_HOSTNAME = w_host
But beware: if you have more thän one AS you have to fix one AS for upload or you have to find the servers name of the file. A better way can be to share one folder by each AS.
You also have to decide between HTTP or FTP.
You wrote:
PF_FTP_DEST = 'SAPFTPA'
PF_HTTP_DEST = 'SAPHTTPA'
You must define only one ! Then you have to check your settings in SM59 about working right.
Pls rate, if this was helpful.
Regards,
Markus -
Files are stored in application server,
Files are stored in application server, I am using Open dataset to write to a file in unix box.would like to convert my itab into tab delimted and download. Please let know
is there any function?You should do a search to get the right ascii value (you can get an
ascii chart, you can google a bit, you can visit the group's page and
search for tab delimited... ) and replace 09 by the right value. And
that's it.. The technique (which is what it matters) is right.
Another tip:: you could download in two steps: first you use
gui_download or ws_download to create a tab delimited file in your pc or
in a network. Then you upload this file (using gui_upload or ws_upload
into an internal table and the final step is to use open dataset -
transfer - close dataset to write down this last itab to your app
server. -
How i access file which stored at application server .? Is there any fm ?
Hi,
How i access file which stored at application server . Is there any function module which provide same funtinality.
Regards,
Gurprit BhatiaHi ,
U need to use datasets for reading data from application server.Do a f1 on dataset,u will get to know rest of the things.
TRY.
OPEN DATASET file FOR INPUT IN TEXT MODE ENCODING UTF-8.
ENDTRY.
IF sy-subrc = 0.
READ DATASET file INTO <wa_data> MAXIMUM LENGTH 200.
move the data in to internal table
close dataset
Edited by: A kumar on Aug 21, 2008 1:37 PM -
Pdf file in txt format in application server
Hi all,
can we use open datset to store pdf file in text format in application server.
when i am using this some data was getting correctly stored in appl server.but some data is getting converted to # symbols.of course the pdf data also contains some different characters in that place.
but i want that pdf data in that format,i dont want that change of # symbols...how can i do that...
and while storing it,it is allowing only open dataset in binary mode only ..can anybody explain why?
regards,
sharma.<b>Check this example....</b>
report ztest.
data: begin of itab occurs 0,
field(256),
end of itab.
data: dsn(100) value '/usr/sap/xfr/FIS/testpdf',
length like sy-tabix,
lengthn like sy-tabix.
call function 'GUI_UPLOAD'
exporting
filename = 'c:\temp\test.pdf'
filetype = 'BIN'
importing
filelength = length
tables
data_tab = itab.
open dataset dsn for output in binary mode.
loop at itab.
transfer itab-field to dsn.
endloop.
close dataset dsn.
clear itab.
refresh itab.
*- To crosscheck if it went well
open dataset dsn for input in binary mode.
do.
read dataset dsn into itab-field.
if sy-subrc = 0.
append itab.
else.
exit.
endif.
enddo.
call function 'GUI_DOWNLOAD'
exporting
filename = 'c:\temp\testn.pdf'
filetype = 'BIN'
bin_filesize = length
importing
filelength = lengthn
tables
data_tab = itab.
<b>TIP</b>
Use the TCode
CG3Z or CG3Y
for downloading to Application Server.
Regards,
Pavan -
Deploying a war file in Oracle Apps's application server
Hi all, i have a war file which i want to deploy inside oracle apps's application server, i just want to know the location to put my war file in so that the application server will auto deploy it.And also provide port and url(Application server) where i can access that web app.
Babu,
There are a lot of dependencies involved. app severes before 10g are not generic j2ee server. what kind of files are you putting in ur war file?
--Shiv -
DART: Could not open file c:\datafile.txt on application server
We are running data extracts on DART (t-code FTW1A).
However we get error:
Could not open file c:\datafile.txt on application server ####.
We verified that c:\datafile is existing and accessible.
Please help tell why? Pints guaranteed. Thanks!Hi,
Are you able to see the file from AL11 or using report RSWATCH0. Also please check below thread it may help you.
File not created in application server
Thanks,
Sushil -
How to change the excel file name which is in Application server...
hi friends,
my requirement is getting failed, when i'm trying to change the file name which is in Application server using the FM: SXPG_COMMAND_EXECUTE.
when i execute above FM, i can see all my required details in SM69 like:
COMMAND NAME: ZSPOOL_TEST1
OS: Windows NT
TYPE: Customer
OS COMMAND: cmd rename Y:\OBRZ.PDF OBRZ38582.PDF
once the above FM is executed, i'm getting SY-SUBRC = 2 (exception: COMMAND_NOT_FOUND).
so, can any one guide me how to resolve this issue or is there any other way to rename the file which is in AS?
thanks in advance...Hi ,
First you can tranfer the AS server file to a new application server file.
Then you delete the original file .
To do that you can write code as follows --
DATA : w_file(8) TYPE c VALUE 'FILE_NAM', " your present AS file name
w_new(8) TYPE c VALUE 'NEW_FILE',
fs_itab(255) TYPE c,
t_itab LIKE TABLE OF fs_itab.
OPEN DATASET w_file FOR OUTPUT IN BINARY MODE.
DO.
READ DATASET w_file INTO fs_itab. " Reading value from the AS file to field string
IF sy-subrc NE 0.
EXIT.
ELSE.
APPEND fs_itab TO t_itab. " Populating internal table form the file value
ENDIF.
ENDDO.
OPEN DATASET w_new FOR INPUT IN BINARY MODE. " creating a new file if that does not exist
LOOP AT t_itab INTO fs_itab.
TRANSFER fs_itab TO w_new. " Transfering to file
ENDLOOP.
CLOSE DATASET w_file..
DELETE DATASET w_file. " Dleting the old file
CLOSE DATASET w_new. " Closing the final file
Regards
Pinaki -
How to run a "exe" file that is residing in application server.
Hi,
I have a requirement in which a .exe (Windows executive) file needs to be run through code, which is residing in the application server. That exe file is nothing but a pdf-excel converter that will convert a pdf file to excel. The corresponding pdf file is also in the application server. Is there any function module to make this happen? I have come across the FM GUI_EXEC, but it operates on exe and pdf files that are in the presentation server.HI Anirban
SM49 /SM69 might be of help
Could you please look into the link below.
Re: sm49/sm69 -
How to check if the file already exists in the application server directory
Hi all. I'm on devsuite 10g.
I transfer file from local machine to application server using webutil function webutil_file_transfer.client_to_as and I want to check if the file I'm transfering already exists on the server directory.
How can I make this?
Thanks all,
Fabriziouse the text_io package and open the file in read-mode.
like this
declare
xFileType text_io.file_type;
begin
xFileType := text_io.fopen('c:\temp\test.txt','R'); --file on the middle tier
-- file exists;
text_io.fclose(xFileType);
exception
when others then
--file doesn't exist
end;
regards
Christian -
FM to select the file path for download into application server
Hello,
I need a FM to select the file path for download into application server. It is a F4 help .
Its functionality should be simmilar to the one used for presentation server i.e. as fol
CALL METHOD cl_gui_frontend_services=>file_save_dialogHello,
What about F4_DXFILENAME_TOPRECURSION? You can check other FMs of the group DX_FILE.
BR,
Suhas
PS: I think these FMs are not released by SAP, so need to be cautious while using these -
How to find that which flat file is belongs to which application server?
How to find that which flat file is belongs to which application server?
Hi,
Search im www.sap-img.com, you will get most of answers.
Jogdand M B -
Transfer file from UNIX to windows application server G:\ drive
Dear Expert,
Really need some help on this, very urgent !
The download program schedule in background to allow file store in unix.
Can we do a unix command in abap program to transfer the file from unix to windows application server G:\ drive.
The gateway for that application server is ukblmqg02.emea.astrazeneca.net .
Anyone have the sample source code ?
Thanks®ards
NislinaHi,
1.
There is a FM 'ARCHIVFILE_SERVER_TO_CLIENT'.
If the requirement need not necessarily require a FM to transfer a file, then you can also use transaction 'CG3Y' to transfer a file
from application server to presentation server.
2.
Try to use FM DOCFILE_SERVER_TO_CLIENT. I am using it to download a file from SAP application server to desktop.
Source path should be application server file path along with file name i.e. /tmp/sample.xls.
Target path should be something like c:\file.xls.
Best regards,
Prashant -
Opening a file stored at application server
Experts,
I have put a document on application server using DATASET .
Now I want to open the same file from there only.
ho to do that.
Thnx in Advance
ChetanHi Chetan ,
U can use following code to open the file u created in application server.
1.
data: <dataset_name>(25) value '.\tmp\file_sarang_01.txt'.
open dataset <dataset_name> for input in text mode encoding UTF-8
read dataset <dataset_name> into itab_wa.
Append itab_wa to itab.
close dataset <dataset_name>
loop at itab.
write: itab-field1 , itab-field2 .
endloop.
2. U can use transaction CG3Y , to save file from application server to presentation server directly.(A short cut for u)
I hope this solves ur problem
Reagrds.
Note: Reward if useful -
Download PDF File from Archiv to SAP Application Server
Hi,
I need to download the PDF file from an NAST-Dataset (how is stored from the message via SAP ArchivLink) to the SAP Application Server.
1) At first i read the Archiv-Link data via function module WFMC_GET_ARCHIVE_OBJECT_TYPE
2) Then i get the Connection-Infos via function module ARCHIV_GET_CONNECTIONS_INT
3) Now i read the file from archiv as table via function module ARCHIVOBJECT_GET_BYTES
4) Save to the SAP Appl.Server via:
- OPEN DATASET ld_dpfad FOR OUTPUT IN BINARY MODE
- LOOP and TRANSFER lf_archivobject TO ld_dpfad.
- CLOSE DATASET ld_dpfad.
In the dialog of NAST-Dataset (Messages) i can open the PDF-File without any errors (display originals). But after the filetransfer to the SAP Appl.Server i get the following errors during the file opening dialog from Adobe Acrobat Reader:
- the embedded font u201CArialu201D cant to be extract
- not enough data for the picture
The reader can display the PDF-File but only without the picture (Logo) and with alternative font.
The same transfer from archiv and sending as an attachement to the BOR-Object via function module SO_DOCUMENT_INSERT_API1 works very fine and without any errors.
Can any one please help me to solve this Issue?
Thanks in Advance,
ThomasHello Keith,
Many thanks for your answer.
In the past i didnu2019t need the BINARCHIVOBJECT-Parameter and so i overlook this option.
Now, the File looks a little bit different, but only in the STREAM-section.
During the Fileopen-Dialog i get only one message now - "not enough data for image" and the image will not displayed. The rest seems to be correct.
The relevant coding is now:
ld_doc_typ = pf_connections-reserve.
CALL FUNCTION 'ARCHIVOBJECT_GET_BYTES'
EXPORTING
archiv_id = pf_connections-archiv_id
archiv_doc_id = pf_connections-arc_doc_id
document_type = ld_doc_typ
length = ld_length1
offset = ld_offset
IMPORTING
binlength = ld_length
offset = ld_offset
TABLES
binarchivobject = lt_binarchivobj
EXCEPTIONS
error_archiv = 1
error_communicationtable = 2
error_kernel = 3
OTHERS = 4.
Zieldatei zum Schreiben öffnen
OPEN DATASET ld_dpfad FOR OUTPUT IN BINARY MODE.
Inhalte in Zieldatei schreiben
LOOP AT lt_binarchivobj INTO lf_binarchivobj.
TRANSFER lf_binarchivobj TO ld_dpfad NO END OF LINE.
ENDLOOP.
Zieldatei schließen
CLOSE DATASET ld_dpfad.
Where is the error for the image data?
Ciao Thomas
Push up by: Thomas Engler on May 3, 2010 4:54 PM
Maybe you are looking for
-
How do I change my Itunes account to a new one
How do I change my itunes account to a new id account
-
How can i remove old device's from My Support Profile. When i try to remove a device, then i see this. We're sorry............................ It is not possible te remove. Any one with a fix for this. Thanks.
-
I have an aluminium MacBook and have just connected an external Samsung HD monitor. The image is blurry and I cannot seem to fix it. The MacBook display is 1280x800 but the maximum for the external monitor is much higher. Also the external monitor so
-
Hi All, output XML of my XSL Transformation has strange errors. First of all, the xmlns attribute is not in the root tag, but in the child element. Second problem is, that all information is listet after the root tag again: XML output: <?xml version=
-
When does a sticky entry get removed on CSM
I have one sticky group for multiple vservers and within each vserver is a different serverfarm with the same IPs but each server farm has a different probe. Now if you look in the sticky table there will be only once entry if my sticky is by sourc