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: 

Delete footer / last record from CSV file

Former Member
0 Kudos

This is for loading data into ODS.

I have a flat file with footer and want to Delete/ Remove it before loading data in ODS writing code in Transfer Routine. Footer looks like:

********END OF FILE****************

How to remove this footer in the routine? Because of this I am getting error saying last record has bad data. Also how can I delete empty line?

Thanks.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hi,

if you are loading the data on to any internal table ... then do this way ..


data : v_lines type i.
describe table it_upload lines v_lines.

loop at it_upload.
  if sy-tabix = v_lines.
   delete it_upload index sy-tabix.
 endif.
endloop. 

Regards,

Santosh

5 REPLIES 5

Former Member
0 Kudos

hi,

if you are loading the data on to any internal table ... then do this way ..


data : v_lines type i.
describe table it_upload lines v_lines.

loop at it_upload.
  if sy-tabix = v_lines.
   delete it_upload index sy-tabix.
 endif.
endloop. 

Regards,

Santosh

former_member181962
Active Contributor
0 Kudos

HI Mau,

Assume that the data is uploaded into your internal table ITAB.

describe table itab lines count.

delete itab index count.

Regards,

Ravi Kanth

0 Kudos

My code is like:

DATA: l_datapak like line of datapak.

Loop at datapak into l_datapak.

Condense l_datapak-Field1.

Modify datapak from l_datapak.

Endloop.

After Condense statement I want to delete the end of line which is footer (************END OF FILE************).

What should I write in the above code?

Thanks.

0 Kudos

Just delete the last line in the LOOP.

(The CONDENSE won't help much without a MODIFY.)

Rob

0 Kudos

try to do that:

data : lines type i.
describe table datapak lines lines.

Loop at datapak into l_datapak.
  Condense l_datapak-Field1.

  IF sy-tabix EQ lines.
    DELETE l_datapak FROM datapak.
  ENDIF.
Endloop.