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

DATASET can't Open

Former Member
0 Likes
1,709

Hi SDN,

Im trying to use OPEN DATASET statement.

The Sy-subrc = 0. but when I use the transfer statement. I get a runtime error it says. Dataset can't Open.

If I change the filename it says,.. download compelted successfully but there is no file in the app ser in the particular path.

Can anyone suggest me what changes to make.

Useful answers will be rewarded with points.

Thanks

Manu

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,098

hi Manu,

filename = HSHRV1_20080521_7.

data : dsn(90) type C VALUE '/usr/sap/bcint/HSBC/Payments/'.

DATA : MESS(60) .

DATA : LIN LIKE LINE OF TAB_X.

TRANSLATE DSN INTO LOWER CASE.

CONCATENATE DSN FILENAME INTO DSN .

condense dsn no-gaps.

OPEN DATASET DSN FOR OUTPUT IN BINARY MODE MESSAGE MESS.

IF SY-SUBRC 0.

WRITE: 'SY-SUBRC:', SY-SUBRC,

/ 'System Message:', MESS.

ENDIF.

LOOP AT TAB_X INTO LIN.

try.

TRANSFER LIN TO DSN LENGTH LEN. WHERE LEN WILL BE LENGTH OF THE TEXT.

CATCH cx_sy_conversion_codepage.

endtry.

ENDLOOP.

CLOSE DATASET DSN.

REWARD POINTS IF HELPFUL,

KUMAR

Hi SDN,

Im trying to use OPEN DATASET statement.

The Sy-subrc = 0. but when I use the transfer statement. I get a runtime error it says. Dataset can't Open.

If I change the filename it says,.. download compelted successfully but there is no file in the app ser in the particular path.

Can anyone suggest me what changes to make.

Useful answers will be rewarded with points.

Thanks

Manu

5 REPLIES 5
Read only

Former Member
0 Likes
1,098

hi

Post ur coding u have wriiten for OPEN DATASET.

Read only

0 Likes
1,098

filename = HSHRV1_20080521_7.

data : dsn(90) type C VALUE '/usr/sap/bcint/HSBC/Payments/'.

DATA : MESS(60) .

DATA : LIN LIKE LINE OF TAB_X.

CONCATENATE DSN FILENAME INTO DSN in CHARACTER MODE.

condense dsn no-gaps.

OPEN DATASET DSN FOR OUTPUT IN BINARY MODE MESSAGE MESS.

IF SY-SUBRC <> 0.

WRITE: 'SY-SUBRC:', SY-SUBRC,

/ 'System Message:', MESS.

ENDIF.

LOOP AT TAB_X INTO LIN.

try.

TRANSFER LIN TO DSN.

CATCH cx_sy_conversion_codepage.

endtry.

ENDLOOP.

CLOSE DATASET DSN.

I hope you can suggest some possible amendments to be tried out.

Read only

0 Likes
1,098

Hi

check the below code.

condense dsn.

CONCATENATE DSN FILENAME INTO DSN in CHARACTER MODE.

condense dsn no-gaps.

OPEN DATASET DSN FOR OUTPUT IN Character MODE MESSAGE MESS.

IF SY-SUBRC 0.

WRITE: 'SY-SUBRC:', SY-SUBRC,

/ 'System Message:', MESS.

ENDIF.

LOOP AT TAB_X INTO LIN.

try.

TRANSFER LIN TO DSN.

CATCH cx_sy_conversion_codepage.

endtry.

ENDLOOP.

CLOSE DATASET DSN.

regards

Shiva

Read only

0 Likes
1,098

Hi,

U can refer to the following sample code. Dont use binary mode. Use text mode.

OPEN DATASET gf_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

IF sy-subrc = 0.

LOOP AT gt_output INTO gwa_output.

TRANSFER gwa_output TO gf_file.

IF sy-subrc <> 0.

MESSAGE e004 WITH text-t33.

gf_error = 0.

ENDIF.

ENDLOOP.

CLOSE DATASET gf_file.

MESSAGE s004 WITH text-t22.

ELSE.

gf_error = 0.

MESSAGE e004 WITH text-t32.

ENDIF.

Reward if helpful.

regards,

Ramya

Read only

Former Member
0 Likes
1,099

hi Manu,

filename = HSHRV1_20080521_7.

data : dsn(90) type C VALUE '/usr/sap/bcint/HSBC/Payments/'.

DATA : MESS(60) .

DATA : LIN LIKE LINE OF TAB_X.

TRANSLATE DSN INTO LOWER CASE.

CONCATENATE DSN FILENAME INTO DSN .

condense dsn no-gaps.

OPEN DATASET DSN FOR OUTPUT IN BINARY MODE MESSAGE MESS.

IF SY-SUBRC 0.

WRITE: 'SY-SUBRC:', SY-SUBRC,

/ 'System Message:', MESS.

ENDIF.

LOOP AT TAB_X INTO LIN.

try.

TRANSFER LIN TO DSN LENGTH LEN. WHERE LEN WILL BE LENGTH OF THE TEXT.

CATCH cx_sy_conversion_codepage.

endtry.

ENDLOOP.

CLOSE DATASET DSN.

REWARD POINTS IF HELPFUL,

KUMAR