04-17-2014 12:14 PM
Hello Experts,
I have one report which is display the success and failure deliveries in the day,
the delivery creating time and confirmation time are different so we are getting the wrong result of in other countries
so I want to change the both the time stamps are same.
how can I change it..?
I heard to change the time stamp we can use the function modules any body have any ideas..?
04-17-2014 1:11 PM
Hi,
I'm not 100% sure what you want to change exactly, but for the problem with "wrong" times in different countries you should go for UTC-Timestamps.
This could either be achieved by:
If you then display this Timestamp (i.e. in an ALV), you could use a Field with the Conversion-Exit "TSTLC" so that the timestamp is converted in the local time zone of the current active user.
If this doesn't meet your requirement, please give more detailed information about what exactly you are trying to achieve.
Regards,
Amadeus
04-17-2014 1:24 PM
If an order is received before 12.00 am it is shipped on the same day
The problem with my report is that the creation time is saved in system time and the confirmation time is saved in user time.
So the analysis result is not correct because of the time difference between Europe and Australia.
04-17-2014 1:41 PM
Then my first recommendation should solve your problem - UTC-Times (http://en.wikipedia.org/wiki/Coordinated_Universal_Time😞
Instead of using the system-variables SY-DATUM, SY-DATLO, etc. create in both cases a UTC-Timestamp with GET TIME STAMP FIELD time_stamp.. And for your report you then can convert the timestamp either by:
CONVERT TIME STAMP time_stamp TIME ZONE tz
INTO [DATE dat]
[TIME tim] [DAYLIGHT SAVING TIME dst].
If you just want to calculate the length between those timestamps, you don't need any conversion at all - then you can just calculate with the UTC-Timstamps.
Regards,
Amadeus
04-17-2014 1:57 PM
If you can't change the creation/confirmation process, I would recommend, that you convert both times into utc, that they are on the same level:
CONVERT DATE dat
[TIME tim [DAYLIGHT SAVING TIME dst]]
INTO TIME STAMP time_stamp TIME ZONE tz.
http://help.sap.com/abapdocu_702/de/abapconvert_date_time-stamp.htm
Then you are on the same timezone with both and can do your analysis.
Regards,
Amadeus
04-17-2014 2:33 PM
In both the cases I am using CONVERT only
* convert LIKP server date/time into local date/time
CONVERT DATE likp-erdat TIME likp-erzet
INTO TIME STAMP curstamp TIME ZONE tzone_s.
CONVERT TIME STAMP curstamp TIME ZONE sy-zonlo
INTO DATE likp-erdat TIME likp-erzet.
*convert NAST server date/time into local date/time
CONVERT DATE nast-erdat TIME nast-eruhr
INTO TIME STAMP curstamp TIME ZONE tzone_s.
CONVERT TIME STAMP curstamp TIME ZONE sy-zonlo
INTO DATE nast-erdat TIME nast-eruhr.
04-17-2014 4:12 PM
04-18-2014 6:39 AM
I am getting the value from this:
SELECT SINGLE tzonesys FROM ttzcu INTO tzone_s
WHERE flagactive = 'X'.
both the cases I ma getting TZONE_S = CET, only..
04-18-2014 7:02 AM
This is the my program:
REFRESH w.
SELECT SINGLE tzonesys FROM ttzcu INTO tzone_s
WHERE flagactive = 'X'.
* read deliveries and fill worktable w
SELECT * FROM likp WHERE erdat IN s_date AND
vstel = p_vstel AND
vbtyp EQ 'J'.
* convert LIKP server date/time into local date/time
CONVERT DATE likp-erdat TIME likp-erzet
INTO TIME STAMP curstamp TIME ZONE tzone_s.
CONVERT TIME STAMP curstamp TIME ZONE sy-zonlo
INTO DATE likp-erdat TIME likp-erzet.
MOVE-CORRESPONDING likp TO w.
APPEND w.
ENDSELECT.
*
* NOW LETS CHECK THE DELIVERY NOTEs
* Sort added (necessary in Europe system)
SORT w BY vbeln erdat erzet.
LOOP AT w.
* default success to NO
vbeln = w-vbeln. "WITH LEADING ZERO'S
success = 'N'. CLEAR errtxt.
*
SELECT SINGLE * FROM nast WHERE kappl = 'V2' AND
objky = vbeln AND
kschl = 'Z53L' AND
aktiv = space.
IF sy-subrc = 0.
* convert NAST server date/time into local date/time
CONVERT DATE nast-erdat TIME nast-eruhr
INTO TIME STAMP curstamp TIME ZONE tzone_s.
CONVERT TIME STAMP curstamp TIME ZONE sy-zonlo
INTO DATE nast-erdat TIME nast-eruhr.
* find next working day
nextwd = w-erdat + 1.
CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'
EXPORTING
correct_option = '+'
date = nextwd
factory_calendar_id = tvst-fabkl
IMPORTING
date = nextwd.
* check time before cut-off time
* same date = success
IF w-erzet LE p_cuttim AND
nast-erdat EQ w-erdat.
success = 'Y'.
ENDIF.
* check next working day
IF w-erzet GT p_cuttim AND
nast-erdat LE nextwd.
success = 'Y'.
ENDIF.
w2-erdat = w-erdat.
IF success = 'Y'.
w2-success = 1.
w2-failure = 0.
ELSE.
w2-success = 0.
w2-failure = 1.
errtxt = 'GI too late'.
IF nextwd GT sy-datum.
errtxt = 'still time to success'.
ENDIF.
ENDIF.
w2-deliveries = 1.
COLLECT w2.
ELSE. " sy-subrc select nast
w2-erdat = w-erdat.
w2-success = 0.
w2-failure = 1.
w2-deliveries = 1.
COLLECT w2.
errtxt = 'Not printed (no NAST)'.
ENDIF.
* append failure information
IF success = 'N'.
CLEAR failures.
MOVE-CORRESPONDING w TO failures.
IF errtxt = 'GI too late'.
failures-erdat2 = nast-erdat.
failures-eruhr = nast-eruhr.
ENDIF.
failures-text = errtxt.
APPEND failures.
ENDIF.
ENDLOOP.
04-18-2014 7:16 AM
That won't work, because that is the system-timezone and you can't be sure, that that is also the users time zone.
I would try this:
DATA: lt_return TYPE bapiret2_t,
ls_logondata TYPE bapilogond.
CALL FUNCTION 'BAPI_USER_GET_DETAIL'
EXPORTING
username = likp-ernam
IMPORTING
logondata = ls_logondata
TABLES
return = lt_return.
CONVERT DATE likp-erdat TIME likp-erzet
INTO TIME STAMP curstamp TIME ZONE ls_logondata-tzone.
And the same with NAST-USNAM.
Regards,
Amadeus