Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

formatting problem converting internal table to text file in web dynpro

Hello Friends,

    I am using the following method to convert internal table data to text file & file is downloaded properly, but column alignment/formatting is not proper.

Kindly give me your suggestion to solve this issue.

LOOP AT lt_output INTO DATA(ls_result_data).

      CONCATENATE lv_string

                  ls_result_data-sortindicator

                  ls_result_data-wu_level

                  ls_result_data-searchobject

                  ls_result_data-so_type

                  ls_result_data-so_sysid

                  ls_result_data-so_status

                  ls_result_data-so_laboffice

                  ls_result_data-so_plant

                  ls_result_data-so_mmsta

                  ls_result_data-so_description

                  ls_result_data-so_businesspartnername

                  ls_result_data-directcomponent

                  ls_result_data-dc_type

                  ls_result_data-dc_description

                  ls_result_data-dc_sysid

                  ls_result_data-directusage

                  ls_result_data-du_type

                  ls_result_data-du_description

                  ls_result_data-du_sysid

                  ls_result_data-du_plant

                  ls_result_data-du_xplantstatus

                  ls_result_data-du_plantstatus

                  ls_result_data-du_materialtype

                  ls_result_data-du_laboffice

                  ls_result_data-du_businesspartnername

                  ls_result_data-du_itemcat

                  ls_result_data-du_itemno

                  lv_item_qty

                  ls_result_data-du_itemuom

                  ls_result_data-du_itemtext1

                  ls_result_data-du_itemtext2

                  ls_result_data-du_vfd

                  ls_result_data-du_vfcma

                  ls_result_data-du_vtd

                  ls_result_data-du_vtcma

                  ls_result_data-du_bomusage

                  ls_result_data-du_bomalt

                  ls_result_data-du_bomstatus

                  ls_result_data-du_bomlaboffice

                  lv_hdr_qty

                  ls_result_data-du_bomheaderuom

                  ls_result_data-du_prodrel

                  ls_result_data-du_calrel

                  ls_result_data-du_engrel

                  ls_result_data-du_altitmgrp

                  lv_usage

                  ls_result_data-finallevelindicator

                  ls_result_data-finalusage

                  ls_result_data-fu_businesspartnername

                  ls_result_data-wustatuscode

                  cl_abap_char_utilities=>newline INTO lv_string

                  SEPARATED BY cl_abap_char_utilities=>horizontal_tab.

    ENDLOOP.


*Convert string to Xstring

TRY.

  CALL METHOD cl_bcs_convert=>string_to_xstring

    EXPORTING

      iv_string    = lv_string

*      iv_convert_cp = 'X'

*        iv_codepage  = '4110'   

*      iv_add_bom    = 'X'

    receiving

      ev_xstring    = lv_xstring.

    CATCH cx_bcs .

  ENDTRY.

* Download contents in text format

    cl_wd_runtime_services=>attach_file_to_response(

        EXPORTING i_filename      = iv_filename

                  i_content      = lv_xstring

                  i_mime_type    = iv_mime_type                "'APPLICATION/TXT"

                  i_in_new_window = abap_false ).


Please check the attachment for file output.



error.jpg (135469 B)
Former Member
Not what you were looking for? View more on this topic or Ask a question