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

Fiscal Year - Help needed

Former Member
0 Likes
633

Hello Experts,

I am in ECC 6.0. My Company has a 4-4-5 calender. In my selection screen, I have to default the current and previous fiscal year. For that I have called the below function module. Everything is good. But when I do a extended code check it says

"Current ABAP Command is Obselete. An explicit work area is necessary in the 00 context. use "append wa to s_gjahr [sorted by]"

Can anyone suggest me how to write the code so that my error will be solved.

FORM set_default_fiscal_year.

DATA: lv_poper TYPE poper, "Fiscal Period

lv_gjahr TYPE gjahr. "Fiscal Year

*Get current fiscal year

CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'

EXPORTING

i_date = sy-datum

i_periv = gc_fiscal_variant

IMPORTING

e_buper = lv_poper

e_gjahr = lv_gjahr

EXCEPTIONS

input_false = 1

t009_notfound = 2

t009b_notfound = 3

OTHERS = 4.

CHECK sy-subrc = 0.

*Get previous fiscal year

s_gjahr-low = lv_gjahr - 1.

s_gjahr-high = lv_gjahr.

s_gjahr-sign = 'I'.

s_gjahr-option = 'BT'.

APPEND s_gjahr.

ENDFORM. " SET_DEFAULT_FISCAL_YEAR

1 ACCEPTED SOLUTION
Read only

naimesh_patel
Active Contributor
0 Likes
579

Instead of using the header line of the S_GJAHR, use an explicit workarea.

Like:


data: la_gjahr like line of s_gjahr.
la_gjahr-low = lv_gjahr - 1.
la_gjahr-high = lv_gjahr.
la_gjahr-sign = 'I'.
la_gjahr-option = 'BT'.
APPEND la_gjahr to s_gjahr.

Regards,

Naimesh Patel

4 REPLIES 4
Read only

naimesh_patel
Active Contributor
0 Likes
580

Instead of using the header line of the S_GJAHR, use an explicit workarea.

Like:


data: la_gjahr like line of s_gjahr.
la_gjahr-low = lv_gjahr - 1.
la_gjahr-high = lv_gjahr.
la_gjahr-sign = 'I'.
la_gjahr-option = 'BT'.
APPEND la_gjahr to s_gjahr.

Regards,

Naimesh Patel

Read only

0 Likes
579

Hi Naimesh,

Thank you so much for the reply.

I wrote a select statement like this.

SELECT SINGLE ltext FROM cskt INTO gs_sapgl_to_cim-ktext WHERE spras = 'E' AND kokrs = gc_kokrs_1000

AND kostl = gs_sapgl_to_cim-kostl.

SELECT SINGLE ltext FROM csku INTO gs_sapgl_to_cim-ltext WHERE spras = 'E' AND kstar = gs_sapgl_to_cim-kstar.

But when I do extended code check, the errors are as follows:

Syntax check warning

This warning is only displayed in SLIN

In "SELECT SINGLE ...", the WHERE condition for the key field "DATBI" does not

test for equality. Therefore, the single record in question is possibly not

unique.

Internal Message Code: MESSAGE GSB

Syntax check warning

This warning is only displayed in SLIN

In "SELECT SINGLE ...", the WHERE condition for the key field "KTOPL" does not

test for equality. Therefore, the single record in question is possibly not

unique.

Internal Message Code: MESSAGE GSB

Can you help me with this.

Read only

0 Likes
579

Both warnings say that you don't have all the primary keys in your Selection. You must have all primary key fields in the where condition to have consistent data because you are using the SELECT SINGLE.

E.g. Cost Center A could has valid description on 12/31/2007 as "Test Cost Center" and Currently valid description as "Testing Exp Cost Center". Than when you run your report which invovles the Data from 2008 than you must select the description as "Testin Exp Cost Center" So, you must include the Validity date in the Selection.

NOTE: Please open a new thread if your question doesn't match to the "Subject". This will help in better search and filter.

Regards,

Naimesh Patel

Read only

0 Likes
579

While using select single you need to use full key in the where clause

Here in CSKT you missed in the primary key field DATBI and in CSKU you missed field KTOPL

and the messages from SLIN is are warning and not errors

a®