Önceki Sayfa

GUI_* WS_* Function In Background, CSV Upload

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.

What is the difference when we use upload, ws_upload, gui_upload function modules?

UPLOAD, WS_UPLOAD, GUI_UPLOAD, are used in BDC concepts.  ie., Batch Data Communication.
Batch Data Conversion is a concept where user can transfer the Data from non SAP to SAP R/3.  So , in these various Function Modules are used.

UPLOAD---  upload a file to the presentation server (PC)
WS_UPLOAD----    Load Files from the Presentation Server to Internal ABAP Tables.
WS means Work Station.
This is used upto SAP 4.6 version.

GUI_UPLOAD-------    Replaces WS_UPLOAD. Upoad file from presentation server to the app server.  From 4.7 SAP version it is replaced.

How to Upload csv file to SAP?

Common File Download Upload Questions:

How  you upload the data from text file to sap internal table?  From my knowledge its by upload or gui_upload.
How you download the data from sap internal table to text file?
How  you upload the data from xls (excel) file to sap internal table how you download the data from sap internal table to xls(excel) file.

You can upload data from presentation server to an internal table using gui_upload. Use gui_download to download from internal table to flat file.

Use fm ALSM_EXCEL_TO_INTERNAL_TABLE to upload data frm excel.

Use function module GUI_UPLOAD

The FILETYPE refer to the type of file format you need: For e.g 'WK1' - Excel format , 'ASC' - Text Format etc.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME                      = 'C:\test.csv'

FILETYPE                      = 'ASC'

TABLES

DATA_TAB                      = itab

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.

Copyright © 2010. KM Group. All Rights Reserved.