04-29-2008 7:09 AM
Hi Friends
I am implementing the BADI : HRHAP00_ENHANCE_FRE1 ~ENHANCE_DOCUMENT.
Actually the BADI conatains the following code for inserting the single objectives at a time to a template.
includes
include: incl_hap_messages,
incl_hap_elements,
incl_hap_enhancement.
tables
data: lt_hri1001 type hap_t_hri1001.
work areas
data: lw_body_elements type hap_s_body_elements.
data: lw_hri1001 type hri1001.
data: lw_enhancement_elements type hap_s_body_elements_add.
read base element
read table t_body_elements into lw_body_elements
with key row_iid = base_row_iid
binary search.
if sy-subrc = 0.
READ REFERENCE OBJECT for the current element
call function 'HRHAP_C_IT1001_READ_NNN'
exporting
plvar = plan_version
otype = lw_body_elements-element_type
objid = lw_body_elements-element_id
subty = c_relationship_b606
AUTHORITY_CHECK = 'X'
importing
t_hri1001 = lt_hri1001
s_return = s_return.
if not s_return is initial.
exit.
endif.
read table lt_hri1001 into lw_hri1001 index 1.
if sy-subrc = 0.
lw_enhancement_elements-new_element_type = lw_hri1001-sclas.
lw_enhancement_elements-new_element_id = lw_hri1001-sobid.
lw_enhancement_elements-weighting = 1.
clear: lw_enhancement_elements-no_value. "weighting is given
use the standard reference element (FIRST FOUND REFERENCE)
clear: lw_enhancement_elements-reference_type,
lw_enhancement_elements-reference_id.
append lw_enhancement_elements to t_enhancement_elements.
INSERT THIS ELEMENT as last ELEMENTS
enhancement_type = c_element_insert_last.
else.
NO REFERENCE FOUND !!!
ENHANCEMENT not allowed without reference object
s_return-msgty = c_message_type_e.
s_return-msgno = '228'.
s_return-msgid = c_message_class_catalog.
Message where-used
if 1 = 2.
message e228(hrhap00_template).
endif.
endif. "reference object found ?
endif. "body element found ?
endmethod. "IF_EX_HRHAP00_ENHANCE_FREE~ENHANCE_DOCUMENT
what I did is :
includes
include: incl_hap_messages,
incl_hap_elements,
incl_hap_enhancement.
tables
data: lt_hri1001 type hap_t_hri1001.
work areas
data: lw_body_elements type hap_s_body_elements.
data: lw_hri1001 type hri1001.
data: lw_enhancement_elements type hap_s_body_elements_add.
read base element
read table t_body_elements into lw_body_elements
with key row_iid = base_row_iid
binary search.
if sy-subrc = 0.
READ REFERENCE OBJECT for the current element
call function 'HRHAP_C_IT1001_READ_NNN'
exporting
plvar = plan_version
otype = lw_body_elements-element_type
objid = lw_body_elements-element_id
subty = c_relationship_b606
AUTHORITY_CHECK = 'X'
importing
t_hri1001 = lt_hri1001
s_return = s_return.
if not s_return is initial.
exit.
endif.
loop.
read table lt_hri1001 into lw_hri1001 index 1.
if sy-subrc = 0.
lw_enhancement_elements-new_element_type = lw_hri1001-sclas.
lw_enhancement_elements-new_element_id = lw_hri1001-sobid.
lw_enhancement_elements-weighting = 1.
clear: lw_enhancement_elements-no_value. "weighting is given
use the standard reference element (FIRST FOUND REFERENCE)
clear: lw_enhancement_elements-reference_type,
lw_enhancement_elements-reference_id.
append lw_enhancement_elements to t_enhancement_elements.
INSERT THIS ELEMENT as last ELEMENTS
enhancement_type = c_element_insert_last.
else.
NO REFERENCE FOUND !!!
ENHANCEMENT not allowed without reference object
s_return-msgty = c_message_type_e.
s_return-msgno = '228'.
s_return-msgid = c_message_class_catalog.
Message where-used
if 1 = 2.
message e228(hrhap00_template).
endif.
endif. "reference object found ?
endloop.
endif. "body element found ?
to achieve my requirement i.e to insert multiple objectives in to the template at a time.But with this code, I am getting dump.
Here I just added loop...endloop to the standard code as a result i am getting the dump.
Can anyone please correct my code in a proper way.
Points are assured for correct answers.
Regards,
Sree
04-29-2008 7:18 AM
Hi,
Can you tell what exactly is the dump?, If you are trying to loop internal table lt_hri1001, then the loop statement is wrong. here is the syntax.
Loop <internal table> into <workarea> [OPTIONAL where <condition>].
endloop.
I guess this is where u r getting dump.
Regards,
Aravind M
04-29-2008 7:17 AM
04-29-2008 7:17 AM
Hi Dear,
1. You need to append values in internal table, which you haven'nt done.
2. You have written loop, you need to specify internal table loop at itab.
REWARD IF USEFUL
04-29-2008 7:18 AM
Hi,
Can you tell what exactly is the dump?, If you are trying to loop internal table lt_hri1001, then the loop statement is wrong. here is the syntax.
Loop <internal table> into <workarea> [OPTIONAL where <condition>].
endloop.
I guess this is where u r getting dump.
Regards,
Aravind M
04-21-2009 9:52 AM