Sap Query Additional Fields using  Abap Code

Hi Experts,
I am relatively new to the world of SAP query (Log Database PNPCE), I have written a number of additional fields to retrieve previous info-type data using the select statement E.G
prev_endda = p0008-begda - 1.
SELECT  single bsgrd
      INTO FTE1
      FROM
        pa0008
      WHERE pernr EQ  P0008-pernr
      AND   endda EQ prev_endda
Although I can retrieve the previous info-type data , I was wondering if there was a easy way where I could take this a step further and show the Previous , Previous record. I.E
Pernr     FTE Current    FTE1      FTE2
101              60%          30%       75%
I guess what I am asking is , is there a way to loop through the HR info-type records, does anybody know if there is a standard function or macro I can use to achieve this.
Your help is much appreciated.

Hi ,
Thanks for our reply.
I have pasted some example code into my additional field which I have created in SAP Query But im not sure how the loop bit works and how I can populate the additional fields that I have created , could you please explain this
CALL FUNCTION 'HR_READ_INFOTYPE'
  EXPORTING
    pernr                 = '000000019'
    infty                 = '01'
    BEGDA                 = '18000101'
    ENDDA                 = '99991231'
  tables
    infty_tab             = p0008
  EXCEPTIONS
    INFTY_NOT_FOUND       = 1
    OTHERS                = 2
    LOOP AT p0008.
NOT SURE WHAT TO PUT IN THIS SECTION *****
  ENDLOOP.
I have created 3 additional Fields in the infoset Current FTE ,FTE1 FTE2 , and I want to loop through the records and populate the relevant Additional field with the employees FTE  (I only want to populate  where there is a change)
Sample Data
Begda              Endda             FTE        Salary
1/1/2010         31/12/999       60%         19K          (Current  FTE)
01/08/2009     31/12/2009     100%       27k           (FTE1)
01/07/2008     31/7/2009         50%       17K          (FTE2)
Thanks in anticipation
DM

Similar Messages

  • SAP Query Custom Field with ABAP Code

    Hi All,
    I have a custom field in my SAP query which has some ABAP code under it. The code finally writes some value to a variable. My question is do i need to explicitly link the variable in the ABAP code to the custom field OR it's done automatically. For some reason i don't see any value for this custom field. Thanks.

    Thanks Sandra

  • How to make SAP Query additional field as one of the selection field ?

    Hi experts,
    I'm working on a AdHoc query. I added some Additional fields to the infoset. I put Abap code to populate this additional fields as output fields but I want to make these fields as selection fields also.
    How can I accomplish this ?
    I'd appreciate any answer or suggestion.
    Thanks in advance.

    See Extended / Quick Search capability with attributes in the following SAP notes.
    [482338 - Using Extended Search in ISA B2B, ver. 30|https://service.sap.com/sap/support/notes/482338]
    [792556 - Quick search using several attributes|https://service.sap.com/sap/support/notes/792556]
    [888528 - ISA R/3 4.0: Extended catalog search not consistent|https://service.sap.com/sap/support/notes/888258]

  • SAP Query - Additional field that collects information from table RESB

    Hello gurus. I have a question.
    I want to create a SAP Query that shows me the stock level of a list of materials, and also show me the total quantity of order reservations in an additional field.
    I created an InfoSet with table MARD, which is the one that holds the Stock information in a plant. Then I created an additional field which would read information from table RESB, the table that holds order reservations per material.
    So I wrote this piece of code:
    SELECT * FROM RESB
    WHERE MATNR EQ MARD-MATNR and
           WERKS EQ MARD-WERKS.
    ENDSELECT.
    if ( sy-dbcnt NE '0').
          MOVE RESB-BDMNG to ZQTY.
    ELSE.
          MOVE '' to ZQTY.
    ENDIF.
    This works fine. However, this is currently just catching the first record in table RESB that matches my condition.
    What I would like is to collect every instance of RESB-BDMNG and add them to field "ZQTY", have it loop in RESB until it finishes finding every record that match the MATNR and WERKS. With this I could get the total number of order reservations that this material has in that table.
    Could someone share some coding that would help me achieve this?

    Yes! That did it. That's what I needed to do. Thank you so much.
    While I'm at it, let me ask you a related question.
    When I execute the query, in the first records of the query where there's no value from RESB to transfer, the value of field ZQTY appears empty. Once it finds the first record in RESB and it populates ZQTY with a value, then the rest of the records with no hit get the proper value of 0.
    Do you know why the first records in the query appear empty and not with a 0? Is there anything I should add to the coding to fix this?

  • SAP Query : additional field

    Hi,
    in my HR query i need to add a new field in infotype specific 9016 to be calculated by ABAP code.
    I perform the following steps :
    - transaction SQ02, i modify my info-set, in the node of my infotype i add a new field, i give a new name and a LIKE reference, and i generate the info-set, it's ok.
    - transaction SQ01 : i add my new field in my request, i check it and it's ok but when i run it, i have a dump : Function module "RPAQ_GET_AF_9016" not found.
    Can you explain to me how can i resolve this problem ?
    Cheers
    Edited by: CECG on Aug 25, 2009 11:08 AM

    Hi,
    What is the field you have referred to using LIKE statement? If this is infotype 9016, there  would be the corresponding table which holds the data for 9016 infotype(PA table...PA9016(i hope so and not sure of HR tables))....
    If so please refer to a dataelement for the field and then try to regenrate your query in SQ01 after adjusting the infotype in SQ02.
    Hope this helps
    Regards
    Shiva

  • SQ01 Sap Query - additional fields doesn't appear

    Hi everybody,
    i've created a SAP Query with transaction SQ01 but one of my additional fields doesn't appear when i execute my Query.
    My query shows the G/L account number and the field status Group (table SKB1)
    I just need to display equally the text field of "field status Group" but it doesn't work.
    When i look at the parameters i can see that it makes the link between the table T004G and SKB1 in order to find the textfield but the field stay blank.
    For information T004g is a Pooled table.
    Is someone could help me?
    Thank you

    Hi,
    First you need to create a structure in Data Dictionary - SE11. This structure will contain all the fields that you want to display in the query output.
    Example - Name the Strucutre as zz_infoset01
    fields of the structure( for your requirement )
    BUKRS
    SAKNR
    FSTAG
    FSTTX
    Go to T-code SQ02
    1) Enter the Infoset name - zinfoset01 press create
    2) Enter a Short Description - G/L Infoset - 01
    3) select radio button - "Data retrieval by program"
                   and in "data structure" enter   zz_infoset01
    4) select "Integrated program" radio button
    5) In the next screen click on the "Data reading program" push button(on the application toolbar)
    6) An Editor will open with the following code
    REPORT  rsaqdvp_template .
      declarations
      (insert your declarations in this section)
    DATA:
      zz_infoset01                          TYPE zz_infoset01                          ,
      it_data TYPE STANDARD TABLE OF zz_infoset01 WITH HEADER LINE.
      selection screen statements
      (define your selection-screen here)
    !! the following comment MUST NOT BE CHANGED !!
    *<QUERY_HEAD>
      read data into IT_DATA
    (select your data here into internal table IT_DATA)
      output of the data
      (this section can be left unchanged)
    LOOP AT it_data.
      zq01  = it_data.                        .
    !! the following comment MUST NOT BE CHANGED !!
    *<QUERY_BODY>
    ENDLOOP.     
    7) when you insert your code in the sections it will look like this
    REPORT  rsaqdvp_template .
      declarations
      (insert your declarations in this section)
    Tables:SKB1,
              t004g.          
    DATA:
      zz_infoset01                          TYPE zz_infoset01 ,
      it_data TYPE STANDARD TABLE OF zz_infoset01 WITH HEADER LINE.
      selection screen statements
      (define your selection-screen here)
    !! the following comment MUST NOT BE CHANGED !!
    *<QUERY_HEAD>
    *These will be the input parameters for the query
    parameters: sp_bukrs like skb1-bukrs,
             sp_saknr like skb1-saknr.     
      read data into IT_DATA
    (select your data here into internal table IT_DATA)
    *get all the G/L for com code and G/L in selection screen
    SELECT bukrs saknr fstag
                INTO TABLE it_data
                FROM skb1
                WHERE bukrs = sp_bukrs
                AND   saknr = sp_saknr.
      output of the data
      (this section can be left unchanged)
    *for every G/L get the status text from t004g for lang 'EN'
    LOOP AT it_data.
    SELECT SINGLE fsttx
                    FROM t004g
                    INTO it_data-fsttx
                    WHERE spras = 'EN' "Language
                    AND   bukrs = it_data-bukrs
                    AND   fstag = it_data-fstag.
      zz_infoset01  = it_data.                        .
    !! the following comment MUST NOT BE CHANGED !!
    *<QUERY_BODY>
    ENDLOOP.     
    8) Save and generate the Infoset.By clicking on the generate button.
    9) Now assign the Infoset to the query in SQ01 and select the output list fields.
    let me know if you need more info. Also award points if helpful.
    Regards,
    Santosh

  • How to Use CMOD and SMOD in SAP using ABAP Code

    Hello anyone,
      Please help me How to use CMOD and SMOD in SAP using ABAP code.
    Give Me Some Sample Example.
    Mail ID: [email protected]
    Thanks,
    Regards,
    S.Muthu,
    SAP Developer.

    Hi,
    User Exits.
    http://www.erpgenie.com/sap/abap/code/abap26.htm
    http://www.sap-img.com/abap/a-short-tutorial-on-user-exits.htm
    http://www.sapgenie.com/abap/code/abap26.htm
    http://www.sap-img.com/abap/what-is-user-exits.htm
    http://wiki.ittoolbox.com/index.php/HOWTO:Implement_a_screen_exit_to_a_standard_SAP_transaction
    http://www.easymarketplace.de/userexit.php
    http://www.sap-img.com/abap/a-short-tutorial-on-user-exits.htm
    http://www.sappoint.com/abap/userexit.pdfUser-Exit
    customer exits
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f1a7e790-0201-0010-0a8d-f08a4662562d
    Menu Exit.
    http://www.sappoint.com/abap/spmp.pdf
    http://www.sappoint.com/abap/userexit.pdf
    http://www.sapdevelopment.co.uk/enhance/mod_sapmenu.htm
    http://www.sapdevelopment.co.uk/enhance/enhancehome.htm
    USER EXIT
    http://www.sap-img.com/abap/a-short-tutorial-on-user-exits.htm
    http://www.sapgenie.com/abap/code/abap26.htm
    http://www.sap-img.com/abap/what-is-user-exits.htm
    http://wiki.ittoolbox.com/index.php/HOWTO:Implement_a_screen_exit_to_a_standard_SAP_transaction
    http://www.easymarketplace.de/userexit.php
    http://www.sap-img.com/abap/a-short-tutorial-on-user-exits.htm
    http://www.sappoint.com/abap/userexit.pdfUser-Exit
    http://www.sap-img.com/ab038.htm
    http://help.sap.com/saphelp_46c/helpdata/en/64/72369adc56d11195100060b03c6b76/frameset.htm
    http://www.sap-img.com/abap/a-short-tutorial-on-user-exits.htm
    http://www.sap-img.com/abap/what-is-user-exits.htm
    http://expertanswercenter.techtarget.com/eac/knowledgebaseAnswer/0,295199,sid63_gci982756,00.html

  • Changing Field Label length for Data Element using ABAP code.

    Hi Experts,
    We have a scenario where we have to update the maximum length of the various Field Labels (Short, Medium, Long..) for a Data Element using ABAP code.
    Does anyone know how to do this ? Is there a Function Module available for this purpose ?
    Appreciate your valuable inputs.

    Hi ,
    Use the view
    DD03M
    Give
    TABNAME as table name,
    DDLANGUAGE = EN / sy-langu
    and order by position. (for correct sequencing)
    You will get description of the fields (short,medium, long etc). You will also get the length and other details.

  • Why should we using ABAP code in RSQ02

    Hi,
    I want to know why should we using ABAP cobe in RSQ02 ,
    while we creating the infoset we writing code using extras icon .
    with out abap code we can't creat infoset query in SAPBW?
    Regards,
    Goodyear.

    Hi dear,
    this is only an additional possibility to manipulate your data, but this is not due !
    Did you know that Marc Bernard wrote a very useful doc about ABAP and BW ?
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/events/bw-and-portals-05/five ways to enhance sap bi backend functionality using abap.pdf
    Hope it helps!
    Bye,
    Roberto

  • Improve data load performance using ABAP code

    Hi all,
             I want to improve my load performance using ABAP code, how to do this?. If i writing ABAP code in SE38 how i can call
    in BW side? if give sample code to improve load performance it will be usefull. please guide me.

    There are several points that can improve performance of your ABAP code:
    1. Avoid using SELECT...ENDSELECT... construct and use SELECT ... INTO TABLE.
    2. Use WHERE clause in your SELECT statement to restrict the volume of data retrieved.
    3. Use FOR ALL ENTRIES in your SELECT statement to retrieve the matching records at one shot.
    4.Avoid using nested SELECT and SELECT statements within LOOPs.
    5. Avoid using INTO CORRESPONDING FIELDS OF. Instead use INTO TABLE.
    6. Avoid using SELECT * and select only the required fields from the table.
    7. Avoid Executing a SELECT multiple times in the program.
    8. Avoid nested loops when working with large internal tables.
    9.Whenever using READ TABLE use BINARY SEARCH addition to speed up the search.
    10. Use FIELD-SYMBOLS instead of a work area when there are more than 200 entries in an internal table where some fields are being manipulated.
    11. Use MOVE with individual variable/field moves instead of MOVE-CORRESPONDING.
    12. Use CASE instead of IF/ENDIF whenever possible.
    13. Runtime transaction code se30 can be used to measure the application performance.
    14. Transaction code st05 can be used to analyse the SQL trace and measure the performance of the select statements of the program.
    15. Start routines can be used when transformation is needed in the data package level. Field/individual routines can be used for a simple formula or calculation. End routines are used when you wish to populate data not present in the source but present in the target.
    16. Always use a WHERE clause for DELETE statement. To delete records for multiple values, use SELECT-OPTIONS.
    17. Always use 'IS INITIAL' instead of equal to '' because null for a character is '' but '0' for an integer.
    Hope it helps.

  • Change Prg name in classes using abap code

    Hello Experts,
    I'm having following req:-
    I need to change program name using abap code .
    I have prepared report which changing prg name & also it is replecting target name into T-code & Programes where source prg name is being used.
    My next req is i want to replace sorce prg name in Classes usinf abap coding.
    <Priority normalized by moderator>
    Thanxs in Advance.
    Moderator message : Requirements dumping not allowed, thread locked.
    Edited by: Vinod Kumar on Feb 7, 2012 12:32 PM

    The application name is not necessarily uniqueue! Customers may create two applications with same name in different systems/clients and transport them into the same target system/client!
    You do the mapping with the query:
    CL_FDT_FACTORY=>GET_INSTANCE( )->GET_QUERY()->...
    There are two methods. One for mapping ID to name and one for name to ID.
    There is also a sample report in package SFDT_DEMO_OBJECTS.

  • Setting value in cookie using ABAP code

    Hai All,
    Is it possible to set value in a cookie using ABAP code.
    Regards,
    H.K.Hayath Basha.

    Hai Thomas Jung,
    In Enterprise portal SAP has standard functionality to set inactivity timeout. We can set whatever time we want, say for example if we set the time as 15 minutes. If the user is not interacting with the system for 15 minutes then portal will logout the user automatically without any information.
    Our user wants a popup to be shown that the system will be logged out due to inactivity.
    Since Portal logout the user automatically without any information. I want to put in my own framework to handle inactivity timeout.
    What idea I have is, when ever user interacts with any function in portal. I will set current time in a cookie. Someother application will read this cookie at regular interval, if the time difference between the cookie and system is 15, then I will force the user to logout by showing a popup screen.
    In our portal we have three different type of application, they are, Java Webdynpro, ABAP-Webdynpro and BSP.
    I think that from Java Webdynpro and BSP we can call a javascript to set value in a cookie, from ABAP-Webdynpro I don't know how to set a value in cookie.
    This is my business requirement. Is there anyother solution to fullfill this business requirement.
    Thanks & Regards,
    H.K.Hayath Basha.
    Let me tell the business requirement.  Our user want to give a popup message when

  • Creating a long text using ABAP code.. fm SAVE_TEXT

    When you create an order via IW31 one of the options is to click on the text button and create a long text. I am basically trying to mimic this action from within my ABAP code.
    The text id details are as follows:
    Text Name       500000015000046  which is (5000000 + order number)
    Language        EN
    Text ID            KOPF         Order header text
    Text Object      AUFK       Order text
    If i manually create the text within the transaction i am then able to view and update it via function modules READ_TEXT and SAVE_TEXT. But if the text has not already been created READ_TEXT obviously returns nothing as it does not exist and SAVE_TEXT does not seem to created it!
    Anyone know how i would go about creating this text using ABAP code?
    Hope this make a bit of sense
    Thanks in advance
    Mart

    I have implemented the code as i think it should be. See below, can any see what is wrong. If i add init_text it makes no difference and adding the commit_text just makes it hang
    DATA: IT_TEXTS type standard table of TLINE,
           wa_texts like line of it_texts,
           wa_txtheader type THEAD.
    wa_txtheader-TDID     = 'KOPF'.
    wa_txtheader-TDSPRAS  = 'EN'.
    wa_txtheader-TDNAME   = '500000015000056'.
    wa_txtheader-TDOBJECT = 'AUFK'.
    wa_texts-tdformat = '*'.
    wa_texts-tdline = 'hello'.
    append wa_texts to it_texts.
    wa_texts-tdformat = '*'.
    wa_texts-tdline = 'hello'.
    append wa_texts to it_texts.
      wa_texts-tdformat = '*'.
    wa_texts-tdline = 'hello'.
    append wa_texts to it_texts.
    wa_texts-tdformat = '*'.
    wa_texts-tdline = 'hello'.
    append wa_texts to it_texts.
    wa_texts-tdformat = '*'.
    wa_texts-tdline = 'hello'.
    append wa_texts to it_texts.
      wa_texts-tdformat = '*'.
    wa_texts-tdline = 'hello'.
    append wa_texts to it_texts.
    CALL FUNCTION 'SAVE_TEXT'
      EXPORTING
        CLIENT                = SY-MANDT
        HEADER                = wa_txtheader
        INSERT                = 'X'
       SAVEMODE_DIRECT       = ' '
       OWNER_SPECIFIED       = 'X'
      LOCAL_CAT             = ' '
    IMPORTING
      FUNCTION              =
      NEWHEADER             =
      TABLES
        LINES                 = IT_TEXTS
    EXCEPTIONS
       ID                    = 1
       LANGUAGE              = 2
       NAME                  = 3
       OBJECT                = 4
       OTHERS                = 5
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

  • How to generate new perner number using Abap Code in pa0002. what is the fu

    how to generate new perner number using Abap Code in pa0002. what is the function Module used.

    hi
    define internal number ranges for ur implementation then when u run PA 40  do not input any employee number , system will generate the employee number automatically.
    Regards
    sameer

  • How to transfer data in change log table of dso to z-table using abap code

    Hi  can you please explain me how to transfer data in change log table of dso to z-table using abap code ,with out using Function module concept

    PROGRAM NAME:   ZBW_DELTA_TO_GSTAR                                 **
    report ZBW_DELTA_TO_GSTAR no standard page heading
                                     line-size 120
                                     line-count 75
                                     message-id ZBW_MSG_CLS.
    tables:   ZGIV_DLTA_EBV_BB,
              ZGIV_DLTA_EM2_BL,
              ZGIV_DLTA_EM2_BK.
    Selection Screen Definitions
    SELECTION-SCREEN: BEGIN OF BLOCK INNER WITH FRAME TITLE TEXT-001.
    SELECTION-SCREEN: SKIP 1.
    PARAMETERS:       EBVBB RADIOBUTTON GROUP ROLL,
                      EM2BL RADIOBUTTON GROUP ROLL,
                      EM2BK RADIOBUTTON GROUP ROLL.
    SELECTION-SCREEN: END OF BLOCK INNER.
    Data:  WS_UPDATE_FLAG  Type C,
           UCounter(9)      Type N,
           ICounter(9)      Type N.
    DATA:  T_ZGIV_DLTA_EBV_BB Type Standard Table of ZGIV_DLTA_EBV_BB,
           s_ZGIV_DLTA_EBV_BB LIKE line of T_ZGIV_DLTA_EBV_BB.
    DATA:  T_ZGIV_DLTA_EM2_BK Type Standard Table of ZGIV_DLTA_EM2_BK,
           s_ZGIV_DLTA_EM2_BK LIKE line of T_ZGIV_DLTA_EM2_BK.
    DATA:  T_ZGIV_DLTA_EM2_BL Type Standard Table of ZGIV_DLTA_EM2_BL,
           s_ZGIV_DLTA_EM2_BL LIKE line of T_ZGIV_DLTA_EM2_BL.
    Standard Internal Tables - Describe usage.
    data: begin of i_AEPSD_O0140 occurs 0.
            include structure /BIC/AEPSD_O0140.
    data: end of i_AEPSD_O0140.
    data: begin of i_AEPSD_O0240 occurs 0.
            include structure /BIC/AEPSD_O0240.
    data: end of i_AEPSD_O0240.
    data: begin of i_AEPSD_O0340 occurs 0.
            include structure /BIC/AEPSD_O0340.
    data: end of i_AEPSD_O0340.
    data: begin of i_GIV_DLTA_EBV_BB occurs 0.
            include structure ZGIV_DLTA_EBV_BB.
    data: end of i_GIV_DLTA_EBV_BB.
    data: begin of i_GIV_DLTA_EM2_BK occurs 0.
            include structure ZGIV_DLTA_EM2_BK.
    data: end of i_GIV_DLTA_EM2_BK.
    data: begin of i_GIV_DLTA_EM2_BL occurs 0.
            include structure ZGIV_DLTA_EM2_BL.
    data: end of i_GIV_DLTA_EM2_BL.
    Miscellaneous Program Variables and Constants.
    TOP-OF-PAGE
    top-of-page.
    START-OF-SELECTION
    start-of-selection.
      Clear: i_GIV_DLTA_EBV_BB,
             i_GIV_DLTA_EM2_BK,
             i_GIV_DLTA_EM2_BL,
             UCounter, ICounter.
      IF EBVBB = 'X'.
        PERFORM 100_EXTRACT_EBV_BB_DELTA_RECS.
      ELSEIF EM2BK = 'X'.
        PERFORM 100_EXTRACT_EM2_BK_DELTA_RECS.
      ELSE.
        PERFORM 100_EXTRACT_EM2_BL_DELTA_RECS.
      ENDIF.
    FORM 100_EXTRACT_EBV_BB_DELTA_RECS
    FORM 100_EXTRACT_EBV_BB_DELTA_RECS.
      Refresh:   i_AEPSD_O0140,
                 i_GIV_DLTA_EBV_BB.
      Clear:      UCounter, ICounter, s_ZGIV_DLTA_EBV_BB .
      Select * From /BIC/AEPSD_O0140
        Into TABLE i_AEPSD_O0140.
      IF SY-Subrc = 0.
        LOOP AT i_AEPSD_O0140.
          MOVE-CORRESPONDING i_AEPSD_O0140 TO s_ZGIV_DLTA_EBV_BB.
          MOVE SY-DATUM to s_ZGIV_DLTA_EBV_BB-create_dt.
          INSERT ZGIV_DLTA_EBV_BB FROM s_ZGIV_DLTA_EBV_BB.
          IF SY-Subrc = 0.
            ICounter = ICounter + 1.
          ELSE.
            UPDATE ZGIV_DLTA_EBV_BB FROM  s_ZGIV_DLTA_EBV_BB.
            IF SY-Subrc = 0.
              UCounter = UCounter + 1.
            ELSE.
              Message E067 with SY-DATUM ' ' SY-UZEIT ' '.
            ENDIF.
          ENDIF.
        ENDLOOP.
      ENDIF.
    ENDFORM.                    "100_EXTRACT_EBV_BB_DELTA_RECS
    FORM 100_EXTRACT_EM2_BK_DELTA_RECS
    FORM 100_EXTRACT_EM2_BK_DELTA_RECS.
    Refresh:   i_AEPSD_O0240,
               i_GIV_DLTA_EM2_BK.
      Clear:      UCounter, ICounter, s_ZGIV_DLTA_EM2_BK .
      Select * From /BIC/AEPSD_O0240
        Into TABLE i_AEPSD_O0240.
      IF SY-Subrc = 0.
        LOOP AT i_AEPSD_O0240.
          MOVE-CORRESPONDING i_AEPSD_O0240 TO s_ZGIV_DLTA_EM2_BK.
          MOVE SY-DATUM to s_ZGIV_DLTA_EM2_BK-create_dt.
            INSERT ZGIV_DLTA_EM2_BK FROM s_ZGIV_DLTA_EM2_BK.
          IF SY-Subrc = 0.
            ICounter = ICounter + 1.
          ELSE.
            UPDATE ZGIV_DLTA_EM2_BK FROM  s_ZGIV_DLTA_EM2_BK.
            IF SY-Subrc = 0.
              UCounter = UCounter + 1.
            ELSE.
              Message E067 with SY-DATUM ' ' SY-UZEIT ' '.
            ENDIF.
          ENDIF.
        ENDLOOP.
      ENDIF.
    ENDFORM.                    "100_EXTRACT_EM2_BK_DELTA_RECS
    FORM 100_EXTRACT_EM2_BL_DELTA_RECS
    FORM 100_EXTRACT_EM2_BL_DELTA_RECS.
    Refresh:   i_AEPSD_O0340,
               i_GIV_DLTA_EM2_BL.
      Clear:      UCounter, ICounter, s_ZGIV_DLTA_EM2_BL .
      Select * From /BIC/AEPSD_O0340
        Into TABLE i_AEPSD_O0340.
      IF SY-Subrc = 0.
        LOOP AT i_AEPSD_O0340.
          MOVE-CORRESPONDING i_AEPSD_O0340 TO s_ZGIV_DLTA_EM2_BL.
          MOVE SY-DATUM to s_ZGIV_DLTA_EM2_BL-create_dt.
            INSERT ZGIV_DLTA_EM2_BL FROM s_ZGIV_DLTA_EM2_BL.
          IF SY-Subrc = 0.
            ICounter = ICounter + 1.
          ELSE.
            UPDATE ZGIV_DLTA_EM2_BL FROM  s_ZGIV_DLTA_EM2_BL.
            IF SY-Subrc = 0.
              UCounter = UCounter + 1.
            ELSE.
              Message E067 with SY-DATUM ' ' SY-UZEIT ' '.
            ENDIF.
          ENDIF.
        ENDLOOP.
      ENDIF.
    ENDFORM.                    "100_EXTRACT_EM2_BL_DELTA_RECS
    END-OF-SELECTION
    end-of-selection.
      perform D1000_REPORT_DATA.
    D1000_REPORT_DATA
    form D1000_REPORT_DATA.
    *Display the title of the program
      write: /25 SY-TITLE.
      skip.
    Diaplay the details of the user and time
      write: /1 'Executed by', 15 SY-UNAME, 30 'Date',
      38 SY-DATUM, 53 'Time', 60 SY-UZEIT.
      skip 2.
      write: /  'Delta Records have been extracted  ',
             /   'Updates : ', UCounter,
             /   'Inserts : ', ICounter.
      skip.
      skip 3.
      write: /20 'End of the report'.
    endform.                                           "D1000_REPORT_DATA
    chgeck it out this also may hep you

Maybe you are looking for