Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

data selection and sorting.

naimkhans_babi
Active Participant
0 Likes
388

Dear friends,,

I m working on problem to fetch data from the database to the internal table based on the selection criteria would you like to give me some idea on it..

what i m doing is, I m searching records from 4 tables and checking first by title if title is match then initial if initial is match then by name_last if the name_last is match then by idnumber then by type then by istype then by zzacc_num so here if i found all seven entries match then it should be moved to one internal table and among seven record if n e one entry is failed to match then it should be moved to another internal table, and if i m found 5 entries matching then it should be left...

so here the problem is

i. to search the records which are matched 0n 7 entries should move to one internal table

ii. to search the records which are matched on 6 entries and not less than 6 then it should be moved to another internal table

iii. rest of the entries left..

thanking you for your time and intrest in my problem i ll be greatfull if you give me some idea. or suggestion or code,, to fix this thing...

thanking you..

regards

naim

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
359

1. First we fetch all the data from 4 database tables into 4 corresponding internal tables ( itab1, itab2, itab3, itab4 ).

2. We have 2 internal tables declared to store entries that match 7 fields and 6 fields ( itab_7match, itab_6match ).

3. We declare two variables as flags ( W_FLAG7, W_FLAG6 ).

3. Now to check if all seven entries are matching.

loop at itab1.

read table itab2 with key <field1> = itab-<field1>

<field2> = itab-<field2>

......

<field7> = itab-<field7>.

if sy-subrc eq 0.

w_flag7 = 'X'.

else.

clear w_flag7.

read table itab2 with key <field1> = itab-<field1>

<field2> = itab-<field2>

......

<field6> = itab-<field6>.

if sy-subrc eq 0.

w_flag6 = 'X'.

else.

clear w_flag6.

continue.

endif.

*C-- Now check if W_FLAG7 or W_FLAG6 is checked, if W_FLAG7 is checked then read itab3 and itab4 with 7 key fields and if the read is successfull populate the entries into itab_7match, if the read is not successfull then clear W_FLAG7 and go to next iteration. (CONTINUE).

or if W_FLAG6 is checked then do read on itab3 and itab4 with 6 fields and populate it to ITAB_6MATCH.

endloop.

2 REPLIES 2
Read only

Former Member
0 Likes
359

Hi Naim,

This is my vague idea (from what i understood).

1) when you do the first matching, keep a "flag" active and keep the flag active if subsequent conditions are met. If any matching fails, then track the number of fails using another variable "count".

2) once the matching is completed for all the 7 conditions, then check for flag active and count. if the count is "0" and flag is active, move it to first_itab. if the count is "1" and flag is active, move it to second_itab. if count is more than 1, ignore them.

I might not be clear but my intention is to use a flag and a counter to keep track of number of matching conditions.

Hope this helps.

Regards,

Vicky

PS: Award points if helpful

Read only

Former Member
0 Likes
360

1. First we fetch all the data from 4 database tables into 4 corresponding internal tables ( itab1, itab2, itab3, itab4 ).

2. We have 2 internal tables declared to store entries that match 7 fields and 6 fields ( itab_7match, itab_6match ).

3. We declare two variables as flags ( W_FLAG7, W_FLAG6 ).

3. Now to check if all seven entries are matching.

loop at itab1.

read table itab2 with key <field1> = itab-<field1>

<field2> = itab-<field2>

......

<field7> = itab-<field7>.

if sy-subrc eq 0.

w_flag7 = 'X'.

else.

clear w_flag7.

read table itab2 with key <field1> = itab-<field1>

<field2> = itab-<field2>

......

<field6> = itab-<field6>.

if sy-subrc eq 0.

w_flag6 = 'X'.

else.

clear w_flag6.

continue.

endif.

*C-- Now check if W_FLAG7 or W_FLAG6 is checked, if W_FLAG7 is checked then read itab3 and itab4 with 7 key fields and if the read is successfull populate the entries into itab_7match, if the read is not successfull then clear W_FLAG7 and go to next iteration. (CONTINUE).

or if W_FLAG6 is checked then do read on itab3 and itab4 with 6 fields and populate it to ITAB_6MATCH.

endloop.