2006 Dec 27 12:35 PM
Hi all,
We are using the FM AUTHORITY_CHECK_DATASET before the command OPEN Dataset to transfer a file to the application server.
The sy-subrc for the FM comes out to be 0, but the sy-subrc for the open dataset command = 8 (on Checking in the debug mode).
The code snippet is as follows
v_path1 = v_bkpf.
CALL FUNCTION 'AUTHORITY_CHECK_DATASET'
EXPORTING
program = 'ZZRFFI058_GL_ACCOUNT_MAPPING'
activity = 'WRITE'
filename = v_path1
EXCEPTIONS
no_authority = 1
activity_unknown = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE e195(zzfn) WITH
'No authorisation to write file on application server'
v_path1.
WRITE:/ 'File:', v_path1, ' not created'.
STOP.
ENDIF.
OPEN DATASET v_bkpf FOR OUTPUT. "DEL ACC012
TRANSFER i_bkpf_w TO v_bkpf LENGTH v_len.
So we have a dump at the TRANSFER command.
Not sure how the FM is successful and OPEN DATASET fails
Pls post your ideas.
Thanks ,
Stock.
Hi all,
We are using the FM AUTHORITY_CHECK_DATASET before the command OPEN Dataset to transfer a file to the application server.
The sy-subrc for the FM comes out to be 0, but the sy-subrc for the open dataset command = 8 (on Checking in the debug mode).
The code snippet is as follows
v_path1 = v_bkpf.
CALL FUNCTION 'AUTHORITY_CHECK_DATASET'
EXPORTING
program = 'ZZRFFI058_GL_ACCOUNT_MAPPING'
activity = 'WRITE'
filename = v_path1
EXCEPTIONS
no_authority = 1
activity_unknown = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE e195(zzfn) WITH
'No authorisation to write file on application server'
v_path1.
WRITE:/ 'File:', v_path1, ' not created'.
STOP.
ENDIF.
OPEN DATASET v_bkpf FOR OUTPUT. "DEL ACC012
TRANSFER i_bkpf_w TO v_bkpf LENGTH v_len.
So we have a dump at the TRANSFER command.
Not sure how the FM is successful and OPEN DATASET fails
Pls post your ideas.
Thanks ,
Stock.
2006 Dec 27 12:53 PM
Hi Stock,
You can check with this piece of code..
The exceptions are Class based to handle this
You catch class-based exceptions in the statement block enclosed by the TRY and ENDTRY statements.
*C-- Open Dataset to write the file path
TRY.
OPEN DATASET p_phy1
FOR INPUT IN TEXT MODE ENCODING DEFAULT MESSAGE w_osmsg.
CATCH cx_sy_file_authority INTO w_obj_error.
PERFORM catch_error1 USING w_obj_error.
ENDTRY.
IF sy-subrc NE 0.
MESSAGE w_osmsg TYPE c_s DISPLAY LIKE c_err.
LEAVE LIST-PROCESSING.
*----
&----
*& Form catch_error1
&----
Catch the error messages of the application server
----
FORM catch_error1 USING fp_obj_error1 TYPE REF TO cx_root.
DATA : l_message TYPE string.
CLEAR :l_message.
l_message = fp_obj_error1->if_message~get_text( ).
MESSAGE l_message TYPE c_s DISPLAY LIKE c_err.
LEAVE LIST-PROCESSING.
ENDFORM. " catch_error1
Regards,
Sivaram.
2006 Dec 27 1:07 PM
hi,
I dont think the sy-subrc value corresponds to transfer it corresponds to open dataset and it means The file could not be opened.
please try to add mode text mode and encoding.
santhosh
2006 Dec 28 6:07 AM
Hi,
The sy-subc after open dataset 8 means the file opening for write fails.
put a check before transferring the content, that if sy-subrc=0(file oepend successfully) only then transfer the contents.
OPEN DATASET v_bkpf FOR OUTPUT. "DEL ACC012
if sy-subrc eq 0.
TRANSFER i_bkpf_w TO v_bkpf LENGTH v_len.
endif.
2006 Dec 28 6:11 AM
try the following,
OPEN DATASET v_bkpf FOR OUTPUT IN LEGACY TEXT MODE.
. "DEL ACC012 check v-bkpf has correct path and file name.
if sy-subrc <> 0.
write:/ 'Error opening file'.
else.
TRANSFER i_bkpf_w TO v_bkpf LENGTH v_len.
endif.
2006 Dec 28 6:25 AM
Hi,
DATA l_msg(60) TYPE c.
OPEN DATASET v_bkpf FOR OUTPUT IN TEXT MODE ENCODING DEFAULT
MESSAGE l_msg. "DEL ACC012
IF sy-subrc NE 0.
MESSAGE s000 WITH 'Error in opening file for output'.
LEAVE LIST-PROCESSING.
ENDIF.
....Processing here
Put a break point in the sy-subrc and in debug mode check the l_msg variable.
I don't think any problem in fm.Anyway for debugging purpose,pass the file path directly and check.
Check this link.
http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb3d5c358411d1829f0000e829fbfe/content.htm
2006 Dec 28 11:15 AM
Hi
You have mentioned that SY-SUBRC value returned is 8. This means the file for writing does not exists and hence TRANSFER to that file gives a dump.
Check the file path you have given and also the file name.
You have checked for the filepath as v_path1 in FM but in OPEN DATASET you have given the path as v_bkpf .
Use below code and if sy-subrc NE 0. then you can get the message and find the problem as to why the file is not getting created.
DATA MESS(255).
OPEN DATASET V_PATH1 FOR OUTPUT MESSAGE MESS.
IF SY-SUBRC <> 0.
WRITE: 'SY-SUBRC:', SY-SUBRC,
/ 'System Message:', MESS.
ENDIF.
| User | Count |
|---|---|
| 6 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |