10-26-2006 4:41 PM
How can i make my report decide which method to use for file upload based on : whether it is run in foreground or background at run time ?
I tried using the sy-batch system variable like this :
if sy-batch = 0.
OPEN DATASET fname FOR INPUT IN TEXT MODE ENCODING DEFAULT.
WHILE SY-SUBRC = 0.
READ DATASET fname INTO i_holdT.
IF SY-SUBRC = 0.
append i_holdT TO I_HOLD.
ENDIF.
ENDWHILE.
CLOSE DATASET fname.
else.
call function 'GUI_UPLOAD'
exporting
filename = fname
filetype = 'ASC'
HAS_FIELD_SEPARATOR = ' '
header_length = 0
read_by_line = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
replacement = '#'
CHECK_BOM = ' '
VIRUS_SCAN_PROFILE =
IMPORTING
FILELENGTH =
HEADER =
tables
data_tab = i_hold
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.
endif.
But when i debug the code , while running in forground , the sy-batch has nothing in it ...!! and when run it in foreground it throws an exception of " CONV_NO_NUM".
If anyone has sample code or idea how to ahcieve this , pls help !
Thanks
10-26-2006 4:44 PM
Hi,
You should check SY-BATCH = 'X' for background..and not SY-BATCH = 0..
Thanks,
Naren
10-26-2006 4:44 PM
Hi,
You should check SY-BATCH = 'X' for background..and not SY-BATCH = 0..
Thanks,
Naren
10-26-2006 4:49 PM
The valid values for Sy-batch are X and space.
sy-batch = 'X' mean running in background and space means foreground.
Regards,
ravi