Skip to Content

internal table searching

Dear firends!!!

I am working on a problem in which i am supposed to collect exact similar records and almost similar record in two seprate internal table... say for example i have 7 fields if they are match 7/7 they should move to one internal table where i have 6/7 matching fields then they should move to another internal table here i have the 7/7 matching fields in one internal tale but where i am trying to fetch another 6/7 it gives me all the matching entries where i am supposed to have only entries which are 6/7 matching... if 5/7 is there the i am not supposed to transfer the entries... i am giving you my code... please help me in this regards. I search the records this way.

// for 90% matching records.

Copy the contents of i_bp_p into another table say i_bp_p_temp.

First sort i_bp_p_temp by 7 fields.

loop at i_bp_p.

read table i_bp_p_temp using KEY addition for the 7 fields.

if sy-subrc ne 0.

sort i_bp_p_temp again .. this time with 6 fields.

do read again.

if sy-subrc ne 0.

sort i_bp_p_temp again .. this time with 5 fields.

do read again.

.

.

.

endloop.

Table1

Id idnumber name Surname account

A 123456 Mr ABC XYZ A12345

B 123456 Mr ABC XYZ A12345

D 123457 Mr DEF ZXY A12346

E 123457 Miss DEF ZXY A12346

F 123457 Mr DEF ZXY A12347

G 123458 Mr ABD BCA A12348

Table2 “ 100% matching

Id idnumber name Surname account

A 123456 Mr ABC XYZ A12345

B 123456 Mr ABC XYZ A12345

Table3 “ 90% matching

D 123457 Mr DEF ZXY A12346

E 123457 Miss DEF ZXY A12346

F 123457 Mr DEF ZXY A12347

So in the above scenario I have 100 matching record in the table 1 but I don’t have the rest 90% match records… it gaves me all the remaining entries plus one entry from the 100% match record this ways

Table3 “ 90% matching

D 123457 Mr DEF ZXY A12346

E 123457 Miss DEF ZXY A12346

F 123457 Mr DEF ZXY A12347

G 123458 Mr ABD BCA A12348

B 123456 Mr ABC XYZ A12345

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jun 21, 2006 at 06:29 AM

    Hi Naim,

    Best Possible solution is u add addtional field to the internal table.

    Tab Field

    Field1 ----->Any Data Type

    Field2 ----->Any Data Type

    Field3 ----->Any Data Type

    Field4 ----->Any Data Type

    Field5 ----->Any Data Type

    Match_ind --> Type I to indicate number of match.

    Let this is ur table ( With Data )

    Field1 Field2 Field3 Field4 Field5 Match_ind

    --Data --Data --Data --Data --Data --7

    --Data --Data --Data --Data --Data --7

    --Data --Data --Data --Data --Data --6

    --Data --Data --Data --Data --Data --5

    --Data --Data --Data --Data --Data --3

    --Data --Data --Data --Data --Data --2

    --Data --Data --Data --Data --Data --1

    --Data --Data --Data --Data --Data --7

    Suppose if u want read data with 7 Matching Field

    Loop at atab where Match_ind = 7.

    -


    Ur Logic

    Endloop.

    Suppose if u want read data with 5 Matching Field

    Loop at atab where Match_ind = 5.

    -


    Ur Logic

    Endloop.

    and so on .

    in this way u will be able to maintain only one table

    and retrieve data as per need.

    I have seen ur previous post but wasnt ;

    can u paste the code so i can comment on ur code

    for matching BP.

    feel free to ask further question.

    Regards.

    email @

    manoj.baijnath@wipro.com

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 21, 2006 at 06:15 AM

    Hi Naim,

    loop at itab1 into wa_itab1.

    loop at itab2 into wa_itab2.

    if wa_itab1 = wa_itab2.

    append wa_itab1 into itab3.

    delete from itab2.

    endif.

    endloop.

    endloop.

    rgds,

    Prakash

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 21, 2006 at 06:26 AM

    Probably you can make use if Key word

    <b>SEARCH itab FOR g.</b> where sy-fdpos will return 0 if <b>g</b> is found. Using the <b>tabix</b> you will get the position and can reterive the record.

    rgds,

    TM

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 21, 2006 at 06:52 AM

    Hi,

    for 7/7 match write.

    READ TABLE i_bp_p_temp WITH KEY f1 = f1

    f2 = f2

    f3 = f3

    f4 = f4

    f5 = f5

    f6 = f6

    f7 = f7.

    for 6/7 match

    Match the six field with equal and last with unequal

    LIKE.

    READ TABLE i_bp_p_temp WITH KEY f1 = f1

    f2 = f2

    f3 = f3

    f4 = f4

    f5 = f5

    f6 = f6

    f7 <> f7.

    FOR 5/7 match write.

    READ TABLE i_bp_p_temp WITH KEY f1 = f1

    f2 = f2

    f3 = f3

    f4 = f4

    f5 = f5

    f6 <> f6

    f7 <> f7.

    Regards,

    Wasim Ahmed

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 21, 2006 at 06:35 AM

    Hi Naim,

    check the following logic.

    count  = 0.
    loop at itab1 into wa1.
      read table itab2 into wa2
        with key f1 = itab1-f1.
       if sy-subrc = 0.
        count = count + 1.
       endif.
      read table itab2 into wa2
        with key f2 = itab1-f2. 
       if sy-subrc = 0.
        count = count + 1.
       endif.  
      --
      --
      read table itab2 into wa2
        with key f7 = itab1-f7. 
       if sy-subrc = 0.
        count = count + 1.
       endif.
    
    * depending upon count insert the record into itab7by7 or itab6by7 etc
    endloop.

    hope it helps.

    Regards,

    kinshuk

    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.