cancel
Showing results for 
Search instead for 
Did you mean: 

Doubt for optimize abap code in BADI

PTecnico
Explorer
0 Kudos
368

Hello Experts,

I need implement the BAdI, that allow create reate object relation for adapting employee organizational assignment

https://help.sap.com/docs/SAP_SUCCESSFACTORS_EMPLOYEE_CENTRAL_INTEGRATION_TO_SAP_BUSINESS_SUITE/a7f1...


I need create a relationship between the object S and Custom

The BADI have a method IF_SFIOM_ADAPT_EE_ORG_ASSGNMNT~CREATE_OBJECT_RELATION for Create object relation

The information organizational comes as a parameter in the internal table is_ee_org_ass_repl_req-org_assignment

For each employee who goes through this BADI, and processes their organizational assignment

I need read the infotype hrp1013 for get the employee type where when the employee type = 1

LOOP AT is_ee_org_ass_repl_req-org_assignment INTO DATA(ls_org_assignment).
SELECT SINGLE persg FROM hrp1013 INTO @DATA(lv_empsgrp)
WHERE plvar = '01'
AND otype = 'S'
AND objid = @LS_org_assignment-position_id
AND istat = '1'
AND begda LE @LS_org_assignment-end_date
AND endda GE @LS_org_assignment-end_date.
IF SY-SUBRC = 0.
" Apply my logic here
ENDIF.
ENDLOOP.

How can avoid issue of performance and not use a select in the LOOP ?

Regards

 

View Entire Topic
raymond_giuseppi
Active Contributor
0 Kudos

You could define an attribute of the implementing class as a sorted type table to save the result of the SELECT and then only select from database if not already saved. You could also reduce the number of criteria in the SELECT to exchange speed vd memory.

PTecnico
Explorer
0 Kudos
Hello raymond_giuseppi , I would like to experiment with this option "define an attribute of the implementing calss as a sorted type table to save the result of the SELECT and then only select from database if not already saved. " , can you give me an idea?
raymond_giuseppi
Active Contributor
0 Kudos

In recent versions you could also perform a SELECT JOIN between the InfoType table and the internal table

SELECT a~field1, a~field2
  FROM dbtable AS a INNER JOIN @lt_it AS b    
  ON a~field3 EQ b~field1 AND
     a~field4 EQ b~field2.
PTecnico
Explorer
0 Kudos

Hi

SELECT a~OBJID, a~OTYPE
  FROM hrp1013 AS a INNER JOIN is_ee_org_ass_repl_req-org_assignment AS b
  ON a~OBJID EQ b~OBJID.

And when I tried of active genered the error:

1 errors found. Activate anyway?
Line 156: The table
name "IS_EE_ORG_ASS_REPL_REQ-ORG_ASSIGNMENT" is
too long. long. It may not be unique.

Sandra_Rossi
Active Contributor
0 Kudos
@PTecnico For joining an internal table, the internal table name must be prefixed with @ (and so, the whole SQL statement must use the Strict Mode syntax). Note that joining an internal table is supported only in an SAP S/4HANA system with minimal ABAP 7.52.
PTecnico
Explorer
0 Kudos

Hi Sandra, This is the information of My system :

PTecnico_0-1737289858847.png

And with this information not can joining an internal table.

Now, I want use SELECT FOR ALL ENTRIES, however I have a doubt  with the use of the instruction for my scenarie.

 

The system standard have a LOOP and When the system call the BADI, send all the records of the assignment for each employee.

This information is received in the table

is_ee_org_ass_repl_req-org_assignment 

For avoid have a SELECT in LOOP. You recommendation is: SELECT FOR ALL ENTRIES,

If I undestand you idea , i Should do the following:

1. Before do a LOOP to the internal table is_ee_org_ass_repl_req-org_assignment , I shoud use the following instuctions and have in the table lt_result_1013, all the employee that have employeeclass = 1,

SELECT result

FROM HRP1013
INTO|APPENDING lt_result_1013
[[FOR ALL ENTRIES IN is_ee_org_ass_repl_req-org_assignment ] WHERE sql_cond] …

 

And with avoid the SELECT in the LOOP and can check this using a READ TABLE in  LOOP at:

LOOP AT is_ee_org_ass_repl_req-org_assignment INTO DATA(ls_org_assignment).

READ TABLE lt_result_1013 ....

ENDLOOP

 

This is rigth?

Regards

 

Sandra_Rossi
Active Contributor
0 Kudos
@PTecnico Just try and revert back if it doesn't work. Note that your question seems to be exactly the same as this one, which you marked as being solved: https://community.sap.com/t5/technology-q-a/doubt-for-optimize-abap-code/qaq-p/13971704