Execute ABAP code in Start Routine only once

I have ABAP code in a start routine that I only want to execute once. Is there a way to tell this is first execution of the start routine?
Also can I find out these value in the start routine ABAP:
1. How many data packets there are?
2. What data packet I am processing?
Regards,
Mike...

Hi,
I've just setup a little test:
TRules, Start Routine Global Decl:
DATA: GVI TYPE I, GVN(5) TYPE N.
Start Routine:
IF GVI IS INITIAL.
GVI = 1.
ELSE.
ADD 1 TO GVI.
ENDIF.
MOVE GVI TO GVN.
This is basically counting the times the start routine is executed and populating the var GVN; I am posting GVN in a char ZTESTGV in the target cube. I am posting as well the datapakID in my cube.
I have loaded two requests (each 4 packets)
the first one first to PSA and then from the PSA to the target: this is Serially using one single process. Here's the result in the cube:
Request________________________________DATAPAKID_____ZTESTGV
REQU_8B5ASGQNYYNIV1OJN68HFH1SR____________1____________1
REQU_8B5ASGQNYYNIV1OJN68HFH1SR____________2____________2
REQU_8B5ASGQNYYNIV1OJN68HFH1SR____________3____________3
REQU_8B5ASGQNYYNIV1OJN68HFH1SR____________4____________4
In this case the global variable is persistent accross packets.
the second request is loaded in paralell: this is, multiple processes are executed at the time. Here's the result in the cube:
Request________________________________DATAPAKID_____ZTESTGV
REQU_14QVH21BSVH44FAJW94BD7N2H____________1____________1
REQU_14QVH21BSVH44FAJW94BD7N2H____________2____________1
REQU_14QVH21BSVH44FAJW94BD7N2H____________3____________1
REQU_14QVH21BSVH44FAJW94BD7N2H____________4____________1
In this case the global variable is always1 !!
This is logic since several a process cannot access the internal memory used by another one...
Conclusion; the global variable will work only if the load is serial...
hope this helps...
Olivier.

Similar Messages

  • Start routine: only once per teh load but not once per data packet

    Hi,
    I would like to execute some code in start routine (in update rules) only once per the load but not once per the data packet.
    How can I implement this.
    Regards,

    I once had that same requirement, but in a datasource in R3. I'm not sure if the same solution would work in BW, though. I used a memory id to keep the variable value between packets:
    DATA: ... n_globalvar TYPE n ...
    then I added...
    IMPORT n_globalvar FROM MEMORY ID 'ZMEMID01'.
    ...at the start of the routine to retrieve to the variable the value from the memory id.
    At the end of the code, I exported the variable back to the same memory id...
    EXPORT n_globalvar to MEMORY ID 'ZMEMID01'.

  • ABAP Code in Start Routine for restricing the data records from ODS1 - ODS2

    Hi
    I need small ABAP Code in Start Routine Of Update rules Of ODS . Im in BW 3.5 .
    I have records like below in first layer ODS and i want to restrict some records while going to second layer ODS ..
    ODS1 :-
    DocNO   EventType    Date
    123         001             08/08/2008
    123         003             08/08/2008
    123         011              09/08/2008
    I want one record in ODS2 for this document number whose EventType = 001 only and date of third record ... like below
    Doc NO     EventType      From Date          Todate
    123              001               08/08/2008         09/08/2008
    So how can i get like this record in the ODS2 which will get data from ODS1 . So i need to write the code in the start routine of the ODS2 .
    So please give the me the code for start routine ....
    Regards
    Suresh

    Its difficult in BW 3.5 to include this logic in START_ROUTINE as you cannot add the extra to_date field to the DATA_PACKAGE table.
    You need to create a new global internal table with the same structure of DATA_PACKAGE with additional field to_date. then use the logic to fill in the global internal table
    define a internal table new_data_package with the required structure like (docno, eventtype, fromdate todate)
    data: l_w_datapkg_001 type data_package,
    data: l_w_newdatapkg type new_data_package,
    data: l_w_datapkg_011 type data_package
    LOOP AT DATA_PACKAGE INTO l_w_datapkg_001 WHERE event_type = '001'.
    l_w_newdatapkg-docno = l_w_datapkg_001-docno.
    l_w_newdatapkg-event_type = l_w_datapkg_001-event_type.
    l_w_newdatapkg-fromdate = l_w_datapkg_001-date.
    MOVE CORRESPONDING FIELDS OF l_w_datapkg_001 INTO l_w_newdatapkg.
    READ TABLE data_package INTO l_w_datapkg_011
    WITH KEY docno = l_w_datapkg_001-docno
                     event_type = '011'.
    l_w_newdatapkg-to_date = l_w_datapkg_011-date.
    APPEND l_w_newdatapkg TO new_data_package          
    ENDLOOP.
    Now the new datapackage contains the ODS2 data that u needed

  • (BW) Run the Start Routine Only Once

    I understand that for every data package from ODS to Cube, the start routine is run.  But I need to run it only once.  Is there anyway to achieve this in ABAP?

    I once had that same requirement, but in a datasource in R3. I'm not sure if the same solution would work in BW, though. I used a memory id to keep the variable value between packets:
    DATA: ... n_globalvar TYPE n ...
    then I added...
    IMPORT n_globalvar FROM MEMORY ID 'ZMEMID01'.
    ...at the start of the routine to retrieve to the variable the value from the memory id.
    At the end of the code, I exported the variable back to the same memory id...
    EXPORT n_globalvar to MEMORY ID 'ZMEMID01'.

  • Need to run start routine only once

    I understand that for every data package from ODS to Cube, the start routine is run.  But I need to run it only once.  Is there anyway to achieve this?  As the programming logic doesn't really do anything to the data package, I don't need it to be in the start routine.  But as I populate a database table using that routine, which in turn is used in update routines, I need to kick it off before the load from ODS to cube happens.  I think an ABAP routine variant can be kicked off in process chains.  Did anyone use the variant and know how to kick off the routine?  Do I have to write this logic in a function module and then kick it off using ABAP variant in Process chains? 
    I would prefer a way to limit my start routine to run once for every data load rather than kicking it off through process chain.  Can someone discuss which is a good approach and how I go about it?  Thanks for your inputs.
    Sam

    Hi Sameer,
    Let me recap you req. You want to populate a database table in your start routine and need to do it once for a load.
    There is no possible way to limit the no. of times a Start routine is run, but you can find some worksaround.
    Is there anyway you can identify that your DB table is updated with new records, i.e.
    1> You delete and refill table every time
    2> You have some kind of time stamps.
    If one of the above case is true, then you can use that as a check in the Start routine to limit the no. of times the DB table is being populated.
    Regards,
    Sree

  • ABAP code in start routine (delete no in)

    In my start routine, I would like to delete some data package whose employee id is not in the selection list.
    but there are some ABAP grammer error in the where condition. Can somebody help this? I tried to read the document for 'WHERE - IN seltab', but still I could not give the right code.
    <p>
      employeeid_itab type table of string.
      select /bic/zpe_employeeid into table employeeid_itab from /bic/pzpe_employeeid.
      DELETE SOURCE_PACKAGE where ZEMP_employee_ID NOT IN employeeid_itab.
    It seems that internal table employeeid_itab could not be directly used after the IN keyword.
    how can I do this?
    Edited by: Ben Li on Feb 22, 2008 2:09 PM

    Hi Oscar,
          Actually I had tried this before, using the code like the following,
          <p>
    Types: EmployeeID(7) type  c.
    <p>
    data: sel_itab type  range of EmployeeID.
    <p>
    select /bic/zpe_employeeid into table sel_itab from /bic/pzpe_employeeid.
    <p>
    delete SOURCE_PACKAGE where zemp_employee_id  not in sel_itab.
    <p>
         The grammer check is OK, but when I debug it, I found that there are records in sel_itab, but all the records just have one charactor, actually, my employeeID have 7 charactors in database. So it does not work, I think I miss something in define  of the range table. Can you please figure out? Thanks a lot.

  • Convert ABAP code in start routine/update rule to transform. start routine

    Dear BW ABAPers,
    I have created a custom purchasing info cube (YCP_PURC1) based on 0CP_PURC1 standard cube. I would like to convert this new data flow to BI7 (from 3.x), and convert the standard update rule to transformation. I would need to rewrite the below start routine from the standard update rule to a start routine ABAP code in the newly created  transformation / start routine. My ABAP knowledge is limited. Will you please help?
    *this is the start routine from the update rule. As a side note, the data source is 2LIS_02_SCL.
    LOOP AT SOURCE_PACKAGE.
        IF (     SOURCE_PACKAGE-cppvlc  EQ 0
             AND SOURCE_PACKAGE-cppvoc  EQ 0
             AND SOURCE_PACKAGE-cpquaou EQ 0 ).
          DELETE SOURCE_PACKAGE.
          CONTINUE.
        ENDIF.
    no_scl is initial ( e.g. for good receipts, billing)
    value has to be set depending on storno
        IF SOURCE_PACKAGE-no_scl IS INITIAL.
          IF SOURCE_PACKAGE-storno = 'X'.
            SOURCE_PACKAGE-no_scl = -1.
          ELSE.
            SOURCE_PACKAGE-no_scl = 1.
          ENDIF.
          MODIFY SOURCE_PACKAGE.
        ENDIF.
      ENDLOOP.
    if abort is not equal zero, the update process will be canceled
      ABORT = 0.
    Many thanks and look forward to your kind feedback.
    Kind regards,
    Csaba

    Dear All, Durgesh,
    thanks to you all for your valuable input. Mainly the ABAP part was more interesting for me.
    Durgesh, thanks for your input, it was useful. I just had to change the info objects to data source fields and add the lines before the loop:
    DATA: I_PACKAGE TYPE TYT_SC_1.
        FIELD-SYMBOLS <i_package> TYPE tys_sc_1.
        I_PACKAGE[] = SOURCE_PACKAGE[].
        LOOP AT SOURCE_PACKAGE assigning <i_package>.
          IF ( <i_package>-BWGEO EQ 0
          AND <i_package>-BWGEOO EQ 0
          AND <i_package>-BWMNG EQ 0 ).
            DELETE SOURCE_PACKAGE index sy-tabix.
            CONTINUE.
          ENDIF.
    no_scl is initial ( e.g. for good receipts, billing)
    value has to be set depending on storno
          IF <i_package>-NOSCL IS INITIAL.
            IF <i_package>-ROCANCEL = 'X'.
              <i_package>-NOSCL = -1.
            ELSE.
              <i_package>-NOSCL = 1.
            ENDIF.
          ENDIF.
        ENDLOOP.
    Points have been assigned accordingly.
    Thanks,
    Csaba

  • ABAP Code in Start Routine to fill a field

    Hello,
    with the following code in the start routine in BW3.5 I am trying to fill Intercompany-Indicator based on Distribution Channel. The main code is marked bold.
    Distribution Channel = DISTR_CHAN
    InterCompany-Indicator = G_CWWR14
    Pls help. Thanks.
    SD
    Intercompany Indicator
        IF NOT wa_daten-customer IS INITIAL.
          SELECT SINGLE /b05/s_rbkunde FROM  /b05/mrbcust INTO l_rbcust
                 WHERE  /b05/s_rbcust  = wa_daten-customer
                 AND    objvers        = 'A'
                 AND    datefrom      <= l_date
                 AND    dateto        >= l_date.
          IF sy-subrc EQ 0.
            SELECT SINGLE g_cwwr14 FROM  /b05/mrbkdbkrs INTO l_ii
                   WHERE  comp_code        = wa_daten-comp_code
                   AND    /b05/s_rbkdbkrs  = l_rbcust
                   AND    objvers          = 'A'
                   AND    datefrom        <= l_date
                   AND    dateto          >= l_date.
            IF sy-subrc = 0.
              wa_daten-g_cwwr14 = l_ii.
            ELSE.
              CLEAR wa_daten-g_cwwr14.
            ENDIF.
          ELSE.
            CLEAR wa_daten-g_cwwr14.
          ENDIF.
        ELSE.
          IF wa_daten-G_CWWR14 = ' '.
            CASE wa_daten-DISTR_CHAN.
              WHEN 'Y4'.
                wa_daten-G_CWWR14 = '4'.
              WHEN 'Y5'.
                wa_daten-G_CWWR14 = '2'.
              WHEN OTHERS.
                wa_daten-G_CWWR14 = '0'.
            ENDCASE.
          ENDIF.
        ENDIF.      " NOT wa_daten-customer IS INITIAL
        MODIFY DATA_PACKAGE FROM wa_daten.
      ENDLOOP.

    Hi Venkat,
      Two things -One is the performance and the other ... there is no Append  within the loop.
      Try moving the select statement ousdie the loop to improve performance and move the modify statement into the loop ... change modify to append. Code below.
       Let me know if you need more help.
    Best regards,
    Kazmi
    data: it_data type standard table of data_package_structure
    with header line
    with non-unique default key initial size 0.
    types: begin of billing_item_type,
    BILL_NUM like /BIC/AZSD_O0700-BILL_NUM,
    DOC_NUMBER like /BIC/AZSD_O0700-DOC_NUMBER,
    PLANT like /BIC/AZSD_O0700-PLANT,
    end of billing_item_type.
    refresh it_data.
    clear it_data.
    it_data] = DATA_PACKAGE[.
    refresh DATA_PACKAGE.
    clear DATA_PACKAGE.
    loop at it_data.
    select DOC_NUMBER PLANT into (it_data-DOC_NUMBER, it_data-PLANT)
    from /BIC/AZSD_O0700
    where BILL_NUM = it_data-BILL_NUM
    and FISCVARNT = it_data-fiscvarnt.
    endselect.
    if sy-subrc = 0.
    move-corresponding it_data to DATA_PACKAGE.
    Append DATA_PACKAGE.
    endif.
    endloop.

  • Abap code in start routine

    hi,
    i have a code in this way in update routine of that info object
    instead of writng that code in update routine i want to write in start routine
    can any one tell me what r the changes i have to made
    please suggest me
    i will assigfn points
    CASE COMM_STRUCTURE-crm_ctstat.
    Contact Achieved
        WHEN '0'.
    Finished faultless
          RESULT = '20'.
          RETURNCODE = 0.
    Contact Not Possible (Missing Communication Data)
        WHEN '1'.
    Finished faulty
          RESULT = '10'.
          RETURNCODE = 0.
    Contact Not Possible (Incorrect Communication Data)
        WHEN '2'.
    Finished faulty
          RESULT = '10'.
          RETURNCODE = 0.
    Contact Not Permitted (Max. Usage BP List)
        WHEN '3'.
    Finished faulty
          RESULT = '10'.
          RETURNCODE = 0.
    Contact Not Permitted (Block Indicator for BP)
        WHEN '4'.
    Finished faulty
          RESULT = '10'.
          RETURNCODE = 0.
    Contact Not Possible (Technical Problems)
        WHEN '5'.
    Finished faulty
          RESULT = '10'.
          RETURNCODE = 0.
      ENDCASE.

    Hi,
    loop at datapackage.
    CASE datapackage-crm_ctstat.
    Contact Achieved
    WHEN '0'.
    Finished faultless
    RESULT = '20'.
    RETURNCODE = 0.
    Contact Not Possible (Missing Communication Data)
    WHEN '1'.
    Finished faulty
    RESULT = '10'.
    RETURNCODE = 0.
    Contact Not Possible (Incorrect Communication Data)
    WHEN '2'.
    Finished faulty
    RESULT = '10'.
    RETURNCODE = 0.
    Contact Not Permitted (Max. Usage BP List)
    WHEN '3'.
    Finished faulty
    RESULT = '10'.
    RETURNCODE = 0.
    Contact Not Permitted (Block Indicator for BP)
    WHEN '4'.
    Finished faulty
    RESULT = '10'.
    RETURNCODE = 0.
    Contact Not Possible (Technical Problems)
    WHEN '5'.
    Finished faulty
    RESULT = '10'.
    RETURNCODE = 0.
    ENDCASE.
    endloop.

  • Need help in ABAP coding in start routine

    Hi,
    I have a requriement like
    -To take the value of month which is an attribute of category(info Object) for which category value is 1. I need to apply the month obtained as the filter to another info object. I have opted to write this ABAP code in start routine. Can anyone guide me on this code.
    Thanks in advance.

    do you not have an abap-er at your disposal? i don't imagine this to be quick & dirty that can be written without access to your system! some analysis work may also be required before the actual coding can be done...so I wouldn't post the entire functional spec (business requirement) here hoping for a solution; that would be too weird.
    Regards.

  • Urgent : Doubt in writing a code in start routine

    Hi all ,
                 I am BI 7.0 system , I have doubt in writing a code in start routine .
    1) i have to extract the data first from a custom table based on one condition and then placing it into internal table .
    2) Now i have to loop at source_package for a particular region field say "ASIA". with this result i have to check for the correponding entries in custoom table .
       if condition is not true (i.e ) with entries or not matching then delete that particular record from source_package.
    i have written a small logic for this . but this is producing any ouput , Please check it and also let me know for modifications .
    thanks in advance.
    select * from zcsp
        into corresponding fields of TABLE itab_T
        where
        ZBUSINESSUNIT = 'BC'.
    loop at SOURCE_PACKAGE into ls_SOURCE_PACKAGE where /BIC/DPREGION = 'XE'.
                 loop at itab_t into itab_w where zcategory =
                   ls_source_package-/BIC/DPMAT/BIC/DPCAT.
                       if sy-subrc ne 0.
                         delete SOURCE_PACKAGE.
                       endif.
               endloop.
           endloop.

    You're deleting the entire input package.  You only want to delete the one row.
    DATA: g_tabix TYPE sy-tabix.
    SELECT * FROM zscp
    INTO CORRESPONDING FIELDS OF TABLE itab_t
    WHERE zbusinessunit = 'BC'.
    SORT itab_t BY zcategory.
    LOOP AT source_package INTO ls_source_package WHERE /bic/dpregion = 'XE'.
      g_tabix = sy-tabix.
      READ TABLE itab_t WITH KEY zcategory = ls_source_package-/bic/dpmat/bic/dpcat TRANSPORTING NO FIELDS BINARY SEARCH.
      IF sy-subrc NE 0.
        DELETE source_package INDEX g_tabix.
      ENDIF.
    ENDLOOP.

  • Why java allow start() method only once for a thread

    Hi ,
    Why java allows start method only once for thread . suppose
    Thread t = new Thread();
    t.start();
    say at later stage if again we call t.start() IllegalStateException is thrown , even though isAlive method returns false.
    Hence the question , why start() method is allowed only once.If you need start a thread , we need to create a new instance.

    Really. Why do you think that? Do you have any evidence? It is one of the first things I would think of, personally.Considering that the Thread API doesn't allow you to specify a stack address (only stack size), I think it demonstrates they wanted to remove that capability from their Thread API all together. That missing "capability" makes me believe they want me to believe it's not something I need to worry about when using their API... I think the exact semantics of the Thread class and its methods were driven by how to make it most understandable and usable for their customers. I'm certain this issue was one of many that was given considerable thought during the design and implementation of the JVM and the underlying runtime classes.
    Do I have any evidence? No. But if you can point me at some first-hand information on this, I'd love to read it. Most of what I've found is second or third hand accounts. (and I mean that sincerely, not as a smart-ass remark or rebuke of your comments).
    On the one hand you seem to think the Java API designers are idiots, on the other hand you think that they should be. I can't make it out.I thought my position was that the Java developers were talented enough to implement platform in whatever way their API called for; hence, the designers made a choice about how they wanted their API to be used by their customers. They decided which capabilities they wanted to include or exclude, and created an API that was consistent with their vision for this technology. While I'm certain technical limitations had an effect on the API design, I certainly don't think the API was dictated by the them.
    I think the current design of the Java Thread API was a reflection of their vision to make Threading easier and more accessible to Joe Programmer, not limitations in the implementation. I never said it was wrong or that I could do better... I just said I think they could have done something different if they decided it would have made for a better customer experience. But hey, maybe I'm wrong.

  • Executing code from a Bean only once when page loads

    Hi all,
    I have a method in a BackingBean which access UI Bindings from my fragment: xxx.jsff.
    So that method has to be invoked from a inside that fragment since access Bindings from xxxPageDef.xml
    I need to execute that code one and only one time when that fragment loads.
    What is the best approach to my case????

    Thanks Pino for your reply.
    Since the fragment does not have OnLoad event, I have no option than to find a work around.
    That is exactly what I am doing.
    I have a PageFlowScope variable which is set to true or false depending if I have input parameter value or not.
    That variable is re-sated when the user pressed a button.
    The problem was where to stick to code that will disable components if needed.
    So I used one component and in its Rendered method I put the code that will disable components if needed (based on my PageFlowScope variable value).
    Works perfectly fine, but it would be much nicer if there was more natural way of doing it (with OnLoad event on fragment).
    Regards.

  • Abap report need to run only once in a day

    can i restrict my abap report that it should run once in a day. is there any authorization funda? or any sap provided concept? how can i approach this?

    hi,
    no authorizations for tht if u want try this code i think it will help u
    DATA:count,date LIKE sy-datum.
    GET PARAMETER ID 'MAX' field count.
    GET PARAMETER ID 'DAT' FIELD date.
    IF date is initial.
    date = sy-datum.
    ENDIF.
    IF date = sy-datum.
    count = count + 1.
    else.
    message e000(zmsgtab)."u con't execute it more than once in a day.
    endif.
    set PARAMETER ID 'MAX' field count.
    IF count > 5.
    count = 0.
    set PARAMETER ID 'MAX' field count.
    date = date + 1.
    set PARAMETER ID 'DAT' field date.
    message e000(zmsgtab)."u con't execute it more than once in a day.
    ENDIF.
    write:/ 'this is my program'.
    <b><removed_by_moderator></b>
    <b><removed_by_moderator></b>
    feel free to ask any quiries
    <b><removed_by_moderator></b>
    <b><removed_by_moderator></b>

  • Pls give me the code to load method only once in JVM.

    Hi all,
    Pls give me the code to execute method only once in JVM.Even if we create more than one instance to call the method.
    Thanks & Regards,
    Vinodh

    [How to ask a question on these forums|http://catb.org/~esr/faqs/smart-questions.html]

Maybe you are looking for

  • Problem in invoking a BPEL process from JSP

    I've deployed HelloWorld BPEL from the samples. It's working fine from the BPEL Console. After that I created a JSP page to invoke this BPEL process. My JSP code looks like this:' <%@page import="com.oracle.bpel.client.Locator" %> <%@page import="com

  • HT204022 Download photos & video from iCloud to iPad?

    How to retrieve video from iCloud back to iPad?

  • Order by in reports

    Hi all I have a report which is a cross tab matrix type. I do the row group by article whoch is varchar2(30). The problem I have is with the order in which I get the items. Let's supose that I have this three diferent items in the table: 'CA000' 'CH0

  • Statistics collection

    Guys, I have a table called ENTITY_VOLUME, which has about 8 partitions. Periodically the business deletes each range of program_id's and hence i drop such partitions and split the last partition to make room for new partitions. Now, i have an issue

  • Problem Installing JWSDP

    I can't install the JWSDP. Here is the resulting log file. Could you explain what I need to do to get it to install? (Sep 2, 2005 9:12:39 AM), Install.product.install, com.sun.jwsdp.installer.SetProxyPanel, err, ServiceException: (error code = -10000