on 05-28-2008 6:58 AM
Hi,
I am getting some date values from a BAPI in the format yyyy-mm-dd. I want to compare a date input against this date.
I have used date/time types for the transactional variables. But here I can declare only in the format yyyy-mm-dd hh:mm:ss. I dont have option to declare values in any other format. How can I compare this date with the dates returned from the BAPI?
Regards,
Divija.
Divija,
Expression Editor Built-In Functions
datecompare(date1, date2)
Datecompare compares two dates and returns an integer that identifies which is the latter date.
If date1 occurs after date2, datecompare returns "-1."
If date1 and date2 are identical, "0" is returned.
If date1 occurs prior to date2, "1" is returned.
Also, I can see that you using the Built-In Function datetoxmlformat. I think your
datetoxmlformat( Repeater_0.Output{/item/START_DATE}, "yyyy-MM-ddT00:00:00" ). is wrong.
Please verify with Mikes Posted: May 28, 2008 1:33 PM.
Regards
Pedro
Edited by: Pedro Iglesias on May 28, 2008 11:14 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Divija,
-Make an Xacute query of your transaction.
-Make a display template as per the requirement.
-Test it through Dynamic Page Generator.
-Make a web page through which you will be passing the input parameters to your query.
-The script part will have following lines of code:
artdocument.AppletName.getQueryObject.setParam(1, <<input1>>);
document.AppletName.getQueryObject.setParam(2, <<input2>>);
document.AppletName.refresh();
(First you have to store the inputs from UI into the variables input1, input2 etc.)
Regards
Khaleel
Hi all,
Thanks for your inputs. Problem is solved now. I could set values for transactional variables from the UI using the following statements:
var StartDate= document.appletname.dateToXMLFormat(SelectedStartDatePass,"yyyy-MM-dd HH:mm:ss");
var EndDate= document.appletname.dateToXMLFormat(SelectedEndDatePass,"yyyy-MM-dd HH:mm:ss");
document.appletname.getQueryObject().setParam(1,StartDate);
document.appletname.getQueryObject().setParam(2,EndDate);
Regards,
Divija.
Divija,
When you extract a date from the response segment of a BAPI, it is in string format by default. Before you use any of the date expressions, you should explicitly convert it to datetime format using the function datetoxmlformat or dateformat. If you have already done that (and you may have from your statements), you can use datecompare and datediff with the two dates even if they are in different formats. However, if you have one date with HH:mm:ss and one without, you can again use dateformat to strip the HH:mm:ss. Then you can compare them. Or you can go the other way and force the HH:mm:ss to be midnight (default when not displayed). The 'T' between the date and the time is for xml date format. When performing datetime functions inside BLS, try to use xml datetime formats. It will save you a lot of headaches.
datetoxmlformat(BAPI.Response{/XXX}, "yyyy-MM-dd") -- my preferred.
-- Yields dates as 2008-05-28T06:31:34
dateformat(Transaction.Input, "yyyy-MM-ddT00:00:00") -- forces the date to midnight
-- Yields date as 2008-05-28T00:00:00
Hope this helps,
Mike
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Michael,
Thanks for your valuable inputs.
Based on your inputs, I am parsing the date returned by BAPI using the statement: datetoxmlformat( Repeater_0.Output{/item/START_DATE}, "yyyy-MM-ddT00:00:00" ). This is assigned to a transactional variable of type datetime.
I want to compare this against another transactional variable of type date time. I am doing it using the statement: (datecompare( Transaction.StartDate , Transaction.InputStartDate ))==1. But somehow this is not having any effect. Any ideas?
Regards,
Divija.
Divija,
Put a tracer in front of whatever action block you are using the date compare in.
Then paste the following into the Message of the Tracer:
"Start Date: " & Transaction.StartDate & " Input Start Date: " & Transaction.InputStartDate & " Date Comparison Results: " & stringif(datecompare(Transaction.StartDate, Transaction.InputStartDate)==1," StartDate After InputStartDate", "StartDate on or before InputStartDate")
The results should tell you whether both dates are valid and whether the date comparison is working.
You may have already done something along these lines. If so, then please provide more information on how you are using the datecompare in you expression.
Good luck!
Mike
Hi Divija,
There is a mistake in the format.
Micheal told to use datetoxmlformat and dateformat.
The sysntax is
datetoxmlformat(datetime, xmlformat) ,
dateformat(datetime, fromformat, toformat)
The bapi is returning the date format as yyyy-MM-dd.
The expression should be
datetoxmlformat( Repeater_0.Output{/item/START_DATE}, "yyyy-MM-dd")
This gives you the result as yyyy-MM-ddT00:00:00.
Then you can compare using the datecompare as mentioned by Pedro and Micheal.
Regards,
Kishore
Hi Divija,
There are different date functions available like datecompare, dateformat, datetoxmlformat etc in link editor.
You can make proper use of those date functions and it will solve your problem.
Regards
Khaleel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
10 | |
5 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.