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

How to code this - Please advise

Former Member
0 Likes
665

Dear friends,

Please advise as how to code the below scenario in order to obtain the best performance.

I've an internal table IT_BSAD.Now I've to check if in the combination of bukrs,augbl,auggj,kostl,prctr,gsber,aufnr, if there is a single record in IT_BSAD, then it should be appended to IT_BSAD1 & if there are multiple records, then those should be appended to IT_BSAD2. In any case IT_BSAD1 & IT_BSAD2 should not contain duplicate records & records in IT_BSAD = records in IT_BSAD1 + Records in IT_BSAD2. I coded it somehow but it hangs in case of million of records. Please advise me the best way of doing it.

I'll appreciate any help in this regard.

Thanks:

Gaurav

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
630

prepare a sorted table with key bukrs,augbl,auggj,kostl,prctr,gsber,aufnr

loop it_basd assigning <fs_basd> .

at new sufnr.
lv_index = 0.
endat.

" move the fields to it_basd1 work area

"append it_basd1
lv_index = lv_index + 1.

if lv_index > 1.

if lv_index = 2.
read it_basd1 into iwa_basd2 with key  bukrs,augbl,auggj,kostl,prctr,gsber,aufnr.

append iwa_bsad2 into it_bsad2.

delete from  it_basd1 where  bukrs,augbl,auggj,kostl,prctr,gsber,aufnr.

endif.

" move the fields of <fs_basd> to it_basd2 work area

append iwa_bsad2 into it_bsad2.
endif.



endloop.

hope this will help

Nafran

prepare a sorted table with key bukrs,augbl,auggj,kostl,prctr,gsber,aufnr

loop it_basd assigning <fs_basd> .

at new sufnr.
lv_index = 0.
endat.

" move the fields to it_basd1 work area

"append it_basd1
lv_index = lv_index + 1.

if lv_index > 1.

if lv_index = 2.
read it_basd1 into iwa_basd2 with key  bukrs,augbl,auggj,kostl,prctr,gsber,aufnr.

append iwa_bsad2 into it_bsad2.

delete from  it_basd1 where  bukrs,augbl,auggj,kostl,prctr,gsber,aufnr.

endif.

" move the fields of <fs_basd> to it_basd2 work area

append iwa_bsad2 into it_bsad2.
endif.



endloop.

hope this will help

Nafran

3 REPLIES 3
Read only

Former Member
0 Likes
630

if it is one time selection for bukrs,augbl,auggj,kostl,prctr,gsber,aufn (mean you need to select the value from itab for only one combination of these fields) than you can simply fetch record in another itab and and at the same time do a count.

now based on the count value append the values in the required itab.

Read only

Former Member
0 Likes
631

prepare a sorted table with key bukrs,augbl,auggj,kostl,prctr,gsber,aufnr

loop it_basd assigning <fs_basd> .

at new sufnr.
lv_index = 0.
endat.

" move the fields to it_basd1 work area

"append it_basd1
lv_index = lv_index + 1.

if lv_index > 1.

if lv_index = 2.
read it_basd1 into iwa_basd2 with key  bukrs,augbl,auggj,kostl,prctr,gsber,aufnr.

append iwa_bsad2 into it_bsad2.

delete from  it_basd1 where  bukrs,augbl,auggj,kostl,prctr,gsber,aufnr.

endif.

" move the fields of <fs_basd> to it_basd2 work area

append iwa_bsad2 into it_bsad2.
endif.



endloop.

hope this will help

Nafran

Read only

0 Likes
630

Thanks for the logical answer.