2009 Mar 03 8:16 AM
Hi,
How 2 upload CSV file in Background, if the Flat file is input .
regrds
2009 Mar 03 8:23 AM
as GUI_* and WS_* function modules do not work in background
When scheduling a job in the background the appropriate statement to read in your file is OPEN DATASET, and the file must be on the file system that the SAP server can see.
At anytime, a user can switch of the Personal Computers even though the job is still running in the background. Therefore GUI_* and WS_* function modules are not designed to work in that way, as they need to access your personal computer file.
To choose the correct download method to used, you can check the value of SY-BATCH in your code,
if it is 'X' use OPEN DATASET and if it is ' ' use WS_UPLOAD.
*-- Open dataset for reading
DATA:
dsn(20) VALUE '/usr/test.dat',
rec(80).
OPEN DATASET dsn FOR INPUT IN TEXT MODE.
IF sy-subrc = 0.
DO.
READ DATASET dsn INTO rec.
IF sy-subrc <> 0.
EXIT.
ELSE.
WRITE / rec.
ENDIF.
ENDDO.
ENDIF.
CLOSE DATASET dsn.
*-- Open dataset for writing
DATA rec(80).
OPEN DATASET dsn FOR OUTPUT IN TEXT MODE.
TRANSFER rec TO '/usr/test.dat'.
CLOSE DATASET dsn.
Hope this will solve your problem.
Regards.
Rajnesh
Edited by: Rajnesh Dharmat on Mar 3, 2009 1:53 PM
Hi,
How 2 upload CSV file in Background, if the Flat file is input .
regrds
2009 Mar 03 8:23 AM
as GUI_* and WS_* function modules do not work in background
When scheduling a job in the background the appropriate statement to read in your file is OPEN DATASET, and the file must be on the file system that the SAP server can see.
At anytime, a user can switch of the Personal Computers even though the job is still running in the background. Therefore GUI_* and WS_* function modules are not designed to work in that way, as they need to access your personal computer file.
To choose the correct download method to used, you can check the value of SY-BATCH in your code,
if it is 'X' use OPEN DATASET and if it is ' ' use WS_UPLOAD.
*-- Open dataset for reading
DATA:
dsn(20) VALUE '/usr/test.dat',
rec(80).
OPEN DATASET dsn FOR INPUT IN TEXT MODE.
IF sy-subrc = 0.
DO.
READ DATASET dsn INTO rec.
IF sy-subrc <> 0.
EXIT.
ELSE.
WRITE / rec.
ENDIF.
ENDDO.
ENDIF.
CLOSE DATASET dsn.
*-- Open dataset for writing
DATA rec(80).
OPEN DATASET dsn FOR OUTPUT IN TEXT MODE.
TRANSFER rec TO '/usr/test.dat'.
CLOSE DATASET dsn.
Hope this will solve your problem.
Regards.
Rajnesh
Edited by: Rajnesh Dharmat on Mar 3, 2009 1:53 PM
2009 Mar 03 8:54 AM
hi,
you have to call it from Applications server using OPEN DATASET and CLOSE DATASET.
GUI_UPLOAD in background wont work.
thanks
2009 Mar 03 9:38 AM
Hi,
Try like this....
lv_filename = <input file path>
open dataset lv_filename for input in text mode encoding default.
if sy-subrc = 0.
do.
read dataset lv_filename into gs_input-wa_string.
if sy-subrc eq 0.
append gs_input to gt_input.
else.
exit.
endif.
enddo.
close dataset lv_filename.
endif.
Hope its helps
2009 Mar 04 3:56 AM
Hi All,
Thanks for the reply,
our system is as follows,
The user logins to the portal and enters the data to the screen and submits,
The UI people turns it to a csv file and sends it to my RFC
so can I follow above procedure.... and is it the only procedure....?
Regards
2009 Mar 04 4:23 AM
if your RFC places the file in Application server.. you can use open dataset statement and get data to internal table by using split at comma....
key words to search Open dataset CSV application server file
| User | Count |
|---|---|
| 6 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |