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

Problem in formating data

Former Member
0 Likes
1,174

Hello Friends,

I am using CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1' to send mail having excel sheet as the attachment.

I am getting the mail properly but the contents in the excel sheet are coming in single line.

The same report is working fine in lower version but it is not working in ECC 6.0.

In lower version I am concatenating the data along with '0D0A' as prefix so that it comes on next line and its data type is X.

In new version it is not supporting data type X so I made it C and all data comes on single line.

Thanks in advance

Regards,

Neelambari.

9 REPLIES 9
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
958

Hello Neelambari,

You need to replace 0D0A with CL_ABAP_CHAR_UTILITIES=>CR_LF.


DATA: v_crlf TYPE char2.

v_crlf =  CL_ABAP_CHAR_UTILITIES=>CR_LF.

This will solve the problem.

BR,

Suhas

Read only

Former Member
0 Likes
958

thanks

My data is coming on next line.

But I have one more problem.

I have used comma ',' as the separater so that each data after comma will come in next column but it is coming in first column.

Regards,

Neelambari

Read only

Former Member
0 Likes
958

thanks

My data is coming on next line.

But I have one more problem.

I have used comma ',' as the separater so that each data after comma will come in next column but it is coming in first column.

Regards,

Neelambari

Read only

Former Member
0 Likes
958

My data is coming on next line.

But I have one more problem.

I have used comma ',' as the separater so that each data after comma will come in next column but it is coming in first column.

Regards,

Neelambari

Read only

Former Member
0 Likes
958

hi,

use the CL_ABAP_CHAR_UTILITIES=>NEWLINE instead of concatinting '0D0A' to the data.

Read only

0 Likes
958

My data is coming on next line.

But I have one more problem.

I have used comma ',' as the separater so that each data after comma will come in next column but it is coming in first column.

Regards,

Neelambari

Read only

0 Likes
958

thanks a lot

Read only

Former Member
0 Likes
958

so a problem might have encountered in the separator.

you might have a declaration

data : c_sep type Hex value '0DXA,

and in unicode correction it might have went to

data : c_sep type C value '0DXA'.

This conversion is wrong and it has to be done through a proper FM.

Please use FM HR_RU_CONVERT_HEX_TO_STRING for these exa to string conversions and then apply the separator value .Making direct coversion to type c will eliminate the unicode error but the o/p varies a lot.

-


data : c_sep type Hex value '0D0A'.

data : c_sep1 type string ,

c_sep2 type xstring .

c_sep2 = c_sep.

call fm HR_RU..

and extract the separator of hex in string form .

i.e into c_sep1.

And in the code use this value .

Vijay.

Read only

Former Member
0 Likes
958

hi,

use this function module SAP_CONVERT_TO_CSV_FORMAT before sending to e-mail and then loop thru your internal table which has the data, and replace the | with cl_abap_char_utilities=>horizontal_tab.

follwoing is the sample code.

loop at it_spool_xls_return into wa_spool_xls_return.
    condense wa_spool_xls_return.
*  l_length = strlen( wa_spool_xls_return ).
*  l_length = l_length - 3.
**delete header lines if contains any
    if  wa_spool_xls_return cp '|--*--|'
    or  wa_spool_xls_return np '*|*|*|*'.
      delete it_spool_xls_return.
      clear wa_spool_xls_return.
*      concatenate cl_abap_char_utilities=>newline wa_SPOOL_XLS_RETURN
*      into wa_SPOOL_XLS_RETURN.
*      modify it_spool_xls_return from wa_spool_xls_return.
*      clear wa_spool_xls_return.
    else.
*If not new line then replace '|' by tabs
      if not wa_spool_xls_return eq cl_abap_char_utilities=>newline.
        if wa_spool_xls_return ca '|'.
          concatenate cl_abap_char_utilities=>newline wa_spool_xls_return
*        cl_abap_char_utilities=>horizontal_tab
          into wa_spool_xls_return.

          replace all occurrences of '|' in wa_spool_xls_return
          with cl_abap_char_utilities=>horizontal_tab.
*get rid of '-' symbol if contains any
*        if wa_SPOOL_XLS_RETURN CA '-'. "or not wa_SPOOL_XLS_RETURN CA '|'.
*          CLEAR wa_SPOOL_XLS_RETURN.
*          concatenate cl_abap_char_utilities=>newline wa_SPOOL_XLS_RETURN
*          cl_abap_char_utilities=>horizontal_tab
*          into wa_SPOOL_XLS_RETURN.
*        endif.
          replace all occurrences of '.' in wa_spool_xls_return
          with space.
          condense wa_spool_xls_return.
          modify it_spool_xls_return from wa_spool_xls_return.
*          wa_SPOOL_XLS_RETURN = cl_abap_char_utilities=>newline.
*          IF l_count NE 0 .
**        l_tabix = l_tabix + 1.
**Insert new line for the excel data
**        if sy-tabix gt 1.
**          INSERT wa_SPOOL_XLS_RETURN INTO it_SPOOL_XLS_RETURN INDEX l_tabix.
**        endif.
*            l_count = l_count - 1.
*          ENDIF.
          clear wa_spool_xls_return.
        else.
          delete it_spool_xls_return.
          clear wa_spool_xls_return .
*          concatenate cl_abap_char_utilities=>newline wa_SPOOL_XLS_RETURN
**        cl_abap_char_utilities=>horizontal_tab
*          into wa_SPOOL_XLS_RETURN.
*          modify it_SPOOL_XLS_RETURN from wa_SPOOL_XLS_RETURN.
*          clear wa_SPOOL_XLS_RETURN.
        endif.
      endif.
    endif.
  endloop.