Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

open dataset exception not triggered

crepmaster
Participant
0 Likes
2,655

hello folks i'm having a dump because i can't open the dataset, but

when i use this code

open dataset p_file for output in text mode encoding default message mes.

if sy ne 0.

message mess type E.

endif.

the error is triggered but if i use:

TRY.

       OPEN DATASET p_file FOR OUTPUT

            IN TEXT MODE ENCODING DEFAULT.

     CATCH cx_dynamic_check  INTO gr_err.

       gs_msg = gr_err->get_text( ).

   ENDTRY.


in debug i can see sy-subrc = 8 but the catch is not trigger, i have also try with   cx_sy_file_authority but nothing, i'm in ECC6 unicode.

Regards

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,808

Hi Marco,

i guess, you are not trying to upload the other format file instead of '.txt' file.

The below link may help you. in case you are uploading .txt, then the program should work.

http://wiki.scn.sap.com/wiki/display/Snippets/Code+sample+to+read+and+upload+a+file+in+application+s...

Best of luck.

Regards,

Krishnaes

hello folks i'm having a dump because i can't open the dataset, but

when i use this code

open dataset p_file for output in text mode encoding default message mes.

if sy ne 0.

message mess type E.

endif.

the error is triggered but if i use:

TRY.

       OPEN DATASET p_file FOR OUTPUT

            IN TEXT MODE ENCODING DEFAULT.

     CATCH cx_dynamic_check  INTO gr_err.

       gs_msg = gr_err->get_text( ).

   ENDTRY.


in debug i can see sy-subrc = 8 but the catch is not trigger, i have also try with   cx_sy_file_authority but nothing, i'm in ECC6 unicode.

Regards

9 REPLIES 9
Read only

sreeramkumar_madisetty
Active Contributor
0 Likes
1,808

Hi

Check for sy-subrc after OPEN DATASET statement and include exception code if SY-SUBRC # 0.

Thanks,

Sreeram

Read only

Katan
Active Participant
0 Likes
1,808

If you check out the SAP Help, the SY-SUBRC = 8 means the app server was unable to open the file. 

In your dump does it mention the name of the class based exception that was raised? 

http://help.sap.com/abapdocu_702/en/abapopen_dataset.htm

For test purposes, you can set it to CX_ROOT and see what comes up.  Then change it to something more appropriate. CX_DYNAMIC_CHECK will only be raised for catchable exceptions caused during runtime. 

Hope that helps...

Read only

rosenberg_eitan
Active Contributor
0 Likes
1,808

Hi,

May I sugest you that you also use this addition:

DATA: mess TYPE string .

OPEN DATASET p_file FOR OUTPUT IN BINARY MODE MESSAGE mess .

Regards.

Read only

Former Member
0 Likes
1,808


Hi Marco,

Before processing the program, make sure the upload file is closed. And check whether you have an authorizations for accessing the file from an application server.

Regards,

Krishnaes.

Read only

Former Member
0 Likes
1,808

Hi Marco,

as Katan said, you try to catch the wrong exception class CX_DYNAMIC_CHECK.

Either you try to catch one or some of the classes in his link or you try to catch CX_ROOT for all available catchable exceptions.

Regards,

Klaus

Read only

crepmaster
Participant
0 Likes
1,808

hy all thanx for you reply, i've also try to catch all the possible exception like this:

data gr_err TYPE REF TO cx_root,

TRY.

       OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING NON-UNICODE.

     CATCH cx_sy_file_open INTO gr_err.

       gs_msg = gr_err->get_text( ).

     CATCH cx_sy_file_authority   INTO gr_err.

       gs_msg = gr_err->get_text( ).

     CATCH cx_dynamic_check  INTO gr_err.

       gs_msg = gr_err->get_text( ).

   ENDTRY.


still nothing catch and sy-subrc still 8.

Read only

Former Member
0 Likes
1,808

Hi Marco,

check whether you can open the file from "AL11" t-code else, take an authorizations for accessing the file and try. Hope it may helps you.

Regards,

Krishnaes.

Read only

0 Likes
1,808

Hy Krishnaes i can open from AL11... it's really a mistery

Read only

Former Member
0 Likes
1,809

Hi Marco,

i guess, you are not trying to upload the other format file instead of '.txt' file.

The below link may help you. in case you are uploading .txt, then the program should work.

http://wiki.scn.sap.com/wiki/display/Snippets/Code+sample+to+read+and+upload+a+file+in+application+s...

Best of luck.

Regards,

Krishnaes