Skip to Content
author's profile photo Former Member
Former Member

codeing help

Hi,

I have an internal table itab of fields name1 and land1

itab has 4 records

name1 land1

a 6-a

b 6-b

c 6-cad

d 8-adf

here in itab I don't want the record which is haveing land1 starting other than 6-

my final itab to be

name1 land1

a 6-a

b 6-b

c 6-cad

Edited by: SHIPLA12 1 on Jan 21, 2008 9:44 AM

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

11 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 21, 2008 at 08:47 AM

    Hi,

    Data : land2 type c.

    Loop at itab.

    clear: land2.

    condense itab-land1.

    land2 = itab-land1+0(1).

    If land2 NE '6'.

    Delete itab.

    endif.

    Endloop.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 21, 2008 at 08:51 AM

    Hi,

    loop at it_tab where land1 cp '%6-'.

    write: name1,

    land1.

    endloop.

    Plzz reward points if it helps.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 21, 2008 at 08:51 AM

    Hi Shilpa,

    Please refer below code:

    data : begin of itab occurs 0,

    first type c,

    second(10),

    end of itab.

    itab-first = 'a'.

    itab-second = '6-a'.

    append itab.

    clear itab.

    itab-first = 'b'.

    itab-second = '6-b'.

    append itab.

    clear itab.

    itab-first = 'c'.

    itab-second = '6-cad'.

    append itab.

    clear itab.

    itab-first = 'd'.

    itab-second = '8-adf'.

    append itab.

    clear itab.

    loop at itab.

    if itab-second+0(1) ne '6'.

    delete itab.

    endif.

    endloop.

    Piyush

    Reward points, if helpfull

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 21, 2008 at 08:52 AM

    Hi Shilpa,

    Try this ,

    Hi,

    Data : land1 type c.

    Loop at itab.

    clear: land1.

    land1 = itab-land+0(1).

    If land1 NE '6'.

    Delete itab.

    endif.

    Endloop.

    Reward If Useful.

    Regards,

    Chitra Parameswaran

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 21, 2008 at 08:52 AM

    Try this

    delete itab where land1+0(2) ne '6-'.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 21, 2008 at 08:56 AM

    hi shilpa,

    loop at itab where land1 cp '%6-'.

    write: name1,'-',land1.

    endloop.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 21, 2008 at 08:56 AM

    hi,

    check this program...

    DATA:BEGIN OF ITAB OCCURS 0,

    NAME1 LIKE KNA1-NAME1,

    LAND1 LIKE KNA1-LAND1,

    END OF ITAB.

    START-OF-SELECTION.

    ITAB-NAME1 = 'a'.

    ITAB-LAND1 = '6-a'.

    APPEND ITAB.

    CLEAR ITAB.

    ITAB-NAME1 = 'b'.

    ITAB-LAND1 = '6-b'.

    APPEND ITAB.

    CLEAR ITAB.

    ITAB-NAME1 = 'c'.

    ITAB-LAND1 = '6-cad'.

    APPEND ITAB.

    CLEAR ITAB.

    ITAB-NAME1 = 'a'.

    ITAB-LAND1 = '8-adf'.

    APPEND ITAB.

    CLEAR ITAB.

    LOOP AT ITAB.

    IF ITAB-LAND1+0(2) EQ '6-'.

    WRITE:/ ITAB-NAME1,ITAB-LAND1.

    ENDIF.

    ENDLOOP.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 21, 2008 at 08:58 AM

    name1 land1

    a 6-a

    b 6-b

    c 6-cad

    d 8-adf

    DELETE itab WHERE land1(1) NE '6'.

    name1 land1

    a 6-a

    b 6-b

    c 6-cad

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 21, 2008 at 09:03 AM

    when you populate your itab why can't you check if the value to be entered in itab-land1 does have 6 in the first character position or not else you can loop at final itab and then check if any record has land1 starting with 6.

    CONSTANTS: gc_6(1) type c VALUE '6'.

    LOOP at itab into gwa_itab.

    gv_chk = gwa_itab-LAND1+0(1).

    IF gv_chk NE gc_6.

    DELETE ITAB from gwa_itab..

    ENDLOOP....

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 21, 2008 at 09:12 AM

    Hi Shilpa,

    I will develop a entire code for ur question.Check it once.I will execute the below code that is executing successfully.plz copy the below code and execute it and ur problem is solved ok..try to debug the code ok..

    CODE:

    data: begin of itab occurs 0,

    name like kna1-name1,

    land(20) type c,

    end of itab.

    data: land1 type c.

    start-of-selection.

    itab-name = 'a'.

    itab-land = '6-a'.

    append itab.

    itab-name = 'b'.

    itab-land = '6-b'.

    append itab.

    itab-name = 'c'.

    itab-land = '6-cad'.

    append itab.

    itab-name = 'd'.

    itab-land = '8-daf'.

    append itab.

    clear itab.

    end-of-selection.

    loop at itab.

    land1 = itab-land.

    land1 = land1+0(1).

    if land1 ne '6'.

    delete itab index sy-tabix.

    endif.

    endloop.

    loop at itab.

    write:/ itab-name, 10 itab-land.

    endloop.

    Reward points if helpful.

    Kiran Kumar.G.A

    Have a Nice Day

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.