cancel
Showing results for 
Search instead for 
Did you mean: 

BEx Query Designer - Customer Exit

Former Member
0 Kudos

Hello All,

I have a requirment to create USER customer exit.

User will enter the value of Month(ex, 02, 03...) and Year (ex 2010,2011 ...) with two different prompt screen.

Now i have to return back a date back to a RKF based on following senario:

1) If month and year is current month and current year than return back current date to the perticular RKF Date.

2) If month and year is not current month and current year then return back the last date of the month and year entered.

Thanks & Regards

Nishant

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Nishant,

You will have to do slight modifications to above code and put it in following manner,

if V_MON eq V_CURR_DATE4(2) AND V_YEAR eq V_CURR_DATE0(4).

V_DATE = SY-DATUM.

else.

CONCATENATE V_YEAR V_MON INTO V_MONTH.

Call Function module RP_LAST_DAY_OF_THE_MONTHS

EXPORT

Last_date = V_DATE.

endif.

L_S_RANGE-SIGN = 'I'.

L_S_RANGE-OPT = 'EQ'.

L_S_RANGE-LOW = V_DATE.

APPEND L_S_RANGE TO E_T_RANGE

Regards,

Durgesh.

john_lang
Active Participant
0 Kudos

Hi Nishant,

Durgesh is right, the sample code I provided earlier was a generic example.

Below is the actual code to be used.

  if V_MON eq V_CURR_DATE+4(2) AND V_YEAR eq V_CURR_DATE+0(4).
    V_DATE = SY-DATUM.
  else.
    V_DATE+0(4)    = V_YEAR.
    V_DATE+4(2)    = V_MON.
    V_DATE+6(2)    = '15'.
    V_DATE         = V_DATE + 28.
    V_DATE+6(2)    = '01'.
    V_DATE         = V_DATE - 1.
  endif.
  L_S_RANGE-SIGN = 'I'.
  L_S_RANGE-OPT  = 'EQ'.
  L_S_RANGE-LOW  = V_DATE.
  APPEND L_S_RANGE TO E_T_RANGE.
endif.

Kind Regards,

John.

Answers (8)

Answers (8)

Former Member
0 Kudos

Its Solved.

Thanks Guys

Former Member
0 Kudos

Hi Nishant,

Can you please let me know how you resolved this issue.

I am facing the same issue.

Thanks,

Anamika

srikanthbwbw
Active Participant
0 Kudos

Hi anamika,

What issue are you facing? company code issue or variable issue?

I would advise you to raise a new discussion. If this discussion is closed by the user then you will not get much help.

thanks

Srikanth

Former Member
0 Kudos

This thread is talking about company code.

Already we have loaded masterdata for company code. Still problem is coming.

Former Member
0 Kudos

Hi Durgesh,

No i am not using any fiscal year attribute or variable. Also with that note, i am using latest version of sap with all the upgrade packages

Former Member
0 Kudos

Hi Nishant,

Check if this thread can give you some hint,

[;

Regards,

Durgesh.

Former Member
0 Kudos

Hi Durgesh,

I tried to run the query is RSRT and got following error

No value could be determined for variable VAR_POS_DATE.

Message no. BRAIN632

Diagnosis

This error diagnosis is specific only to the variables 0P_FVAEX or 0P_CTPCA !

Termination message BRAIN 632 appears:

Could not determine value for variable 0P_FVAEX (or 0P_CTPCA).

But i am not using any of this variable.

Former Member
0 Kudos

Hi Nishant,

This error is bascially related to missing Fiscal year variant in the query. Are you using any attribute in the query where fiscal year variant is required.

alternatively check OSS Note 981797

Regards,

Durgesh.

Former Member
0 Kudos

While creating the RKF with VAR_POS_DATE as (VAR_POS_DATE-90) - (VAR_POS_DATE -61), I am getting error, while checking error it shows me following diagnosis.

Diagnosis

In the following cases, an optional entry for VAR_POS_DATE is not possible:

VAR_POS_DATE is used in a selection row with exclude (SIGN = E)

VAR_POS_DATE is used in a selection row where the operator is not EQ or BETWEEN

The selection row is an interval and both the From value and To value are optional variables

The selection is a structure element (FEMS > 0) and consists of several selection rows with include (SIGN = I) for the same characteristic

System Response

Variable VAR_POS_DATE is set as a mandatory entry in this query.

Procedure

If you can permit the mandatory entry setting, you do not have to perform any further steps.

Alternatively, you can use an optional interval variable. You can also define two or more (hidden) selection elements, which you merge with a formula element.

Procedure for System Administration

Former Member
0 Kudos

Hi Durgesh,

I have created the variable "VAR_POS_DATE" with the above code

Now in query designer, i have restricted this with my number of stocks and a date range

(VAR_POS_DATE-90)-(VAR_POS_DATE-61).

While executing the query its giving me this error.

NO VALUE COULD BE DETERMINED FOR VARIABLE "VAR_POS_DATE"

But if i restrict with single date like (VAR_POS_DATE-90), its working fine.

Do i have to change some condition like L_S_RANGE-OPT = 'EQ' to GT or BT or something else

Thanks

Nishant

Former Member
0 Kudos

Hi,

In our project what we did was, created a simple RKF in which we have restriced 0FISCPER with customer exit variable with FROM and TO offset value and then with 0AMOUNT and it worked.

Not sure how exactly you are using this customer exit variable?

Regards,

Durgesh.

Former Member
0 Kudos

Thanks Joey, John and durgesh,

The code is working but i have 1 doubt and 1 query

Doubt is "case" will come in starting right?

My query is while creating RKF, i am giving my variable a date range. Now the code works fine for a single date. But if i am giving date range and creating an offset onto it, its giving me error. Do i have to loop my cmod code?

Thanks

Nishant

Former Member
0 Kudos

Hi Nishant,

There is nothing as such looping of your CMOD code, because only one line is returned by the e_t_data table.

What error you are getting in query designer?

For setting the from and TO offset you should select the range option from restriction panel and then you can set the individual offset for FROM and TO range.

The same variable value will be used to calculate the offset and code will be executed only once.

Regards,

Durgesh.

former_member202684
Contributor
0 Kudos

HI,

Just restrict the RKF with a CMOD variable and write the CMOD code as follows (sample):

assume your month and year variables are as follows: VAR_MON and VAR_YEAR


DATA: L_S_VAR LIKE RRRANGEEXIT.
DATA: L_S_RANGE TYPE RSR_S_RANGESID.
DATA: V_MON TYPE C LENGTH 2.
DATA: V_YEAR TYPE C LENGTH 2.
DATA: V_MONTH TYPE /bi0/oicalmonth.
DATA: V_CURR_DATE TYPE SY-DATUM.
DATA: V_DATE TYPE SY-DATUM.

when 'variable_name'.
if i_step = 2.
 READ TABLE I_T_VAR_RANGE WITH KEY VNAM = 'var_mon' INTO L_S_VAR.
 IF SY-SUBRC = 0.
   V_MON = L_S_VAR-LOW.
 ENDIF.
CLEAR L_S_VAR.
 READ TABLE I_T_VAR_RANGE WITH KEY VNAM = 'var_year' INTO L_S_VAR.
 IF SY-SUBRC = 0.
   V_YEAR = L_S_VAR-LOW.
 ENDIF.
V_CURR_DATE = . "Current date
"Check for the values
if V_MON eq V_CURR_DATE+4(2) AND V_YEAR eq V_CURR_DATE+0(4).
V_DATE = SY-DATUM.
else.
CONCATENATE V_YEAR V_MON INTO V_MONTH.
"call some function module to populate the last day of the above month (V_MONTH) 
"and populate the above obtained value into V_DATE.
"see if you can use this SG_PS_GET_LAST_DAY_OF_MONTH

  L_S_RANGE-SIGN = 'I'.
  L_S_RANGE-OPT  = 'EQ'.
  L_S_RANGE-LOW  = V_DATE.
  APPEND L_S_RANGE TO E_T_RANGE.
endif.

Regards,

Joe

john_lang
Active Participant
0 Kudos

Hi Joe and Nishant,

Here is a quick way to find the last day of the month.

The DATS data type honours arithmetic calculations on a calendar dateline.

data: l_calday type /bi0/oicalday.

l_calday = '19991206'.

l_calday+6(2) = '15'.
l_calday      = l_calday + 28.
l_calday+6(2) = '01'.
l_calday      = l_calday - 1.

Kind Regards,

John.