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

Space issue in Internal table

Former Member
0 Likes
2,938

Hi Experts,

I Have An issue while Appending into Internal table.

This is an outbound interface in which I have 7 different types of records. I am appending all the work area to an internal table with size 500 char. the problem is that the last field is blank in some records the spaces are trucated. I need those space at the end as that file will be encrypted and send.

Thanks in advance.

Vijay

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,944

Hi Vijay,

ABAP type C truncates all trailing blank spaces. I assume your internal table is defined on a Char-field basis.

My suggestions:

1.- Include a final character after the trailing blanks, such as a "|" or a "\". The calling procedure should handle and remove this extra character. This change might be quite straightforward and quick to achieve.

2.- Change your parameters into XML strings. This change can be quite time-consuming.

I hope this helps. Kind regards,

Alvaro

9 REPLIES 9
Read only

Former Member
0 Likes
1,944

Hi madhan,

In my opinion you should concatenate all the fields into one work area using the respecting blanks statement and then try to append the record in the internal table.This way you will get the spaces also in the internal table.

Thanks,

Sumit

Read only

0 Likes
1,944

HI Sumit,

I tried that way,but when Appended to Internal table the spaces are getting Truncated..

Read only

Former Member
0 Likes
1,945

Hi Vijay,

ABAP type C truncates all trailing blank spaces. I assume your internal table is defined on a Char-field basis.

My suggestions:

1.- Include a final character after the trailing blanks, such as a "|" or a "\". The calling procedure should handle and remove this extra character. This change might be quite straightforward and quick to achieve.

2.- Change your parameters into XML strings. This change can be quite time-consuming.

I hope this helps. Kind regards,

Alvaro

Read only

0 Likes
1,944

Hi Alvaro,

i tried those options also , as i am appending all the fields of the workarea into 1 field of the internal table (500char) its truncating the spaces. I tried putting the special characterin the last field and at last replaced with spaces, this didnt work out .... any other options you have ..

Thanks in advance

Read only

0 Likes
1,944

Hi Madhan,

Try below tricky code to get spaces.


DATA: BEGIN OF t_space OCCURS 0,   " Data table
      name(10) TYPE c,
      dept(10) TYPE c,
      last_fld(480) TYPE c,   " Last field in data table, which you have to check 
      END OF t_space,
      wa_space LIKE LINE OF t_space.

DATA: str_space TYPE string.

DATA: BEGIN OF t_final OCCURS 0,        " Final table
      text(500) TYPE c,    " Single field with length 500 characters
      END OF t_final,
      wa_final LIKE LINE OF t_final.

"Below is tricky way to get ASCII value for space.
" Press ALT key and hold it and now press 255 in Numeric Keypad and now release ALT key. 
"This is ASCII value for space
CONSTANTS: ascii_space VALUE ' '.    " Give this space as mentioned in above line

wa_space-name = 'A'. wa_space-dept = 'IT'.
APPEND wa_space TO t_space.

wa_space-name = 'B'. wa_space-dept = 'CSE'.
APPEND wa_space TO t_space.

wa_space-name = 'C'. wa_space-dept = 'EEE'.
APPEND wa_space TO t_space.

wa_space-name = 'D'. wa_space-dept = 'ECE'.
APPEND wa_space TO t_space.

IF NOT t_space[] IS INITIAL.
  DO 480 TIMES.    "  480 times because it is length of the last_fld(480) in data table. Change it according to length of your last field
    CONCATENATE str_space ascii_space INTO str_space.
  ENDDO.
ENDIF.

LOOP AT t_space INTO wa_space.
 CONCATENATE wa_space-name wa_space-dept INTO wa_final. "Concatenate all data fields into final workarea except final field
  IF wa_space-last_fld IS INITIAL.  " Check whether final field is empty
    CONCATENATE wa_final str_space INTO wa_final.  " Concatenate spaces at end of final work area
  ENDIF.
  APPEND wa_final TO t_final. " Append to Final table
ENDLOOP.

Hope you understand friend.

Read only

0 Likes
1,944

Hi ,

The code didn't work Actually and i have 7different structured work area and this needs to be downloaded to presentation and Application server. at last in your code also the spaces are trimmed when downloaded to presentation server.

Thanks

Read only

0 Likes
1,944

Have you used below method to give space?


" Press ALT key and hold it and now press 255 in NUMERIC KEYPAD and now release ALT key. 
"This is ASCII value for space

CONSTANTS: ascii_space VALUE '  '.    " Give this space like mentioned in above way

"Use this ASCII value value of space to concatenate at the end of workarea. 
"Sure this will not get truncated

Read only

0 Likes
1,944

I tried putting the special characterin the last field and at last replaced with spaces, this didnt work out ....

That is not what Alvaro suggested. You should leave the special character (/) in place. Receiving application should ignore that special character.

Read only

0 Likes
1,944

Hi mad hans,

you say this is an outbound interface: What kind of technique is used? GUI download will truncate spaces except you use download type binary.

You can use a string and use back hyphens to create/preserve trailing spaces using

while strlen( stringfield ) < 500.
  concatenate stringfield ` ` into stringfield.
endwhile.

Regards,

Clemens