10-04-2010 7:50 AM
Hi All,
I have a requirement where we have to find the number of records created on a hourly basis and display it in the report
the date and time are the selection screen fields.
For example if we give the date as 01.10.2010 to 04.10.2010 and time as 01.00.00 to 20.00.00, we should display the report in hourly basis like
1st hour 01,10.2010 2nd hour 01.10.2010...........so on 1st hour 02,10.2010.........20th hour 04.10.2010
No of records 1 20 10 40
How can we find the number of records in an internal table based on time.
thanks
Rajesh
10-04-2010 7:58 AM
Write a program that keeps track of the time, and the number of records within that time?
What is the problem here? Do you know how to program?
10-04-2010 8:55 AM
Hi Matt,
Wanted to know if there are any standard functionalities available.. since my requirement is not restricted to a single scenario..we have to find all the documents..
I would have asked for a sample code if i would not be able to code..hope u get it?
Regards,
Rajesh.G
10-04-2010 9:50 AM
To the best of my knowledge there is no standard function module that will do this, what appears to me, very specific requirement.
You'll have to code it.
10-04-2010 6:36 PM
Hi there,
You've provided to less information. In order to help you please be more precise: the records you have to count on a time basis are created by you or in a custom program? Or they are standard objects in the system (e.g. invoices, orders, etc)?
In both cases there are solutions to your problem, but I need to know which the case.
And NO, there is no standard functionality for what you want.
br
10-05-2010 3:32 AM
Hi,
We have to find the number of the Orders,Deliveries and PGIED Delivries. These are being created with the normal process through the standard transactions....and some of the deliveries are being created from the flat file through the custom program
Please let me know if any thing is required. As of now i am fetching the data from the respective standard tables based on the date and time..
Regards,
Rajesh.G
10-05-2010 6:13 AM
Hi,
I supose that the custom program loads deliveries from the flat file and calls a standard process flow to create the deliveries in the system (I mean here you don't use a "Direct Input" technique). In this case all documents should already possess information about creation time and date, regardless of the document kind (orders, deliveries, etc.). These 2 fields are named ERZET (time of creation) and ERDAT (date of creation).
What you have to do:
1. Create 2 select-options in your selection screen, e.g.:
S_ERDAT FOR VBAK-ERDAT,
S_ERZET FOR VBAK-ERZET.
2. Use any technique you'd like, to split the entered dates and times in hourly intervals (and eventually store these intervals in an internal table with a low/high structure - like ranges/select options)
3. Select the data from DB using the criteria imposed by your functional spec requirements AND add criteria for creation time and creation date (with select-options from above)
3. Loop the itab with hourly intervals
4. Inside the above loop, make a new loop on the itab with the data fetched from DB and using as WHERE clause the hourly interval from the above loop
5. Do anything you want with selected data.
6. Endloop(s).
Splitting of input times and dates in hour intervals depends on the imposed constraints over the select-options, if any. For e.g. you may impose the user, by coding, to enter only single and continuous intervals for time and date in the selection screen.
10-05-2010 7:03 AM
Look here
TABLES: vbak.
DATA: lwa_vbak TYPE vbak,
lt_vbak TYPE STANDARD TABLE OF vbak.
TYPES: BEGIN OF ty_hours,
start_date TYPE erdat,
start_time TYPE erzet,
end_date TYPE erdat,
end_time TYPE erzet,
END OF ty_hours.
DATA: lwa_hour TYPE ty_hours,
lt_hours TYPE STANDARD TABLE OF ty_hours.
DATA: lv_timediff TYPE sy-index.
* Selection Screen
SELECT-OPTIONS: s_erdat FOR vbak-erdat NO-EXTENSION OBLIGATORY DEFAULT '20101005' TO '20101006',
s_erzet FOR vbak-erzet NO-EXTENSION OBLIGATORY DEFAULT '010000' TO '200000'.
* Ensure end date is filled
AT SELECTION-SCREEN ON s_erdat.
IF s_erdat-high IS INITIAL.
MESSAGE e001(00) WITH 'end date to be filled'.
ENDIF.
* Ensure end time is after start time, in case of same day
AT SELECTION-SCREEN ON s_erzet.
IF s_erdat-low = s_erdat-high.
IF s_erzet-low > s_erzet-high.
MESSAGE e001(00) WITH 'start time must be greater than end time'.
ENDIF.
ENDIF.
START-OF-SELECTION.
* Ignore minutes and seconds
s_erzet-low+2(4) = '0000'.
s_erzet-high+2(4) = '0000'.
* The case of the same day
IF s_erdat-low = s_erdat-high.
lv_timediff = ( s_erzet-high - s_erzet-low ) / 3600.
DO lv_timediff TIMES.
CLEAR lwa_hour.
lwa_hour-start_date = s_erdat-low.
lwa_hour-end_date = s_erdat-low.
lwa_hour-start_time = s_erzet-low + ( sy-index - 1 ) * 3600.
* here you can add 3600 but in the loop below operator LE will be changed to LT
lwa_hour-end_time = lwa_hour-start_time + 3599.
ENDDO.
ENDIF.
* Similar is treated the case for different days,
* but you will have 3 parts: start date, end date and
* dates between start and end
* Fetch the data from DB
SELECT * INTO TABLE lt_vbak
FROM vbak
WHERE erdat IN s_erdat
AND erzet IN s_erzet.
* Split by hours
LOOP AT lt_hours INTO lwa_hour.
LOOP AT lt_vbak INTO lwa_vbak WHERE erdat GE lwa_hour-start_date
AND erdat LE lwa_hour-end_date
AND erzet GE lwa_hour-start_time
AND erzet LE lwa_hour-end_time.
* do what you need here
ENDLOOP.
ENDLOOP.
10-05-2010 10:58 AM
Hi,
Thanks for your suggestion. Followed a similar approach...in order to meet the requirement.
Regards,
Rajesh.G