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: 

Small doubt in Internaltable...

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

faisal_altaf2
Active Contributor
0 Kudos

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

3 REPLIES 3

Former Member
0 Kudos

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

Former Member
0 Kudos

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

faisal_altaf2
Active Contributor
0 Kudos

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