Convert to column records to column header

Dear All, 
I have a query, where i have a table where two columns is there.
I want to write a query convert first column records in Column header and second column records
would come under that header.
Col1 Col2
FirstName Ajay
LastName Nath
DOB 25/08/1981
Gender Male
Output
FirstName LastName DOB Gender
Ajay Nath 25/08/1981 Male
Please help me

Please read any book on RDBMS. You have no idea what a table is. This is a report, not a query. This is so basic, how do you not know this? 
Heck, you did not even use ISO-8601 date formats in your silly picture! Oh, ISO has a sex_code, not gender, standard that you are not using. 
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL

Similar Messages

  • Converting column header and a single record into rows

    Lets suppose the table with only one record
    col1 col2 col3-----Column Header
    d1 d2 d3
    i want it in following manner
    column_name Column_data----Column Header
    col1 d1
    col2 d2
    col3 d3
    for this i have written the query as
    select column_name,column_data from (select * from XXX where col1=123)
    MODEL RETURN UPDATED ROWS
    dimension by(col1)
    measures (col1,0 column_name,0 column_data )
    ignore nav
    rules ITERATE(167)
    column_name[iteration_number]=cast( iteration_number as varchar2(3)),
    column_data[iteration_number]=cast( iteration_number as int)
    here i am just assigning iteration_number but i want to assign name of the column and its value;
    Note:--table contains nearly 200 columns

    Something like (using one of my own tables):
    select column_name colname,
           decode(column_name,'RUN_NO',to_char(run_no),
                              'SEARCH_ID',to_char(search_id),
                              'PROCESSING_START_DATE',to_char(processing_start_date,'DDMMYYYYHH24MISS'),
                              'PROCESSING_END_DATE',to_char(processing_end_date,'DDMMYYYYHH24MISS'),
                              'NO_OF_MATCHES',to_char(no_of_matches),
                              'ERROR_DETAILS',error_details,
                              'ADVREP_TIMESTAMP',to_char(advrep_timestamp,'DDMMYYYYHH24MISS')
                  ) colvalue
    from partial_search_history, (select rownum r, column_name
                                  from user_tab_columns
                                  where table_name = 'PARTIAL_SEARCH_HISTORY')
    where run_no = 356You can build the decode by doing
    SELECT ''''||COLUMN_NAME||''',TO_CHAR('||COLUMN_NAME||'),'
    FROM user_tab_columns
    where table_name = 'PARTIAL_SEARCH_HISTORY'A decode on DATA_TYPE field would allow you to add a format mask for DATE fields if necessary.

  • File Write Adapter, First record as a Column Header

    Hi,
    Using File adapter of type WRITE i m creating a file.
    I want to include the column header also as a first record in File.
    One way i can think of Creating one record manually and append as a first record in the File write variable.
    Is there any other simple way or standard way to do it??

    To have fixed header every time before it writes the data, i think you should have file with header and data, then use it to configure file write in JCA adapter.
    This will create a schema with static header and dynamic results to the schema file.
    So that everytime you will have the header then it write the data below that.
    Note: I have done this some years back, i wrote here with from my memory.
    Let me know if you still have problem, wll try to create a simple example and share.
    Thanks,
    Vijay

  • How to return a record's column head given a record of a table.

    Hi:
    Do you know how to return a record's column head given a record of a table.
    For example, in a table with 3 columns "ID", "Education", "Age".
    Give you the record "Bachelor", how can you use a SQL to return the correspondent column head "Education"?
    Thanks for the big help.

    Have a look at http://java.sun.com/j2se/1.4.2/docs/api/java/sql/ResultSetMetaData.html.
    import java.sql.*;
    import java.util.*;
    ResultSet rs = stmt.executeQuery("SELECT * FROM testTable");
    ResultSetMetaData rsmd = rs.getMetaData();
    // loop through rsmd.getColumnCount() {
         String columnName = getColumnName(i);
         // run a query SELECT * FROM testTable WHERE columnName='Bachelor'
         // if rs !=null return columnName and break out of the loop
    }

  • Converting Column Header to Rows Value in SQL Query

    Dear Guys,find blew the table from A1_30 to YetToDue columns. I need from A1_30 to A356 columns convert into row values and that values column head name like Abstract. A1_30 A31_60 A61_90 A91_120 A121_180A181_365A365 BalArr NoOfLoanLoanOS YetToDue
    0 0 0 101 0 0 0 909 66730 909 3637
    0 40 0 0 0 0 0 1818 66681 1818 3637
    0 56 0 0 0 0 0 1818 70210 1818 5455
    0 0 66 0 0 0 0 909 73735 909 7273
    0 35 0 0 0 0 0 2727 73327 2727 7273
    0 0 66 0 0 0 0 909 73353 909 7273
    0 40 0 0 0 0 0 909 66778 909 3637
    0 40 0 0 0 0 0 1818 66744 1818 3637
    0 0 0 101 0 0 0 909 66787 909 3637
    0 40 0 0 0 0 0 1818 66671 1818 3637
    0 56 0 0 0 0 0 1818 70201 1818 5455
    0 56 0 0 0 0 0 1818 70204 1818 5455
    0 0 66 0 0 0 0 909 73331 909 7273
    0 40 0 0 0 0 0 1818 66726 1818 3637
    0 40 0 0 0 0 0 2727 66798 2727 3637
    0 40 0 0 0 0 0 909 66676 909 3637
    0 40 0 0 0 0 0 1818 66685 1818 3637
    0 56 0 0 0 0 0 1818 70209 1818 5455
    0 57 0 0 0 0 0 1818 70226 1818 5455
    0 35 0 0 0 0 0 2727 73762 2727 7273
    0 0 66 0 0 0 0 909 73333 909 7273
    0 40 0 0 0 0 0 1818 66759 1818 3637
    0 40 0 0 0 0 0 882 66597 882 8826
    0 40 0 0 0 0 0 2727 66789 2727 3637
    0 40 0 0 0 0 0 2646 66609 2646 8826
    0 40 0 0 0 0 0 2646 66641 2646 8826
    0 57 0 0 0 0 0 1818 70193 1818 5455
    0 56 0 0 0 0 0 1818 70202 1818 5455
    0 35 0 0 0 0 0 2727 73757 2727 7273
    0 0 66 0 0 0 0 909 73345 909
    7273
    I expecting the results:
    Abstract BalArr NoOfLoan LoanOS YetToDue
    A0_30 0 0 0 0
    A31_60 45261 1579445 45261 122852
    A61_90 4545 367097 4545 36365
    A91_120 1818 133517 1818 7274
    A121_180 0 0 0 0
    A181_365 0 0 0 0
    A365 0 0 0 0
    pls help I really appreciate ..

    Dear Partrck Hurst.I have facing struggle with my store procedure , It work very slow performance when i pass the entryPlease go through my store procedure and let me advice if i wrote the script wrongly .ALTER PROCEDURE [dbo].[MFDB_GenerateDCBCollection]
    @i_BranchId INT,
    @i_SHGId INT,
    @p_SHGMemberId INT,
    @i_LoanNumber INT,
    @i_DayOpenDate DATETIME,
    @o_ErrorStatus INT Output
    ) AS
    --WITH ENCRYPTION AS
    DECLARE @p_DayOpenDate AS DATETIME
    DECLARE @p_BranchId AS INT
    DECLARE @D_FromDate AS DATE
    DECLARE @D_ToDate AS DATE
    DECLARE @E_ToDate AS DATE
    DECLARE @p_RecordCounter AS INT
    DECLARE @p_RecordCount AS INT
    DECLARE @p_TempCollectionId AS INT
    DECLARE @p_TempStateId AS INT
    DECLARE @p_TempRegionId AS INT
    DECLARE @p_TempBranchId AS INT
    DECLARE @p_TempSHGId AS INT
    DECLARE @p_TempSHGName AS VARCHAR(75)
    DECLARE @p_TempSHGMemberId AS INT
    DECLARE @p_TempMemberId AS INT
    DECLARE @p_TempMemberName AS VARCHAR(75)
    DECLARE @p_TempVillageName AS VARCHAR(100)
    DECLARE @p_TempPanchayatName AS VARCHAR(100)
    DECLARE @p_TempPanchayatId AS INT
    DECLARE @p_TempVillageId AS INT
    DECLARE @p_TempInstNumber AS INT
    DECLARE @p_TempLoanNumber AS INT
    DECLARE @p_TempDisbursedDate AS DATE
    DECLARE @p_TempStatus AS INT
    DECLARE @p_TempLoanSchemeId AS INT
    DECLARE @p_TempLCategoryId AS INT
    DECLARE @p_TempLActivityId AS INT
    DECLARE @p_TempLActSpecId AS INT
    DECLARE @p_TempLoanAmount AS NUMERIC(18,2)
    DECLARE @p_TempApprovalStatus AS INT
    DECLARE @p_TempFundingAgencyId AS INT
    DECLARE @p_TempOpenBalPrin AS NUMERIC(18,2)
    DECLARE @p_TempOpenBalInt AS NUMERIC(18,2)
    DECLARE @p_TempStdPrin AS NUMERIC(18,2)
    DECLARE @p_TempStdInt AS NUMERIC(18,2)
    DECLARE @p_TempCollPrin AS NUMERIC(18,2)
    DECLARE @p_TempCollInt AS NUMERIC(18,2)
    DECLARE @p_TempAdvancePrin AS NUMERIC(18,2)
    DECLARE @p_TempAdvanceInt AS NUMERIC(18,2)
    DECLARE @p_TempArrearPrin AS NUMERIC(18,2)
    DECLARE @p_TempArrearInt AS NUMERIC(18,2)
    DECLARE @p_TempBalancePrin AS NUMERIC(18,2)
    DECLARE @p_TempBalanceInt AS NUMERIC(18,2)
    DECLARE @p_TempDemandDate AS DATE
    DECLARE @p_TempCollectionDate AS DATE
    DECLARE @p_TempLStatus AS INT
    DECLARE @p_TempLSourceId AS INT
    DECLARE @p_TempVoucherName AS VARCHAR(75)
    DECLARE @p_TempInsurance AS NUMERIC(18,2)
    DECLARE @p_TempUpFrontFess AS NUMERIC(18,2)
    DECLARE @p_TempDocumentFees AS NUMERIC(18,2)
    DECLARE @p_TotalInterest AS NUMERIC(18,2)
    DECLARE @i_Month AS INT = 1
    DECLARE @p_Year AS INT = 2015
    DECLARE @i_SHGMemberId AS INT
    BEGIN TRANSACTION DCBGenerated
    BEGIN
    Set @o_ErrorStatus = 0
    SELECT @D_FromDate = DATEADD(MONTH, @i_Month - 1, DATEADD(YEAR, @p_Year - 1900, 0)) --as [START DATE]
    SELECT @D_ToDate = DATEADD(MONTH, @i_Month, DATEADD(YEAR, @p_Year - 1900, -1)) --as [EMD DATE]
    SELECT @i_SHGMemberId = MFDB_SHGMemberId FROM MFDB_SHGMEMBER_MASTER WHERE MFDB_SHGId = @i_SHGId AND MFDB_MemberId = @p_SHGMemberId
    SELECT @p_TempVillageName = MFDB_VillageName,
    @p_TempVillageId = MFDB_VillageId ,
    @p_TempPanchayatId = MFDB_PanchayatId ,
    @p_TempPanchayatName = MFDB_PanchayatName
    FROM MFDB_SHG_MASTER WHERE MFDB_SHGId = @i_SHGId
    /* Drop and Create TempCollection Table. This table has all installments for a given member */
    CREATE TABLE #TEMPDCBCOLLECTION
    [MFDB_LedgerNumber] [int] IDENTITY(1,1) NOT NULL,
    [MFDB_StateId] [int] NOT NULL,
    [MFDB_RegionId] [int] NOT NULL,
    [MFDB_BranchId] [int] NOT NULL,
    [MFDB_SHGId] [int] NOT NULL,
    [MFDB_SHGName] [varchar](75) NOT NULL,
    [MFDB_ShgMemberId] [int] NOT NULL,
    [MFDB_MemberName] [varchar](50) NOT NULL,
    [MFDB_LoanNumber] [int] NOT NULL,
    [MFDB_LoanAmount] [int] NOT NULL
    ) ON [PRIMARY]
    /* Drop and Create TempCollection Table. This table has all installments for a given member */
    ;WITH CTE_1 AS
    SELECT CT.MFDB_StateId AS StateId,
    CT.MFDB_RegionId AS RegionId,
    CT.MFDB_BranchId AS BranchId,
    CT.MFDB_SHGId AS ShgId,
    SM.MFDB_SHGName AS ShgName,
    CT.MFDB_SHGMemberId AS SHGMemberId,
    SMM.MFDB_MemberName AS MemberName,
    CT.MFDB_LoanNumber AS LoanNumber,
    LM.MFDB_LoanAmount AS LoanAmount
    FROM dbo.MFDB_COLLECTION_TXN CT
    LEFT JOIN dbo.MFDB_COLLECTION_AUDIT CA
    On CT.MFDB_SHGId = CA.MFDB_SHGId
    And CT.MFDB_MemberId = CA.MFDB_MemberId
    And CT.MFDB_LoanNumber = CA.MFDB_LoanNumber
    And CT.MFDB_CollectionId = CA.MFDB_CollectionId
    And CT.MFDB_LSourceId = CA.MFDB_LSourceId
    INNER JOIN dbo.MFDB_SHG_MASTER SM
    On CT.MFDB_SHGId = SM.MFDB_SHGId
    INNER JOIN dbo.MFDB_SHGMEMBER_MASTER SMM
    On CT.MFDB_SHGId = SMM.MFDB_SHGId
    And CT.MFDB_SHGMemberId = SMM.MFDB_SHGMemberId
    INNER JOIN dbo.MFDB_LOANAPPLICATION_MASTER LM
    ON LM.MFDB_SHGId = CT.MFDB_SHGId
    AND LM.MFDB_ShgMemberId = CT.MFDB_ShgMemberId
    AND LM.MFDB_LoanNumber = CT.MFDB_LoanNumber
    Where DATEDIFF(DAY,MFDB_CollectionDate,@i_DayOpenDate) = 0
    And CT.MFDB_CollectionAmount > 0
    And CT.MFDB_CollApprovedBy IS NULL
    AND CT.MFDB_BranchId = @i_BranchId
    AND CT.MFDB_SHGId = @i_SHGId
    AND CT.MFDB_ShgMemberId = @i_SHGMemberId
    AND CT.MFDB_LoanNumber = @i_LoanNumber
    CTE_2 AS
    SELECT DISTINCT
    StateId,
    RegionId,
    BranchId,
    ShgId,
    ShgName,
    SHGMemberId,
    MemberName,
    LoanNumber,
    LoanAmount
    FROM CTE_1
    INSERT INTO #TEMPDCBCOLLECTION ([MFDB_StateId],[MFDB_RegionId],[MFDB_BranchId],[MFDB_SHGId],[MFDB_SHGName],[MFDB_ShgMemberId],[MFDB_MemberName],[MFDB_LoanNumber],[MFDB_LoanAmount])
    SELECT StateId,
    RegionId,
    BranchId,
    ShgId,
    ShgName,
    SHGMemberId,
    MemberName,
    LoanNumber,
    LoanAmount
    FROM CTE_2
    DECLARE DCBMonthCursor CURSOR FOR
    SELECT [MFDB_StateId],
    [MFDB_RegionId],
    [MFDB_BranchId],
    [MFDB_SHGId],
    [MFDB_SHGName],
    [MFDB_ShgMemberId],
    [MFDB_MemberName],
    [MFDB_LoanNumber],
    [MFDB_LoanAmount]
    FROM #TEMPDCBCOLLECTION
    OPEN DCBMonthCursor
    FETCH NEXT FROM DCBMonthCursor
    INTO @p_TempStateId ,
    @p_TempRegionId ,
    @p_TempBranchId ,
    @p_TempSHGId ,
    @p_TempSHGName ,
    @p_TempSHGMemberId ,
    @p_TempMemberName ,
    @p_TempLoanNumber ,
    @p_TempLoanAmount
    WHILE (@@FETCH_STATUS = 0)
    BEGIN
    Set @p_TotalInterest = 0
    Select @p_TotalInterest = SUM(MFDB_StdInterest) From MFDB_LOAN_DISBURSEMENT Where MFDB_SHGId = @p_TempSHGId And MFDB_ShgMemberId = @p_TempSHGMemberId And MFDB_LoanNumber = @p_TempLoanNumber
    ;With
    CTE_1 AS
    SELECT LM.MFDB_StateId AS StateId ,
    LM.MFDB_RegionId AS RegionId,
    LM.MFDB_BranchId AS BranchId,
    LM.MFDB_SHGId AS SHGId,
    SM.MFDB_SHGName AS SHGName,
    LM.MFDB_ShgMemberId AS SHGMemId,
    LM.MFDB_MemberName AS MemberName,
    SM.MFDB_VillageId AS VillageId,
    LM.MFDB_LoanNumber AS LoanNo,
    LM.MFDB_LoanAmount AS LoanAmount,
    LM.MFDB_DisburseDate AS DisbursedDate,
    ISNULL((SELECT LD.MFDB_DemandDate
    FROM dbo.MFDB_LOAN_DISBURSEMENT LD
    Where LD.MFDB_SHGId = LM.MFDB_SHGId
    And LD.MFDB_ShgMemberId = LM.MFDB_ShgMemberId
    And LD.MFDB_LoanNumber = LM.MFDB_LoanNumber
    And DATEDIFF(DAY,LD.MFDB_DemandDate,@i_DayOpenDate) = 0
    And LD.MFDB_ApprovalStatus = 1 ),NULL) AS DemandDate,
    ISNULL((SELECT TOP 1 CT.MFDB_CollectionDate
    FROM dbo.MFDB_COLLECTION_TXN CT
    Inner Join dbo.MFDB_COLLECTION_AUDIT CA
    On CT.MFDB_SHGId = CA.MFDB_SHGId
    And CT.MFDB_ShgMemberId = CA.MFDB_ShgMemberId
    And CT.MFDB_LoanNumber = CA.MFDB_LoanNumber
    And CT.MFDB_LSourceId = CA.MFDB_LSourceId
    And CT.MFDB_CollectionId = CA.MFDB_CollectionId
    WHERE CT.MFDB_SHGId = LM.MFDB_SHGId
    AND CT.MFDB_ShgMemberId = LM.MFDB_ShgMemberId
    AND CT.MFDB_LoanNumber = LM.MFDB_LoanNumber
    And DATEDIFF(DAY,CT.MFDB_CollectionDate,@i_DayOpenDate) = 0
    ORDER BY CA.MFDB_CollectionId DESC),NULL) AS CollectionDate,
    ISNULL((SELECT TOP 1 CA.MFDB_InstallmentNumber
    FROM dbo.MFDB_COLLECTION_AUDIT CA
    Inner Join dbo.MFDB_COLLECTION_TXN CT
    On CT.MFDB_SHGId = CA.MFDB_SHGId
    And CT.MFDB_ShgMemberId = CA.MFDB_ShgMemberId
    And CT.MFDB_LoanNumber = CA.MFDB_LoanNumber
    And CT.MFDB_LSourceId = CA.MFDB_LSourceId
    And CT.MFDB_CollectionId = CA.MFDB_CollectionId
    WHERE CA.MFDB_SHGId = LM.MFDB_SHGId
    AND CA.MFDB_ShgMemberId = LM.MFDB_ShgMemberId
    AND CA.MFDB_LoanNumber = LM.MFDB_LoanNumber
    And DATEDIFF(DAY,CT.MFDB_CollectionDate,@i_DayOpenDate) = 0
    ORDER BY CA.MFDB_CollectionId DESC),
    ISNULL((SELECT LD.MFDB_InstallmentNumber
    FROM dbo.MFDB_LOAN_DISBURSEMENT LD
    Where LD.MFDB_SHGId = LM.MFDB_SHGId
    And LD.MFDB_ShgMemberId = LM.MFDB_ShgMemberId
    And LD.MFDB_LoanNumber = LM.MFDB_LoanNumber
    And DATEDIFF(DAY,LD.MFDB_DemandDate,@i_DayOpenDate) = 0
    And LD.MFDB_ApprovalStatus = 1 ),0)) AS IntallNo,
    ISNULL(CAST((SELECT TOP 1 NR.MFDB_BalancePrincipal
    FROM dbo.MFDB_NEW_DCB_REPORT NR
    WHERE NR.MFDB_SHGId = LM.MFDB_SHGId
    AND NR.MFDB_ShgMemberId = LM.MFDB_ShgMemberId
    AND NR.MFDB_LoanNumber = LM.MFDB_LoanNumber
    ORDER BY NR.MFDB_LedgerNumber DESC) AS NUMERIC(18,0)),0) AS ArrPrincipal,
    ISNULL(CAST((SELECT TOP 1 NR.MFDB_BalanceInterest
    FROM dbo.MFDB_NEW_DCB_REPORT NR
    WHERE NR.MFDB_SHGId = LM.MFDB_SHGId
    AND NR.MFDB_ShgMemberId = LM.MFDB_ShgMemberId
    AND NR.MFDB_LoanNumber = LM.MFDB_LoanNumber
    ORDER BY NR.MFDB_LedgerNumber DESC) AS NUMERIC(18,0)),0) AS ArrInterest,
    0 AS CurrDemandPrin,
    0 AS CurrDemandInt,
    ISNULL((SELECT CAST(SUM(ISNULL(CA.MFDB_CollectedPrincipal,0) +
    ISNULL(CA.MFDB_AdvancePrincipal,0) +
    ISNULL(CA.MFDB_ArrearPrincipal,0)) AS NUMERIC(18,0))
    FROM dbo.MFDB_COLLECTION_AUDIT CA
    Inner Join dbo.MFDB_COLLECTION_TXN CT
    On CT.MFDB_SHGId = CA.MFDB_SHGId
    And CT.MFDB_ShgMemberId = CA.MFDB_ShgMemberId
    And CT.MFDB_LoanNumber = CA.MFDB_LoanNumber
    And CT.MFDB_LSourceId = CA.MFDB_LSourceId
    And CT.MFDB_CollectionId = CA.MFDB_CollectionId
    WHERE CA.MFDB_SHGId = LM.MFDB_SHGId
    AND CA.MFDB_ShgMemberId = LM.MFDB_ShgMemberId
    AND CA.MFDB_LoanNumber = LM.MFDB_LoanNumber
    And DATEDIFF(DAY,CT.MFDB_CollectionDate,@i_DayOpenDate) = 0
    ),0) AS CurrCollPri,
    ISNULL((SELECT CAST(SUM(ISNULL(CA.MFDB_CollectedInterest,0) +
    ISNULL(CA.MFDB_AdvanceInterest,0) +
    ISNULL(CA.MFDB_ArrearInterest,0)) AS NUMERIC(18,0))
    FROM dbo.MFDB_COLLECTION_AUDIT CA
    Inner Join dbo.MFDB_COLLECTION_TXN CT
    On CT.MFDB_SHGId = CA.MFDB_SHGId
    And CT.MFDB_ShgMemberId = CA.MFDB_ShgMemberId
    And CT.MFDB_LoanNumber = CA.MFDB_LoanNumber
    And CT.MFDB_LSourceId = CA.MFDB_LSourceId
    And CT.MFDB_CollectionId = CA.MFDB_CollectionId
    WHERE CA.MFDB_SHGId = LM.MFDB_SHGId
    AND CA.MFDB_ShgMemberId = LM.MFDB_ShgMemberId
    AND CA.MFDB_LoanNumber = LM.MFDB_LoanNumber
    And DATEDIFF(DAY,CT.MFDB_CollectionDate,@i_DayOpenDate) = 0
    ),0) AS CurrCollInt,
    ISNULL(CAST((SELECT TOP 1 NR.MFDB_AdvCBPrincipal
    FROM dbo.MFDB_NEW_DCB_REPORT NR
    WHERE NR.MFDB_SHGId = LM.MFDB_SHGId
    AND NR.MFDB_ShgMemberId = LM.MFDB_ShgMemberId
    AND NR.MFDB_LoanNumber = LM.MFDB_LoanNumber
    ORDER BY NR.MFDB_LedgerNumber DESC) AS NUMERIC(18,0)),0) AS AdvOBPri,
    ISNULL(CAST((SELECT TOP 1 NR.MFDB_AdvCBInterest
    FROM dbo.MFDB_NEW_DCB_REPORT NR
    WHERE NR.MFDB_SHGId = LM.MFDB_SHGId
    AND NR.MFDB_ShgMemberId = LM.MFDB_ShgMemberId
    AND NR.MFDB_LoanNumber = LM.MFDB_LoanNumber
    ORDER BY NR.MFDB_LedgerNumber DESC) AS NUMERIC(18,0)),0) AS AdvOBInt,
    0 AS AdvCBPri,
    0 AS AdvCBInt,
    0 AS BalancePri,
    0 AS BalanceInt,
    ISNULL((SELECT CAST(SUM(ISNULL(CA.MFDB_CollectedPrincipal,0) +
    ISNULL(CA.MFDB_AdvancePrincipal,0) +
    ISNULL(CA.MFDB_ArrearPrincipal,0)) AS NUMERIC(18,0))
    FROM dbo.MFDB_COLLECTION_AUDIT CA
    Inner Join dbo.MFDB_COLLECTION_TXN CT
    On CT.MFDB_SHGId = CA.MFDB_SHGId
    And CT.MFDB_ShgMemberId = CA.MFDB_ShgMemberId
    And CT.MFDB_LoanNumber = CA.MFDB_LoanNumber
    And CT.MFDB_LSourceId = CA.MFDB_LSourceId
    And CT.MFDB_CollectionId = CA.MFDB_CollectionId
    WHERE CA.MFDB_SHGId = LM.MFDB_SHGId
    AND CA.MFDB_ShgMemberId = LM.MFDB_ShgMemberId
    AND CA.MFDB_LoanNumber = LM.MFDB_LoanNumber
    And DATEDIFF(DAY,CT.MFDB_CollectionDate,@i_DayOpenDate) >= 0
    ),0) AS OS_Pri,
    ISNULL((SELECT CAST(SUM(ISNULL(CA.MFDB_CollectedInterest,0) +
    ISNULL(CA.MFDB_AdvanceInterest,0) +
    ISNULL(CA.MFDB_ArrearInterest,0)) AS NUMERIC(18,0))
    FROM dbo.MFDB_COLLECTION_AUDIT CA
    Inner Join dbo.MFDB_COLLECTION_TXN CT
    On CT.MFDB_SHGId = CA.MFDB_SHGId
    And CT.MFDB_ShgMemberId = CA.MFDB_ShgMemberId
    And CT.MFDB_LoanNumber = CA.MFDB_LoanNumber
    And CT.MFDB_LSourceId = CA.MFDB_LSourceId
    And CT.MFDB_CollectionId = CA.MFDB_CollectionId
    WHERE CA.MFDB_SHGId = LM.MFDB_SHGId
    AND CA.MFDB_ShgMemberId = LM.MFDB_ShgMemberId
    AND CA.MFDB_LoanNumber = LM.MFDB_LoanNumber
    And DATEDIFF(DAY,CT.MFDB_CollectionDate,@i_DayOpenDate) >= 0
    ),0) AS OS_Int,
    0 AS RepaymentPercentage,
    LM.MFDB_LoanSchemeId AS LoanProduct,
    LM.MFDB_LActivityId AS LoanActivity,
    LM.MFDB_LActSpecId AS LoanSubActivity,
    LM.MFDB_FundingAgencyId AS FundAgencyId,
    LM.MFDB_LSourceId AS SourceId
    FROM dbo.MFDB_LOANAPPLICATION_MASTER LM
    Left Join dbo.MFDB_SHG_MASTER SM
    On SM.MFDB_ShgId = LM.MFDB_ShgId
    WHERE LM.MFDB_ApprovalStatus= 3
    AND LM.MFDB_DisburseDate IS NOT NULL
    AND LM.MFDB_StateId = @p_TempStateId
    AND LM.MFDB_RegionId = @p_TempRegionId
    AND LM.MFDB_BranchId = @p_TempBranchId
    AND LM.MFDB_SHGId = @p_TempSHGId
    AND LM.MFDB_ShgMemberId = @p_TempSHGMemberId
    AND LM.MFDB_LoanNumber = @p_TempLoanNumber
    CTE_2 AS
    SELECT StateId, RegionId, BranchId, SHGId, SHGName, SHGMemId, MemberName, VillageId , LoanNo, LoanAmount, DisbursedDate,DemandDate, CollectionDate, IntallNo,
    ArrPrincipal,
    ArrInterest,
    CurrDemandPrin,
    CurrDemandInt,
    ISNULL(ISNULL(ArrPrincipal,0) + ISNULL(CurrDemandPrin,0),0) AS TotDemandPri,
    ISNULL(ISNULL(ArrInterest,0) + ISNULL(CurrDemandInt,0),0) AS TotDemandInt,
    AdvOBPri,
    AdvOBInt,
    CurrCollPri,
    CurrCollInt,
    AdvCBPri,
    AdvCBInt,
    BalancePri,
    BalanceInt,
    ISNULL(ISNULL(LoanAmount,0) - ISNULL(OS_Pri,0),0) AS OS_Pri,
    ISNULL(ISNULL(@p_TotalInterest,0) - ISNULL(OS_Int,0),0) OS_Int,
    CONVERT(INT,RepaymentPercentage) AS RepaymentPercentage,
    LoanProduct,
    LoanActivity,
    LoanSubActivity,
    FundAgencyId,
    SourceId
    FROM CTE_1
    CTE_3 AS
    SELECT StateId, RegionId, BranchId, SHGId, SHGName, SHGMemId, MemberName, VillageId , LoanNo, LoanAmount, DisbursedDate,DemandDate, CollectionDate, IntallNo,
    ArrPrincipal,
    ArrInterest,
    CurrDemandPrin,
    CurrDemandInt,
    TotDemandPri,
    TotDemandInt,
    CASE WHEN AdvOBPri < 0 THEN AdvOBPri * -1 ELSE AdvOBPri END AS AdvOBPri,
    CASE WHEN AdvOBInt < 0 THEN AdvOBInt * -1 ELSE AdvOBInt END AS AdvOBInt,
    CurrCollPri,
    CurrCollInt,
    CASE WHEN ISNULL(TotDemandPri,0) = 0 THEN ISNULL((CurrCollPri + AdvOBPri),0)
    WHEN ISNULL(TotDemandPri,0) > 0 AND ISNULL(CurrCollPri + AdvOBPri,0) > ISNULL(TotDemandPri,0) THEN ISNULL(ISNULL(CurrCollPri + AdvOBPri,0) - ISNULL(TotDemandPri,0),0)
    WHEN ISNULL(TotDemandPri,0) > 0 AND ISNULL(CurrCollPri + AdvOBPri,0) < ISNULL(TotDemandPri,0) THEN 0
    WHEN ISNULL(CurrCollPri + AdvOBPri,0) = ISNULL(TotDemandPri,0) THEN 0
    ELSE 0 END AS AdvCBPri,
    CASE WHEN ISNULL(TotDemandInt,0) = 0 THEN ISNULL((CurrCollInt + AdvOBInt),0)
    WHEN ISNULL(TotDemandInt,0) > 0 AND ISNULL(CurrCollInt + AdvOBInt,0) > ISNULL(TotDemandInt,0) THEN ISNULL(ISNULL(CurrCollInt + AdvOBInt,0) - ISNULL(TotDemandInt,0),0)
    WHEN ISNULL(TotDemandInt,0) > 0 AND ISNULL(CurrCollInt + AdvOBInt,0) < ISNULL(TotDemandInt,0) THEN 0
    WHEN ISNULL(CurrCollInt + AdvOBInt,0) = ISNULL(TotDemandInt,0) THEN 0
    ELSE 0 END AS AdvCBInt,
    0 AS BalancePri,
    0 AS BalanceInt,
    OS_Pri,
    OS_Int,
    0 AS Repayment,
    LoanProduct,
    LoanActivity,
    LoanSubActivity,
    FundAgencyId,
    SourceId,
    CONVERT(CHAR(3), @i_DayOpenDate, 0) + ' - ' + RIGHT(CONVERT(CHAR(4), YEAR(@i_DayOpenDate)),2) AS Months
    FROM CTE_2
    INSERT INTO dbo.MFDB_NEW_DCB_REPORT
    ( [MFDB_TxnDate]
    ,[MFDB_StateId]
    ,[MFDB_RegionId]
    ,[MFDB_BranchId]
    ,[MFDB_SHGId]
    ,[MFDB_SHGName]
    ,[MFDB_ShgMemberId]
    ,[MFDB_MemberName]
    ,[MFDB_VillageId]
    ,[MFDB_LoanNumber]
    ,[MFDB_LoanAmount]
    ,[MFDB_DisbursedDate]
    ,[MFDB_DemandDate]
    ,[MFDB_CollectionDate]
    ,[MFDB_InstallmentNumber]
    ,[MFDB_ArrearPrincipal]
    ,[MFDB_ArrearInterest]
    ,[MFDB_DemandPrincipal]
    ,[MFDB_DemandInterest]
    ,[MFDB_TotDemandPrincipal]
    ,[MFDB_TotDemandInterest]
    ,[MFDB_AdvOBPrincipal]
    ,[MFDB_AdvOBInterest]
    ,[MFDB_CollectedPrincipal]
    ,[MFDB_CollectedInterest]
    ,[MFDB_AdvCBPrincipal]
    ,[MFDB_AdvCBInterest]
    ,[MFDB_BalancePrincipal]
    ,[MFDB_BalanceInterest]
    ,[MFDB_OS_Pri]
    ,[MFDB_OS_Int]
    ,[MFDB_RepaymentPercentage]
    ,[MFDB_LoanSchemeId]
    ,[MFDB_LActivityId]
    ,[MFDB_LActSpecId]
    ,[MFDB_FundAgencyId]
    ,[MFDB_LSourceId]
    ,[MFDB_Months]
    ,[MFDB_PanchayatId]
    ,[MFDB_PanchayatName]
    ,[MFDB_VillageName]
    SELECT @i_DayOpenDate ,StateId, RegionId, BranchId, SHGId, SHGName, SHGMemId, MemberName, VillageId , LoanNo, LoanAmount, DisbursedDate,DemandDate,CollectionDate,IntallNo,
    ArrPrincipal,ArrInterest,CurrDemandPrin,CurrDemandInt,TotDemandPri,TotDemandInt,AdvOBPri,AdvOBInt,CurrCollPri,CurrCollInt,
    CASE WHEN AdvCBPri < 0 THEN 0 ELSE AdvCBPri END,
    CASE WHEN AdvCBInt < 0 THEN 0 ELSE AdvCBInt END,
    CASE WHEN ISNULL(TotDemandPri,0) = 0 THEN 0
    WHEN ISNULL(TotDemandPri,0) > 0 AND ISNULL(CurrCollPri + AdvOBPri,0) > ISNULL(TotDemandPri,0) THEN 0
    WHEN ISNULL(TotDemandPri,0) > 0 AND ISNULL(CurrCollPri + AdvOBPri,0) < ISNULL(TotDemandPri,0) THEN ABS(ISNULL(ISNULL(CurrCollPri + AdvOBPri,0) - ISNULL(TotDemandPri,0),0) * -1)
    WHEN ISNULL(CurrCollPri + AdvOBPri,0) = ISNULL(TotDemandPri,0) THEN 0
    ELSE 0 END AS BalancePri,
    CASE WHEN ISNULL(TotDemandInt,0) = 0 THEN 0
    WHEN ISNULL(TotDemandInt,0) > 0 AND ISNULL(CurrCollInt + AdvOBInt,0) > ISNULL(TotDemandInt,0) THEN 0
    WHEN ISNULL(TotDemandInt,0) > 0 AND ISNULL(CurrCollInt + AdvOBInt,0) < ISNULL(TotDemandInt,0) THEN ABS(ISNULL(ISNULL(CurrCollInt + AdvOBInt,0) - ISNULL(TotDemandInt,0),0) * -1)
    WHEN ISNULL(CurrCollInt + AdvOBInt,0) = ISNULL(TotDemandInt,0) THEN 0
    ELSE 0 END AS BalanceInt,
    OS_Pri,
    OS_Int,
    0 AS Repayment,
    LoanProduct,LoanActivity,LoanSubActivity,FundAgencyId,SourceId,Months,@p_TempPanchayatId,@p_TempPanchayatName,@p_TempVillageName
    FROM CTE_3
    If @@Error != 0
    Begin
    Set @o_ErrorStatus = 1
    ROLLBACK TRANSACTION DCBGenerated
    RETURN
    End
    FETCH NEXT FROM DCBMonthCursor
    INTO @p_TempStateId ,
    @p_TempRegionId ,
    @p_TempBranchId ,
    @p_TempSHGId ,
    @p_TempSHGName ,
    @p_TempSHGMemberId ,
    @p_TempMemberName ,
    @p_TempLoanNumber ,
    @p_TempLoanAmount
    END
    CLOSE DCBMonthCursor
    DEALLOCATE DCBMonthCursor
    DELETE FROM #TEMPDCBCOLLECTION
    If @@Error != 0
    Begin
    Set @o_ErrorStatus = 1
    ROLLBACK TRANSACTION DCBGenerated
    RETURN
    End
    END
    COMMIT TRANSACTION DCBGenerated

  • Supress Column Heading - File Content Conversion in Sender Adapter

    Hi,
    Let me give a more clear picture about my scenario.  I need to convert CSV File to XML output:-
    My source file has column heading and values.  The sample data is mentioned hereunder:-
    PERNR;KID;PNALT;NACHN;NAME2;VORNA
    ;1200;1200;Angus
    I have created a data type as under:-
    DT_LegacyEmployee (Category - Complex Type)
         Employees (Category - Element, Occurence - 1)
              Header (Category - Element, Occurence - 0...1)
                   PERNR_H
                   KID_H
                   PNALT_H
                   NACHN_H
                   NAME2_H
                   VORNA_H
              Employee (Categroy - Element, Type - DT_LegacyEmployee_Row, Occurence - 0...unbounded)
                   PERNR
                   KID
                   PNALT
                   NACHN
                   NAME2
                   VORNA
    The file conversion parameters in the file sender adapter are mentioned hereunder:-
    Document Name - MT_LegacyEmployee
    Document Namespace - http://abc.com/xi
    Recordset Name - Employees
    Rescordset Structure - Header,1,Employee,*
    Recordsets per Message - 1
    Key Field Type - String (Case Sensitive)
    Employee.fieldSeparator - ;
    Employee.endSeparator - 'nl'
    Employee.fieldNames - PERNR,KID,PNALT,NACHN,NAME2,VORNA
    I dont' have a key field value.  How do we remove the header and show only the values in the xml output.  I have searched the forum topics as well checked many blogs related to file content conversion, but nothing helped.  Kindly advice how to fix this issue.  Thanks in advance.
    Regards.
    Praveen

    Hi Praveen,
    Change your File Adapter as below
    Document Name - MT_LegacyEmployee
    Document Namespace - http://abc.com/xi
    Recordset Name - Employees
    Rescordset Structure - Employee,*
    Recordsets per Message - 1
    Key Field Type - String (Case Sensitive)
    Employee.fieldSeparator - ;
    Employee.endSeparator - 'nl'
    Employee.fieldNames - PERNR,KID,PNALT,NACHN,NAME2,VORNA
    There is no need for the Header required in the data type.
    DT_LegacyEmployee (Category - Complex Type)
    Employees (Category - Element, Occurence - 1)
    Employee (Categroy - Element, Type - DT_LegacyEmployee_Row, Occurence - 0...unbounded)
    PERNR
    KID
    PNALT
    NACHN
    NAME2
    VORNA
    Now the trick is in the mapping program
    Lets assume your mapping looks like
    MT_LegacyEmployee ---> MT_TargetEmployee
    - Employees ---> Records
       - Employee ---> Record
         - PERNR  ---> TargetPERNR
         - .. so on
    When you do a mapping from Employee ---> Record apply the following logic.
    (PERNR)--->
                 (TestEquals =) --->(NOT)--->
    (Constant) --->                                (IF)
    (PERNR)                       (IF Without Else) ---> (Record)
                                                   (THEN)
                                (Employee)--->
    When doing this make sure RightClick on PERNR and Select Context ---> Employees.
    By default context would be from Employee and it will give you an error of XSD format. So make sure you are changing the context.

  • Excel like 'Freeze column header' functionality in sharepoint OOB list view webpart

    Hi,
    I have OOB external list dropped on a page as listview webpart. It contains many records and hence while scrolling down headers are no available, hence it should freeze all column headers while scrolling down the page. Its directly dragged and dropped
    on site page hence no server side formatting can be done.
    Is there any way we can apply some client side script to freeze column headers to listview webpart while scrolling down? or any settings that can be done to acheive this?
    Thanks in advance.
    Regards,
    Rahul

    Hi Rahul,
    Normal techniques for freezing the header row of an HTML table tend to fall short when it comes to SharePoint 2010 lists due to the lack of THEAD elements.
    You can try something like this, although you may want to test it in various browsers in case the column heading alignment is off.
    <style>
    .ms-viewheadertr{background-color:white;}
    </style>
    <script>
    /* wrap the table in a div, set its height, give it scrollbars, and move it down */
    var myTable = document.querySelector(".ms-listviewtable");
    var wrapperDiv = document.createElement('div');
    wrapperDiv.setAttribute("ID","FreezePaneWrapper");
    wrapperDiv.setAttribute("style","OVERFLOW: auto; HEIGHT: 400px; padding-top:38px;");
    wrapperDiv.appendChild(myTable.cloneNode(true));
    myTable.parentNode.replaceChild(wrapperDiv,myTable);
    /* Freeze the header row and move it up*/
    var headerRow = document.querySelector(".ms-viewheadertr");
    document.getElementById("FreezePaneWrapper").style.width = "" + headerRow.scrollWidth + "px";
    headerRow.style.width = "" + headerRow.scrollWidth + "px";
    headerRow.style.position = "absolute";
    headerRow.style.top = ""+(headerRow.offsetTop-39)+"px";
    /* Tell the header's columns to be the same width as the cells in the first "alternating" row */
    var columns = document.querySelector("table.ms-listviewtable tr.ms-alternating").querySelectorAll("tr>td");
    headers = document.querySelectorAll("tr.ms-viewheadertr th");
    for(var i = 0; i < headers.length; i++){
    if(columns[i].scrollWidth > headers[i].scrollWidth){
    headers[i].style.width = ""+columns[i].scrollWidth + "px";
    }else{
    columns[i].style.width = ""+headers[i].scrollWidth + "px";
    </script>
    Edit: Also, you may want to inspect the HTML attributes on the external list view to be sure the class names match up with the querySelector parameters above. Specifically, the table should have a class of "ms-listviewtable", the header row should
    have a class of "ms-viewheadertr", and rows of alternating background color should have a class of "ms-alternating".
    If any of those are different in your case, you may be able to adjust the above code accordingly.

  • How to Link column header only in classic Report in APEX 4.1

    Hello Everybody,
    Probably there is a simpler way to do this, but I am not sure. I want a link on column header in Report on a specific column. The link will take me to new region or a page.
    How to achieve this in APEX 4.1
    Theme : Blue 2
    Database 11g
    I see there is a column link opiton, but that creates link for every row in that column on a specific icon, I just want link on a title of the column in Classic Report.
    For Example,
    if there are two columns Name and Client ID, which has 10 records to display on a classic report. I wan the link on Client ID on header only not on the records.
    Can anybody provide some simple solution for this.
    Thanks,
    --CP
    Edited by: cpora007 on Jun 22, 2012 10:38 AM

    Hello,
    I didn't understand, what do you mean by default it is going to sort popup. I have a classic report based on SQL, which generates a report with static header, there is no sort or any other link on that.
    I added a link in column header name with an anchor. It works and takes to the new page.
    But it is not a proper solution. A solution based on Jquery dynamic action is preferable. Also the preferred option is that the link opens a hidden region of the same page at the same location of the report and the report gets hidden. after the procession on the form region and submitting the update/ insert process. the report region shows up with the change data.
    Moving on to new page is 2nd option, if the first do not work.
    In the JavaScript, put: apex.submit("GO_TO_MY_OTHER_PAGE");
    On the page, create a Branch to the Second page. Set the condition to Request=Expression 1. Set the request to "GO_TO_MY_OTHER_PAGE"
    On which page I need to create a branch?, Is it on the report page or the form page.
    Thanks a lot for the response. I appreciate your kind efforts in this regard.
    --CP                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Infinite loop creating new page due to column header overflow.

    i am getting an error and some pages "Infinite loop creating new page due to column header overflow. " --
    using report builder 9, i have a fairly simple report - that contains 4 subreports.
    for some pages i get the error - it seems if there is more data than would fit on 1 page.
    smaller pages work fine.
    the subreports are all simple queries and dumps....
    containing page header, column header, detail sections.
    page header has just a text bar of the name of the section.
    column header has the field names
    detail section has the data - 1 row for each row in the recordset.
    nothing i do seems to change getting "Infinite loop creating new page due to column header overflow. " on a page with more than 15-20 records returned.
    any ideas would be appreciated.

    Try these links if you are still having the issue:
    http://community.jaspersoft.com/questions/543302/receive-infinite-loop-creating-new-page-d ue-column-header-overflow-exception
    http://community.jaspersoft.com/questions/500177/infinite-loop-due-page-header-overflow

  • Sub report in column header

    Infinite loop creating new page due to column header overflow.
    I have a sub report on the column header which works,
    Because my sub report return different records from data source, it fails and get infinite loop error message like above when I have 9 records, it works less than 9 records.
    I would like to know my sub report returns records some times more, are there any place for my subreport?
    Are there limit for sub report?
    Your help and information is great appreciated,
    Regards,
    Iccsi,

    Thanks for the message and help,
    My sub report link to a data soruce which is a stroed procedure running from MS SQL server.
    The stroed procedure returns data based on data base what data in the table.
    It looks like the sub report on the Report Builder limited by the length of the report band.
    I tried to move to column header, column footer, report footer all the same, when the sub report growth then it fails to generate the reports.
    Regards,
    Iccsi,

  • Column heading -refer to the webdynpro tutorial 34

    Excel Export Using the Web Dynpro Binary Cache (34)
    column heading problem
    https://www.sdn.sap.com/irj/sdn/downloaditem?rid=/library/uuid/1208c2cd-0401-0010-4ab6-f4736074acc6
    u will get the heading like
    /Products
    /ProductsElement/Article
    /ProductsElement/Quantity
    /ProductsElement/Price
    the code that form the heading
    public void exportToExcel2003( com.sap.tc.webdynpro.progmodel.api.IWDNode dataNode, java.util.Map columnInfos )
        //@@begin exportToExcel2003()
        byte[] excelXMLFile;
        IWDCachedWebResource cachedExcelResource = null;
        String fileName = dataNode.getNodeInfo().getName() + ".xls";
        try {
          // create Excel 2003 XML data as a byte array for the given context node, attributes and headers       
          excelXMLFile = this.toExcel(dataNode, columnInfos).getBytes("UTF-8");
          // create a cached Web Dynpro XLS Resource for the given byte array and filename
          cachedExcelResource = this.getCachedWebResource(excelXMLFile, fileName, WDWebResourceType.XLS);
          // Store URL and filename of cached excel resource in context.
          if (cachedExcelResource != null) {
            wdContext.currentContextElement().setExcelFileURL(cachedExcelResource.getURL());
            wdContext.currentContextElement().setExcelFileName(cachedExcelResource.getResourceName());
            // Open popup window with a link to the cached excel file web resource.
            this.openExcelLinkPopup();
          } else {
            wdComponentAPI.getMessageManager().reportException("Failed to create Excel file from table!", true);
        } catch (UnsupportedEncodingException e) {
          wdComponentAPI.getMessageManager().reportException(e.getLocalizedMessage(), true);
        } catch (WDURLException e) {
          wdComponentAPI.getMessageManager().reportException(e.getLocalizedMessage(), true);
        //@@end
      //@@begin javadoc:closeExcelLinkPopup()
       * Destroys popup window. To be called in an action event handler of a view controller related to
       * the opened popup window. View controller must have a controller usage declared for invoking
       * this public method of the public component controller API. 
      //@@end
      public void closeExcelLinkPopup( )
        //@@begin closeExcelLinkPopup()
        if (excelLinkWindow != null) {
          excelLinkWindow.destroy();
          excelLinkWindow = null;
        //@@end
       * The following code section can be used for any Java code that is
       * not to be visible to other controllers/views or that contains constructs
       * currently not supported directly by Web Dynpro (such as inner classes or
       * member variables etc.). </p>
       * Note: The content of this section is in no way managed/controlled
       * by the Web Dynpro Designtime or the Web Dynpro Runtime.
      //@@begin others
       * Create an XML respresentation of the given context data.
       * RESTRICTION: Excel 2003 must be installed on the client machine for opening the given xml data
       * representation as an Excel file. 
       * @return string respresentation of the created xml data for Excel 2003.
      private String toExcel(IWDNode dataNode, Map columnInfos) {
        StringBuffer x = new StringBuffer();
        String attributeName, headerName;
        String entriesName = dataNode.getNodeInfo().getName();
        String entryName = entriesName + "Element";
        // trim given header texts, so that XML element names adhere to the rule 'no spaces contained'.    
        trimHeaderTexts(columnInfos);
        x.append("<?xml version='1.0' encoding='UTF-8' standalone='no'?>n");
        x.append("<").append(entriesName).append(">n");
        for (int i = 0; i < dataNode.size(); ++i) {
          IWDNodeElement dataNodeElement = dataNode.getElementAt(i);
          x.append("<").append(entryName).append(">n");
          for (Iterator iter = columnInfos.keySet().iterator(); iter.hasNext();) {
            attributeName = (String) iter.next();
            headerName = (String) columnInfos.get(attributeName);
            x
              .append("<")
              .append(headerName)
              .append(">")
              .append(dataNodeElement.getAttributeValue(attributeName))
              .append("</")
              .append(headerName)
              .append(">n");
          x.append("</").append(entryName).append(">n");
        x.append("</").append(entriesName).append(">n");
        return x.toString();
       * Create cached Web Dynpro resource for given byte-array, filename and web resource type (xls).
       * @return Excel file as cached Web Dynpro web resource. 
      private IWDCachedWebResource getCachedWebResource(byte[] file, String name, WDWebResourceType type) {
        IWDCachedWebResource cachedWebResource = null;
        if (file != null) {
          cachedWebResource = WDWebResource.getWebResource(file, type);
          cachedWebResource.setResourceName(name);
        return cachedWebResource;
       * Opens new popup window. The popup contains a link to the newly generated, cached excel file. 
      private void openExcelLinkPopup() {
        excelLinkWindow =
          wdComponentAPI.getWindowManager().createModalWindow(
            wdComponentAPI.getComponentInfo().findInWindows("ExcelLinkPopup"));
        excelLinkWindow.setWindowPosition(WDWindowPos.CENTER);
        excelLinkWindow.open();
      * Trims all given header texts because XML element names (to be created) must adhere to XML
      * rules (that is, they cannot include special characters, spaces, and so on.
      private void trimHeaderTexts(Map columnInfos) {
        String attributeName, trimmedHeaderText;
        for (Iterator iter = columnInfos.keySet().iterator(); iter.hasNext();) {
          attributeName = (String) iter.next();
          trimmedHeaderText = trimHeaderText((String) columnInfos.get(attributeName));
          columnInfos.put(attributeName, trimmedHeaderText);
       * Trims one single header text. Omit empty strings. Convert sub-strings to lower case.
       * Convert first char of sub-strings to upper case.
       * Example: "Product Price in EURO" ->"ProductPriceInEuro"
      private String trimHeaderText(String headerText) {
        StringBuffer newHeaderText = new StringBuffer();
        String token;
        StringTokenizer tokenizer = new StringTokenizer(headerText.trim());
        while (tokenizer.hasMoreTokens()) {
          token = tokenizer.nextToken();
          newHeaderText.append(token.substring(0, 1).toUpperCase());
          newHeaderText.append(token.substring(1).toLowerCase());
        return newHeaderText.toString();
      // private member variable for storing instance of an opened popup window.  
      private IWDWindow excelLinkWindow;
    public void onActionExportToExcel(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
        //@@begin onActionExportToExcel(ServerEvent)
         wdThis.wdGetExcelExportCompInterface().exportToExcel2003(
                wdContext.nodeAddress(),
                getProductColumnInfos());     
                //wdContext.nodeCustomer().nodeAddress()
        //@@end
       * The following code section can be used for any Java code that is
       * not to be visible to other controllers/views or that contains constructs
       * currently not supported directly by Web Dynpro (such as inner classes or
       * member variables etc.). </p>
       * Note: The content of this section is in no way managed/controlled
       * by the Web Dynpro Designtime or the Web Dynpro Runtime.
      //@@begin others
          columnInfosMap.put(IPrivateTableCompBasketView.IProductsElement.QUANTITY, "Quantity");
          columnInfosMap.put(IPrivateTableCompBasketView.IProductsElement.ARTICLE, "Article");
          columnInfosMap.put(IPrivateTableCompBasketView.IProductsElement.COLOR, "Color");
          columnInfosMap.put(IPrivateTableCompBasketView.IProductsElement.PRICE, "Price in EURO");
          columnInfosMap.put(
          IPrivateTableCompBasketView.IProductsElement.TOTAL__PER__ARTICLE,
           "Total Per Article In Euro");
          return columnInfosMap;
    if i can modify the code so that it read from behind and when it reached the "/" it stop and insert the string for the header

    Check this
    https://forums.sdn.sap.com/click.jspa?searchID=870698&messageID=292922
    /people/alfred.barzewski/blog/2005/07/27/new-samples-and-tutorials-for-web-dynpro-programming
    Regards, Anilkumar

  • JTable not displaying column Heads

    The following JPanel was constructed using JBuilder 7 (a horrendous piece of software) and is in GridBagLayout. I'm attempting to display the contents of a table using JTable, and whilst it displays the rows it doesn't display the columnHeads! What am I doing wrong?
    import java.sql.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    import java.text.*;
    public class BeginTask extends JPanel implements ActionListener{
    private boolean dbupdated;
    private MainFrame main;
    private JLabel jLabel1 = new JLabel();
    private JLabel jLabel2 = new JLabel();
    private JTable jTable1 = new JTable();
    private JButton jButton1 = new JButton();
    private JButton jButton2 = new JButton();
    private GridBagLayout gridBagLayout1 = new GridBagLayout();
    private Connection connection;
    private String url = "jdbc:odbc:bapers";
    private String username = "";
    private String password = "";
    public BeginTask(MainFrame ma) throws SQLException{
    main = ma;
    logon();
    drawTable();
    try {
    jbInit();
    catch(Exception ex) {
    ex.printStackTrace();
    void jbInit() throws Exception {
    jLabel1.setFont(new java.awt.Font("Dialog", 1, 18));
    jLabel1.setText("Begin Task");
    this.setLayout(gridBagLayout1);
    jLabel2.setText("Select Task, and press OK.");
    jButton1.setText("OK");
    jButton2.setText("CANCEL");
    jButton1.addActionListener(this);
    jButton2.addActionListener(this);
    this.add(jButton1, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0
    ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(12, 117, 14, 0), 94, 8));
    this.add(jButton2, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0
    ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(19, 43, 7, 119), 62, 8));
    this.add(jTable1, new GridBagConstraints(0, 2, 2, 1, 1.0, 1.0
    ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(12, 25, 0, 22), 522, 281));
    this.add(jLabel2, new GridBagConstraints(0, 1, 2, 1, 0.0, 0.0
    ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 181, 0, 226), 13, 6));
    this.add(jLabel1, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0
    ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(29, 202, 0, 251), 19, 17));
    public void actionPerformed(ActionEvent e) {
    if (e.getSource() == jButton1) {
    if (dbupdated == true)
    JOptionPane.showMessageDialog(null, "The database has been updated to show that the user has begun the task selected.");
    else if (dbupdated == false)
    JOptionPane.showMessageDialog(null, "The database has not been updated.");
    else if (e.getSource() == jButton2) {
    BapProcMain bpm = new BapProcMain(main);
    main.redisplay(bpm);
    public void logon() {
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    connection = DriverManager.getConnection(url, username, password);
    catch (ClassNotFoundException cnfex) {
    System.err.println("Failed to load the JDBC/ODBC driver.");
    cnfex.printStackTrace();
    System.exit(1);
    catch (SQLException sqlex) {
    System.err.println("Unable to connect (SQL error)");
    sqlex.printStackTrace();
    public void logoff() {
    if (connection == null) return;
    try { connection.close(); }
    catch (SQLException sqlex) {
    System.err.println("Unable to disconnect (SQL error)");
    public void drawTable() {
    Statement stmt;
    ResultSet rset;
    try {
    String query = "SELECT * FROM SpecificTask";
    stmt = connection.createStatement();
    rset = stmt.executeQuery(query);
    displayResultSet(rset);
    stmt.close();
    catch (SQLException sqlex) {
    sqlex.printStackTrace();
    private void displayResultSet(ResultSet rs) throws SQLException {
    // position to first record
    boolean moreRecords = rs.next();
    // if there are no records, display a message
    if (! moreRecords){
    JOptionPane.showMessageDialog (this, "No Specific Tasks to begin.");
    return;
    Vector columnHeads = new Vector();
    Vector rows = new Vector();
    try {
    // get column heads
    ResultSetMetaData rsmd = rs.getMetaData();
    for (int i = 1; i <= rsmd.getColumnCount(); ++i)
    columnHeads.addElement (rsmd.getColumnName(i));
    //get row data
    // System.out.println("Got this far. Check getNextRow(...)");
    do { rows.addElement(getNextRow(rs, rsmd)); }
    while (rs.next());
    // display table with ResultSet contents
    jTable1 = new JTable (rows, columnHeads);
    JScrollPane scroller = new JScrollPane(jTable1);
    // validate();
    catch (SQLException sqlex) {
    sqlex.printStackTrace();
    private Vector getNextRow (ResultSet rs, ResultSetMetaData rsmd) throws SQLException {
    Vector currentRow = new Vector();
    for (int i = 1; i <= rsmd.getColumnCount(); ++ i)
    switch (rsmd.getColumnType(i)) {
    case Types.VARCHAR:
    currentRow.addElement(rs.getString(i));
    break;
    case Types.INTEGER:
    currentRow.addElement(new Long (rs.getLong(i) ) );
    break;
    default: System.out.println ("Type was: " +
    rsmd.getColumnTypeName(i));
    return currentRow;
    }

    The table header is shown automatically when you add the table to a scrollpane and then display the scrollpane in a panel. You use the following code to build the table/scrollpane:
    // display table with ResultSet contents
    jTable1 = new JTable (rows, columnHeads);
    JScrollPane scroller = new JScrollPane(jTable1);
    but, you add the table to your panel NOT the scrollpane:
    this.add(jTable1, new GridBagConstraints(0, 2, 2, 1, 1.0, 1.0
    ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(12, 25, 0, 22), 522, 281));
    You should be adding the scrollpane to you panel.

  • Wrap report column header when using heading type : Column Names

    The headers for my report is actual data from the database. In order to get it to work I'm using aliases on my columns that correspond to the header name that I want. However, I have been unable to get the headers to wrap. I have tried using <br> and chr(10) but it seems to be stripping them out since it's a column alias. Any ideas? Region source is listed below...r1.fc_desc is the column header that I need to have wrapped.
    declare
    v_sql varchar2(4000);
    v_sql2 varchar2(4000);
    cursor c1 is select distinct fc_code, fc_desc from
    [email protected] where FG_ID=v('G_FINANCIAL_GROUP') order by fc_desc;
    begin
    for r1 in c1 loop
    if v_sql is null then
    v_sql:='select to_char(trans_week_end_thur,''mm/dd/yyyy'') as "Week Ending",sum(decode(fc_code,'''||r1.fc_code||''',payments,0)) as "'||r1.fc_desc||'"';
    v_sql2:='select ''Average:'' as "WeekEnding", avg(sum(decode(fc_code,'''||r1.fc_code||''',payments,0))) as "'||r1.fc_desc||'"';
    else v_sql:=v_sql||' ,sum(decode(fc_code,'''||r1.fc_code||''',payments,0)) as "'||r1.fc_desc||'"';
    v_sql2:=v_sql2||' ,avg(sum(decode(fc_code,'''||r1.fc_code||''',payments,0))) as "'||r1.fc_desc||'"';
    end if;
    end loop;
    if v_sql is null then
    v_sql := 'select ''No records found for weekly analysis by insurance class for this financial group '' as " " from dual;';
    else
    v_sql:= v_sql||' from [email protected] where fg_id=:G_FINANCIAL_GROUP group by trans_week_end_thur';
    v_sql2:=v_sql2||' from [email protected] where fg_id=:G_FINANCIAL_GROUP group by trans_week_end_thur;';
    v_sql:=v_sql||' union '||v_sql2;
    end if;
    return v_sql;
    end;

    I've resorted to creating a separate function to return a colon-separated list of column names, in which you can include a br tag or whatever, until I get a chance to research this more thoroughly.
    I thought it would just be a case of asking APEX not to strip the HTML, but it's clearly not as simple as that.
    Regards,
    John.

  • OBIEE 11g:  Use presentation variable in Column Heading

    Hi everyone,
    I was playing around with sample app dashboards and I saw a dashboard prompt that they converted into a column selector. I liked it and reproduced it in my own sandbox.
    I like the results, however, I would also like to change the column heading to clearly reflect which measure was selected. It's pretty clear when you are looking in the dashboard, but once you export the data, it can be confusing which measure was selected.
    That is why I would like to use a presentation variable in the column heading section. I tried to do this but it interpreted it as a literal instead of evaluating the statement.
    Is there anyway to get a variable in the column heading?
    Thanks!
    -Joe

    Hi,
    Have a look at the following links:
    http://oraclebizint.wordpress.com/2008/01/25/oracle-bi-ee-101332-dynamic-column-headers-using-presentation-variables-sets-and-conditional-formatting/
    show the presentation variable on table column header
    Define presentation variable in column header
    hope it helps.
    Regards,
    Kalyan Chukkapalli
    http://123obi.com

  • How to avoid WRAP of EXCEL Column HEADER Fields

    We have 3 tablix in the rdl file with 11 inch * 8.5 inch (to print in A4)
    Tablix 1 - HTML viewer
    Tablix 2 - EXCEL
    Tablix 3 - PDF 
    The size of the rdl is fixed , if size altered then printing becomes an issue.
    So we have to keep the rdl size fix
    but at the same time the WRAP of column header of the EXCEL need to be avoided ,
    because if the size of the column header is not reduced then we cannot be able to accomodate in the defined page size
    Eaxmple of SOme Header Field Name 
    1.OccupationCode 
    2.ChargeJobPhase which are quiet large fields, so it need to be wrapped(to reduce the length of the column to accomodate ) to fit in the page.
    So as an Alternative option  I use the COncept of Subreport and called it by adding row outside group otherwise the
    Report Server treats subreport as new report for each instance of the parent report.
    The challenge we faced is when export to EXCEL some of the columns is getting merged , I believe the size of the child report (sub report) is having the length
    greater than the parent report (Called Report )  and the size has to be large otherwise the COLUMN HEADER need to reduced which makes it Wrapped 
    So  is there any alternative without changing the parent report size and without WRAPPING the HEADER text of CHild report the MERGING of cell can be avoided.
    Since MERGING is happening which is not allowing us to PUT  FILTER in EXCEL but we need to have FILTER applicable since the END user use it to sort, find the records.

    Hi SubhadipRoy,
    In Reporting Services, whether to wrap text or not is depended on the CanGrow property. If we set the CanGrow property of tablix header row to true, then the header row of tablix will be expanded. If we set the CanGrow property of tablix header row
    to false, the header row will be shrunk as the designed size.
    So if we want to avoid wrap text, we can try to set the CanGrow property of tablix header row to false in Reporting Services level. Alternatively, we can click the Wrap Text button to enable the expended extra-long text property in Excel level.
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

Maybe you are looking for