2010 Nov 12 9:34 AM
Moderator message: background/foreground/GUI problems = FAQ, please search before posting.
Hi All,
I have a program which is not working in background.It actuly takes the file and using GUI_upload i upload it into ITAb and then modify the database table based on this. But when i process this in foreground it working and updating the table.But when i scedule in background the job is getting over in 1-2 sec and not updating the table.
Please help me. below is the code for your refrence:
data:begin of i_tab occurs 0,
Bp1 like DATAbase table,
Bp2 like database table,
trf1 type string,
trf2 type string,
status type string,
end of i_tab.
*
data: BP_ver type STANDARD TABLE OF DATAbase table with header line ,
w_ver type ZVERS_BUT050_CUR .
DATA: it_tab type filetable,
gd_subrc TYPE i,
file_name TYPE string,
path TYPE string.
DATA : lw_file TYPE file_table.
DATA: LIN TYPE I.
&----
*Input File
SELECTION-SCREEN begin of block blk with frame title text-100.
SELECTION-SCREEN SKIP 2.
parameters : p_file like rlgrap-filename .
SELECTION-SCREEN end of block blk.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CLEAR: file_name.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = 'Select only Text File'
default_filename = '*.txt'
multiselection = ' '
CHANGING
file_table = it_tab
rc = gd_subrc.
READ TABLE it_tab INTO lw_file INDEX 1.
file_name = lw_file.
p_file = file_name.
&----
START-OF-SELECTION.
*Upload the file
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = FILE_NAME
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
TABLES
DATA_TAB = i_tab
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.
loop at i_tab.
if i_tab-status = 'Yes'.
i_tab-status = 'V'.
else.
i_tab-status = 'I'.
endif.
modify i_tab.
endloop.
&----
if i_tab is not INITIAL.
select * from DATAbase table into CORRESPONDING FIELDS OF TABLE BP_ver FOR ALL ENTRIES IN i_tab
where PARTNER1 = i_tab-Bp1 and PARTNER2 = i_tab-bp2 .
endif.
*Update the table
loop at BP_ver .
clear i_tab.
read TABLE i_tab with key bp1 = BP_ver-PARTNER1 bp2 = BP_ver-PARTNER2 .
if i_tab-bp1 = w_ver-PARTNER1 and i_tab-bp2 = w_ver-PARTNER2.
BP_ver-PARTNER1 = i_tab-bp1 .
BP_ver-PARTNER2 = i_tab-bp2 .
BP_ver-Z_CURRENTLY_VALI = i_tab-status .
modify BP_ver TRANSPORTING Z_CURRENTLY_VALI .
endif.
endloop.
update DATAbase table from table bp_ver[] .
&----
if sy-SUBRC eq 0.
commit work.
message 'Table DATAbase table Updated Sucsussfully' type 'S'.
else.
message 'Table Not Updated !!! Check the file data or input' type 'S'.
endif.
Edited by: Thomas Zloch on Nov 12, 2010 11:03 AM
2010 Nov 12 9:37 AM
Hi,
Look at the coding in FM GUI_UPLOAD ... This does not work in background ....
Batch mode is not supported
IF sy-batch = 'X'.
MESSAGE ID 'FES' TYPE 'E' NUMBER '002' RAISING NO_BATCH.
ENDIF.
Regards,
Srini.
Hi,
I don't think there is any way to upload data from desktop in back ground.
Regards,
Srini.
2010 Nov 12 9:37 AM
Hi,
Look at the coding in FM GUI_UPLOAD ... This does not work in background ....
Batch mode is not supported
IF sy-batch = 'X'.
MESSAGE ID 'FES' TYPE 'E' NUMBER '002' RAISING NO_BATCH.
ENDIF.
Regards,
Srini.
2010 Nov 12 9:40 AM
Hi ,
Thanks for the reply.
GUI_upload is not suported in batchmode then which FM we can use to upload in background.
Please help me your inputs are realy helping me.
Mahesh
2010 Nov 12 9:42 AM
As I said in my reply you need to put the file on the application server and then use the OPEN DATASET, READ DATSET and CLOSE DATASET commands to process the file.
2010 Nov 12 9:38 AM
You can't use GUI_UPLOAD in a background job as it's designed to load files from the presentation server which isn'r accessible from a background job.
For background processing you should use OPEN DATASET on a file that you've loaded to the application server.
You could add a switch in your program to allow it to run in foreground and background.
2010 Nov 12 9:42 AM
hi Thanks for the reply.
I need to upload the file from my desktop to a table so how to use opendataset to upload the file from presentation in background. please help me with the code.
Mahesh
2010 Nov 12 9:46 AM
Hi,
I don't think there is any way to upload data from desktop in back ground.
Regards,
Srini.
2010 Nov 12 9:47 AM
You can still load the data to your internal table and update the database in background but you can't use GUI_UPLOAD - you have to use the dataset processing commands.
2010 Nov 12 9:39 AM
Hi,
You have to use the OPEN DATASET command to read your file. The GUI_upload FM does not work in background.
Best regards
George Zervas
2010 Nov 12 9:54 AM
Hi,
You need to put the file at application server. Use tcode - CG3Z
Then as said by other use, OPEN, READ and CLOSE dataset commands.
There is no ways to upload the file from presentation server for a background job.
Regards
Munish Garg
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |