Application Development and Automation 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: 
Read only

exception handling

Former Member
0 Likes
628

hi experts

i have an internal table, itab with 3 columns.

eid, ename and edearttment.

i also write a paramter statement

paramter: pid like eid.

now i write

loop at itab where eid = pid.

......................

......................

endloop.

now if pid not equal to eid i need an exception handling cx_hrpa_invalid_paramter.

if pid equals eid then it should proceed with its normal state.

how to do that

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
605

loop at itab where eid = pid.

......................

......................

endloop.

<b>if sy-subrc <> 0.

  • handle your exception logic here. If this is within a function module, you can simply raise an exception which can later be handled in the calling program

endif.</b>

Regards,

Ravi

5 REPLIES 5
Read only

Former Member
0 Likes
606

loop at itab where eid = pid.

......................

......................

endloop.

<b>if sy-subrc <> 0.

  • handle your exception logic here. If this is within a function module, you can simply raise an exception which can later be handled in the calling program

endif.</b>

Regards,

Ravi

Read only

0 Likes
605

Let us this scenario:

In ITab you are having more than one entry of PID not equal to EID. then for the first occurance only you want to trigger exception and stop processing other entries? or you want to process all entires and just trigger exception in case you are having atleast one entry of "pid ne eid".

Let me know.

In first case you loop itab with out where. In loop use IF to chk the pid ne eid. In IF handle exception. and come out of loop

In other case also loop itba with out where. Use IF to know whether any entry is having PID ne EID. set a flag there. after the loop handle the exception

Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
605

HI,

You can do it this way.

LOOP AT itab.

READ TABLE itab into wa WITH KEY eid = pid.

if sy-subrc <> 0.

raise exception type cx_hrpa_invalid_paramter.

else.

normal processing

endif.

ENDLOOP.

Regards,

Sesh

Read only

Former Member
0 Likes
605

hi,

loop at itab where eid = pid.

......................

......................

endloop.

if sy-subrc <> 0. "This loop will return 4 if no entry found with eid = pid.

*throw your exception here.

endif.

Hope this helps.

Regards,

Richa

Read only

Former Member
0 Likes
605

Hi,

As u have to raise an exception when eid <>pid u have to loop generally and then read other wise u may not be able to read the needed rows and raise exception for the else.

loop at itab.

READ TABLE itab into wa WITH KEY eid = pid.

if sy-subrc <> 0.

exception cx_hrpa_invalid_paramter have to be raised.

else.

process normally

endif.

ENDLOOP.

in this for every row it checks for feisibility.

Regards,

S.Ravi