Exporting data in rows and columns and loading in RDBMS
<p>I have a scenario wherein i want to export data from HyperionEssbase in <b>rows and coulmns</b> and <b>load it into</b><b>RDBMS</b>. I can load data into RDBMS using informatica if theflat file exported is in form of rows and columns.But when i exportthe file using Hyperion Essbase 9 i get it in from of alldimensions and then the fact value which is not how i want. I wantdata in relational from in flat file itself(row,column).</p><p>Looking forard to your suggestions..Thanks in advance..</p>
<p>Thanks <b>willjordan</b> and <b>twakim</b> for yoursuggestions..</p><p> </p><p>I tried both the techniques and both worked...</p><p>With reference to the technique suggested by <b>twakim</b> , I was able to use that in Hyperion Essbase 9..But in myreal scenario the cube is in Hyperion Essbase 6.5.4.2..Can i usethis Custom defined functions in Hyperion Essbase 6.5.4.2..and ifso how as there is no concept of Analytical server there???</p><p> </p><p>Please help me in this issue???<br></p>
Similar Messages
-
Rows as Columns and Columns as Rows
Hi,
How to print rows as columns and columns as rows?
Suppose I've the following data
colA colB
X 1
Y 2
Z 3
I want the output to be something like
X Y Z
1 2 3.
Is this possible? Please let me know.
Regards,
Jai.The following assumes that there is only one value of colb for each value of cola, but allows for any number of values of cola. The script below creates the query and results below that, given the test data that you provided.
-- script:
STORE SET saved_settings REPLACE
SET ECHO OFF FEEDBACK OFF HEADING OFF PAGESIZE 0 VERIFY OFF WRAP ON
SPOOL query.sql
SELECT 'SELECT MAX (DECODE (cola, ''' || cola || ''', colb)) AS "' || cola || '"'
FROM (SELECT MIN (cola) AS cola
FROM test_table)
SELECT ', MAX (DECODE (cola, ''' || cola || ''', colb)) AS "' || cola || '"'
FROM (SELECT DISTINCT cola
FROM test_table
WHERE cola >
(SELECT MIN (cola)
FROM test_table))
PROMPT FROM test_table
PROMPT /
SPOOL OFF
START saved_settings
START query.sql
-- query and results:
SQL> SELECT MAX (DECODE (cola, 'X', colb)) AS "X"
2 , MAX (DECODE (cola, 'Y', colb)) AS "Y"
3 , MAX (DECODE (cola, 'Z', colb)) AS "Z"
4 FROM test_table
5 /
X Y Z
1 2 3
SQL> -
Interchanging of Rows to Columns and Columns to Rows
Can anyone help me in this query ....
Interchanging of Rows to Columns and Columns to Rows in Oracle
Ex :- Actual Data
EmpId Ename Sal
1 A 2000
2 B 3000
3 C 1000
4 D 3000
Query Result should be like below ::::::::::
after Transposing [ Interchanging of Rows to Columns and Columns to Rows ]the data should come like below
Empid 1 2 3 4
EName A B C D
Sal 2000 3000 1000 3000
Thanks
Kavitha and SudhirPlease see the following links
transpose my table column
http://asktom.oracle.com/pls/ask/f?p=4950:8:1532380262922962983::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:52733433785851
pivot a result set
http://asktom.oracle.com/pls/ask/f?p=4950:8:1532380262922962983::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:124812348063 -
Resulting grid does not contain at least one row, one column and one POV
I have upgraded to 9.3.3 recently.
We have a front end app which will run MDX queries to retrieve data.
Sometimes based on the users selections MDX query might get back nothing i.e will get #missing across all rows/columns and this works fine with the existing 9.3.1 essbase server.
If I run the same query against a 9.3.3 essbase cube I get the error "Resulting grid does not contain at least one row, one column and one POV. If you have any suppress row options selected pls clear them."
I DO NOT have Supress missing data/zero enabled. Not sure why I get this error even though I dont have that option enabled.
Essbase 9.3.3 on HP-UX ITanium 11.31
APS 9.3.3 on win 2003 R2
Smartview 9.3.3 - also tried with smartview 9.3.1.6 and see the same error.
Any suggestions to fix this issues?The front end is using a VBA command "hypexecutequery" and with 9.3.3 essbase I get a return code -9 which means Operation was cancelled as per the smartview doc.
In 9.3.1 essbase I get the return code 0 which means the query is fine even if it does not return any data.
The query I am using now will return nothing as it is a check to see if there is any data. But with 9.3.3 Essbase I get an error code -9 which looks like it does not like the syntax or something.
Any suggestions? -
Can anybody help....SQL to display row as column and column as rows
Can anybody help in writing a SQL to display row as column and column as rows?
Thankscheck this link:
Re: Creating Views - from rows to a new column? -
In the final display list how can i change rows to columns and vice versa
in the final display list how can i change rows to columns and vice versa
It's Urgent
Thanks
BasuHai,
Check this following Threads,
converting rows to columns in internal tables
Re: logic- report to move columns to row in a list
Regards,
Padmam. -
How to transpose the data records (rows) to column(lists) using apd
Hi,
how to transpose the data records (rows) to column (lists) using apd in sap bw.
I do not want to use abap routine.only use the transpose rows to list transformation .
Pls provide the step by step procedure .
thanks,
NimaiSave youe file to transpose as a csv and in the header row of your file for the columns you want to transpose you need to put some soer of a tag before the column name (ie your colum header was for a period budget will be something lie 2011001:ZFIBDD)
1. You will need to create a new apd process (rsanwb)
2. Insert a "Read from Data File" data source object and map it file (,csv)
3. insert a transpose object into your apd process (middle row 4th one over in the transformations section)
4. under the definition tab in the transformation object select all the columns that are to be transposed into rows and move them to the transformed area, the grouping fields section should contain the rows that you want to now be columns
5.under the transformation tab enter in the seperator you selected under the Field Name/Infoobject area (ie. ZFIBDD)
6. under the details tab you need to enter in all the fields to be transformed and tner the transposition field (ie ZFIBDD)
7. Then you can insert a set of transformations and a DSO and link the newly transposed fields into that.
hope that helps -
How to convert a table data from rows to columns?
Hi,
I have a Employee table of the following format:
Emp_id | Emp_name | Salary
101 | James | 1000
102 | Julia | 2000
I have to convert or transpose the table data as follows using a SQL statement/function -
Emp_id | 101 | 102
Emp_name | James | Julia
Salary | 1000 | 2000
How do I achieve this?
Please help me.
Thanks,
993012
Edited by: 993012 on Mar 11, 2013 3:26 AM993012 wrote:
Hi Pavan,
Thanks for the prompt reply.
The link seems to be of not relevant to my question.
My question is to clearly transpose the rows to columns and vice versa without any changes to data.
Regards,
993012I do not see any modification to the data in the Link posted by Pavan. Anyways, One catch with Transposing the Rows is, you need to know the Number of Columns you need to project.
With Static SQL, there is no way to do so. Hence, you will need PL/SQL with Execute Immediate/Dynamic SQL.
See demostration by Tom Kyte on Dynamic Pivots to have a look at the example and adapt to your situation.
Although, I will debate on the need to do it in SQL. Because what you are upto is a part of Reporting and there are many reporting Tools which will have this functionality in-built. SQL, ideally should not be used for reporting purposes. It sole purpose it to store and pass the data to be rendered by Client Software i.e. Java or Third Party tools. -
How to enter a data into the specified column and row in a created table
Hi,
I want to enter some data to specified column and row in a already created table. Please let me know how to do this.
Regards
Shivakumar SinghA table is just a 2D array of strings. Keep it in a shift register and use "replace array element" to modify the desired entry programmatically.
If you want to modify it manually and directly from the front panel, make it into a control and type directly into the desired element. (In this case your program would need to write to it using a local variable).
Atttached is a simple example in LabVIEW 7.0 that shows both possibilities.
LabVIEW Champion . Do more with less code and in less time .
Attachments:
ChangeTableEntries.vi 41 KB -
Best way to export data with r.t. prompts and have dense dim mbrs on rows?
Hi All-
What is the best way to export data with Run time prompts out of Essbase?
One thought was to use Business Rules with run time variables and DATAEXPORT command, but I came across at least one limitation where I cannot have months (part of dense Time Periods dimension) on rows.
I have only two dense dimensions: Accounts and Time Periods and I need both of these on rows. This would come handy when user enter Start and End month and year for data to be exported e.g. If start period is Feb 2010 and end is Jan 2011, I get data for all months in 2010 and 2011.
"CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","402000",14202.24,14341.62,14560,13557.54,11711.92,10261.58,12540.31,15307.83,16232.88,17054.62,18121.76,18236
"CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","403000",19241,21372.84,21008.4,18952.75,23442.13,19938.18,22689.61,23729.29,22807.48,23365,23915.3,24253
"CORP1","0173","FY11","Working","Budget","Local","HSP_InputValue","404000",21364,22970.37,23186,27302,25144.38,27847.91,27632.11,29007.39,24749.42,27183.39,26599,27112.79
where ideally I would need to get the following:
"CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","402000","Feb",14341.62
"CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","402000","Mar",14560
"CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","402000","Apr",13557.54
"CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","402000","May",11711.92
"CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","402000","Jun",10261.58
"CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","402000","Jul",12540.31
"CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","402000","Aug",15307.83
"CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","402000","Sep",16232.88
"CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","402000","Oct",17054.62
"CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","402000","Nov",18121.76
"CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","402000","Dec",18236
"CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","403000","Feb",21372.84
"CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","403000","Mar",21008.4,
"CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","403000","Apr",18952.75
"CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","403000","May",23442.13
"CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","403000","Jun",19938.18
"CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","403000","Jul",22689.61
"CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","403000","Aug",23729.29
"CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","403000","Sep",22807.48
"CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","403000","Oct",23365
"CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","403000","Nov",23915.3
"CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","403000","Dec",24253
"CORP1","0173","FY11","Working","Budget","Local","HSP_InputValue","404000","Jan",21364
Thank you in advance for any tips.Have a read of the following post :- export data to sql
It may give you a further option.
Cheers
John
http://john-goodwin.blogspot.com/ -
Rows as columns and dynamic alv display
Hi everyone,
I need to build a intenal table dynamically as well as dispaly few rows as columns in alv output.
I have seen posts where internal table has been created dynamicaaly as well seen the posts where rows of the table are displayed as columns but, can we achieve both the functionalities at same time.
I have table as:
SO PO Date MAT QTY
1 A X Y1 10
K1 15
M2 11
2 B X1 Y2 5
M1 12
3 C 1x Z1 15
K1 6
L1 10
Now the ouput has to be :
SO PO Date MAT-Y1 MAT-K1 MAT-Y2 MAT-L1 Mat-Z1 MAT-M1 MAT-M2
1 A X 10 15 11
2 B X1 5 12
3 C 1X 6 10 15
I will not be knowing the number of materials untill runtime(dynamic) and as well the rows has to be displayed as columns. Is it possible to do that.
Regards
Edited by: Madhu Posanipalli on Jun 6, 2011 4:51 PMHi,
Check below code. It will work definitly.
*& Report YTEST_PROG_RP
REPORT YTEST_PROG_RP.
type-POOLs slis.
TYPES: BEGIN OF ty_tab,
so TYPE i,
po TYPE c,
date(2) TYPE c,
mat(2) TYPE c,
qty TYPE i,
END OF ty_tab.
DATA: itab TYPE STANDARD TABLE OF ty_tab INITIAL SIZE 0,
jtab TYPE STANDARD TABLE OF ty_tab INITIAL SIZE 0,
ktab TYPE STANDARD TABLE OF ty_tab INITIAL SIZE 0,
wa_tab TYPE ty_tab, wa_j TYPE ty_tab, wa_k TYPE ty_tab.
FIELD-SYMBOLS: <t_dyntable> TYPE STANDARD TABLE,
<fs_dyntable>,
<fs_fldval> type any.
*ALV data declarations
data: fieldcatalog type LVC_T_FCAT, " with header line, "slis_t_fieldcat_alv with header line,
fieldcatalog1 TYPE LVC_s_FCAT,
fieldcatalog2 type slis_t_fieldcat_alv with header line,
gd_tab_group type slis_t_sp_group_alv,
gd_layout type slis_layout_alv,
gd_repid like sy-repid,
gt_events type slis_t_event,
gd_prntparams type slis_print_alv.
DATA t_newtable TYPE REF TO data.
DATA t_newline TYPE REF TO data.
DATA wa_flname TYPE string.
*Start-of-selection.
START-OF-SELECTION.
perform data_retrieval.
perform build_fieldcatalog.
perform dynamic_table.
perform build_layout.
perform build_events.
perform build_print_params.
perform display_alv_report.
*& Form BUILD_FIELDCATALOG
Build Fieldcatalog for ALV Report
form build_fieldcatalog.
DATA: lv_field1 TYPE string, lv_cnt LIKE sy-tabix VALUE 3, itab_lines TYPE i.
DATA: fieldname(20) TYPE c.
DATA: fieldvalue(10) TYPE c.
DATA: index(3) TYPE c.
DATA: wa_cat LIKE LINE OF fieldcatalog2,
wa_colno(2) TYPE n,
wa_flname(5) TYPE c. .
fieldcatalog1-fieldname = 'SO'.
fieldcatalog1-seltext = 'SO'.
fieldcatalog1-col_pos = 1.
fieldcatalog1-outputlen = 2.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
fieldcatalog-do_sum = 'X'.
fieldcatalog-no_zero = 'X'.
append fieldcatalog1 to fieldcatalog.
clear fieldcatalog1.
fieldcatalog1-fieldname = 'PO'.
fieldcatalog1-seltext = 'PO'.
fieldcatalog1-col_pos = 2.
fieldcatalog1-outputlen = 2.
append fieldcatalog1 to fieldcatalog.
clear fieldcatalog1.
fieldcatalog1-fieldname = 'DATE'.
fieldcatalog1-seltext = 'Date'.
fieldcatalog1-col_pos = 3.
fieldcatalog1-outputlen = 2.
append fieldcatalog1 to fieldcatalog.
clear fieldcatalog1.
LOOP AT itab INTO wa_tab.
lv_cnt = lv_cnt + 1.
CONCATENATE 'MAT-' wa_tab-mat into lv_field1.
TRANSLATE lv_field1 TO UPPER CASE.
fieldcatalog1-fieldname = lv_field1.
fieldcatalog1-seltext = lv_field1.
fieldcatalog1-col_pos = lv_cnt.
fieldcatalog1-outputlen = 6.
append fieldcatalog1 to fieldcatalog.
clear fieldcatalog1.
CLEAR: lv_field1, wa_tab.
ENDLOOP.
CLEAR lv_cnt.
Create dynamic internal table and assign to FS
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = fieldcatalog
IMPORTING
ep_table = t_newtable.
ASSIGN t_newtable->* TO <t_dyntable>.
CREATE DATA t_newline LIKE LINE OF <t_dyntable>.
ASSIGN t_newline->* TO <fs_dyntable>.
DESCRIBE TABLE fieldcatalog LINES itab_lines.
loop at fieldcatalog INTO fieldcatalog1.
CLEAR wa_cat.
wa_cat-fieldname = fieldcatalog1-fieldname.
wa_cat-seltext_s = fieldcatalog1-fieldname.
wa_cat-outputlen = fieldcatalog1-outputlen.
APPEND wa_cat TO fieldcatalog2.
CLEAR fieldcatalog1.
ENDLOOP.
endform. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
Build layout for ALV grid report
form build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
gd_layout-totals_only = 'X'.
gd_layout-f2code = 'DISP'. "Sets fcode for when double
"click(press f2)
gd_layout-zebra = 'X'.
gd_layout-group_change_edit = 'X'.
gd_layout-header_text = 'helllllo'.
endform. " BUILD_LAYOUT
*& Form DISPLAY_ALV_REPORT
Display report using ALV grid
form display_alv_report.
gd_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
i_callback_user_command = 'USER_COMMAND'
i_grid_title = outtext
is_layout = gd_layout
it_fieldcat = fieldcatalog2[]
it_special_groups = gd_tabgroup
it_events = gt_events
is_print = gd_prntparams
i_save = 'X'
is_variant = z_template
tables
t_outtab = <t_dyntable>
exceptions
program_error = 1
others = 2.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
endform. " DISPLAY_ALV_REPORT
*& Form DATA_RETRIEVAL
Retrieve data form EKPO table and populate itab it_ekko
form data_retrieval.
DATA: lv_index LIKE sy-tabix.
wa_tab-so = 1.
wa_tab-po = 'A'.
wa_tab-date = 'X'.
wa_tab-mat = 'Y1'.
wa_tab-qty = 10.
append wa_tab to itab.
clear wa_tab.
wa_tab-mat = 'K1'.
wa_tab-qty = 15.
append wa_tab to itab.
CLEAR wa_tab.
wa_tab-mat = 'M2'.
wa_tab-qty = 11.
append wa_tab to itab.
CLEAR wa_tab.
wa_tab-so = 2.
wa_tab-po = 'B'.
wa_tab-date = 'X1'.
wa_tab-mat = 'Y2'.
wa_tab-qty = 5.
append wa_tab to itab.
CLEAR wa_tab.
wa_tab-mat = 'M1'.
wa_tab-qty = 12.
append wa_tab to itab.
CLEAR wa_tab.
wa_tab-so = 3.
wa_tab-po = 'C'.
wa_tab-date = '1x1'.
wa_tab-mat = 'Z1'.
wa_tab-qty = 15.
append wa_tab to itab.
CLEAR wa_tab.
wa_tab-mat = 'K1'.
wa_tab-qty = 6.
append wa_tab to itab.
CLEAR wa_tab.
wa_tab-mat = 'L1'.
wa_tab-qty = 10.
append wa_tab to itab.
CLEAR wa_tab.
LOOP AT itab INTO wa_tab.
if wa_tab-so is NOT INITIAL AND wa_tab-po is NOT INITIAL AND wa_tab-date is NOT INITIAL.
wa_j-so = wa_tab-so.
wa_j-po = wa_tab-po.
wa_j-date = wa_tab-date.
lv_index = wa_tab-so.
else.
READ TABLE itab INTO wa_j WITH KEY so = lv_index.
ENDIF.
wa_j-mat = wa_tab-mat.
wa_j-qty = wa_tab-qty.
APPEND wa_j to jtab.
CLEAR: wa_tab, wa_j.
ENDLOOP.
endform. " DATA_RETRIEVAL
Form TOP-OF-PAGE *
ALV Report Header *
Form top-of-page.
**ALV Header declarations
*data: t_header type slis_t_listheader,
wa_header type slis_listheader,
t_line like wa_header-info,
ld_lines type i,
ld_linesc(10) type c.
Title
wa_header-typ = 'H'.
wa_header-info = 'EKKO Table Report'.
append wa_header to t_header.
clear wa_header.
Date
wa_header-typ = 'S'.
wa_header-key = 'Date: '.
CONCATENATE sy-datum+6(2) '.'
sy-datum+4(2) '.'
sy-datum(4) INTO wa_header-info. "todays date
append wa_header to t_header.
clear: wa_header.
Total No. of Records Selected
describe table it_ekko lines ld_lines.
ld_linesc = ld_lines.
concatenate 'Total No. of Records Selected: ' ld_linesc
into t_line separated by space.
wa_header-typ = 'A'.
wa_header-info = t_line.
append wa_header to t_header.
clear: wa_header, t_line.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = t_header.
i_logo = 'Z_LOGO'.
endform. "top-of-page
FORM USER_COMMAND *
--> R_UCOMM *
--> RS_SELFIELD *
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
Check function code
CASE r_ucomm.
WHEN '&IC1'.
Check field clicked on within ALVgrid report
IF rs_selfield-fieldname = 'EBELN'.
Read data table, using index of row user clicked on
READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.
Set parameter ID for transaction screen field
SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln.
Sxecute transaction ME23N, and skip initial data entry screen
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
ENDIF.
ENDCASE.
ENDFORM. "user_command
*& Form BUILD_EVENTS
Build events table
form build_events.
data: ls_event type slis_alv_event.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = gt_events[].
read table gt_events with key name = slis_ev_end_of_page
into ls_event.
if sy-subrc = 0.
move 'END_OF_PAGE' to ls_event-form.
append ls_event to gt_events.
endif.
read table gt_events with key name = slis_ev_end_of_list
into ls_event.
if sy-subrc = 0.
move 'END_OF_LIST' to ls_event-form.
append ls_event to gt_events.
endif.
endform. " BUILD_EVENTS
*& Form BUILD_PRINT_PARAMS
Setup print parameters
form build_print_params.
gd_prntparams-reserve_lines = '3'. "Lines reserved for footer
gd_prntparams-no_coverpage = 'X'.
endform. " BUILD_PRINT_PARAMS
*& Form END_OF_PAGE
form END_OF_PAGE.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10) type c.
write: sy-uline(50).
skip.
write:/40 'Page:', sy-pagno .
endform. "END_OF_PAGE
*& Form END_OF_LIST
form END_OF_LIST.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10) type c.
skip.
write:/40 'Page:', sy-pagno .
endform. "END_OF_LIST
*& Form dynamic_table
text
--> p1 text
<-- p2 text
FORM dynamic_table .
DATA: lv_s1 TYPE string, lv_s2 TYPE string.
DATA lv_mat TYPE string.
DATA: fieldvalue(10) TYPE c.
ktab[] = jtab[].
delete ADJACENT DUPLICATES FROM ktab COMPARING so.
loop at ktab INTO wa_tab.
Field1
wa_flname = 'SO'.
fieldvalue = wa_tab-so.
CONDENSE fieldvalue NO-GAPS.
ASSIGN COMPONENT wa_flname
OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
<fs_fldval> = fieldvalue.
CLEAR fieldvalue.
Field2
wa_flname = 'PO'.
fieldvalue = wa_tab-po.
CONDENSE fieldvalue NO-GAPS.
ASSIGN COMPONENT wa_flname
OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
<fs_fldval> = fieldvalue.
CLEAR fieldvalue.
Field3
wa_flname = 'DATE'.
fieldvalue = wa_tab-date.
CONDENSE fieldvalue NO-GAPS.
ASSIGN COMPONENT wa_flname
OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
<fs_fldval> = fieldvalue.
CLEAR fieldvalue.
loop at jtab INTO wa_j WHERE so = wa_tab-so.
CONCATENATE 'MAT-' wa_j-mat INTO lv_mat.
wa_flname = lv_mat.
fieldvalue = wa_j-qty.
CONDENSE fieldvalue NO-GAPS.
ASSIGN COMPONENT wa_flname
OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
<fs_fldval> = fieldvalue.
CLEAR: wa_j, fieldvalue.
ENDLOOP.
APPEND <fs_dyntable> TO <t_dyntable>.
CLEAR wa_tab.
FREE <fs_dyntable>.
ENDLOOP.
ENDFORM. " dynamic_table
Ram. -
How to export data from webdynpro to Excel and start a Excel macro
Hello All
I want to export data displayed in the Web dynpro ALV into Excel. I have tried the ALV export function but my problem with it is when it does export to excel the data loses formatting and I have long text in columns which display with wrapping in ALV but when exported to excel it loses formatting.
So I want to define a custom button and when user presses on this button the excel export is called with a macro. Can you kindly share ideas how I can do this from a webdynpro.
Thanks
KarenHi friends!
I have followed the following:
http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=(J2EE3417300)ID1487994050DB10407586481486749551End?blog=/pub/wlg/5522
...in order to create standard ALV with Export to Excel.
However what is exported into excel is awful. It does not contain my data in nice columns... Instead it shows a lot of meta-data.
Please let me know what to do to kick the standard Export button in the correct direction.. that is...to have my nice table in same way in Excel, because that is my intention with "Export to excel"
Best reg
Henrik -
Rows to column and need to nvl for that newly columns
Hi,
I have to create rows to column query in rdf and in turn i have to created excel rtf template to produce excel output.
select max(decode (test.role, 'PA-ELT Member', test.full_name )) ELT_MEMBER,
max(decode (test.role, 'PA-IT Director', test.full_name )) IT_MEMBER,
max(decode (test.role, 'Project Manager', test.full_name )) Project_Manager,
TEST.segment1 project_NUMber,
test.name project_Name,
test.project_id,
test.project_type ,
test.organization_name,
TEST.project_status_name Status_Name,
TEST.start_date Start_date,
TEST.COMPLETION_DATE,
TEST.Planned_OOE,
TEST.Planned_Dep,
TEST.Planned_lab
from
(select
pppv.full_name,
pppv.role,
ppa.name,
ppa.project_id,
ppa.segment1,
ppa.project_type,
(select name from PA_ALL_ORG_V where organization_id = ppa.CARRYING_OUT_ORGANIZATION_ID) organization_name,
ppa.PROJECT_STATUS_CODE,
pps.PROJECT_STATUS_NAME,
ppa.START_DATE,
ppa.COMPLETION_DATE,
(select N_EXT_ATTR1 from PA_PROJECTS_ERP_EXT_B where project_id = ppa.project_id and ATTR_GROUP_ID = 243) Planned_OOE,
(select N_EXT_ATTR2 from PA_PROJECTS_ERP_EXT_B where project_id = ppa.project_id and ATTR_GROUP_ID = 243) Planned_Dep,
(select N_EXT_ATTR3 from PA_PROJECTS_ERP_EXT_B where project_id = ppa.project_id and ATTR_GROUP_ID = 243) Planned_lab
from
PA_PROJECTS_ALL ppa, PA_PROJECT_PLAYERS_V pppv, pa_project_statuses pps
where ppa.project_id = pppv.project_id
and ppa.PROJECT_STATUS_CODE = pps.PROJECT_STATUS_CODE
and pppv.role in ('PA-ELT Member','PA-IT Director','Project Manager')
and ppa.CARRYING_OUT_ORGANIZATION_ID=3994
)test
where 1=1
and TEST.project_type = nvl(:P_PROJECT_TYPE,test.project_type)
and TEST.project_status_name = nvl(:P_PROJECT_STATUS,test.project_status_name)
and TEST.segment1 = nvl(:P_PROJECT_NUMBER,test.segment1)
and TEST.full_name = nvl(:P_ELT_MEMBER, test.full_name)
and test.full_name = nvl(:P_IT_DIRECTOR,test.full_name)
and TEST.full_name = nvl(:P_PROJECT_MANAGER,test.full_name)
group by
TEST.segment1,
test.name,
test.project_id,
test.project_type,
test.organization_name,
TEST.project_status_name,
TEST.start_date,
TEST.COMPLETION_DATE,
TEST.Planned_OOE,
TEST.Planned_Dep,
TEST.Planned_lab
order by TEST.SEGMENT1
see ELT_MEMBER,IT_MEMBER and Project_Manager are columns created from rows to column.
now if i put where clause for this any columns for Eg: ELT_MEMBER it is giving Elt_member column values alone not remaining IT_member and Project Manager it show null even it has values .
it is because of this where clause
and TEST.full_name = nvl(:P_ELT_MEMBER, test.full_name)
and test.full_name = nvl(:P_IT_DIRECTOR,test.full_name)
and TEST.full_name = nvl(:P_PROJECT_MANAGER,test.full_name)
though i have ELT_MEMBER, IT_member and Project Manager column in where clause i have to call parent sql query column full_name.
i have tried to have nvl on column like below.
nvl( max(decode (test.role, 'Project Manager', test.full_name )),(select full_name from PA_PROJECT_PLAYERS_V where project_id = test.project_id and role ='Project Manager')) Project_Manager,
but it is showing error single -row subquery error .
it is possible to have a where clause for rows to columns .
Please help in this regardsSQL> ed
Wrote file afiedt.buf
1 with t as (select 'john,henry,michi,glen' as customer_name, 25000 as credit_limit from dual union all
2 select 'dilon,bryan', 10000 from dual union all
3 select 'raymond', 8000 from dual)
4 -- END OF TEST DATA
5 select regexp_substr(customer_name, '[^,]+', 1, rn) as customer_name, credit_limit
6 from t
7 ,(select rownum rn
8 from dual
9 connect by rownum <= (select max(length(regexp_replace(t.customer_name,'[^,]'))+1) from t))
10 where regexp_substr(customer_name, '[^,]+', 1, rn) is not null
11* order by credit_limit desc
SQL> /
CUSTOMER_NAME CREDIT_LIMIT
john 25000
henry 25000
michi 25000
glen 25000
bryan 10000
dilon 10000
raymond 8000
7 rows selected.
SQL>Just replace "t" with your query to select the data from the external table. -
Transpose columns and rows / Switch columns and rows
Hello,
Is it possible to interchange columns and rows in order to create a left-to-right scrolling table instead of a top-to-bottom scrolling one?
In detail:
I have this:
| col 1 | col 2 | col 3
row 1 | | |
row 2 | | |
row 3 | | |
... | | |
...and want to have this:
| row 1 | row 2 | row 3 | ...
col 1 | | | |
col 2 | | | |
col 3 | | | |
Does anyone know if this is possible with the standard table or the ALV?
Thanks in advance & Kind regards,
RobertHi,
So there is no easy solution by just setting a flag in the ALV config!? ...too bad!
As for the dynamic creation:
Would there be an issue with different data types in one "column" (former row)? As a matter of fact there probably will be a mix of character, numbers, ...
Regards,
Robert -
Mapping of JTable Rows and columns and paint it to the JPanel
Hi,
I am using JTable and graphics object to draw the JTable on JPanel. But due to some lack of measurement I am not able to draw table cells correctly.
Apart from this on changing the fontSize I have to redraw it according to the requirement. But when the data size increases it draws absurdly.
I am using jTable.getCellRect() api to get the row width and height. Please help to redraw a JTable cell row and height on JPanel.
I am also attaching a sample code with this mail.
Thanks,
Ajay
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.*;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.table.*;
import java.util.*;
import java.awt.*;
public class SimpleTableDemo extends JPanel {
private boolean DEBUG = false;
private int spacing = 6;
private Map columnSizes = new HashMap();
String[] columnNames = {"First Name",
"Last Name",
"Sport",
"# of Years",
"Vegetarian"};
Object[][] data = {
{"Kathy", "Smith",
"SnowboardingXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", new Integer(5), new Boolean(false)},
{"John", "Doe",
"Rowing", new Integer(3), new Boolean(true)},
{"Sue", "Black",
"Knitting", new Integer(2), new Boolean(false)},
{"Jane", "White",
"Speed reading", new Integer(20), new Boolean(true)},
{"Joe", "Brown",
"Pool", new Integer(10), new Boolean(false)}
final JTable table = new JTable(data, columnNames);
Panel1 panel;
public SimpleTableDemo() {
super(new GridLayout(3,0));
table.setPreferredScrollableViewportSize(new Dimension(500, 70));
//table.setFillsViewportHeight(true);
if (DEBUG) {
table.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
printDebugData(table);
//Create the scroll pane and add the table to it.
JScrollPane scrollPane = new JScrollPane(table);
//Add the scroll pane to this panel.
add(scrollPane);
panel = new Panel1();
Rectangle rect = table.getCellRect(0,0,true);
panel.setX(table.getWidth());
panel.setY(0);
panel.setWidth(rect.width);
panel.setHeight(rect.height);
panel.setStr(table.getModel().getValueAt(0,0).toString());
panel.setModel(table);
add(panel);
final JComboBox jNumberComboBoxSize = new JComboBox();
jNumberComboBoxSize.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "11", "12", "14", "16", "18", "20", "24", "30", "36", "48", "72" }));
jNumberComboBoxSize.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jNumberComboBoxSizeActionPerformed(jNumberComboBoxSize);
JPanel panel2 = new JPanel();
panel2.add(jNumberComboBoxSize);
add(panel2);
adjustColumns();
private void jNumberComboBoxSizeActionPerformed(JComboBox jNumberComboBoxSize)
int fontSize = Integer.parseInt(jNumberComboBoxSize.getSelectedItem().toString());
table.setRowHeight(fontSize);
table.setFont(new Font("Serif", Font.BOLD, fontSize));
Rectangle rect = table.getCellRect(0,0,true);
panel.setX(0);
panel.setY(0);
// panel.setWidth(rect.width);
panel.setHeight(rect.height);
panel.setStr(table.getModel().getValueAt(0,0).toString());
panel.setModel(table);
panel.repaint();
table.revalidate();
private void printDebugData(JTable table) {
int numRows = table.getRowCount();
int numCols = table.getColumnCount();
javax.swing.table.TableModel model = table.getModel();
System.out.println("Value of data: ");
for (int i=0; i < numRows; i++) {
System.out.print(" row " + i + ":");
for (int j=0; j < numCols; j++) {
System.out.print(" " + model.getValueAt(i, j));
System.out.println();
System.out.println("--------------------------");
* Adjust the widths of all the columns in the table
public void adjustColumns()
TableColumnModel tcm = table.getColumnModel();
for (int i = 0; i < tcm.getColumnCount(); i++)
adjustColumn(i);
* Adjust the width of the specified column in the table
public void adjustColumn(final int column)
TableColumn tableColumn = table.getColumnModel().getColumn(column);
if (! tableColumn.getResizable()) return;
int columnHeaderWidth = getColumnHeaderWidth( column );
int columnDataWidth = getColumnDataWidth( column );
int preferredWidth = Math.max(columnHeaderWidth, columnDataWidth);
panel.setWidth(preferredWidth);
updateTableColumn(column, preferredWidth);
* Calculated the width based on the column name
private int getColumnHeaderWidth(int column)
TableColumn tableColumn = table.getColumnModel().getColumn(column);
Object value = tableColumn.getHeaderValue();
TableCellRenderer renderer = tableColumn.getHeaderRenderer();
if (renderer == null)
renderer = table.getTableHeader().getDefaultRenderer();
Component c = renderer.getTableCellRendererComponent(table, value, false, false, -1, column);
return c.getPreferredSize().width;
* Calculate the width based on the widest cell renderer for the
* given column.
private int getColumnDataWidth(int column)
int preferredWidth = 0;
int maxWidth = table.getColumnModel().getColumn(column).getMaxWidth();
for (int row = 0; row < table.getRowCount(); row++)
preferredWidth = Math.max(preferredWidth, getCellDataWidth(row, column));
// We've exceeded the maximum width, no need to check other rows
if (preferredWidth >= maxWidth)
break;
return preferredWidth;
* Get the preferred width for the specified cell
private int getCellDataWidth(int row, int column)
// Inovke the renderer for the cell to calculate the preferred width
TableCellRenderer cellRenderer = table.getCellRenderer(row, column);
Component c = table.prepareRenderer(cellRenderer, row, column);
int width = c.getPreferredSize().width + table.getIntercellSpacing().width;
return width;
* Update the TableColumn with the newly calculated width
private void updateTableColumn(int column, int width)
final TableColumn tableColumn = table.getColumnModel().getColumn(column);
if (! tableColumn.getResizable()) return;
width += spacing;
// Don't shrink the column width
width = Math.max(width, tableColumn.getPreferredWidth());
columnSizes.put(tableColumn, new Integer(tableColumn.getWidth()));
table.getTableHeader().setResizingColumn(tableColumn);
tableColumn.setWidth(width);
* Create the GUI and show it. For thread safety,
* this method should be invoked from the
* event-dispatching thread.
private static void createAndShowGUI() {
//Create and set up the window.
JFrame frame = new JFrame("SimpleTableDemo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Create and set up the content pane.
SimpleTableDemo newContentPane = new SimpleTableDemo();
newContentPane.setOpaque(true); //content panes must be opaque
frame.setContentPane(newContentPane);
//Display the window.
frame.pack();
frame.setVisible(true);
public static void main(String[] args) {
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
class Panel1 extends JPanel
int x;
int y;
int width;
int height;
String str;
JTable model;
public void setModel(JTable model)
this.model = model;
public void setX(int x)
this.x = x;
public void setY(int y)
this.y = y;
public void setWidth(int w)
this.width = w;
public void setHeight(int h)
this.height = h;
public void setStr(String s)
this.str = s;
public void paint(Graphics g)
super.paint(g);
int initX= 0;
for(int row=0;row < 5; ++row)
initX = x;
for (int col=0;col < 5;++col)
g.drawRect(x,y,width,height);
g.drawString(model.getModel().getValueAt(row,col).toString(),x + 10,y + 10);
x = x + width;
x = initX;
y = y + height;
};an easy way would be to use setSize()
Maybe you are looking for
-
Hi, I wanted to send mails from my solaris box. Below is the step i used # svcs | grep mail # svcadm enable smtp # svcs | grep mail online 14:24:58 svc:/network/smtp:sendmail # mail -s "HELLO" [email protected] Nothing happens after this... i tried w
-
What is Apple's position on iOS4 ipod Touch problems?
Considering all the posts regarding battery drains, sync problems, crashes, and slow operation since the iOS4 release for the ipod Touch 3g it is time for Apple to provide an updated iOS4 and/or fix the problems. Has anyone seen or heard of any infor
-
Keynote 6.2.2 crash on startup
Hi, I have a situation where a presentation is crashing Keynote as soon as it is opened. Looking in the console I get the following 29/09/14 10:33:36,214 Keynote[14287]: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reas
-
Please suggest this how to rectified
Sale for ETAM under head "Sales _ retail(net)" has got uploaded in "sales on Approval" Sale for "Instituional Sales" has got uploaded in "sales-Retail(net)". Please suggest as to how the same can be rectified. very urgent Thank you Anil
-
Hi. I have a problem I have a jdialog and when i click on a button i need open a jframe. i do this but the jframe is not active or not enable. Can you help me? Thanks