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: 

Download to Excel with Header but one field data is repeating

Former Member
0 Kudos

Hi All,

I'm downloading to Excel with Header. But One field is repeating and another is not. This is happening only when I use 'CONCATENATE ' . With Out this key usage data download to excel is correct. But CONCATENATE is required as constant need to add before the one field.

My coding is as below.

DATA: BEGIN OF IT_FINAL OCCURS 0,

P1(10) TYPE C,

SI(19) type c,

END OF IT_FINAL.

DATA : BEGIN OF IT_HEADER OCCURS 0,

TITLE(100) TYPE C,

END OF IT_HEADER,WA_HEADER LIKE IT_HEADER.

loop at it_final.

CONCATENATE '894412' it_final-SI INTO IT_FINAL.

modify it_final.

endloop.

CLEAR:WA_HEADER.

WA_HEADER-TITLE = 'Mat No'.

APPEND WA_HEADER TO IT_HEADER.

CLEAR:WA_HEADER.

WA_HEADER-TITLE = 'Serial'.

APPEND WA_HEADER TO IT_HEADER.

CALL FUNCTION 'MS_EXCEL_OLE_STANDARD_DAT'

EXPORTING

FILE_NAME = P_FILE " path offile where u need to download

TABLES

DATA_TAB = IT_FINAL

FIELDNAMES = IT_HEADER.

CALL FUNCTION 'MS_EXCEL_OLE_STANDARD_DAT'

EXPORTING

FILE_NAME = P_FILE " path offile where u need to download

TABLES

DATA_TAB = IT_FINAL

FIELDNAMES = IT_HEADER.

Excel OUT PUT:

Mat No Serial

11Z52321 8944126000

11Z52394 8944126000

11Z52395 8944126000

Thank You,

Pranitha

5 REPLIES 5

former_member222709
Contributor
0 Kudos

Hi,

The field is not repeating, but your Modify statement is changing the entire Internal Table.

Use INDEX clause in your Modify statement.

Regards,

Pranav.

Edited by: Pranav Mandelia on Aug 26, 2011 2:55 PM

Former Member
0 Kudos

hi,

it would have been better if u hve opt for creating workarea for ur internal table.

Try to use "clear it_final" after

CONCATENATE '894412' it_final-SI INTO IT_FINAL.

n also change the modify statement :

modify it_final transporting SI .

hope this will surely help you

Regards,

Punit

Edited by: punit raval on Aug 26, 2011 2:55 PM

former_member213437
Active Participant
0 Kudos

Hi Pranitha,


loop at it_final.
CONCATENATE '894412' it_final-SI INTO IT_FINAL.   " Wrong : Assign it to some field not for the entire internal table
modify it_final.
endloop.

Regards,

Murthy.

former_member404244
Active Contributor
0 Kudos

Hi,

You need to change your code.



loop at it_final.
v_index = sy-tabix
CONCATENATE '894412' it_final-SI INTO IT_FINAL-SI .(assuming SI is the field you are concatenating)
modify it_final index v_index.
endloop.

Regards,

Nagaraj

Former Member
0 Kudos

Thanks for inputs..