04-09-2012 3:51 PM
hi,
i want to download some 10 fields with different lenghts to a text file. i need to have descriptions of the fields at top as header. the formatting is not coming quite right. as mentioned below ( just an example). i want the values to be aligned with the header descriptions. how cani achieve this
field1 field2 field3 field4............
01 02 sdsd 3
04-09-2012 5:30 PM
Hi,
One way: define a table with 10 string fields and use parameter WRITE_FIELD_SEPARATOR...
Cheers,
Manu.
04-09-2012 7:03 PM
04-09-2012 7:23 PM
The predefined constants in the CL_ABAP_CHAR_UTILITIES must be used for making use of such platform independant constants.Use the constant cl_abap_char_utilities=>horizontal_tab and insert it into the string before download.
Also, this is a Unicode Compliant way.
Sample Code :
CONCATENATE <f01> <f02> .....<fn> into <str> SEPERATED BY cl_abap_char_utilities=>horizontal_tab.
04-09-2012 7:45 PM
Rather than trying to include a separate table with field names, since this is a text file, why not simply insert a row at the beginning of the table to be downloaded with the field names? Separate each with a tab.
Rob
04-09-2012 11:54 PM
of course that's what I meant... put the all things (rows and header) into one table with 10 string fields.. The table actually used seems to contain some field shorter that his header hence the new table. No need to insert tabs manually then, if the parameter WRITE_FIELD_SEPARATOR is used...
@op, I'd like to know why this simple solution does not suit the requirement here? What is the issue you are facing exactly?
Cheers,
Manu.
04-10-2012 5:03 AM
the problem is some of the header descriptions are longer than actal values and some of them are shorter than row values. let's say header has fields
fisrt second third
1232343 1223 12
what i want to see in the file is as below
fisrt second third
1232343 1223 12
04-10-2012 6:44 AM
Did you try to do it manully in notepad? Did you succeed ? If not then you like to do something below. You need to put the logic so that you know what is the max lenght between for each column and it's content. you need to pad space and so that the lenght for both the header and the content becomes same.
check the bleow program I created for you. The subroutine may help you
f_get_table.
It takes a dictionary structure. It creates an internal table of string with header as field name and delimited by the delimeter passed to it.
Let me know if it helps
04-10-2012 6:38 AM
Use field symbols, and dynamically assign the values from the table to the field symbol and build a string by concatenating the fields
CONCATENATE <f01> <f02> .....<fn> into <str> SEPERATED BY cl_abap_char_utilities=>horizontal_tab.
LOOP at Itab INTO wa.
.....
ASSIGN (var) to <fs1>.
.....
* Build the string
ENDLOOP.
04-10-2012 8:42 AM
Dear sankara,
for this u nee to Give position(length) as like fallows and u wii get output as like u want.
DATA: BEGIN OF i_gr OCCURS 0,
gr(96),
END OF i_gr.
LOOP AT I_IKPF.
i_gr+0(12) = i_ikpf-matnr.
i_gr+12(4) = i_ikpf-lgort.
i_gr+16(8) = date.
i_gr+40(5) = i_ikpf-meins.
i_gr+71(11) = i_ikpf-iblnr.
i_gr+86(2) = '10'.
i_gr+88(4) = i_ikpf-iblnr+6(4).
i_gr+92(4) = i_ikpf-posnr.
i_gr+94(2) = '60'.
append i_gr.
ENDLOOP.
IF i_gr[] IS NOT INITIAL.
filename ='C:\GR\IDTL.TXT'.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = filename
TABLES
data_tab = i_gr.
Regards,
Siva rama krishna mohan G.
Message was edited by: siva rama