How to display Employee Attendance Data in Crosstab Format?
Hi all,
I have the data in sql server 2005 like below, which saves the employee in date and in time and entry type
How can i create a cross tab query for the above records in sql server 2005. and i need the record in the below format:
where 1, 2, 3 are indate days, and below is intime, out time and the difference of hours per employee...
How can i achieve it as i have to make report for it... need sql query or stored procedure for the format required.
Thanks in adv.
One could argue that the crosstab is best produced in the presentation layer and that SQL Server should only return the raw data. But if you like to hurt yourself...
First you need an unpivoting query to put starttime, endtime and length in a single row. Since all columns in a row needs to have the same data type, this requires some care.
We take this CTE:
WITH CTE AS (
SELECT t.EmpID, u.n, datepart(day, t.starttime) AS day
substring(convert(char(23),
CASE u.n WHEN 1 THEN t.starttime
WHEN 2 THEN t.endtime
WHEN 3 THEN dateadd(ss, datediff(ss, t.starttime, t.endtime), '19000101')
END, 108), 11, 5)
FROM tbl
CROSS JOIN (SELECT n = 1 UNION ALL SELECT 2 UNION ALL SELECT 3)
WHERE t.starttime >= @month + '01'
AND t.starttime < dateadd(month, 1, @month + '01')
I assume here that @month is on the form YYYYMM.
Before I go on, I like to point out that something you need to consider is what output you want if there are multiple entries the same day. And even worse, what output do you want if the intervals are overlapping? To keep this post down in complexity, I
will ignore this situation, but I like to stress that unless you have the appropriate triggers and constraints in place, you will have that sort of data in a real production scenarion. Bad data knows how to creep in.
With the CTE above, we can now pivot the data per day. It is kind of boring to write:
SELECT EmpID,
MIN (CASE day WHEN 1 THEN data END) AS [1],
MIN (CASE day WHEN 2 THEN data END) AS [2],
MIN (CASE day WHEN 31 THEN data END) AS [31]
FROM CTE
GROUP BY EmpID, n
ORDER BY EmpID, n
Note: all code here is untested. If you want a tested solution, you need to supply the CREATE TABLE statements for your table and sample data as INSERT statements.
Erland Sommarskog, SQL Server MVP, [email protected]
Similar Messages
-
How to display webdynpro view data in PDF format.
Dear All,
Greetings!!!
scenario :
i am having five tabstrips in a table , first four for the different kinds of data
and fifth one is for to display all tabstrips data in a PDF format.
Kindly let me know how to acheive this .
is it possible with out ADLC..? any demo or article is available for similar requirement?
Thanks in Advance.
Best Regards,
Kranthikumar Palle.It's better to use the Adobe form to display your WD data. But you can choose Smartform as a PDF doc to display the WD data.
Check out the thread [Display a Smartform as PDF document in WD ABAP|http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f0de1eb8-0b98-2910-7996-8a3c2fcf6785] for more details. -
How to display the header data on different position in alv report
hi all,
how to display the header data on different position in alv report.
for example ,
customer name
xxxx xxxx
vendor name street
xxxx xxxx xxxxx
pls help me .hi
as per my understanding you need to trnasfer header internal table data to pdf..
please check the following links for internal table to pdf..
Convertion of Internal table data to PDF
This link is related to ur issue
Re: how to insert the calling of the FM: OTF to PDF
Thanks -
Need a function to calculate employee attendance data for a given period
need a function to calculate employee attendance data for a given period
as
Working days,
CL ,
SL,
PL,
LWP
regards,
Gaurav Sood.Issue resolved
-
How to display the current date in the prompt value.
Hi,
How to display the current date in the prompt value. When the user runs the query he want the current date to be displayed in the prompt value and he should also be able to change the date if required ...... I am using web Intellegency BO XI3.0.
Thanks,
Shakthi.Please refer the below link.
Prompt with default date ( currentdate-1 and current date-8)
http://www.dagira.com/2008/07/15/how-can-i-make-today-my-default-prompt-value/
http://www.dagira.com/2008/07/21/using-a-magic-date-value-in-prompts/
Regards,
Bilahari -
How to display planned movement date and actual movement date together?
Hi, Professionals,
My purpose is to list delayed outbound deliveries.
Anyone could tell me how to display planned movement date and actual movement date?
Appreciate your help.Thanks Shiva.
I tried another way to do it. It works only for a short period of time.
By using VL06O, I list all outbound deliveries by limiting both planned goods movement dates and actual goods movements dates to the same week I would like to inspect. Say both from 7th/11 to 14th/11.
then I list outbound delivery list with planned goods movement date to 7th/11 but left out actual goods movements dates this time.
In excel, I compare those two lists and filter out those unique ones because those unique documents means delayed deliveries which cannot delivery according to planned date.
However, the "delayed" list generated by this method has some noises. Not all of documents are really delayed although most of them do.
I'm also looking for a way to list sales documents number of these delayed delivery documents so i can retrieve order details from it such as order value.
Help still needed. -
Displaying metadata, how to display ONLY the Date
I would like to display the Date below each image in Aperture 3. When I select "Date" in the Browser & Viewer Metadata window, the result is a very long string with the Date, the Time and the Time Zone. meaning that most of the time I see nothing because the string is much too long to be displayed...
How to display ONLY the Date ?
Thank you.
Olivierom28 wrote:
I will do that but still... if the Date could be ONLY the Date "without time and time zone", I would be able to display more information.. and it will look nicer.
I said at the top of my first response above: +Afaik, there is no way within Aperture to change the date format of the date metadata overlay.+
Send Aperture feedback to Apple via "Aperture→Provide Aperture Feedback"
In the past I used Expression Media and the config for displaying such info was better.
Aperture has a strange interface for it (and for other parameters), it does not behave at all like an Apple software (for the GUI), probably an external development team... but I agree it is more complex than iPhoto.
Aperture is 10x more complex than iPhoto.
If you want to see a rigid, boxed, "engineer"-style image database interface, take a look at Lightroom 3. It's a great program -- but it's a very different concept of information presentation and interaction.
Thanks again. -
How to write the oracle data as XML format. (.XML file)
create or replace procedure pro(p_number )
is
cursor c1 is select *from emp where empno=p_number;
v_file utl_file.file_type;
begin
v_file := utl_file.fopen('dirc','filename.txt','w');
for i in c1 loop
utl_file.put_line(v_file,i.ename || i.empno ||i.job);
end loop;
closef(v_file);
end;
Now my client want instead of .txt file he need .xml files
File should contains xml tags. can any one help regarding this.. with one example.
How to write the oracle data as XML format. (.XML file)hi,
hope this example will do something....
SQL> select employee_id, first_name, last_name, phone_number
2 from employees where rownum < 6
EMPLOYEE_ID FIRST_NAME LAST_NAME PHONE_NUMBER
100 Steven King 515.123.4567
101 Neena Kochhar 515.123.4568
102 Lex De Haan 515.123.4569
103 Alexander Hunold 590.423.4567
104 Bruce Ernst 590.423.4568
SQL> select dbms_xmlgen.getxml('select employee_id, first_name,
2 last_name, phone_number from employees where rownum < 6') xml
3 from dual;
*<?xml version="1.0"?>*
*<ROWSET>*
*<ROW>*
*<EMPLOYEE_ID>100</EMPLOYEE_ID>*
*<FIRST_NAME>Steven</FIRST_NAME>*
*<LAST_NAME>King</LAST_NAME>*
*<PHONE_NUMBER>515.123.4567</PHONE_NUMBER>*
*</ROW>*
*<ROW>*
*<EMPLOYEE_ID>101</EMPLOYEE_ID>*
*<FIRST_NAME>Neena</FIRST_NAME>*
*<LAST_NAME>Kochhar</LAST_NAME>*
*<PHONE_NUMBER>515.123.4568</PHONE_NUMBER>*
*</ROW>*
*<ROW>*
*<EMPLOYEE_ID>102</EMPLOYEE_ID>*
*<FIRST_NAME>Lex</FIRST_NAME>*
*<LAST_NAME>De Haan</LAST_NAME>*
*<PHONE_NUMBER>515.123.4569</PHONE_NUMBER>*
*</ROW>*
*<ROW>*
*<EMPLOYEE_ID>103</EMPLOYEE_ID>*
*<FIRST_NAME>Alexander</FIRST_NAME>*
*<LAST_NAME>Hunold</LAST_NAME>*
*<PHONE_NUMBER>590.423.4567</PHONE_NUMBER>*
*</ROW>*
*<ROW>*
*<EMPLOYEE_ID>104</EMPLOYEE_ID>*
*<FIRST_NAME>Bruce</FIRST_NAME>*
*<LAST_NAME>Ernst</LAST_NAME>*
*<PHONE_NUMBER>590.423.4568</PHONE_NUMBER>*
*</ROW>*
*</ROWSET>*
ask if you want more assistance.
thanks. -
How to download the Dynamic data into PPT format
Hi Friends,
I have one doubt on WDJ. How to download the Dynamic data into PPT format. For Example Some Dynamic data is available in to View in that One Download Link or button available. Click on Download link or button download that data into PPT Format
Is it possible for WDJ. If possible please tell me.
Or
How to create Business Graphics in Web Dynpro Applications depening up on Excel Data and finally we can download the Business Graphics into powerpoint presentation.
Thank you,
Regards
Vijay Kalluri
Edited by: KalluriVijay on Mar 11, 2011 6:34 AMHi Govindu,
1. I have one doubt on WDJ. Click on either Submit Buttion or LinkToURL UI we can download the file that file having ppt formate(Text.PPT).
I am using NWDS Version: 7.0.09 and Java Version: JDK 1.6
2. is it possible to download the business Graphics in to the PPT by using Java DynPro
Regards
VijayK -
How to convert internal table data to PDF format
HI,
I have an internal table data having one field with 255 chars. length.I want to send that intenal table data as attachemnt with external mail. i am thinking of converting that data into PDF format and use the FM to send the mail. How to convert internal table data to PDF format.
KishoreIn which format is your data in the internal table currently. Is it returned by a smartform/script or its just data fetched from some database table into an internal table. Since its obvious that the data should appear in the PDF with some Layout, you should be using smartform to format the data properly. See the Link
Smartform to PDF to EMAIL
This shows convertion of smartform to pdf and send it through email
Regards,
Abhishek -
Need a POP-UP which can display internal table data in ALV format
HI All,
I need to display INTERNAL TABLE values through a POP-UP. Only condition is that the window with the internal table data should be in ALV format and not in TEXT only format.
To clarify, I used FM 'POPUP_WITH_TABLE_DISPLAY_OK' and 'POPUP_WITH_TABLE_DISPLAY', but both display the data in TEXT format and there is no provision to put the FIELD names there. Everthing needs to be put into internal table and it displays it in text format.
So I want a FM where I can display internal tabel data in ALV format( same format that would appear if you creata search help for a filed and output window would have all the ALV features like SORT buttons etc.
Hope there is some FM to achieve this ALV format data thing.
Thanks in advance for all your help.
Regards
FX3check this
REPORT y_demo_alv_3.
TYPE-POOLS: slis.
DATA: BEGIN OF i_outtab OCCURS 0.
INCLUDE STRUCTURE sflight.
DATA: w_chk TYPE c. "For multiple selection
DATA: END OF i_outtab.
* I_OUTTAB TYPE SFLIGHT OCCURS 0,
DATA: i_private TYPE slis_data_caller_exit,
i_selfield TYPE slis_selfield,
W_exit(1) TYPE c.
PARAMETERS: p_title TYPE sy-title.
START-OF-SELECTION.
SELECT * FROM sflight INTO TABLE i_outtab.
CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
EXPORTING
i_title = p_title
i_selection = 'X'
i_zebra = 'X'
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
i_checkbox_fieldname = 'W_CHK'
* I_LINEMARK_FIELDNAME =
* I_SCROLL_TO_SEL_LINE = 'X'
i_tabname = 'I_OUTTAB'
i_structure_name = 'SFLIGHT'
* IT_FIELDCAT =
* IT_EXCLUDING =
* I_CALLBACK_PROGRAM =
* I_CALLBACK_USER_COMMAND =
* IS_PRIVATE = I_PRIVATE
IMPORTING
es_selfield = i_selfield
e_exit = w_exit
TABLES
t_outtab = i_outtab
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE i000(0k) WITH sy-subrc.
ENDIF.
*****the internal table is modified with a cross sign for marking the
***rows selected
LOOP AT i_outtab WHERE w_chk = 'X'.
WRITE: / i_outtab-carrid, i_outtab-price.
ENDLOOP. -
How can i save a data in text format
how can i save a data in text format in labwindows cvi
Message Edited by Tikoy on 04-14-2010 11:30 PM
Solved!
Go to Solution.Hi,
If your data is in an array, the easiest way is to use the ArrayToFile function.
It automatically creates a file and puts your data in it according to the format you provide.
If you have individual samples that you need to write once in a while, you can either collect them into an array and then use ArrayToFile or open a file with fopen and write them as they are acquired with fwrite.
Hope this helps,
S. Eren BALCI
www.aselsan.com.tr -
How to display employee photo in pdf through WebDynpro OR ABAP print Progr?
hi,
I have uploaded employee photos using TCODE OAOH. Now all the employee photos are stored in Archive link.
Now my requirement is i have get the employee photo and display it in PDF using PDF forms and webdynpro OR using ABAP print program.
I am able to get the employee photo from SAP archive link using ABAP code. After this i have to upload this to MIME reository. From MIME repository i have to display it in PDF forms from WEbDynpro.
I tried with ABAP print program, directly calling the PDF form in program and display the employee data with Employee Photo. With my program i am able to see only employee data. But it's not displaying employee Photo.
Plz any helps to display employee photo in PDF forms using either webdynpro OR ABAP printprogram.
If ur reply is related to WebDynpro, pla tel me how to upload photo to MIME repository From Archive Link.
Since all the employee photos are uploaded into Archive link using Tcode OAOH. From this i have to get the employee photo and upload it to MIME repository and i have to display it in PDF forms.
Any help are appreciated.......
Regards,
Shankar.Hi Sankar,
1)You can use the program BSP_UPDATE_MIMEREPOS to upload the photos in the mime repository.
2)Use the following code to get the content from your mime and set the content to your interactive UI element as Xstring format.
data:
mime_repository type ref to if_mr_api,
content type xstring,
url type string value '/SAP/BC/BSP/SAP/myBSPapplication/rajkumar.jpg' .
mime_repository = cl_mime_repository_api=>get_api( ).
call method mime_repository->get
exporting
i_url = url
importing
e_content = content.
wd_context->set_attribute( name = 'DATAS' value = content ).
Thanks,
Rajkumar.S -
How to display a table data on Screen having a Table control
Hi ,
I am new to ABAP.I would like to display a table data (Eg: ZDemo) on a screen at run time.I have defined a Table control in screen. Now I want to populate data from ZDemo to table control.How can I do that?Please help moving forward in this regard.Hi Gayatri,
After creating table control do the following steps.
1. In the flow logic section write the following code:
PROCESS BEFORE OUTPUT.
MODULE STATUS_0200.
LOOP AT I_LIKP WITH CONTROL LIKP_DATA CURSOR LIKP_DATA-CURRENT_LINE.
MODULE ASSIGN_DATA.
ENDLOOP.
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0200.
LOOP AT I_LIKP.
ENDLOOP.
I_LIKP is the internal table which is used to display table data in the table control.
2. In Process Before Output, in the module STATUS_0200 write the following code:
DESCRIBE TABLE I_LIKP LINES FILL.
LIKP_DATA-LINES = FILL.
In Process After Input, in the module USER_COMMAND_0200 write the following code:
CASE SY-UCOMM.
WHEN 'LIPS'.
READ TABLE I_LIKP WITH KEY MARK = 'X'.
SELECT VBELN
POSNR
WERKS
LGORT
FROM LIPS
INTO TABLE I_LIPS
WHERE VBELN = I_LIKP-VBELN.
IF SY-SUBRC = 0.
CALL SCREEN 200.
ENDIF.
WHEN 'BACK'.
SET SCREEN 200.
ENDCASE.
In Process Before Output and in the module ASSIGN_DATA which is there inside the loop write the following code:
MOVE-CORRESPONDING I_LIKP TO LIKP.
So, Totally your flow logic code should be like this.
TABLES: LIKP, LIPS.
DATA: BEGIN OF I_LIKP OCCURS 0,
VBELN LIKE LIKP-VBELN,
ERNAM LIKE LIKP-ERNAM,
ERZET LIKE LIKP-ERZET,
ERDAT LIKE LIKP-ERDAT,
MARK TYPE C VALUE 'X',
END OF I_LIKP,
BEGIN OF I_LIPS OCCURS 0,
VBELN LIKE LIPS-VBELN,
POSNR LIKE LIPS-POSNR,
WERKS LIKE LIPS-WERKS,
LGORT LIKE LIPS-LGORT,
END OF I_LIPS,
FILL TYPE I.
CONTROLS: LIKP_DATA TYPE TABLEVIEW USING SCREEN 200,
LIPS_DATA TYPE TABLEVIEW USING SCREEN 300.
DATA: COLS LIKE LINE OF LIKP_DATA-COLS.
*& Module USER_COMMAND_0100 INPUT
text
MODULE USER_COMMAND_0100 INPUT.
CASE SY-UCOMM.
WHEN 'LIKP'.
SELECT VBELN
ERNAM
ERZET
ERDAT
FROM LIKP
INTO TABLE I_LIKP
WHERE VBELN = LIKP-VBELN.
IF I_LIKP[] IS INITIAL.
CALL SCREEN 200.
ENDIF.
WHEN 'EXIT'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Module assign_data OUTPUT
text
MODULE ASSIGN_DATA OUTPUT.
MOVE-CORRESPONDING I_LIKP TO LIKP.
ENDMODULE. " assign_data OUTPUT
*& Module STATUS_0200 OUTPUT
text
MODULE STATUS_0200 OUTPUT.
DESCRIBE TABLE I_LIKP LINES FILL.
LIKP_DATA-LINES = FILL.
ENDMODULE. " STATUS_0200 OUTPUT
*& Module USER_COMMAND_0200 INPUT
text
MODULE USER_COMMAND_0200 INPUT.
CASE SY-UCOMM.
WHEN 'LIPS'.
READ TABLE I_LIKP WITH KEY MARK = 'X'.
SELECT VBELN
POSNR
WERKS
LGORT
FROM LIPS
INTO TABLE I_LIPS
WHERE VBELN = I_LIKP-VBELN.
IF SY-SUBRC = 0.
CALL SCREEN 200.
ENDIF.
WHEN 'BACK'.
SET SCREEN 200.
ENDCASE.
ENDMODULE. " USER_COMMAND_0200 INPUT
Save and Activate the program along with the screen in which you have included table control.
Hope this will help you.
Regards
Haritha. -
How to edit employee master data form in SAP B1 9.1?.
Hi all,
I have a problem in SAP B1 9.1.
Is it possible to edit form of Employee Master Data in SAP B1 9.1 without creating an Add-On? Likes how other forms can be edited.
Please anyone can help me.Hi Edey,
Can you please refer to this link:
How to create add-on of a system form in sap b1 9.0?
or 9.1?.
Maybe you are looking for
-
'MD_SALES_ORDER_STATUS_REPORT'
Dear experts, 'MD_SALES_ORDER_STATUS_REPORT' is used to relate the (PR PR PlanOrder Prorder) with Sales Order. I want only see the production orders and planned orders which are shown in CO46. But when the screen go to MD04,the number of (PR PR Plan
-
Hello, i have a trouble after re-installed os for my z30 via sachesi search os from Canada-rogers-z30. i re-install following this responding: http://supportforums.blackberry.com/t5/BlackBerry-Z30/Model-Blackberry-z30-charging-upto-60-only/td-... My
-
My iMac won't connect to my network drive
I have a Buffalo network drive on my network. It is already connected to my PC laptops. I have installed the necessary software, but it will connect through the finder, but it will not go further than the "share" folder. I have pictures and iTunes
-
Help with Creature speakers on iMac...
Ok, so i got the JBL Creature speakers to go with my new iMac and I have one problem. The left satellite speaker has no sound.I am very sure that when we tested it at the store it was playing ok on all speakers. We even tried it on the iMac they had
-
Why are songs greyed out in my itunes
Why are songs greyed out on iTunes? The songs will play within iTunes, but will not sync with my iPod Classic 160G. How do I correct this situation?