on 2024 Dec 25 3:28 PM
Dear experts
How can optimize the following code :
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 hrp1001 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 ) AND subty = 'A012'
ENDLOOP.
In the t,code ST12 appear the following log:
Regards
Request clarification before answering.
On a Hana system, you can inner join the ITAB with the database table directly; without FOR ALL ENTRIES.
select
from is_ee_org_ass_repl_req-org_assignment as _oa
inner join hrp1001
on hrp1001~plvar = '01' and
hrp1001~subty = 'A012' and
hrp1001~objid = _oa~position_id and
hrp1001~begda <= _oa~start_date and
hrp1001~endda >= _oa~end_date
fields _oa~position_id,hrp1001~sobid
into table @DATA(results).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
I have used the code
DATA: lt_sobid TYPE TABLE OF hrp1001-sobid, lt_posids TYPE TABLE OF hrp1001-objid.
" Collect all position IDs first
LOOP AT is_ee_org_ass_repl_req-org_assignment INTO DATA(ls_org_assignment2).
APPEND ls_org_assignment2-position_id TO lt_posids.
ENDLOOP.
" Ensure the table is not empty to prevent runtime errors
IF lt_posids IS NOT INITIAL.
" Fetch all relevant sobids in a single SELECT statement
SELECT sobid FROM hrp1001 CLIENT SPECIFIED
INTO TABLE lt_sobid FOR ALL ENTRIES IN lt_posids
WHERE mandt = SY-mandt AND
plvar = '01' AND
objid = LT_posids AND
begda <= lv_fecha_final AND
endda >= lv_fecha_final AND
subty = 'A012'.
ENDIF.
" Processing the results as needed
LOOP AT lt_sobid INTO DATA(ls_sobid).
" Your logic here using ls_sobid
ENDLOOP.
and this generated error:
1 errors found. Activate anyway? Line 171: "LT_POSIDS" cannot be a table or a reference and cannot contain either of these objects or strings.
Regards
@PTecnico Did you read the ABAP documentation to see what "Pseudo-Component" means? Let's cross the Ts. The concerned line must be:
objid = LT_posids-table_line AND
User | Count |
---|---|
64 | |
10 | |
8 | |
8 | |
7 | |
6 | |
6 | |
6 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.