cancel
Showing results for 
Search instead for 
Did you mean: 

Download to excel file has a blank column

former_member206441
Contributor
0 Kudos

Dear Experts,

I used the below mentioned code to download data from table. I am able to succesfully download the data but the first column is coming as blank. It will be helpful if i get help to remove the blank column from the excel sheet.

   DATA: str  TYPE string,
        str1  TYPE string,
        xstr TYPE xstring.

  LOOP AT lt_ekko INTO ls_ekko .

IF  str = ' ' .
      CONCATENATE 'Ebeln'
                  'BUKRS'
                  'BSTYP'
                  'BSART'
                  cl_abap_char_utilities=>newline INTO str SEPARATED BY
                  cl_abap_char_utilities=>horizontal_tab.

else.
         CONCATENATE  str
                 ls_ekko-EBELN
                 ls_ekko-BUKRS
                 ls_ekko-BSTYP
                 ls_ekko-BSART
                 cl_abap_char_utilities=>newline INTO str  SEPARATED BY
                 cl_abap_char_utilities=>horizontal_tab.

endif.

  ENDLOOP.

  CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
    EXPORTING
      text   = str
    IMPORTING
      buffer = xstr
    EXCEPTIONS
      failed = 1.
  "Attach file
  CALL METHOD cl_wd_runtime_services=>attach_file_to_response
    EXPORTING
      i_filename      = 'Download.xls'
      i_content       = xstr
      i_mime_type     = 'EXCEL'
      i_in_new_window = abap_false
      i_inplace       = abap_false.

Thanks & Regards

Arun.K.P

Accepted Solutions (1)

Accepted Solutions (1)

bastinvinoth
Contributor
former_member206441
Contributor
0 Kudos

Hi Vinoth,

Thank you for the reply. Already i am able to populate the data in Excel sheet but the problem is i am getting a blank first column. I want to remove that please suggest me the way to remover the vacant column.

Thanks & Regards

Arun.K.P

former_member206441
Contributor
0 Kudos

Dear Experts

I tried using the statement  SHIFT str BY 1 PLACES LEFT.

But only the first column not getting the blank cell but from second row the first column is blank.

Any help will be appreciated.

Thanks & Regards

Arun.K.P

Former Member
0 Kudos

Hi,

Try populating the string variable like this to avoid first column blank.

CONCATENATE lv_text

ls_output-sno cl_abap_char_utilities=>horizontal_tab

ls_output-short cl_abap_char_utilities=>horizontal_tab

ls_output-stext cl_abap_char_utilities=>horizontal_tab

ls_output-begda cl_abap_char_utilities=>horizontal_tab

ls_output-endda cl_abap_char_utilities=>horizontal_tab

ls_output-rsign cl_abap_char_utilities=>horizontal_tab

ls_output-relat cl_abap_char_utilities=>horizontal_tab

ls_output-sclas cl_abap_char_utilities=>horizontal_tab

ls_output-sobid cl_abap_char_utilities=>horizontal_tab

ls_output-mess cl_abap_char_utilities=>horizontal_tab

ls_output-posi cl_abap_char_utilities=>horizontal_tab

cl_abap_char_utilities=>newline

INTO lv_text.

Best Regards,

Arun Krishnamoorthy



former_member206441
Contributor
0 Kudos

Hi Arun,

Thank you for the reply it worked but the first cell value got depricated

ie the value to be displayed is

3000000004 but the value is displayed as 4

Thanks & Regards

Arun.K.P

Former Member
0 Kudos

Hi,

Did you removed the statement SHIFT str BY 1 PLACES LEFT. May be it could be the reason.

If the value is 30000004 irrespective of its data type is string or number it will be displayed as 30000004. The same if the value is 00004 and the data type is numeric then it will be displayed as 4 in the excel.

What is the value in the text string you are getting at runtime??

Best Regards,

Arun Krishnamoorthy

former_member206441
Contributor
0 Kudos

Hi Arun

only the code

LOOP AT lt_ekko INTO ls_ekko .

CONCATENATE  str

ls_ekko-EBELN cl_abap_char_utilities=>horizontal_tab

ls_ekko-BUKRS cl_abap_char_utilities=>horizontal_tab

ls_ekko-BSTYP cl_abap_char_utilities=>horizontal_tab

ls_ekko-BSART cl_abap_char_utilities=>horizontal_tab

cl_abap_char_utilities=>newline

INTO str.

ENDLOOP.

is there. i removed shift and other statements.

Thanks & Regards

Arun.K.P

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Arun,

Could you share the structure of lt_ekko.

Thanks,

Namrata

former_member206441
Contributor
0 Kudos

Hi Namrata,

This is the structure.

      types: begin of ty_ekko,
            ebeln type EBELN,
            bukrs type BUKRS,
            bstyp type EBSTYP,
            bsart type ESART,
           end of ty_ekko.

     data: itab_ekko type table of ty_ekko,
           wa_ekko type ty_ekko.

Thanks & Regards

Arun.K.P