‎2009 May 14 2:24 PM
Hi experts,
Can some one help with small problem.
i need to count entries(no) and put into one varibale after deleting first 4 values from the itab.
LOOP AT ITAB.
COUNTER = COUNTER + 1.
IF COUNTER > 4.
EXIT.
ENDIF.
DELETE ITAB INDEX SY-TABIX.
ENDLOOP.
This is working fine up to deleting 4 values from itab.
after that i want to store the no enetries remaining in the itab into one variable.
How can we do it?
say itab having 40 entries after deleting first 4 i have to store 36 entries as a no into "one variable".
I used DESCRIBE TABLE itab LINES N.
but it is giving only "4".
why?
Thanks.
Sailu
‎2009 May 14 2:30 PM
LOOP AT ITAB.
COUNTER = COUNTER + 1.
IF COUNTER <= 4.
DELETE ITAB .
ENDIF.
Append itab
ENDLOOP.
Hope this will solve ur problem...
‎2009 May 14 2:30 PM
LOOP AT ITAB.
COUNTER = COUNTER + 1.
IF COUNTER <= 4.
DELETE ITAB .
ENDIF.
Append itab
ENDLOOP.
Hope this will solve ur problem...
‎2009 May 14 2:34 PM
Hi Try this.
Delete itab index 1.
Delete itab index 2.
Delete itab index 3.
Delete itab index 4.
Then try describe table itab lines lv_lin.
you will get the no of entries in lv_lin.
Regards,
Sharath
‎2009 May 14 2:39 PM
IN MY CODE I AM USING LIKE THAT
LOOP AT ITAB.
COUNTER = COUNTER + 1.
IF COUNTER > 4.
EXIT.
ENDIF.
DELETE ITAB INDEX SY-TABIX.
ENDLOOP.
DESCRIBE TABLE itab LINES N.
CONCATENATE text-001 g_text N text-002
INTO g_lang SEPARATED BY space.
But inconcatenate "N" is not alowing because n is DATA:N type I.
I want "N" value in my concatenate statement.
How we going to convert?
Thanks.
‎2009 May 14 2:42 PM
move it to a character variable.
DATA:
w_lines type i,
w_char(2) type c.
DESCRIBE TABLE itab LINES w_lines.
w_char = w_lines.
‎2009 May 14 2:45 PM
you can move any type of variable to a character varaible and then use it in concatenate. You can do the same here as well by passing integer variable in a caharacter variable.
‎2009 May 14 2:47 PM
It is giving "char " value as a "*"(star) not exactly converting.
‎2009 May 14 2:49 PM
‎2009 May 14 2:50 PM
increase the length of your character variable. means something like char(10) means your char variable should be of enough length to hold the integer value otherwise it will give *.
‎2009 May 14 2:54 PM
Hi,
It is because of the length in char field.Change the declaration according to the no. of lines.
DATA:
w_lines type i,
w_char(5) type c.
‎2009 May 14 2:31 PM
it is working fine..
DATA : counter TYPE i,
counter1 TYPE i.
DATA itab TYPE but000 OCCURS 0 WITH HEADER LINE.
SELECT * FROM but000 INTO TABLE itab UP TO 10 ROWS.
LOOP AT itab.
counter = counter + 1.
IF counter > 4.
EXIT.
ENDIF.
DELETE itab INDEX sy-tabix.
ENDLOOP.
DESCRIBE TABLE itab LINES counter1.
WRITE / counter1.
‎2009 May 14 2:35 PM
Hello,
Instead doing loop and all. Use delete statement using from and to.
DELETE ITAB FROM 1 to 4. See help for delete statements.
Try to debug the logic, you can know what exactly happening and you can fix it yourself.