02-13-2009 10:19 AM
Dear experts..!
Please tell me what is the Function Module that is used for Uploading data from Application Server.
Thank you.
Regards,
Naveen
02-13-2009 10:22 AM
If you search in SCN you will get so many posts with these transactions,
CG3Z - upload
CG3Y - download
02-13-2009 10:22 AM
02-13-2009 10:22 AM
You can use
OPEN dataset command for uploading the data from Appln.server .
DATA FNAME(60) VALUE 'myfile'.
DATA: TEXT1(12) VALUE 'abcdefghijkl',
TEXT2(5),
LENG TYPE I.
OPEN DATASET FNAME FOR OUTPUT IN BINARY MODE.
TRANSFER TEXT1 TO FNAME.
CLOSE DATASET FNAME.
*" for Reading
OPEN DATASET FNAME FOR INPUT IN BINARY MODE.
DO.
READ DATASET FNAME INTO TEXT2 LENGTH LENG.
WRITE: / SY-SUBRC, TEXT2, LENG.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET FNAME.
.
http://help.sap.com/saphelp_nw04/helpdata/EN/fc/eb3d42358411d1829f0000e829fbfe/content.htm
02-13-2009 10:22 AM
Hi,
for upload use this FM
FILE_READ_AND_CONVERT_SAP_DATA
Thanks
Arun
Edited by: Arun Kayal on Feb 13, 2009 11:28 AM
02-13-2009 10:31 AM
Hi,
FILE_READ_AND_CONVERT_SAP_DATA Uploads the file from either presentation or application server into an internal table
SUBST_GET_FILE_LIST To get the list of files from Application Server.
data: fich like filename-fileintern.
data: begin of tab occurs 0,
agr_name like agr_1251-agr_name,
object like agr_1251-object,
field like agr_1251-field,
low like agr_1251-low,
high like agr_1251-high,
end of tab.
all function 'FILE_READ_AND_CONVERT_SAP_DATA'
exporting
i_filename = fich
i_servertyp = 'PRS'
i_fileformat = 'XLS'
I_FIELD_SEPERATOR =
i_line_header = 'X'
tables
i_tab_receiver = tab
exceptions
close_failed = 1
authorization_failed = 2
open_failed = 3
file_not_found = 4
conversion_failed = 5
others = 6.
Hope it helps u...
02-13-2009 10:32 AM
Hello Navin,
Please have a step-by-step glance of the following code snippet, it's to upload accounting data onto the application server, hope it helps you to understand the concept of uploading to application server.
*---------------------------------------------------------------------*
* Structure for Accounting Information *
*---------------------------------------------------------------------*
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. " BEGIN OF TYPE_S_BKPF
*---------------------------------------------------------------------*
* Field String for Accounting Information *
*---------------------------------------------------------------------*
DATA:
fs_bkpf TYPE type_s_bkpf.
*---------------------------------------------------------------------*
* Internal Table For Accounting Information *
*---------------------------------------------------------------------*
DATA:
t_bkpf LIKE
STANDARD TABLE
OF fs_bkpf.
*---------------------------------------------------------------------*
* Work Variables *
*---------------------------------------------------------------------*
DATA:
w_filename(50) TYPE c. " File Name
*---------------------------------------------------------------------*
* INITIALIZATION *
*---------------------------------------------------------------------*
INITIALIZATION.
SELECT-OPTIONS:
s_bukrs FOR fs_bkpf-bukrs, " Company Code
s_gjahr FOR fs_bkpf-gjahr. " Fiscal Year
PARAMETERS p_file(50) VISIBLE LENGTH 15.
" Name of File to be saved
*---------------------------------------------------------------------*
* START-OF-SELECTION *
*---------------------------------------------------------------------*
START-OF-SELECTION.
IF p_file IS INITIAL.
MESSAGE 'No File Selected' TYPE 'S' DISPLAY LIKE 'E'.
ELSE.
PERFORM get_accounts_data.
w_filename = p_file.
IF sy-dbcnt EQ 0.
MESSAGE 'No Records Found' TYPE 'S'.
ELSE.
PERFORM save_file.
ENDIF. " IF SY-DBCNT EQ 0
ENDIF. " IF P_FILE IS INITIAL
*&---------------------------------------------------------------------*
*& Form save_file
*&---------------------------------------------------------------------*
* This Subroutine saves File on Application Server.
*----------------------------------------------------------------------*
* This Subroutine has got no Interface Parameters.
*----------------------------------------------------------------------*
FORM save_file .
OPEN DATASET w_filename FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
LOOP AT t_bkpf INTO fs_bkpf.
TRANSFER fs_bkpf TO w_filename.
ENDLOOP. " LOOP AT T_BKPF INTO FS_BKPF
CLOSE DATASET w_filename.
IF sy-subrc NE 0.
MESSAGE 'Data Couldn't be uploaded' TYPE 'S'.
ELSE.
MESSAGE 'Data Successfully Uploaded' TYPE 'S'.
ENDIF. " IF SY-SUBRC NE 0
ENDFORM. " FORM SAVE_FILE
*&---------------------------------------------------------------------*
*& Form get_accounts_data
*&---------------------------------------------------------------------*
* This Subroutine gets Accounting Data.
*----------------------------------------------------------------------*
* This Subroutine has got no Interface Parameters.
*----------------------------------------------------------------------*
FORM get_accounts_data .
SELECT bukrs " Company Code
belnr " Accounting Document Number
gjahr " Fiscal Year
blart " Document Type
bldat " Document Date in Document
INTO TABLE t_bkpf
FROM bkpf
WHERE bukrs IN s_bukrs AND
gjahr IN s_gjahr.
ENDFORM. " FORM GET_ACCOUNTS_DATA
*----------------------------------------------------------------------*
*******************END OF PROGRAM***************************************
*----------------------------------------------------------------------*
Thanks: Zahack
02-13-2009 10:42 AM
02-13-2009 11:33 AM
Use function module
ARCHIVFILE_CLIENT_TO_SERVER
to upload a file from our presentation server(local pc) to application server location
if you want to upload in background use
open dataset method
02-17-2009 7:17 AM
Hi,
Use this FM
FILE_READ_AND_CONVERT_SAP_DATA
Uploads the file from either presentation or application server into an internal table
Regards
Kiran
02-17-2009 9:11 AM
Hi,
Check the below Function Modules
FILE_READ_AND_CONVERT_SAP_DATA
FILE_READ_AND_GET_TAB
ARCHIVFILE_CLIENT_TO_CLIENT
ARCHIVFILE_CLIENT_TO_SERVER
ARCHIVFILE_CLIENT_TO_TABLE
Regards,
Anki Reddy