Skip to Content

Problem with CSV attachment using function 'SO_NEW_DOCUMENT_ATT_SEND_API1'

Hello,

I am having a problem with a CSV file that I want to attach to an email sending it with function 'SO_NEW_DOCUMENT_ATT_SEND_API1'.

The function needs Contents_bin to be "solisti1" type, which has a line of 255 characters. Here is my code previous to the function:

"Main Text: Properties


CLEAR lw_objpack-transf_bin.

lw_objpack-head_start = 1.

lw_objpack-head_num = 0.

lw_objpack-body_start = 1.

lw_objpack-body_num = lv_lines_txt.

lw_objpack-doc_type = 'RAW'.

APPEND lw_objpack TO lt_objpack.

*  "Main Attachment (Properties)

lw_objpack-transf_bin = 'X'.

lw_objpack-head_start = 1.

lw_objpack-head_num = 0.

lw_objpack-body_start = 1.

DESCRIBE TABLE lt_objbin LINES lv_lines_bin.

lw_objpack-doc_size =  lv_lines_bin * 255.

lw_objpack-body_num = lv_lines_bin.

lw_objpack-doc_type = 'CSV'.

lw_objpack-obj_name = 'smart'.

"Get Attachment Name

CLEAR lv_text.

lv_text = 'FILE_NAME'.

lw_objpack-obj_descr = lv_text.      "Attachment Name

APPEND lw_objpack TO lt_objpack.



The the execution goes OK, but the CSV file attached is wrong: each line (no matter how much columns) has 255 characters, and if for example only 15 are completed, the other 240 char appear as blank spaces instead of not showing.


I mean, the width of the last column is not defined by the lenght of the last text, it just expands until it gets 255 characters.


Can somebody help me to avoid this? Thanks.

capture2.PNG (9.6 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Jan 12, 2015 at 01:34 PM

    I answer myself!!

    I made a sollution with this code:

    loop at itable into work_area.

    clear lv_long.

    lv_long = strlen( work_area ).

       while lv_long < 254.

         concatenate work_area';' into work_area.

         lv_long = lv_long + 1.

         ENDWHILE.

         if lv_long = 254.

    CONCATENATE work_area c_new_line into work_area.

    append work_area to object_bin.

    endif.

       endloop.

    This way, I fill with ; the end of all lines until they have 255 characters and I avoid the problem with the blank spaces.

    If anybody knows another way to solve this, please write anyway!

    Add comment
    10|10000 characters needed characters exceeded