SQL HELP , URGENT PLEASE

Hi,
I want some help in writing a SQL Query .Its besically a hierarchical query. Let me lay down the table structure first to explain my requirements better.
PORP_TABLE(NODE_LEVEL int, WBS_ID int, WBS_NUMBER varchar(60), LFT int,RGT int)
SELECT NODE_LEVEL, WBS_ID, LFT,RGT FROM PROPOSAL_WBS PW WHERE PROPOSAL_REV_ID = 7000
(SAMPLE DATA)
NODE WBS
LEVEL WBS_ID NUMBER LFT RGT
0 7055 ROOT 1 24
1 7056 1 2 5
1 7088 2 6 9
2 7057 1.1 3 4
2 7089 2.1 7 8
2 7091 3.1 11 14
2 7103 3.2 15 16
2 7105 4.1 19 20
1 7090 3 10 17
3 7092 3.1.1 12 13
1 7104 4 18 23
2 7106 4.2 21 22
ALLOCATION_DETAIL( WBS_ID int, COST_ID int, PERIOD Date, AMOUNT Float)
sample data
WBS_ID , COST_ID , PERIOD , AMOUNT
7057 100 01-jan-2005 5000
7057 100 01-feb-2005 2000
7057 100 01-mar-2005 1000
7057 100 01-apr-2005 6000
7057 100 01-may-2005 3000
7057 100 01-jun-2005 45000
7106 100 01-mar-2005 8000
7106 100 01-apr-2005 7000
7106 100 01-may-2005 9000
Now the PORP_TABLE has got the parents and childs. Only the leaf nodes in the hierarchy has the values stored in the ALLOCATION_DETAIL table. Now here is the scenario
In the example 7055 is the root WBS . The Leaf WBS are the one with max extension in the wbs number ( in this case it is 1.1, 2.1, 3.1.1, 3.2, 4.1 and 4.2)
Now the Starting period for each leaf node in the ALLOCATION_TABLE could be differrent . What that means is WBS 1.1 could start in Jan -2003 and WBS 3.1 Could be Jul-2005 . So the ending perios are also differrent for differrent WBS . Some can span 2 years some can 5 years.
So how to write a query so it retrieves the value for all the Wbs starting from the MIN ( PERIOD ) upto the MAX(PERIOD), and it should roll up also. Now there is No connect by Prior or any analytic functions available for this . THIS NEEDS TO BE DONE ONLY THROUGH TRADITIONAL SQL STATEMENT . And NO DB FUNCTIONS CAN BE USED .
Now if the WBS is a parent node then it should have the sum of all its child nodes for the COST category.
SO THE RESULT SET SHOULD BRING LIKE THIS
WBS_NUMBER, PERIOD_NUMER, COST_CATEGORY , AMOUNT
ROOT
1
1.1
2
2.1
3
3.1
3.1.1
3.2
4
4.1
4.2
......

Hi,
<br>Read String Aggregation Techniques</br>
<br>HTH,</br>
<br>Nicolas.</br>

Similar Messages

  • Help Urgent please !!

    Hello, i've got an great problem:
    Ihave an frameset with 2 frames. these 2 frames should be loaded dynamicaly, that means i call the frameset
    frameset.html#NameOfTheRightFrame#Titleoftheframeset#browsertyp
    the extraction of the sendet data works without problems and under Internet Explorer i can call the right frame by document.FrameName.href. But under Netscape it doesn't work.
    Do anybody of you know how i could call an frame out of the frameste under netscape?????
    Thaknks
    J�rg

    Help Urgent please !!And the winner of this weeks Lest Perspicuous Subject Line - award goes to...
    "Help Urgent please !!"
    <applause/>
    While including all the magic words "help", "urgent", and "please", multiple exclamation marks and some mis-capitalization, and not describing the actual message at all, it's not perfect in style: "urgent" is not written in all caps and there are too few exclamation marks. But the fact that the body of the post itself is totally off-topic is an amendment to failing in these.
    To the actual question I'd answer: have you tried checking the javascript reference?

  • Sound trouble need help urgent please

    Could somebody tell me how i can fix my problem.
    problem: when my curve 8520 is in silence profile en i start typing in a phnoe number i hear nothing,
    but when my phone is in normal profile i hear i beep with every number of the phone number i enter.
    so i want to know how i can stop my bb from making this noise

    My friend it is a fillable form, can i email you the pdf that iam trying to fill out? then would you be able to tell me how to do it please mate?
    I have attached the form, i need to fill in those boxes so that everything is accuratly height + spacing is correct, and to do it fast, thats all im after.
    Date: Sun, 27 Jun 2010 18:31:58 -0600
    From: [email protected]
    To: [email protected]
    Subject: Need Help Urgent Please
    If is a fillable form, just tab to the next field. What we do not understand from you is IF it is a fillable form or not. If it is not, then the 3 options I gave can be used. Placing text is always a problem. You might find it useful to turn on the grid to help in placing your typewriter fields. However, if it is fillable you do not have to create any fields to type in, you just leave the tool as the hand tool and select the predefined fields with the cursor or the tab key and type accordingly. If the field is a checkbox, then you just use the space key to activate it.
    So, are we talking about a fillable form or something that has the appearance of a form, but not fields to fill in. This is what Bernd has been try to find out and you keep suggesting it is fillable as we read what you have said.
    >

  • I need help urgent please :(

    Hi i'm too much worried about my laptop because before 1 hours its working perfectly and while i working on my laptop suddenly laptop is off and now when i presss power on button its on for 4 seconds with a fast fan voice and no display on screen and then again off what i do can any one help me please thansk a lot advanced....
    Regards,
    Osman

    Please diagnose your PC using the detailed instructions in the link below.
    The "HP PC Hardware Diagnositcs" will test all the hardware components of your PC.
    Testing using HP PC Hardware Diagnostics (UEFI)

  • SQL QUERY, URGENT PLEASE HELP .....

    Hi,
    There is a table which stores the sales record, weekly basis.
    For example
    WEEK______ ITEMNO______SALES______QTY
    200201_____10001______10,000______50
    200202_____10001______18,000______55
    200230_____10001______55,000_____330
    Now the report should display the week nos and a Cumulative average.
    like
    ITEM NO - 10001
    WEEKNO____WK-AVG____13WK-AVG____26WK-AVG____52WK-AVG
    200201
    200202
    200203
    200230
    The WK-AVG is calculated for that perticular (weeks sales /weeks qty) but for 13WK-AVG,26-AVG and 52WK-AVG , The calculationis the (cumulative of last 13 week sales /cumulative of last 13 wk qty)
    for example at week 200230 the 13WK-AVG should be
    (cumulative sales from week 200218 to 200230 / cumulative qty from week 200218 to 200230 )
    the same hold good for 26WK-AVG AND 52WK-AVG. Please suggest me how to do it . This is very urgent . Please help me .
    Thanks
    Feroz

    Feroz,
    One way is to use subselects. E.g.,
    SELECT WK_AVG, 13WK_AVG, 26WK_AVG, 56WK_AVG FROM
    (SELECT (SALES/QTY) AS WK_AVG FROM TABLE WHERE ITEMNO=x AND WEEK = ...),
    (SELECT (SUM(SALES)/SUM(QTY)) AS 13WK_AVG WHERE ITEMNO=X AND WEEK > Y AND WEEK <= Z),
    hope this helps.
    regards,
    Stewart

  • SQL help - urgent

    Hello all,
    I have to write an SQL and do not know how to formulate it. I would appreciate if anyone can give me the SQL for the below question:
    I have 2 tables(Transaction and Programs)
    Transaction data:
    Trans_ID| Trans_Pgm| Trans_Short_Desc| Trans_Desc
    1234|     prog1|     Transaction 1| Transaction 1
    5678|     prog2|     Transaction 2| Transaction 2
    Programs data:
    Pgm_Name| Called_Pgm| Type
    prog1|     prog3|     X|
    prog2|     prog4|     X|
    prog3|     prog5|     L|
    prog5|     sprog1|     C|
    sprog1| bprog2| L|
    Need to get the data in below format:
    Trans_ID| Trans_Pgm| Level1| Level2| Level3| Level4|
    Trans_ID & Trans_Pgm need to come from Transaction table.
    Level1, Level2, Level3 & Level4 will come from Programs table and are explained below:
    Lets take for eg. prog1 from Transaction table. prog1 is called by prog3, prog3 is called by prog5, prog5 is called by sprog1 and sprog1 is called by bprog2. Hence the result of query needs to look like below:
    Trans_ID| Trans_Pgm| Level1| Level2| Level3| Level4
    1234|     prog1| prog3| prog5| sprog1| bprog2
    5678|     prog2| prog4|
    Please help. I do not know how to write this kind of SQL. Simple SQL's are fine for me but this would be difficult.
    Since this is very urgent, pls let me know asap.
    Thanking you all in advance,
    -Jos

    You can get the hierarchy using the SYS_CONNECT_BY_PATH function (requires 9i) within a CONNECT BY query:
    SELECT level
         , SYS_CONNECT_BY_PATH(p.pgm_name, '|') AS path
    FROM   programs p
    CONNECT BY PRIOR p.called_pgm = p.pgm_name
    START WITH p.pgm_name IN
          ( SELECT trans_pgm FROM trans );
         LEVEL PATH
             1 |prog1
             2 |prog1|prog3
             3 |prog1|prog3|prog5
             4 |prog1|prog3|prog5|sprog1
             1 |prog2
    5 rows selected.If you need the elements in separate columns it'll take a bit more work.
    Also notice that prog2 has no path because its caller 'prog4' is not defined as a PGM_NAME in the PROGRAMS table. If we add that row so that PROGRAMS looks like this:SQL> INSERT INTO programs (pgm_name)
      2  SELECT called_pgm FROM programs
      3  MINUS
      4  SELECT pgm_name FROM programs;
    2 rows created.
    SQL> commit;
    Commit complete.
    SQL> SELECT * FROM programs;
    PGM_NAME   CALLED_PGM T
    prog1      prog3      X
    prog2      prog4      X
    prog3      prog5      L
    prog5      sprog1     C
    sprog1     bprog2     L
    bprog2
    prog4
    7 rows selected.We get slightly better results:SELECT level
         , SYS_CONNECT_BY_PATH(p.pgm_name, '|') AS path
    FROM   programs p
    CONNECT BY PRIOR p.called_pgm = p.pgm_name
    START WITH p.pgm_name IN
          ( SELECT trans_pgm FROM trans );
         LEVEL PATH
             1 |prog1
             2 |prog1|prog3
             3 |prog1|prog3|prog5
             4 |prog1|prog3|prog5|sprog1
             5 |prog1|prog3|prog5|sprog1|bprog2
             1 |prog2
             2 |prog2|prog4
    7 rows selected.Now it just needs some filtering (we want the deepest level for each hierarchy) and joining up to TRANSACTIONS:SELECT t.trans_id
         , pgm_path.path
    FROM   ( SELECT SUBSTR(pgm.path,1, INSTR(pgm.path,'|',2) -1) AS program
                  , MAX(pgm.path) KEEP (DENSE_RANK LAST ORDER BY pgm.lvl) AS path
             FROM   ( SELECT level AS lvl
                           , LTRIM(SYS_CONNECT_BY_PATH(p.pgm_name, '|'),'|') AS path
                      FROM   programs p
                      CONNECT BY PRIOR p.called_pgm = p.pgm_name
                      START WITH p.pgm_name IN
                            ( SELECT trans_pgm FROM trans ) ) pgm
             WHERE pgm.lvl > 1
             GROUP BY SUBSTR(pgm.path,1, INSTR(pgm.path,'|',2) -1) ) pgm_path
         , trans t
    WHERE  t.trans_pgm = pgm_path.program
      TRANS_ID PATH
          1234 prog1|prog3|prog5|sprog1|bprog2
          5678 prog2|prog4
    2 rows selected.

  • Creating Views using XSU PL/SQL API.Urgent please.

    Folks,
    I need some help in creating a View.
    I am using XSU PL/SQL to generate an XML Document.
    I have a table (SDI) with 2 cols CMPY_NUM and CPTY_BORG_NUM.
    If the values in these 2 cols are equal then the xml
    value to be returned is 'OURS' else return 'THEIRS'.
    How do I Create this View please?
    The XSU PL/SQL I am using to generate the XML is:
    declare
    queryCtx DBMS_XMLquery.ctxType;
    xmlResult CLOB;
    begin
    queryCtx := DBMS_XMLQuery.newContext('select CMPY_NUM,CPTY_BORG_NUM from SDI');
    xmlResult := DBMS_XMLQuery.getXML(queryCtx);
    DBMS_XMLQuery.closeContext(queryCtx); -- you must close the query handle..
    end;
    Output
    <?xml version='1.0'?>
    <ROWSET>
         <ROW num="1">
         <CMPY_NUM>1</CMPY_NUM>
    <CPTY_BORG_NUM>2/CPTY_BORG_NUM>
         </ROW>
    <!-- additional rows ... -->
    </ROWSET>
    Please can any one tell me how to create a view that will be used in place
    of the select statement,and returns back OURS or THEIRS
    Create View XML AS

    This is a duplicate of this posting Creating a View to check for 2 conditions.. This is a particularly heinous case because some of our finest minds have already responded in that thread.
    Lose ten culture points.
    Regards, APC

  • Ar aging report, need help urgent please help!

    Hey All Gurus,
    Im in a thick soup here. I am trying to do something like this -
    if you see the selection screen i have rep and super rep, when a user enters a rep value --- it should use the same value to pull all open items for the super rep as well, since they are essentially the same. please help! this one needs to be done fast. i am pasting the code so that it will be easier ...
    thanks a million!
    *& Report ZFDOFW04_NEW
    REPORT ZFDOFW04_NEW MESSAGE-ID FR
    LINE-SIZE 132
    LINE-COUNT 60.
    *==================================================================
    Program: ZFDOFW03 - Aged Trial Balance Report
    This produces an Accounts Receivable Past Due Aging Report
    in a more simplified/condensed format than the
    SAP supplied aging report program - RFDOPR10.
    This program is a modified copy of RFDOFW00, - a SAP
    Future-Due Report.
    This was a 'rush' job - program probably should be
    rewritten someday not using logical databases as that
    maybe why this runs so slowly!
    Original: Feb 1997.
    MAINTENANCE HISTORY:
    NES071797 Copied from ZFDOFW03. Adding parameter for saeles rep.
    JDEDERER - changed header text so it is differnet from ZFDORW03. 9/23
    *TEXT SYMBOLS :
    001 Open items per
    002 O p e n
    003 D u e o n
    004 cc ba in total
    005 until
    006 Days until
    007 Days over
    008 Days
    009 over
    011 valid until........
    012 Insurance limit.....
    016 F u t u r e
    017 + days
    018 D u e
    020 Last dunn.notice...
    021 Dunning level....
    030 S U M M A R Y S H E E T
    031 =====================
    050 Name Page
    051 Burton Snowboard
    SELECTION TEXTS:
    SUMMEN Output totals only
    TAGE1 Due date I until
    TAGE2 Due date II until
    TAGE3 Due date III until
    TAGE4 Due date IV until
    TABLES: T001, KNA1, KNB1, KNB5, BSID, BSEGA, RFPDO1, KNVP,
    T014, "credit control areas JAM
    KNVK, "cust master - contact partner JAM
    T014T, "Credit control areas names
    BKPF, "TONY ISSUE 4743
    TVKO, "TONY ISSUE 4743
    KNKK. "cust master - credit mgmt JAM
    TYPES: BEGIN OF TOT_TYPE, "DEVK939546
    BUKRS LIKE LFB1-BUKRS, "DEVK939546
    GSBER LIKE BSIK-GSBER, "DEVK939546
    KKBER LIKE BSID-KKBER,
    RAST1 TYPE P, "DEVK939546
    RAST2 TYPE P, "DEVK939546
    RAST3 TYPE P, "DEVK939546
    RAST4 TYPE P, "DEVK939546
    RAST5 TYPE P, "DEVK939546
    RAST6 TYPE P, "DEVK939546
    RAST7 TYPE P, "DEVK939546
    END OF TOT_TYPE, "DEVK939546
    TOT_TAB TYPE TOT_TYPE OCCURS 0. "DEVK939546
    CONSTANTS:
    C_FALSE TYPE I VALUE 0, "JAM
    C_TRUE TYPE I VALUE 1.
    DATA: BEGIN OF GTAB OCCURS 1000,
    SUPER(10) TYPE C, "TONYC
    REP(10) TYPE C, "TONYC
    FILKD(10), "tonyc show buying groups
    LAND1 LIKE KNA1-LAND1,
    GSBER LIKE BSIK-GSBER,
    REGIO LIKE KNA1-REGIO,
    NAME1 LIKE KNA1-NAME1,
    NAME2 LIKE KNA1-NAME2,
    ORT01 LIKE KNA1-ORT01,
    TELF1 LIKE KNVK-TELF1, "telephone number JAM
    CONT_NAME1 LIKE KNVK-NAME1, "contact name JAM
    NAMEV LIKE KNVK-NAMEV, "contact name JAM
    KUNNR LIKE KNA1-KUNNR, "TONYC
    BUKRS LIKE LFB1-BUKRS, "TONYC
    KKBER LIKE BSID-KKBER, "tonyc issue #2500
    ZTERM LIKE KNB1-ZTERM, "tonyc issue #2500
    KLIMK_TXT(22) TYPE C, "credit limit JAM
    WAERS LIKE T014-WAERS, "currency JAM
    SORT_GSB, "TONYC
    RAST1 TYPE P,
    RAST2 TYPE P,
    RAST3 TYPE P,
    RAST4 TYPE P,
    RAST5 TYPE P,
    RAST6 TYPE P,
    RAST7 TYPE P,
    T_IND,
    END OF GTAB.
    DATA HOLD_NAME(40).
    DATA HOLD_BUKRS LIKE T001-BUKRS. "tonyc
    DATA GOOD_SUPER_REP. "tonyc
    DATA: HOLD_REP LIKE KNA1-KUNNR, "tonyc
    SUPER_NAME LIKE KNA1-NAME1, "tonyc
    REP_NAME LIKE KNA1-NAME1. "tonyc
    DATA NAME_LENGTH(2) TYPE C. "tonyc
    DATA BACKSLASH(3) VALUE ' / '. "tonyc
    DATA REPS_INFO(70) TYPE C. "tonyc
    DATA REPORT_TYPE(12) TYPE C.
    DATA: C_CREDIT_ABTNR LIKE KNVK-ABTNR. "dept 003 = credit
    DATA Z_HOLD_LIMIT(22) TYPE N. "tonyc issue#2216
    DATA Z_DESCRIPTION(18). "tonyc issue#2216
    DATA WRITE_TOTAL.
    DATA HOLD_KLIMK LIKE KNKK-KLIMK.
    DATA HOLD_KLIMK2(22) TYPE C.
    DATA HOLD-CTLPC LIKE KNKK-CTLPC.
    DATA HOLD-CTLPC-TEXT LIKE T691T-RTEXT.
    DATA HOLD_ZTERM LIKE KNVV-ZTERM.
    DATA TOTAL_RAST7 TYPE P.
    DATA TOTAL_RAST2 TYPE P.
    DATA TOTAL_RAST3 TYPE P.
    DATA TOTAL_RAST4 TYPE P.
    DATA TOTAL_RAST5 TYPE P.
    DATA TOTAL_RAST6 TYPE P.
    DATA TOTAL_RAST1 TYPE P.
    DATA HOLD_BUKRS2 LIKE T001-BUKRS.
    DATA HOLD_KKBER LIKE BSID-KKBER.
    DATA HOLD_KKBER_DESC LIKE T014T-KKBTX.
    DATA HOLD_KKBER_DESC2 LIKE T014T-KKBTX.
    DATA HOLD_KUNNR2 LIKE KNA1-KUNNR.
    DATA L_FIRST_DAY_OF_FISCAL LIKE SY-DATUM. "tonyc issue #3047
    DATA: STAB TYPE TOT_TAB WITH HEADER LINE, "DEVK939546
    RTOT TYPE TOT_TAB WITH HEADER LINE, "DEVK939546
    STOT TYPE TOT_TAB WITH HEADER LINE, "DEVK939546
    OP,
    MAXMANDT LIKE DD_STIDA,
    MAXMANST TYPE P,
    SUMKLIMB TYPE P,
    SUMVLIBB TYPE P,
    VERZUG TYPE P,
    OBAD TYPE P,
    BLOCK_CNT TYPE P,
    INTENS,
    ONEBYTE(1) TYPE C,
    TAGE1A LIKE RFPDO1-ALLGFAEL,
    TAGE2A LIKE RFPDO1-ALLGFAEL,
    TAGE3A LIKE RFPDO1-ALLGFAEL,
    HOLD_KUNNR LIKE KNA1-KUNNR, "tonyc
    HOLD_SUPER LIKE KNA1-KUNNR, "tonyc
    HOLD_REP2 LIKE KNA1-KUNNR, "tonyc
    SUPER_REP LIKE KNA1-KUNNR, "tonyc
    TEMP_TELF1 LIKE KNA1-TELF1, "JAM
    IT_T014 LIKE T014 OCCURS 0 WITH HEADER LINE, "JAM
    G_KLIMK_TXT LIKE GTAB-KLIMK_TXT, "JAM
    G_WAERS LIKE GTAB-WAERS, "JAM
    G_CONT_NAME(50) TYPE C. "JA
    DATA FILL_REP_INFO.
    BC SUNILP 05/14/2007
    DATA: BEGIN OF ITAB_VBRP OCCURS 0.
    INCLUDE STRUCTURE VBRP.
    DATA: END OF ITAB_VBRP.
    DATA: T_PERC TYPE F,
    SUM_NETWR LIKE VBRP-NETWR.
    *DATA: GTAB_LINES LIKE GTAB OCCURS 0 WITH HEADER LINE.
    DATA: BEGIN OF GTAB_LINES OCCURS 0.
    INCLUDE STRUCTURE GTAB.
    DATA: IND(1),
    OBAD TYPE P.
    DATA: END OF GTAB_LINES.
    DATA: BEGIN OF ITAB_VBRP1 OCCURS 0,
    VBELN LIKE VBRP-VBELN,
    NETWR LIKE VBRP-NETWR,
    ZZMREP LIKE VBRP-ZZMREP, "Super Rep
    ZZLREP LIKE VBRP-ZZLREP, "Rep
    PERC TYPE F,
    END OF ITAB_VBRP1.
    EC SUNILP 05/14/2007
    BEGIN_OF_BLOCK 2.
    PARAMETERS: REGIO LIKE KNA1-REGIO.
    PARAMETERS: CONSOL AS CHECKBOX. "TONYC
    PARAMETERS: P_KKBER AS CHECKBOX, "TONYC
    P_CONV AS CHECKBOX. "tonyc issue #3047
    PARAMETERS: SUMMEN LIKE RFPDO1-ALLGSUMM,
    TAGE1 LIKE RFPDO1-ALLGFAEL DEFAULT '30',
    TAGE2 LIKE RFPDO1-ALLGFAEL DEFAULT '60',
    TAGE3 LIKE RFPDO1-ALLGFAEL DEFAULT '90',
    TAGE4 LIKE RFPDO1-ALLGFAEL DEFAULT '120'.
    END_OF_BLOCK 2.
    BEGIN_OF_BLOCK 3.
    SELECT-OPTIONS: P_SUPREP FOR KNVP-KUNNR, "Super REP "DEVK939546
    P_REP FOR KNVP-KUNNR, "SALES REP "DEVK939546
    P_VKORG FOR TVKO-VKORG, "TONYC ISSUE 4743
    P_LOTKZ FOR BKPF-LOTKZ. "TONYC ISSUE 4743
    END_OF_BLOCK 3.
    INITIALIZATION. "JAM
    PERFORM LOAD_T014. "JAM
    refresh dd_augdt.
    clear dd_augdt.
    dd_augdt-option = 'EQ'.
    dd_augdt-sign = 'I'.
    dd_augdt-low = ' '.
    append dd_augdt.
    AT SELECTION-SCREEN.
    IF CONSOL = 'X'.
    IF NOT P_SUPREP[] IS INITIAL. "DEVK939546
    MESSAGE E999 WITH 'Consolidated report not allowed w/ Super Rep'.
    ENDIF.
    ENDIF.
    CHECK IF THE REP INFO IS ADDED OR NOT - VS
    IF NOT P_SUPREP IS INITIAL OR"TONY ISSUE 4743
    NOT P_REP IS INITIAL."TONY ISSUE 4743
    FILL_REP_INFO = 'X'."TONY ISSUE 4743
    ENDIF."TONY ISSUE 4743
    START-OF-SELECTION.
    get_frame_title 2.
    add function module to track usage JD 10/13/98 *****
    CALL FUNCTION 'Z_RUN_LOG'
    EXCEPTIONS
    OTHERS = 1.
    *IF NOT P_SUPREP IS INITIAL AND NOT P_REP IS INITIAL.
    P_SUPREP = ' '.
    *ENDIF.
    GET KNA1 FIELDS LAND1 REGIO KUNNR NAME1 NAME2 ORT01 TELF1. "JAM
    new-page.
    skip.
    TEMP_TELF1 = KNA1-TELF1.
    MAXMANDT = '19000101'.
    MAXMANST = 0.
    SUMVLIBB = 0.
    PERFORM GET_CUST_CONTACT. "JAM
    Check sales rep- NES071797
    Get any valid record and exit.
    IF NOT p_suprep[] IS INITIAL. "DEVK939546 "TONY ISSUE 4743 start
    good_super_rep = ' '.
    SELECT kunn2 INTO super_rep FROM knvp UP TO 1 ROWS
    WHERE
    kunnr = kna1-kunnr AND
    parvw = 'ZS' AND
    kunn2 IN p_suprep.
    EXIT.
    ENDSELECT.
    IF sy-subrc = 0.
    good_super_rep = 'X'.
    gtab-super = super_rep.
    super_rep = ' '.
    ENDIF.
    CHECK good_super_rep = 'X'.
    SELECT kunn2 INTO gtab-rep FROM knvp UP TO 1 ROWS
    WHERE
    kunnr = kna1-kunnr AND
    parvw = 'ZR' AND
    kunn2 IN p_rep.
    EXIT.
    ENDSELECT.
    CHECK sy-subrc = 0.
    ELSEIF NOT p_rep[] IS INITIAL. "DEVK939546
    SELECT kunn2 INTO gtab-rep FROM knvp UP TO 1 ROWS
    WHERE
    kunnr = kna1-kunnr AND
    parvw = 'ZR' AND
    kunn2 IN p_rep.
    EXIT.
    ENDSELECT.
    CHECK sy-subrc = 0.
    ENDIF. "TONY ISSUE 4743 end
    GET KNB1 FIELDS BUKRS VLIBB ZTERM. "tonyc #2500
    GTAB-BUKRS = KNB1-BUKRS.
    GTAB-ZTERM = KNB1-ZTERM.
    SUMVLIBB = SUMVLIBB + KNB1-VLIBB.
    GET KNB5.
    IF KNB5-MADAT > MAXMANDT.
    MAXMANDT = KNB5-MADAT.
    ENDIF.
    IF KNB5-MAHNS > MAXMANST.
    MAXMANST = KNB5-MAHNS.
    ENDIF.
    SUMKLIMB = SUMKLIMB + KLIMB.
    GET BSID.
    CHECK BSID-BSTAT = SPACE.
    field was intended for Business Area, changed to use Currency
    GTAB-GSBER = BSID-WAERS.
    IF P_KKBER = 'X'. "TONYC ISSUE #2500
    IF BSID-KKBER = ' '.
    GTAB-KKBER = BSID-BUKRS.
    ELSE.
    GTAB-KKBER = BSID-KKBER. "TONYC ISSUE #2500
    ENDIF.
    ENDIF. "TONYC ISSUE #2500
    SELECT SINGLE * FROM BKPF "TONY ISSUE 4743
    WHERE BUKRS = BSID-BUKRS "TONY ISSUE 4743
    AND BELNR = BSID-BELNR "TONY ISSUE 4743
    AND GJAHR = BSID-GJAHR. "TONY ISSUE 4743
    BC SUNILP 05/14/2007
    IF BKPF-XREF2_HD IS NOT INITIAL.
    CHECK BKPF-XREF2_HD IN P_SUPREP. "TONY ISSUE 4743
    ELSE.
    IF P_REP[] IS INITIAL.
    REFRESH: ITAB_VBRP, ITAB_VBRP1.
    IF NOT BKPF-XBLNR IS INITIAL.
    SELECT * FROM VBRP INTO ITAB_VBRP WHERE VBELN = BKPF-XBLNR.
    APPEND ITAB_VBRP. CLEAR ITAB_VBRP.
    ENDSELECT.
    CHECK ITAB_VBRP[] IS NOT INITIAL.
    CLEAR: SUM_NETWR.
    LOOP AT ITAB_VBRP.
    CHECK ITAB_VBRP-ZZMREP IN P_SUPREP.
    CHECK ITAB_VBRP-ZZLREP IN P_REP.
    MOVE-CORRESPONDING ITAB_VBRP TO ITAB_VBRP1.
    COLLECT: ITAB_VBRP1.
    SUM_NETWR = SUM_NETWR + ITAB_VBRP-NETWR.
    CLEAR ITAB_VBRP.
    ENDLOOP.
    CHECK ITAB_VBRP1[] IS NOT INITIAL.
    LOOP AT ITAB_VBRP1.
    CLEAR: T_PERC.
    T_PERC = ( ITAB_VBRP1-NETWR / SUM_NETWR ).
    ITAB_VBRP1-PERC = T_PERC.
    MODIFY ITAB_VBRP1 INDEX SY-TABIX TRANSPORTING PERC.
    ENDLOOP.
    ENDIF.
    ENDIF.
    ENDIF.
    EC SUNILP 05/14/2007
    IF FILL_REP_INFO = 'X'.
    GTAB-SUPER = BKPF-XREF2_HD. "TONY ISSUE 4743 "MOVE THE CONTENTS OF XREF2_HD TO GTAB INTERNAL TABLE - VS
    ENDIF.
    BC SUNILP 05/14/2007
    IF BKPF-XREF1_HD IS NOT INITIAL.
    CHECK BKPF-XREF1_HD IN P_REP. "TONY ISSUE 4743 " ELSE MOVE THE CONTENTS OF - VS
    ELSE.
    REFRESH: ITAB_VBRP, ITAB_VBRP1.
    IF NOT BKPF-XBLNR IS INITIAL.
    SELECT * FROM VBRP INTO ITAB_VBRP WHERE VBELN = BKPF-XBLNR.
    APPEND ITAB_VBRP. CLEAR ITAB_VBRP.
    ENDSELECT.
    CHECK ITAB_VBRP[] IS NOT INITIAL.
    CLEAR: SUM_NETWR.
    LOOP AT ITAB_VBRP.
    CHECK ITAB_VBRP-ZZMREP IN P_SUPREP.
    CHECK ITAB_VBRP-ZZLREP IN P_REP.
    MOVE-CORRESPONDING ITAB_VBRP TO ITAB_VBRP1.
    COLLECT: ITAB_VBRP1.
    SUM_NETWR = SUM_NETWR + ITAB_VBRP-NETWR.
    CLEAR ITAB_VBRP.
    ENDLOOP.
    CHECK ITAB_VBRP1[] IS NOT INITIAL.
    LOOP AT ITAB_VBRP1.
    CLEAR: T_PERC.
    T_PERC = ( ITAB_VBRP1-NETWR / SUM_NETWR ).
    ITAB_VBRP1-PERC = T_PERC.
    MODIFY ITAB_VBRP1 INDEX SY-TABIX TRANSPORTING PERC.
    ENDLOOP.
    ENDIF.
    ENDIF.
    EC SUNILP 05/14/2007
    IF FILL_REP_INFO = 'X'.
    GTAB-REP = BKPF-XREF1_HD. "TONY ISSUE 4743
    ENDIF.
    CHECK BKPF-LOTKZ IN P_LOTKZ. "TONY ISSUE 4743
    CHECK BKPF-BRNCH IN P_VKORG. "TONY ISSUE 4743
    SELECT SINGLE FILKD INTO GTAB-FILKD FROM BSEG
    WHERE BUKRS = BSID-BUKRS
    AND BELNR = BSID-BELNR
    AND GJAHR = BSID-GJAHR
    AND BUZEI = BSID-BUZEI.
    gtab-gsber = bsid-gsber.
    get rep info for each bsid record
    IF NOT P_SUPREP IS INITIAL. "tonyc
    SELECT KUNNR FROM VBPA INTO HOLD_REP UP TO 1 ROWS "tonyc
    WHERE VBELN = BSID-VBELN "tonyc
    AND PARVW = 'ZR'. "tonyc
    ENDSELECT. "tonyc
    IF NOT P_REP IS INITIAL. "tonyc
    CHECK HOLD_REP = P_REP. "tonyc
    ENDIF. "tonyc
    GTAB-REP = HOLD_REP. "tonyc
    HOLD_REP = ' '. "tonyc
    ENDIF. "tonyc
    PERFORM GET_KNKK_INFO. "JAM
    GTAB-KLIMK_TXT = G_KLIMK_TXT.
    GTAB-WAERS = G_WAERS.
    GTAB-LAND1 = KNA1-LAND1.
    GTAB-REGIO = KNA1-REGIO.
    GTAB-KUNNR = KNA1-KUNNR.
    GTAB-NAME1 = KNA1-NAME1.
    GTAB-NAME2 = KNA1-NAME2.
    GTAB-ORT01 = KNA1-ORT01.
    *if there is no phone number for the contact, pull the phone
    *number from the sold-to
    IF KNVK-TELF1 = ' '.
    GTAB-TELF1 = TEMP_TELF1.
    ELSE.
    GTAB-TELF1 = KNVK-TELF1. "JAM
    ENDIF.
    GTAB-CONT_NAME1 = KNVK-NAME1.
    GTAB-NAMEV = KNVK-NAMEV.
    verzug = bsega-netdt - dd_stida.
    VERZUG = DD_STIDA - BSEGA-NETDT. "days past due calculation
    OP = 'X'.
    GTAB-RAST2 = GTAB-RAST3 = GTAB-RAST4 = 0.
    GTAB-RAST5 = GTAB-RAST6 = OBAD = GTAB-RAST7 = 0.
    IF VERZUG LE 0. "future due
    GTAB-RAST1 = BSEGA-WRSHB.
    ELSE.
    IF VERZUG LE TAGE1. "past due 1 to tage1 days
    GTAB-RAST1 = BSEGA-WRSHB.
    GTAB-RAST2 = BSEGA-WRSHB.
    OBAD = BSEGA-WRSHB.
    ELSE.
    IF VERZUG LE TAGE2. "past due tage1 to tage2 days
    GTAB-RAST1 = BSEGA-WRSHB.
    GTAB-RAST3 = BSEGA-WRSHB.
    OBAD = BSEGA-WRSHB.
    ELSE.
    IF VERZUG LE TAGE3. "past due tage2 to tage3 days
    GTAB-RAST1 = BSEGA-WRSHB.
    GTAB-RAST4 = BSEGA-WRSHB.
    OBAD = BSEGA-WRSHB.
    ELSE.
    IF VERZUG LE TAGE4. "past due tage3 to tage4 days
    GTAB-RAST1 = BSEGA-WRSHB.
    GTAB-RAST5 = BSEGA-WRSHB.
    OBAD = BSEGA-WRSHB.
    ELSE.
    IF VERZUG GT TAGE4. "past due > tage4 days
    GTAB-RAST1 = BSEGA-WRSHB.
    GTAB-RAST6 = BSEGA-WRSHB.
    OBAD = BSEGA-WRSHB.
    ENDIF.
    ENDIF.
    ENDIF.
    ENDIF.
    ENDIF.
    ENDIF.
    GTAB-RAST7 = GTAB-RAST1 - OBAD.
    stab = gtab.
    MOVE-CORRESPONDING GTAB TO STAB.
    BC SUNILP 05/15/2007
    IF ITAB_VBRP1[] IS NOT INITIAL.
    GTAB-T_IND = 'X'.
    LOOP AT ITAB_VBRP1.
    MOVE-CORRESPONDING GTAB TO GTAB_LINES.
    GTAB_LINES-SORT_GSB = '1'.
    GTAB_LINES-SUPER = ITAB_VBRP1-ZZMREP.
    GTAB_LINES-REP = ITAB_VBRP1-ZZLREP.
    GTAB_LINES-RAST1 = GTAB_LINES-RAST1 * ITAB_VBRP1-PERC.
    GTAB_LINES-RAST2 = GTAB_LINES-RAST2 * ITAB_VBRP1-PERC.
    GTAB_LINES-RAST3 = GTAB_LINES-RAST3 * ITAB_VBRP1-PERC.
    GTAB_LINES-RAST4 = GTAB_LINES-RAST4 * ITAB_VBRP1-PERC.
    GTAB_LINES-RAST5 = GTAB_LINES-RAST5 * ITAB_VBRP1-PERC.
    GTAB_LINES-RAST6 = GTAB_LINES-RAST6 * ITAB_VBRP1-PERC.
    GTAB_LINES-RAST7 = GTAB_LINES-RAST7 * ITAB_VBRP1-PERC.
    GTAB_LINES-OBAD = GTAB_LINES-OBAD * ITAB_VBRP1-PERC.
    COLLECT: GTAB_LINES.
    ENDLOOP.
    ELSE.
    MOVE-CORRESPONDING GTAB TO GTAB_LINES.
    GTAB_LINES-T_IND = 'X'.
    GTAB_LINES-SORT_GSB = '1'.
    IF GTAB_LINES-SUPER IN P_SUPREP OR GTAB_LINES-REP IN P_REP.
    COLLECT: GTAB_LINES.
    ENDIF.
    ENDIF.
    EC SUNILP 05/15/2007
    gtab-sort_gsb = stab-sort_gsb = '0'.
    collect: gtab, stab.
    gtab-gsber = stab-gsber = '****'.
    GTAB-SORT_GSB = '1'.
    IF REGIO = SPACE OR REGIO = GTAB-REGIO.
    IF GTAB_LINES-SUPER IN P_SUPREP OR GTAB_LINES-REP IN P_REP.
    COLLECT: GTAB, STAB.
    ENDIF.
    ENDIF.
    END-OF-SELECTION.
    TAGE1A = TAGE1 + 1.
    TAGE2A = TAGE2 + 1.
    TAGE3A = TAGE3 + 1.
    IF SUMMEN = ' '.
    sort gtab by bukrs land1 regio kunnr gsber sort_gsb.
    sort gtab by bukrs land1 regio name1 kunnr gsber sort_gsb. "JAM
    IF CONSOL = 'X'.
    SORT GTAB BY LAND1 REGIO NAME1 KUNNR BUKRS KKBER GSBER SORT_GSB.
    "TONYC
    REPORT_TYPE = 'consolidated'.
    ELSEIF NOT P_SUPREP[] IS INITIAL. "DEVK939546
    SORT GTAB
    BY SUPER REP NAME1 BUKRS KKBER LAND1 REGIO NAME1 GSBER SORT_GSB.
    BC SUNILP 05/15/2007
    SORT GTAB_LINES
    BY SUPER REP NAME1 BUKRS KKBER LAND1 REGIO NAME1 GSBER SORT_GSB.
    EC SUNILP 05/15/2007
    REPORT_TYPE = 'super rep'.
    CLEAR STAB. "tonyc 03/06/2004
    REFRESH STAB. "tonyc 03/06/2004
    ELSEIF NOT P_REP[] IS INITIAL. "DEVK939546
    SORT GTAB "DEVK939546
    BY REP NAME1 BUKRS KKBER LAND1 REGIO NAME1 GSBER SORT_GSB.
    "DEVK939546
    BC SUNILP 05/15/2007
    SORT GTAB_LINES
    BY REP NAME1 BUKRS KKBER LAND1 REGIO NAME1 GSBER SORT_GSB.
    EC SUNILP 05/15/2007
    REPORT_TYPE = 'rep'. "DEVK939546
    CLEAR STAB. "tonyc 03/06/2004
    REFRESH STAB. "tonyc 03/06/2004
    ELSE.
    SORT GTAB BY BUKRS KKBER LAND1 REGIO NAME1 KUNNR GSBER SORT_GSB.
    BC SUNILP 05/15/2007
    SORT GTAB_LINES BY BUKRS KKBER LAND1 REGIO NAME1 KUNNR GSBER SORT_GSB.
    EC SUNILP 05/15/2007
    REPORT_TYPE = 'regular'.
    ENDIF.
    BC SUNILP 05/15/2007
    DELETE ADJACENT DUPLICATES FROM GTAB COMPARING BUKRS NAME1.
    LOOP AT GTAB_LINES.
    IF P_REP[] IS INITIAL.
    IF GTAB_LINES-SUPER NOT IN P_SUPREP.
    DELETE GTAB_LINES.
    ENDIF.
    ELSE.
    IF GTAB_LINES-SUPER NOT IN P_SUPREP OR GTAB_LINES-REP NOT IN P_REP.
    DELETE GTAB_LINES.
    ENDIF.
    ENDIF.
    ENDLOOP.
    LOOP AT GTAB.
    READ TABLE GTAB_LINES WITH KEY BUKRS = GTAB-BUKRS
    NAME1 = GTAB-NAME1.
    IF SY-SUBRC NE '0'.
    DELETE GTAB.
    ENDIF.
    ENDLOOP.
    EC SUNILP 05/15/2007
    LOOP AT GTAB.
    MOVE GTAB-BUKRS TO T001-BUKRS. READ TABLE T001.
    RESERVE 5 LINES.
    CASE REPORT_TYPE.
    WHEN 'regular'.
    IF HOLD_BUKRS <> GTAB-BUKRS.
    IF SY-TABIX > 1. "TONYC
    NEW-PAGE. SKIP. "TONYC
    ENDIF. "TONYC
    ENDIF.
    PERFORM WRITE_CUST_INFO. "TONYC
    PERFORM WRITE_DETAIL.
    hold_bukrs = gtab-bukrs. "tonyc
    WHEN 'consolidated'.
    IF HOLD_KUNNR <> GTAB-KUNNR. "TONYC
    PERFORM WRITE_CUST_INFO. "TONYC
    ENDIF. "TONYC
    HOLD_KUNNR = GTAB-KUNNR. "TONYC
    PERFORM WRITE_DETAIL.
    WHEN 'super rep'.
    IF GTAB-T_IND NE 'X'.
    BC SUNILP 05/22/2007
    READ TABLE GTAB_LINES WITH KEY BUKRS = GTAB-BUKRS
    NAME1 = GTAB-NAME1.
    EC SUNILP 05/22/2007
    IF ( HOLD_SUPER <> GTAB_LINES-SUPER ) OR
    ( HOLD_REP2 <> GTAB_LINES-REP ).
    NEW-PAGE.
    PERFORM GET_AND_WRITE_SUPERINFO.
    ENDIF.
    HOLD_REP2 = GTAB_LINES-REP.
    HOLD_SUPER = GTAB_LINES-SUPER.
    IF HOLD_KUNNR <> GTAB-KUNNR. "TONYC
    WRITE :/. "TONYC
    ULINE. "TONYC
    PERFORM WRITE_CUST_INFO. "TONYC
    ENDIF. "TONYC
    HOLD_KUNNR = GTAB-KUNNR. "TONYC
    PERFORM WRITE_DETAIL. "TONYC
    AT END OF REP. "DEVK939546
    SKIP. "DEVK939546
    RESERVE 7 LINES. "DEVK939546
    FORMAT COLOR COL_TOTAL INTENSIFIED. "DEVK939546
    WRITE: / 'Summary for Rep:', "DEVK939546
    GTAB-REP, '/', REP_NAME, 132 ONEBYTE."DEVK939546
    PERFORM WRITE_TOTS TABLES RTOT. "DEVK939546
    REFRESH RTOT. "DEVK939546
    ENDAT. "DEVK939546
    AT END OF SUPER. "DEVK939546
    CLEAR STAB. "tonyc 03/06/2004
    REFRESH STAB. "tonyc 03/06/2004
    NEW-PAGE. SKIP. "DEVK939546
    FORMAT COLOR COL_TOTAL INTENSIFIED. "DEVK939546
    WRITE: / 'Summary for Super Rep:', "DEVK939546
    GTAB-SUPER, '/', SUPER_NAME, 132 ONEBYTE."DEVK939546
    PERFORM WRITE_TOTS TABLES STOT. "DEVK939546
    REFRESH STOT. "DEVK939546
    ENDAT. "DEVK939546
    ELSE.
    LOOP AT GTAB_LINES WHERE BUKRS = GTAB-BUKRS
    AND NAME1 = GTAB-NAME1.
    IF ( HOLD_SUPER <> GTAB_LINES-SUPER ) OR
    ( HOLD_REP2 <> GTAB_LINES-REP ).
    NEW-PAGE.
    PERFORM GET_AND_WRITE_SUPERINFO.
    ENDIF.
    HOLD_REP2 = GTAB_LINES-REP.
    HOLD_SUPER = GTAB_LINES-SUPER.
    IF HOLD_KUNNR <> GTAB_LINES-KUNNR.
    WRITE :/.
    ULINE.
    PERFORM WRITE_CUST_INFO.
    ENDIF.
    HOLD_KUNNR = GTAB_LINES-KUNNR.
    PERFORM WRITE_DETAIL.
    AT END OF REP.
    SKIP.
    RESERVE 7 LINES.
    FORMAT COLOR COL_TOTAL INTENSIFIED.
    WRITE: / 'Summary for Rep:',
    GTAB_LINES-REP, '/', REP_NAME, 132 ONEBYTE.
    PERFORM WRITE_TOTS TABLES RTOT.
    REFRESH RTOT.
    ENDAT.
    AT END OF SUPER.
    CLEAR STAB. "tonyc 03/06/2004
    REFRESH STAB. "tonyc 03/06/2004
    NEW-PAGE. SKIP.
    FORMAT COLOR COL_TOTAL INTENSIFIED.
    WRITE: / 'Summary for Super Rep:',
    GTAB_LINES-SUPER, '/', SUPER_NAME, 132 ONEBYTE.
    PERFORM WRITE_TOTS TABLES STOT.
    REFRESH STOT.
    ENDAT.
    ENDLOOP.
    ENDIF.
    WHEN 'rep'. "DEVK939546
    LOOP AT GTAB_LINES WHERE BUKRS = GTAB-BUKRS
    AND NAME1 = GTAB-NAME1.
    IF HOLD_REP2 <> GTAB_LINES-REP. "DEVK939546
    NEW-PAGE. "DEVK939546
    PERFORM GET_AND_WRITE_REPINFO. "DEVK939546
    ENDIF. "DEVK939546
    HOLD_REP2 = GTAB_LINES-REP. "DEVK939546
    IF HOLD_KUNNR <> GTAB_LINES-KUNNR. "DEVK939546
    WRITE :/. "DEVK939546
    ULINE. "DEVK939546
    PERFORM WRITE_CUST_INFO. "DEVK939546
    ENDIF. "DEVK939546
    HOLD_KUNNR = GTAB_LINES-KUNNR. "DEVK939546
    PERFORM WRITE_DETAIL. "DEVK939546
    AT END OF REP. "DEVK939546
    SKIP. "DEVK939546
    RESERVE 7 LINES. "DEVK939546
    FORMAT COLOR COL_TOTAL INTENSIFIED. "DEVK939546
    WRITE: / 'Summary for Rep:', "DEVK939546
    GTAB_LINES-REP, '/', REP_NAME, 132 ONEBYTE."DEVK939546
    PERFORM WRITE_TOTS TABLES RTOT. "DEVK939546
    REFRESH RTOT. "DEVK939546
    ENDAT. "DEVK939546
    ENDLOOP.
    ENDCASE.
    ENDLOOP.
    ENDIF.
    OP = ' '.
    REFRESH GTAB.
    IF NOT REPORT_TYPE = 'super rep'.
    ULINE.
    ENDIF.
    SKIP 1.
    IF SUMMEN = ' '. "if 'output totals only' bypass new-page
    NEW-PAGE. SKIP.
    ENDIF.
    WRITE: /25 TEXT-030, 132 ONEBYTE, /25 TEXT-031, 132 ONEBYTE.
    PERFORM WRITE_TOTS TABLES STAB. "DEVK939546
    TOP-OF-PAGE.
    INTENS = SPACE.
    FORMAT COLOR COL_HEADING INTENSIFIED ON.
    WRITE: / SY-VLINE, 1 TEXT-001, DD_STIDA, 75 TEXT-051, 132 SY-VLINE.
    ULINE.
    WRITE: / SY-VLINE, 13 SY-VLINE, 30 SY-VLINE,
    47 SY-VLINE, 58 TEXT-003, 81 SY-VLINE,
    92 TEXT-003, 115 SY-VLINE, 118 TEXT-003, 132 SY-VLINE,
    / SY-VLINE, 02 TEXT-004, 13 SY-VLINE, TEXT-002,
    30 SY-VLINE, 32 TEXT-018, 47 SY-VLINE,
    50 '1', 54 TEXT-040, 57 TAGE1, 64 SY-VLINE, " 65 tage2,
    67 TAGE1A, 72 TEXT-040, 75 TAGE2,
    81 SY-VLINE, 83 TAGE2A, 89 TEXT-040, 91 TAGE3, 98 SY-VLINE,
    101 TAGE3A, 107 TEXT-040, 110 TAGE4, 115 SY-VLINE,
    117 TAGE4, 123 TEXT-017, 132 SY-VLINE.
    ULINE.
    SKIP 1.
    SUMMARY.
    FORMAT COLOR COL_HEADING INTENSIFIED OFF.
    FORM write_tots *
    --> PTAB *
    FORM WRITE_TOTS TABLES PTAB TYPE TOT_TAB. "DEVK939546
    CLEAR INTENS. "DEVK939546
    FORMAT COLOR COL_HEADING INTENSIFIED OFF. "DEVK939546
    IF P_CONV = 'X'. "tonyc issue #3047 begin
    WRITE /4 TEXT-101.
    WRITE: /4 TEXT-102,
    50 TEXT-100.
    ENDIF. "tonyc issue #3047 end
    ULINE. "DEVK939546
    SORT PTAB BY BUKRS GSBER. "DEVK939546
    LOOP AT PTAB. "DEVK939546
    IF SY-TABIX > 1.
    WRITE_TOTAL = 'X'.
    ENDIF.
    MOVE PTAB-BUKRS TO T001-BUKRS. READ TABLE T001. "DEVK939546
    MOVE PTAB-GSBER TO T001-WAERS. "DEVK939546
    IF P_CONV = 'X'. "tonyc issue #3047 begin
    PERFORM CONVERT_VALUES USING STAB-RAST1
    STAB-GSBER.
    PERFORM CONVERT_VALUES USING STAB-RAST2
    STAB-GSBER.
    PERFORM CONVERT_VALUES USING STAB-RAST3
    STAB-GSBER.
    PERFORM CONVERT_VALUES USING STAB-RAST4
    STAB-GSBER.
    PERFORM CONVERT_VALUES USING STAB-RAST5
    STAB-GSBER.
    PERFORM CONVERT_VALUES USING STAB-RAST6
    STAB-GSBER.
    PERFORM CONVERT_VALUES USING STAB-RAST7
    STAB-GSBER.
    ENDIF. "TOnyc issue #3047 end
    MOVE-CORRESPONDING PTAB TO STAB.
    COLLECT STAB.
    IF P_KKBER = 'X'. "TONYC ISSUE #2500
    CLEAR HOLD_KKBER_DESC2.
    SELECT SINGLE KKBTX INTO HOLD_KKBER_DESC2 FROM T014T
    WHERE KKBER = STAB-KKBER AND
    SPRAS = 'E'.
    IF SY-SUBRC <> '0'.
    HOLD_KKBER_DESC2 = 'Undetermined'.
    ENDIF.
    FORMAT COLOR OFF.
    WRITE: / SY-VLINE.
    FORMAT COLOR COL_HEADING INTENSIFIED OFF.
    WRITE: 6 STAB-GSBER, HOLD_KKBER_DESC2, SY-VLINE.
    ULINE.
    FORMAT COLOR OFF.
    WRITE: / SY-VLINE.
    FORMAT COLOR COL_HEADING INTENSIFIED OFF.
    IF P_CONV = 'X'. "tonyc issue #3047 begin
    T001-WAERS = 'USD'.
    ENDIF. "tonyc issue #3047 end
    WRITE: 13 STAB-RAST1 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
    (14) STAB-RAST7 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
    (14) STAB-RAST2 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
    (14) STAB-RAST3 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
    (14) STAB-RAST4 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
    (14) STAB-RAST5 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
    (14) STAB-RAST6 NO-ZERO CURRENCY T001-WAERS, SY-VLINE.
    HOLD_BUKRS2 = STAB-BUKRS. "TONYC ISSUE #2500
    ULINE.
    FORMAT COLOR OFF.
    TOTAL_RAST1 = STAB-RAST1 + TOTAL_RAST1.
    TOTAL_RAST2 = STAB-RAST2 + TOTAL_RAST2.
    TOTAL_RAST3 = STAB-RAST3 + TOTAL_RAST3.
    TOTAL_RAST4 = STAB-RAST4 + TOTAL_RAST4.
    TOTAL_RAST5 = STAB-RAST5 + TOTAL_RAST5.
    TOTAL_RAST6 = STAB-RAST6 + TOTAL_RAST6.
    TOTAL_RAST7 = STAB-RAST7 + TOTAL_RAST7.
    ELSE.
    FORMAT COLOR COL_NORMAL INTENSIFIED OFF. "DEVK939546
    IF INTENS = SPACE. "DEVK939546
    FORMAT COLOR COL_NORMAL INTENSIFIED OFF. "DEVK939546
    INTENS = 'X'. "DEVK939546
    ELSE. "DEVK939546
    FORMAT COLOR COL_NORMAL INTENSIFIED ON. "DEVK939546
    INTENS = SPACE. "DEVK939546
    ENDIF. "DEVK939546
    WRITE: / SY-VLINE, PTAB-BUKRS, PTAB-GSBER, SY-VLINE, "DEVK939546
    (14) PTAB-RAST1 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,"DEVK939546
    (14) PTAB-RAST7 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,"DEVK939546
    (14) PTAB-RAST2 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,"DEVK939546
    (14) PTAB-RAST3 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,"DEVK939546
    (14) PTAB-RAST4 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,"DEVK939546
    (14) PTAB-RAST5 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,"DEVK939546
    (14) PTAB-RAST6 NO-ZERO CURRENCY T001-WAERS, SY-VLINE."DEVK939546
    TOTAL_RAST1 = STAB-RAST1 + TOTAL_RAST1.
    TOTAL_RAST2 = STAB-RAST2 + TOTAL_RAST2.
    TOTAL_RAST3 = STAB-RAST3 + TOTAL_RAST3.
    TOTAL_RAST4 = STAB-RAST4 + TOTAL_RAST4.
    TOTAL_RAST5 = STAB-RAST5 + TOTAL_RAST5.
    TOTAL_RAST6 = STAB-RAST6 + TOTAL_RAST6.
    TOTAL_RAST7 = STAB-RAST7 + TOTAL_RAST7.
    ENDIF.
    ENDLOOP. "DEVK939546
    ULINE. "DEVK939546
    IF P_KKBER = 'X'. "TONYC ISSUE #2500
    IF P_CONV = 'X'. "tonyc issue #3047 begin
    FORMAT COLOR OFF.
    FORMAT COLOR COL_HEADING INTENSIFIED OFF.
    WRITE: SY-VLINE,
    6 'TOTAL ', SY-VLINE.
    ULINE.
    FORMAT COLOR OFF.
    WRITE: / SY-VLINE.
    FORMAT COLOR COL_HEADING INTENSIFIED OFF.
    WRITE: 13 TOTAL_RAST1 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
    (14) TOTAL_RAST7 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
    (14) TOTAL_RAST2 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
    (14) TOTAL_RAST3 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
    (14) TOTAL_RAST4 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
    (14) TOTAL_RAST5 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
    (14) TOTAL_RAST6 NO-ZERO CURRENCY T001-WAERS, SY-VLINE.
    ULINE.
    ENDIF. "tonyc issue #3047 end
    ELSE.
    IF P_CONV = 'X'.
    FORMAT COLOR OFF.
    FORMAT COLOR COL_HEADING INTENSIFIED OFF.
    WRITE: SY-VLINE,
    6 'TOTAL ', SY-VLINE.
    ULINE.
    FORMAT COLOR OFF.
    WRITE: / SY-VLINE.
    FORMAT COLOR COL_HEADING INTENSIFIED OFF.
    WRITE: 13 TOTAL_RAST1 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
    (14) TOTAL_RAST7 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
    (14) TOTAL_RAST2 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
    (14) TOTAL_RAST3 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
    (14) TOTAL_RAST4 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
    (14) TOTAL_RAST5 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
    (14) TOTAL_RAST6 NO-ZERO CURRENCY T001-WAERS, SY-VLINE.
    ULINE.
    ENDIF.
    ENDIF.
    SKIP 1. "DEVK939546
    ENDFORM. "DEVK939546
    *& Form GET_KNKK_INFO
    text
    --> p1 text
    <-- p2 text
    FORM GET_KNKK_INFO.
    CLEAR: G_WAERS,
    G_KLIMK_TXT,
    KNKK-KLIMK.
    get credit control area (KKBER) for comp code (BUKRS)
    SELECT SINGLE KLIMK
    INTO KNKK-KLIMK
    FROM KNKK
    WHERE KUNNR = KNA1-KUNNR AND
    KKBER = T001-KKBER.
    IF SY-SUBRC = 0.
    get currency for cred ctrl area
    CLEAR IT_T014.
    READ TABLE IT_T014 WITH KEY KKBER = T001-KKBER BINARY SEARCH.
    G_WAERS = IT_T014-WAERS.
    WRITE KNKK-KLIMK TO G_KLIMK_TXT CURRENCY G_WAERS.
    ENDIF.
    ENDFORM. " GET_KNKK_INFO
    *& Form SELECT_KNKK
    text
    -->P_KKBER Credit Limit Controlling Area
    <--P_FOUND_KNKK Indicates if record found
    FORM SELECT_KNKK USING P_KKBER
    CHANGING P_FOUND_KNKK.
    CLEAR: G_WAERS,
    G_KLIMK_TXT,
    KNKK-KLIMK.
    SELECT SINGLE KLIMK
    INTO KNKK-KLIMK
    FROM KNKK
    WHERE KUNNR = KNA1-KUNNR AND
    KKBER = P_KKBER.
    IF SY-SUBRC = 0.
    P_FOUND_KNKK = C_TRUE.
    get currency for cred ctrl area
    CLEAR IT_T014.
    READ TABLE IT_T014 WITH KEY KKBER = P_KKBER BINARY SEARCH.
    G_WAERS = IT_T014-WAERS.
    WRITE KNKK-KLIMK TO G_KLIMK_TXT CURRENCY G_WAERS.
    ELSE.
    P_FOUND_KNKK = C_FALSE.
    ENDIF.
    ENDFORM. " SELECT_KNKK
    *& Form GET_CUST_CONTACT & PHONE NUMBER
    FORM GET_CUST_CONTACT.
    CLEAR KNVK.
    C_CREDIT_ABTNR = '0003'. "look for contact in credit dept
    SELECT NAME1
    NAMEV
    TELF1
    INTO (KNVK-NAME1,
    KNVK-NAMEV,
    KNVK-TELF1)
    FROM KNVK
    WHERE KUNNR = KNA1-KUNNR AND
    ABTNR = C_CREDIT_ABTNR.
    ENDSELECT.
    If there wasn't a contact person for the credit dept, then just
    pull up the first contact info we find regardless of dept
    IF SY-SUBRC <> 0.
    CLEAR KNVK.
    SELECT NAME1
    NAMEV
    TELF1
    INTO (KNVK-NAME1,
    KNVK-NAMEV,
    KNVK-TELF1)
    FROM KNVK
    WHERE KUNNR = KNA1-KUNNR.
    IF SY-SUBRC = 0.
    EXIT.
    ENDIF.
    ENDSELECT.
    ELSE.
    EXIT.
    ENDIF. "not contact found in credit dept.
    ENDFORM. " GET_CUST_CONTACT
    *& Form LOAD_T014
    FORM LOAD_T014.
    SELECT *
    INTO TABLE IT_T014
    FROM T014.
    SORT IT_T014.
    ENDFORM. " LOAD_T014
    *& Form WRITE_CUST_INFO "TONYC
    text moved code and created a form. for cleaner code "TONYC
    --> p1 text
    <-- p2 text
    FORM WRITE_CUST_INFO.
    IF NOT REPORT_TYPE = 'super rep'.
    IF SY-TABIX > 1.
    ULINE.
    ENDIF.
    ENDIF.
    CONCATENATE GTAB-NAMEV "JAM
    GTAB-CONT_NAME1
    INTO G_CONT_NAME
    SEPARATED BY SPACE.
    FORMAT COLOR COL_TOTAL INTENSIFIED OFF.
    IF REPORT_TYPE = 'super rep'.
    IF GTAB-T_IND NE 'X'.
    WRITE: / GTAB-KUNNR, GTAB-NAME1, GTAB-ORT01, GTAB-REGIO, GTAB-LAND1,
    "g_cont_name,
    132 ONEBYTE.
    ELSE.
    WRITE: / GTAB_LINES-KUNNR, GTAB_LINES-NAME1, GTAB_LINES-ORT01, GTAB_LINES-REGIO, GTAB_LINES-LAND1,
    "g_cont_name,
    132 ONEBYTE.
    ENDIF.
    WRITE: /21 onebyte, 12 gtab-name2, 45 gtab-ort01,
    gtab-telf1, "gtab-klimk_txt, gtab-waers.
    132 onebyte.
    ELSE.
    WRITE: / GTAB-KUNNR, GTAB-NAME1, GTAB-ORT01, GTAB-REGIO, GTAB-LAND1,
    "g_cont_name, "JAM
    132 ONEBYTE.
    WRITE: /11 onebyte, 12 gtab-name2, 45 gtab-ort01,
    gtab-telf1, "gtab-klimk_txt, gtab-waers, "JAM
    132 onebyte.
    ENDIF.
    ENDFORM. " WRITE_CUST_INFO
    *& Form GET_AND_WRITE_SUPERINFO
    text
    --> p1 text
    <-- p2 text
    FORM GET_AND_WRITE_SUPERINFO.
    ULINE.
    IF GTAB-T_IND NE 'X'.
    SELECT SINGLE NAME1 FROM KNA1 INTO SUPER_NAME "TONYC
    WHERE KUNNR = GTAB-SUPER. "TONYC
    SELECT SINGLE NAME1 FROM KNA1 INTO REP_NAME "TONYC
    WHERE KUNNR = GTAB-REP. "TONYC
    CONCATENATE SUPER_NAME REP_NAME INTO REPS_INFO "TONYC
    SEPARATED BY BACKSLASH. "TONYC
    FORMAT COLOR COL_TOTAL INTENSIFIED. "TONYC
    WRITE:/ GTAB-SUPER, '/', "TONYC
    GTAB-REP, "TONYC
    25 REPS_INFO, 132 ONEBYTE. "TONYC
    ELSE.
    SELECT SINGLE NAME1 FROM KNA1 INTO SUPER_NAME
    WHERE KUNNR = GTAB_LINES-SUPER.
    SELECT SINGLE NAME1 FROM KNA1 INTO REP_NAME
    WHERE KUNNR = GTAB_LINES-REP.
    CONCATENATE SUPER_NAME REP_NAME INTO REPS_INFO
    SEPARATED BY BACKSLASH.
    FORMAT COLOR COL_TOTAL INTENSIFIED.
    WRITE:/ GTAB_LINES-SUPER, '/',
    GTAB_LINES-REP,
    25 REPS_INFO, 132 ONEBYTE.
    ENDIF.
    ENDFORM. " GET_AND_WRITE_SUPERINFO
    *& Form GET_AND_WRITE_REPINFO
    text
    --> p1 text
    <-- p2 text
    FORM GET_AND_WRITE_REPINFO.
    ULINE.
    SELECT SINGLE NAME1 FROM KNA1 INTO REP_NAME
    WHERE KUNNR = GTAB-REP.
    FORMAT COLOR COL_TOTAL INTENSIFIED.
    WRITE:/ GTAB-REP,
    25 REP_NAME, 132 ONEBYTE.
    ENDFORM. " GET_AND_WRITE_REPINFO
    *& Form WRITE_DETAIL
    text
    --> p1 text
    <-- p2 text
    FORM WRITE_DETAIL.
    clear z_description. "TONYC #2216
    move GTAB-KLIMK_TXT to z_hold_limit.
    IF z_hold_limit = 400.
    z_description = 'COD/Check'.
    elseif z_hold_limit = 500.
    z_description = 'COD/Cash'.
    elseif z_hold_limit = 600.
    z_description = 'Need Dealer Agree'.
    elseif z_hold_limit = 700.
    z_description = 'Need PDCs'.
    elseif z_hold_limit = 800.
    z_description = 'Need Fin Statements'.
    elseif z_hold_limit = 900.
    z_description = 'Past Due Balance'.
    elseif z_hold_limit = 1000.
    z_description = 'Miracle?'.
    endif. "TONYC #2216
    MOVE GTAB-GSBER TO T001-WAERS.
    FORMAT COLOR COL_TOTAL INTENSIFIED OFF.
    IF HOLD_KUNNR2 <> GTAB-KUNNR. "TONYC
    IF REPORT_TYPE = 'super rep'.
    WRITE: /3 ONEBYTE, GTAB-BUKRS.
    WRITE: 92 gtab-klimk_txt, gtab-waers, 132 onebyte. "TONYC
    WRITE: 92 gtab-klimk_txt, z_description,132 onebyte."TONYC #2500
    ELSE.
    WRITE: / ONEBYTE, GTAB-BUKRS.
    WRITE: 92 gtab-klimk_txt, z_description,132 onebyte."TONYC #2500
    WRITE: 92 gtab-klimk_txt, gtab-waers, 132 onebyte. "TONYC
    ENDIF.
    ENDIF.
    FORMAT COLOR COL_TOTAL INTENSIFIED OFF.
    IF P_KKBER = 'X'. "TONYC ISSUE# 2500
    CLEAR HOLD_KKBER_DESC.
    SELECT SINGLE KKBTX INTO HOLD_KKBER_DESC FROM T014T
    WHERE KKBER = GTAB-KKBER AND
    SPRAS = 'E'.
    IF SY-SUBRC <> '0'.
    HOLD_KKBER_DESC = 'Undetermined'.
    ENDIF.
    SELECT SINGLE KLIMK CTLPC
    INTO (HOLD_KLIMK, HOLD-CTLPC)
    FROM KNKK
    WHERE KUNNR = GTAB-KUNNR AND
    KKBER = GTAB-KKBER.
    SELECT SINGLE RTEXT INTO HOLD-CTLPC-TEXT FROM T691T
    WHERE SPRAS = 'EN' AND
    CTLPC = HOLD-CTLPC AND
    KKBER = GTAB-KKBER.
    WRITE HOLD_KLIMK TO HOLD_KLIMK2 CURRENCY GTAB-WAERS.
    WRITE: /7 GTAB-KKBER,
    12 HOLD_KKBER_DESC,
    80 HOLD_KLIMK2,
    103 GTAB-GSBER,
    108 HOLD-CTLPC-TEXT.
    ENDIF. "TONYC ISSUE# 2500
    FORMAT COLOR COL_NORMAL INTENSIFIED ON. "TONYC
    MOVE STAB-GSBER TO T001-WAERS.
    CLEAR HOLD_NAME.
    SELECT SINGLE NAME1 FROM KNA1 INTO HOLD_NAME
    WHERE KUNNR = GTAB-FILKD.
    WRITE: /15 GTAB-FILKD,
    30 HOLD_NAME.
    IF GTAB-T_IND NE 'X'.
    WRITE: /15(14) GTAB-RAST1 NO-ZERO CURRENCY T001-WAERS, ONEBYTE,
    (14) GTAB-RAST7 NO-ZERO CURRENCY T001-WAERS, ONEBYTE,
    (14) GTAB-RAST2 NO-ZERO CURRENCY T001-WAERS, ONEBYTE,
    (14) GTAB-RAST3 NO-ZERO CURRENCY T001-WAERS, ONEBYTE,
    (14) GTAB-RAST4 NO-ZERO CURRENCY T001-WAERS, ONEBYTE,
    (14) GTAB-RAST5 NO-ZERO CURRENCY T001-WAERS, ONEBYTE,
    (14) GTAB-RAST6 NO-ZERO CURRENCY T001-WAERS, ONEBYTE,
    132 ONEBYTE.
    ELSE.
    IF REPORT_TYPE NE 'super rep'.
    LOOP AT GTAB_LINES WHERE KUNNR = GTAB-KUNNR.
    WRITE: / GTAB_LINES-SUPER, ONEBYTE,
    15(14) GTAB_LINES-RAST1 NO-ZERO CURRENCY T001-WAERS, ONEBYTE,
    (14) GTAB_LINES-RAST7 NO-ZERO CURRENCY T001-WAERS, ONEBYTE,
    (14) GTAB_LINES-RAST2 NO-ZERO CURRENCY T001-WAERS, ONEBYTE,
    (14) GTAB_LINES-RAST3 NO-ZERO CURRENCY T001-WAERS, ONEBYTE,
    (14) GTAB_LINES-RAST4 NO-ZERO CURRENCY T001-WAERS, ONEBYTE,
    (14) GTAB_LINES-RAST5 NO-ZERO CURRENCY T001-WAERS, ONEBYTE,
    (14) GTAB_LINES-RAST6 NO-ZERO CURRENCY T001-WAERS, ONEBYTE,
    132 ONEBYTE.
    ENDLOOP.
    ELSE.
    WRITE: / GTAB_LINES-SUPER, ONEBYTE,
    15(14) GTAB_LINES-RAST1 NO-ZERO CURRENCY T001-WAERS, ONEBYTE,
    (14) GTAB_LINES-RAST7 NO-ZERO CURRENCY T001-WAERS, ONEBYTE,
    (14) GTAB_LINES-RAST2 NO-ZERO CURRENCY T001-WAERS, ONEBYTE,
    (14) GTAB_LINES-RAST3 NO-ZERO CURRENCY T001-WAERS, ONEBYTE,
    (14) GTAB_LINES-RAST4 NO-ZERO CURRENCY T001-WAERS, ONEBYTE,
    (14) GTAB_LINES-RAST5 NO-ZERO CURRENCY T001-WAERS, ONEBYTE,
    (14) GTAB_LINES-RAST6 NO-ZERO CURRENCY T001-WAERS, ONEBYTE,
    132 ONEBYTE.
    ENDIF.
    ENDIF.
    HOLD_BUKRS = GTAB-BUKRS. "Tonyc
    HOLD_KUNNR2 = GTAB-KUNNR. "TONYC
    HOLD_KKBER = GTAB-KKBER. "TONYC ISSUE #2500
    IF REPORT_TYPE = 'super rep' OR REPORT_TYPE = 'rep'. "DEVK939546
    IF GTAB-T_IND NE 'X'.
    MOVE-CORRESPONDING GTAB TO RTOT. "DEVK939546
    COLLECT RTOT. "DEVK939546
    ELSE.
    MOVE-CORRESPONDING GTAB_LINES TO RTOT.
    COLLECT RTOT.
    ENDIF.
    IF REPORT_TYPE = 'super rep'. "DEVK939546
    IF GTAB-T_IND NE 'X'.
    MOVE-CORRESPONDING GTAB TO STOT. "DEVK939546
    COLLECT STOT. "DEVK939546
    ELSE.
    MOVE-CORRESPONDING GTAB_LINES TO STOT.
    COLLECT STOT.
    ENDIF.
    ENDIF. "DEVK939546
    ENDIF. "DEVK939546
    ENDFORM. " WRITE_DETAIL
    *& Form convert_values
    text
    -->P_STAB_RAST1 text
    -->P_STAB_GSBER text
    FORM CONVERT_VALUES USING P_STAB_RAST1 "tonyc issue #3047 begin
    P_STAB-GSBER.
    CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
    EXPORTING
    CLIENT = SY-MANDT
    DATE = SY-DATUM
    FOREIGN_AMOUNT = P_STAB_RAST1
    FOREIGN_CURRENCY = P_STAB-GSBER
    LOCAL_CURRENCY = 'USD'
    RATE = 0
    TYPE_OF_RATE = 'M'
    READ_TCURR = 'X'
    IMPORTING
    EXCHANGE_RATE =
    FOREIGN_FACTOR =
    LOCAL_AMOUNT = P_STAB_RAST1
    LOCAL_FACTOR =
    EXCHANGE_RATEX =
    FIXED_RATE =
    DERIVED_RATE_TYPE =
    EXCEPTIONS
    NO_RATE_FOUND = 1
    OVERFLOW = 2
    NO_FACTORS_FOUND = 3
    NO_SPREAD_FOUND = 4
    DERIVED_2_TIMES = 5
    OTHERS = 6 .
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM. " convert_values

    solved

  • MacBook Pro dead, need help urgently please!

    My mac has died. It's really urgent to fix because I have a degree project to submit in 2 days! Many thanks in advance for help;
    Yesterday my mac froze up ( nothing would move appart from the cursor ). I hit the off button and my mac takes about 15-20 minutes to load up. When it does load its veeerrrryyyy sluggish and the beach ball whirls. It also popped up with a circle with a line through it, its stopped doing that since turning on and off a few times.. I tried reinstalling lion from command R at restart. This worked but didn't fully erase everything and I still have the same issue. I now can't go to the recovery menu on restart it just goes straight to log in so I am unable to fully erase everything.
    Computer specs:
    MacBook pro mid 2009 running 10.7.3 Lion.
    2.66 dual core
    8 gig ram
    320 hard drive.
    Any help would be most appreciated!!!
    Many thanks!

    James.thatcher wrote:
    I have the disc assistant on an SD connected to USB but my computer will only open it with disc utility. Is there anything I coud do?
    The program you download is meant to be downloaded and run from OS X on a working Lion Mac (not your sick one) to copy the Recovery HD Partiton of their Lion Mac to the USB thumb drive (properly formatted) then you take it to the sick Mac and can hold the option key boot off of it.
    http://osxdaily.com/2011/08/08/lion-recovery-disk-assistant-tool-makes-external- lion-boot-recovery-drives/
    Once you get your computer booted off the Recovery USB, you connect a blank external drive and install Recovery HD and OS X Lion onto that from the Recovery USB using your AppleID and password.
    Once you got that done, then you hold the option key down and boot the computer off the external drive, which the internal drive can be seen when you do Finder > Go menu > Computer and click on your internal boot drive.
    Then you open the Users folder and copy your User to the external drive your booted from.
    Once you have gotten your User folder copied off the machine, you can choose to run the comptuer off the external drive until your ready to have it fixed.
    If you can't handle all this, then call a local Mac/PC computer person to do it for you, as Apple may just replace the drive and tell you tough luck charlie, you should have made a backup.

  • Compiling error need help urgently please

    im trying to compile a java file but i get the following error:
    Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/tools/javac/Main
    and im typing in the right location of the file, and the package has been set properly, some please please please help me.

    Hiya.
    I seem to get this error message too, but there was more to it. It points out a classB i'm creating an instance of in the main() of classA, that it can't find or doesn't know where to get classB.
    The program easily works in VisualAge or in Forte, but when i tried using the command line compiler from the JDK1.3, it doesn't work right.
    They are all in the same package, and I did use the package statement to also indicate that, and they are public so that's not the problem.
    Seems, i can only compile and run programs where all the custom classes are in the same java file.
    Anybody know of a tutorial that consists of a program that uses 2 or more java files (1 custom class in each file), and then shows you how to use the command line to compile and run them?

  • Icloud help, urgent, please help

    I need to use icloud to backup my photos but it says I have 10.3 gb of stuff to back up (I only have the free 5 gb to use). I turned of icloud backup for everything on my phone except photos, which I have 2.2 gb of, but it wont work. Please help me

    You probably have a lot of texts with attachments that can't be turned off.    Those are automatically part of the backup.
    Turn on Photostream also to get your photos backed up.  The best method is to backup to your PC.

  • Files opening in unreadable code need help urgently please

    When I was given my new Toshiba laptop as a gift in 2007 Microsoft Office with Word and Excel etc were already set up so I do not have any discs or keycodes. .Being a senior person, it is also possible that my son who gifted it to me may have installed the above mentioned discs to help set me up, but he does not have any recollection of this, except that he gave me the Toshiba Recovery Disc which I do have.
    My laptop had to go back to Toshiba some time ago for a Manufacture- related issue. They also informed me that some of my files were corrupted. All features remained on my computer as prior to repair, so nothing was lost or had to be re-loaded.
    I have found that since then all my docs are opening in code form and are unreadable. Microsoft Word seems to have disappeared and I have had to install an old Microsoft Works 2001 disc in order to be able to work on new documents. Microsoft Onenote was on the disc but not Word, so the docs will not open with Onenote, so I am stuck.
    Is it possible for me to find out if Toshiba holds the keycode to my original Microsoft Office and would I be able to download it again.? I cannot afford to buy a full new Office system and I have no way of knowing which Microsoft Office ( 2007? )created the documents. I have to know if there is any way I can read these documents and also to establish which of them may be corrupted so that I can delete them. Would a system restore make the documents readable? I am very untechnical minded with regard to computers as you can observe from my wording and would really appreciate any help you can give as I cannot afford to pay someone who keeps my computer for a day or more and then charges me an extortionate amount.
    Thank you so much in advance if you can help me in any way with easy to follow instructions/advice.

    What is the model number of your laptop?
    A Trial version of MS Office may have been pre-installed. If you activated Office (Purchased a license), then you could try calling Microsoft to re-activate it.
    If you reinstall Windows using your Toshiba Recovery Disc, the Office installation should be installed. (Note that the Recovery Disc will delete your data, so back up your files first).
    Alternatively, you could use OpenOffice to read your documents. OpenOffice (free) works with Microsoft Office files.

  • Need Help Urgently please

    i'm not a Java expert but i like to think i'm not a beginner.
    I've been working on a University Project now for a week and it must be submitted tomorrow . It is a Lexical Analyzer of sorts but for some reason the program freezes and kicks out this error "java.lang.ClassNotFoundException <uncaught>"thread=main", " when i debug to find the problem. it gives no errors on compile and just freezes. i can't figure this out . if anyone can help me it would be greatly appreciated.
    Below is the code
    My email is : [email protected]
    I know the code might be a bit messy or cluttered, so i apologize ahead of time,
    package components;
    import java.io.Console;
    import java.io.InputStreamReader;
    import java.util.regex.*;
    import java.lang.*;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import java.util.Scanner;
    import java.util.ArrayList;
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.Container;
    import javax.swing.*;
    import javax.swing.filechooser.*;
    public class LA extends JPanel implements ActionListener
        static private final String newline = "\n";
        JButton OpenButton, LexButton, ExitButton, ViewLexButton, ViewSymbolButton;
        JTextArea log;
        JFileChooser fc;
        String Filepath="";
        String Filedata="";
        String Scanloc="";
        int strlength=0;
        String temp="";
        String[] reswords={"abstract","do","if","package","synchronized","boolean",
                               "double","implements","private","this","break","else","enum",
                               "import","protected","throw","byte","extends","instanceof",
                               "public","throws","case","false","int","return","transient",
                               "catch","final","interface","short","true","char","finally",
                               "long","static","try","class","float","native","strictfp",
                               "void","const","for","new","super","volatile","continue",
                               "goto","null","switch","while","default","assert"};
        String[] symbols={"+","-","%","/","*","_","(",")","[","]","{","}","||","&&",
                              "=","==","++","--","!=",">",">=","<=","<",".",",",";",":","!","<>","=>","=<","+=","-="};
        String[] symident={"PLUS","MINUS","MODULUS","DIVIDE","MULTIPLY","UNDERSCORE",
                               "OPENING ROUND BRACKET","CLOSING ROUND BRACKET",
                               "OPENING SQUARE BRACKET","CLOSING SQUARE BRACKET","OPENING CURLY BRACE",
                               "CLOSING CURLY BRACE","OR","AND","EQUALS","INSTANCE COMPARE","INCREMENT",
                               "DECREMENT","NOT EQUAL","GREATER THAN","GREATER THAN OR EQUAL TO",
                               "LESS THAN OR EQUAL TO","LESS THAN","DOT","COMMA","SEMI-COLON","COLON","NOT","NOT EQUAL",
                               "EQUAL TO OR GREATER THAN","EQUAL TO OR LESS THAN","PLUS EQUALS","MINUS EQUALS"};
        boolean state=false;
        int i=0;
        int j=0;
        boolean match=false;
        String LexToken="C:\\LexToken.txt";
        String SymTable="C:\\SymbolT.txt";
        String Lexstring="";
        String SymbolTableString=" Symbol |   Kind  | Type \n";
        ArrayList<String> wordarray=new ArrayList<String>();
        String[] temparray1;
        String REPat="";
        public LA()
            super(new BorderLayout());
            log = new JTextArea(20,40);
            log.setMargin(new Insets(5,5,5,5));
            log.setEditable(false);
            JScrollPane logScrollPane = new JScrollPane(log);
            fc = new JFileChooser();
            OpenButton = new JButton("Open a File");
            OpenButton.addActionListener(this);
            ExitButton = new JButton("Exit");
            ExitButton.addActionListener(this);
            LexButton = new JButton("Analyze Lexically");
            LexButton.addActionListener(this);
            ViewLexButton = new JButton("View Token/Lexeme Table");
            ViewLexButton.addActionListener(this);
            ViewSymbolButton = new JButton("View Symbol Table");
            ViewSymbolButton.addActionListener(this);
            JPanel buttonPanel = new JPanel(); //use FlowLayout
            buttonPanel.add(OpenButton);
            buttonPanel.add(LexButton);
            buttonPanel.add(ViewLexButton);
            buttonPanel.add(ViewSymbolButton);
            buttonPanel.add(ExitButton);
            add(buttonPanel, BorderLayout.PAGE_START);
            add(logScrollPane, BorderLayout.CENTER);
        public static String StoreAsString(String FileName)throws Exception
                 FileInputStream fis = new FileInputStream(FileName);
              int x= fis.available();
              byte b[]= new byte[x];
              fis.read(b);
              String content = new String(b);
              return content;
         public static void FileWrite(String filename,String Message)throws IOException
              try
              FileWriter fileWriter = new FileWriter(filename);
              BufferedWriter buffWriter = new BufferedWriter(fileWriter);
              buffWriter.write(Message);
              buffWriter.close();
              fileWriter.flush();
              fileWriter.close();
              catch(IOException e)
              System.out.println("Exception "+ e.getMessage());
         public boolean TestForResWord(int val)
              char marker=' ';
              for(i=0;i<reswords.length;i++)
                     if(reswords==wordarray.get(val))
                   i=reswords.length+1;
                   marker='Y';
         else
                   marker='N';
              if(marker=='Y')
                   return true;
              else
                   return false;
         public boolean patmatch(String patstr)
         Pattern pattern= Pattern.compile(patstr);
              Matcher matcher= pattern.matcher(temparray1[j]);
              boolean temp=false;
              temp=matcher.find();
              if (temp=true)
                   return true;
              else
                   return false;
    public void actionPerformed(ActionEvent e)
    try
              if (e.getSource() == OpenButton)
         int returnVal = fc.showOpenDialog(LA.this);
         if (returnVal == JFileChooser.APPROVE_OPTION)
         File file = fc.getSelectedFile();
         Filepath = new String(file.getPath());
         log.append("Opening: " + file.getName() + "." + newline);
         log.append(Filepath + newline);
         Filedata=StoreAsString(Filepath);
         log.append(Filedata);
    else
    log.append("Open command cancelled by user." + newline);
         else if (e.getSource() == LexButton)
         //int answer = JOptionPane.showConfirmDialog(null,"Are you ready to analyze Lexically?");
              //          if (answer == JOptionPane.YES_OPTION)      // User clicked YES.
                             log.setText("");
                   try
                        FileReader rd = new FileReader(Filepath);      // Create the tokenizer to read from a file
                        StreamTokenizer st = new StreamTokenizer(rd);
                        int linenum=0;
                        int colnum=0;
                        st.parseNumbers();           // Prepare the tokenizer for Java-style tokenizing rules
                        st.wordChars('_', '_');
                        st.eolIsSignificant(true);
                        // If whitespace is not to be discarded, make this call
                        st.ordinaryChars(0, ' ');
                        // These calls caused comments to be discarded
                        st.slashSlashComments(true);
                        st.slashStarComments(true);
                        // Parse the file
                        int token = st.nextToken();
                        while (token != StreamTokenizer.TT_EOF)
                        token = st.nextToken();
                             switch (token)
                                  case StreamTokenizer.TT_NUMBER:
                                  // A number was found; the value is in nval
                                  double num = st.nval;
                                  linenum=st.lineno();
                                  temp=String.valueOf(num);
                                  strlength=temp.length();
                                  Lexstring=Lexstring+"\nLine : "+linenum+" |Column : "+colnum+" |Token: "+num+" |Lexeme: NUMBER";
                                  colnum=colnum+strlength;
                                  break;
                                  case StreamTokenizer.TT_WORD:
                                  // A word was found; the value is in sval
                                  //String[] wordarray;
                                  boolean match=false;
                                  String word = st.sval;
                                  int z=0;
                                  if(z==0)
                                       wordarray.add(0,word);
                                       z++;
                                  linenum=st.lineno();
                                  char[] characters=word.toCharArray();
                             for(int x=0;x<characters.length;x++)
                                       for (int y=0;y<symbols.length;y++)
                                            String tempword="";
                                            tempword=tempword+characters[x];
                                            while((z>=1)&&(x<=characters.length))
                                            if (tempword==symbols[y])
                                                 if((((characters[x]=='+')||(characters[x]=='-')||(characters[x]=='='))&&((wordarray.get(0+z-1)=="+")||(wordarray.get(0+z-1)=="-")||(wordarray.get(0+z-1)=="=")))||(tempword==wordarray.get(0+z-1))||(((tempword=="=")&&(wordarray.get(0+z-1)=="<"))||((tempword=="=")&&(wordarray.get(0+z-1)==">"))||((tempword==">")&&(wordarray.get(0+z-1)=="="))||((tempword=="<")&&(wordarray.get(0+z-1)=="="))||((tempword==">")&&(wordarray.get(0+z-1)=="<")) ) )
                                                      wordarray.add(0+z,wordarray.get(0+z)+characters[x]);
                                                 else
                                                 z++;//NOT SURE ABOUT THIS INCREMENT
                                                 wordarray.add(0+z,""+characters[x]);
                                                 z++;
                                       wordarray.add(0+z,wordarray.get(0+z)+characters[x]);
                             while(state=false)
                                  overhere:                                                                       
                                                      for(j=0;j<wordarray.size();j++)
                                       String[] temparray1=(String[])wordarray.toArray();
                                  temp=temparray1[j];
                                       strlength=temp.length();
                                  if(strlength>1)
                                  REPat="[\\W]";
                                  match=patmatch(REPat);     
                                  if(match=false)
                                  for(i=0;i<reswords.length;i++)
                                       if(reswords[i]==wordarray.get(j))
                                            String lexemestr=reswords[i].toUpperCase();
                                            Lexstring=Lexstring+"\nLine : "+linenum+" |Column : "+colnum+" |Token: "+wordarray.get(j)+" |Lexeme: OP_"+lexemestr;
                                            colnum=colnum+strlength;
                                            i=reswords.length+1;
                                            j++;
                                            break overhere;
                                  REPat="[(?i)[a-z][\\w*]*]";
                                  match=patmatch(REPat);
                                  if(match=true)
                                       boolean test1=false;
                                            test1=TestForResWord(j-1);
                                       boolean test2=false;
                                            test2=TestForResWord(j-2);
                                       boolean test3=false;
                                            test3=TestForResWord(j-3);
                                       String[] temparray2=(String[])wordarray.toArray();
                                  temp=temparray2[j];
                                       strlength=temp.length();
                                       Lexstring=Lexstring+"\nLine : "+linenum+" |Column : "+colnum+" |Token: "+temp+" |Lexeme: VARIABLE";
                                       if(((test1==true)&&(test2==true)&&(test3==true))||((test1==true)&&(test2==true)&&(test3==false)))
                                            SymbolTableString=SymbolTableString+" "+temp+" | Method | "+wordarray.get(j-1)+"\n";
                                       else if((test1==true)&&(test2==false)&&(test3==false))
                                            SymbolTableString=SymbolTableString+" "+temp+" | Variable | "+wordarray.get(j-1)+"\n";
                                       colnum=colnum+strlength;
                                       i=reswords.length+1;
                                  else if(match=false)
                                  String[] temparray3=(String[])wordarray.toArray();
                                  temp=temparray3[j];
                                  strlength=temp.length();
                                  Lexstring=Lexstring+"\nLine : "+linenum+" |Column : "+colnum+" |Token: "+temp+" |Lexeme: INVALID_WORD";
                                  colnum=colnum+strlength;
                                  i=reswords.length+1;
                                  else
                                  for(i=0;i<symbols.length;i++)
                                            if(symbols[i]==wordarray.get(j))
                                            Lexstring=Lexstring+"\nLine : "+linenum+" |Column : "+colnum+" |Token: "+wordarray.get(j)+" |Lexeme: OP_"+symident[i];
                                            colnum=colnum+strlength;                                    
                                            i=symbols.length+1;
                                  else if(strlength==1)
                                       for(i=0;i<symbols.length;i++)
                                            if(symbols[i]==wordarray.get(j))
                                            Lexstring=Lexstring+"\nLine : "+linenum+" |Column : "+colnum+" |Token: "+wordarray.get(j)+" |Lexeme: OP_"+symident[i];
                                            colnum=colnum+strlength;                                    
                                            i=symbols.length+1;
                                            else
                                            boolean test1=false;
                                            test1=TestForResWord(j-1);
                                       boolean test2=false;
                                            test2=TestForResWord(j-2);
                                       boolean test3=false;
                                            test3=TestForResWord(j-3);
                                            Lexstring=Lexstring+"\nLine : "+linenum+" |Column : "+colnum+" |Token: "+wordarray.get(j)+" |Lexeme: VARIABLE";
                                            if(((test1==true)&&(test2==true)&&(test3==true))||((test1==true)&&(test2==true)&&(test3==false)))
                                                      SymbolTableString=SymbolTableString+" "+temp+" | Method | "+wordarray.get(j-1)+"\n";
                                            else if((test1==true)&&(test2==false)&&(test3==false))
                                                      SymbolTableString=SymbolTableString+" "+temp+" | Variable | "+wordarray.get(j-1)+"\n";
                                            colnum=colnum+strlength;
                                            i=symbols.length+1;     
                                                      if(wordarray.size()>=j)
                                       state=true;
                                  //colnum=colnum+strlength;
                                  break;
                                  case '"':
                                  // A double-quoted string was found; sval contains the contents
                                  String dquoteVal = st.sval;
                                  linenum=st.lineno();
                                  strlength=dquoteVal.length();
                                  colnum=colnum+strlength;
                                  break;
                                  case '\'':
                                  // A single-quoted string was found; sval contains the contents
                                  String squoteVal = st.sval;
                                  linenum=st.lineno();
                                  strlength=squoteVal.length();
                                  colnum=colnum+strlength;
                                  break;
                                  case StreamTokenizer.TT_EOL:
                                  // End of line character found
                                  colnum=0;
                                  break;
                                  case StreamTokenizer.TT_EOF:
                                  // End of file has been reached
                                  break;
                                  default:
                                  // A regular character was found; the value is the token itself
                                  char ch = (char)st.ttype;
                                  break;
                                  rd.close();
                        catch (IOException ex)
                             System.err.println("Exception with file! "+ex.getMessage());
                             log.append("Lexical Analysis Complete");
                   //     else if (answer == JOptionPane.NO_OPTION)      // User clicked NO.
         //          log.append("Analyze command decided against by user." + newline);
              //          else if (answer == JOptionPane.CANCEL_OPTION)      // User clicked CANCEL.
         //          log.append("Analyze command cancelled by user." + newline);
         FileWrite(LexToken,Lexstring);
         FileWrite(SymTable,SymbolTableString);
         else if (e.getSource() == ViewLexButton)
              log.setText("");
              Filedata=StoreAsString("C:\\LexToken.txt");
              log.append(Filedata);
              log.append("LexToken.txt has been stored at C:\\LexToken.txt");
    else if (e.getSource() == ViewSymbolButton)
              log.setText("");
              Filedata=StoreAsString("C:\\SymbolT.txt");
              log.append(Filedata);
              log.append("SymbolT.txt has been stored at C:\\SymbolT.txt");
    else if (e.getSource() == ExitButton)
    System.exit (0);
    catch(FileNotFoundException ex)
                   System.err.println("File not found! "+ex);
         catch(IOException ex)
                   System.err.println("Exception with file! "+ex);
         catch(Exception ex)
                   System.err.println("Exception with file! "+ex);
    /** Returns an ImageIcon, or null if the path was invalid. */
    protected static ImageIcon createImageIcon(String path)
    java.net.URL imgURL = LA.class.getResource(path);
    if (imgURL != null) {
    return new ImageIcon(imgURL);
    } else {
    System.err.println("Couldn't find file: " + path);
    return null;
    private static void createAndShowGUI()
    //Create and set up the window.
    JFrame frame = new JFrame("LA");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    //Create and set up the content pane.
    JComponent newContentPane = new LA();
    newContentPane.setOpaque(true); //content panes must be opaque
    frame.setContentPane(newContentPane);
    //Display the window.
    frame.pack();
    frame.setVisible(true);
    public static void main(String[] args)throws IOException
    // javax.swing.SwingUtilities.invokeLater(new Runnable()
    // public void run()
    createAndShowGUI();

    I started to look at that code and saw that massive if statement and decided this was far too messy for me to waste my time on. That being said, I still have some recommendations.
    First, I have a question: How are you debugging this? What are you doing to try to identify where your hang-up is occurring? Have you tried anything yourself yet, or is this your first attempt?
    Second, my recommendation would be to add a few System.out.println() statements in that mess of for/while loops that you have to see how far into them you're getting and when/if you're ever exiting them. Once you don't get to one of those print statements, then you will know where you're buggered.
    So why don't you take a little time and try to narrow your code down to a block or two to see where you're problems are coming from. Then you can come back and give us a place to look, because - quite frankly - no one here is going to want to sift through that mess of code.
    Good luck.

  • Sql help - URGENT update info

    I ran a query to find 1)the current distribution group and corresponding account id number and 2) the historical distribution group and corresponding account id number from checks written in contract year 2008.
    Here is the sql statement from my query:
    SELECT EMPLOYEE_MASTER.EMPLOYEE_NO, EMPLOYEE_DISTRIBUTIONS.DISTRIBUTION_GROUP, EMPLOYEE_DISTRIBUTIONS.ACCOUNT_ID, PAYS_HISTORY.DISTRIBUTION_GROUP, ACCOUNT_HISTORY.ACCOUNT_ID, ACCOUNT_HISTORY.CHECK_KEY
    FROM HRS.ACCOUNT_HISTORY ACCOUNT_HISTORY, HRS.EMPLOYEE_DISTRIBUTIONS EMPLOYEE_DISTRIBUTIONS, HRS.EMPLOYEE_MASTER EMPLOYEE_MASTER, HRS.PAYS_HISTORY PAYS_HISTORY
    WHERE EMPLOYEE_DISTRIBUTIONS.EMPLOYEE_NO = EMPLOYEE_MASTER.EMPLOYEE_NO AND PAYS_HISTORY.EMPLOYEE_NO = EMPLOYEE_MASTER.EMPLOYEE_NO AND ACCOUNT_HISTORY.CHECK_KEY = PAYS_HISTORY.CHECK_KEY AND ((PAYS_HISTORY.CONTRACT_YEAR=2008) AND (ACCOUNT_HISTORY.TRANSACTION_TYPE='GRS'))
    What I need to do now is update the distribution_group from the pays_history to match the distribution_group from the employee_distribution where the account_id is the same as the account_history.account_id.
    Any ideas?
    Thanks!

    Are you asking me to create an update statement? Isn't it you want to achieve ?
    If I could I wouldn't have posted here! (smiling)Yes, learning is made by tries and errors.
    Your statement not so bad ;-)
    So what about (with forum tags usage for post readability) :
    &#091;pre&#093;Update hrs.pays_history ph
    set    distribution_group = (select ed.distribution_group
                                 from   hrs.employee_distributions ed
                                 where  ph.employee_no   = ed.employee_no
                                 and    ph.account_id    = ed.account_id
                                 and    ph.contract_year = 2008)
    where exists (select  null
                   from   hrs.employee_distributions ed
                   where  ph.employee_no   = ed.employee_no
                   and    ph.account_id    = ed.account_id
                   and    ph.contract_year = 2008)&#091;/pre&#093;
    Not sure about the requirements, but at least that should run.
    Nicolas.

  • Pl/sql(help me please)

    I have a problem.
    When I read from a file I must respect the following rules:
    The only characters admitted are :
    Number: from 0 till 9
    Alphanumeric:
    Blank and A....Z (capital letters).
    (The not capital letters and the letters with accent are deleted.)
    The special letters: ! ‘’ % $ & ’ ( ) * +, - . / : ; < = > ?
    All the others characters will be replaced by blanks.
    How could I realize,easily this thing.
    Yours,
    Virginia

    declare
    abc VARCHAR2(1000);
    in_file utl_file.file_type;
    BEGIN
    in_file :=utl_file.fopen('TEST_DIR','test.txt','R');
    loop
      utl_file.get_line(in_file,abc);
      dbms_output.put_line('Line:'||abc);
      abc := translate(abc,trim(translate(abc,'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!"%$',' ')),' ');
      dbms_output.put_line(abc);
      exit when abc is null;
    end loop;
      utl_file.fclose(in_file);
    EXCEPTION
    when no_data_found then
      null;
    END ;
    Line:abc.?
    abc
    Line:+-/def.abc
    defabc
    Line:ghi/*+12345
    ghi 12345
    PL/SQL procedure successfully completed.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Maybe you are looking for

  • Unable to resolve error while creating a maintenance project for SMD

    Hi, I am getting an error when I try to create a maintenance project for SMD 331- SMD 341 - SMD 351 systems. ( SMD 331- Development, SMD 341- Test, SMD 351- Production ) SMD is 4.0 upgraded system. Detailed description of the problem: In SOLAR_PROJEC

  • How to search for a document

    Hi I am uploading document in KM. But when i am updating i assigning custom property country to some specified courties. How can I filter those documents depending on the country? For Example, When i am uploading the document, i have country property

  • Grr... please someone help me and stop me going mad!!!

    I've just got a 160gb apple tv and running a macbook so all is good in the apple household, that is until i try and sync my movies or anything thing in itunes over to the apple tv, stream works but as soon as i log out of computer poof everythings go

  • AF_UNIX socket with java

    Is there any way to use unix domain sockets with java ? Is it level of socket abstraction implementation to high ? I guess it's not possible to use such functionality without JNI, but if so i'll be very happy. If it's not possible to do it without JN

  • HT5622 Apple ID and password don't work on iTunes!

    My apple ID and password are rejected on itunes, but works elsewhere... why? Help!