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: 

AL11 File Save Problem

Former Member
0 Kudos

Good morning everybody,

I've again ran into a problem using AL11. While exporting my file unconverted I seem to be losing white space.

I'm writing an ecryption program that operates using ASCII Characters 32 to 126, spaces included.

1) After program execution, the white space character is in the string at the end

[http://imgur.com/MvXRU]

2) When I export to HTML format, it appears that the white space is still there

[http://i.imgur.com/CBemx.jpg]

3) When I export uncoverted to text file, the white space is removed.

[http://i.imgur.com/TELSx.jpg]

The text file on the application server is then transferred using a windows batch file to another location where it can be decrypted using a key. However, the problem is that since whitespace at the end is shaved, It kind of ruins the decryption and message.

I'm thinking that the space is still there on the text file that is on the application server because the space is exported when going to HTML, but I can't access the file directly, only this way which.

So, my question being is white-space at the end of lines trimmed upon export from AL11? Is there a way to avoid this?

10 REPLIES 10

Former Member
0 Kudos

Hi,

While trasferring data from itab, concatenate the data using the below syntax.

CONCATENATE LINES OF itab
            INTO result 
            RESPECTING BLANKS.

Then move this itab to the file.

Hope it works.

0 Kudos

Thanks for the reply, though that isn't the solution.

[http://i.imgur.com/F19Ag.jpg]

It's still cutting the space at the end after the export.

I had the statement before:

        concatenate ls_text_line ' ' into ls_text_line seperated by space.

Which I changed to:

       concatenate ls_text_line lc_enc into ls_text_line respecting blanks.

Both produce the same results.

SuhaSaha
Advisor
Advisor
0 Kudos

Hello,

Can you post relevant portions of the code which you've used to download the file to the App server?

If i understand correctly you want the file to be fixed length, so you need "space" to be padded to the right if the line length is lesser. Correct me if i am wrong.

BR,

Suhas

Former Member
0 Kudos

Hi Suhas,

Sure. I can't do a fixed length because the lines vary. Some lines are 20 characters, others are 300. Also if I use a fixed length and the extra spaces get added to other lines then I have an alignment problem.

    open dataset ls_c_path for output in text mode encoding non-unicode.


    do li_bp_str_length times.

      lc_key = me->cl_keygen->get_current_key( ).

      lc_dec = ls_cur_bp_str+li_str_pos(1).

      lc_enc = me->cl_v->enc_char( in_key   = lc_key
                                          in_char  = lc_dec
                                          in_pos   = li_str_pos
                                          in_l_num = li_line_number ).

        concatenate ls_text_line lc_enc into ls_text_line respecting blanks.
      clear lc_enc.

      li_str_pos = li_str_pos + 1.

    enddo.

    transfer ls_text_line to ls_c_path.

Even with the transfer statement given a length, the space at the end still gets cut off.

transfer ls_text_line to ls_c_path length li_bp_str_length.

Edited by: Bryan Abrams on Jun 8, 2011 10:05 AM

Edited by: Bryan Abrams on Jun 8, 2011 10:07 AM

Edited by: Bryan Abrams on Jun 8, 2011 10:23 AM

Former Member
0 Kudos

Hi Bryan,

May be you can check the ascii value of this "SPACE"(after encoding) and check it is indeed SPACE "DEC VALUE - 32".

Regards,

Chen

Former Member
0 Kudos

Hi,

Have you opened the file in binary mode for output? If not, try doing the same.

OPEN DATASET FNAME FOR OUTPUT IN BINARY MODE.

Former Member
0 Kudos

Hi Chen,

There is a space in the last position of the string, so it's part of it.

[http://i.imgur.com/0QrRK.jpg]

Vinraaj,

When I set it to binary mode, the output I get is absurdly weird.

[http://i.imgur.com/WeWE6.jpg]

Former Member
0 Kudos

Hi everybody, just an update as I did some playing around.

As per the suggestion for Binary Mode in output, I tried this and noticed the funny output. I'm not sure exactly why but spaces are placed intbetween each character, or some odd value.

Anyway, as so I tried:


DATA:
      path    TYPE string VALUE 'E:\dir\test_file.txt',
      teststr TYPE string VALUE 'This is a transferred statement. '.

OPEN DATASET path FOR OUTPUT IN BINARY MODE.
TRANSFER teststr TO path.
CLOSE DATASET path.

And in the output I noticed the whitespace at the end is still removed:

[http://i.imgur.com/Y6X5w.jpg]

Edit: It's also the same in the case of LEGACY BINARY and LEGACY TEXT MODE. I'm thinking the transfer statement probably shaves whitespace off the end.

Edited by: Bryan Abrams on Jun 9, 2011 11:18 AM

Former Member
0 Kudos

Hi everybody, the problem has been solved. I ended a linebreak at the end of the string before transfering it. So for example:


string = 'space on the end '.
concatenate string cl_abap_char_utilities=>cr_lf into string.
transfer string to file.

The white space at the end is new preserved. Thanks everybody for the help.

0 Kudos

Hi..

Similar to your SPACE problem, I have issues with preceding zeros when downloading from AL11 to excel file.

Is there any solution to make appear the preceding zeros of a field in excel when downloading from AL11?

I already used formula "=T("0010") in ABAP code but user doesn't wanted it that way(with formulas applied)...

Thanks for your help.

Regards, Swami