cancel
Showing results for 
Search instead for 
Did you mean: 

How to implement a BRF+ table with unique key?

Former Member
0 Kudos

How can I implement a table with a unique key property in BRF+ or make a table compliant to some unique key constraint?

Use case:

  • I have to execute some expression only once per data entity (identified by a name)
  • Which of these expressions to execute depends on the input data
  • Number of expressions is much greater than data entities
  • Final step: For each unique data entity (name) that had expressions executed, do a data store operation

Normally I would use a HASHED or SORTED TABLE WITH UNIQUE KEY name for this, but BRF+ tables are STANDARD TABLE internally, even when bound to a DDIC table.

Right now I and INSERT only if not.

Since I do not need the table during the intermediate steps, an easier approach could be to SORT the table and then DELETE ADJACENT DUPLICATES. Table operations can sort, but the Table Operations expression does not seem to offer the duplicate deletions.

Accepted Solutions (1)

Accepted Solutions (1)

christianlechne
Active Contributor
0 Kudos

Hi Jürgen,

you are right. Within BRF+ there is operation like „delete adjacent duplicates“ nor in the table operation expression neither in any other expression (leaving out an procedure call expression that calls ABAP coding).

I am not 100% sure if I understand your use-case completely, but I give it a try how I would solve the requirement: I guess each expression corresponds to a rule within a ruleset.  In order to check which rule has to be executed the “IF”-statement of the rule is used. The condition checks if the input parameters meet the condition for the rule execution.

In addition you need a control table (CT1) which contains the information entity name (as unique identifier), expression ID (I would guess that this is an expressive ID like “Derive xyz”, not the GUID) executed for entity (yes/no) and a second control table (CT2) where the information is stored if the entity has to be persisted or not.


The flow would then be:

  • Iterate over the entities within the ruleset
  • In the rule the IF condition checks if the expression should be executed or not. This comprises the check of the input parameters, the table CT1 if only one execution per entity is allowed
  • In the execution of the “THEN”-branch the business logic is executed, the table CT1 is filled with the information that the entity and the rule/expression were executed.
    Then check the table CT2 and check if an entry exists: if yes, nothing has to be done, if no add an entry with the entity.
  • After iterating over all entities, loop over table CT2 and do the persistency

Hope that helps (and also that I did not get you completely wrong)

BR

Christian 

Former Member
0 Kudos

Hello Christian,

that's pretty much my requirement and my current solution. (Have you been on my system?! ).

Anyways, important thing is you said that DELETE DUPLICATES is not in BRF+ right now, thus sparing me the embarrassment of having overlooked yet another feature.

I'll consider doing an OSS on this one.

Thx a lot

Jürgen

christianlechne
Active Contributor
0 Kudos

Hi Jürgen,

honestly I was not on your system, but I am happy that I understood your requirement 🙂

Before opening an OSS I would recommend to get in touch with . Perhaps he has a clever idea on that topic (which is usually the case)

BR

Christian

Answers (0)