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

File handling

Former Member
0 Likes
736

Hi All,

I have a problem with writing the data into the file.

Please look at my code once.

p_file = '/sapuser/interface/inwork/cust_credit_exposure.txt'.

OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

LOOP AT li_output INTO wa_output.

TRANSFER wa_output TO p_file.

ENDLOOP.

CLOSE DATASET p_file.

I got short dump at the line 'TRANSFER wa_output TO p_file'.

My output table has the following fields:

1)cust no

2)Amt1(CURR 19,2)

3)Amt2(CURR 19,2)

4)Currency

5) date/time

In the error analysis i got this :

The system tried to access the file

"/sapuser/interface/inwork/cust_credit_exposure.txt" but found that this file

was not opened. For this reason, it could not access the file.

Please help me in this.

Thanks

Suresh

Hi All,

I have a problem with writing the data into the file.

Please look at my code once.

p_file = '/sapuser/interface/inwork/cust_credit_exposure.txt'.

OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

LOOP AT li_output INTO wa_output.

TRANSFER wa_output TO p_file.

ENDLOOP.

CLOSE DATASET p_file.

I got short dump at the line 'TRANSFER wa_output TO p_file'.

My output table has the following fields:

1)cust no

2)Amt1(CURR 19,2)

3)Amt2(CURR 19,2)

4)Currency

5) date/time

In the error analysis i got this :

The system tried to access the file

"/sapuser/interface/inwork/cust_credit_exposure.txt" but found that this file

was not opened. For this reason, it could not access the file.

Please help me in this.

Thanks

Suresh

5 REPLIES 5
Read only

anversha_s
Active Contributor
0 Likes
707

hi,

chk the ITAB is initial or not.

chk this sample code

report zfile_write.
 
Parameters: d2 type localfile default '/usr/sap/TST/SYS/Data1.txt'.
 
data: itab type table of string.
data: wa type string.
 
 
start-of-selection.
 
* suppose itab has all the values.
 
if itab[] is not initial. "chk this
 
* Copy to file
  open dataset d2 for output in text mode.
  loop at itab into wa.
    transfer wa to d2.
  endloop.
  close dataset d2.

endif.

Regards,

Anver

Read only

Clemenss
Active Contributor
0 Likes
707

Hi Malineedi,

this one is easy:

The fields Amt1 and Amt2 are no text fields. If you open in text mode, only charcter fields can be transferred.

Amount fields in ABAP ara binary coded decimals. Starting with unicode compliance of ABAP, the system determines how many bytes are used for a character. The system does not know how to handle amount fields as text.

The solution for you depends on the use of the output file: No problem if you use BINARY mode but this might be a problem to read the amounts because BCD (binary coded decimal) amounts pack 2 decimals into 1 byte.

Otherwise you have to convert the amounts to character fields using WRITE TO an target field of sufficient size. But then you have the problem of user-dependent settings for thousands and decimals separator. (i.e. 100,000.52 or 100.000,52).

Roll up the process from the end: What do you expect to be in the file. Then find out how to create it.

Regards,

Clemens

Read only

Former Member
0 Likes
707

Hi Clemens ,

Thanks for your reply. The issue is solved by taking the BINARY mode. But while writing the data to the file, the amount filed is written as

'#######' . Please help me to solve this issue. Below is the output given for ur reference.

Cust_no Amt1 Amt2 Curr Date / Time

0010034544 ########` ########### USD 20070218/214646

Thanks & Regards

Suresh

Read only

Former Member
0 Likes
707

Hi,

Change the below line and check if it works:

OPEN DATASET p_file FOR OUTPUT IN TEXT MODE<b>. "ENCODING DEFAULT.</b>

Thanks

Read only

sreeramkumar_madisetty
Active Contributor
0 Likes
707

Hi

OPEN DATASET physical_file FOR OUTPUT IN TEXT MODE.

use this to open the data sets.

Regards,

kumar