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

Clear header

Former Member
0 Likes
2,126

Hi,

In my code the value there are 2 values in a internal table.The value in header is 0 but the next two lines have values in it.I have given the codn such that "if the internal table in not initial it must perform some actions" but though the table has value and as the header value is 0 its not performing the action.How to remove the 0 value.I tried with clear also its not working ou

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,990

Hi,

You should write the code in below way. Consider ITAB is your internal table.

IF not ITAB[] is initial.

do some processing.

ENDIF.

Remember [] indicates internal table body. Internal table having Header & Body. Header contains one record at a time whereas body can multiple.

Regards,

Amit

14 REPLIES 14
Read only

Former Member
0 Likes
1,990

hi,

refresh the header..for better solution..please paste ur code..

Rgds.,

subash

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,990

Hello Saranya,

You wrote:

if the internal table in not initial it must perform some actions

Try the stmt as:


IF ITAB[] IS NOT INITIAL.
* Code ur logic
ENDIF.


To address the table body instead of the header line in a statement, you can append [] e.g., ITAB[]

For internal tables without header line, the table body is always used

BR,

Suhas

Edited by: Suhas Saha on Feb 4, 2009 3:08 PM

Read only

Former Member
0 Likes
1,990

Hi,

Refresh: itab will clear the header.

Cheers,

Surinder

Read only

Former Member
0 Likes
1,990

Hi,

You might have declared the internal table with header line..so in that case your condition should be like this ..

IF NOT itab[] IS INITIAL.
" Do processing
ENDIF.

Read only

Former Member
0 Likes
1,990

hi,

Make sure that the check your performing is with respect to the body of the table

i.e.

if you are using a internal table with a header line, the condition should go like this

if t_tab[] is not initial.

endif.

where t_tab is a internal table with header line and if the table has got entries in it this condition shall work.

Read only

faisalatsap
Active Contributor
0 Likes
1,990

Hi,

Test the following Code hope will solve out your problem,

TYPES: BEGIN OF t_test,
  name(50),
END OF t_test.

DATA: it TYPE STANDARD TABLE OF t_test WITH HEADER LINE.

it-name = 'AAA'.
APPEND it TO it.
it-name = 'BBB'.
APPEND it TO it.
it-name = 'CCC'.
APPEND it TO it.

CLEAR: it,    " TO clear the Header
       it[].  " To Clear the Body.


IF it IS INITIAL.

  WRITE: / 'Header is Clear'.

ENDIF.

IF it[] IS INITIAL.

  WRITE: / 'Body is Clear'.

ENDIF.

Kind Regards,

Faisal

Edited by: Faisal Altaf on Feb 4, 2009 2:38 PM

Read only

0 Likes
1,990

Code is

loop at gi_final.

clear gi_table.

if gt_table is not initial.

perform process.

endif.

endloop.

the value present in gi_table is

0000

000

00000000

00000000

0

0.00

0071 |**** |*********|** |*******|*******| 0 | 0.00 |

Read only

0 Likes
1,990

if gt_table is not initial.

right

if gi_table is not initial.

and loop at gi_table only to have value in the header.

Cheers,

Surinder

Edited by: SURINDER SINGH OBEROI on Feb 4, 2009 3:15 PM

Read only

0 Likes
1,990

Have declared gt_final as internal table as

DATA: BEGIN OF gt_final OCCURS 0,

some fields

end of gt_final

Read only

0 Likes
1,990

hi,

taking gt_final as ur internal table,

gt_table as ur header...

so in order to check whether ur internal table has values or not..

u should write

if gt_final[] is not initial.

perform process..

endif..

to clear 0's in ur header , u can refresh it...

Rgds.,

subash

Read only

0 Likes
1,990

what is gi_table???

Cheers,

Surinder

Read only

Former Member
0 Likes
1,990

Check if you have given [] after ITAB.

Read only

Former Member
0 Likes
1,990

Hi Saranya,

As far as i have understood you are using a table with header line....

If so.... then please check if your condition with if is similar to the one give below

data: itab type table of <structure_name> with header line.

if itab[] is not initial.

        • your statement follows here *****

endif.

hope this resolves your issue

Regards,

Siddarth

Read only

Former Member
0 Likes
1,991

Hi,

You should write the code in below way. Consider ITAB is your internal table.

IF not ITAB[] is initial.

do some processing.

ENDIF.

Remember [] indicates internal table body. Internal table having Header & Body. Header contains one record at a time whereas body can multiple.

Regards,

Amit