After we created in part 1 all tables and objects, we can now create a new BAdI to generate the partitions. Go to
the transaction **se19** and create a new implementation with the Name **RSLPO_BADI_PARTITIONING**.

Give the enhancement implementation a name and a short text.

Click **continue** and **save**. Now specify the **BAdI implementation name**, the **implementation class** and the **BAdI
definition**. Select for the BAdI Definition **RSLPO_BADI_PARTITIONING**, click **continue** and **save**.

After that the following screen appears.

Double click the implementation class and the following screen appears. The 6 methods of the class ZCL_DEMO_BADI_PARTITION which we use to define the partitions are displayed in the right panel.

- GET_T_SPO
- GET_T_PART
- GET_T_PART_TEXT
- GET_T_PART_CRIT
- GET_T_PART_PROP
- GET_T_PART_DTP

Each method has a specific role, which you can see under the short description. Double click the method **IF_RSLPO_BADI_PARTITIONING~GET_T_SPO**.

First we have to implement the name of the Semantic Partitioning Object (SPO).

method IF_RSLPO_BADI_PARTITIONING~GET_T_SPO.

DATA:

l_spo TYPE rslponame.

* Return a table with names of supported BAdI SPOs.

SELECT SPONAME from ZSPOINFOPROV into l_spo.

APPEND l_spo TO r_t_spo.

ENDSELECT.

endmethod.

Save and activate the method and the class. Now implement the **IF_RSLPO_BADI_PARTITIONING~GET_T_PART**.

method IF_RSLPO_BADI_PARTITIONING~GET_T_PART.

DATA:

l_cnt TYPE i,

l_posit TYPE i VALUE 1,

l_id TYPE c LENGTH 2,

l_s_part TYPE rslpo_badi_s_part,

* ZSPOINFOPROV Variable

l_it_spoinfoprov TYPE TABLE OF ZSPOINFOPROV,

l_wa_spoinfoprov TYPE ZSPOINFOPROV.

SELECT * from ZSPOINFOPROV into CORRESPONDING FIELDS OF TABLE L_IT_SPOINFOPROV where SPONAME = I_SPO.

Loop at L_IT_SPOINFOPROV into L_WA_SPOINFOPROV.

SELECT COUNT(*) from zspocriteria into l_cnt where PATTERNID = L_WA_SPOINFOPROV-PATTERNID1.

WHILE l_posit LE l_cnt.

UNPACK l_posit to l_id.

l_s_part-IDPART = l_id.

l_s_part-POSIT = l_posit.

APPEND l_s_part TO r_t_part.

l_posit = l_posit + 1.

ENDWHILE.

CLEAR l_posit.

ENDLOOP.

endmethod.

**IF_RSLPO_BADI_PARTITIONING~GET_T_PART_TEXT** specifies the text for each partition. The problem is, the customer normally named the partitions after his own mind, so I just
implemented a comment, so it would be initialized. The comment is necessary.

* Coding will follow later

Now we implement the **IF_RSLPO_BADI_PARTITIONING~GET_T_PART_CRIT**. This implementation specifies the partition criteria.

method IF_RSLPO_BADI_PARTITIONING~GET_T_PART_CRIT.

DATA:

l_id TYPE c length 2,

l_s_part_crit TYPE rslpo_badi_s_part_crit,

* SPOCRITERIA Variable

l_it_criteria TYPE TABLE OF ZSPOCRITERIA,

l_wa_criteria TYPE ZSPOCRITERIA,

* ZSPOINFOPROV Variable

l_it_spoinfoprov type table of zspoinfoprov,

l_wa_spoinfoprov type zspoinfoprov.

SELECT * from ZSPOINFOPROV into CORRESPONDING FIELDS OF TABLE L_IT_SPOINFOPROV where SPONAME = I_SPO.

Loop at L_IT_SPOINFOPROV into L_WA_SPOINFOPROV.

SELECT * from ZSPOCRITERIA into CORRESPONDING FIELDS OF TABLE l_it_criteria

where patternid = L_WA_SPOINFOPROV-PATTERNID1

or patternid = l_wa_spoinfoprov-patternid2

or patternid = l_wa_spoinfoprov-patternid3

or patternid = l_wa_spoinfoprov-patternid4.

LOOP AT l_it_criteria INTO l_wa_criteria.

SELECT INFOOBJECT FROM ZSPOPATTERN into l_s_part_crit-IOBJNM where patternid = l_wa_criteria-patternid.

If L_WA_CRITERIA-HIGHVALUE NE ''.

l_s_part_crit-opt = 'BT'.

ELSE.

l_s_part_crit-opt = 'EQ'.

ENDIF.

UNPACK L_WA_CRITERIA-PARTGROUP to l_id.

l_s_part_crit-IDPART = l_id.

l_s_part_crit-low = l_wa_criteria-LOWVALUE.

l_s_part_crit-high = l_wa_criteria-HIGHVALUE.

l_s_part_crit-posit = L_WA_CRITERIA-PARTGROUP.

APPEND l_s_part_crit TO r_t_part_crit.

ENDSELECT.

ENDLOOP.

ENDLOOP.

endmethod.

The method **IF_RSLPO_BADI_PARTITIONING~GET_T_PART_PROP** will only be initialized with the following code:

* Coding will follow later

The next and last method is **IF_RSLPO_BADI_PARTITIONING~GET_T_PART_DTP**. It specifies the template of the DTP.

method IF_RSLPO_BADI_PARTITIONING~GET_T_PART_DTP.

DATA:

l_posit TYPE i VALUE 1,

l_cnt TYPE i,

l_id TYPE c LENGTH 2,

l_s_part_dtp type rslpo_badi_s_part_dtp,

* ZSPODTP Variable

l_it_dtp type table of zspodtp,

l_wa_dtp type zspodtp,

* ZSPOINFOPROV Variable

l_it_spoinfoprov type table of zspoinfoprov,

l_wa_spoinfoprov type zspoinfoprov.

SELECT * from ZSPOINFOPROV into CORRESPONDING FIELDS OF TABLE L_IT_SPOINFOPROV where SPONAME = I_SPO.

Loop at L_IT_SPOINFOPROV into L_WA_SPOINFOPROV.

SELECT COUNT(*) FROM ZSPOCRITERIA into l_cnt where PATTERNID = L_WA_SPOINFOPROV-PATTERNID1.

SELECT * from ZSPODTP into CORRESPONDING FIELDS OF TABLE l_it_dtp where SPONAME = I_SPO.

LOOP at l_it_dtp into l_wa_dtp.

l_s_part_dtp-DTPTEMPLATE = l_wa_dtp-DTPTEMPLATE.

l_s_part_dtp-OBJNM = l_wa_dtp-OBJNAME.

l_s_part_dtp-LOGSYS = l_wa_dtp-LOGSYS.

l_s_part_dtp-TLOGO = l_wa_dtp-OBJTYPE.

WHILE l_posit LE l_cnt.

UNPACK l_posit to l_id.

l_s_part_dtp-IDPART = l_id.

APPEND l_s_part_dtp TO r_t_part_dtp.

l_posit = l_posit + 1 .

ENDWHILE.

ENDLOOP.

ENDLOOP.

endmethod.

After all methods are implemented, activate the Enhancement Implementation. Now we are able to create a Semantic Partitioning Object (SPO). What we need to maintain will be described in Part 3 of this series.

**These posts might also be interesting:**

**29,99 €**

^{1}

**39,99 €**

^{1}

Write a comment

0