2006 Sep 08 2:51 AM
I have developed an customized report which basically uploads a file from server and perform computation against the data in SAP.
Tested ok when executed normally. But it fails to upload file when its set to background job.
Used 'Open Dataset'
Please advice.
2006 Sep 08 3:46 AM
Hi Duxton
Can you post your code? Also can you check if the
file still exists on server by the time you are
executing in background.
Kind Regards
Eswar
2006 Sep 08 3:46 AM
Hi Duxton
Can you post your code? Also can you check if the
file still exists on server by the time you are
executing in background.
Kind Regards
Eswar
2006 Sep 08 4:08 AM
OPEN DATASET ZFNAME IN TEXT MODE.
IF SY-SUBRC = 0.
DO.
READ DATASET ZFNAME INTO ZLINE LENGTH LEN.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
ITAB-LINE = ZLINE.
APPEND ITAB. CLEAR ITAB.
ENDDO.
ENDIF.
CLOSE DATASET ZFNAME.
Its a simple code, and i have checked that file existed during the scheduled time.
2006 Sep 08 6:33 AM
Hi Duxton,
The only simplest answer to this is that maybe 'ZFNAME' has no value in it. Can you please hardcode the value and then try and let me know if still it fails.
Regards
Nishant
2006 Sep 08 4:24 AM
Hi
Couldnt find anything wrong with your code, for it to fail in background...can u post your complete code?
Regards,
Raj
2006 Sep 08 6:26 AM
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
FILENAME = ZFNAME
FILETYPE = 'ASC'
IMPORTING
FILELENGTH = RC
TABLES
DATA_TAB = ITAB
EXCEPTIONS
FILE_OPEN_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0 .
DATA: LEN TYPE I.
CLEAR ZLINE.
OPEN DATASET ZFNAME IN TEXT MODE.
IF SY-SUBRC = 0.
DO.
READ DATASET ZFNAME INTO ZLINE LENGTH LEN.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
ITAB-LINE = ZLINE.
APPEND ITAB. CLEAR ITAB.
ENDDO.
ENDIF.
CLOSE DATASET ZFNAME.
ENDIF.
IF ITAB[] IS INITIAL .
ERR-FDATE = SDATE.
ERR-REMARKS = "unable to find file".
APPEND ERR.
ENDIF.
This is the portion for uploading the file.
Anyway to debug when in backgroud?
2006 Sep 08 11:32 AM
Hi Duxton
While opening the file to read the data, use as
OPEN DATASET ZFNAME <b>FOR INPUT</b> IN TEXT MODE.
I guess the default mode will be FOR OUTPUT.
For debugging a background job, there are two options
1. When the job is finished, go to SM37. Select the
job, execute command JDBG in command field. A series of
F7 need to be done until you reach your program. From
then you can debug to see how the commands are executed.
2. Place an infinite loop in the program, execute in
background. Go to SM50, select the process. Go to menu
Program/Mode -> Program -> Debugging. Which will open
your program in debugging mode, change the value to exit
the infinite loop and proceed with other steps.
Btb, can you check if you are using the same filename
for both foreground and background processing as the
naming convention will be different for presentation
server filename and application server filename.
Eg:
Presentation Server: 'C:Eswar.txt'.
Application Server: '/usr/sap/Eswar.txt'.
Hope your problem gets resolved.
Kind Regards
Eswar
2006 Sep 08 11:35 AM
Good Your problem is already resolved. Am slow to respond.
Kind Regards
Eswar
2006 Sep 08 5:43 AM
hi,
Only work in the case of BDC.
please add this condition also.
IF sy-binpt IS NOT INITIAL.
sy-binpt = 1 when its a back ground job,
regards,
anver
2006 Sep 08 6:28 AM
there is no BDC involved in the program
It merely compares the amount from the file against the amount in SAP table.