Need to output data to TXT with static header and footer but multiple rows

Using APEX 4.0 and 11g - The only way I could find to get data out of APEX in TXT format was to use htp.prn. I load a cursor with the data and this works fine, the problem is that I need to have the file start with a string (*:P9_HEADER_STRING*) but it can only appear once in the output.
Is there a way to add the *:P9_HEADER_STRING* to the output in a single TXT file? or is there another way I should be doing this?
This is what I have now: The *:P9_HEADER_STRING* is in the loop which I know it can't be, but I can't figure out how to concatenate this string to the output from the loop. The rank() is being used because I can only send the selected number of records, ranked from highest. (I will have to do the same thing with a footer too, but that variable isn't in here yet)
begin
-- Set the MIME type
owa_util.mime_header( 'application/octet', FALSE );
-- Set the name of the file
htp.p('Content-Disposition: attachment; filename="cra_outgoing.txt"');
-- Close the HTTP Header
owa_util.http_header_close;
-- Loop through all rows in CLIENT_TABLE
for x in (select * from (select XREF_NBR
, TOT_AMT
, '' SPOUSE_INFO
, '' PHONES
, NAME
, SURNAME
, '' MARITAL_STATUS
, '' EMPLOYER_INFO
, GENDER
, '' CO_ADDRESS
, '' PREV_ADDRESS
, POSTAL_CODE
, ADDRESS1
, '' FILLER
, rank() over (order by tot_amt desc, rownum asc) rn
from client_table c where c.File_Seq_Nbr is NULL and c.xref_nbr in (select xref_nbr from ticket_table where to_char(ticket_issue_date, 'YYYY-MM-DD') between :P7_START_DATE and :P7_END_DATE))
where rn <= :P7_NUMBER_RECORDS)
loop
-- Print out a portion of a row,
-- separated by commas and ended by a CR
htp.prn( *:P9_HEADER_STRING* || '03' || lpad(X.XREF_NBR, 12) || lpad(x.TOT_FINE_AMT, 11, '0') || '0201'|| lpad(x.NAME, 30) || lpad(x.SPOUSE_INFO, 60) || '00000000000000000000'|| x.DATE_OF_BIRTH || '0000000000000000' || x.GENDER || x.MARITAL_STATUS || lpad(x.EMPLOYER_INFO, 60) || lpad(x.CO_ADDRESS, 102) || lpad(x.ADDRESS1, 30) || lpad(x.POSTAL_CODE, 9) || lpad(x.FILLER, 21) );
end loop;
-- Send an error code so that the
-- rest of the HTML does not render
htmldb_application.g_unrecoverable_error := true;
end;

Yes, I've already done that, hence this part of the code I pasted above:
begin
-- Set the MIME type
owa_util.mime_header( 'application/octet', FALSE );
-- Set the name of the file
htp.p('Content-Disposition: attachment; filename="cra_outgoing.txt"');
-- Close the HTTP Header
owa_util.http_header_close;
-- Loop through all rows in CLIENT_TABLE
-- Send an error code so that the
-- rest of the HTML does not render
htmldb_application.g_unrecoverable_error := true;
end;
I've solved my problem by loading the cursor data into a variable (inside the loop) and concatenating the header info to it (outside the loop). This works when there are only a few records but as soon as I get to 32767 bytes it's throwing an error because of the size. So that's a different issue altogether.

Similar Messages

  • How to print jTable with custom header and footer....

    Hello all,
    I'm trying to print a jTable with custom header and footer.But
    jTable1.print(PrintMode,headerFormat,footerFormat,showPrintDialog,attr,interactive)
    does not allow multi line header and footer. I read in a chat that we can make custom header and footer and wrap the printable with that of the jTable. How can we do that..
    Here's the instruction on the chat...
    Shannon Hickey: While the default Header and Footer support in the JTable printing won't do exactly what you're looking for, there is a straight-forward approach. You can turn off the default header/footer and then wrap JTable's printable inside another Printable. This wrapper printable would then render your custom data, and then adjust the size given to the wrapped printable
    But how can i wrap the jTable's Printable with the custom header and footer.
    Thanks in advance,

    I also once hoped for an easy way to modify a table's header and footer, but found no way.
    Yet it is possible.

  • Print jTable with a header and footer panel

    Hi Folks,
    I'm currently at a sticking point in a project I'm playing around with. I have a data set of around 300 objects that i'd like printed out in a table. Now, I've gotten the display part down without a hitch but printing the data as well as a header panel and footer panel has been eluding me. I'd basically like something like this...
    Name: some name Order date: some date
    Address: some address Shipped To: some address
    somewhere Some city, some state, etc
    in some city
    Date | Title | Etc | Etc | Etc
    date1 title1 5 $3.00 $15.00
    date1 title1 5 $3.00 $15.00
    date2 title1 5 $3.00 $15.00
    date2 title1 5 $3.00 $15.00
    Total purchases: $60.00
    Total Items: 20
    # of Orders: 2
    Am I barking up the wrong tree by making the first and third sections panels and the second section a table? If not, how the heck do I accomplish this? Most of the time the table has been multiple pages as well - I only need section one on the first page and section three on the last page, but whatever is easiest really.
    My current approach has been basically to make a custom printables, print the first section, figure out how high it was, print the second section and hope for the best, but the third would never show up because it'd never go over two pages.
    Any help would be very much appreciated.
    Thanks,
    Stephen
    Edited by: stephenliberty on May 7, 2009 9:11 AM - more specific subject

    I suppose as a quick update, this is as far as I've gotten and will likely get-
    public class PrintForm extends JFrame implements Printable{
        JComponent headerPanelForPrint;
        JComponent footerPanelForPrint;
        JTable dataTableForPrint;
        public void setPieces(JComponent header, JTable table, JComponent footer){
            this.headerPanelForPrint = header;
            this.footerPanelForPrint = footer;
            this.dataTableForPrint = table;
        public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException {
            graphics.translate((int)pageFormat.getImageableX(), (int)pageFormat.getImageableY());
            TableFormat tableFormat;
            if(pageIndex>0){
                tableFormat = new TableFormat(0, footerPanelForPrint.getHeight());
            } else {
                headerPanelForPrint.printAll(graphics);
                tableFormat = new TableFormat(headerPanelForPrint.getHeight(), footerPanelForPrint.getHeight());
            MessageFormat footer = new MessageFormat("Page - {0}");
            Printable table = dataTableForPrint.getPrintable(PrintMode.FIT_WIDTH, null, footer);
            int printme = table.print(graphics, tableFormat, pageIndex);
            if(printme == table.NO_SUCH_PAGE){ return table.NO_SUCH_PAGE; }
            return Printable.PAGE_EXISTS;
    class TableFormat extends PageFormat {
        double footerHeight;
        double headerHeight;
        public TableFormat(double headerHeight, double footerHeight){
            this.headerHeight = headerHeight;
            this.footerHeight = footerHeight;
        @Override
        public double getImageableHeight() {
            return super.getImageableHeight() - ( this.footerHeight + this.headerHeight );
        @Override
        public double getHeight() {
            return super.getImageableHeight() - ( this.footerHeight + this.headerHeight);
        @Override
        public double getImageableX() {
            return 0;
        @Override
        public double getImageableY() {
            return this.headerHeight;
    }It works very well with just a header and the table, but I still have not been able to get a footer to show up in the appropriate spot or (preferably) on the last page.
    Edited by: stephenliberty on May 8, 2009 12:29 PM

  • Data load problem with Sales Header and Item

    Hi all,
    The delta loads have failed, so I want to reload the delta again.  I deleted the failed requests in data targets and then trying to reload the data.  I am getting a message saying
    Last delta update is not yet completed
    Therefore, no new delta update is possible.You can start the request again if the last delta request is red or green in the monitor (QM activity)
    Is it in RSA7, that I have to make the delta red?  Please let me know where I have to do this.  The data is going to an ODS object.
    thanks
    Sabrina.

    Hi Sabrina,
    Hope you have sorted it out by now, as there are other responses as well. Assuming that you now know the cause of failure.
    For the below message "If you set a 'red' delta upload to green,with the next request, BW sends a delta request to the source system and this delivers the next delta data.
    The data from the 'red' delta load is then no longer available (even with a repeat). This can lead to loss of data.Do you want to execute a QM Action?" -- Say OK and and set the QM status to red (status not ok) and when prompted for activation of M records, say "no" (as indicated in my previous post).
    However, to be able to load this request from PSA you need to have this request in PSA (depending on the processing options), so goto RSA1> Modeling> PSA--> find your request under the relevant application component, and right click -->start the update immediately.
    Hope it helps,
    Sree

  • How to display 2 layouts with 2 different Header and Footer in a template.

    Hi,
    I am using XML Publisher 5.5. I have created one template which is having two layouts. I am using <?Start: Body?> and <?end body?> for displaying Headers and footers. Now my problem is, I need to display first layout with it's associated Header and footer and then second layout with other header and footer. But the two layouts should come in single template file. How is it possible?. Is there any work around? Please help me as this is the urgent requirement to my client.
    Thanks.
    Siva.

    No problem. Select Insert -> Break from the menu bar. Then select a "Section Break" - Next page.
    Header 1
    <?start:body?>
    Page 1
    <?end: body?>
    Footer 1
    ==================Section Break (Next Page)=================
    Header 2
    <?start:body?>
    Page 2
    <?end: body?>
    Footer 2
    Worked like a charm.
    Klaus

  • Need to add Header  and footer in an alv grid display output.

    How can I add header and footer in an alv grid dispay output.
    For the grid display, I am using the function module "REUSE_ALV_GRID_DISPLAY".

    HI,
    call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program      = gd_repid
                i_callback_top_of_page   = 'TOP-OF-PAGE'
                i_callback_html_end_of_list = 'END_OF_LIST_HTML'
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
                i_save                  = 'X'
           tables
                t_outtab                = it_ekko
           exceptions
                program_error           = 1
                others                  = 2.
    FORM end_of_list_html USING end TYPE REF TO cl_dd_document.
      DATA: ls_text TYPE sdydo_text_element,
            l_grid     TYPE REF TO cl_gui_alv_grid,
            f(14) TYPE c VALUE 'SET_ROW_HEIGHT'.
      ls_text = 'Footer title'.
    adds and icon (red triangle)
      CALL METHOD end->add_icon
        EXPORTING
          sap_icon = 'IL'.
    adds test (via variable)
      CALL METHOD end->add_text
        EXPORTING
          text         = ls_text
          sap_emphasis = 'strong'.
    adds new line (start new line)
      CALL METHOD end->new_line.
    display text(bold)
      CALL METHOD end->add_text
        EXPORTING
          text         = 'Bold text'
          sap_emphasis = 'strong'.
    adds new line (start new line)
      CALL METHOD end->new_line.
    display text(normal)
      CALL METHOD end->add_text
        EXPORTING
          text         = 'Nor'.
    adds new line (start new line)
      CALL METHOD end->new_line.
    display text(bold)
      CALL METHOD end->add_text
        EXPORTING
          text         = 'Yellow '
          sap_emphasis = 'str'.
    adds and icon (yellow triangle)
      CALL METHOD end->add_icon
        EXPORTING
          sap_icon = 'IC''.
    display text(normal)
      CALL METHOD end->add_text
        EXPORTING
          text         = 'Mor'.
    *set height of this section
      CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
        IMPORTING
          e_grid = l_grid.
      CALL METHOD l_grid->parent->parent->(f)
        EXPORTING
          id     = 3
          height = 14.
    ENDFORM. "end_of_list_html.
    This will solve  it. Post if you need more help in this.
    Regards,
    Madhu.

  • TS2570 Mac will not start up after software up date, just screen with Apple logo and spinning icon?

    Mac will not start up after software up date, just screen with Apple logo and spinning icon? I have tried safe start up, unplugged all other cables, no luck?

    How to Perform an Archive and Install
    An Archive and Install will NOT erase your hard drive, but you must have sufficient free space for a second OS X installation which could be from 3-9 GBs depending upon the version of OS X and selected installation options. The free space requirement is over and above normal free space requirements which should be at least 6-10 GBs. Read all the linked references carefully before proceeding.
    1. Be sure to use Disk Utility first to repair the disk before performing the Archive and Install.
    Repairing the Hard Drive and Permissions
    Boot from your OS X Installer disc. After the installer loads select your language and click on the Continue button. When the menu bar appears select Disk Utility from the Installer menu (Utilities menu for Tiger, Leopard or Snow Leopard.) After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list. In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive. If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the installer. Now restart normally.
    If DU reports errors it cannot fix, then you will need Disk Warrior and/or Tech Tool Pro to repair the drive. If you don't have either of them or if neither of them can fix the drive, then you will need to reformat the drive and reinstall OS X.
    2. Do not proceed with an Archive and Install if DU reports errors it cannot fix. In that case use Disk Warrior and/or TechTool Pro to repair the hard drive. If neither can repair the drive, then you will have to erase the drive and reinstall from scratch.
    3. Boot from your OS X Installer disc. After the installer loads select your language and click on the Continue button. When you reach the screen to select a destination drive click once on the destination drive then click on the Option button. Select the Archive and Install option. You have an option to preserve users and network preferences. Only select this option if you are sure you have no corrupted files in your user accounts. Otherwise leave this option unchecked. Click on the OK button and continue with the OS X Installation.
    4. Upon completion of the Archive and Install you will have a Previous System Folder in the root directory. You should retain the PSF until you are sure you do not need to manually transfer any items from the PSF to your newly installed system.
    5. After moving any items you want to keep from the PSF you should delete it. You can back it up if you prefer, but you must delete it from the hard drive.
    6. You can now download a Combo Updater directly from Apple's download site to update your new system to the desired version as well as install any security or other updates. You can also do this using Software Update.

  • Download internal table data into excel sheet with column heading and data

    Hi,
      I am having one internal table with column headings and other table with data.
    i want to download the data with these tables into an excel sheet.
    It should ask the user for file name to save it on their own name. They should give the file name in runtime and it should be downloaded into an excel sheet.
    Can anyone tell what is the right function module for downloading these two internal table data with column heading and data.
    what we have to do for storing the file name in runtime.
    Can anyone help me on this.
    Thanks,
    Rose.

    Hi Camila,
        Try this
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        FILENAME                        = PATH2
       FILETYPE                        = 'XLS'
      TABLES
        DATA_TAB                        = IT_DATA
       FIELDNAMES                      = IT_HEADINGS
    EXCEPTIONS
       FILE_WRITE_ERROR                = 1
       NO_BATCH                        = 2
       GUI_REFUSE_FILETRANSFER         = 3
       INVALID_TYPE                    = 4
       NO_AUTHORITY                    = 5
       UNKNOWN_ERROR                   = 6
       HEADER_NOT_ALLOWED              = 7
       SEPARATOR_NOT_ALLOWED           = 8
       FILESIZE_NOT_ALLOWED            = 9
       HEADER_TOO_LONG                 = 10
       DP_ERROR_CREATE                 = 11
       DP_ERROR_SEND                   = 12
       DP_ERROR_WRITE                  = 13
       UNKNOWN_DP_ERROR                = 14
       ACCESS_DENIED                   = 15
       DP_OUT_OF_MEMORY                = 16
       DISK_FULL                       = 17
       DP_TIMEOUT                      = 18
       FILE_NOT_FOUND                  = 19
       DATAPROVIDER_EXCEPTION          = 20
       CONTROL_FLUSH_ERROR             = 21
       OTHERS                          = 22

  • What is needed to use iPhone 5 musicdock with iPhone 4S and getting iPhone 4S battery charged. Any adapter yet?

    What is needed to use iPhone 5 musicdock with iPhone 4S and getting iPhone 4S battery charged. Any adapter yet?

    Not by Apple but see this
    SANDBERG 440-45 Adaptor 30 Pin to Lightning Connector
    Try Amazon in your Country

  • I need to burn a DVD with a menu and everything but I don't have iDVD. Help please? I bought my iMac in March 2012.

    I need to burn a DVD with a menu and everything, but I don't have iDVD. I bought my iMac from an Apple store in March 2012. Help please?

    You may be able to find iDVD as part of the iLife 11 Retail Package. It is no longer sold by Apple, but you may find it on eBay or Amazon.
    Other options include Toast from Roxio.
    See here for more discussion of the options.
    https://discussions.apple.com/docs/DOC-3711

  • My Outlook/iCloud calendar invites to others appear to work on my end and sync with my PC and mobile, but when other people "accept" the invite, it will not populate/add in to their calendar. How can i fix this without turning off iCloud?

    My Outlook/iCloud calendar invites to others appear to work on my end and sync with my PC and mobile, but when other people "accept" the invite, it will not populate/add in to their calendar. How can I fix this without turning off iCloud?
    I am at a new office that uses Outlook (not Outlook Exchange) which does not sync with my mobile... I just got iCloud set up on my PC to sync my contacts, calendar, reminders, etc... The sync worked (not without flaws, but the other issues seem solvable... I think), so that i can now see all my appointments on both my phone and on my PC. The problem I am having is that iCloud moved all of my calendar items from Outlook into iCloud calendar and now when I send out meeting/calendar invites the recipients may accept them, but the meeting does not get added to their calendar. This is a huge problem and may mean that i need to turn off iCloud.
    Does anyone know how to fix this?
    Thanks!

    I am replying to my own post here as I seem to have fixed the problem.
    I do have some calendars that are shared. Some of those are shared with users who have time zone support turned on. So i activated time zone support on my iphone, then deleted my icloud subscription. I then signed in to icloud again and voila... problem solved.
    It is a weird one as the other calendar views were always fine and when you opened an event that appeared in the wrong day (on list view), the correct date of the event was shown in the information...
    one more bug in a complicated system I guess

  • Regarding Header And Footer in Data type Creation

    Hi All,
    Can Any One Please Send me One Screen Shot Developed with Header And Footer in the Data type Creation
    I want to Know How to Create And where to create that in DT Creation
    And Why Do we need Both of these in DT Creation
    Regards
    Vamsi

    Hi,
    Will u Please send One Screen With These Details, So that I Can Uderstand More
    ID : [email protected]
    Please send
    Regards
    Vamsi

  • Bypass Header and Footer in Excel output

    I have a Requirement like this
    I need to have the report output in the below three formats
    PDF,EXCEL,HTML
    But when we see the ouput in EXcel it should not have the Footer and Header Scetion ,
    remaining two output formats (PDF,HTML) must have the Footer and Header Section.
    Any one having any idea about this issue.
    Thanks in Advance.
    Have a Nice day.

    Hi @BIPuser.
    I said the same thing to them but they said no that is final option but we need only single template for all the outputs alos it should handle the bypassing of header and footer for excel output.
    Thanks for your reply, If i come across anything i will let u know.

  • Problem in Consistent Header and Footer with Sub Templates in BI publisher

    Hi All,
    I have recently started working with OBI and used Sub templates for getting Consistent Header and Footer in all of our reports. I did this in the following way
    1. Created one template called HeaderFooter.rtf with Header and footer templates.
    2. placed the file in web server and called in the main Template with
    <?import: http://myserver.com:9704/xmlpserver/HeaderFooter.rtf?> I mean as static URL and it is working fine.
    3. Now as a part of generalizing the server i have added HTTPSERVER property in xdo.cfg file which is located in
    %BI_REPOSITORY%/Admin/Configuration.
    4. I have checked this property by placing <?xdoxslt:getXDOProperties($_XDOCTX)? in my rtf file and HTTPSERVER property is showing same as that of static.
    5. Now when i place <?import:http://{$HTTPSERVER}/HeaderFooter.rtf?> in my rtf it is ending with an error.
    so can anyone please help me out in this regard?

    Hi User XY,
    you might want to ask this in the [url http://forums.oracle.com/forums/forum.jspa?forumID=245]BI Publisher Forum
    brgds,
    Peter
    Blog: http://www.oracle-and-apex.com
    ApexLib: http://apexlib.oracleapex.info
    BuilderPlugin: http://builderplugin.oracleapex.info
    Work: http://www.click-click.at

  • Header and footer must be static and main content must be dynamic

    Hello, i need to design a webpage such that
    1. Header and footer has some menus and when i click on menu, only main content should change.
    For example, if i have a gif image in header, it should not be reloaded everytime when i click on menu or submenu.
    I hope you understand my problem. I have header and footer and only content inside should change but not header and footer.
    header and footer must not reload everytime when i click any url or menu item.

    One of the way is using <FRAME> or <IFRAME> elements. Another modern way (probably recommended) is based on partial page updates with
    UpdatePanel control:
    https://msdn.microsoft.com/en-us/library/bb399001(v=vs.140).aspx. The
    http://www.asp.net/ site is a good place to find details.

Maybe you are looking for

  • How to calculate the variance in PO price history?

    hi i hav standard report ME1P, since i need to do some modifications in this program i copied to Y prgrm,,,' im getting all the values properly... but my prblm is im not getting how to calculate the variance? im not getting the logic behid it... can

  • Problem with network printer on Windows 7 machine

    I'm running Mavericks on a Mac Mini.  I have a Windows 7 machine with an attached Brother HL-5340D printer.  I'm using the Brother HL-5340D CUPS driver.  Whatever configuration I use, I cannot get my Mac to print from the Brother.  I have even set up

  • Add logic to Submit button in web form

    We have created a form from scratch in FormsCentral. It has a fair bit of logic associated with questions in the application form. Some of the logic leads to the end result that an applicant should not be able to submit the form. The issue is, that a

  • How to set the username in PeopleEditor programmatically

    Hi , How to set the user name in people picker entity programmatically. I have tried this: <sp:PeopleEditor ID="sppcustom" runat="server" AllowEmpty="false" MultiSelect="false" SelectionSet="User" /> In the webpart cs code: PeopleEditor sppcustom = n

  • External email users cannot use IMAPS/SMTPS

    We have an email server running but since Mountain Lion (ML) server we do not have the webmail for external users and they are now forced to use email clients on PCs etc., which would be acceptable, if it worked. This has created a weird problem... t