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

Remove duplicate values based on condition

Former Member
0 Likes
1,534

Hi There,

I have implimented the BW-BPS upload file functionality, but I require some further enhancements to be done to the file to remove duplicate values.

This is what I have used, and it works, although now I want to remove further fields based on these conditions...

**************Global Data***************************** 

TYPES: BEGIN OF ys_file_fob,

0KNART(4),

0PLANT(4),

ZPLANT(4),

0MATERIAL(25),

ZCNDNRATE(25),

ZCONDCRCY(3),

0SOLD_TO(10),

ZCURRCONV(1),

END OF ys_file_fob.

 

DATA: gt_file_fob TYPE STANDARD TABLE OF ys_file_fob WITH DEFAULT KEY.

********************************************************

SORT gt_file_fob by 0KNART 0PLANT ZCONDCRCY.

DELETE ADJACENT DUPLICATES FROM gt_file_fob COMPARING 0KNART 0PLANT ZCONDCRCY.

 

*------------------------------------------------------------------------------------->>*

 

* Map and merge loaded data

 

LOOP AT gt_file_fob INTO ls_file.

CHECK sy-tabix > 1.

CLEAR ls_data.

The upload file used.

Condition type Plant Sold-to party  Condition Rate Condition Currency 

ZDNH A002 A075 FECR_AGLX 0.25 USD 01.01.2010 31.12.9999

ZDNH A002 A075 FECR_LX 0.25 USD 01.01.2010 31.12.9999

ZDNH B022 B075 FECR_LXF 0.25 USD 01.01.2010 31.12.9999

ZDNH C002 C075 FECR_LXS 0.25 USD 01.01.2010 31.12.9999

ZDNH D042 D075 FECR_REC 0.25 USD 01.01.2010 31.12.9999

ZDNH B002 B075 FECR_RXF 0.25 USD 01.01.2010 31.12.9999

ZDNH E002 E075 FECR_RXS 0.25 USD 01.01.2010 31.12.9999

This is what I have used, and it works, although now I want to remove further fields based on these conditions...all these fields above results should be only one record. Meaning in the original code I removed duplicates excluding material, now I want to remove the records further where all the fields for plant (second column) = *002....to ignore the A, B, C... and filter on the *002 fields.

Hope I explained correctly...hehe, I searched for about two days already and could not find anything, hoping somone can assit.

Best Regards and Thanks

Rudi

1 ACCEPTED SOLUTION
Read only

schneidertho
Product and Topic Expert
Product and Topic Expert
0 Likes
1,333

Hi Rudi,

not sure if I understood the requirements to the full extend: you want to consider A002 and B002 as duplicates, because you want to ignore the first character (A, B) and do the comparison based on the last three characters (002)... right?

Probably this is not the only way... I am not sure, if it is the fastest one... and I am not sure, if there is some specific BW-BPS functionality which might help you.

But what about this idea: You create an additional column in your internal table. You fill this from the plant column. Somehow like this: gs_file_fob-plant2 = gs_file_fob-plant+1(3). Then you do the sort based on this column and then the deletion of duplicates...

Cheers

Thorsten

4 REPLIES 4
Read only

schneidertho
Product and Topic Expert
Product and Topic Expert
0 Likes
1,334

Hi Rudi,

not sure if I understood the requirements to the full extend: you want to consider A002 and B002 as duplicates, because you want to ignore the first character (A, B) and do the comparison based on the last three characters (002)... right?

Probably this is not the only way... I am not sure, if it is the fastest one... and I am not sure, if there is some specific BW-BPS functionality which might help you.

But what about this idea: You create an additional column in your internal table. You fill this from the plant column. Somehow like this: gs_file_fob-plant2 = gs_file_fob-plant+1(3). Then you do the sort based on this column and then the deletion of duplicates...

Cheers

Thorsten

Read only

0 Likes
1,333

Hi, yes you are correct. That is exactly what I want to accomplish. However finding it difficult to impliment...hehe.

If I use the code gt_file_fob-plant2 = gt_file_fob-plant+1(3) I get the error that no header line specified, therefore plant2 does not exist. If I declare the table with header line, it does not seem to work to filter the records out.

Hehe, I get confused with this abap language

Thanks for replying. 

Read only

schneidertho
Product and Topic Expert
Product and Topic Expert
0 Likes
1,333

Hi Rudi,

you could try something like this (only 'pseudo code'... still have not learnt to write syntax error free ABAP without the syntax check 🙂

field-symbols: <gs_file_fob> like line of gt_file_fob.

...

loop at gt_file_fob assigning <gs_file_fob>.

  <gs_file_fob>-plant2 = <gs_file_fob>-plant+1(3).

endloop.

In terms of with header line vs. without header line: strange. I would not have expected any difference in the behavior. But using header lines is a bit old fashioned anyway...

Best regards

Thorsten

Read only

0 Likes
1,333

Mr Thorsten, I am so happy now, you have helped me greatly....thank you sir!! It is working 100%, busy testing further, but sovar so good.

I might have done something wrong with the header lines thing earlier.

Regards

Rudi