| Home • Tips • Tutorials • Forums • Certification Q's • Interview Q's • Jobs • Testimonials • Contact Us | ||
Tips Categories:
Contribute?What's New?
What's Hot? |
Keeping Trailing spaces in a fileby Joyjit Ghosh, IBM India In few requirements I have seen that client wants to keep the
trailing spaces in the file that is generated from an interface program/data
extraction program. This is important for the legacy application that ultimately
processes this file. This tip will show us how to keep trailing blanks in a file. REPORT z_sn_space. CONSTANTS: c_space TYPE syhex02 VALUE '00a0'. " Value for space DATA: g_space TYPE string,
l_pos type i.
TYPES: BEGIN OF ty_data,
field1(8) TYPE c,
END OF ty_data.
DATA: wa_data TYPE ty_data. DATA: i_data TYPE STANDARD TABLE OF ty_data. * Get the value of a space g_space = cl_abap_conv_in_ce=>uccp( c_space ). wa_data-field1 = 'Joy'. L_pos = strlen( wa_data-field1 ). Do 5 times. wa_data-field1+l_pos(1) = g_space. L_pos = l_pos + 1. Enddo. APPEND wa_data TO i_data. CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
filename = 'C:\trailing_space_demo.txt'
CHANGING
data_tab = i_data
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
NOT_SUPPORTED_BY_GUI = 22
ERROR_NO_GUI = 23
others = 24
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Output of the generated file:
|
|
|
Please send us your feedback/suggestions at webmaster@SAPTechnical.COM Home • Contribute • About Us • Privacy • Terms Of Use • Disclaimer • Safe • Companies: Advertise on SAPTechnical.COM | Post Job • Contact Us ©2006-2007 SAPTechnical.COM. All rights reserved. All
product names are trademarks of their respective companies. SAPTechnical.COM
is in no way affiliated with SAP AG. Graphic Design by Round the Bend Wizards |
||