Generating dynamic columns for a report
Hi all,
Can anybody pls. tell me how to output dynamic columns in a report. my req. is that i've to generate so many columns as there are no. of unique(a particular field value) rows in my internal table. for e.g say suppose i've 5 rows in my internal table which has 2 fields, one short text & it's corresponding value. so now my report output shud have 5 columns with the short text as the column heading & the their corresponding values below each column heading. i heard it can be done thru field-symbols. can anyone pls. guide me.
Hi Sushma,
This piece of code might be useful.
The following sections will help you to understand the steps required to define a Dynamic ALV.
Following symbol signifies:
Þ Important
Main Steps Required
The following are the main steps that are to be performed for defining a dynamic Alv
1. Defining a field catalog
2. Defining the dynamic table
3. Filling data into the table
4. Displaying ALV list
Defining a field catalog
The purpose of defining a field catalog first in case of Dynamic ALV is somewhat different than in case of normal ALV. In case of Dynamic ALV the field catalog is used to define the final internal table that will hold the data, and would be used to display the final output.
Þ It is very important to remember that the field catalog table be refreshed first, else it might give an error.
For example:
DATA: T_FIELDCAT TYPE LVC_T_FCAT,
L_FIELDCAT TYPE LVC_S_FCAT.
Refresh T_FIELDCAT.
CLEAR L_FIELDCAT.
L_FIELDCAT-FIELDNAME = 'LIFNR'.
L_FIELDCAT-INTTYPE = ''.
L_FIELDCAT-OUTPUTLEN = 10.
L_FIELDCAT-COLTEXT = TEXT-002.
APPEND L_FIELDCAT TO T_FIELDCAT.
Defining the dynamic table.
This table will hold the final data that needs to be displayed. To declare the table the following things need to be done.
Declare a field symbol
Displaying Alv List
This is done in the same way as we do for normal Alv. Call function REUSE_ALV_GRID_DISPLAY and pass the field catalog table in the export parameters and the dynamic table in Tables.
Reward Points if it is helpful.
Reagrds,
Kiran I
Similar Messages
-
halo fellow SAPiens,
i need to show dynamic columns for a particular material........the scenario is as follows....
1) there r 7 fixed columns describing the material...
2)when the material returns back to the plant for some reason , i need to insert a column which shows the date and reason(char) of return.
3)again after dispatching the material for some reason it comes back again a new column shld be displayed showin the date and reason(char).
4)if the material doesnt come back...the report shows only 7 columns.
any solution?try <a href="http://www.alvrobot.com.ar/home.php">here</a> ......its a useful tool for dealing with ALV
<b>reward points if useful</b> -
Generating dynamic column in planning layout
Hi Guys,
I am new to BPS.. My task is user inputs calendar year thru variable, based on the year it has generate dynamic columns as month of the year entered by the user.
Dnt know i am right or wrong based on the sdn threads. i think i have to create user input variable, and create a FM to read the user input value. Upto to this i can understand, after reading the user input how to calculate the months and generate 12 columns dynamically for each month...
Kindly help me in this scenario..
Edited by: kevin peterson on Jun 6, 2008 5:23 AMHi,
I hope you are using calendar year/month and calendar year characteristics. Create an user input variable for calendar year,
create one exit variable for calendar year month.
Inside this exit, read the value of the user input variable, append the year with all 12 months, so u get 12values for this exit variable.
Now keep calendar year in header, restricted by user input variable, create one data column dynamic for calendar year month restricted by this exit variable. This will generate 12columns dynamically.
Bindu -
Designing Dynamic column in BI Report Template
Hi,
In one of my report i have a table grid where the columns are dynamic.How do i design dynamic column in BI rtf Template
Is it possible to hide/Show column for BI report
Please advice
Regards
JeethiHi ,
Check the below link
http://download.oracle.com/docs/cd/E10091_01/doc/bip.1013/b40017/T421739T481157.htm#4535400
search for the Column Formatting you will find the example for dynamic cloumn creation.
Thanks,
Ananth -
How can I get (using API) the current sort column for some report
hello,
How can I get (using API) the current sort column for some report ? For example something like "fsp_sort_1_desc" - if the user sorts by the first column ?
I cannot use the :REQUEST for this, sometimes the current sort column is not in the :REQUEST, but it is still active.
I thought it was posssible by using
APEX_UTIL.GET_PREFERENCE (
p_preference IN VARCHAR2 DEFAULT NULL,
p_user IN VARCHAR2 DEFAULT V('USER'))
RETURN VARCHAR2;
function, but I don't really know which preference should I pass as parameter.
looking in WWV_FLOW_PREFERENCES$, i saw preferences_names like FSP4000_P527_R6281510839654570_SORT , I'm not sure how this name is formed.
I'm using generic columns for that complex report (which has a flexible number of columns shown), and the idea is that sometimes I have to overwrite that sort column, in case the user chose the version of the report with fewer columns than the previous one.
Can I get (using API) a list of all preferences set for some user ?
Thank you,seems that it is FSP<app_number>P<pagenumber>R<regionnumber>_SORT.
is there anyplace where I can get these kind of things documented ?
Thank you. -
Define Dynamic column for integrated inbox
hi ,
can any one explain me what is the puprose of this setting.
SPRO>SRM>Cross application basic settings>sap business workflow>define Dynamic columns for integarted inbox.
what we maintain here and how it is helpful
regards
subhashHi Subhash,
Please check if the following link helps you:
How to add an extra dynamic columns in workflow inbox?
Regards,
Saumya -
How to generate Excle file for a report runningin a Batch job
Hello All,
Can we generate Excle file for a report running in a Batch job.
Kindly send reply to [email protected]
Thanks in Advance.
Cheers,
SundeepDear Sundeep,
I'm providing you with the following piece of code ... Its working fine for me ... hopefully it suits your requirement ...
D A T A D E C L A R A T I O N *
TYPES: BEGIN OF TY_EXCEL,
CELL_01(80) TYPE C,
CELL_02(80) TYPE C,
CELL_03(80) TYPE C,
CELL_04(80) TYPE C,
CELL_05(80) TYPE C,
CELL_06(80) TYPE C,
CELL_07(80) TYPE C,
CELL_08(80) TYPE C,
CELL_09(80) TYPE C,
CELL_10(80) TYPE C,
END OF TY_EXCEL.
DATA: IT_EXCEL TYPE STANDARD TABLE OF TY_EXCEL,
WA_EXCEL TYPE TY_EXCEL..
E V E N T : S T A R T - O F - S E L E C T I O N *
START-OF-SELECTION.
Here you populate the Internal Table.
Display - Top of the Page.
PERFORM DISPLAY_TOP_OF_PAGE.
E V E N T : E N D - O F - S E L E C T I O N *
END-OF-SELECTION.
SET PF-STATUS 'GUI_STATUS'.
E V E N T : A T U S E R - C O M M AN D *
AT USER-COMMAND.
CASE SY-UCOMM.
WHEN 'EXPORT'.
Exporting the report data to Excel.
PERFORM EXPORT_TO_EXCEL.
ENDCASE.
*& Form DISPLAY_TOP_OF_PAGE
text
--> p1 text
<-- p2 text
FORM DISPLAY_TOP_OF_PAGE .
SKIP.
WRITE: /05(128) SY-ULINE,
/05 SY-VLINE,
06(127) 'O R I C A'
CENTERED COLOR 1,
132 SY-VLINE.
WRITE: /05(128) SY-ULINE,
/05 SY-VLINE,
06(127) 'Shift Asset Depreciation - Period/Year-wise Report.'
CENTERED COLOR 4 INTENSIFIED OFF,
132 SY-VLINE.
WRITE: /05(128) SY-ULINE.
E X C E L O P E R A T I O N
CLEAR: IT_EXCEL[],
WA_EXCEL.
PERFORM APPEND_BLANK_LINE USING 1.
WA_EXCEL-cell_02 = ' XYZ Ltd. '.
APPEND WA_EXCEL TO IT_EXCEL.
CLEAR: WA_EXCEL.
WA_EXCEL-cell_02 = 'Shift Asset Depreciation - Period/Year-wise Report.'.
APPEND WA_EXCEL TO IT_EXCEL.
PERFORM APPEND_BLANK_LINE USING 1.
ENDFORM. " DISPLAY_TOP_OF_PAGE
*& Form APPEND_BLANK_LINE
text
-->P_1 text
FORM APPEND_BLANK_LINE USING P_LINE TYPE I.
DO P_LINE TIMES.
CLEAR: WA_EXCEL.
APPEND WA_EXCEL TO IT_EXCEL.
enddo.
ENDFORM.
*& Form EXPORT_TO_EXCEL
text
--> p1 text
<-- p2 text
FORM EXPORT_TO_EXCEL .
DATA: L_FILE_NAME(60) TYPE C.
Create a file name
CONCATENATE 'C:\' 'Shift_Depn_' SY-DATUM6(2) '.' SY-DATUM4(2)
'.' SY-DATUM+0(4) INTO L_FILE_NAME.
Pass the internal table (it_excel which is already populated )
to the function module for excel download.
CALL FUNCTION 'WS_EXCEL'
exporting
filename = L_FILE_NAME
tables
data = IT_EXCEL
exceptions
unknown_error = 1
others = 2.
if sy-subrc <> 0.
message e001(ymm) with 'Error in exporting to Excel.'.
endif.
ENDFORM. " EXPORT_TO_EXCEL
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When you click the button - Export to Excel ( GUI-Status) you'll be able to export the content of the Internal Table to an Excel file .......
Regards,
Abir
Don't forget to award points * -
Cannot generate dynamic alert for initial column in SNP.
Hello,
I have an SNP alert macro with a simple condition running from Initial column for 158 weeks. The alert is generated correctly for all other weeks but not for initial column.
The IF condition works correctly because a CELL_BG() in the same alert macro is correctly changing the color of the Initial column cell.
Is there some setting I need to make to generate alert for initial column?
Regards,
SSHello jejeje,
thanks for your efforts - what you describe is something users have found out on our side too - a problem remains: you can save this setting "Period from last Selection" and it brings you to the INITIAL column but: once you have scrolled forward in the SNP data view (so that the INITIAL column has disappeared) and you leave the SNP data view or select another product ... it "remembers" that you last time left the data view NOT having INITIAL column as a start column.
So, my users say that they scroll back to INITIAL column before selecting another part or using another SelectionID or leaving the SNP data view ... and of course they hate this since they have to do this a few hundred times a day worse case.
We had a call open to SAP on this and I told them that is about productivity and usabaliity issue moving from SCM5.0 to SCM7.0 - but they have nothing more to say than "not supported anymore" - and the ultimate solution is / will be to modifiy SAP SCM standard coding - unless somebody from SAP is reading the discussioons here and is dedicated to help their customers which pay millions every year into SAP support fees.
Thanks for your responses and effort !
Regards
Thomas -
Hi,
I have to generate a report which contains a query with database link. This database link is not hard coded and would be picked up from another report which contans a link to this report. So this database link value for the query could be any. Can anyone guide me hot to write a dynamic select statement so that i could append database link value at run time.
Thanks
SalmanHi,
You can not directly use a PL/SQL query to create an Interactive Report - that is not yet available.
What you could do is create a collection from your query and then use that for the report. Have a look at: [http://download-uk.oracle.com/docs/cd/B32472_01/doc/appdev.300/b32471/advnc.htm#BABGHJFD].
In there, you will see APEX_COLLECTION.CREATE_COLLECTION_FROM_QUERY - this allows you to create a collection from a string. You could add a PL/SQL process to your page that runs "On Load: Before Header" that actually creates the collection. Something like:
BEGIN
IF APEX_COLLECTION.COLLECTION_EXISTS('MYCOLLECTIONNAME') THEN
APEX_COLLECTION.DELETE_COLLECTION('MYCOLLECTIONNAME');
END IF;
APEX_COLLECTION.CREATE_COLLECTION_FROM_QUERY('MYCOLLECTIONNAME','MY SQL QUERY STRING');
END;Your Interactive Report can then be based on:
SELECT SEQ_ID, C001, C002, C003, ...
FROM APEX_COLLECTIONS
WHERE COLLECTION_NAME = 'MYCOLLECTIONNAME'The tricky part is the headings as these would tend to be the SEQ_ID, C001, C002, C003, etc column names from the collection itself.
To get around this, make sure that the report's sql statement includes as many Cnnn columns as you will need for the widest of the reports. Before doing anything else, run the report once to make sure that all these columns are included in the output.
Then, through Shared Components, Application Items, create items that will hold heading names - for example, G_HEADING1, G_HEADING2 etc - one for each possibile column.
Now, update the process to:
BEGIN
IF APEX_COLLECTION.COLLECTION_EXISTS('MYCOLLECTIONNAME') THEN
APEX_COLLECTION.DELETE_COLLECTION('MYCOLLECTIONNAME');
END IF;
IF ..test1.. THEN
APEX_COLLECTION.CREATE_COLLECTION_FROM_QUERY('MYCOLLECTIONNAME','MY SQL QUERY STRING 1');
:G_HEADING1 := 'ColumnHeading1Value';
:G_HEADING2 := 'ColumnHeading2Value';
:G_HEADING3 := NULL; -- column not used for this query, so set it to null
ELSIF ..test2 .. THEN
APEX_COLLECTION.CREATE_COLLECTION_FROM_QUERY('MYCOLLECTIONNAME','MY SQL QUERY STRING 2');
:G_HEADING1 := 'ColumnHeading1Value';
:G_HEADING2 := 'ColumnHeading2Value';
:G_HEADING3 := 'ColumnHeading3Value';
ELSIF ...etc...
.. etc ...
END IF;
END;Finally, on the report itself, set the column headings to *&G_HEADING1.*, *&G_HEADING2.* etc. Then, on each column, set a Condition of "Value of Item in Expression 1 is NOT NULL" and in Expression 1, enter in the application item for that column - eg, G_HEADING1
I have done all that here: [http://apex.oracle.com/pls/otn/f?p=16338:5] - select either Departments or Employees from the list and the report will change.
Andy -
Creating dynamic columns in rdlc report
Hi,
I want to generate an rdlc report where columns are not fixed and decided on the basis of user input.
So I can not design the report before and it should be done dynamically at run time. I have the data in datatable.
Can anyone help how to achieve this.Hi,
You can do this by creating a crosstab report so that the column heading is from an item in the folder.
You cannot have dynamic headings for a table report.
Rod West -
How to Generate Dynamic Columns from SQL
Hi Friends,
I want to create a data fromat like This
Showroom / date 01-01-09 02-01-09 03-01-09 04-01-09 05-01-09 06-01-09 07-01-09
S1 20 10 09 90 90 10 100
S2 10 1 1 2 6 2 10
S3 5 7 9 1 2 3 12This Data is Just like Matriz Reports....................................
Here i Want to Generate Date column value Dynamically.....................is it possible through SQL
the values are Sales value for each showroom for diffrent date value
all sale,showroom and Date Column are in one Table......................
It should Generate date Dynamically depending on User VAlues./..............
Thanks in Advancesomething to play with (not tested as I don't have database access)
declare
/* assuming table showroom_sales has columns a_showroom,a_date,a_sale */
the_sql varchar2(32000) := 'select a_showroom';
day_from date := to_date('20090101','yyyymmdd');
day_till date := to_date('20090107','yyyymmdd');
begin
for d in (select a_date from showroom_sales where a_date between day_from and day_till)
loop
the_sql := the_sql ||
',max(decode(a_date,to_date('''||to_char(d.a_date,'yyyymmdd')||''',''yyyymmdd''),a_sale,null)) "'||to_char(d.a_date,'dd-mm-rr')||'"'
end loop;
the_sql := the_sql || ' from showroom_sales group by a_showroom order by a_showroom ';
dbms_output.put_line(the_sql); /* to verify if query is correct or not */
end;the code above should generate something like (provided all those dates appear in your showroom_sales table)
select a_showroom,
max(decode(a_date,to_date('20090101','yyyymmdd'),a_sale,null)) "01-01-09",
max(decode(a_date,to_date('20090102','yyyymmdd'),a_sale,null)) "02-01-09",
max(decode(a_date,to_date('20090103','yyyymmdd'),a_sale,null)) "03-01-09",
max(decode(a_date,to_date('20090104','yyyymmdd'),a_sale,null)) "04-01-09",
max(decode(a_date,to_date('20090105','yyyymmdd'),a_sale,null)) "05-01-09",
max(decode(a_date,to_date('20090106','yyyymmdd'),a_sale,null)) "06-01-09",
max(decode(a_date,to_date('20090107','yyyymmdd'),a_sale,null)) "07-01-09"
from showroom_sales
group by a_showroom
order by a_showroom to be executed to get the result as required
Regards
Etbin -
Hi,
In my report i have dynamic columns and i am achieving this using <?split-column-header:header?> , <?split-column-data:variable?>
I need to define width for the dynamically created columns.
How do i achieve this.
i have seen <?split-column-width:name?>,<?split-column-width:@width?>
I tried <?split-column-header:header?><?split-column-width:@200pt?><?heading?><?end split-column-data?> but didn't succeed.
Please advice.
Regards
Jeethi GeorgeHi User
Try this link
Dynamic columns in OBIEE -
How apex generate LOV values for Interactive report
Scott,
For interactive report, does APEX full table/index scan to generate the LOV drop down list every time user click the column header? If I set max row count to 100, does LOV values only derived from the first 100 rows that apex hits?
If I enter SQL query in "list of value definition", will that sql get executed every time users click the column header or the result is cached?
For standard and interactive report, does APEX parse (soft/hard) the sql statement again when user do pagination?Hi N.Raj,
{thread:id=2245456}
Yes you have to Configure BI Publisher or other.
{thread:id=2242147}
Hope it helps!
Regards,
Kiran -
To increase dynamically columns in ALV report
hi everyone,
Could any one give me a sample code ,to increase columns in ALV report output dynamically as record increase, i need to increase columns so that i can keep all the years data of a particular project in one rowPlease refer to the code piece
*& Report ZTEST_DYNAMIC_ALV
REPORT ztest_dynamic_alv.
DATA: gt_fcat TYPE lvc_t_fcat,
gw_grid TYPE REF TO cl_gui_alv_grid.
SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-s01.
PARAMETERS: p_number TYPE i.
SELECTION-SCREEN : END OF BLOCK b1.
** Start of Selection
START-OF-SELECTION.
*1) Create Base Catalog
PERFORM sub_create_base_catalog.
*2) Add additional fields
PERFORM sub_fill_addtional.
*3) Display output data.
PERFORM sub_display_output.
*& Form SUB_CREATE_BASE_CATALOG
* Create Base catalog for display
FORM sub_create_base_catalog .
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'ZSTRCT'
CHANGING
ct_fieldcat = gt_fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
ENDFORM. " SUB_CREATE_BASE_CATALOG
*& Form SUB_FILL_ADDTIONAL
* text
FORM sub_fill_addtional .
DATA: lw_fcat TYPE lvc_s_fcat,
lw_from TYPE i,
lw_data TYPE REF TO data,
lw_fname TYPE stfna,
lw_index(2) TYPE n.
FIELD-SYMBOLS: <l_output> TYPE table.
DESCRIBE TABLE gt_fcat LINES lw_from.
DO p_number TIMES.
lw_from = lw_from + 1.
lw_index = sy-index.
CONCATENATE 'DYNA' lw_index INTO lw_fname SEPARATED BY '-'.
lw_fcat-col_pos = lw_from.
lw_fcat-fieldname = lw_fname.
lw_fcat-tabname = '1'.
lw_fcat-scrtext_l = lw_fcat-scrtext_m = lw_fcat-scrtext_s = lw_fname.
APPEND lw_fcat TO gt_fcat.
CLEAR lw_fcat.
ENDDO.
** Convert gt_fcat to internal table.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = gt_fcat
IMPORTING
ep_table = lw_data
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
IF sy-subrc = 0.
** Create the internal table form field catalog.
ASSIGN lw_data->* TO <l_output>.
** display the ALV data.
CREATE OBJECT gw_grid
EXPORTING
i_parent = cl_gui_container=>screen0
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5.
IF sy-subrc = 0.
CALL METHOD gw_grid->set_table_for_first_display
CHANGING
it_outtab = <l_output>
it_fieldcatalog = gt_fcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc = 0.
MESSAGE s000(zrak) WITH p_number 'DISPLAYED DYNAMICALLY'.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. " SUB_FILL_ADDTIONAL
*& Form SUB_DISPLAY_OUTPUT
* text
FORM sub_display_output .
CALL SCREEN '9001'.
ENDFORM. " SUB_DISPLAY_OUTPUT
*& Module STATUS_9001 OUTPUT
* text
MODULE status_9001 OUTPUT.
SET PF-STATUS ' '.
SET TITLEBAR 'MAIN00'.
ENDMODULE. " STATUS_9001 OUTPUT
*& Module USER_COMMAND_9001 INPUT
* text
MODULE user_command_9001 INPUT.
CASE sy-ucomm.
WHEN 'BACK' OR
'CANC' OR
'%EX'.
SET SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_9001 INPUT -
Building dynamic columns in BO Report (BO 4.0)
Hi All
To start with I am new to BO and using reporting tool
I have a requirement to create a WEBI report which contain a table with a feature to hide / remove columns based on input selection. ( dynamic columns)
I tried to do this by following concept
In my test scenario table has 3 columns. user will select which columns to show when refreshing the report.
I created 4 tables .
table 1: column 1, column 2 and colum 3
table 2: column 1, column 2
table 3: column 1, column 3
table 4: column 2, column 3
all tables were overlapped in display.
I am trying to hide the table using the property which is available in table properties "Hide when following formula is true"
to display table 1: formula is as follows
=UserResponse("Enter Column") = "column1;column2;column3"
The problem doing this way is
1. selection should happen in a given order
2. If there are mulitple columns , it doesn't make sense to create multiple tables as combination of columns increases.
Is there a better formula to set using user response to achieve the above.
Is there any better way to achieve the above generally.
any suggestion and guidance will be appreciated.
Thanks.Hello Guruprasad,
PFB link to a good explanation how to display columns dynamically.
http://blog.davidg.com.au/2011/09/dynamic-measures-in-webi-on-any-data.html
hide formula for different tables will not be easy when you have more number of columns.
another option is conditional formatting of columns based on a variable value. ie, indirectly hiding it by making background and value color white and keeping dynamic width for column.
Regards,
Nikhil Joy
Maybe you are looking for
-
I usually get a blank screen but sometimes get as far as the Apple insignia. I've tried the following without success: 1. Press C During Startup Booting from a CD? You can hold down the C key on your keyboard to instantly boot to a Mac OS X or other
-
Common custom swatch libraires
I have several custom swatch libraires that I'd like to share among all my Adobe apps & macs. Is there a commom place that I can put them, so I dont have to copy to every Swatch Libraries folder for each app? I'd like to have 1 common place to put th
-
Thumbnails do not open in organizer on my MAC.
I am currently using an evaluation copy of Elements 9 and its associated organizer on a Mac. I imported a set of photos into the organizer and everything worked fine. When I imported the next set the thumbnails do not open if there are more that tw
-
HT1386 I don't have a computer. How can I set iTunes to sync with wi-fi?
I have an iPhone & iPad and don't have a computer how can I sync iTunes ?
-
VR error message class, set as a warning message
Hi, How can we change an error message into a warning message.. In VF05, it requires either a payer or material.. Error message number VR436 (enter partner or material) .. How can we change this to a warning message instead of error?