05-02-2009 7:01 AM
Hi Experts,
I have an internal table called i_text with one text field. The content of the internal table is
itext_
This is the test information
This is the 1st line
This is the 2nd line
This is the 3rd line
This is the 4th line
My problem is i need to remove the 1st line of the internal table and i need to move the 1st line. Remaining lines i needed in the same internal table. That means i need remove This is the test information from the internal table and move the line into another local variable. Remaining lines i needs as itis.
I deleted with sy-index. But its deleting every line one by one dueto the loop.
Anyone guide me pls.
Mohana
05-02-2009 7:15 AM
HI,
Test the Sample Code bellow.
DATA: BEGIN OF it OCCURS 10,
char(30),
END OF it,
local_var(30).
it-char = 'Test'. APPEND it. it-char = 'Line 1'. APPEND it. it-char = 'Line 2'. APPEND it.
READ TABLE it INDEX 1.
local_var = it-char.
DELETE it INDEX 1.
LOOP AT it.
WRITE: / it-char.
ENDLOOP.
WRITE: / 'Local Var = ',local_var.
Hope will Solve out your Problem.
Best Regards,
Faisal
05-02-2009 7:08 AM
Hi...
do following steps...
LOOP AT ITAB INTO WA_ITAB.
IF SY-INDEX EQ 1.
HERE WRITE USE DELETE CODE
DELETE ITAB FROM WA_ITAB.
THEN ASSIGN THIS WORK AREA field value TO ANOTHER variable SUPPOSE ITS v_i_text SAMe type i_text field.
v_i_text = WA_ITAB-i_text.
ENDIF.
ENDLOOP.
Hope this helps..
Regards,
Chintan.
Edited by: Chintan_SAP on May 2, 2009 11:38 AM
Edited by: Chintan_SAP on May 2, 2009 11:42 AM
05-02-2009 7:09 AM
Hi Mohana,
try below
data: lv_flag type c.
clear lv_flag.
loop at itab into wa_tab.
if sy-tabix = 1 and lv_flag NE 'X'.
delete itab from wa_tab.
lv_flag = 'x'. "Need to set the flag
else.
"do your process
endif.
endloop.
It works.
Thanks!
Edited by: Prasanth Maddela on May 2, 2009 11:40 AM
05-02-2009 7:15 AM
HI,
Test the Sample Code bellow.
DATA: BEGIN OF it OCCURS 10,
char(30),
END OF it,
local_var(30).
it-char = 'Test'. APPEND it. it-char = 'Line 1'. APPEND it. it-char = 'Line 2'. APPEND it.
READ TABLE it INDEX 1.
local_var = it-char.
DELETE it INDEX 1.
LOOP AT it.
WRITE: / it-char.
ENDLOOP.
WRITE: / 'Local Var = ',local_var.
Hope will Solve out your Problem.
Best Regards,
Faisal