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

Short dump with function module - Exception problem - how to avoid thi s ?

Former Member
0 Likes
2,359

Short Dump is occuring in the below function module , when no user entry found in ZGXMIT for a specific period. ( Below is the funtion module code. )

It should not short dump but just return the exception.

<b>How can i do this in the below code inorder to avoid short dump or

How can i do coding while calling this function module inorder to avoid short dump.</b>

clear: e_zgxmit.

IF I_GJAHR IS INITIAL OR

I_MONAT IS INITIAL.

  • To get the latest month of i_prctr selection.

SELECT * FROM zgxmit

UP TO 1 ROWS

INTO CORRESPONDING FIELDS OF e_zgxmit

WHERE zprctr = i_prctr

ORDER BY ZMONAT DESCENDING.

ENDSELECT.

if sy-subrc ne 0.

raise no_entry_found.

endif.

ELSEIF NOT I_GJAHR IS INITIAL AND

NOT I_MONAT IS INITIAL.

SELECT SINGLE *

FROM zgxmit

INTO CORRESPONDING FIELDS OF e_zgxmit

WHERE zprctr = i_prctr

AND zgjahr = i_gjahr

AND zmonat = i_monat.

IF sy-subrc NE 0.

RAISE no_entry_found.

ENDIF.

ENDIF.

ENDFUNCTION.

6 REPLIES 6
Read only

Former Member
0 Likes
1,186

hi Sam,

declare your if statements in this way ..i.e, conditions separated by braces

IF <b>(</b> I_GJAHR IS INITIAL<b> )</b> OR

<b>(</b> I_MONAT IS INITIAL<b> ).</b>

  • To get the latest month of i_prctr selection.

SELECT * FROM zgxmit

UP TO 1 ROWS

INTO CORRESPONDING FIELDS OF e_zgxmit

WHERE zprctr = i_prctr

ORDER BY ZMONAT DESCENDING.

ENDSELECT.

if sy-subrc ne 0.

raise no_entry_found.

endif.

ELSEIF NOT <b>(</b> I_GJAHR IS INITIAL <b>)</b> AND

<b>(</b> I_MONAT IS INITIAL<b> ).</b>

SELECT SINGLE *

FROM zgxmit

INTO CORRESPONDING FIELDS OF e_zgxmit

WHERE zprctr = i_prctr

AND zgjahr = i_gjahr

AND zmonat = i_monat.

IF sy-subrc NE 0.

RAISE no_entry_found.

ENDIF.

ENDIF.

ENDFUNCTION.

Regards,

Santosh

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,186

So that it does not short dump, you must handle the exception from the caller. So when you call the function module, you need to have the exception listed, then it will not dump.

call function 'ZFUNCTION'
     exceptions
          no_entry_found = 1
          other                = 2.

If sy-subrc  = 1.
  Write:/ 'No Entries Found'.
endif.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
1,186

Did you define the exception "no_entry_found" in the exceptions tab of function module. If you have and the dump is happening at the caller program, ensure you catch the exception:

CALL FUNCTION 'FUNCTION'

EXCEPTIONS

no_entry_found = 1

OTHERS = 99.

if sy-subrc ne 0.

handle exceptions.

endif.

hith

Sunil Achyut

Read only

Former Member
0 Likes
1,186

Whenever we use any FMs. It is advised not to comment out or remove the EXCEPTION handler in the calling program. Otherwise it may dump.

Thanks,

Santosh

Read only

Former Member
0 Likes
1,186

THANK YOU VERY MUCH .

I am calling this function module three times in my program :

Instead using <b>WRITE : / 'no_entry_found'.</b>

Shall I display system message or information message .

will it work.

Like <b>MESSAFE s(100)ZG Text-011. "no_entry_found for this period </b>.

I am new of using thsi exception of function module.

LOOP AT it_prctrs.

CLEAR: izgxmit.

CALL FUNCTION 'Z_GL_GET_ZGXMIT'

EXPORTING

i_prctr = it_prctrs-lg_locnum

*{ Start of changes - JVALAPA - CMS 6901

I_GJAHR = P_YEAR

I_MONAT = P_PERIOD

*} End of changes - JVALAPA - CMS 6901

IMPORTING

e_zgxmit = izgxmit

EXCEPTIONS

no_entry_found = 1

OTHERS = 2.

IF sy-subrc = 0.

IF ( izgxmit-bal_xmit = 'X' OR izgxmit-inc_xmit = 'X' ) and

izgxmit-zgjahr = p_year and izgxmit-zmonat = p_period. "XXXX

g_tbl_zgbsis_itab-prctr = izgxmit-zprctr.

g_tbl_zgbsis_itab-rpt_loc = izgxmit-rpt_loc.

APPEND g_tbl_zgbsis_itab. CLEAR: g_tbl_zgbsis_itab.

ENDIF.

*{ Start of changes - JVALAPA - CMS 6901

ELSEIF sy-subrc = 1.

WRITE : / 'no_entry_found'.

*} End of changes - JVALAPA - CMS 6901

ENDIF.

ENDLOOP.

_________________________________

clear: izgxmit. "XXXX

call function 'Z_GL_GET_ZGXMIT' "XXXX

exporting "XXXX

i_prctr = it_zgxmit-zprctr "XXXX

*{ Start of changes - JVALAPA - CMS 6901

I_GJAHR = P_YEAR

I_MONAT = P_PERIOD

*} End of changes - JVALAPA - CMS 6901

importing "XXXX

e_zgxmit = izgxmit "XXXX

exceptions "XXXX

no_entry_found = 1 "XXXX

others = 2. "XXXX

if sy-subrc = 0. "XXXX

if it_zgxmit-zgjahr = izgxmit-zgjahr and "XXXX

it_zgxmit-zmonat = izgxmit-zmonat. "XXXX

it_zgxmit-z500_xmit = izgxmit-z500_xmit. "XXXX

  • Start of changes - JVALAPA - CMS 6901

IF izgxmit-inc_xmit <> ' ' AND it_zgxmit-inc_xmit = 'P'.

it_zgxmit-inc_xmit = izgxmit-inc_xmit.

ENDIF.

IF izgxmit-bal_xmit <> ' ' AND it_zgxmit-bal_xmit = 'P'.

it_zgxmit-bal_xmit = izgxmit-bal_xmit.

ENDIF.

  • End of changes - JVALAPA - CMS 6901

else. "XXXX

it_zgxmit-z500_xmit = ' '. "XXXX

endif. "XXXX

  • Start of changes - JVALAPA - CMS 6901

elseif sy-subrc = 1.

WRITE : / 'no_entry_found'.

  • End of changes - JVALAPA - CMS 6901

endif. "XXXX

append it_zgxmit. clear it_zgxmit.

endloop.

_____________________________________

LOOP AT izccod_t.

CALL FUNCTION 'Z_GL_GET_ZGXMIT'

EXPORTING

i_prctr = izccod_t-lg_locnum

I_GJAHR = p_year

I_MONAT = p_period

IMPORTING

E_ZGXMIT = wa_zgxmit

EXCEPTIONS

NO_ENTRY_FOUND = 1

OTHERS = 2

.

IF sy-subrc = 1.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Read only

0 Likes
1,186

Depends on what your requirement is, if you have to stop processing when no entries are found you can use Message type 'E'. If however, your requirement is to display a message to the user then Message type 'I' would work.

hith

Sunil Achyut