Grandfather I just need the sample code from you people which is really beyond my programming abilities.Please look into the requirement. I have to create an application that converts the Oracle RPT code into usable, executable perl code. The translator script will convert a .rpt file in such a way, to where once created I can run it on command prompt by passing filename like script.pl file180 Oracle RPT code means the file which actually generates any report using Oracle Reports tool so the main reason behind to create this application is to generate the Old Oracle reports.. Here the sample report file(.rpt file) which contains Oracle sql or Pl/sql statements in Oracle report language
.rem ***************************************************************** +***** .rem .rem ------------------------ booking_table variables ---------------- +----- .rem .declare booking_no a13 ###### Mea +ns CHAR(13) .declare line_code a10 .declare line_booking a12 .declare book_date a11 .declare taken_by a10 .declare ud a10 .declare ship_name a40 .declare ship_addr1 a40 .declare ship_addr2 a40 .declare ship_addr3 a40 .declare ship_cont a20 .declare ship_phone a20 .declare ship_ref a20 .declare fwdr_name a40 .declare po_no a20 .declare vessel_name a25 .declare voyage a10 .declare etd_origin a11 .declare sail_date a11 .declare origin_name a20 .declare weight 9999999.99 ####### Num +ber type with specified width .declare cube 9999999.999 .set page_no 1 .set first "N" .set no_more_clauses "N" .set line_count 0 .set del_count 0 .set pick_count 0 .set sys_date $$DATE$$ .rem ----------------------------------------------------------------- +----- #dt 1 1 80 # #dt 2 1 6 9 48 50 61 63 76 80 80 # #dt 3 1 13 15 34 36 40 42 56 58 62 64 74 75 79 # #dt 4 1 13 15 49 53 64 66 80 # #dt 5 1 15 18 52 # #dt 6 1 22 23 77 # #dt 7 1 15 17 77 # .define lock_tables lock table booking_table, booking_hazmat, custdata2, edit_tabl +e, booking_rates, printer_table in share update mode .. .define get_input select passkey, '//FAX(fax=' || passkey1, passkey2, passkey3, passkey4, printer_name into input_booking_seq, fax_header, file_no, input_print_rates, myNoteId, printer_name from edit_table where edit_table.tag = 'BOOKING' and edit_table.key = 'PRINT' and edit_table.user_id = user .. .define get_user_info select user_location,user_name, user_company, &fax_header || +';style=' || letterhead, fax_printer, nvl(fax_yn,'N') into user_location, user_name, user_company, fax_header, fa +x_printer, fax_yn from security_header where user_id = lower(substr(user,5,10)) .. .define get_fax_printer select &fax_header || ';print = Confirm;printer = ' || &fax_prin +ter || ')' into fax_header from dual .. .define get_user_office select name, address1, address2, address3 || ' ' || state || ' ' || zip_cnty, 'PHONE: ' || telephone, 'FAX: ' || +fax, fax || '.' into name, address1, address2, address3, phone, fax, fax1 from custdata2 where custdata2.code = &user_location ##### H +ere user_location is passed by argument .. .define get_lots select booking_seq into input_booking_seq from itemdata where reference = &file_no .. .define printMsg .execute formatMsg .if "&myNote = 'N/A' " then skipMyNote .print myNote .&skipMyNote .if "&myNoteExt = 'N/A' " then skipMyNoteExt .print myNoteExt .&skipMyNoteExt .add line_count line_count 9 .. .rem ----------------------------------------------------------------- +-- .rem main logic .rem ----------------------------------------------------------------- +-- .rem .execute lock_tables .execute get_input .execute printer_controls .execute get_top .execute get_user_info .execute get_user_office .rem --------- this section is added to print bookings by file ------- .ifnull file_no skip_by_file .report get_lots file_loop .goto skip_to_end .&skip_by_file .rem ----------------------------------------------------------------- +- .if "&fcl_lcl = 'F' " then ck_fcl .execute adjust_letterhead_lcl .goto skip_over_fcl .&ck_fcl .execute adjust_letterhead_fcl .&skip_over_fcl .if "&fax_yn = 'N' " then skip_confirm .execute get_fax_printer .goto skip_to_booking .&skip_confirm .execute set_no_confirm .&skip_to_booking .print_info .ifnull hz_code skip_to_end .if "&hz_code = '000' or &hz_code = 'N' " then skip_to_end .rem .report get_hazmat_data print_hz_page .&skip_to_end .execute update_inet_upd .execute delete_input .commit .stop
I have commented wherever its possible and here is some report language syntax for understanding
#cen - to define a centred title #dt - table definition rpt - To produce the report .declare - variable declaration with o/p format .define - macro to specify SQL commands to be used to retrieve data == .define statement is terminated by two full stops at the beginning +of a line. == .report - executes a select macro .execute - executes a select macro .if - tests values and allows conditional execution .goto - control execution #t 2 - starts using table 2 format #te - reverts to the previous table format #np - start a new page #n - start a new line #p - start a new paragraph #nc next column # end literal output and start formatting again. .rem - comments & - execute or call macros
For this as u suggested I want to use Parse::RecDescent module for creating a generic parser which will parse the file and generate the report according to the flow...For final report I would be using Text::Report module for formatted output which will look like this
COMPANY ADDRESS _________________ ADDRESS 1 ________________ ADDRESS 2 _____________________ PHONE: ___________________ FAX: B O O K I N G C O N F I R M A T I O N *** BOOKING NO: CHIJOH1592318 *** TO: ADDRESS ONE DATE : 19-JUN-2007 STREET OUR CONTACT : MACH ROAD PHONE: YOUR REFERENCE : P.O. NUMBER : ATTN: DENZIL F. WE THANK YOU FOR YOUR BOOKING, WHICH WE HEREBY CONFIRM AS FOLLOWS: ______________________________________________________________________ +_________ BOX: NEW TOOL FROM: NEWYORK DATE: 26-JUN-2 +007 NUMBERS : 351 LOAD: LA DATE: 05-JUL-2 +007(ETS) DISCH PLACE : PHILIPPINES DEST: PHILIPPINES DATE: 06-AUG-2 +007(ETA) ______________________________________________________________________ +_________ ___________ ___________ ______ ____ NUMBER/TYPE DESCRIPTION WEIGHT CUBE 4 COMPUTER SUPPLIES 1959 LBS 200.00 +0 CFT ______________________________________________________________________ +__________
So please help me atleast in writing a grammer to create a parser using Parse::RecDescent module.... I just want some sample code to write the grammar...... denzil_cactus

In reply to Re^6: Converting Oracle report language code into perl by denzil_cactus
in thread Converting Oracle report language code into perl by denzil_cactus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.