Logic needed for increment value

HI,
This function returns me if i pass 'ABC01' it will return 'ABC02' like if i pass
'ABC55' it will return 'ABC56'.
But my requirment is i need to pass value from 01 to 99.
so if i pass 'ABC99' it sud return ''ABC01'.
so the sequence is from 01 to 99.And after 99 it will again start from 01.
create or replace function get_next_value
string_1 in varchar2
return varchar2
as
v_string_1 number(10);
v_string_2 varchar2(10);
begin
select to_number(substr(string_1,4))+1 into v_string_1 from dual;
if length(v_string_1)=1 then
v_string_2:=substr(string_1,1,4)||v_string_1;
return v_string_2;
else
v_string_2:=substr(string_1,1,3)||v_string_1;
return v_string_2;
end if;
end;
test sript
select get_next_value('ABC01') from dual
select get_next_value('ABC55') from dual
Thanks,
Lony

create or replace function get_next_value
string_1 in varchar2
return varchar2
as
v_string_1 number(10);
v_string_2 varchar2(10);
begin
select to_number(substr(string_1,4))+1 into v_string_1 from dual;
if length(v_string_1)=1 then
v_string_2:=substr(string_1,1,4)||v_string_1;
return v_string_2;
else
v_string_2:=substr(string_1,1,3)||v_string_1;
if v_string_1 = 100 then
   return substr(string_1,1,3)||'01';
end if;
return v_string_2;
end if;
end;
select get_next_value('ABC01') from dual;
select get_next_value('ABC99') from dual;
GET_NEXT_VALUE('ABC01')                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
ABC02                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
1 rows selected
GET_NEXT_VALUE('ABC99')                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
ABC01

Similar Messages

  • Logic needed for dynamic report

    Hi Experts,
    I have made a dynamic report where my logic is if the value of the columns is 0 than it should be blank and if the columns of the stores have some value for eg: 01 than it should populate the same store.
    The logic goes like :
    for matnr     01store 02 store
                                             01       100.00          0.00
                                             02          00              00
                                             03       50.00           13.00
    than the output should be
    matnr     01store 02 store
                                             01           01store       
                                             02        
                                             03           01store    02 store
    I have made the logic but all the lines are getting appended
    it_field_dynamic1-fieldname = 'MATNR'.
        it_field_dynamic1-desc      = 'ARTICLE'.
        it_field_dynamic1-reffield = 'MATNR'.
        it_field_dynamic1-reftab   = 'MBEW'.
        it_field_dynamic1-seq =  1.
        COLLECT it_field_dynamic1.
        CLEAR wa_itab.
        LOOP AT itab INTO wa_itab. "WHERE SALK3 NE '0.00'.
          it_field_dynamic1-fieldname = wa_itab-bwkey.
          it_field_dynamic1-desc      = wa_itab-bwkey.
    *    IF WA_ITAB-SALK3 NE '0.00'.
    *    it_field_dynamic1-reffield = wa_itab-bwkey.
    *    ENDIF.
          it_field_dynamic1-reftab   = 'MBEW'.
          it_field_dynamic1-seq =  1.
          COLLECT it_field_dynamic1.
          CLEAR wa_itab.
        ENDLOOP.
        LOOP AT it_field_dynamic1.
          wa_alv_cat1-fieldname = it_field_dynamic1-fieldname.
          wa_alv_cat1-col_pos    = sy-tabix.
          wa_alv_cat1-ref_field = it_field_dynamic1-reffield.
          wa_alv_cat1-ref_table = it_field_dynamic1-reftab.
          wa_alv_cat1-seltext   = it_field_dynamic1-desc.
          COLLECT wa_alv_cat1 INTO lt_alv_cat1 .
          CLEAR wa_alv_cat1 .
    *    APPEND wa_alv_cat TO lt_alv_cat .
        ENDLOOP.
        IF NOT lt_alv_cat1[] IS INITIAL .
    * Create Dynamic Table -> i_table
          CALL METHOD cl_alv_table_create=>create_dynamic_table
            EXPORTING
              it_fieldcatalog = lt_alv_cat1
            IMPORTING
              ep_table        = i_table1.
          ASSIGN i_table1->* TO <table1> .
    * Create dynamic work area and assign to FS
          CREATE DATA i_struct1 LIKE LINE OF <table1>.
          ASSIGN i_struct1->* TO <struc1>.
        ENDIF.
        DATA: l_row TYPE sy-index.
        FIELD-SYMBOLS: <ls_table> TYPE ANY.
        FIELD-SYMBOLS: <l_field> TYPE ANY.
        DATA: wa_dref1 TYPE REF TO data.
        FIELD-SYMBOLS: <wa_tab1> TYPE ANY.
        CREATE DATA wa_dref1 LIKE LINE OF <table1>.
        ASSIGN wa_dref1->* TO <wa_tab1>.
        FIELD-SYMBOLS: <fs1>, <fs2>.
    *  DATA: wa_dref1 TYPE REF TO data.
    *  FIELD-SYMBOLS: <wa_tab1> TYPE ANY.
        CREATE DATA wa_dref1 LIKE LINE OF <table1>.
        ASSIGN wa_dref1->* TO <wa_tab1>.
        CLEAR : wa_matnr, wa_itab.
       LOOP AT imatnr INTO wa_matnr.
    *clear: wa_itab-bwkey.
    *      CLEAR: wa_itab.
          LOOP AT itab INTO wa_itab WHERE matnr = wa_matnr-matnr.
    *        CLEAR: wa_itab-bwkey.
            IF wa_itab-salk3 EQ '0.00'.
              CLEAR: wa_itab-bwkey .
            ELSE.
            ASSIGN COMPONENT wa_itab-bwkey OF  STRUCTURE <wa_tab1> TO <fs1>.
              IF sy-subrc =  0 . "AND WA_ITAB-SALK3 NE '0.00'.
                <fs1> = wa_itab-bwkey.
              ENDIF.
            ENDIF.
    *ON  CHANGE OF WA_ITAB-MATNR.
            ASSIGN COMPONENT 'MATNR' OF  STRUCTURE <wa_tab1> TO <fs2>.
            IF sy-subrc =  0.
    *      ON CHANGE OF wa_itab-matnr.
              <fs2> = wa_itab-matnr.
    *      ENDON.
            ENDIF.
    *      APPEND <wa_tab1> TO <table1>.
          ENDLOOP.
           APPEND <wa_tab1> TO <table1>.
          CLEAR : wa_ltab.
        ENDLOOP.
    than i have called the alv grid display
    Please let me know.
    Thanks,
    Nikhil.

    Hi Oliver,
    My current output is:
    for                                  
    matnr     01store 02 store
                                                      01         100.00         0.00
                                                       02          00              00
                                                       03       50.00           13.00
                                            matnr    01store   02 store
                                             01       01store         
                                             02       01store            
                                             03       01store
    but for matnr 02,  01 store has 0 value hence it should come blank but its appending from the first line and populating 01store for material 2.
    Thanks & Regards,
    Nikhil.

  • Fail safe logic needed for purchase order upload program

    Hello all,
    i am working on creating PO's by reading data from a text file. I need to implement fail safe logic in it, which is to make sure this program uploads all the records in the text file successfully. For example, i have 1000 records in my text file and while running the upload program if the program times out while creating the 500th PO or if SAP is down at that time, then we have 499 PO's created and 501 yet to be created. But if we run the same program again, we will generate duplicate PO's for 499 again. I want to avoid this kind of problem.
    How do i implement this idea?
    Kindly guide me on this.
    Thanks.

    Ok ..
    Then I would suggest you use Application Log to keep the success and error messages of PO processing.
    You can check trsnaction SLG0 and create your own application log object.
    Then you need to use FMs BAL_LOG_* to crate and add messages to it.
    This way you will have a facility to check as which of your records are converted to PO for a run.
    In case SAP gets down in between , still you can find the details using Xn SLG1 and then accordingly remove the records from your file which are already converted to PO.
    Thanks,
    Ram

  • Logic needed for report: Parameter Group

    hi..friends,
    im dev a report: refernce std report - "S_ALR_87012178" is the tcode.  there they are giving 5 slabs: ie. under 'Output control Sel Scrn - in "Due date sorted List" '. but my requirement is to do same like that for 10 slabs.
    the values are dynamic. Accordingly we should display the amount falling in that specified period.
    i hav already fetched the data. but to display them, i hav struck.
    how to access the input and print them.
    i hav to use alv hierarchical seq display format.
    My decl:
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 01(30) text-050 for field p_slab1.
    SELECTION-SCREEN POSITION POS_LOW.
    PARAMETERS: p_slab1 LIKE rfpdo1-allgrogr OBLIGATORY DEFAULT '15',
                p_slab2 LIKE rfpdo1-allgrogr OBLIGATORY DEFAULT '30',
                p_slab3 LIKE rfpdo1-allgrogr OBLIGATORY DEFAULT '45',
                p_slab4 LIKE rfpdo1-allgrogr OBLIGATORY DEFAULT '60',
                p_slab5 LIKE rfpdo1-allgrogr OBLIGATORY DEFAULT '75',
                p_slab6 LIKE rfpdo1-allgrogr OBLIGATORY DEFAULT '90',
                p_slab7 LIKE rfpdo1-allgrogr OBLIGATORY DEFAULT '115',
                p_slab8 LIKE rfpdo1-allgrogr OBLIGATORY DEFAULT '130',
                p_slab9 LIKE rfpdo1-allgrogr OBLIGATORY DEFAULT '145'.
    SELECTION-SCREEN END OF LINE.
    suggest me logic pls.
    regards,
    Padmashree.

    Hi,
    Try out this.
    declare all the parameters in the block.
    selection-screen begin of block b2 with frame .
    parameter:  declare all the parameters.
    selection-screen end of block b2.
    hope it may help you.

  • Logic need for my selection screen

    Hi,
    i designed my selection screen
    PARAMETERS:
      rb_alv   RADIOBUTTON GROUP g2,                                                        " Radio 1
      rb_pc    RADIOBUTTON GROUP g2,                                                        " Radio 2
      rb_unix  RADIOBUTTON GROUP g2.                                                        " Radio 3
    *File path
    PARAMETERS: pa_ftxt TYPE rlgrap-filename.
    Below isMy requirement is :How to do it???please help
    Do not hard-code the directory output for Unix. Just make sure the selection logic checks to make sure a value exists in the path field if either download option (pc/unix) is set). For the PC default, use u2018c:\temp\veninfo.txtu2019 as a constant.
    Thanks
    asis

    PARAMETERS:
    rb_alv RADIOBUTTON GROUP g2 user-command 'RAD', " Radio 1
    rb_pc RADIOBUTTON GROUP g2, " Radio 2
    rb_unix RADIOBUTTON GROUP g2. " Radio 3
    *File path
    PARAMETERS: pa_ftxt TYPE rlgrap-filename.
    at selection-screen output.
    if rb_pc = 'X'.
    pa_ftxt = 'c:\temp\veninfo.txt'.
    else.
    clear pa_ftxt.
    endif.
    at selection-screen on value request for pa_ftxt.
    CALL FUNCTION 'F4_DXFILENAME_TOPRECURSION'
    EXPORTING
    i_location_flag = 'A'
    i_server = ' '
    i_path = ' ' "here you can give the path of the server directory
    IMPORTING
    o_path = l_path
    abend_flag = l_abend_flag
    EXCEPTIONS
    communication_failure = 1
    system_failure = 2
    rfc_error = 3.
    IF sy-subrc EQ 0.
    p_file = l_path.        "This gives you the path
    ENDIF.
    IF l_abend_flag = 'X'.
    EXIT.
    else.
    Move l_path to your screen field pa_ftxt.
    ENDIF.

  • Logic Needed for MM Report with PR, PO, GR and Invoice details

    Hi Experts,
    We need to provide a list of below details as columns.
    PR, PR creation date, PO, PO creation date, GR, GR creation date, Invoice and Invoice creation date.
    Now on the selection screen we'll have Date range. If I give the dat range as 01.01.2011 to 31.12.2011, then the list should be displaying all the details. However, it should first check Invoices in that date range and mention the related details. If there are some GRs (for which invoice is not yet created) for that year, then the related details (PR, PO and GR) of that GR are to be shown. For POs (for which GR itself is not yet created), again details are to be shown (PR and PO details).
    Can somebody help me in getting this done in some simpler way? I am thinking of fetching the data from the respective tables for this date range and then from invoice i will be printing and then deleting the corresponding GR, PO and PR. Then will be checking GR , printing the details and deleting corresponding PR and PO.. and so on. But I felt this not that great.
    Can anyone suggest some other logic or provide some inputs?
    Thanks.

    Hi,
    As per your requirement you can cross the tables i.e. BSET,RSEG,RBKP(For Invoice Header n Item Details).Then now go to the MKPF,MSEG tables (For MIGO Details) and EBAN,EKKO,EKPO(For Purchase Requsitions,Orders Details).... Consider BUDAT as  a selection date among the tables RSEG,MKPF,EKKO.
    Regards,
    Rickky

  • Logic needed for the following data

    Hi All,
    I have procedure in that I am calling a cursor to fetch the records. This query is returning the following data
    DI
    SZ
    DII
    CWT
    Top
    down
    9 1/2
    9.625
    8.921
    36
    18
    1602
    13 1/2
    13.375
    12.515
    61
    19
    1962
    18 1/2
    18.625
    17.755
    87.5
    20
    503
    26
    26
    24.75
    105
    20
    103
    9 1/2
    9.625
    8.835
    40
    1602
    3858
    7
    7
    6.276
    26
    1683
    6352
    I want to  print just these values ..
    9 1/2
    9.625
    8.921
    36
    18
    1602
    9 1/2
    9.625
    8.835
    40
    1602
    3858
    7
    7
    6.276
    26
    1683
    6352
    As you can see in these values top and down are overlapping.
    I tried several ways to sort the query on the fields and have some logic, but I am always getting one row extra which is not overlapping.
    Can someone please give me the logic to get the desired result through conditions in Procedure/function/package
    Thanks

    BrendanP wrote:
    26    AND t.top
    "AND t.top....."... what?
    Here's another solution, giving the least overlap over the greatest distance...
    SQL> ed
    Wrote file afiedt.buf
      1  with data as (select 1 id , 18 top, 1602 down from dual union all
      2                select 2,19, 1962 from dual union all
      3                select 3,20, 503 from dual union all
      4                select 4,20, 103 from dual union all
      5                select 5,1602, 3858 from dual union all
      6                select 6,1683, 6352 from dual
      7               )
      8  -- -------------------------------------------------------
      9  -- END OF TEST DATA JUST USE QUERY BELOW AGAINST OWN TABLE
    10  -- -------------------------------------------------------
    11      ,idealpath as (
    12         select id, path, idpath
    13         from (
    14               select id, path, idpath, cmlt_diff, min_diff, cvrg, max_cvrg
    15               from  (
    16                      select x.id
    17                           ,x.path
    18                           ,idpath
    19                           ,to_number(y.column_value) as cmlt_diff
    20                           ,min(to_number(y.column_value)) over (partition by cvrg) as min_diff
    21                           ,cvrg
    22                           ,max(cvrg) over () as max_cvrg
    23                     from (
    24                           select connect_by_root(id) as id
    25                                 ,down-connect_by_root(top) as cvrg
    26                                 ,ltrim(sys_connect_by_path(prior down-top,'+'),'+') as cmlt_diff
    27                                 ,ltrim(sys_connect_by_path(top||'-'||down,':'),':') as path
    28                                 ,ltrim(sys_connect_by_path(id,':'),':') as idpath
    29                           from   data
    30                           where connect_by_isleaf = 1
    31                           connect by nocycle top between prior top and prior down
    32                                      and not down between prior top and prior down
    33                          ) x
    34                          ,xmltable(nvl(cmlt_diff,'0')) y
    35                    )
    36               where cvrg = max_cvrg
    37              )
    38         where cmlt_diff = min_diff
    39        )
    40  --
    41  select d.id, d.top, d.down
    42  from   data d
    43        ,(select level l, to_number(regexp_substr(idpath,'[^:]+',1,level)) as id
    44          from   idealpath
    45          connect by regexp_substr(idpath,'[^:]+',1,level) is not null) bp
    46  where  bp.id = d.id
    47* order by bp.l
    SQL> /
            ID        TOP       DOWN
             1         18       1602
             2         19       1962
             6       1683       6352

  • Logic need for currency calculation

    Hi All,
    Can u pleae help me out to solve this requirement?
    Sample code below;
    1 declare
    2 CURSOR C1 IS SELECT * FROM TEST2;
    3 begin
    4 DBMS_OUTPUT.PUT_LINE('From Currency'||' '||'To Currency'||' '||'Rate:');
    5 FOR C2 IN C1 LOOP
    6 DBMS_OUTPUT.PUT_LINE(c2.from_currency||' '||c2.to_currency||' '||c2.rate);
    7 END LOOP;
    8* end;
    SQL> /
    From Currency To Currency Rate:
    GBP INR 75.1371
    GBP AUD 1.5342
    GBP USD 1.57291
    Based on this i need to derive all the permutations and Combination of other currencie like INR to AUD,INR to USD,etc...
    Please any one come across through such requirement Please help me to solve this requiremen.
    Regards
    Raaghavendra

    Hello,
    Is it what you need ?
    with t as
    (select 'GBP' fromCur ,'INR' ToCurr, 75.1371 rate from dual union all
    select 'GBP', 'AUD' ,1.5342 from dual union all
    select 'GBP', 'USD', 1.57291 from dual)
    select  t1.tocurr as calc_fromcurr,
            t2.tocurr as calc_tocurr,
            t2.rate/t1.rate as calc_rate
    from t t1, t t2
    where t1.tocurr!=t2.tocurr;regards,
    Sylvie

  • Logic needed for FI BDC

    Hi ,
    I ned to write Bdc for the FI transaction f-53. In that BDC various entry is uploaded in trnsaction thr flat file . After Upload Document No is generted and it should stored in the excel file and at the last col of th flat file .
    How to do this . I have no clue for thsi . How to capture valus of document no which is genrated ,
    Thanks

    You can also use parameter ID 'BLN' if you are calling individual transactions. Some variants of the FI transactions will use different success messages, so if you use a common routine for the call, you'll definitely want to use this approach instead of hardcoding message numbers and fields to read. 
    Before the call:
    SET PARAMETER ID 'BLN' FIELD SPACE.
    CLEAR GV_BELNR.
    After the call, insert the proper error handling and for successful calls:
    GET PARAMETER ID 'BLN' FIELD GV_BELNR.  " GV_BELNR defined as type BELNR_D

  • SAP PS Module Report, Help needed for the Right Logic.

    Hi,
             I have to develop a  PS module Report . This spec of this  report is when you enter , project # , month , date , proj type it should  display all the projects  and only the billing levels  with  different  fiels  like ITD cost, ITD sales, ytd cost,  sales,  awards  etc etc.
    Right now  Iam getting the O/P : in the  following manner, There are many fields  I am just showing the desired ones which have to be changed.
    Proj,           Title,         award,    ITDsales,         ITD cost ,    ytd sales,   ytd costs,
    14148,       New prj       123        --                   ---                    -
    14148-B01,  bill1          -
                234           -
                       456                -
    14148-B02,  bill2          -
                789          -
                       123                -
    14148.001    wbs1        -
             123                     -
                     456
    14148.001    wbs2        -
              567                    -
                     890
    But   for me  the desired output must be only for  project  and the billing levels. It shouldn’t be for WBS elements  xxxx.001  and xxxx.002.
    Desired  output:
    Proj,           Title,         award,    ITDsales,   ITD cost ,       ytd sales,      ytd costs,
    14148,       New prj       123        --               690                 -
                   1346
    14148-B01,  bill1          -
             234                -
                       456             -
    14148-B02,  bill2          -
             789                -
                      123              -
    The ITD costs  and YTD costs must be added   123 + 567 = 690 and
                                                                                 456+890 = 1346.
    And these values must come   on the project level.
    P.S:  I can restrict the values  for wbs elements  , means I can filter them at PRPS table  by giving prps-stufe LE ‘2’.  Then I wont get the wbs level, But I want the values of these to be added up and then show it on the project level.
    Please  go through  this code and let me  know where exactly I need to put the right logic  to work in the desired manner.
    Thanks   in advance
    Dan
    Code Below************************
    [code]TABLES: PROJ,                "Project Definition
            PRPS,                "WBS Elements
            prhi,
            CEPC,                " Profit Center w/ Group Head info
            BPGE,                "Plans (12, 13, etc.)
            COSP,                "Primary   Cost Element (Bill Sales, DPC)
            COSS,                "Secondary Cost Element (Shrd Sls,Sal,etc)
            COSB,                "Results Analysis Cost Elements (Unbil Sls)
            COOI,                "Commitments management: Line items
            JEST,                "Project Status
            TCJ04,               "Person Responsible for Project
            zpclasses,           "Project classes.
    New Added
            CRCO,            " Assignment of Work Center to Cost Center
            CRHD.            " Work Center Header
    Record Layout of extracted data
    TYPES: BEGIN OF EXDEF,       "Data definition of extract data
           X_BU(2)     TYPE C,   "Business Unit
           X_CNTR(10)  TYPE C,   " Profit Center
           X_PROJ(24)  TYPE C,   "Project def (Prj)
           X_CREP(30)  TYPE C,   "Contract Rep.
           X_BDREP(25) TYPE C,   "BD Rep. name
           X_GRPH(15)  TYPE C,   "Tech Rep employee name
           X_ACTREP(15)  TYPE C,  "Acct Rep employee name
           X_PMGR(15)  TYPE C,   "PM employee name
           X_TTLE(35)  TYPE C,   "Title
           X_CLNT(20)  TYPE C,   "Client
           X_POCN(20)  TYPE C,   "Prime Contract Number
           X_TYPE(13)  TYPE C,   "Order Type Sarnoff
           X_OPEN(10)  TYPE C,   "Open Date
           X_CLOSE(10) TYPE C,   "Close Date
           X_CGT(4)    TYPE C,   "CO, GV, TC
           X_DISTR(2)  TYPE C,   "Distribution Channel
           X_CONTR(6)  TYPE C,   "Percentage contribution
           X_AWRD(14)  TYPE C,   "Award        (Plan 11)
           X_P12R(14)  TYPE C,   "Auth Revenue (Plan 12 @ Rev)
           X_P12C(14)  TYPE C,   "Auth Cost    (Plan 12 @ Cost)
           X_P13R(14)  TYPE C,   "Auth Revenue (Plan 13 @ Rev)
           X_P13C(14)  TYPE C,   "Auth Cost    (Plan 13 @ Cost)
           X_ITDS(14)  TYPE C,   "ITD Sales
           X_ITDC(14)  TYPE C,   "ITD Costs
           X_YTDS(14)  TYPE C,   "YTD Sales
           X_YTDC(14)  TYPE C,   "YTD Costs
           X_MTHS(14)  TYPE C,   "Current Month Sales
           X_MTHC(14)  TYPE C,   "Current Month Costs
           X_ITDB(14)  TYPE C,   "ITD Billed Sales
           X_YTDB(14)  TYPE C,   "YTD Billed Sales
           X_MTHB(14)  TYPE C,   "Current Month Billed Sales
           X_COMM(14)  TYPE C,   "Commitments
           X_STAT(6)   TYPE C,   "Active or Inactive (REL, TECO, or CLSD)
           X_ZPROJCLASS(12),
           X_MTHIC(14) TYPE C,   "Current Month Incremental Costs
           X_YTDIC(14) TYPE C,   "YTD Incremental Costs
           X_ITDIC(14) TYPE C,   "ITD Incremental Costs
           X_ZSCURVE(10) TYPE C, "S-CURVE  Status
    New Added
           X_CM_COST(20) TYPE C,
           X_AM_COST(20) TYPE C,
           X_TL_COST(20) TYPE C,
           X_KP_COST(20) TYPE C,
           X_PM_COST(20) TYPE C,
    END OF EXDEF.
    Data declarations
    FIELD-SYMBOLS <MNT> .
    DATA: ETAB  TYPE  EXDEF   OCCURS 100  WITH  HEADER LINE.
    DATA:  X1_PM_COST(20) TYPE C,
           X1_TL_COST(20) TYPE C,
           X1_AM_COST(20) TYPE C,
           X1_CM_COST(20) TYPE C,
           X1_KP_COST(20) TYPE C.
    DATA: KOKRS_FIXED      LIKE PROJ-VKOKR VALUE 'DSRC',  "Controlling Area
          TOTAL_AWARD      LIKE BPGE-WTGES,
          TOTAL_AUTHR12    LIKE BPGE-WTGES,
          TOTAL_AUTHC12    LIKE BPGE-WTGES,
          TOTAL_AUTHR13    LIKE BPGE-WTGES,
          TOTAL_AUTHC13    LIKE BPGE-WTGES,
          TOTAL_ITDSALES   LIKE BPGE-WTGES,
          TOTAL_ITDCOSTS   LIKE BPGE-WTGES,
          TOTAL_ITDICOSTS  LIKE BPGE-WTGES,
          TOTAL_YTDSALES   LIKE BPGE-WTGES,
          TOTAL_YTDCOSTS   LIKE BPGE-WTGES,
          TOTAL_YTDICOSTS  LIKE BPGE-WTGES,
          TOTAL_MTHSALES   LIKE BPGE-WTGES,
          TOTAL_MTHCOSTS   LIKE BPGE-WTGES,
          TOTAL_MTHICOSTS  LIKE BPGE-WTGES,
          TOTAL_ITDBILLED  LIKE BPGE-WTGES,
          TOTAL_YTDBILLED  LIKE BPGE-WTGES,
          TOTAL_MTHBILLED  LIKE BPGE-WTGES,
          TOTAL_COMMITMENT LIKE COOI-WTGBTR,
          HOLD_PRART       LIKE PRPS-PRART,
          COUNT_PROJECTS   TYPE I,
          MNT_INDX(20)     TYPE C,
          HLD_INDX(3)      TYPE N,
          YYYY_MM(10)      TYPE C,
          TEMP-DATE(8)     TYPE C.
    Selection Screen
    SELECTION-SCREEN SKIP 3.
    SELECTION-SCREEN BEGIN OF BLOCK XEXTRPM WITH FRAME TITLE TEXT-001.
    SELECTION-SCREEN SKIP 2.
    PARAMETERS MONTH(2)  TYPE  N   OBLIGATORY.
    PARAMETERS YEAR(4)   TYPE  N   OBLIGATORY.
    SELECT-OPTIONS: EXTRPRJ  FOR PROJ-PSPID.     " Range of Projects
    SELECT-OPTIONS: EXTRTYP  FOR PRPS-PRART.  "Project Types (CO,GV,etc.*)
    SELECT-OPTIONS: EXTRPCTR FOR PROJ-PRCTR.     " Range of Profit centers
    SELECTION-SCREEN SKIP 2.
    PARAMETERS: OPT1 RADIOBUTTON GROUP OPTN,
                OPT2 RADIOBUTTON GROUP OPTN DEFAULT 'X'.
    select-options : s_pc for proj-zprojclass.   "project class
    SELECTION-SCREEN END OF BLOCK XEXTRPM.
    Select Tables
    START-OF-SELECTION.
    write: / 'Sales data (Unshared) extracted on: ', sy-datum.
    uline.
      CLEAR:  COUNT_PROJECTS,
              TOTAL_AWARD,
              TOTAL_AUTHR12,
              TOTAL_AUTHC12,
              TOTAL_AUTHR13,
              TOTAL_AUTHC13,
              TOTAL_ITDSALES,
              TOTAL_ITDCOSTS,
              TOTAL_YTDSALES,
              TOTAL_YTDCOSTS,
              TOTAL_MTHSALES,
              TOTAL_MTHCOSTS,
              TOTAL_ITDBILLED,
              TOTAL_YTDBILLED,
              TOTAL_MTHBILLED,
              TOTAL_COMMITMENT,
              ETAB.
    PROJ Table                                          Project Definition
      SELECT  * FROM PROJ                   "Project Definition
           WHERE PSPID IN EXTRPRJ AND      " Range of Project Numbers
              PRCTR IN EXTRPCTR and        " Range of Profit center
                zprojclass in s_pc.     "project class
    SELECT * FROM PRPS WHERE           "WBS Elements
                  PRART IN EXTRTYP         " Range of Proj.Types (CO,GV,TC..
                 and PSPHI = PROJ-PSPNR.
        HOLD_PRART   = '  '.               "clears project type
        CLEAR ETAB.
        ETAB-X_PROJ  = PRPS-POSID.
        ETAB-X_BU    = PRPS-PRCTR(2).      "Business Unit
        ETAB-X_PMGR = PROJ-VERNA.          "Project Manager
        IF PRPS-PRCTR(2) = '01'.
         ETAB-X_CNTR  = PRPS-PRCTR.         " Profit Center
         CONCATENATE SPACE PRPS-PRCTR INTO ETAB-X_CNTR SEPARATED BY SPACE.
        ELSE.
          ETAB-X_CNTR  = PRPS-PRCTR.         " Profit Center
        ENDIF.
         ETAB-X_TTLE  = PRPS-POST1.         "Title
        CLEAR  TEMP-DATE.
        TEMP-DATE    = PROJ-PLFAZ.         "Project planned start date
        CONCATENATE  TEMP-DATE4(2)  '/' TEMP-DATE6(2) '/'
                     TEMP-DATE+0(4)  INTO  ETAB-X_OPEN.
        TEMP-DATE    = PROJ-PLSEZ.         "Project planned finish date
        CONCATENATE  TEMP-DATE4(2)  '/' TEMP-DATE6(2) '/'
                     TEMP-DATE+0(4)  INTO  ETAB-X_CLOSE.
    Tech Lead
    will comment below
        SELECT SINGLE VERNA FROM TCJ04     "Tech Lead name from TCJ04
               INTO  (ETAB-X_GRPH) WHERE  VERNR = PROJ-ZGRPHD.
    End Of Tech Lead
    Account Manager
        SELECT SINGLE VERNA FROM TCJ04  "Acct Manager from TCJ04
               INTO  (ETAB-X_BDREP) WHERE  VERNR = PROJ-ZBUSDEV.
    ******End Of Account Manager
    Key Personnel
        SELECT SINGLE VERNA FROM TCJ04     "Account Rep name from TCJ04
               INTO  (ETAB-X_ACTREP) WHERE  VERNR = PROJ-ZRESPDIR.
    ********End of Key Personnel
    **Contract Manager
        SELECT SINGLE VERNA FROM TCJ04     "Contract Rep name from TCJ04
               INTO  (ETAB-X_CREP) WHERE  VERNR = PROJ-ZCNTREP.
    End of Contract Manager
    PRPS Table                            WBS's attached to the Project
       SELECT * FROM PRPS WHERE           "WBS Elements
                 PRART IN EXTRTYP         "Range of Proj.Types (CO,GV,TC..
                 AND PSPHI = PROJ-PSPNR.
                order by posid stufe.    "Sort by WBS & Level (needed?)
    get info from level 1 of the WBS
         IF PRPS-STUFE EQ 1.              "top-level WBS element
            HOLD_PRART  = PRPS-PRART.      "save project type for later
            ETAB-X_STAT = '????'.          "set ? as the default status
    get Status for level 1
            SELECT * FROM JEST             "use JEST to determine Status
               WHERE OBJNR =  PRPS-OBJNR
                 AND INACT EQ SPACE.       "space denotes an active status
               CASE JEST-STAT.             "find the system status (Ixxx)
                    WHEN 'I0001'.
                         ETAB-X_STAT = 'CRTD'.    "Created
                    WHEN 'I0002'.
                         ETAB-X_STAT = 'REL'.     "Released
                    WHEN 'I0045'.
                         ETAB-X_STAT = 'TECO'.    "Technically Complete
                    WHEN 'I0046'.
                         ETAB-X_STAT = 'CLSD'.    "Closed
               ENDCASE.
            ENDSELECT.
    Select only active projects (ie; those not with TECO or CLSD)
            IF  OPT2 EQ 'X'
               AND  ( ETAB-X_STAT EQ  'TECO'
                  OR  ETAB-X_STAT EQ  'CLSD' ).
                   EXIT.
            ENDIF.
    *comment Contract Rep and Proj man because we get them from PROJ now
           etab-x_crep   = prps-zzcont.     "Contract Rep.
           etab-x_pmgr   = prps-verna.      "Program Manager Name
            ETAB-X_CLNT   = PRPS-ZZMANDT.    "Client Name
            ETAB-X_CGT    = PRPS-PRART.      "CO, GV, TC, etc
            ETAB-X_DISTR  = PRPS-ZZVTWEG.    "Distrib Channel (ie; GP, etc.)
            ETAB-X_CONTR  = PRPS-USR04.      "Contribution %
            ETAB-X_POCN   = PRPS-ZZPOCN.     "Contract Number
            ETAB-X_TYPE   = PRPS-ZZORDT.     "Order Type Sarnoff
    Award and Authorization (Revenue & Cost)
            SELECT * FROM BPGE
               WHERE OBJNR   = PRPS-OBJNR
                 AND LEDNR   = '0001'        "Budget / Planning Ledger
                 AND TRGKZ   = 'N'           "Object indicator
                 AND WRTTP   = '01'          "Value Type
                 AND ( VERSN = '011'         "011 = Award
                    OR VERSN = '012'         "012 = Billing Authorization
                    OR VERSN = '013' ).      "013 = RA Authorization
                                             "010 = Funding Authorization
    Award                                                        Plan 11
              IF BPGE-VERSN = '011'.         "Plan 11 = Award
                CASE BPGE-VORGA.
                  WHEN 'KSTP'.               "KSTP = Cost level
                    ETAB-X_AWRD = ETAB-X_AWRD + BPGE-WTGES.
                ENDCASE.
              ENDIF.
        IF prps-stufe eq '2'.
    Authorization (Revenue & Cost plan 12)                       Plan 12
              IF BPGE-VERSN = '012'.         "Plan 12 = RA Authorization
                CASE BPGE-VORGA.
                  WHEN 'KSTR'.               "KSTR = Revenue level
                    ETAB-X_P12R = ETAB-X_P12R - BPGE-WTGES.
                  WHEN 'KSTP'.               "KSTP = Cost level
                    ETAB-X_P12C = ETAB-X_P12C + BPGE-WTGES.
                ENDCASE.
              ENDIF.
    Authorization (Revenue & Cost plan 13)                       Plan 13
              IF BPGE-VERSN = '013'.         "Plan 13 = RA Authorization
                CASE BPGE-VORGA.
                  WHEN 'KSTR'.               "KSTR = Revenue level
                    ETAB-X_P13R = ETAB-X_P13R - BPGE-WTGES.
                  WHEN 'KSTP'.               "KSTP = Cost level
                    ETAB-X_P13C = ETAB-X_P13C + BPGE-WTGES.
                ENDCASE.
              ENDIF.
        endif.
            ENDSELECT.                     "BPGE
      ENDIF.      "end of if prps-stufe eq 1. top-level WBS element
    COSP Table (External Postings)                     Awards
    COSP Table (External Postings)                     Billed Sales
    COSP Table (External Postings)                     DPC's & Legacy Load
            SELECT * FROM COSP
               WHERE OBJNR = PRPS-OBJNR    AND
                     GJAHR LE YEAR
             AND (
                 ( kstar = '0000400999'   and        "old CE for Award $
                   ( KSTAR BETWEEN '0000400990' AND '0000400999' AND
                     VERSN = '011'              AND    "11 = Award
                     WRTTP = '01' )                    "01 = Planned
              OR ( ( KSTAR BETWEEN '0000400001' AND '0000400989' OR
                     KSTAR BETWEEN '0000999001' AND '0000999003' ) AND
                     WRTTP = '04' )                    "04 = Actuals
              OR ( ( KSTAR BETWEEN '0000998001' AND '0000998010' OR
                     KSTAR BETWEEN '0000600001' AND '0000601999' ) AND
                     WRTTP = '04' )                    "04 = Actuals
    *------- Awards
           if cosp-kstar = '0000400999' and          "old 400999 = Awards
             IF COSP-KSTAR BETWEEN '0000400990' AND '0000400999' AND
                COSP-VERSN = '011'              AND    "11 = Award
                COSP-WRTTP = '01'.                     "01 = Planned
               IF YEAR       = COSP-GJAHR.
                 DO.
                     IF SY-INDEX LE MONTH.
                        MOVE SY-INDEX TO HLD_INDX.
                        MNT_INDX =  'COSP-WKGXXX'.
                        REPLACE 'XXX' WITH HLD_INDX INTO MNT_INDX.
                        ASSIGN  (MNT_INDX) TO <MNT>.
                        ETAB-X_AWRD = ETAB-X_AWRD + <MNT>.
                     ELSE.
                        EXIT.
                     ENDIF.
                 ENDDO.
               ELSEIF YEAR > COSP-GJAHR.
                   ETAB-X_AWRD = ETAB-X_AWRD +
                                 COSP-WKG001 + COSP-WKG002 +
                                 COSP-WKG003 + COSP-WKG004 +
                                 COSP-WKG005 + COSP-WKG006 +
                                 COSP-WKG007 + COSP-WKG008 +
                                 COSP-WKG009 + COSP-WKG010 +
                                 COSP-WKG011 + COSP-WKG012 +
                                 COSP-WKG013 + COSP-WKG014 +
                                 COSP-WKG015 + COSP-WKG016.
               ELSE.
                 EXIT.
               ENDIF.
             ENDIF.
    *------- Billed Sales
             IF ( COSP-KSTAR BETWEEN '0000400001' AND '0000400989' OR
                  COSP-KSTAR BETWEEN '0000999001' AND '0000999003' ) AND
                  COSP-WRTTP = '04'.
                                     "0000999001 = ITD Sales
                                     "0000999003 = ITD Billed Revenue
                IF YEAR = COSP-GJAHR.
                  DO.
                   IF SY-INDEX LE MONTH.
                      MOVE SY-INDEX TO HLD_INDX.
                      MNT_INDX =  'COSP-WKGXXX'.
                      REPLACE 'XXX' WITH HLD_INDX INTO MNT_INDX.
                      ASSIGN  (MNT_INDX) TO <MNT>.
                      ETAB-X_ITDB = ETAB-X_ITDB - <MNT>.
                      ETAB-X_YTDB = ETAB-X_YTDB - <MNT>.
                      IF SY-INDEX = MONTH.
                         ETAB-X_MTHB = ETAB-X_MTHB - <MNT>.
                      ENDIF.
                   ELSE.
                      EXIT.
                   ENDIF.
                  ENDDO.
                ELSEIF YEAR > COSP-GJAHR.
                  ETAB-X_ITDB = ETAB-X_ITDB -
                             COSP-WKG001 - COSP-WKG002 -
                             COSP-WKG003 - COSP-WKG004 -
                             COSP-WKG005 - COSP-WKG006 -
                             COSP-WKG007 - COSP-WKG008 -
                             COSP-WKG009 - COSP-WKG010 -
                             COSP-WKG011 - COSP-WKG012 -
                             COSP-WKG013 - COSP-WKG014 -
                             COSP-WKG015 - COSP-WKG016.
                ELSE.
                  EXIT.
                ENDIF.
             ENDIF.
    *------- DPC's & Legacy Load
             IF ( COSP-KSTAR BETWEEN '0000998001' AND '0000998010' OR
                  COSP-KSTAR BETWEEN '0000600001' AND '0000601999' ) AND
                  COSP-WRTTP = '04'.
               IF YEAR = COSP-GJAHR.
                 DO.
                     IF SY-INDEX LE MONTH.
                        MOVE SY-INDEX TO HLD_INDX.
                        MNT_INDX =  'COSP-WKGXXX'.
                        REPLACE 'XXX' WITH HLD_INDX INTO MNT_INDX.
                        ASSIGN  (MNT_INDX) TO <MNT>.
                        ETAB-X_ITDC  = ETAB-X_ITDC  + <MNT>.
                        ETAB-X_YTDC  = ETAB-X_YTDC  + <MNT>.
                        IF SY-INDEX = MONTH.
                           ETAB-X_MTHC  = ETAB-X_MTHC  + <MNT>.
                        ENDIF.
                     ELSE.
                        EXIT.
                     ENDIF.
                 ENDDO.
               ELSEIF YEAR > COSP-GJAHR.
                   ETAB-X_ITDC = ETAB-X_ITDC +
                                 COSP-WKG001 + COSP-WKG002 +
                                 COSP-WKG003 + COSP-WKG004 +
                                 COSP-WKG005 + COSP-WKG006 +
                                 COSP-WKG007 + COSP-WKG008 +
                                 COSP-WKG009 + COSP-WKG010 +
                                 COSP-WKG011 + COSP-WKG012 +
                                 COSP-WKG013 + COSP-WKG014 +
                                 COSP-WKG015 + COSP-WKG016.
               ELSE.
                  EXIT.
               ENDIF.
             ENDIF.
           ENDSELECT.
    COOI Table (Commitments)              commitments for the WBS elements
           SELECT  * FROM COOI
             WHERE OBJNR =  PRPS-OBJNR.
               ETAB-X_COMM = ETAB-X_COMM + COOI-WTGBTR.
           ENDSELECT.
    COSS Table (External Postings)                    G&A on Commitments
    COSS Table (External Postings)                    Shared Billed Sales
    COSS Table (External Postings)                    Shared DPC's
    COSS Table (External Postings)                    Salary,ESE,OH, & G&A
           SELECT  *   FROM  COSS
             WHERE
              ( OBJNR =  PRPS-OBJNR AND
                WRTTP =  '22' )                         "G&A on Commitments
                    OR
              ( OBJNR =  PRPS-OBJNR AND
                GJAHR LE YEAR       AND
                WRTTP = '04'        AND                 "04 = Actuals
                   (                                   "Shared Billed Sales
                     (   KSTAR BETWEEN '0000400001' AND '0000400989' OR
                         KSTAR BETWEEN '0000999001' AND '0000999003' )
                     OR                                "Shared DPC's
                     (   KSTAR BETWEEN '0000600001' AND '0000601999' )
                     OR                                "Salary,ESE,OH, & G&A
                     ( ( KSTAR BETWEEN '0000001000' AND '0000001999'  OR
                         KSTAR BETWEEN '0000002100' AND '0000002199'  OR
                         KSTAR BETWEEN '0000002500' AND '0000002599'  OR
                         KSTAR BETWEEN '0000002800' AND '0000002899' ) )
                  and  parob not like 'PR%' ) "commented out on 4/19/2000
    *------- G&A on Commitments    (NOTE: data is always as of the RUN date)
             IF  COSS-WRTTP = '22'.
                   ETAB-X_COMM = ETAB-X_COMM +
                                 COSS-WKG001 + COSS-WKG002 +
                                 COSS-WKG003 + COSS-WKG004 +
                                 COSS-WKG005 + COSS-WKG006 +
                                 COSS-WKG007 + COSS-WKG008 +
                                 COSS-WKG009 + COSS-WKG010 +
                                 COSS-WKG011 + COSS-WKG012 +
                                 COSS-WKG013 + COSS-WKG014 +
                                 COSS-WKG015 + COSS-WKG016.
             ENDIF.
    *------- Shared Billed Sales
             IF ( COSS-KSTAR BETWEEN '0000400001' AND '0000400989' OR
                  COSS-KSTAR BETWEEN '0000999001' AND '0000999003' ) AND
                  COSS-WRTTP = '04'.
               IF YEAR = COSS-GJAHR.
                 DO.
                     IF SY-INDEX LE MONTH.
                        MOVE SY-INDEX TO HLD_INDX.
                        MNT_INDX =  'COSS-WKGXXX'.
                        REPLACE 'XXX' WITH HLD_INDX INTO MNT_INDX.
                        ASSIGN  (MNT_INDX) TO <MNT>.
                        ETAB-X_ITDB = ETAB-X_ITDB - <MNT>.
                        ETAB-X_YTDB = ETAB-X_YTDB - <MNT>.
                        IF SY-INDEX = MONTH.
                           ETAB-X_MTHB = ETAB-X_MTHB - <MNT>.
                        ENDIF.
                     ELSE.
                        EXIT.
                     ENDIF.
                 ENDDO.
               ELSEIF YEAR > COSS-GJAHR.
                 ETAB-X_ITDB = ETAB-X_ITDB -
                               COSS-WKG001 - COSS-WKG002 -
                               COSS-WKG003 - COSS-WKG004 -
                               COSS-WKG005 - COSS-WKG006 -
                               COSS-WKG007 - COSS-WKG008 -
                               COSS-WKG009 - COSS-WKG010 -
                               COSS-WKG011 - COSS-WKG012 -
                               COSS-WKG013 - COSS-WKG014 -
                               COSS-WKG015 - COSS-WKG016.
               ELSE.
                  EXIT.
               ENDIF.
             ENDIF.
    *------- Shared DPC's
             IF COSS-KSTAR BETWEEN '0000600001' AND '0000601999' AND
                COSS-WRTTP = '04'.
               IF YEAR = COSS-GJAHR.
                 DO.
                     IF SY-INDEX LE MONTH.
                        MOVE SY-INDEX TO HLD_INDX.
                        MNT_INDX =  'COSS-WKGXXX'.
                        REPLACE 'XXX' WITH HLD_INDX INTO MNT_INDX.
                        ASSIGN  (MNT_INDX) TO <MNT>.
                        ETAB-X_ITDC  = ETAB-X_ITDC  + <MNT>.
                        ETAB-X_YTDC  = ETAB-X_YTDC  + <MNT>.
                        IF SY-INDEX = MONTH.
                           ETAB-X_MTHC  = ETAB-X_MTHC  + <MNT>.
                       ENDIF.
                     ELSE.
                        EXIT.
                     ENDIF.
                 ENDDO.
               ELSEIF YEAR > COSS-GJAHR.
                   ETAB-X_ITDC = ETAB-X_ITDC +
                                 COSS-WKG001 + COSS-WKG002 +
                                 COSS-WKG003 + COSS-WKG004 +
                                 COSS-WKG005 + COSS-WKG006 +
                                 COSS-WKG007 + COSS-WKG008 +
                                 COSS-WKG009 + COSS-WKG010 +
                                 COSS-WKG011 + COSS-WKG012 +
                                 COSS-WKG013 + COSS-WKG014 +
                                 COSS-WKG015 + COSS-WKG016.
               ELSE.
                  EXIT.
               ENDIF.
             ENDIF.
    *------- Salary,ESE,OH,& G&A
             IF ( COSS-KSTAR BETWEEN '0000001000' AND '0000001999'  OR
                  COSS-KSTAR BETWEEN '0000002100' AND '0000002199'  OR
                  COSS-KSTAR BETWEEN '0000002500' AND '0000002599'  OR
                  COSS-KSTAR BETWEEN '0000002800' AND '0000002899' ) AND
                  COSS-WRTTP = '04'.
               IF YEAR = COSS-GJAHR.
                 DO.
                   IF SY-INDEX LE MONTH.
                      MOVE SY-INDEX TO HLD_INDX.
                      MNT_INDX =  'COSS-WKGXXX'.
                      REPLACE 'XXX' WITH HLD_INDX INTO MNT_INDX.
                      ASSIGN  (MNT_INDX) TO <MNT>.
                      ETAB-X_ITDC = ETAB-X_ITDC + <MNT>.
                      ETAB-X_YTDC = ETAB-X_YTDC + <MNT>.
                      IF SY-INDEX = MONTH.
                          ETAB-X_MTHC = ETAB-X_MTHC + <MNT>.
                      ENDIF.
                   ELSE.
                      EXIT.
                   ENDIF.
                 ENDDO.
               ELSEIF YEAR > COSS-GJAHR.
                 ETAB-X_ITDC = ETAB-X_ITDC +
                               COSS-WKG001 + COSS-WKG002 +
                               COSS-WKG003 + COSS-WKG004 +
                               COSS-WKG005 + COSS-WKG006 +
                               COSS-WKG007 + COSS-WKG008 +
                               COSS-WKG009 + COSS-WKG010 +
                               COSS-WKG011 + COSS-WKG012 +
                               COSS-WKG013 + COSS-WKG014 +
                               COSS-WKG015 + COSS-WKG016.
               ELSE.
                 EXIT.
                ENDIF.
             ENDIF.
            ENDSELECT.
    COSB Table (Results from running RA)                    Unbilled Sales
            SELECT * FROM COSB
               WHERE OBJNR = PRPS-OBJNR
                 AND KSTAR BETWEEN '0000003004' AND '0000003005'
                                   "0000003004 = Unbilled Revenue
                                   "0000003005 = Unearned Revenue
                 AND GJAHR LE YEAR
                 AND WRTTP = '32'.                    "32 = Results Analysis
               IF YEAR = COSB-GJAHR.
                 DO.
                     IF SY-INDEX LE MONTH.
                        MOVE SY-INDEX TO HLD_INDX.
                        MNT_INDX =  'COSB-WKGXXX'.
                        REPLACE 'XXX' WITH HLD_INDX INTO MNT_INDX.
                        ASSIGN  (MNT_INDX) TO <MNT>.
                        ETAB-X_ITDS = ETAB-X_ITDS - <MNT>.
                        ETAB-X_YTDS = ETAB-X_YTDS - <MNT>.
                        IF SY-INDEX = MONTH.
                           ETAB-X_MTHS = ETAB-X_MTHS - <MNT>.
                        ENDIF.
                     ELSE.
                        EXIT.
                     ENDIF.
                 ENDDO.
               ELSEIF YEAR > COSB-GJAHR.
                 ETAB-X_ITDS = ETAB-X_ITDS -
                               COSB-WKG001 - COSB-WKG002 -
                               COSB-WKG003 - COSB-WKG004 -
                               COSB-WKG005 - COSB-WKG006 -
                               COSB-WKG007 - COSB-WKG008 -
                               COSB-WKG009 - COSB-WKG010 -
                               COSB-WKG011 - COSB-WKG012 -
                               COSB-WKG013 - COSB-WKG014 -
                               COSB-WKG015 - COSB-WKG016.
               ELSE.
                  EXIT.
               ENDIF.
            ENDSELECT.
      ENDSELECT.               "End of WBS records (from PRPS) for project
    Get Total Sales by adding Billed Sales to Unbilled Sales.
       ETAB-X_ITDS  =  ETAB-X_ITDS  +  ETAB-X_ITDB.
       ETAB-X_YTDS  =  ETAB-X_YTDS  +  ETAB-X_YTDB.
       ETAB-X_MTHS  =  ETAB-X_MTHS  +  ETAB-X_MTHB.
       IF  HOLD_PRART IN EXTRTYP.   "Matches the user requested project type
         IF  OPT1 EQ 'X' OR         "All projects
           ( OPT2 EQ 'X' AND        "Only active projects
             ETAB-X_STAT NE  'TECO' AND
             ETAB-X_STAT NE  'CLSD' ).
               TOTAL_AWARD      = TOTAL_AWARD      + ETAB-X_AWRD.
               TOTAL_AUTHR12    =   TOTAL_AUTHR12    + ETAB-X_P12R .
              TOTAL_AUTHC12    = TOTAL_AUTHC12    + ETAB-X_P12C.
               TOTAL_AUTHR13    = TOTAL_AUTHR13    + ETAB-X_P13R.
               TOTAL_AUTHC13    = TOTAL_AUTHC13    + ETAB-X_P13C.
               TOTAL_ITDSALES   = TOTAL_ITDSALES   + ETAB-X_ITDS.
               TOTAL_ITDCOSTS   = TOTAL_ITDCOSTS   + ETAB-X_ITDC.
               TOTAL_YTDSALES   = TOTAL_YTDSALES   + ETAB-X_YTDS.
               TOTAL_YTDCOSTS   = TOTAL_YTDCOSTS   + ETAB-X_YTDC.
               TOTAL_MTHSALES   = TOTAL_MTHSALES   + ETAB-X_MTHS.
               TOTAL_MTHCOSTS   = TOTAL_MTHCOSTS   + ETAB-X_MTHC.
               TOTAL_ITDBILLED  = TOTAL_ITDBILLED  + ETAB-X_ITDB.
               TOTAL_YTDBILLED  = TOTAL_YTDBILLED  + ETAB-X_YTDB.
               TOTAL_MTHBILLED  = TOTAL_MTHBILLED  + ETAB-X_MTHB.
               TOTAL_COMMITMENT = TOTAL_COMMITMENT + ETAB-X_COMM.
               PERFORM SHIFT_SIGN.
               APPEND  ETAB.              "Write data to internal table
               CLEAR   ETAB.
               COUNT_PROJECTS = COUNT_PROJECTS + 1. "Count # of Projects
         ENDIF.
       ENDIF.
       ENDSELECT.
    ENDSELECT.                          "End of Projects from PROJ table
      PERFORM GRAND_TOTALS.
      SORT  ETAB  BY  X_BU X_PROJ.
      ETAB-X_BU    = 'BU'.
      ETAB-X_CNTR  = 'PrftCntr'.
      ETAB-X_PROJ  = 'Proj'.
      ETAB-X_CREP  = 'Contract Mgr'.
      ETAB-X_BDREP = 'Account Mgr'.
      ETAB-X_GRPH  = 'Technical Lead'.
      ETAB-X_ACTREP = 'Key Person1'.
      ETAB-X_PMGR  = 'Program Mgr'.
      ETAB-X_TTLE  = 'Title'.
      ETAB-X_CLNT  = 'Client'.
      ETAB-X_POCN  = 'Contract #'.
      ETAB-X_TYPE  = 'Type'.
      ETAB-X_OPEN  = 'Open'.
      ETAB-X_CLOSE = 'Close'.
      ETAB-X_CGT   = 'CGT'.
      ETAB-X_DISTR = 'DC'.
      ETAB-X_CONTR = 'Contr%'.
      ETAB-X_AWRD  = 'Award'.
      ETAB-X_P12R  = 'Auth12 Sales'.
      ETAB-X_P12C  = 'Auth12 Cost'.
      ETAB-X_P13R  = 'Auth13 Sales'.
      ETAB-X_P13C  = 'Auth13 Cost'.
      ETAB-X_ITDS  = 'ITD Sales'.
      ETAB-X_ITDC  = 'ITD Costs'.
      ETAB-X_YTDS  = 'YTD Sales'.
      ETAB-X_YTDC  = 'YTD Costs'.
      ETAB-X_MTHS  = 'Mth Sales'.
      ETAB-X_MTHC  = 'Mth Costs'.
      ETAB-X_ITDB  = 'ITD Billed'.
      ETAB-X_YTDB  = 'YTD Billed'.
      ETAB-X_MTHB  = 'Mth Billed'.
      ETAB-X_COMM  = 'Commitments'.
      ETAB-X_STAT  = 'Status'.
      INSERT ETAB  INDEX 1.    "Write a report header line to internal table
      CLEAR  ETAB.
    CALL FUNCTION 'Z_RH_START_EXCEL_DATA_OLE'
        EXPORTING
           data_name = 'C:\WINNT\Profiles\cbraswell\Desktop\TestTemp.xlt'
             DATA_NAME          = 'ZSales.XLS'
             DATA_PATH_FLAG     = 'W'
             DATA_TYPE          = 'DAT'
             DATA_BIN_FILE_SIZE = 'ZSales'
             CHART_TITLE        = 'ZSales'
             CHART_TYPE         = 2
             CATEGORY_TITLE     = 'ZSales'
             VALUE_TITLE        = 'ZSales'
             DATA_XTOP_COR      = 0
             DATA_YTOP_COR      = 0
             DATA_XBOT_COR      = 0
             DATA_YBOT_COR      = 0
             CATEGORY_XTOP_COR  = 0
             CATEGORY_YTOP_COR  = 0
             CATEGORY_XBOT_COR  = 0
             CATEGORY_YBOT_COR  = 0
         TABLES
              DATA_TAB           =    ETAB
         EXCEPTIONS
              NO_BATCH           = 1
              DOWNLOAD_ERROR     = 2
              INVALID_TYPE       = 3
              INTERNAL_ERROR     = 4
              NO_OLE_SUPPORT     = 5
              OLE_FILE_ERROR     = 6
              OLE_ERROR          = 7
              NO_DATA            = 8
              COORDINATE_ERROR   = 9
              OTHERS             = 10.
    Negative # sign in the front of number for downloading to Excel
    FORM  SHIFT_SIGN.
      IF ETAB-X_AWRD CA '-'.    SHIFT ETAB-X_AWRD RIGHT CIRCULAR.     ENDIF.
      IF ETAB-X_P12R CA '-'.    SHIFT ETAB-X_P12R RIGHT CIRCULAR.     ENDIF.
      IF ETAB-X_P12C CA '-'.    SHIFT ETAB-X_P12C RIGHT CIRCULAR.     ENDIF.
      IF ETAB-X_P13R CA '-'.    SHIFT ETAB-X_P13R RIGHT CIRCULAR.     ENDIF.
      IF ETAB-X_P13C CA '-'.    SHIFT ETAB-X_P13C RIGHT CIRCULAR.     ENDIF.
      IF ETAB-X_ITDS CA '-'.    SHIFT ETAB-X_ITDS RIGHT CIRCULAR.     ENDIF.
      IF ETAB-X_ITDIC CA '-'.   SHIFT ETAB-X_ITDIC RIGHT CIRCULAR.    ENDIF.
      IF ETAB-X_ITDC CA '-'.    SHIFT ETAB-X_ITDC RIGHT CIRCULAR.     ENDIF.
      IF ETAB-X_YTDS CA '-'.    SHIFT ETAB-X_YTDS RIGHT CIRCULAR.     ENDIF.
      IF ETAB-X_YTDC CA '-'.    SHIFT ETAB-X_YTDC RIGHT CIRCULAR.     ENDIF.
      IF ETAB-X_YTDIC CA '-'.   SHIFT ETAB-X_YTDIC RIGHT CIRCULAR.    ENDIF.
      IF ETAB-X_MTHS CA '-'.    SHIFT ETAB-X_MTHS RIGHT CIRCULAR.     ENDIF.
      IF ETAB-X_MTHC CA '-'.    SHIFT ETAB-X_MTHC RIGHT CIRCULAR.     ENDIF.
      IF ETAB-X_MTHIC CA '-'.   SHIFT ETAB-X_MTHIC RIGHT CIRCULAR.    ENDIF.
      IF ETAB-X_ITDB CA '-'.    SHIFT ETAB-X_ITDB RIGHT CIRCULAR.     ENDIF.
      IF ETAB-X_YTDB CA '-'.    SHIFT ETAB-X_YTDB RIGHT CIRCULAR.     ENDIF.
      IF ETAB-X_MTHB CA '-'.    SHIFT ETAB-X_MTHB RIGHT CIRCULAR.     ENDIF.
      IF ETAB-X_COMM CA '-'.    SHIFT ETAB-X_COMM RIGHT CIRCULAR.     ENDIF.
    ENDFORM.
    FORM  GRAND_TOTALS.
    SKIP 1.    .
    WRITE: / '----
    WRITE: / 'System ID                  = ', SY-SYSID,
           / 'Client                     = ', SY-MANDT,
           / 'User                       = ', SY-UNAME,
           / 'Date of data extract       = ', SY-DATUM ,
           / 'Number of Projects          =           ',   COUNT_PROJECTS,
           / 'total Award      (Plan 11)  = ', TOTAL_AWARD,
           / 'total Auth Sales

    Hi all,
        Iam really waiting for someone to see and  get the logic right  for this code.Iam completely stuck up.  i need ur help
    Thanks

  • Need to restrict values in F4 help for Batch Characteristic

    Hi,
    I need to restrict values in F4 Help for a batch characteristic based on values entered for another characteristic. I could not find any BADI or Exit for this purpose. There is a BADI CACL_VALUE which is triggered after an entry is selected from dropdown list but nothing when we press F4. I thought of using Object Dependency but I need to write a programming logic for the requirement. Please let me know if there is any way to write program in Object Dependency or any other way for this requirement.
    Regards,
    Nikhil

    Hi nikhil simha,
    first of all, find out which search help is called.
    [Hierarchy of the Search Help Call|http://help.sap.com/saphelp_nw70/helpdata/en/0b/32e9b798da11d295b800a0c929b3c3/frameset.htm]
    may help you.
    If you know the search help, you may enhance it, but first of all you should check the where-used-list and make sure that the search help shows the requested behavior only in the context where you want it to.
    If it is your own program, you may be better off to create your own search help and define the triggering fields as search help interface input fields. Then you can use the values to filter results.
    Regards
    Clemens

  • ALV  List  in the same Column for the row  CELL  i need button or value

    Hi,
    In my ALV list  for the same column I need Button or  Value for the different rows (CELL) depending upon my condition.
    as well as I have to make  read only of 3 rd column CELL based on my first column dropdown value CELL for this Row Only.
    Depends upon the value in  column 1 /  row 2   I have to  read only  the CELL of   column 5 / row 2   ie for the same row.
    Depends upon the value in Column 1/ row 3    I have to   EDITABLE  or   Button   the CELL  of column 5 / row 3 ie for the same row
    How to do the logic for this.
    I tried and got it for the entire column only.
    But my requirement is for the sepecific cell in the column.
    Kindly help to proceed further.
    Thanks in advance.
    Dav

    Here is how you can make a particular cell in the row read-only based on certain conditions.
    In my example I am displaying the flight details in an ALV. Here I am checking the airline id and if it is "AA' I am making the cell in the column airline id as readonly. In my example I am putting a check and readonly on the same column. However you can do this for different columns as well.
    In order to achieve this you need to add a new context attribute 'READONLY' of type abap_bool to the context node which is bound to data node of ALV.
    The method where I populate the node has the following code to populate the data.
      data: lr_input_node type ref to if_wd_context_node,
            lr_flight_node type ref to if_wd_context_node,
            lv_cityfrom   type s_from_cit,
            lv_cityto     type s_to_city,
            ls_from       type bapisfldst,
            ls_to         type bapisfldst,
            lt_flights    type table of bapisfldat,
            ls_flights    type bapisfldat.
      data: lt_final type if_mainview=>elements_node_flighttab,
            ls_final type if_mainview=>element_node_flighttab.
    * Instantiate the variable lr_input_note to the node NODE_FLIGHT
      lr_input_node  = wd_context->get_child_node( name = 'NODE_FLIGHT' ).
    * Instantiate the variable lr_flight_note to the node NODE_FLIGHTTAB
      lr_flight_node = wd_context->get_child_node( name = 'NODE_FLIGHTTAB' )
    * Get the attributes CityFrom und CityTo
      lr_input_node->get_attribute( exporting name = 'CITYFROM'
                                    importing value = lv_cityfrom ).
      lr_input_node->get_attribute( exporting name = 'CITYTO'
                                    importing value = lv_cityto ).
    * Fill the stuctures ls_from and ls_to
      ls_from-city = lv_cityfrom.
      ls_to-city   = lv_cityto.
    * Call the function BAPI_FLIGHT_GETLIST
      call function 'BAPI_FLIGHT_GETLIST'
       exporting
         destination_from       = ls_from
         destination_to         = ls_to
       tables
         flight_list            = lt_flights.
    Now I am going to check if the airline id is 'AA' and based on that I will fill the readonly context attribute.
    loop at lt_flights into ls_flights.
        MOVE-CORRESPONDING ls_flights to ls_final.
        if ls_flights-airlineid = 'AA'.
          ls_final-readonly = abap_true.
        else.
          ls_final-readonly = abap_false.
        endif.
        append ls_final to  lt_final.
      endloop.
    Finally bind the data to the context node.
    * Bind the data to the node NODE_FLIGHTTAB
      lr_flight_node->bind_elements( lt_final ).
    Now you need to do the ALV configuration settings.
    * create an instance of ALV component
      DATA:
        lr_salv_wd_table_usage TYPE REF TO if_wd_component_usage.
      lr_salv_wd_table_usage = wd_this->wd_cpuse_alv( ).
      IF lr_salv_wd_table_usage->has_active_component( ) IS INITIAL.
        lr_salv_wd_table_usage->create_component( ).
      ENDIF.
    * get ALV component
      DATA:
        lr_salv_wd_table TYPE REF TO iwci_salv_wd_table.
      lr_salv_wd_table = wd_this->wd_cpifc_alv( ).
      wd_this->alv_config_table = lr_salv_wd_table->get_model( ).
      CALL METHOD wd_this->alv_config_table->if_salv_wd_table_settings~set_read_only
        EXPORTING
          VALUE  = ABAP_FALSE
    * set visible row count
      DATA:
        lr_table_settings TYPE REF TO if_salv_wd_table_settings.
      lr_table_settings ?= wd_this->alv_config_table.
      lr_table_settings->set_visible_row_count( '10' ).
      DATA:
        lr_column_settings TYPE REF TO if_salv_wd_column_settings,
        lr_column          TYPE REF TO cl_salv_wd_column.
      lr_column_settings ?= wd_this->alv_config_table.
      DATA: lr_input_field TYPE REF TO cl_salv_wd_uie_input_field.
      lr_column = lr_column_settings->get_column( 'AIRLINEID' ).
      CREATE OBJECT lr_input_field EXPORTING value_fieldname = 'AIRLINEID'.
      lr_column->set_cell_editor( lr_input_field ).
      lr_input_field->set_read_only_fieldname( value = 'READONLY' ).
      CALL METHOD lr_column_settings->delete_column
        EXPORTING
          id     = 'READONLY'

  • How to search for an incremented value

    Hi,
    We are using Oracle Enterprise DB in which we have two tables
    first table returns id as:
    select id from Table1 where state IN (4,7);
    output:
    145623
    145896
    147102
    we need to search in another table Table2 for Title and pass one incremented value from the output of above query.
    i.e. we need to search Table2 for Title and paas value 145624,145897, 147103... and so  on.
    Please suggest how can we achieve this.
    TIA,
    Bob

    Hi Manik,
    we are using oracle Database 11g release 2 enterprise edition.
    currently table 1 contains 500 rows and table 2 contains 2000 rows, but this no. will increase by significant amount with time.
    Table1 contains Group_Id and Table2 contains Title and the relation between Table1 and Table2 is through Instance_Id but the instance id present in table2 is incremented value by 1 of what present in table1.
    Table1 has many columns but i need to query for below columns:
    COMPOSITE_INSTANCE_ID - NUMBER
    GROUP_ID - VARCHAR2(1000 BYTE)
    COMPONENT_STATE - NUMBER
    search Query for Table1 is
    select composite_instance_id, group_id from mediator_instance where component_state IN (4,7)
    this query gives below output:
    145623 - 36313337343339353732313335373033
    145896 - 32313636333434306131303739313134
    147102 - 32313736313631313737303339353038
    Table2 contains below column which i need to search. ID in table 2 is related to table1 in such a way that the id present in table2 is one incremented value of the composite_instance_id present in table1.
    ID - NUMBER
    TITLE - NVARCHAR2(100 CHAR)
    sample value:
    ID               Title
    145624       1-1234
    145897       1-5268  
    147103             
    My output should contain:
    Group_id and Title (here group_id is from table1 and title is from table2)
    36313337343339353732313335373033     1-1234
    32313636333434306131303739313134     1-5268
    32313736313631313737303339353038     1-8965

  • I need to find an Unibody 2.66GHz core i7 logic board  for my MacBook Pro 15"

    I need to find an Unibody 2.66GHz core i7 logic board  for my MacBook Pro 15". Where can I find it?

    have you searched the internet? perhaps ifixit.com might have one.

  • I'm going next week to the usa(I'm from Brazil) and i need the logic board for Apple MacBook Pro 15" A1286 where can i get it?, I'm going next week to the usa(I'm from Brazil) and i need the logic board for Apple MacBook Pro 15" A1286 where can i get it?

    I need to buy a logic board for 
    Apple MacBook Pro 15" A1286, but i couldn´t find online to buy it where can i get one and if it´s possible if i can have it delivered to my hotel

    There are a lot of MacBook Pros with the model # A1286 - which year is your model (e.g., "15-inch Late 2011")?
    The only place that I know that you might could score a specific logic board is www.ifixit.com. They may be able to ship to your hotel.
    Clinton

Maybe you are looking for

  • Please help - We can't get JDEV 9.0.3.1035 to work for us

    Hi, we installed and configured JDEV 9.0.3.1035 and are experiencing this persistent problem, whenever we try to run our app the second or any subsequent time: C:\JDEV\jdk\bin\javaw.exe -ojvm -classpath C:\JDEV\j2ee\home\oc4j.jar -Dhttp.proxyHost=DEL

  • ITunes has stopped working - iTunes 12.1

    I just updated iTunes 12 to 12.1 on two Windows 7 x64 systems. On both systems, iTunes fails to run now although 12.0 ran perfectly. Upon clicking on the iTunes program icon, I get a dialog:           Runtime Error!           Program:  C:\Program Fil

  • CS4: DVD encoding problem(s) Mpeg2 and avi

    Hi, I have been trying to burn my video files to DVD. After a month of failures and 50+ wasted DVDs thrown in the garbage -- plus countless hours trying to learn the basics, reading the FAQs, trouble-shooting, and losing my patience awaiting technica

  • Request is running yellow with 0 records

    hi insource i have 14 records, i am running infopackge load to psa? i loaded immediately, its showing yellopw with 0-0 records. i deleted request and run again i am facing same problem what could be the reason

  • DVD-rom Scratch my Snow Leopard Disc

    Hi All, my early 08 mbp dvd rom put alot of scratch on my new snow leopard install disc. although the installation went through smoothly. I do heard that it was trying alittle hard to read the disc. In the end i found lot of scratch. Does anyone expe