08-26-2011 10:16 AM
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
08-26-2011 10:24 AM
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
08-26-2011 10:25 AM
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
08-26-2011 10:45 AM
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.
08-26-2011 10:51 AM
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
09-30-2011 8:39 AM