2006 Sep 04 1:36 PM
Hi experts,
pls look into the following code:
types: begin of it_ktab,
str type string,
end of it_ktab.
data: it_jtab type table of it_ktab.
data: it_jtab_size_length type i.
data: p_file type string.
p_file = 'C:\config.sys'.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
EXPORTING
FILENAME = p_file
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
HEADER_LENGTH = 0
DAT_MODE = SPACE
CODEPAGE = SPACE
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
READ_BY_LINE = 'X'
IMPORTING
FILELENGTH = it_jtab_size_length
HEADER =
CHANGING
DATA_TAB = it_jtab
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
NOT_SUPPORTED_BY_GUI = 17
ERROR_NO_GUI = 18
others = 19
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
data: wa like line of it_jtab.
if sy-batch EQ 'X'.
loop at it_jtab into wa.
write:/ wa-str.
endloop.
ENDIF.
WRITE:/ 'SY-BATCH IS', SY-BATCH
So when i run this program in back groung ,in SM37 the status of job is finished.But it is not generatng spool.
That menas it is not shoing o/p of wa_str.
But when i comment that write:/ wa_str,and run in back ground,then it is generating spool and showing o/p of
WRITE:/ 'SY-BATCH IS', SY-BATCH.
Can any body tell me what may be the problem?
2006 Sep 04 1:57 PM
Hi Ravi,
GUI_UPLOAD doesn't work in background mode.
Cheers
-Pramod
2006 Sep 04 1:42 PM
Hello Ravi,
In background job I don't think ur upload is working because of which the internal table is empty and so write wa-str is not getting executed.
Try writing the sy-subrc after upload in FM. U may get the clue.
2006 Sep 04 1:53 PM
This FM will throw you sy-subrc 4. As this will not be applicable for running in background.
Handles the exceptions of FM, which will help you know the reason behind.
Currently this internal tbale is empty.
Regds
Manohar
2006 Sep 04 2:03 PM
Hi all,
Thank you for ur replies.
So my requirement is that that program has to run in background.So can any body tell me how can we achieve this?
2006 Sep 04 2:10 PM
Hi,
if your program has to run in background,the only option to read the contents of the file is using DATASET.
keep the file on the application server and use 'OPEN DATASET' functionality to read the file contents into an internal table.
Regards
Appana
2006 Sep 04 3:00 PM
Hi All,
Thanks for your replies.
Ok. As you told i will put the file in Application server.
and i will read into internal table.So in my requirement this internal table contains some path where original files are stored.So i have to give this path name agin in GUI_UPLOAD fm.So all this process should run in back ground.
is it possible?wil it work?
2006 Sep 04 3:22 PM
No. If you have a requirement of running this program in background, you should always work with datasets. GUI_UPLOAD will not work in background.
Regds
Manohar
2006 Sep 04 1:57 PM
Hi Ravi,
GUI_UPLOAD doesn't work in background mode.
Cheers
-Pramod
2006 Sep 04 3:57 PM
Hi,
It can be done another way, Just create select-option in the screen which invisible, and at selection-screen just call this Upload function module/Static method., need use flag logic
In Selction-Screen:
Checkbox: Background Option, Parameter for Job Name
At selection-Screen:
Call Upload FM/Static Method call
Flag = Background Check.
Upload data should be loaded into Select-Option which invisble
In start-of-selection
Call FM Job_open
Call FM Get_PRINT_PARAMETERS
SuBmit Report with parameters BAckground = Space
Invisible select-option = invisible select_option
TO SAP-SPOOL
SPOOL PARAMETERS <Var/Struc>
WITHOUT SPOOL DYNPRO
USER <var>
VIA JOB <JoB Name> NUMBER < Job Number> AND RETURN.
call FM Job_close
Give me Points if you find it is useful to you
Thanks