Application Development 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: 

Open Dataset with currency-fields

Former Member
0 Kudos

Hi,

we tried to write a program exporting the results of Quick-Viewer-Reports into a file while batch processing. This worked out fine with the coding below.

But as soon as there are currency-fields SAP aborts with "UC_OBJECTS_NOT_CHARLIKE".

-


DATA: filename LIKE rlgrap-filename.

IF list_id = 'G00'.

filename = '/usr/sap/trans/tmp/'.

filename+19 = program.

filename+120 = sy-datum.

REPLACE ALL OCCURRENCES OF '=' IN filename WITH ' '.

CONDENSE filename NO-GAPS.

OPEN DATASET filename FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

IF sy-subrc = 0.

LOOP AT datatab.

TRANSFER datatab TO filename.

ENDLOOP.

CLOSE DATASET filename.

ELSE.

MESSAGE w111(z1) WITH filename.

ENDIF.

ENDIF.

-


Wie tried various kinds of "open dataset... encoding utf-8/non-unicode... ignoring conversion errors..." but nothing worked. Binary mode isn't helpful because the data in the file have to be useful for the user instantly.

Who can help?

Thanks in advance!

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi

You could use only string to transfer data to file, so:

DATA STRING TYPE STRING.

LOOP AT datatab.

move datatab to string

TRANSFER string TO filename.

ENDLOOP.

Max

Message was edited by: max bianchi

15 REPLIES 15

Former Member
0 Kudos

Hi

You could use only string to transfer data to file, so:

DATA STRING TYPE STRING.

LOOP AT datatab.

move datatab to string

TRANSFER string TO filename.

ENDLOOP.

Max

Message was edited by: max bianchi

Former Member
0 Kudos

What is the structure of datatab. Replace all currency fields with char fields of same name and then try to do a transfer . You can use move or write to for moving currency fields to char fields. It should work.

Cheeers

Former Member
0 Kudos

You are getting an error due to the fact that you have Unicode checks active checked on the program attributes screen.

In SE38, you can edit the attributes and uncheck this flag. Unicode has very strict data validation.

Good luck,

JOhn

0 Kudos

Thanks for your ideas so far. I tried a lot, but again nothing worked. Using string does work, but still only without currency fields. And before I can even change the type of currency fields, the program aborts.

As far as I have learned now, the problem is, that I have a unicode program, but our system ist non-unicode. And I can't change program attribute to no unicode checks, because it's an inlcude in SAP-exit SQUE0001 (SAP Note 537735, executed while using Quick Viewer or SAP Query). In an include, I can't change this attribute, and I can't edit the program because it's SAP original.

Any ideas? I've got no more...

0 Kudos

I'm not sure why you can't reformat the data before writing to the dataset. Create a new structure with the same fields as your itab, only define them all as CHARACTER! ie)

data: begin of file_layout,

field1(20),

field2(10),

currency_field1(20),

end of file_layout.

Loop at itab.

move-corresponding itab to file_layout.

write itab-currency_field1 to file_layout-currency_field1.

transfer file_layout to file.

endloop.

Good luck,

John

0 Kudos

Sounds like you should send it to OSS.

Rob

Former Member
0 Kudos

Have you tried "LEGACY MODE" variant?

Former Member
0 Kudos

Hi Felicitas,

TRANSFER f TO dsn.

Effect

Transfers the field f (usually a field string) to the sequential file specified in dsn

In your case, modify your datatab, so that the currency fields are moved to char fields of suitable length.

Later loop on your internal table and transfer to file on application server.

Regards,

Rajasekhar

0 Kudos

Hi,

'Transfer To' didn't work at all.

We also tried every kind of Mode, text, binary, legacy - either it didn't work or the result was unusable.

At least, an OSS-Message obviously helped. Using "assign component" helps to transfer f. e. currency fields. It's kind of long winded and the result ist not as fine as we intended to have, because the records are without separators, you have to define it by field length, but it works - at least.

Anyhow, thanks for your ideas

Felicitas

former_member188685
Active Contributor
0 Kudos

Try to COnvert your Currency into Char foramt and Then transfer the data.

regards

vijay

0 Kudos

Hi,

yes that's what we were trying from the beginning, but it wasn't possible to do anything with currency fields because everytime you address this field anyhow, a shortdump was created (or in binary/legacy mode the value of these fields was kind of "#$"... no way to get the value). So there was no possibility to change field type.

It only seems to be possible with "assign component"...

Thanks

Felicitas

-


Try to COnvert your Currency into Char foramt and Then transfer the data.

regards

vijay

-


Former Member
0 Kudos

I have faced the same Problem

Move the currency field to some Char field and use in the Internal table then Transfer data

U can transfer only char fields to File.

Former Member
0 Kudos

This works, but a bit late :

Regards Meinhart:

FIELD-SYMBOLS: <file_name> TYPE ANY.

fiELD-SYMBOLS: <ftab> TYPE ANY,

<field> type any.

DATA: it_table TYPE fieldname VALUE '(RSAQEXCE)%pathname'.

ASSIGN (it_table) TO <file_name>.

data : tp_tab(1) type x value '09',

tp_lf(2) type x value '0D0A'.

data : tp_file(128) .

data : tp_field(256).

data : tp_length type i.

tp_file = <file_name>.

OPEN DATASET tp_file FOR output IN binary mode.

if sy-subrc ne 0.

message e001(38) with 'Cannot open dataset' tp_file .

endif.

*

loop at datatab assigning <ftab>.

loop at LISTDESC.

ASSIGN COMPONENT listdesc-FNAMEINT OF STRUCTURE <ftab> TO <field>.

write <field> to tp_field.

SHIFT tp_field LEFT DELETING LEADING space.

tp_length = strlen( tp_field ) .

transfer tp_field to tp_file length tp_length.

transfer tp_tab to tp_file.

endloop.

transfer tp_lf to tp_file.

endloop.

close dataset tp_file.

Former Member
0 Kudos

I need to write to an output file data that has both characters and packed field. The amount field must be packed. I have unicode set in my program attributes. When I do a TRANSFER f to dsn i get an error uc_objects_not_charlike.

All the replies says to convert the packed field to char. How do i handle a field that must be packed?

Need help ASAP. Thanks.

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Just curious, can you tell us why exactly it MUST be packed?

Regards,

Rich Heilman