12-07-2011 6:02 AM
Hi,
I developed a Migration Program, Which reads the data from Application serever and procced with further process in back ground mode.
Same program is workind fine in Development System in Back ground mode (SY-BATCH = 'X', Scheduled a batch Job). So I transported to Quality system.
Now When I run the program in background mode (SY-BATCH = 'X', Scheduled a batch Job), getting Message as "File is not Open" at Quality system. So I debugged the Batch job through "JDBG", and found file opening and reading the content sucessfully.
But its not working without debugging mode and getting message as "File not open".
Is there any Authorizations required for background mode (without debugging).
So can you please help me on this how to solve this issue.
12-07-2011 8:44 AM
rajsekhar,
Please answer my following questions.
1. is there any extension in the file name you are providing? if yes, remove it, might help
2. are you using the same user id for foreground processing and background processing, (i dont think issue lies here)
3. Main Question are your app servers and central instance belong to same OS type? what i mean is: do you have combination of UNIX and WINDOWs for your app servers/central instance??
Please answer these
12-07-2011 8:21 AM
12-07-2011 8:27 AM
***opening dataset for reading and preparing an internal table from the applciation server file.
OPEN DATASET p_fname FOR INPUT IN TEXT MODE ENCODING DEFAULT.
DO.
READ DATASET p_fname INTO ls_content.
IF sy-subrc EQ 0.
APPEND ls_content TO lt_content.
ELSE.
EXIT.
ENDIF.
CLEAR :ls_content.
ENDDO.
*Delete the entries, where the content is initial
DELETE lt_content WHERE content IS INITIAL.
*******closing dataset
CLOSE DATASET p_fname.
CATCH cx_root INTO gr_exception.
CALL METHOD gr_exception->get_text
RECEIVING
result = lv_msg.
FORMAT COLOR 6 ON.
WRITE:/ lv_msg.
FORMAT COLOR 6 OFF.
EXIT.
ENDTRY.
12-07-2011 8:36 AM
There are some exceptions which can be caught and cannot be. try it like below. You can refer this good debate
OPEN DATASET p_fname FOR INPUT IN TEXT MODE ENCODING DEFAULT MESSAGE lv_message.
IF sy-subrc NE 0.
MESSAGE e000 WITH 'The reason was-' lv_message.
ENDIF.
12-07-2011 8:52 AM
Please put a sy-subrc check after open dataset so as to know whether the file was opened sucessfully or some authorization issue in background.
thanks
Nabheet
12-07-2011 8:44 AM
rajsekhar,
Please answer my following questions.
1. is there any extension in the file name you are providing? if yes, remove it, might help
2. are you using the same user id for foreground processing and background processing, (i dont think issue lies here)
3. Main Question are your app servers and central instance belong to same OS type? what i mean is: do you have combination of UNIX and WINDOWs for your app servers/central instance??
Please answer these
12-07-2011 9:44 AM
Hi Sowmyaprakash,
Please find my answers below.
1. is there any extension in the file name you are providing? if yes, remove it, might help
While writing data on Application server , upload ed file with text.txt
2. are you using the same user id for foreground processing and background processing, (i dont think issue lies here)
Yes using same User ID
3. Main Question are your app servers and central instance belong to same OS type? what i mean is: do you have combination of UNIX and WINDOWs for your app servers/central instance??
its UNIX not with other OS.
12-07-2011 9:47 AM
12-07-2011 9:59 AM
Hi Soumya,
Tried as per your suggestion but still problem is there.
Kindly find below result, which i received in Spool.
The file '/usr/sap/tmp/DR_APAC_07122011' is not open
Total no of records = 0
Total no of success records = 0
Total no of error records = 0
Success file is empty. File Not downloaded
Error file is empty. File Not downloaded
But when I debug through JDBG, its working properly.
Edited by: Rajasekhar Reddy P on Dec 7, 2011 3:30 PM
12-07-2011 10:30 AM
Might sound silly. Introduce a wait upto few seconds before the open dataset statement and check if it is working.
WAIT UPTO 2 SECONDS.
Vikranth
12-07-2011 10:31 AM
and what is the EXACT file name in OS?
is there any lower case upper case values there?
just check p_fname value in both foreground mode and background mode... are they both having similar CASEs in both mode?
see, in OS if you have ABCD.TXT then p_file should also contain ABCD.TXT (which, i recomend not to add extensions)
in OS if you have Abcd, then p_file should also contaon Abcd.
like that...
12-07-2011 10:41 AM
Hi Vikranth,
Yes its silly.
May i know wat is the use if I keep WAIT UP TO 2 Sec before OPEN DATA SET.
Can U pls tell me.
12-07-2011 10:42 AM
Hi Soumya,
Checked its coming as per naming. No Problem With UPPER/LOWER cases.
12-07-2011 10:47 AM
dont mind but please post the file name...
OS level full path:
p_fname in foreground mode just before read dataset
p_fname is backgrounb(pass a system message of type 'S' at this point with value p_fname, you can get the p_fname value in the job log.):
12-07-2011 10:48 AM
Did you try what i said ?. It will give you the full proof message why it was not opened.
12-07-2011 11:07 AM
Hi Keshav,
here am catching the exceptions right.
it means it will return the exact errro I hope.
TRY.
***opening dataset for reading and preparing an internal table from the applciation server file.
OPEN DATASET p_fname FOR INPUT IN TEXT MODE ENCODING DEFAULT .
DO.
READ DATASET p_fname INTO ls_content.
IF sy-subrc EQ 0.
APPEND ls_content TO lt_content.
ELSE.
EXIT.
ENDIF.
CLEAR :ls_content.
ENDDO.
*Delete the entries, where the content is initial
DELETE lt_content WHERE content IS INITIAL.
*******closing dataset
CLOSE DATASET p_fname.
CATCH cx_root INTO gr_exception.
CALL METHOD gr_exception->get_text
RECEIVING
result = lv_msg.
FORMAT COLOR 6 ON.
WRITE:/ lv_msg.
FORMAT COLOR 6 OFF.
EXIT.
ENDTRY.
From thsi only am getting Message as "File XXXXXXXXXXXXX is open'.
Edited by: Rajasekhar Reddy P on Dec 7, 2011 4:38 PM
12-07-2011 11:22 AM
here am catching the exceptions right.
it means it will return the exact errro I hope.
Read the link which i mentioned for better understanding. Try it once and come back
kesav
12-07-2011 2:24 PM
Hi Keshav,
After Open Data Set used if Sy-Subrc NE 0 endif and after that used READ DATA SET now its working in back ground.
Still am not understanding wat happend and how its working. If u kno wthe reason can u pls explain that.
thanks for your help
12-07-2011 4:34 PM
Try this code:
DATA: PATH_NAME(80) TYPE C,
LV_FILENAME TYPE STRING.
DATA: LW_XSTRING TYPE XSTRING,
X_LEN TYPE I.
DATA: FILE_AUTH_ERR TYPE REF TO CX_SY_FILE_AUTHORITY,
FILE_OPEN_ERR TYPE REF TO CX_SY_FILE_OPEN,
FILE_OPEN_MODE_ERR TYPE REF TO CX_SY_FILE_OPEN_MODE,
FILE_CLOSE_ERR TYPE REF TO CX_SY_FILE_CLOSE,
FILE_CONVERSION_ERR TYPE REF TO CX_SY_CONVERSION_CODEPAGE,
FILE_TOO_MANY_ERR TYPE REF TO CX_SY_TOO_MANY_FILES,
MESS TYPE STRING,
W_TEXT TYPE STRING.
DATA: L_RC TYPE INT4.
concatenate pathname lv_filename into lv_filename.
TRY.
OPEN DATASET LV_FILENAME FOR INPUT IN BINARY MODE MESSAGE MESS.
CATCH CX_SY_FILE_OPEN_MODE INTO FILE_OPEN_MODE_ERR.
W_TEXT = FILE_OPEN_MODE_ERR->GET_TEXT( ).
L_RC = 1.
CATCH CX_SY_FILE_AUTHORITY INTO FILE_AUTH_ERR.
W_TEXT = FILE_AUTH_ERR->GET_TEXT( ).
L_RC = 2.
CATCH CX_SY_CONVERSION_CODEPAGE INTO FILE_CONVERSION_ERR.
L_RC = 3.
W_TEXT = FILE_CONVERSION_ERR->GET_TEXT( ).
CATCH CX_SY_TOO_MANY_FILES INTO FILE_TOO_MANY_ERR.
L_RC = 4.
W_TEXT = FILE_TOO_MANY_ERR->GET_TEXT( ).
CATCH CX_SY_FILE_OPEN INTO FILE_OPEN_ERR. "File already open
L_RC = 5.
W_TEXT = FILE_OPEN_ERR->GET_TEXT( ).
ENDTRY.
IF L_RC = 0.
L_RC = SY-SUBRC.
ENDIF.
IF L_RC <> 0 OR SY-SUBRC NE 0.
Issue Error message in open file.
CONCATENATE MESS 'Open dataset failed' w_text INTO MESS SEPARATED BY SPACE.
message Exx(yyy) with mess.
ELSE. "file exists and can be opened
ENDIF.
12-07-2011 5:21 PM
I doubt if the problem is in reading the file; it is in how p_fname is declared. If there are any lower case letters in the file name, it must be declared as:
PARAMETERS: f_name TYPE string LOWER CASE " or CHAR...
Rob