‎2006 Mar 26 3:21 PM
Hello !
I want to upload file with data <u>from the presentation server</u> into an Internal Table
(in my abap program).
I can't use 'gui_upload' function - because My
program ran in background.
Also - can't use 'upload' and 'ws_upload' functions
because they are obselete. (in ECC5)
What function can I use to upload the file in
background processing ?
Thanks ,
N.S.
‎2006 Mar 27 4:29 AM
Hi,
First upload your file using CG3Z transaction.
Then use the following code to read the file from application server.
CALL FUNCTION 'FILE_GET_NAME'
EXPORTING
LOGICAL_FILENAME = P_INFILE
IMPORTING
FILE_NAME = INPUTFILE
EXCEPTIONS
FILE_NOT_FOUND = 1
OTHERS = 2.
IF SY-SUBRC NE 0.
MESSAGE E899 WITH text-064 P_INFILE text-065.
ENDIF.
Open the inputfile for reading in text mode
OPEN DATASET INPUTFILE FOR INPUT IN TEXT MODE.
IF SY-SUBRC NE 0.
MESSAGE E899 WITH text-066 INPUTFILE text-067.
ENDIF.
DO.
READ DATASET INPUTFILE INTO TEXT2 . "LENGTH LENG.
MOVE TEXT2 TO I_MATCONV.
APPEND I_MATCONV.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET INPUTFILE.
Regards,
Gayathri
‎2006 Mar 26 3:24 PM
Hi Nitzan,
You can use ABAP command <b>OPEN DATASET <dsn> [FOR ....] [IN ... MODE] AT POSITION <pos></b>.
And check this link for sample code.
http://www.sapgenie.com/abap/code/abap6.htm
Hope this will help.
Regards,
Ferry Lianto
‎2006 Mar 26 3:44 PM
Hi,
You will first have to put the frontend file onto the Application server before using the OPEN DATASET statement in your program. For that you can use the Transaction CG3Z.
Regards,
Suresh Datti
‎2006 Mar 27 4:29 AM
Hi,
First upload your file using CG3Z transaction.
Then use the following code to read the file from application server.
CALL FUNCTION 'FILE_GET_NAME'
EXPORTING
LOGICAL_FILENAME = P_INFILE
IMPORTING
FILE_NAME = INPUTFILE
EXCEPTIONS
FILE_NOT_FOUND = 1
OTHERS = 2.
IF SY-SUBRC NE 0.
MESSAGE E899 WITH text-064 P_INFILE text-065.
ENDIF.
Open the inputfile for reading in text mode
OPEN DATASET INPUTFILE FOR INPUT IN TEXT MODE.
IF SY-SUBRC NE 0.
MESSAGE E899 WITH text-066 INPUTFILE text-067.
ENDIF.
DO.
READ DATASET INPUTFILE INTO TEXT2 . "LENGTH LENG.
MOVE TEXT2 TO I_MATCONV.
APPEND I_MATCONV.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET INPUTFILE.
Regards,
Gayathri
‎2006 Mar 27 5:57 AM
Hi,
As Suggested,use CG3Z transaction to put the file into application server.
Then use the following sample code,to read the file from there to internal table.
data : G_AFILE1(100) TYPE C,
G_DATA(1000) TYPE C,
G_DELIM TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
DATA: BEGIN OF T_INPUT OCCURS 0, " Flat file data
PERNR(9) TYPE C,
AMOUNT(15) TYPE C,
W_TYPE(5) TYPE C,
END OF T_INPUT.
OPEN DATASET G_AFILE1 FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC = 0.
DO.
READ DATASET G_AFILE1 INTO G_DATA.
IF SY-SUBRC = 0.
SPLIT G_DATA AT G_DELIM INTO T_INPUT-PERNR T_INPUT-AMOUNT T_INPUT-W_TYPE .
IF SY-SUBRC = 0.
APPEND T_INPUT.
CLEAR T_INPUT.
ELSE.
"Message:Incorrect data format in file
ENDIF.
ELSE.
EXIT. "After reading last Record
ENDIF.
ENDDO.
ELSE.
"Message:File Opening Error
ENDIF.
‎2006 Mar 27 6:20 AM
Hi,
<a href="http://www.sap-img.com/ab004.htm">http://www.sap-img.com/ab004.htm</a>
hope this link is useful..
regards,
chithra
‎2006 Mar 27 8:36 AM