cancel
Showing results for 
Search instead for 
Did you mean: 

Counting the records in transformation routine.

Former Member
0 Kudos

Hello Guys,

I have some weird requirement i have one dso like A which have keys Visitid, Tour id, doc no and doc item. So the data for this dso can be:

Visit id     Tourid     DocNo          DocItem

1004          11          001               10

1004          11          002               20

1004          11          003               10

1005          12          004               30

1005          12          005               40.

Now we are taking visitid and tourid in start routine and checking if the combination is present in another dso if yes then we are updating the keyfigure with 1 otherwise 0.

Now with above data we will have 1 to all first three records I want some thing like eventhough i have three records for keys combination in dso it should populate 1 to keufigure based upon visitid and tourid. Like for above frst three reocrd, keyfigure should be updated with 1 only once based upon unique combination of visitid and tourid.

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi Deepak,

1) First select the all records from DSO from where you want look up and put into an internal table lt_data.

2) Sort and delete adjacent duplicates comparing key so you will be having unique records in the internal table.

3) In your DTP put the semantic key for these 2 key fields so for same keys data will come into same data package.

4) Loop at data package into field_symbol.

Read table lt_data into internal table where key fields

                              binary search.

if sy-subrc = 0.

Assign the value.

Endif

Endloop.

Hope this will help.

Best Regards,

Kamal

Former Member
0 Kudos

Hi Deepak,

Once u have internal table with above data, u can sort the table based on VisitID and TourID. Then go for DELETE ADJACENT command to delete duplicate records. Finally u will have table with unique records and then u can update the keyfigure. This approach is helpful concerning performance tuning.

May help u.

Regards,

Avadhoot

former_member183012
Active Contributor
0 Kudos

Hi Deepak,

We have also having similar kind of requirement.To achive this you need to first change your DTP In semantic group you need to tick  Visit id menas on based on this key you unique records will come in to one source package based on semantic key..some times it will come in diffrent source package thats why we nee to do this setting to avoid same key combination in diffrent package.

after that loop at your source pacakge

use  AT NEW Visit id statement in code and modify your key figure to 1.it will update 1for every new record visit Id in this way you will achive your requirement.

hope it will help.

Regards,

Ganesh Bothe

former_member185132
Active Contributor
0 Kudos

Hi Deepak,

In the code, you probably have an internal table that contains the contents of the other DSO, and are doing a READ statement on the ITAB to identify if there is a matching combination in the other DSO. So you could achieve your requirement by deleting the itab entry once you make your kf value as 1.

This way, once the code finds a matching record for one combination, it will delete the record from the lookup itab. The next time it comes across the same combination, the corresponding record won't be present in the lookup itab. The code will roughly look like below.

LOOP AT Result_package assigning <result_fields>.

     READ itab_other_dso transporting no fields add your search criteria.

     IF sy-subrc = 0.

          delete itab_other_dso index sy-tabix.         

          <result_fields>-your_key_figure = 1.                  

     ENDIF.

ENDLOOP.

Regards,

Suhas

former_member182470
Active Contributor
0 Kudos

Why don't you simply use DISTINCT statement in your Code while calculating "Count" ?