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
Chetan
Hi 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
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 -
Hi,
I have downloaded a XML file to the application server.....
File is created but i am not able to open the file there....
Plz advice ....how to open it.....
Regards.Use Notepad. Drag and drop in notepad.
Aman -
Problem opening freehand files stored in linux server
hi,
i have mac and i work using a file server that has a linux.
The problem is that when i saved a freehand file, after cloosing
the program and reconect to the local server, i try to open the
file but freehand ask me for the images the the document has. Is
like freehand forget the links of the images or can't find it in a
linux server where they are when i create the file.
Anyone knows what can i do?
thanksYes, i know if we put the images in the same folder or i we
embedded de images in the document the problem doesn't ocurre, but
we used to work with the same image in lots of documents, like ads,
catalogues, flyers,... and we can't put each image in each folder
the disk quote will increase a lot. Moreover if we embedded the
images the document file will be higger and it's not good to send
it .
Thanks -
Junk chars in the file posted on application server
HI All,
I am posting a file on the application server using the OPEN DATASET, TRANSFER, CLOSE DATASET commands.
The file is posted successfully but it contains junk characters like # and some box kind of character. The file that has the data doesnot have these junk characters.
Help me resolve this problem.
Thanks in advance.this is my code...
Open the file in the application server
OPEN DATASET l_filename FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc = 0.
Convert workarea to string type
CALL METHOD CL_ABAP_CONTAINER_UTILITIES=>FILL_CONTAINER_C
EXPORTING
IM_VALUE = ls_jhak
IMPORTING
EX_CONTAINER = l_file
EXCEPTIONS
ILLEGAL_PARAMETER_TYPE = 1
OTHERS = 2.
Transfer the data fetched into the file
TRANSFER l_file TO l_filename.
ELSE.
RETURN.
ENDIF.
Close the file in the application server
CLOSE DATASET l_filename. -
Opening pdf files stored on server
Hi
We have an application in which we display pdf files stored on the server.
Pdf files opens in a new browser.
User selects the invoice number from a list and based on the invoice selected, we get a pdf file from R/3 system. This file is stored in a particular folder on the server. We extract this file from the folder to show it to the user in a separate browser.
This functionality works fine in the development system but not in test system.
We have recently installed our test system and have done all required settings in config tool.
Config Tool --> Display configuration --> HttpHttps --> Root and Alias folder.
But despite this the functionality is not working.
Is there some other setting that I have missed.
Unfortunately these settings were done in the dev system by someone else and I do not have a document for it.
Can anyone help me please.
This is very urgent for me as we are plannning to migrate our production system as well. I may face the same problem over there as well.
Regards
VineetHi,
We have the same requirement at our client end. Could you please guide me for the same?
Regards,
Sachin Mahajan -
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. -
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. -
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 -
Excel File downloaded from application server is also opening in notepad
Hi Friends,
While downlaoding an excel file from the application server,we are able to open in notepad also.But this does not conatin the excel properties and hence happening.File should only oopen with excel and no other file type
Can any open help on this
ld_file = '/usr/sap/trans/abap/HR_DATA.xls'.
OPEN DATASET ld_file FOR OUTPUT in text mode ENCODING DEFAULT .
IF sy-subrc = 0.
LOOP AT int_final.
CLEAR wa_string.
CONCATENATE int_final-employee_sno int_final-employee_code INTO wa_string SEPARATED BY con_tab.
CONCATENATE wa_string int_final-first_name INTO wa_string SEPARATED BY con_tab.
please help...
Edited by: Neliea on Oct 29, 2009 1:11 PMHi,
Please refer to these links.
[url]Re: Internal table to excel download?;url]
[url]Re: Transfer from Internal Table to EXCEL file...;url]
Regards,
Aditya -
Missing CRLF in file created on application server
Hello,
We have a requisite to create a file on the Application Server (AS/400) with CRLF at the end of every record. The records are stored in this structure:
- OUTPUT: CHAR655, text to export;
- LENGTH: NUMC4, length of the record (text to export).
To create the file I have the following code:
open dataset lv_filename
for output in text mode
encoding default
with windows linefeed.
loop at pt_output into ls_output.
try.
clear lv_length.
lv_length = ls_output-length.
transfer ls_output-output to lv_filename
length lv_length.
catch cx_root into gv_oref.
* TODO
endtry.
endloop.
I have two problems:
1º When I open the file in Notepad++ the records should have 500 caracters (lv_length = 500), but it has 502;
2º Only LF appears, not CRLF.
Can anyone help me please?
Regards.Hello,
Strangest thing, when I test it with 255 characters it works fine (CR+LF):
clear lv_string.
ls_output-output+254(1) = cl_abap_char_utilities=>cr_lf.
lv_string = ls_output-output+0(255).
transfer lv_string to lv_filename
length 255.
When I try with 256 characters it doesn't work, at the end of each record I can only find LF:
clear lv_string.
ls_output-output+255(1) = cl_abap_char_utilities=>cr_lf.
lv_string = ls_output-output+0(256).
transfer lv_string to lv_filename
length 256.
Don't understand why...
Regards. -
Default file path on application server ?
Can you tell me what is the file path of the file 'dataset' in the below code? I think it is stored in application server but not sure of the path. Is there any default path for such things?
Thank you very much!
report Z_test_BDC1
no standard page heading line-size 255.
include bdcrecx1.
parameters: dataset(132) lower case.
DO NOT CHANGE - the generated data section - DO NOT CHANGE ***
If it is nessesary to change the data section use the rules:
1.) Each definition of a field exists of two lines
2.) The first line shows exactly the comment
'* data element: ' followed with the data element
which describes the field.
If you don't have a data element use the
comment without a data element name
3.) The second line shows the fieldname of the
structure, the fieldname must consist of
a fieldname and optional the character '_' and
three numbers and the field length in brackets
4.) Each field must be type C.
Generated data section with specific formatting - DO NOT CHANGE ***
data: begin of record,
data element: KUN16
KUNNR_001(016),
data element: KTOKD
KTOKD_002(004),
data element: NAME1_GP
NAME1_003(035),
data element: SORTL
SORTL_004(010),
data element: ORT01_GP
ORT01_005(035),
data element: LAND1_GP
LAND1_006(003),
data element: SPRAS
SPRAS_007(002),
data element: PSTLZ
PSTLZ_008(010),
data element: LZONE
LZONE_009(010),
end of record.
End generated data section ***
start-of-selection.
perform open_dataset using dataset.
perform open_group.
do.
read dataset dataset into record.
if sy-subrc <> 0. exit. endif.
perform bdc_dynpro using 'SAPMF02D' '0107'.
perform bdc_field using 'BDC_CURSOR'
'RF02D-KTOKD'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RF02D-KUNNR'
record-KUNNR_001.
perform bdc_field using 'RF02D-KTOKD'
record-KTOKD_002.
perform bdc_dynpro using 'SAPMF02D' '0110'.
perform bdc_field using 'BDC_CURSOR'
'KNA1-SORTL'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'KNA1-NAME1'
record-NAME1_003.
perform bdc_field using 'KNA1-SORTL'
record-SORTL_004.
perform bdc_field using 'KNA1-ORT01'
record-ORT01_005.
perform bdc_field using 'KNA1-LAND1'
record-LAND1_006.
perform bdc_field using 'KNA1-SPRAS'
record-SPRAS_007.
perform bdc_field using 'KNA1-PSTLZ'
record-PSTLZ_008.
perform bdc_dynpro using 'SAPMF02D' '0120'.
perform bdc_field using 'BDC_CURSOR'
'KNA1-LZONE'.
perform bdc_field using 'BDC_OKCODE'
'=UPDA'.
perform bdc_field using 'KNA1-LZONE'
record-LZONE_009.
perform bdc_transaction using 'VD01'.
enddo.
perform close_group.
perform close_dataset using dataset.FORM OPEN_DATASET USING P_DATASET.
OPEN DATASET P_DATASET
FOR INPUT IN TEXT MODE
ENCODING DEFAULT.
IF SY-SUBRC <> 0.
WRITE: / TEXT-E00, SY-SUBRC.
STOP.
ENDIF.
ENDFORM.
Thanks Ashish. -
How do upload a file to the application server into a directory?
hi to all,
i want to upload file into the database..i need upload the file into the application server and save it to a directory..is there any way?where i can read about this?any information?
ashwinyHello,
First, we need to determine the terms we are using, in order to avoid confusion. We (including the documentation) are using "upload" to describe storing the file on the server, and "download" to pull it from the server into local machine.
You can use the "File Browse" item to upload any file you need from your local machine and into a database table. The default APEX configuration (in the dads.conf file) stored the uploaded file in a table called wwv_flow_file_objects$. In your application, you can access this table using a view called APEX_APPLICATION_FILES.
After you uploaded a file, any user can access it, using the download procedure described in the reference I gave you. The download procedure gives you an option to store the download file anywhere you need, using the "Open/Save" dialog box.
I believe this is covering everything you need. If you still having problems, please consider posting the relevant application pages on apex.oracle.com. It will be easier to understand and help you.
Regards,
Arie. -
How to see the file at the application server
HI TO ALL SDNERS ,
THIS IS MY CODE WHERE TO CHECK THE DOWNLOADED FILE AT THE APPLICATION SERVER.IN TCODE AL11 I HAVE SEEN THERE IS NO FILE GETTING CREATED.WHEN TRANSFERRING THE SY-SUBRC VALUE IS ZERO.
Program Name : ZME11_BDC.
Title : PURCHASE INFORMATION RECORD LOAD PROGRAM
Program Objective : THIS PROGRAM READS IN THE PURCHASE
INFORMATION FILE. IT CREATES A BDC SESSION TO
USE TO LOAD THE PURCHASE INFORMATION RECORDS
INTO SAP using the ME11 Transaction.
REPORT ZME11_BDC no standard page heading MESSAGE-ID ZHNC line-size 55.
constants declaration
constants: c_x value 'X',
c_sess type apqi-groupid value 'zcustomer',
c_xd01 type tstc-tcode value 'ME11'.
DECLARING VARIABLES
DATA: V_MSG(255),
V_ERREC TYPE I,"NO OF FAILED RECORDS
V_LINES."NO OF RECORDS
FLAG DECLARATIONS
DATA: FG_DATA_EXIST VALUE 'X',"CHECK FOR DATA
FG_SESSION_OPEN VALUE ''.
STRUCTURES AND INTERNAL TABLE DECLARATIONS
TYPES :BEGIN OF TY_PIR,
LIFNR TYPE EINA-LIFNR,
MATNR TYPE EINA-MATNR,
EKORG TYPE EINE-EKORG,
WERKS TYPE EINE-WERKS,
VERKF TYPE EINA-VERKF,"sales person
TELF1 TYPE EINA-TELF1,"telephone
URZLA TYPE EINA-URZLA,"country
REGIO TYPE EINA-REGIO,"region
APLFZ(5),"plan deleivery time
EKGRP TYPE EINE-EKGRP,"purchase group
NORBM(13),
NETPR(13),
END OF TY_PIR.
DATA : IT_PIR TYPE TABLE OF TY_PIR,
WA_PIR LIKE LINE OF IT_PIR.
DATA: BEGIN OF IT_BDCDATA.
INCLUDE STRUCTURE BDCDATA.
DATA END OF IT_BDCDATA.
DATA : BEGIN OF IT_BDCMSG.
INCLUDE STRUCTURE BDCMSGCOLL.
DATA END OF IT_BDCMSG.
SELECTION SCREEN
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETER : FNAME TYPE RLGRAP-FILENAME.
SELECTION-SCREEN END OF BLOCK B1.
AT SELECTION ON VALUE REQUEST
AT SELECTION-SCREEN ON VALUE-REQUEST FOR FNAME.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
IMPORTING
FILE_NAME = FNAME.
START OF SELECTION
START-OF-SELECTION.
PERFORM F_GET_DATA USING FNAME
CHANGING IT_PIR.
PERFORM F_GENERATE_DATASET USING FNAME
CHANGING IT_PIR WA_PIR.
*& Form F_GET_DATA
text
-->P_V_FNAME text
<--P_IT_PIR text
FORM F_GET_DATA USING P_FNAME LIKE FNAME
CHANGING P_IT_PIR LIKE IT_PIR.
DATA: LV_FILE TYPE STRING.
LV_FILE = FNAME.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = LV_FILE
FILETYPE = 'DAT'
HAS_FIELD_SEPARATOR = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
DATA_TAB = P_IT_PIR
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
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 P_IT_PIR IS INITIAL.
FG_DATA_EXIST = ''.
ENDIF.
ENDFORM. " F_GET_DATA
*& Form F_GENERATE_DATASET
text
-->P_V_FNAME text
<--P_IT_PIR text
FORM F_GENERATE_DATASET USING P_V_FNAME LIKE FNAME
CHANGING P_IT_PIR LIKE IT_PIR
P_WA_PIR LIKE WA_PIR.
MESSAGE I001(ZHNC).
*OPENING FILE AT THE APPLICATION SERVER FOR WRITING
OPEN DATASET FNAME FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC EQ 0.
MESSAGE I002(ZHNC).
LOOP AT P_IT_PIR INTO P_WA_PIR.
SPLIT P_WA_PIR AT '*' INTO P_WA_PIR-LIFNR
P_WA_PIR-MATNR
P_WA_PIR-EKORG
P_WA_PIR-WERKS
P_WA_PIR-VERKF
P_WA_PIR-TELF1
P_WA_PIR-URZLA
P_WA_PIR-REGIO
P_WA_PIR-APLFZ
P_WA_PIR-EKGRP
P_WA_PIR-NORBM.
*TRANSFER THE FILE FROM INTERNAL TABLE TO APPLICATION SERVER
MESSAGE I003(ZHNC).
TRANSFER P_WA_PIR TO FNAME.
ENDLOOP.
*CLOSING THE FILE AT THE APPLICATION SERVER
CLOSE DATASET FNAME.
ENDIF.Hello,
I made a similar program. You can have a look at it.
*& Form write_to_app_server
text
--> p1 text
<-- p2 text
FORM write_to_app_server.
To get filename
PERFORM get_filename.
To write into the application server
OPEN DATASET g_filename_with_path FOR OUTPUT IN TEXT MODE.
IF sy-subrc = 0.
LOOP AT <l_table> INTO <l_line>.
TRANSFER <l_line> TO g_filename_with_path.
ENDLOOP.
CLOSE DATASET g_filename_with_path.
ELSE.
CLOSE DATASET g_filename_with_path.
ENDIF.
To send mail
PERFORM send_mail.
ENDFORM. " write_to_app_server
*& Form get_filename
text
--> p1 text
<-- p2 text
FORM get_filename.
DATA : l_log_path TYPE filepath-pathintern
VALUE 'Y28M_DOWNLOADS_BACKGROUND' .
CALL FUNCTION 'FILE_GET_NAME_USING_PATH'
EXPORTING
client = sy-mandt
logical_path = l_log_path
operating_system = sy-opsys
file_name = p_fname
IMPORTING
file_name_with_path = g_filename_with_path
EXCEPTIONS
path_not_found = 1
missing_parameter = 2
operating_system_not_found = 3
file_system_not_found = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " get_filename
You may find it useful.
Regards,
Karuna. -
File from the Application server
Hi gurus,
I am working on a scenario where I need to get a file from the application server and for this I need to ask user to enter the location and that too at the selection screen and then I need to read this location using open data set and read data set in my program , once I am done with this I need to do some other validations. so can you please help me out how to achieve this.
Thanks
Rajeev GuptaHi
Declare the selection screen with file as parameter so that the user enter the application server file..
the use the OPEND DATASET as mentioned in below code and process
Refer this:
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3ca6358411d1829f0000e829fbfe/frameset.htm
ABAP code for uploading a TAB delimited file into an internal table. See code below for structures.
*& Report ZUPLOADTAB * &----
*& Example of Uploading tab delimited file *
REPORT zuploadtab .
PARAMETERS: p_infile LIKE rlgrap-filename
OBLIGATORY DEFAULT '/usr/sap/'..
DATA: ld_file LIKE rlgrap-filename.
*Internal tabe to store upload data
TYPES: BEGIN OF t_record,
name1 like pa0002-VORNA,
name2 like pa0002-name2,
age type i,
END OF t_record.
DATA: it_record TYPE STANDARD TABLE OF t_record INITIAL SIZE 0,
wa_record TYPE t_record.
*Text version of data table
TYPES: begin of t_uploadtxt,
name1(10) type c,
name2(15) type c,
age(5) type c,
end of t_uploadtxt.
DATA: wa_uploadtxt TYPE t_uploadtxt.
*String value to data in initially.
DATA: wa_string(255) type c.
constants: con_tab TYPE x VALUE '09'.
*If you have Unicode check active in program attributes then you will
*need to declare constants as follows:
*class cl_abap_char_utilities definition load.
*constants:
con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB.
*START-OF-SELECTION
START-OF-SELECTION.
ld_file = p_infile.
OPEN DATASET ld_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0.
ELSE.
DO.
CLEAR: wa_string, wa_uploadtxt.
READ DATASET ld_file INTO wa_string.
IF sy-subrc NE 0.
EXIT.
ELSE.
SPLIT wa_string AT con_tab INTO wa_uploadtxt-name1
wa_uploadtxt-name2
wa_uploadtxt-age.
MOVE-CORRESPONDING wa_uploadtxt TO wa_upload.
APPEND wa_upload TO it_record.
ENDIF.
ENDDO.
CLOSE DATASET ld_file.
ENDIF.
*END-OF-SELECTION
END-OF-SELECTION.
*!! Text data is now contained within the internal table IT_RECORD
Display report data for illustration purposes
loop at it_record into wa_record.
write:/ sy-vline,
(10) wa_record-name1, sy-vline,
(10) wa_record-name2, sy-vline,
(10) wa_record-age, sy-vline.
endloop.
Regards
Anji
Maybe you are looking for
-
Fixed size regions in Apex 4.0
It is possible to create a fixed size regiion - that is only using half of the screen height to have a report (and having a bar to on the right to move up/down) ? I'm going to use it for a 2+ master-detail report. regards Mette
-
I am going to NYC in a week and I'm wondering if there is a store where I can buy a new trackpad for my Macbook Pro 2011 unibody. I would also like to buy the tools i need to replace it myself. I can't find anything when I search the interwebz.
-
ALV Logo is not down loading to excel.
Hi All, when we are downloading the ALV output to excel logo is not appearing.. please tell me how to down load logo to excel file, Thanks in advance..
-
can somebody please help me fix this issue, i have been sitting at my computer all last night and this morning trying to figure it out. It could be the hardrive or anything really i just need to get it working. Alot of important things that need to b
-
I need to know how I can get my iPhone to work in South Africa. I used it in Australia and was told I could use it in SA...but now I am told the settings are different and therefor I cannot get the internet to work on my iphone. How can I get this wo