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

Explain code

Former Member
0 Likes
1,197

Hi Friends,

pls. see below code.

CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'

EXPORTING

I_DATE = SY-DATUM

I_PERIV = 'A'

IMPORTING

E_BUPER = MMM

E_GJAHR = YEAR.

IF SY-SUBRC NE 0.

MESSAGE E000 WITH 'Cannot convert date to fiscal period'.

ENDIF.

HERE MMM IS PERIOD AND YEAR IS YEAR AND PERIV IS FISICAL YEAR VARIANT.

MY QUESTION IS :

WHEN CAN I GET THE ABOVE MESSAGE.SY-SUBRC <> 0.

PLS. CAN ANY ONE EXPLAIN.

REGARDS,

8 REPLIES 8
Read only

Former Member
0 Likes
1,122

HI,

If the Fiscal year is maintained in the system then you can not get the SY-SUBRC <> 0, if the Fiscal year is not maintained then you get the SY-SUBRC <> 0

Regards

Sudheer

Read only

Former Member
0 Likes
1,122

I assume you will get the message if you don't have a fiscal period setup for the date.

Read only

VXLozano
Active Contributor
0 Likes
1,122

You cannot. You must include the EXCEPTIONS clause to your calling sentence.

CALL FUNCTION 'xxxx'
  EXPORTING
    valuelist
  IMPORTING
    valuelist
  CHANGING
    valuelist
  TABLES
    tablelist
  EXCEPTIONS
    here_are_the_sy-subrc_returnings.

Check the comments at the header of your FM:

*"       IMPORTING
*"             VALUE(I_DATE) LIKE  SY-DATUM
*"             VALUE(I_MONMIT) LIKE  GJVAR-MONMIT DEFAULT 00
*"             VALUE(I_PERIV) LIKE  T009B-PERIV
*"       EXPORTING
*"             VALUE(E_BUPER) LIKE  T009B-POPER
*"             VALUE(E_GJAHR) LIKE  T009B-BDATJ
*"       EXCEPTIONS
*"              INPUT_FALSE
*"              T009_NOTFOUND
*"              T009B_NOTFOUND

If you use the proper pattern in your editor, you will get an EXCEPTIONS clause like

EXCEPTIONS
  INPUT_FALSE    = 1
  T009_NOTFOUND  = 2
  T009B_NOTFOUND = 3
  OTHERS         = 4.

If you have this clause, you will get a proper sy-subrc returning, and not a crash (dump).

Message was edited (to expand answer) by:

Vicenç Lozano

Read only

Former Member
0 Likes
1,122

Hi,

Whenever the FM fails then sy-subrc <> 0. There may be the cases where the fiscal year variant you have used to not found. And declaration if you declare MMM as monat and passing to BUPER then also it will go to dump, because MMM should be of type T009B-POPER.

Thanks,

Sriram Ponna.

Read only

0 Likes
1,122

Hi Sriram,

in f.module if i changed the Fisical year A TO B.

( the Fisical Year B is not found in the system. )

finally it is giving 'FISICAL YEAR VARIANT B IS NOT EXPECTED ' MESSAGE IS

DISPLAYING.

But it is not giving below message :

MESSAGE E000 WITH 'Cannot convert date to fiscal period'.

what is the reason??

reagards,

Read only

0 Likes
1,122

Please, update your coding adding the EXCEPTIONS clause to your function call. I bet you will get the appropiate exception number under sy-subrc, and then you will be able to output a proper message using an IF or a CASE sentence.

Read only

0 Likes
1,122

Hi,

I think whenever the importing parameters fails, may be at that time you will get.

Anyhow i will try to figure it out.

Thanks,

Sriram Ponna.

Read only

Former Member
0 Likes
1,122

Hi Venu,

There are two condition when this error message can be triggered.

1) If the fiscal year variant (factory calendar) is not maintained

2) If the fiscal year is not maintained for a particular year

Simply if you doesnt find a value for fiscal year variant or fiscal year in the table T009B or T009.

Thanks,

Vinay