Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Can anyone correct the code in a right way...

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

Tags:
Former Member

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question