Skip to Content
author's profile photo
Former Member

move from itab1 to itab2 using where clause

i have a internal table it1 which have matnr mtart ............so on fields , but in it2 i want only those matnr where mtart = halb ,for eg

it1

matnr mtart bmtyp stlal

00528 fert 1 1

00529 halb 1 2

00530 halb 1 1

00531 bop 1 3

but in it2 i wnt only

matnr mtart

00529 halb

00530 halb

how can be done ,help plz ,it is urgent, pointswill be rewarded soon

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

11 Answers

  • Best Answer
    Posted on Aug 23, 2007 at 07:14 AM

    You can use where clause to only to retrieve data from database table.

    In your case, you can write code as.

    Loop at it1 where mtart = 'halb'.

    move-corresponding it1 to it2.

    append it2.

    endloop.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Aug 23, 2007 at 07:09 AM

    Hi Sarbjit,

    <b>Assuming wa1 as the header for it1 and wa2 as header for it2.</b>

    Loop at it1 into wa1.

    if wa1-mtart eq 'halb'.

    wa2-matnr = wa1-matnr.

    wa2-mtart = wa1-mtart.

    append wa2 to it2.

    clear wa2.

    endif.

    clear wa1.

    endloop.

    <b>Reward points if this helps,</b>

    Kiran

    Message was edited by:

    Kiran Kumar Somaroutu

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Aug 23, 2007 at 07:11 AM

    Hi,

    Use loop at where on itab1.

    ex:-

    loop at itab1 where mtart = 'halb'.

    append itab1 to itab2.

    endloop.

    assuming itab1 and itab2 are internal tables with header lines.

    Regards,

    Sankar

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Aug 23, 2007 at 07:12 AM

    write a select query by using where clause using mtart and move those to itab2.

    write code like this:

    select * from <itab1> into table <itab2> where mtart = 'halb'.

    you will find the all values in itab2.

    reward if useful.

    kishore

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Aug 23, 2007 at 07:13 AM

    it2[] = it1[].

    DELETE it2 WHERE mtart NE 'HALB'.

    Add comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 23, 2007 at 07:14 AM

    Hi,

    Use like this

    DATA: wa1 like line of itab1, wa2 like line of itab2.
    LOOP AT ITAB1 INTO WA1 WHERE MTART = 'halb'.
    MOVE-CORRESPONDING WA1 TO WA2.
    APPEND WA2 TO ITAB2.
    ENDLOOP.
    

    Regards,

    Sesh

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Aug 23, 2007 at 07:18 AM

    HI sarabjit,

    Loop at itab1.

    read table itab2 with key mtart = itab1-mtart.

    itab2-matnr = itab1-matnr.

    itab2-mtart = itab1-mtart.

    append itab2.

    endloop.

    <b>Regards,

    Azhar</b>

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Aug 23, 2007 at 07:12 AM

    hi try like this,

    loop at itab1 where mtart = 'halb'.

    append itab1 to itab2. or move itab1[] itab[] or move-corresponding itab1[] itab2[]

    endloop.

    based on ur requirement choose any one st .

    if helpful reward some points.

    with regards,

    Suresh Aluri

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Aug 23, 2007 at 07:15 AM

    i think problem is solved

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Aug 23, 2007 at 07:32 AM

    hi,

    try this code:

    types:begin of it1,

    matnr type mara-matnr,

    mtart type mara-mtart,

    *bmtyp type mara-bmtyp,

    end of it1.

    data:it2 type table of it1 with header line.

    data it3 type table of it1 with header line.

    move '222' to it2-matnr.

    move 'halb' to it2-mtart.

    append it2.

    move '223' to it2-matnr.

    move 'halb' to it2-mtart.

    append it2.

    move '224' to it2-matnr.

    move 'hale' to it2-mtart.

    append it2.

    loop at it2 where mtart = 'halb'.

    move it2-matnr to it3-matnr.

    move it2-mtart to it3-mtart.

    append it3.

    endloop.

    loop at it3.

    write:/ it3-matnr, it3-mtart.endloop.

    rgds

    award points if it helps

    Add comment
    10|10000 characters needed characters exceeded