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

Transfer command not working fine

Former Member
0 Likes
765

Hi all .... I am using the following code.

its not giving any error and file is also getting created but when we view the file in AL11 the file dosnet shows the data updated and gives a message that the data in the file cant be viewed.

OPEN DATASET i_file FOR OUTPUT IN BINARY MODE .

IF sy-subrc EQ 0.

LOOP AT i_record INTO wa_record .

TRANSFER wa_record-FELD1 TO i_file.

IF sy-subrc NE 0 .

RAISE open_dataset_no_authority.

ENDIF.

ENDLOOP.

ELSE.

IF sy-subrc NE 0 .

RAISE error_opening_file.

ENDIF.

ENDIF.

Thanks in advance,

Naval Bhatt

Hi all .... I am using the following code.

its not giving any error and file is also getting created but when we view the file in AL11 the file dosnet shows the data updated and gives a message that the data in the file cant be viewed.

OPEN DATASET i_file FOR OUTPUT IN BINARY MODE .

IF sy-subrc EQ 0.

LOOP AT i_record INTO wa_record .

TRANSFER wa_record-FELD1 TO i_file.

IF sy-subrc NE 0 .

RAISE open_dataset_no_authority.

ENDIF.

ENDLOOP.

ELSE.

IF sy-subrc NE 0 .

RAISE error_opening_file.

ENDIF.

ENDIF.

Thanks in advance,

Naval Bhatt

4 REPLIES 4
Read only

Former Member
0 Likes
642

Hello Naval,

When you are using a dataset... first you have to lock it. after your usage you have to unlock it. The property CONSISTENCY.

I think your problem occurs due to.. already some other user is using that dataset.

Reward If Useful.

Regards

--

Sasidhar Reddy Matli.

Read only

dev_parbutteea
Active Contributor
0 Likes
642

Hi,

you should add tha statement close dataset like in the code below , else it won't release the lock to the file.

OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

LOOP AT gt_fichier INTO gs_fichier.

TRANSFER gs_fichier TO p_file.

ENDLOOP.

<b> CLOSE DATASET p_file.</b>

Read only

varma_narayana
Active Contributor
0 Likes
642

Hi...Naval...

this may be bcoz you opened the file in BINARY mode.

In this mode records are not transferred line be line.

So you can use.

OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

Try it...

Regards

Varma

Read only

Former Member
0 Likes
642

Hi Naval,

Refer this code :

open dataset i_files for output in text mode encoding default.

loop at i_data into wa_data.

transfer wa_data to i_files.

endloop.

close dataset i_files.

if sy-subrc = 0.

message i001.

endif.

clear files.

Reward points if helpful.

Regards,

Hemant