Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

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

sreeramkumar_madisetty
Active Contributor
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

4 REPLIES 4

kiran_k8
Active Contributor
0 Kudos

Sreeram,

LOOP at what?

K.Kiran.

Former Member
0 Kudos

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

Former Member
0 Kudos

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

sreeramkumar_madisetty
Active Contributor
0 Kudos

Closed.