Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

gui_download tab delimited file

former_member184741
Active Contributor
0 Kudos

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

9 REPLIES 9

Former Member
0 Kudos

Hi,

One way: define a table with 10 string fields and use parameter WRITE_FIELD_SEPARATOR...

Cheers,

Manu.

0 Kudos

it does not work

0 Kudos

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.

Former Member
0 Kudos

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

0 Kudos

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.

0 Kudos

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

0 Kudos

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

ShyamPindiproli
Active Participant
0 Kudos

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.

Former Member
0 Kudos

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