Application Development and Automation 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: 
Read only

Need to create CSV file.

Former Member
0 Likes
536

Hi,

I have requirement to create csv file which has two headers, one body and one trailer. First header has 5 fields. Second header has 58 fields. Body has 58 fields. Trailer has 2 fields. If i'll create 4 internal tables then can you please tell me how I can be able to append all these internal tables one by one to the csv file?. Also csv file should be separated by ^, how to do this ? Sample code would be helpful.

thanks.

1 ACCEPTED SOLUTION
Read only

former_member212705
Active Participant
0 Likes
490

Hi Abap Guy,

Create one final output table gi_output type c length 1500 (or according to urs).

gw_hearder1 - 5 fields

gw_header2 - 58 fields

gi_body - 58 fields

gw_trailer - 2 fields

first append first header

concatenate gw_headr-field1

                   gw_header-field2

                   .......

                   gw_header-field5

                 into gw_output-data seperated by <your delimiter>.

append gw_output to gi_output.

now append second header similar as above.

now loop over your main body table

loop at gi_body into gw_body.

concatenate gw_body-field1

                   .......

                   gw_body-fieldn

                  into gw_output-data seperated by <delimiter>

append gw_output to gi_output.

i hope this wil solve your issue.

thanks

A. trivedi

Hi,

I have requirement to create csv file which has two headers, one body and one trailer. First header has 5 fields. Second header has 58 fields. Body has 58 fields. Trailer has 2 fields. If i'll create 4 internal tables then can you please tell me how I can be able to append all these internal tables one by one to the csv file?. Also csv file should be separated by ^, how to do this ? Sample code would be helpful.

thanks.

2 REPLIES 2
Read only

rosenberg_eitan
Active Contributor
0 Likes
490

Hi,

Have a look here:

http://scn.sap.com/servlet/JiveServlet/download/14388283-193968/y_r_eitan_test_71_01.txt.zip

http://scn.sap.com/message/14388283#14388283

Specially to FORM wrt_data_1 .

You can change cl_abap_char_utilities=>horizontal_tab to your delimeterif you want.

Regards.

Read only

former_member212705
Active Participant
0 Likes
491

Hi Abap Guy,

Create one final output table gi_output type c length 1500 (or according to urs).

gw_hearder1 - 5 fields

gw_header2 - 58 fields

gi_body - 58 fields

gw_trailer - 2 fields

first append first header

concatenate gw_headr-field1

                   gw_header-field2

                   .......

                   gw_header-field5

                 into gw_output-data seperated by <your delimiter>.

append gw_output to gi_output.

now append second header similar as above.

now loop over your main body table

loop at gi_body into gw_body.

concatenate gw_body-field1

                   .......

                   gw_body-fieldn

                  into gw_output-data seperated by <delimiter>

append gw_output to gi_output.

i hope this wil solve your issue.

thanks

A. trivedi