3 weeks ago
Hello Experts,
I need implement the BAdI, that allow create reate object relation for adapting employee organizational assignment
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 as appear in the following image:
I had this code and generate issue of performance:
LOOP AT is_ee_org_ass_repl_req-org_assignment INTO DATA(ls_org_assignment).
lv_fecha_inicial = ls_org_assignment-start_date.
lv_fecha_final = ls_org_assignment-end_date.
lv_posicion ls_org_assignment-position_id
SELECT SINGLE sobid FROM hrp1013 CLIENT SPECIFIED
INTO (@DATA(lv_sobid) )
WHERE mandt = @SY-mandt and plvar = '01' and
objid = @LV_posicion AND ( begda <= lv_fecha_final AND endda >= lv_fecha_final )
ENDLOOP.
I need read the infotype hrp1013 for get the employee type where when the employee type = 1
I have done the following change:
DATA(lv_cont) = lines( is_ee_org_ass_repl_req-org_assignment ).
IF lv_cont >= 2.
APPEND is_ee_org_ass_repl_req-org_assignment[ lv_cont - 1 ] TO lt_fin.
APPEND is_ee_org_ass_repl_req-org_assignment[ lv_cont ] TO lt_fin.
ELSEIF lv_cont = 1.
APPEND is_ee_org_ass_repl_req-org_assignment[ lv_cont ] TO lt_fin.
ENDIF.
DATA: lt_sobid TYPE TABLE OF hrp1001-sobid, lt_posids TYPE TABLE OF hrp1001-objid.
IF lt_fin IS NOT INITIAL.
SELECT sobid FROM hrp1013 CLIENT SPECIFIED
INTO TABLE lt_sobid FOR ALL ENTRIES IN lt_fin
WHERE mandt = @SY-mandt AND
plvar = '01' AND
objid = @LT_posids AND
begda <= lv_fecha_final AND
endda >= lv_fecha_final
ENDIF.
" Processing the results as needed
LOOP AT lt_sobid INTO DATA(ls_sobid).
" My logic here using ls_sobid
ENDLOOP.
My Question :
What other changes can do? or Using the new ABAP how can change this code ?
Request clarification before answering.
Your code is a bit confusing.
Can you explain what the swapping is used for?
To me there is little change in general, just some re-formating going on. In order to give an answer to your question on what you can do better I’d say
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
The is triger by each employee and when is called the BADI the table is_ee_org_ass_repl_req-org_assignment, have all the organizational assignment only for this employee:
I need pass only the two last records to a internal table that I am named as lt_fin
DATA :lt_fin TYPE TABLE OF SFIOM_S_REPL_REQ_ORG_ASS_EXTND .
DATA(lv_cont) = lines( is_ee_org_ass_repl_req-org_assignment ).
IF lv_cont >= 2.
APPEND is_ee_org_ass_repl_req-org_assignment[ lv_cont - 1 ] TO lt_fin .
APPEND is_ee_org_ass_repl_req-org_assignment[ lv_cont ] TO lt_fin.
ELSEIF lv_cont = 1.
APPEND is_ee_org_ass_repl_req-org_assignment[ lv_cont ] TO lt_fin.
ENDIF.
And then I need do a loop to the table lt_fin, but an SELECT in LOOP generate issue of performance
LOOP AT lt_fin INTO DATA(ls_fin).
SELECT SINGLE persg FROM hrp1013 INTO @DATA(lv_empsgrp)
WHERE plvar = '01'
AND otype = 'S'
AND objid = @LS_fin-position_id
AND istat = '1'
AND begda LE @LSfin-end_date
AND endda GE @Fin-end_date.
IF SY-SUBRC = 0.
" Apply my logic here
ENDIF.
ENDLOOP.
I have checked the option of SELECT FOR ALL ENTRIES , and with this should be two loop?
Regards
User | Count |
---|---|
45 | |
9 | |
9 | |
6 | |
5 | |
5 | |
4 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.