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

Fetch records from internal table

HI

I HAVE ONE INTERNAL TABLE ITAB_ERR. THIS HAS RECORDS AND I AM FETCHING DATA FROM ISEG AS WELL.

WHAT I WANT IS I NEED TO FETCH THE RECORDS FROM

ITAB_ERR WHOSE RECORDS DO NOT MATCH WITH ISEG TABLE RECORDS.

I HAVE WRITTEN FOLLOWING CODE BUT IT DOES NOT FETCH THE RECORDS FROM ITAB_ERR THAT DOES NOT MATCH WITH ISEG RECORDS i.e. ITAB_ERR HAS SOME RECORDS WHICH ARE NOT THERE IN ISEG AND I NEED TO FETCH THOSE RECORDS FROM ITAB_ERR.

PLEASE LOOK AT MY CODE AND CORRECT OR SUGGEST CORRECTIONS.

ITAB_ERR[] = ITAB_UPD[]. (ITAB_ERR HAS RECORDS)

SELECT *

FROM ISEG INTO CORRESPONDING FIELDS OF TABLE WA_ITAB_ISEG

where werks eq zptf_phyinv_hed-zwerks and zldat eq itab-zldat and budat eq itab-zbldat.

  • WA_ITAB_ISEG HAS RECORDS.

clear sy-subrc.

sort itab_err by zmatnr1.

LOOP AT WA_ITAB_ISEG.

loop at itab_err INTO ITAB_DEL

where ZWERKS <> WA_ITAB_ISEG-WERKS

and ZLDAT <> WA_ITAB_ISEG-ZLDAT

and ZBLDAT <> WA_ITAB_ISEG-BUDAT

and ZMATNR1 <> WA_ITAB_ISEG-MATNR

and ZCHARG1 <> WA_ITAB_ISEG-CHARG

and ZLGORT <> WA_ITAB_ISEG-LGORT.

IF SY-subrc = 0.

move-corresponding ITAB_err to itab_del2.

append itab_del2.

CLEAR SY-SUBRC.

ENDIF.

ENDLOOP.

ENDLOOP.

THANX

ROCKY

Edited by: Alvaro Tejada Galindo on Mar 19, 2008 7:04 PM

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Mar 19, 2008 at 11:44 AM

    Hi,

    during selection in where condition u have compared using internal table. Compare using work Area Fields.

    Secondly, You have looped at work-area but i think loop is possible on internal table to workarea.

    Thirdly, Dont' use loop within a loop.(performance Issue)

    regards

    Sandipan ghosh

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 19, 2008 at 11:48 AM

    Write the coding as :

    LOOP AT ITAB_ERR.

    READ TABLE WA_ITAB_ISEG with key

    ZWERKS = ITAB_ERR-WERKS.

    If sy-subrc <> 0.

    itab_err1 = ITAB_ERR.

    append itab_err1.

    Endif.

    ENDLOOP.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 20, 2008 at 02:39 AM

    Try This,

    LOOP AT WA_ITAB_ISEG.

    loop at itab_err INTO ITAB_DEL

    where ZWERKS WA_ITAB_ISEG-WERKS

    and ZLDAT WA_ITAB_ISEG-ZLDAT

    and ZBLDAT WA_ITAB_ISEG-BUDAT

    and ZMATNR1 WA_ITAB_ISEG-MATNR

    and ZCHARG1 WA_ITAB_ISEG-CHARG

    and ZLGORT WA_ITAB_ISEG-LGORT.

    DELETE itab_err FROM ITAB_DEL.

    ENDLOOP.

    ENDLOOP.

    Now the itab_err will contains only the records which you required.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 20, 2008 at 02:47 AM

    Hi,

    LOOP AT WA_ITAB_ISEG.

    loop at itab_err INTO ITAB_DEL

    where ZWERKS WA_ITAB_ISEG-WERKS

    and ZLDAT WA_ITAB_ISEG-ZLDAT

    and ZBLDAT WA_ITAB_ISEG-BUDAT

    and ZMATNR1 WA_ITAB_ISEG-MATNR

    and ZCHARG1 WA_ITAB_ISEG-CHARG

    and ZLGORT WA_ITAB_ISEG-LGORT.

    move-corresponding ITAB_DEL to itab_del2.

    append itab_del2.

    ENDIF.

    ENDLOOP.

    ENDLOOP.

    No need of SY-SUBRC if condition satisfies then only cursor enter into loop.

    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.