cancel
Showing results for 
Search instead for 
Did you mean: 

Query getting executed based on userinput not customer exit variable

Former Member
0 Kudos

Hi all,

I need to get persian dates as user input and convert it to Greg date and execute the query ( I am doing HR in BW) based on this greg date.

I have created two variables:

Persian Date = User Input

Greg Date = Customer exit

Query is restricted on calendar day where the user enters persian date instead of greg date and CMOD project is executed which does the conversion perfectly fine.

I have also created a selection field on Headcount and restricted it to Greg Date customer exit variable.

But the problem is that since the entire query is restricted on calendar day variable , even though I am converting persian to greg, the query doesn't return anything.

I mean If I remove the query restriction on calendar day and hard code a greg date in CMOD project, I am getting correct result for the HeadCount restricted on this Greg Date variable but calendar day variable is getting in the way. I cannot remove it because I need to get the persian date from the user.

Would you help me please?  I don't want the query to be executed on calendar day variable . I just want it to get the user input and pass it to conversion code.

Thanks

Accepted Solutions (0)

Answers (1)

Answers (1)

sander_vanwilligen
Active Contributor
0 Kudos

Hi,

I think that your approach could be a much simpler one. We have to realize that on the variable pop-up, the date is displayed in "external format" (prerequisite is that your input field is type date). The display is dependent on the standard SAP "date format" setting in the user's Defaults.

Please have a look in t/code SU3, second tab page Defaults. There is a field called "Date Format". Behind this field is domain XUDATFM. It can have different values depending on the user's preference. It can of course also be set by an administrator, e.g. via t/code SU01 or a corresponding CUA t/code.

In my user it is set to DD.MM.YYYY (i.e. domain value '1'). But it can also be set to YYYY/MM/DD (Iranian Date) (i.e. domain value 'C').

The "internal date format" is however always in Gregorian date format. So in my opinion the conversion from external format to internal format should be done automatically by SAP.

I suggest to remove the user-exit variable and use the date input variable for restricting the selection.

Best regards,

Sander

Former Member
0 Kudos

Hi Sander,

Thanks a lot for taking the time to reply but the problem is that user default settings for date format do not work in BO tools and not even in Bex.

Regards,

SJ

sander_vanwilligen
Active Contributor
0 Kudos

Hi,

Did you already try Persian format in Windows Region and Language settings?

I would say that the combination of the appropriate date format in both the SAP user settings (t/code SU3) and Windows regional settings should logically work. If not, then I suggest to create an SAP Support message for it.

If you have to go for a custom solution with a customer-exit variable, it might be that class CL_ABAP_DATFM offers the conversion functionality you are looking for. E.g. method CONV_ISL_TO_GREG_FORMULA could be useful.

Anyway, I am curious which coding you developed for the user-exit variable. Can you please share your coding?

Best regards,

Sander

Former Member
0 Kudos

Hi Sander,

Unfortunately the root cause of all date problems is that windows does not have a persian calendar!!! ( apparently recently added in win 10).

Anyway, this is the code used to the conversion. I am closing this thread.

DATA: greg_dt TYPE d.

DATA: dat_format TYPE xudatfm.

DATA: conv_hijra(10).

DATA: lv_date(10) TYPE c." -- Gregorain to Hijra calculation can be adjusted by maintaining values in TISLCAL as required.

GREG_DT = SOURCE_FIELDS-BILL_DATE .

TRY.

CALL METHOD cl_abap_datfm=>conv_date_int_to_ext

EXPORTING

im_datint = greg_dt

im_datfmdes = 'C'

    IMPORTING ex_datext = conv_hijra.

CATCH cx_abap_datfm_format_unknown .

ENDTRY.

CONCATENATE conv_hijra+0(4) '/' conv_hijra+5(2) '/' conv_hijra+8(2) into lv_date .

RESULT = lv_date .