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

Delete data from internal table?

Hi,

I have an internal table T as following:

-


DATA: BEGIN OF t OCCURS 0,

bukrs LIKE knb1-bukrs,

zuonr LIKE bsid-zuonr, "sort key "CR01

belnr LIKE bsid-belnr,

kunnr LIKE kna1-kunnr,

bldat LIKE bsid-bldat,

budat LIKE bsid-budat,

netdt LIKE bsega-netdt,

waers LIKE bsid-waers,

wrbtr LIKE bsid-wrbtr,

shkzg LIKE bsid-shkzg,

xblnr LIKE bsid-xblnr, "WD041005a

sgtxt LIKE bsid-sgtxt,

dmbtr LIKE bsid-dmbtr,

END OF t.

DATA : t1 LIKE STANDARD TABLE OF t WITH HEADER LINE.

DATA : BEGIN OF t3 OCCURS 0,

kunnr TYPE kna1-kunnr,

END OF t3.

...................

End-of-selection.

SORT t.

  • REFRESH t3.*

LOOP AT t WHERE xblnr EQ space. "change from belnr to xblnr by LI_Y 2008/01/16

t3-kunnr = t-kunnr.

APPEND t3.

ENDLOOP.

SORT t3.

DELETE ADJACENT DUPLICATES FROM t3.

LOOP AT t.

READ TABLE t3 WITH KEY kunnr = t-kunnr BINARY SEARCH.

IF sy-subrc EQ 0.

MOVE-CORRESPONDING t TO t1.

APPEND t1.

DELETE t.

ENDIF.

ENDLOOP.

-


The outcome like this:

KUNNR XBLNR

11111 SPACE

11111 A1B2C3

11111 DEF34

22222 SPACE

22222 0980

33333 98987

33333 78648

44444 9804

My problem is that

*The first KUNNR (11111) which has space value was deleted,

But the second KUNNR (22222) which has space value can not be deleted.*

My Question

Is there any problem in my refresh t3?

How to correc the coding inorder to deleted all the recording of KUNNR which XBLNR has space value there????

Please help?

Thank you!!

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 18, 2008 at 05:28 AM

    hi.,

    use delete t3 where XBLNR = Space.

    Reward points if useful

    Chandra

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 18, 2008 at 05:29 AM

    Hi,

    Use this statement.

    delete itab where xblnr is initial.

    regards,

    Santosh Thorat

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 18, 2008 at 05:33 AM

    Hi,

    Use the following statement.

    Delete itab where XBLNR eq 'SPACE'.

    Should work.

    Regards,

    Lalit

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 18, 2008 at 05:44 AM

    hi studyabap,

    after reading your code i can understand ur problem.The first problem i.e., is there any problem in refresh t3. yes problem is there better you can use the below statement.

    delete t3 where XBLNR = Space

    and i think now it will work.and automatically your other problems also solved if u use this statement.

    kindly reward me if it's ok

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 18, 2008 at 05:33 AM

    Hi Study

    DATA: BEGIN OF t OCCURS 0,

    bukrs LIKE knb1-bukrs,

    zuonr LIKE bsid-zuonr, "sort key "CR01

    belnr LIKE bsid-belnr,

    kunnr LIKE kna1-kunnr,

    bldat LIKE bsid-bldat,

    budat LIKE bsid-budat,

    netdt LIKE bsega-netdt,

    waers LIKE bsid-waers,

    wrbtr LIKE bsid-wrbtr,

    shkzg LIKE bsid-shkzg,

    xblnr LIKE bsid-xblnr, "WD041005a

    sgtxt LIKE bsid-sgtxt,

    dmbtr LIKE bsid-dmbtr,

    END OF t.

    DATA : t1 LIKE STANDARD TABLE OF t WITH HEADER LINE.

    DATA : BEGIN OF t3 OCCURS 0,

    kunnr TYPE kna1-kunnr,

    END OF t3.

    ...........................................

    End-of-selection.

    Sort t by XBLNR.

    read table t where xblnr is initial.

    if sy-subrc eq 0.

    delete t where kunnr = t-kunnr.

    endif.

    SORT t3.

    DELETE ADJACENT DUPLICATES FROM t3.

    LOOP AT t.

    READ TABLE t3 WITH KEY kunnr = t-kunnr BINARY SEARCH.

    IF sy-subrc EQ 0.

    MOVE-CORRESPONDING t TO t1.

    APPEND t1.

    DELETE T.

    ENDIF.

    ENDLOOP.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 18, 2008 at 07:42 AM

    YOU CAN MAKE USE OF THIS STATEMENT

    delete t3 where XBLNR = Space.

    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.