Planning Layout -KP66 with dynamic period column

Dear experts,
I would like to create a planning layout for cost center/ cost elements in which we have the different periods in the columns .The periods in the columns should dynamically select according to the planning cycle selected in the excel file.
Planning Cycle                           Start Period                                End Period                Total Months
JAN                                         JAN                                           JUN                            6
FEB                                         FEB                                            JUN                            5
MAR                                       MAR                                            JUN                           4
According to planning cycle my period column should change dynamically.Please let us know how to create planning layout with dynamic period columns. I donot want to create the planning layout with 12 period columns to upload the data.
Thanks & Regards
Kumar

NOT ANSWERED

Similar Messages

  • Planning layout with dynamic period colomns

    Dear experts,
    I would like to create a planning layout for cost center/ cost elements in which we have the different periods in the columns (1-12). This layout I could already create, but now the business asked to have the number of columns selected dynamically in the selection screen ( eg: I want to enter the data as of April till December).
    The reason behind this is that the planning periods of Jan - Mar will be locked when we will enter the data from April to December. My first layout does not allow to enter any data if Jan - Mar is locked.
    In other words, would it be possible to have the periods in the selection screen AND in the columns of your layout?
    Thanks in advance,
    Roeland
    Eg:
    In selection screen
    Period from 3 - 5
    Planning layout:
    Cost center     cost element          Per 3     Per 4     Per 5
    10000     40000001          1000     1200     1400
    10000     40000002          2000     2200     2400

    Hi,
    This indeed describes the problem, but does not really provides an answer to the problem.
    Thanks anyhow
    I have found a solution to upload data via excel though:
    If for example periods 1-4 are locked you should start your layout in excel as of period 5 but you should repeat period 12, five times (to get to 12 columns/periods). This way you will be able to process the file with a planning layout for a year where some periods are blocked)
    Version     0     Plan/Act - Version                                                                 
    Fiscal Year     2011                                                                      
                        5     6     7     8     9     10     11     12     12     12     12     12
    Cost Ctr     AType     Cost elem.          FixCstOC Pd 5     FixCstOC Pd 6     FixCstOC Pd 7     FixCstOC Pd 8     FixCstOC Pd 9     FixCstOC Pd 10     FixCstOC Pd 11     FixCstOC Pd 12     FixCstOC Pd 12     FixCstOC Pd 12     FixCstOC Pd 12     FixCstOC Pd 12

  • How to create dynamic DataTable with dynamic header/column in JSF?

    Hello everyone,
    I am having problem of programmatically create multiple DataTables which have different number of column? In my JSF page, I should implement a navigation table and a data table. The navigation table displays the links of all tables in the database so that the data table will load the data when the user click any link in navigation table. I have gone through [BalusC's post|http://balusc.blogspot.com/2006/06/using-datatables.html#PopulateDynamicDatatable] and I found that the section "populate dynamic datatable" does show me some hints. In his code,
    // Iterate over columns.
            for (int i = 0; i < dynamicList.get(0).size(); i++) {
                // Create <h:column>.
                HtmlColumn column = new HtmlColumn();
                dynamicDataTable.getChildren().add(column);
                // Create <h:outputText value="dynamicHeaders"> for <f:facet name="header"> of column.
    HtmlOutputText header = new HtmlOutputText();
    header.setValue(dynamicHeaders[i]);
    column.setHeader(header);
    // Create <h:outputText value="#{dynamicItem[" + i + "]}"> for the body of column.
    HtmlOutputText output = new HtmlOutputText();
    output.setValueExpression("value",
    createValueExpression("#{dynamicItem[" + i + "]}", String.class));
    column.getChildren().add(output);
    public HtmlPanelGroup getDynamicDataTableGroup() {
    // This will be called once in the first RESTORE VIEW phase.
    if (dynamicDataTableGroup == null) {
    loadDynamicList(); // Preload dynamic list.
    populateDynamicDataTable(); // Populate editable datatable.
    return dynamicDataTableGroup;
    I suppose the Getter method is only called once when the JSF page is loaded for the first time. By calling this Getter, columns are dynamically added to the table. However in my particular case, the dynamic list is not known until the user choose to view a table. That means I can not call loadDynamicList() in the Getter method. Subsequently, I can not execute the for loop in method "populateDynamicDataTable()".
    So, how can I implement a real dynamic datatable with dynamic columns, or in other words, a dynamic table that can load data from different data tables (different number of columns) in the database at run-time?
    Many thanks for any help in advance.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    flyeminent wrote:
    However in my particular case, the dynamic list is not known until the user choose to view a table. Then move the call from the getter to the bean's action method.

  • Creating Planning Layout for GP12N  - Posting Period as columns/rows

    I am trying to create new layouts for GP12N, but do not know how to create the integrated layout with one column or one row for each Posting Period 1 - 12.  I did read that 'Sets' were not allowed.  Can anyone provide the steps necessary to allow Posting Periods as columns or rows?

    Hi,
       a) Remove period from general data selection.
       b) Create 12 columns of the same Key Figure which use the characteristic period and set it as a fixed value

  • Dynamic period columns in data forms?

    Hi,
    We are running HFM v11.1.1.3
    I have some input data forms that shows some different periods and scenarios, however the periods sometimes needs to be changed, so I was wondering if anyone knows a way in doing this dynamic?
    For January we would like it to be:
    C1=S#Actual.Y#CUR.P#CUR
    C2=S#Actual.Y#CUR.P#CUR-1
    C3=S#FYE.Y#CUR.P#CUR
    and in March it should be:
    C1=S#Actual.Y#CUR.P#CUR
    C2=S#Actual.Y#CUR.P#CUR-1
    C3=S#FYE.Y#CUR.P#CUR
    C4=S#FYE.Y#CUR.P#CUR-2
    in June and September it should be
    C1=S#Actual.Y#CUR.P#CUR
    C2=S#Actual.Y#CUR.P#CUR-1
    C3=S#FYE.Y#CUR.P#CUR
    C4=S#FYE.Y#CUR.P#CUR-3
    so basically this would require 3 different forms, and with linked forms as well it will be many forms. So if there could be build in some kind of if statement?
    Thank you in advance
    Best regards
    Kenneth

    Hi Kenneth,
    Nobody is answering you because there is no way to do that with Data Forms.
    If you are skilled with Excel, and if you understand the implications of going that path, you can create dynamic Excel grids that send data to HFM using HFM functions.
    Depending on your needs and your budget, you can also create a custom web application that would replace data forms.
    If you want to stick with data forms, then you will need to create 3 forms (+the linked forms you mentioned).
    Not sure that helped...
    Julien

  • Saving data in Planning web form with about 270 columns failed

    Hi all and please help!
    We developed a number of planning forms with a lot of columns (business requirement:() and faced issues with entering data in both web form and excel via smartview.
    As I undersood already that it's not about 'service.olap.dataQuery.grid.maxColumns' property in essbase.properties file for APS.
    For test I developed some planning forms with different number of columns (and only one row) from 255 to 300 and saving stops to work when the number of columns exceeds 257 columns. It's rather close to default value for maxColumns property=255 but not equal. I essbase log we could see short spreadsheeting request and then restarting of Essbase server.
    And at the same time if we transposed columns into rows - saving works properly.
    Please help!
    Thanks in advance,
    Gregory Taxelman

    Hi, Alp
    Thank you for you answer. I've checked your link and it's amazing that information like this was written not in admin but in user guide.
    Another thing i've wondered that it depends on setting of Calculate Currencies calc script (run on save). But it's just a think men must know and do I think.
    Unfortunately I can't see how does it work, although I've done this settings.
    If I set local currency for one of the entity as GBP then I can enter data in GBP of course and Calculate Currencies script runs ok. I can see exact values for local (GBP) and default currency (USD) just on planning form as I set currency dim in page.
    But in my case when i set local currency for this entity back to USD entered value in GBP always changed back to USD regardless of Calculate Currencies script settings. It happens during save on the form
    Can I get a bit more information about some other settings to be done to make this functionality work?
    BR,
    Vladimir

  • Editable ALV with dynamically growing columns

    Hi Gurus,
    I have one Parameter table and another data (transaction) table
    When I fetch the data from data table I have put a when condition to one of date field in data table with between sy-datum and sy-datum + need to run days in parameter table
    Its working properly
    So my requirement is …. &#61516;
    There are three key fields (fixed) and
    when the parameter value = 4 ALV columns must be 7
    when the parameter value = 6 ALV columns must be 9
    like that.
    So I want to know how can I do this?
    My second question is when the ALV displaying, user need to change there value in ALV list, so therefore ALV should be editable.
    Please help me o solve these problems.

    below  is the program  to  make   an  parameter  as  Editable in the ALV Grid  .  example <b> Net price</b>  .
    see the field catalog   statement  for    netprice   * edit  parameter for  that  field .
    *& Report  ZDEMO_ALVGRID_EDIT                                          *
    *& Example of a simple ALV Grid Report                                 *
    *& The basic ALV grid, Enhanced to display specific fields as          *
    *& editable depending on field value                                   *
    REPORT  ZDEMO_ALVGRID_EDIT                 .
    TABLES:     ekko.
    TYPE-POOLS: slis.                                 "ALV Declarations
    *Data Declaration
    TYPES: BEGIN OF t_ekko,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
      statu TYPE ekpo-statu,
      aedat TYPE ekpo-aedat,
      matnr TYPE ekpo-matnr,
      menge TYPE ekpo-menge,
      meins TYPE ekpo-meins,
      netpr TYPE ekpo-netpr,
      peinh TYPE ekpo-peinh,
      field_style  TYPE lvc_t_styl, "FOR DISABLE
    END OF t_ekko.
    DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          wa_ekko TYPE t_ekko.
    *ALV data declarations
    DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE.
    DATA: it_fieldcat TYPE lvc_t_fcat,     "slis_t_fieldcat_alv WITH HEADER LINE,
          wa_fieldcat TYPE lvc_s_fcat,
          gd_tab_group TYPE slis_t_sp_group_alv,
          gd_layout    TYPE lvc_s_layo,     "slis_layout_alv,
          gd_repid     LIKE sy-repid.
    *Start-of-selection.
    START-OF-SELECTION.
      PERFORM data_retrieval.
      PERFORM set_specific_field_attributes.
      PERFORM build_fieldcatalog.
      PERFORM build_layout.
      PERFORM display_alv_report.
    *&      Form  BUILD_FIELDCATALOG
    *       Build Fieldcatalog for ALV Report
    FORM build_fieldcatalog.
      wa_fieldcat-fieldname   = 'EBELN'.
      wa_fieldcat-scrtext_m   = 'Purchase Order'.
      wa_fieldcat-col_pos     = 0.
      wa_fieldcat-outputlen   = 10.
      wa_fieldcat-emphasize   = 'X'.
      wa_fieldcat-key         = 'X'.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname   = 'EBELP'.
      wa_fieldcat-scrtext_m   = 'PO Item'.
      wa_fieldcat-col_pos     = 1.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname   = 'STATU'.
      wa_fieldcat-scrtext_m   = 'Status'.
      wa_fieldcat-col_pos     = 2.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname   = 'AEDAT'.
      wa_fieldcat-scrtext_m   = 'Item change date'.
      wa_fieldcat-col_pos     = 3.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname   = 'MATNR'.
      wa_fieldcat-scrtext_m   = 'Material Number'.
      wa_fieldcat-col_pos     = 4.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname   = 'MENGE'.
      wa_fieldcat-scrtext_m   = 'PO quantity'.
      wa_fieldcat-col_pos     = 5.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname   = 'MEINS'.
      wa_fieldcat-scrtext_m   = 'Order Unit'.
      wa_fieldcat-col_pos     = 6.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname   = 'NETPR'.
    wa_fieldcat-scrtext_m   = 'Net Price'.
      <b>wa_fieldcat-edit        = 'X'. "sets whole column to be editable</b>
      wa_fieldcat-col_pos     = 7.
      wa_fieldcat-outputlen   = 15.
      wa_fieldcat-datatype     = 'CURR'.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname   = 'PEINH'.
      wa_fieldcat-scrtext_m   = 'Price Unit'.
      wa_fieldcat-col_pos     = 8.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
    ENDFORM.                    " BUILD_FIELDCATALOG
    *&      Form  BUILD_LAYOUT
    *       Build layout for ALV grid report
    FORM build_layout.
    * Set layout field for field attributes(i.e. input/output)
      gd_layout-stylefname = 'FIELD_STYLE'.
      gd_layout-zebra             = 'X'.
    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'
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
           EXPORTING
                i_callback_program      = gd_repid
    *            i_callback_user_command = 'USER_COMMAND'
                is_layout_lvc               = gd_layout
                it_fieldcat_lvc             = it_fieldcat
                i_save                  = 'X'
           TABLES
                t_outtab                = it_ekko
           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.
      SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh
       UP TO 10 ROWS
        FROM ekpo
        INTO  CORRESPONDING FIELDS OF TABLE it_ekko.
    ENDFORM.                    " DATA_RETRIEVAL
    *&      Form  set_specific_field_attributes
    *       populate FIELD_STYLE table with specific field attributes
    form set_specific_field_attributes .
      DATA ls_stylerow TYPE lvc_s_styl .
      DATA lt_styletab TYPE lvc_t_styl .
    * Populate style variable (FIELD_STYLE) with style properties
    * The NETPR field/column has been set to editable in the fieldcatalog...
    * The following code sets it to be disabled(display only) if 'NETPR'
    * is gt than 10.
      LOOP AT it_ekko INTO wa_ekko.
        IF wa_ekko-netpr GT 10.
          ls_stylerow-fieldname = 'NETPR' .
          ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.
                                                 "set field to disabled
          APPEND ls_stylerow  TO wa_ekko-field_style.
          MODIFY it_ekko FROM wa_ekko.
        ENDIF.
      ENDLOOP.
    endform.           
    reward  points if it is usefull ....
    Girish

  • Planning Layout error K9162 - max number of columns in planning layout rest

    Hello collegues,
    our client would like to have 34 columns in planning layout costs activity inputs of TA KP67. But error message K9162 - max. number of columns is restricted to 30. So I tried to switch of the message with TA OBA5 application area K9 - msg number 162. But this does not work as the error comes up again even though the message is switched off.
    Do you have some ideas?
    Thanks and regards,
    Christian

    Hello,
    thanks for your response. I have maintaine in OBMSG:
    K9     162     WE     E    switch off selected
    then in OBA5 for dialog and batch I have maintained  -
    but the error is upcoming again. So I think that this sort of message cannot be switched off as the planning layout is restricted to 30 columns by design maybe?
    thanks and regards,
    Christian

  • Query Designer - Dynamic periods

    Dear BI EXPERTS,
    I am new to BI and I have got a requirement to display a Query with dynamic periods on execution.
    Requirement:
    On Execution of Report, It asks for a Period from the user.
    Suppose user gives 3 then it shows report as below
    Char1 Char2 Period1 Period2 Period3
    If user gives 5 then it shows report as below
    Char1 Char2 Period1 Period2 Period3 Period4 Period5
    Kindly let me know how it can be done(step-by-step) and if it solves my problem then i shall definitely assign FULL P O I N T S.
    Regards

    HI Sajid,
    Let us assume that the info object for Period is ZPERIOD.
    Now for the query Definition.
    1.Drag Char1 into the Row Section of the Query.
    2.Drag the the Key figure into the Column Section of the Query.
    3. Drag the ZPERIOD object into the column section of the Query above the Keyfigure.
    4. No go to the Filter Section and drag and Drop ZPERIOD into it.
    5. Right Click and restrict the ZPERIOD with a Manual Input Optional variable. (if not available create one) with range Options as less than or equal to the variable name.
    Now this way, when the user Inputs the period the report will show all months less than or equal to the user Input month.
    If he does not enter anything it will show all values.
    Hope this Helps.
    Regards.
    Shafi.
    Edited by: shafi abdul on Aug 9, 2010 4:31 PM

  • Planning Layout - BCS

    Dear All,
    I wish to create a new planning layout in BCS. the layout is as below, for a series of Commitment Item i also want subtotal. The summary table used is FMBDT. Could you please share some information/knowledge/document which will help me to meet the requirement.
    Funds Center I Commitment Item I Commitment Item Description I Amount I Distribution Key
    Best regards
    Abishay Solomon

    Hi,
    What you mean series commitment item for subtotal? for planning or reporting.
    To create new planning layout, just copy the standard planning layout and add the new column, select the attribute for distribution key.
    Regards,
    Dewi

  • The columns must be marked with a * in the columnsin Planning layout

    hi ,
    Doeas anyone please tell me how to add ' * ' next to characetristic name in the Header of the planning Layout in only some columns headers.
    i am not able to just add * and save.
    is there any VBA code we have to use ? or any changes in the BSP application of the webinterface attached to the layout.
    Suppose i have ' Company code ' in the column header of the planning layout.
    i want in the output of the webinterface as ' company code* '
    Regards,
    Sandhya

    Hi Sandhya,
    in Excel Layouts you should use VBA. Loop over the cells of the column headings until you find the one with "Company Code". Then change it.
    In Web Interfaces you can do the same with a JavaScript item.
    Regards,
    Marc
    SAP NetWeaver RIG

  • Difficult to achive the report layout with dynamic column names

    I have a report layout as below.
    So here the column names are dynamic.And each fixed row group has different calculations. I have a date parameter. If I select July 2013, then I need to show data from July 2012 to July 2013 with Columns(Jul-12, Aug-12...Jul-13). How to achive below layout
    with dynamic columns?

    Hi Sarayu_CM,
    According to your description, you want to filter the records of prior year based on only one parameter selection. Right?
    In this scenario, we can create two parameters. The first one is for user to select. The second parameter is based on the first parameter selection. We don't need to specify Available Values for the second parameter, but we should use expression to specify
    Default Values based on the first parameter selection. Use the expression below:
    =DateAdd("m",-12,FormatDateTime(Parameters!param1.Value))
    Then we just need to apply a filter on the matrix/dataset to get the records which the date is between values in these two parameters.
    If you have any question, please feel free to ask.
    Best Regards,
    Simon Hou

  • **URGENT** - PRODUCTION ISSUE with Planning Layout

    Hi,
    we've a manual planning layout that uses both macros SAPAFTERDATAPUT and SAPBEFOREDATAGET with custom code developed in these 2 macros to switch data between "SEM-BPS 1" and "New" sheet.
    Layout has 11 characteristics in lead columns and around 40 keyfigures in data columns (dynamic).
    Using macros, we are formatting SEM-BPS 1 sheet to display all dynamic data coumns in a single page of New sheet.
    for this, our custom macro formats each row of SEM-BPS1 into 10 rows of New sheet by reducing 40 columns into 4 (columns is what matters for our users but not rows).
    We tried this for 40 rows of data. (means, 40 rows 40 columns). Our Custom macro formed 400 rows and 4 columns into New Sheet and even switched data between "SEM-BPS 1" and "New" sheet as per our macro coding. here, we can execute all planning functions. fine till this point
    Now, we have a problem when dealing with 100 rows. (means, 100 rows 40 columns). <b>Our custom macro had formed 1000 rows and 4 columns as expected with accurare data. </b>
    at this point, When we started running any planning function or even when we just click on check button (check button runs both SAP macros, I assume), <b>system is freezing up doing nothing. each time, we had to kill the process. when we looked into CPU usage, we can see that excel.exe process is using 99% of CPU.</b>
    Appreciate if any one can share experinces on this.
    <b><u>Note: </b></u>
    1. By disabling custom macros, we  executed 100 rows 40 columns w/o any issues.
    2. when executed custom macros outside of SAP for 1000 rows 4 columns, both macros took just 2 seconds to switch data between sheets.

    Hi there
    This is the option Jeff was referring to. I see it in my own RoboHelp version 10. As we aren't seeing it in your screen capture, I'm wondering if this was an option that was added via a service release you haven't installed.
    I do suppose another possibility would be that you are using RoboHelp for Word and perhaps that isn't an option with that application.
    Cheers... Rick

  • Problem with dynamic columns in the BEx report

    Hi Gurus,
    I am tryging to build some planning application using BI-IP and input ready queries.
    I'm facing issues with making the columns in the query 'dynamic'. The example is given below: -
    Lets say there are states and cities for which we have to plan sales volumes. Depending on the value I choose for 'State' it should create as many columns for 'Cities' as per the hierarchy of the cities.
    Lets say if I choose Maharashtra then the report shud look like :-
    State-> Maharashtra
    Rows               Column1                      Column2                      Column3
    GL Account      Mumbai/0quantity        Pune/0quantity            Aurangabad/ 0quantity
    1000000            1000                               1500                              1200
    State--> Karnatka
    Rows                 Column1                  Column2
    GL account        Bangalore                 Mangalore
    1000000
    Any idea how this can be achieved?
    Best Regards,
    SSC

    Hi friend,
    See the link below it is having the solution of hiding the columns in smart forms
    Hide table columns in smart form?
    Create a table to display your values with 12 col and hide the columns based on the idea provided in the link above.
    I think this will solve your issue if you still have queries please revert back to me i will help you.
    Thanks,
    Sri Hari

  • How to generate report with dynamic variable number of columns?

    How to generate report with dynamic variable number of columns?
    I need to generate a report with varying column names (state names) as follows:
    SELECT AK, AL, AR,... FROM States ;
    I get these column names from the result of another query.
    In order to clarify my question, Please consider following table:
    CREATE TABLE TIME_PERIODS (
    PERIOD     VARCHAR2 (50) PRIMARY KEY
    CREATE TABLE STATE_INCOME (
         NAME     VARCHAR2 (2),
         PERIOD     VARCHAR2 (50)     REFERENCES TIME_PERIODS (PERIOD) ,
         INCOME     NUMBER (12, 2)
    I like to generate a report as follows:
    AK CA DE FL ...
    PERIOD1 1222.23 2423.20 232.33 345.21
    PERIOD2
    PERIOD3
    Total 433242.23 56744.34 8872.21 2324.23 ...
    The TIME_PERIODS.Period and State.Name could change dynamically.
    So I can't specify the state name in Select query like
    SELECT AK, AL, AR,... FROM
    What is the best way to generate this report?

    SQL> -- test tables and test data:
    SQL> CREATE TABLE states
      2    (state VARCHAR2 (2))
      3  /
    Table created.
    SQL> INSERT INTO states
      2  VALUES ('AK')
      3  /
    1 row created.
    SQL> INSERT INTO states
      2  VALUES ('AL')
      3  /
    1 row created.
    SQL> INSERT INTO states
      2  VALUES ('AR')
      3  /
    1 row created.
    SQL> INSERT INTO states
      2  VALUES ('CA')
      3  /
    1 row created.
    SQL> INSERT INTO states
      2  VALUES ('DE')
      3  /
    1 row created.
    SQL> INSERT INTO states
      2  VALUES ('FL')
      3  /
    1 row created.
    SQL> CREATE TABLE TIME_PERIODS
      2    (PERIOD VARCHAR2 (50) PRIMARY KEY)
      3  /
    Table created.
    SQL> INSERT INTO time_periods
      2  VALUES ('PERIOD1')
      3  /
    1 row created.
    SQL> INSERT INTO time_periods
      2  VALUES ('PERIOD2')
      3  /
    1 row created.
    SQL> INSERT INTO time_periods
      2  VALUES ('PERIOD3')
      3  /
    1 row created.
    SQL> INSERT INTO time_periods
      2  VALUES ('PERIOD4')
      3  /
    1 row created.
    SQL> CREATE TABLE STATE_INCOME
      2    (NAME   VARCHAR2 (2),
      3       PERIOD VARCHAR2 (50) REFERENCES TIME_PERIODS (PERIOD),
      4       INCOME NUMBER (12, 2))
      5  /
    Table created.
    SQL> INSERT INTO state_income
      2  VALUES ('AK', 'PERIOD1', 1222.23)
      3  /
    1 row created.
    SQL> INSERT INTO state_income
      2  VALUES ('CA', 'PERIOD1', 2423.20)
      3  /
    1 row created.
    SQL> INSERT INTO state_income
      2  VALUES ('DE', 'PERIOD1', 232.33)
      3  /
    1 row created.
    SQL> INSERT INTO state_income
      2  VALUES ('FL', 'PERIOD1', 345.21)
      3  /
    1 row created.
    SQL> -- the basic query:
    SQL> SELECT   SUBSTR (time_periods.period, 1, 10) period,
      2             SUM (DECODE (name, 'AK', income)) "AK",
      3             SUM (DECODE (name, 'CA', income)) "CA",
      4             SUM (DECODE (name, 'DE', income)) "DE",
      5             SUM (DECODE (name, 'FL', income)) "FL"
      6  FROM     state_income, time_periods
      7  WHERE    time_periods.period = state_income.period (+)
      8  AND      time_periods.period IN ('PERIOD1','PERIOD2','PERIOD3')
      9  GROUP BY ROLLUP (time_periods.period)
    10  /
    PERIOD             AK         CA         DE         FL                                             
    PERIOD1       1222.23     2423.2     232.33     345.21                                             
    PERIOD2                                                                                            
    PERIOD3                                                                                            
                  1222.23     2423.2     232.33     345.21                                             
    SQL> -- package that dynamically executes the query
    SQL> -- given variable numbers and values
    SQL> -- of states and periods:
    SQL> CREATE OR REPLACE PACKAGE package_name
      2  AS
      3    TYPE cursor_type IS REF CURSOR;
      4    PROCEDURE procedure_name
      5        (p_periods   IN     VARCHAR2,
      6         p_states    IN     VARCHAR2,
      7         cursor_name IN OUT cursor_type);
      8  END package_name;
      9  /
    Package created.
    SQL> CREATE OR REPLACE PACKAGE BODY package_name
      2  AS
      3    PROCEDURE procedure_name
      4        (p_periods   IN     VARCHAR2,
      5         p_states    IN     VARCHAR2,
      6         cursor_name IN OUT cursor_type)
      7    IS
      8        v_periods          VARCHAR2 (1000);
      9        v_sql               VARCHAR2 (4000);
    10        v_states          VARCHAR2 (1000) := p_states;
    11    BEGIN
    12        v_periods := REPLACE (p_periods, ',', ''',''');
    13        v_sql := 'SELECT SUBSTR(time_periods.period,1,10) period';
    14        WHILE LENGTH (v_states) > 1
    15        LOOP
    16          v_sql := v_sql
    17          || ',SUM(DECODE(name,'''
    18          || SUBSTR (v_states,1,2) || ''',income)) "' || SUBSTR (v_states,1,2)
    19          || '"';
    20          v_states := LTRIM (SUBSTR (v_states, 3), ',');
    21        END LOOP;
    22        v_sql := v_sql
    23        || 'FROM     state_income, time_periods
    24            WHERE    time_periods.period = state_income.period (+)
    25            AND      time_periods.period IN (''' || v_periods || ''')
    26            GROUP BY ROLLUP (time_periods.period)';
    27        OPEN cursor_name FOR v_sql;
    28    END procedure_name;
    29  END package_name;
    30  /
    Package body created.
    SQL> -- sample executions from SQL:
    SQL> VARIABLE g_ref REFCURSOR
    SQL> EXEC package_name.procedure_name ('PERIOD1,PERIOD2,PERIOD3','AK,CA,DE,FL', :g_ref)
    PL/SQL procedure successfully completed.
    SQL> PRINT g_ref
    PERIOD             AK         CA         DE         FL                                             
    PERIOD1       1222.23     2423.2     232.33     345.21                                             
    PERIOD2                                                                                            
    PERIOD3                                                                                            
                  1222.23     2423.2     232.33     345.21                                             
    SQL> EXEC package_name.procedure_name ('PERIOD1,PERIOD2','AK,AL,AR', :g_ref)
    PL/SQL procedure successfully completed.
    SQL> PRINT g_ref
    PERIOD             AK         AL         AR                                                        
    PERIOD1       1222.23                                                                              
    PERIOD2                                                                                            
                  1222.23                                                                              
    SQL> -- sample execution from PL/SQL block
    SQL> -- using parameters derived from processing
    SQL> -- cursors containing results of other queries:
    SQL> DECLARE
      2    CURSOR c_period
      3    IS
      4    SELECT period
      5    FROM   time_periods;
      6    v_periods   VARCHAR2 (1000);
      7    v_delimiter VARCHAR2 (1) := NULL;
      8    CURSOR c_states
      9    IS
    10    SELECT state
    11    FROM   states;
    12    v_states    VARCHAR2 (1000);
    13  BEGIN
    14    FOR r_period IN c_period
    15    LOOP
    16        v_periods := v_periods || v_delimiter || r_period.period;
    17        v_delimiter := ',';
    18    END LOOP;
    19    v_delimiter := NULL;
    20    FOR r_states IN c_states
    21    LOOP
    22        v_states := v_states || v_delimiter || r_states.state;
    23        v_delimiter := ',';
    24    END LOOP;
    25    package_name.procedure_name (v_periods, v_states, :g_ref);
    26  END;
    27  /
    PL/SQL procedure successfully completed.
    SQL> PRINT g_ref
    PERIOD             AK         AL         AR         CA         DE         FL                       
    PERIOD1       1222.23                           2423.2     232.33     345.21                       
    PERIOD2                                                                                            
    PERIOD3                                                                                            
    PERIOD4                                                                                            
                  1222.23                           2423.2     232.33     345.21                       

Maybe you are looking for

  • Satellite P300D-10v - Question about warranty

    HI EVERYBODY I have these overheating problems with my laptop Satellite P300D-10v. I did everything I could do to fix it without any success.. I get the latest update of the bios from Toshiba. I cleaned my lap with compressed air first and then disas

  • Cisco Jabber Demo license

    Guys, Our company is willing to implement Cisco Jabber 9 but they require some sort of demo license to test the functionality of the solution, i have simply no idea about it, so need your help in this regard. BR. Abd

  • TS3274 all my icons have dissapeard what can i do

    All my icons have dissapeared just my background picture showing. What can i do to get them back.

  • IMovie HD won't boot up on new iMAC Intel machine

    I just bought a new IMac Intel DP and completed the SW updates. Opened iMovie HD and created a new project. The program started to open but gets hung up when loading the "new movie" (which doesn't exist yet) and state loading "saved thumbnails" - thi

  • Can you change the format when converting pdf to excel?

    example.  I'm trying to export a PDF file to excel.  However, the PDF file isn't in a table/spreadsheet format so when it exports to excel, I can't sort at all.  It doesn't convert into any sortable columns.  Is there a way to change the format on th