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: 

Function module:G_Period_Get error exception1

0 Kudos
1,761

Select - options:

s_zyear for s031-spmon.(MM.YYYY)

I need to convert the year and month to the fiscal year. And the coding is like this:

With debug, the exception 1 was issued, and I don't know why, Can anyone here help me??

please,thank you.

Data:
  LDF_DATUM TYPE SY_DATLO. 

LDF_DATUM+0(4) = S_ZYEAR-LOW+0(4).
LDF_DATUM+4(2) = S_ZYEAR-LOW+4(2).
LDF_DATUM+6(2) = '01'.

Call function 'G_Period_get'.
  Exporting
    company = p_bukrs
    date    = LDF_DATUM
    ledger  = 'LEDGER'
  Importing
    Period = GDF_Period
    Year   = Gdf_year
  Exception
    Lendger_not_assigned_to_company
= 1
1 ACCEPTED SOLUTION

FredericGirod
Active Contributor
1,620

You should provide the error returned by SAP.

at first, ledger could not be 'LEDGER' it is a CHAR2

24 REPLIES 24

0 Kudos
1,620

I've tried to set a range table of s_zyear, but I don't know how to use the range table in a Call function. Date could be a scope???

FredericGirod
Active Contributor
1,621

You should provide the error returned by SAP.

at first, ledger could not be 'LEDGER' it is a CHAR2

0 Kudos
1,620

Hi,Girod!

The error returned by SAP may be 'Get finance period error'.

SY-SUBRC = 1…

About ledger, it's my miss.It is 'Ol'

0 Kudos
1,620

Do you have retest with the good ledger value ?

0 Kudos
1,620

Yes, test by ledger = 'ol' , there's also the exception error issued..

0 Kudos
1,620

(the lowercase value is strange)

Use transaction ST05 to check witch tables are read by the FM, and whitch one is returning 0 record. You will see the WHERE condition criteria and maybe understand what is missing

0 Kudos
1,620

I wonder how to set value of the date with select-options? Should I call function twice with date of S_ZYEAR-LOW and S_ZYEAR-HIGH?

0 Kudos
1,620
FUNCTION g_period_get.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"  IMPORTING
*"     VALUE(COMPANY) LIKE  T001-BUKRS DEFAULT SPACE
*"     VALUE(DATE) LIKE  SY-DATUM DEFAULT SY-DATLO
*"     VALUE(GLOBAL_COMPANY) LIKE  T880-RCOMP DEFAULT SPACE
*"     VALUE(LEDGER) LIKE  T881-RLDNR DEFAULT SPACE
*"     VALUE(VARIANT) LIKE  T882-PERIV DEFAULT SPACE

Company is type BUKRS, simple field

Date is type SYDATUM, simple field

Global Company is type RCOMP, simple field

Ledger is type RLDNR, simple field

....

where do you want to put a SELECT OPTION or a RANGE ?

0 Kudos
1,620

DO you actually mean that there's nothing with a Select option or a Range?

And it's alright to type SY-DATUM?

Don't I need to concatenate the year and month into DATE?

0 Kudos
1,620

Because I need to convert the select option into fiscal year... (maybe wrong)

0 Kudos
1,620

There is nothing to do with Select Option nor Range

I don't know if your concatenation is right, because I don't know the internal format of the field S_YEAR

You could describe a date field as TYPE SY-DATUM or TYPE SYDATUM

and if you want to test simply the FM before playing with your code, you could use in transaction SE37 the test mode (F8), it will generate a Selection screen where you will be able to test the value without doing a program

0 Kudos
1,620

The value of date is gotten from select option, isn't it?

0 Kudos
1,620

You have a problem with SELECT OPTION ? 🙂

For the value 01 01 2021

Parameters : 20210101

Select-Options: I EQ 20210101

Do you think you could enter the I EQ 20210101 into a simple field DATE ?

A Select-option is a table with a structure : Sign, Option, Low, Value it is very specific

0 Kudos
1,620

OK,I see.

Oh,I just now used SE37 to test with value that is used in SE38, there's also the same exception issued

0 Kudos
1,620

why the exception'ledger_not_assigned_to_company' issued? Omg

0 Kudos
1,620

No, it actually couldn't be entered into the date value..

So how I define the value of date??

I definitely think that the concatenation is wrong

0 Kudos
1,620

TRY

SE37 ... G_PERIOD_GET (in uper case in your code please)

F8

and try like this

0 Kudos
1,620
王 雅昕 What are you using G_PERIOD_GET for? Maybe you should use another function module?

0 Kudos
1,620

Hi!

For getting fiscal period data.

another function module is like what?

1,620

Thank you so much,Girod!

Finally got it with SE37, the correct value of ledger should be '0L',but not 'OL'.

0 Kudos
1,620
王 雅昕 and you had find it if you have try the ST05 trans. This is a very usefull transaction to find where the SELECT fails

0 Kudos
1,620

oh,got it!

I'll try ST05 again. Lol,

always thank u!

RaymondGiuseppi
Active Contributor
1,620

You could use some other FM such as DATE_TO_PERIOD_CONVERT after call of CCODE_GET_FISCAL_YEAR_VARIANT to get calendar variant - or - get an actual value of ledger (Domain RLDNR doesn't allow lowercase character) ex: FAGL_GET_LEADING_LEDGER or FAGL_GET_ALL_LEDGERS_IN_BUKRS

You can create a TYPE RANGE table from your SELECT-OPTION by converting LOW and HIGH values (if not initial) Keep SIGN and OPTION values.

0 Kudos
1,620

OK,thanks a lot~