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/READ DATSET not working correct under ECC6.0.

Former Member
0 Kudos
185

hi,

we are upgrading vom R/3 4.6.c to mySAP ERP 2005 (ECC 6.0).

i am on with testing all Z-ABAPS now and i have the following problem:

i have the following coding:

OPEN DATASET p-filenm FOR INPUT IN TEXT MODE

DO.

READ DATASET p-filenm INTO inprec.

IF sy-subrc EQ 0.

APPEND inprec TO gt_inp.

ELSE.

EXIT.

ENDIF.

ENDDO.

when i look to inprec or later in gt_inp-table i got an '#' at the

end of the string. WHY DOES THIS OCCUR. I got a big problem,

because when i have a field at the end and i am moving it to

a table. so it contains now the value 'EUR#'..........it is the currency-code

for invoices.

Any ideas ? The problem ONLY occurs under ECC 6.0, NOT under 4.6.c.

regards, Martin

22 REPLIES 22

suresh_datti
Active Contributor
0 Kudos
155

Use this statement & try..

open dataset p-filenm in text mode for input encoding utf-8.

~Suresh

0 Kudos
155

okay suresh, thank you.

i will try this ! BUT: why it has do be done now ? i would have to change MANY z-abaps if this is the case ;-(

reg, Martin

0 Kudos
155

I don't think there is an option if your programs are to be Unicode compliant.. Pl go through the following <a href="http://help.sap.com/saphelp_erp2005vp/helpdata/en/62/3f2cadb35311d5993800508b6b8b11/content.htm">SAP help</a> on ABAP & Unicode that miht help in making your Z-programs Unicode compliant.

~Suresh

Former Member
0 Kudos
155

Hi,

according to unicode

OPEN DATASET p-filenm FOR INPUT IN TEXT MODE should be changed to

OPEN DATASET p-filenm FOR INPUT IN TEXT MODE encoding default.

because encoding and mode is compulsory in ECC6.0 .

click on f1 on open datatement in ECC6.0 u can clearly see the syntax open according to unicode.

Regards,

Sruthi

0 Kudos
155

thanky shruthi,

but we don't have a unicode system ! so why i should change this ?

reg, Martin

0 Kudos
155

Hi,

chek the attributes of your zprogarm in Ecc6.0 .

chec the Unicode checks active of your zprogarm.

Regards,

Sruthi

0 Kudos
155

when i activate the 'unicode' in the attributes i got 100's of warnings, most of them saying that '-' is not allowed in names.

i don' t care about unicode. i will NEVER EVER need unicode in my company. so i don't understand why i should take care about that now.

regards, Martin

0 Kudos
155

now i have changed the open dataset to:

OPEN DATASET p-filenm FOR INPUT IN TEXT MODE encoding default.

but it still does not work, i still get the '#' at the end of the line !

0 Kudos
155

To be clear, the extension ENCODING is required because the statement has changed, you absolutly need this extension whether you are unicode or not. You could probably just use ENCODING DEFAULT and all will be well.

Also, you say NEVER EVER, well let me tell you, a) using NEVER EVER means 100%, you should say MAYBE NEVER. Anyway, it is my understanding that as of the next release, SAP will REQUIRE you to be unicode even if you will not benefit from it. So that said, I would highly suggest that you do a unicode conversion in the near future, maybe once the upgrade problems settle.

Regards,

Rich Heilman

0 Kudos
155

In order to get rid of that '#', you could simply remove it manually after the READ DATASET .

Regards,

Rich Heilman

0 Kudos
155

rich,

thanks for your statment !

uh uh uh.......i will REQUIRE unicode in the next release ? i have to accept 30-50 % of more hardware-requirements (CPU, disk space) ? does SAP have contracts with hardware-vendors ? that is not very good, because i think many customers will get mad about that

0 Kudos
155

Boy, I really don't like being the barer of bad news. I just checked with SAP Product Managment to verify, and the answer was "Maybe, it is still too early to tell".

But I was at the Upgrade Symposium a couple of weeks ago, and they did mention that Unicode would be required in the next release. I did hear them say that. But I guess, the real answer is "maybe". Which isn't very comforting.

So if the answer is yes, then when the next release comes, sometime in 2010, or probably 2011(as said by SAP), you will be required to be UNICODE. And yes, that means hardware requirements will increase, as well as costs, and in some cases, the IT directors blood pressure. This is also the reason why SAP pushes to install as unicode even if you are a single language system.

My company is going to do this immedately following the upgrade from 46c to ERP2005, not on the same weekend, but maybe a few weeks later. We will be making all our programs Unicode compliant when we upgrade, so that there is no work(for me at least) when the unicode conversion comes.

REgards,

Rich Heilman

0 Kudos
155

i have tried with all your tips, using

encoding utf-8

encoding default

encodint non-unicode

but i still get the '#' at the end of every line.

what about the 'linefeed' option in the open dataset statement ?

regards, Martin

0 Kudos
155

Well, do you just want to get rid of it manually? If so, you can strip it off after the READ.



DATA: ds TYPE string.
DATA: len TYPE i.
DATA: istr TYPE TABLE OF string.
DATA: xstr TYPE string.
DATA: c(1000) TYPE c.

ds = '/SAP/NSP/test.txt'.

OPEN DATASET ds FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc = 0.
  DO.
    READ DATASET ds INTO xstr.
    IF sy-subrc <> 0.
      EXIT.
    ENDIF.
    c = xstr.
    len = STRLEN( c ).
    len = len - 1.
    CLEAR c+len(1).
    xstr = c.
    APPEND xstr TO istr.
  ENDDO.
ENDIF.

LOOP AT istr INTO xstr.
  WRITE:/ xstr.
ENDLOOP.

Regards,

Rich Heilman

0 Kudos
155

i know that i can put it away manually (much more easier with the replace-statment) !

but that can't be the way i think to put it away manually. that would be kind of very strange i think

regards, Martin

0 Kudos
155

Yes, you are right, you could use the REPLACE statement, the reason that I did it like the above, is because I simply don't know what the "non-printable" character is, probably a CR_LF, but I wasn't sure. The '#' is an internal represent of the non-printable character and it is not an '#'.

So you could simply replace the logic with the REPLACE statement using the constant CL_ABAP_CHAR_UTILITIES=>CR_LF.

Regards,

Rich Heilman

0 Kudos
155

how can i use this constant ??? i am not sure what you mean with 'replace the logic with the REPLACE statement using the constant CL-ABAP..............'

regards, Martin

0 Kudos
155

Well, if we revisit the code above, you can see that you can use th REPLACE statement with the static CL_LF attribute(which has a constant value) of the static class CL_ABAP_CHAR_UTILITIES.



DATA: ds TYPE string.
DATA: len TYPE i.
DATA: istr TYPE TABLE OF string.
DATA: xstr TYPE string.
DATA: c(1000) TYPE c.

ds = '/SAP/NSP/test.txt'.

OPEN DATASET ds FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc = 0.
  DO.
    READ DATASET ds INTO xstr.
    IF sy-subrc <> 0.
      EXIT.
    ENDIF.
    REPLACE cl_abap_char_utilities=>cr_lf IN xstr
                  WITH space.
    APPEND xstr TO istr.
  ENDDO.
ENDIF.

LOOP AT istr INTO xstr.
  WRITE:/ xstr.
ENDLOOP.

Regards,

Rich Heilman

0 Kudos
155

thanks rich,

i will try this tomorrow !

but there is still the question why i can not avoid that ?!? why does the open dataset not check that ? that still confuses me a bit

regards, Martin

0 Kudos
155

hi friends,

i am still not able to get away the linefeed ;-(

i have done the open dataset with

OPEN DATASET p-filenm FOR INPUT IN TEXT MODE ENCODING DEFAULT MESSAGE iwrkfd-messag.

the # is still there !

then i have done a

REPLACE cl_abap_char_utilities=>cr_lf IN xstr WITH space.

but the '#' is still there. when i debug cl_abap_char_utilities=>cr_lf

hast the value '##', and not '#'.

please help me........how can i get this problem solved ?

regards, Martin

Former Member
0 Kudos
155

Hi Martin,

Try this:

open dataset p-filenm for input

in text mode encoding non-unicode.

This should make your open statement compatible for non-unicode.

Cheers,

Vikram

Pls mark for helpful replies!!

Former Member
0 Kudos
155

I already found the solution!

In this case you must use this way:

TYPES: BEGIN OF t_estruc,

valor(200) TYPE c,

END OF t_estruc.

DATA: wa type [ User-Defined-Estructure ]

wa_datos_sep TYPE t_estruc,

variable TYPE i.

variable = STRLEN( wa_datos_sep-valor ) - 1.

wa-estatus = wa_datos_sep-valor(variable).

Good luck.