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: 

How 2 add Header & Footer for flat file(.txt) ........

Former Member
0 Kudos

Hi Experts,

hi friends, am generating Flat file for that i want to add Header and Footer,this i want 2 place in application server, how to add any clue pls..

my file should be...

it contains all ICNUM from HR table.. my file foamate willbe..

<Header>

<data>

<Footer>

ex:

< Report Name>

S2334459I

S8473944Z

S7613048G

<Date:Time:no of records>

how to add Header & Footer to this file....any logic pls

thanks in Advance,

sudeer.

1 ACCEPTED SOLUTION

former_member156446
Active Contributor
0 Kudos

use open dataset and get data from app server file into Internal table

use append header to itab index 1. " to add header to internal table

use just append footer to itab. " for footer.

write the file to the same path back again. and check for sy-subrc to 0.

5 REPLIES 5

former_member156446
Active Contributor
0 Kudos

use open dataset and get data from app server file into Internal table

use append header to itab index 1. " to add header to internal table

use just append footer to itab. " for footer.

write the file to the same path back again. and check for sy-subrc to 0.

0 Kudos

Hi Jay,

thank for ur replay,,

as u told is ok for header.

how to add footer for that...

i ve an idia just let me know its ok r not.

suppose in my flat file i ve 10 records,

get the no of records into Count.

for header i can do like

APPEND header TO itab INDEX 1.

For footer: can i do like

v1= count + 1.

APPEND footer TO itab INDEX v1.

is it ok or not..

Thanks ,

sudeer.

0 Kudos

do it this way.

INSERT HEADER INTO ITAB INDEX 1.  " This is your header.

APPEND FOOTER TO ITAB. " This is your Footer

0 Kudos

Hi Friends,

thank u very much...to All....

0 Kudos

Hi sudeer,

ok, let us assume your data is in itab. and suppose it contains 10 records...

so if u want to add an header, just do like

DATA: count TYPE i,

lines TYPE i,

footer(15) TYPE c VALUE ' abapabapabap'.

DESCRIBE itab LINES count. " it gives no of records of itab now count = 10

data: header(10) type c VALUES 'ABCDEFGHIJ'. then,

INSERT header INTO itab INDEX 1.

now ur itab contains 11 records i.e including header(10+1).

For Footer, create one more var like..

lines = count + 2.

INSERT footer INTO itab INDEX lines. " footer will insert at 12th row.

<removed_by_moderator>

sudharsan.

Edited by: Julius Bussche on Oct 11, 2008 7:57 PM