Delete a variable number of records

Can I do something like this?
DECLARE @del AS INT
SET @del = 10
DELETE TOP(@del) FROM TABLE

Tom,
Look closer in the examples provided in your link
B. Using TOP with a variable
The following example uses a variable to specify the number of employees that are returned in the query result set.
Transact-SQL
USE AdventureWorks2012;
GO
DECLARE @p AS int = 10;
SELECT TOP(@p)JobTitle, HireDate, VacationHours
FROM HumanResources.Employee
ORDER BY VacationHours DESC
GO
You can use variable just fine starting from the SQL 2005 version.
For every expert, there is an equal and opposite expert. - Becker's Law
My blog
My TechNet articles

Similar Messages

  • Best way to delete large number of records but not interfere with tlog backups on a schedule

    Ive inherited a system with multiple databases and there are db and tlog backups that run on schedules.  There is a list of tables that need a lot of records purged from them.  What would be a good approach to use for deleting the old records?
    Ive been digging through old posts, reading best practices etc, but still not sure the best way to attack it.
    Approach #1
    A one-time delete that did everything.  Delete all the old records, in batches of say 50,000 at a time.
    After each run through all the tables for that DB, execute a tlog backup.
    Approach #2
    Create a job that does a similar process as above, except dont loop.  Only do the batch once.  Have the job scheduled to start say on the half hour, assuming the tlog backups run every hour.
    Note:
    Some of these (well, most) are going to have relations on them.

    Hi shiftbit,
    According to your description, in my opinion, the type of this question is changed to discussion. It will be better and 
    more experts will focus on this issue and assist you. When delete large number of records from tables, you can use bulk deletions that it would not make the transaction log growing and runing out of disk space. You can
    take the table offline for maintenance, a complete reorganization is always best because it does the delete and places the table back into a pristine state. 
    For more information about deleting a large number of records without affecting the transaction log.
    http://www.virtualobjectives.com.au/sqlserver/deleting_records_from_a_large_table.htm
    Hope it can help.
    Regards,
    Sofiya Li
    Sofiya Li
    TechNet Community Support

  • Variable number of document info record parameters

    Hi guys,
    I have a question about adding additional information to document info record.
    The situation is following:
    Our customer wants us to link original purchase order (PDF file) with it's document info record in SAP. The document itself is stored in another document management system and we have succeeded in linking this object with it's document info record in SAP.
    He also wants to have some description data stored in document info record (date, description, name, etc). One odd requirement is copying information about cost centers and costs per each cost center from fields in document management system to some fields in document info record.
    The problem is that each purchase order can have various number of cost centers and costs per each cost center!
    So, is there any possibility to define some fields in document info record to which I can store variable number of parameters (for example in one case 3 fields, and maybe in another case 1 field)?
    Any kind of information will be valuable for me!
    Thanks for help!

    Hi,
    But my next question is how can I know how much cost centers will be for some document? If I need to define number of cost centers in advance, then this solution is not very flexible. The best solution would be if I could add values to classification flexibly (for example: one time 3 values and the other time 1 value).
    :-Check box additional values in values tab of char. that will allow to enter flexible number of values any time
    The other question is about values of parameters. For each cost center I need to enter two values (cost center number, and costs for that cost center). So, for each cost center I need to add 2 values. Is that possible using classification?
    :-Create classification with chara. cost center, cost center value and check box additional values as above that will allow you to add values for cost center and cost center value.
    Anirudh.

  • System build-in or system variable to get number of records from a query

    Hi,
    Is there a system build-in or system variable to get number of records from a Oracle Forms query?
    Thank you

    Namely, when GO_BLOCK(BLOCK_NAME) EXECUTE QUERY finishes, is there a way directly get the number of the records?
    SYSTEM.COURSOR_RECORD = 1 tells this is the first record
    SYSTEM.LAST_RECORD = 'TRUE' tells this is the last record
    Thanks

  • Code to verify the number of records before selective deletion

    In order to archive some old data, I would like to do a selective deletion in the source cube after their transfer in the archive cube  by launching a program.
    I’ve seen in this forum that the name of the function module to do a selective deletion is RSDRD_SEL_DELETION.
    Nevertheless, I would like to check before if the <b>number of records</b> of the <b>archiving period</b> in my archive <b>cube</b> is the same as in my source cube.
    Who can help me to write the code to do this check with a selection of time? Thanks in advance

    Hi Domi,
    You can do it via the cintents tab in the management function of the infoprovider.
    There also is an selective deletion function button.

  • Count total number of record of table with deletion from archiving object

    Does anyone know is there any SAP standard program to count the total number of record of the table with deletion from Archiving Object and display in repprt?

    Not sure of the question. Are you looking to get the sql "select count(*) from table" from using the TopLink expression framework or are you getting that SQL already and want something else?
    If you are looking just to get the count from a table/class, you can use a ReportQuery:
    ReportQuery rquery = new ReportQuery(ClassToQueryOn.class);
    rquery.addCount(); //equivalent to count(*);
    session.executeQuery(rquery);
    You can use a report query to return data instead of objects, and use selection criteria just like a normal read query.
    Best Regards,
    Chris

  • Variable to hold the number of records returned by the SQL Query.

    Hi folks,
    Is there any way to hold the number of records that could be returned by the SQL query we use to make a report?
    If so, please do come up with the answer.
    Cheers,
    PCZ.

    Hi there,
    Well, there is no actual business requirement.
    It is just the curiosity of mine.
    I would like to handle
    1) the number of records our report query returns or
    2) the query itself
    to write a better pl/sql code in any trigger/program unit, if any business logic beckons in future.
    Cheers,
    PCZ.

  • Total number of records in given range.

    total number of records in given range.
    Hi all ,
    I have the Requirement as follows.
    I Have a Table which Contains Duplicate Dates like
    22.11.2006
    15.11.2006
    31.10.2006
    15.09.2006
    15.09.2006
    14.09.2006
    15.09.2006
    14.09.2006
    16.09.2006
    etc...
    The input is monday of any week of a Year. Suppose 3 rd week starts from 15.11.2006 and ends to 21.11.2006. Weekly 5 days are working days. If i ienter the 15.09.2006 as input.....
    The Required out put is : 5 Records ( In above example 15.09.2006 to 21.09.2006 total Number of records is 5. I mean 15.09.2006 is Found 4 times + 16.09.2006 is found 1 time in the Specied Range.
    total: 4+1 = 5 records.)
    Simply...my requirement is to find total number of Records(with Duplicates) in the Given range .
    thanks in Advance
    sivaranga& Krish...

    this is the code. Where i have to make changes..
    this is the program which they given
    Report Title:         /GIL/ZZKWKBKS
    Author:               XNIMKARP
    Creation Date:        29.09.2006
    ZSAO System:          <&system>  (blue)
    ZSAO System Fct.:     <&sf>      (green)
    DER:                  DER&
    HLD:                  HLD&
    Request number:
    Description (technical)
    ===================================================================
    Modification History  (recent on top / refs: MODnnn+ or MODnnn-)
    Modification Number:  MODnnn
    Modifier:             &userid
    Modification Date:    &
    Change object:        DER, TPR, Clarify number
    Request number:
    Description
    Modification Number:  MOD001
    Modifier:             &userid
    Modification Date:    &
    Change object:        DER, TPR, Clarify number
    Request number:
    Description
    REPORT /GIL/ZZKWKBKS
             MESSAGE-ID  ??               "....
           NO STANDARD PAGE HEADING
           LINE-COUNT 65(0)
           LINE-SIZE 132.
    eject*******************************************************
    Data Declaration Section                                   *
    TABLE declarations for select-options only                 *
    TABLES: /GIL/ZZKDERMAST ,
            /GIL/ZZKCOMBOOK ,
            /GIL/ZZKWEEKID .
    SELECT-OPTIONS and PARAMETERS                              *
    SELECT-OPTIONS:
        S_STRWK   FOR /GIL/ZZKWEEKID-STRWK  NO INTERVALS .          "....
    "PARAMETERS:
    "    P_????  TYPE ????-????? DEFAULT ?,   "description ????
    "    PX_??? AS CHECKBOX                   "description ????
    TYPES                                                      *
    TYPES:
          begin of T_IT_OUTTAB  ,
              STRWK like  /GIL/ZZKCOMBOOK-STRWK ,
              CSTMZ like  /GIL/ZZKDERMAST-CSTMZ ,
              NAME_TEXT like ADRP-NAME_TEXT ,
              DERNO like  /GIL/ZZKCOMBOOK-DERNO ,
              BNAME like  /GIL/ZZKCOMBOOK-BNAME ,
              HRSBK like  /GIL/ZZKCOMBOOK-HRSBK ,
              STATS like  /GIL/ZZKDERMAST-STATS ,
              CLSDT like  /GIL/ZZKDERMAST-CLSDT ,
              MNTHI like  /GIL/ZZKWEEKID-MNTHI ,
              QRTRI like  /GIL/ZZKWEEKID-QRTRI ,
        end of T_IT_OUTTAB  .
    TYPES:
        begin of  T_IT_WEEKSUM ,
            STRWK  like  /GIL/ZZKCOMBOOK-STRWK ,
            MNTHI like  /GIL/ZZKWEEKID-MNTHI ,
            QRTRI like  /GIL/ZZKWEEKID-QRTRI ,
            DEVHRS like  /GIL/ZZKCOMBOOK-HRSBK ,
            CUSHRS like  /GIL/ZZKCOMBOOK-HRSBK ,
            TOTHRS like  /GIL/ZZKCOMBOOK-HRSBK ,
            DVMHRS like  /GIL/ZZKCOMBOOK-HRSBK ,
            CSMHRS like  /GIL/ZZKCOMBOOK-HRSBK ,
            TOMHRS like  /GIL/ZZKCOMBOOK-HRSBK ,
            DVQHRS like  /GIL/ZZKCOMBOOK-HRSBK ,
            CSQHRS like  /GIL/ZZKCOMBOOK-HRSBK ,
            TOQHRS like  /GIL/ZZKCOMBOOK-HRSBK ,
            TOTDER like  /GIL/ZZKCOMBOOK-HRSBK ,
            TOMDER like  /GIL/ZZKCOMBOOK-HRSBK ,
            TOQDER like  /GIL/ZZKCOMBOOK-HRSBK ,
        end of  T_IT_WEEKSUM .
    TYPES:
        begin of  T_IT_DEVSUM ,
            NAME_TEXT like ADRP-NAME_TEXT ,
            HRSBK like  /GIL/ZZKCOMBOOK-HRSBK ,
        end of  T_IT_DEVSUM .
    "TYPES: T_FL_???  TYPE ????-?????.          "description ???
    "TYPES: T_IT_???  TYPE ????-?????.          "description ???
    VARIABLES                                                  *
    "DATA: V_???   TYPE ????-?????.          "field description
    "DATA: VX_???  TYPE ????-?????.          "flag description
    DATA:  VIT_DATATAB TYPE T_IT_OUTTAB occurs 0 with header line.
    DATA:  VIT_WEEKSUM TYPE T_IT_WEEKSUM occurs 0 with header line.
    DATA:  VIT_DEVSUM TYPE T_IT_DEVSUM occurs 0 with header line.
    constants                                                  *
    CONSTANTS: C_BR1    TYPE C VALUE '(' ,
               C_BR2    TYPE C VALUE ')' ,
               C_DASH   TYPE C VALUE '-' ,
               C_005    TYPE I VALUE '5' ,
               C_006    TYPE I VALUE '6' ,
               C_030    TYPE I VALUE '30' ,
               C_031    TYPE I VALUE '31' ,
               C_055    TYPE I VALUE '55' ,
               C_056    TYPE I VALUE '56' ,
               C_080    TYPE I VALUE '80' ,
               C_081    TYPE I VALUE '81' ,
               C_105    TYPE I VALUE '105' ,
               C_106    TYPE I VALUE '106' ,
               C_125    TYPE I VALUE '126' ,
               C_130    TYPE I VALUE '130' ,
               C_150    TYPE I VALUE '150' .
    eject*******************************************************
    program section  (EVENTS)                                  *
    start of database access                                   *
    START-OF-SELECTION.
    PERFORM FETCH_BOOKING_DATA .
    PERFORM FETCH_USER_DATA .
    PERFORM WEEKLY_CUMULATION .
    TOP-OF-PAGE.
       PERFORM WRITE_HEADER .
    *&      Form  FETCH_BOOKING_DATA
          text
    -->  p1        text
    <--  p2        text
    FORM FETCH_BOOKING_DATA .
        select a~STRWK
              a~DERNO
              a~BNAME
              a~HRSBK
              b~STATS
              b~CLSDT
              b~CSTMZ
              c~MNTHI
              c~QRTRI
        into corresponding fields of table VIT_DATATAB
        from  /GIL/ZZKCOMBOOK as a
        inner join /GIL/ZZKDERMAST as b
        on   bBNAME = aBNAME
        and  bDERNO = aDERNO
        inner join /GIL/ZZKWEEKID as c
        on cSTRWK = aSTRWK
        where a~STRWK in S_STRWK .
        if SY-SUBRC <>  0 .
            WRITE /10 TEXT-001.
            EXIT .
        endif .
    ENDFORM.                    " FETCH_BOOKING_DATA
    *&      Form  FETCH_USER_DATA
          text
    -->  p1        text
    <--  p2        text
    FORM FETCH_USER_DATA .
    DATA:
        BEGIN OF LIT_USER OCCURS 0 ,
            BNAME like  /GIL/ZZKCOMBOOK-BNAME ,
            NAME_TEXT like ADRP-NAME_TEXT ,
        END OF LIT_USER .
    DATA : L_SY_TABIX LIKE SY-TABIX .
        LOOP AT VIT_DATATAB .
          MOVE-CORRESPONDING VIT_DATATAB TO LIT_USER .
          APPEND LIT_USER .
        ENDLOOP .
        DELETE ADJACENT DUPLICATES FROM LIT_USER COMPARING BNAME .
         if LIT_USER[] is not initial .
               SELECT BBNAME ANAME_TEXT
               INTO corresponding fields of table LIT_USER
               FROM ADRP AS A
               INNER JOIN USR21 AS B
               ON BPERSNUMBER = APERSNUMBER
               for all entries in LIT_USER
               WHERE B~BNAME = LIT_USER-BNAME .
         endif.
        loop at VIT_DATATAB .
          L_SY_TABIX = SY-TABIX .
          read table LIT_USER with key BNAME = VIT_DATATAB-BNAME .
          if sy-subrc = 0 .
              VIT_DATATAB-NAME_TEXT = LIT_USER-NAME_TEXT .
               modify VIT_DATATAB index L_SY_TABIX .
          endif .
        endloop.
    ENDFORM.                    " FETCH_USER_DATA
    *&      Form  WEEKLY_CUMULATION
          text
    -->  p1        text
    <--  p2        text
    FORM WEEKLY_CUMULATION .
    DATA:
        L_PREV_MNTHI  like /GIL/ZZKWEEKID-MNTHI ,
        L_PREV_QRTRI  like /GIL/ZZKWEEKID-QRTRI ,
        LFL_DATATAB_WA  TYPE T_IT_OUTTAB .
      SORT VIT_DATATAB BY STRWK CSTMZ NAME_TEXT .
      loop at VIT_DATATAB .
          move-corresponding VIT_DATATAB to LFL_DATATAB_WA .
          AT END OF NAME_TEXT .
              SUM .
              VIT_DEVSUM-NAME_TEXT =  VIT_DATATAB-NAME_TEXT .
              VIT_DEVSUM-HRSBK = VIT_DATATAB-HRSBK .
              APPEND VIT_DEVSUM .
          ENDAT .
          AT END OF CSTMZ .
              SUM .
              if LFL_DATATAB_WA-CSTMZ IS INITIAL .
                  VIT_DEVSUM-NAME_TEXT =  TEXT-011 .
              else.
                  VIT_DEVSUM-NAME_TEXT =  TEXT-012 .
              endif.
              VIT_DEVSUM-HRSBK = VIT_DATATAB-HRSBK .
              APPEND VIT_DEVSUM .
          ENDAT .
          AT END OF STRWK .
            CLEAR: VIT_WEEKSUM-DEVHRS ,
                  VIT_WEEKSUM-CUSHRS ,
                  VIT_WEEKSUM-TOTHRS .
            VIT_WEEKSUM-STRWK = LFL_DATATAB_WA-STRWK .
            VIT_WEEKSUM-MNTHI = LFL_DATATAB_WA-MNTHI .
            VIT_WEEKSUM-QRTRI = LFL_DATATAB_WA-QRTRI .
            SUM .
            VIT_WEEKSUM-TOTHRS = VIT_DATATAB-HRSBK .
            VIT_DEVSUM-NAME_TEXT =  TEXT-013 .
            VIT_DEVSUM-HRSBK = VIT_DATATAB-HRSBK .
            APPEND VIT_DEVSUM .
            SELECT SUM( HRSBK )
            INTO VIT_WEEKSUM-CUSHRS
            from /GIL/ZZKWEKBK
            where STRWK = LFL_DATATAB_WA-STRWK
            AND   CSTMZ NE  SPACE .
            VIT_WEEKSUM-DEVHRS =
                VIT_WEEKSUM-TOTHRS - VIT_WEEKSUM-CUSHRS .
           IF LFL_DATATAB_WA-MNTHI <> L_PREV_MNTHI .
              if week falls in differnet month .
                 L_PREV_MNTHI = LFL_DATATAB_WA-MNTHI  .
                CLEAR: VIT_WEEKSUM-DVMHRS ,
                       VIT_WEEKSUM-CSMHRS ,
                       VIT_WEEKSUM-TOMHRS .
                SELECT SUM( HRSBK )
                INTO VIT_WEEKSUM-DVMHRS
                from /GIL/ZZKWEKBK
                where MNTHI =  LFL_DATATAB_WA-MNTHI
                AND   CSTMZ EQ SPACE .
                SELECT SUM( HRSBK )
                INTO VIT_WEEKSUM-CSMHRS
                from /GIL/ZZKWEKBK
                where MNTHI =  LFL_DATATAB_WA-MNTHI
                AND   CSTMZ NE  SPACE .
                VIT_WEEKSUM-TOMHRS =
                    VIT_WEEKSUM-DVMHRS + VIT_WEEKSUM-CSMHRS  .
            ENDIF .
          IF LFL_DATATAB_WA-QRTRI <> L_PREV_QRTRI .
                L_PREV_QRTRI = LFL_DATATAB_WA-QRTRI .
                SELECT SUM( HRSBK )
                INTO VIT_WEEKSUM-DVQHRS
                from /GIL/ZZKWEKBK
                where QRTRI = LFL_DATATAB_WA-QRTRI
                AND   CSTMZ EQ SPACE .
                SELECT SUM( HRSBK )
                INTO VIT_WEEKSUM-CSQHRS
                from /GIL/ZZKWEKBK
                where QRTRI = LFL_DATATAB_WA-QRTRI
                AND   CSTMZ NE  SPACE .
                VIT_WEEKSUM-TOQHRS =
                    VIT_WEEKSUM-DVQHRS + VIT_WEEKSUM-CSQHRS  .
          ENDIF .
          APPEND VIT_WEEKSUM .
          NEW-PAGE .
          PERFORM WRITE_WEEKLY_STATISTICS .
          PERFORM WRITE_DEVELOPER_STATISTICS .
          ENDAT .
       endloop .
    ENDFORM.                    " WEEKLY_CUMULATION
    *&      Form  WRITE_DEVELOPER_STATISTICS
          text
    -->  p1        text
    <--  p2        text
    FORM WRITE_DEVELOPER_STATISTICS .
    SKIP 2.
    WRITE AT: /C_005 TEXT-014 .
      ULINE AT /C_005(C_125) .
      WRITE AT:/C_005 SY-VLINE ,
                C_006 TEXT-014 ,
                C_080 SY-VLINE ,
                C_081 TEXT-015 ,
                C_130 SY-VLINE .
       WRITE AT: C_005 SY-VLINE ,
                C_080 SY-VLINE ,
                C_130 SY-VLINE .
        ULINE AT /C_005(C_125) .
        loop at VIT_DEVSUM .
              CASE VIT_DEVSUM-NAME_TEXT .
              WHEN TEXT-011 .
                  WRITE AT:/C_005 SY-VLINE ,
                            C_006 VIT_DEVSUM-NAME_TEXT COLOR COL_NEGATIVE  ,
                            C_080 SY-VLINE ,
                            C_081 VIT_DEVSUM-HRSBK COLOR COL_NEGATIVE   ,
                            C_130 SY-VLINE .
               WHEN TEXT-012 .
                  WRITE AT:/C_005 SY-VLINE ,
                            C_006 VIT_DEVSUM-NAME_TEXT COLOR COL_NEGATIVE  ,
                            C_080 SY-VLINE ,
                            C_081 VIT_DEVSUM-HRSBK COLOR COL_NEGATIVE   ,
                            C_130 SY-VLINE .
               WHEN TEXT-013 .
                    WRITE AT:/C_005 SY-VLINE ,
                            C_006 VIT_DEVSUM-NAME_TEXT COLOR COL_TOTAL  ,
                            C_080 SY-VLINE ,
                            C_081 VIT_DEVSUM-HRSBK COLOR COL_TOTAL    ,
                            C_130 SY-VLINE .
                WHEN OTHERS .
                    WRITE AT:/C_005 SY-VLINE ,
                            C_006 VIT_DEVSUM-NAME_TEXT   ,
                            C_080 SY-VLINE ,
                            C_081 VIT_DEVSUM-HRSBK     ,
                            C_130 SY-VLINE .
               ENDCASE .
               WRITE AT: C_005 SY-VLINE ,
                C_080 SY-VLINE ,
                C_130 SY-VLINE .
               ULINE AT /C_005(C_125) .
        endloop .
        REFRESH VIT_DEVSUM .
        CLEAR VIT_DEVSUM .
    ENDFORM.                    " WRITE_DEVELOPER_STATISTICS
    *&      Form  WRITE_WEEKLY_STATISTICS
          text
    -->  p1        text
    <--  p2        text
    FORM WRITE_WEEKLY_STATISTICS .
       SKIP 2.
       ULINE AT C_005(C_125) .
       WRITE AT: /C_005 SY-VLINE ,
                  C_006 TEXT-003 ,
                  C_030 SY-VLINE ,
                  C_031 TEXT-004 ,
                  C_055 SY-VLINE ,
                  C_056 TEXT-005 ,
                  C_080 SY-VLINE ,
                  C_081 TEXT-006 ,
                  C_105 SY-VLINE ,
                  C_106 TEXT-007 ,
                  C_130 SY-VLINE .
       WRITE AT: /C_005 SY-VLINE ,
                  C_030 SY-VLINE ,
                  C_031 /GIL/ZZKWEEKID-STRWK ,
                  41    C_DASH ,
                  43    /GIL/ZZKWEEKID-ENDWK ,
                  C_055 SY-VLINE ,
                  C_056 VIT_WEEKSUM-MNTHI ,
                  C_080 SY-VLINE ,
                  C_081 VIT_WEEKSUM-QRTRI ,
                  C_105 SY-VLINE ,
                  C_130 SY-VLINE .
        WRITE AT: /C_005 SY-VLINE ,
                  C_030 SY-VLINE ,
                  C_055 SY-VLINE ,
                  C_080 SY-VLINE ,
                  C_105 SY-VLINE ,
                  C_130 SY-VLINE .
         ULINE AT C_005(C_125) .
        WRITE AT: /C_005 SY-VLINE ,
                  C_006 TEXT-008 ,
                  C_030 SY-VLINE ,
                  C_031 VIT_WEEKSUM-DEVHRS ,
                  C_055 SY-VLINE ,
                  C_056 VIT_WEEKSUM-DVMHRS ,
                  C_080 SY-VLINE ,
                  C_081 VIT_WEEKSUM-DVQHRS ,
                  C_105 SY-VLINE ,
                  C_130 SY-VLINE .
        WRITE AT: /C_005 SY-VLINE ,
                  C_030 SY-VLINE ,
                  C_055 SY-VLINE ,
                  C_080 SY-VLINE ,
                  C_105 SY-VLINE ,
                  C_130 SY-VLINE .
        ULINE AT C_005(C_125) .
        WRITE AT: /C_005 SY-VLINE ,
                  C_006 TEXT-009 ,
                  C_030 SY-VLINE ,
                  C_031 VIT_WEEKSUM-CUSHRS ,
                  C_055 SY-VLINE ,
                  C_056 VIT_WEEKSUM-CSMHRS ,
                  C_080 SY-VLINE ,
                  C_081 VIT_WEEKSUM-CSQHRS ,
                  C_105 SY-VLINE ,
                  C_130 SY-VLINE .
        WRITE AT: /C_005 SY-VLINE ,
                  C_030 SY-VLINE ,
                  C_055 SY-VLINE ,
                  C_080 SY-VLINE ,
                  C_105 SY-VLINE ,
                  C_130 SY-VLINE .
        ULINE AT C_005(C_125) .
        WRITE AT: /C_005 SY-VLINE COLOR COL_TOTAL,
                  C_006 TEXT-010 COLOR COL_TOTAL,
                  C_030 SY-VLINE COLOR COL_TOTAL ,
                  C_031 VIT_WEEKSUM-TOTHRS COLOR COL_TOTAL,
                  C_055 SY-VLINE COLOR COL_TOTAL,
                  C_056 VIT_WEEKSUM-TOMHRS COLOR COL_TOTAL,
                  C_080 SY-VLINE COLOR COL_TOTAL,
                  C_081 VIT_WEEKSUM-TOQHRS COLOR COL_TOTAL,
                  C_105 SY-VLINE COLOR COL_TOTAL,
                  C_130 SY-VLINE COLOR COL_TOTAL.
        WRITE AT: /C_005 SY-VLINE ,
                  C_030 SY-VLINE ,
                  C_055 SY-VLINE ,
                  C_080 SY-VLINE ,
                  C_105 SY-VLINE ,
                  C_130 SY-VLINE .
        ULINE AT C_005(C_125) .
    ENDFORM.                    " WRITE_WEEKLY_STATISTICS
    *&      Form  WRITE_HEADER
          text
    -->  p1        text
    <--  p2        text
    FORM WRITE_HEADER .
    SKiP 1 .
    SELECT SINGLE *
    FROM /GIL/ZZKWEEKID
    WHERE STRWK = VIT_WEEKSUM-STRWK .
    WRITE AT:  5 TEXT-002 INTENSIFIED ON .
    WRITE AT:  47 /GIL/ZZKWEEKID-MNTHI ,
                55 /GIL/ZZKWEEKID-WEEKI ,
                65 C_BR1 ,
                67 /GIL/ZZKWEEKID-STRWK ,
                78 C_DASH ,
                80 /GIL/ZZKWEEKID-ENDWK ,
                91 C_BR2
                INTENSIFIED ON  .
    ENDFORM.                    " WRITE_HEADER

  • How to calculate the number of records in Multiprovider

    Hi Experts
    I have created a report based on the multiprovider (Consist of Cube and ODS)
    I need count the number of records inside the multiprovider, how can i do it in the reporting level
    Regards
    Santosh

    Hi,
    You can use calculated key figure with replacement path variable.
    Follow This:
    1) From the context menu of the Key Figure directory, choose New Calculated Key Figure.
    2) From the context menu for the Formula Variable, choose New Variable.
    3) Choose the Processing type as Replacement Path.
    4) In the next screen, select the Characteristic Info Object based on which the number of documents is to be displayed in the report (For example: Document Number / Order Number).
    5) Choose Next.
    In the Replace Variable with drop down box, choose Attribute Value.
    In the Attribute drop down, select Characteristic Reference (Constant 1).
    6)Choose Next.
    On the Save Variable page, an overview of the settings made for the variable will be displayed.
    Confirm the entries and Choose Finish.
    7) If the Formula variable is directly assigned to the Calculated Key Figure, a warning Calculated Key Figure is not defined correctly will be displayed while executing the Query.
    8) Properties of Calculated Key Figure dialog box, assign a Technical name for the CKF.
    9) set the Time of Calculation to After Aggregation.
    Hope this will help you.
    Cheers,
    DK
    Edited by: Debasish Khaitan on May 14, 2009 1:03 PM

  • BAPI to find the number of records existing in HR module

    Hi ,
    I wanted to know if there exist BAPI  that would return me the number of SAP HR module users in a system.
    I cam across the BAPI's for info types like  personu2019s Personal Data (Infotype 0002)
    BAPI_PERSDATA_CHANGE u2013 Change personal data
    BAPI_PERSDATA_CREATE u2013 Create personal data
    BAPI_PERSDATA_CREATESUCCESSOR u2013 Create subsequent personal data record
    BAPI_PERSDATA_DELETE u2013 Delete personal data
    BAPI_PERSDATA_DELIMIT u2013 Delimit personal data validity period
    BAPI_PERSDATA_GETDETAIL u2013 Read personal data
    BAPI_PERSDATA_GETDETAILEDLIST u2013 read instances with data
    BAPI_PERSDATA_GETLIST u2013 Read instances
    But i wanted to know if there exist a master table which would  return me the number of records irresepctive of the  infotypes.
    Best Regards
    Manoj

    Hi,
    if you want to know the number of employees, then u should  use the infotype PA00001 and PA0000 with appropriate criteria. Infotype PA0002 should not be used to find the number of employees in the HR.
    As you requested there are no specific BAPI to find the records. Hope this helps you.
    Or u can use PAR2 transaction to find details.
    Thanks,
    Saibaba Kondani
    Edited by: Kondani Saibaba on Aug 19, 2009 7:33 AM

  • How to print new main report page based on number of records in subreport?

    Hi,
    I've a main report which prints on a pre-printed stationary with 2 subreports in the detail section.  The subreport prints multiple records.  If there are more than 6 records in the subreports, a new page should be printed with all the contents of the main report and the subreports should continue with the remaining records.  How can I do this?  I've tried incrementing a shared variable counter in the subreport and accessed that variable in the detail section of the main report to check the counter and reset the counter to 0 if it exceeds 6.  But this does not work.  All the lines till it can hit page footer are printing on first page and the second page prints only the remaining subreport lines without the other details of the main report page. 
    The main report page uses a view which returns only 1 record. The subreport returns multiple records. 
    I would certainly appreciate if any one can provide a solution for this problem. 
    Thanks,
    Ram

    hi Ram,
    sorry, i misunderstood exactly what you wanted.
    let me get this straight...
    1) if there's more than 6 records in the subreport then show only the first 6 records
    2) then (if there's more than 6 records) do a new page after the subreport
    3) then (if there's more than 6 records) show the subreport's remaining records and the rest of the report
    let know if i've got it straight.
    if that is correct, you will have received another sample report that does this. in total 3 subreports are used...one is a dummy report that adds up the number of records which is used later. there's more info on the report's design mode.
    cheers,
    jamie

  • How to determine number of records in recordset returned by stored procedure?

    In TestStand 3.0 I am calling an SQL stored procedure where the stored
    procedure returns a recordset. Everything appears to work (I can
    iterate through the recordset and see that the data is valid).
    However, I can not figure out how to easilly determine how many
    records are actually in the recordset. Unlike the 'Open SQL
    Statement' step, in the 'Data Operation' step that actually invokes
    the stored procedure, there is no 'Number of Records Selected' option
    to specify a TestStand variable to accept this value. I know I could
    iterate through the returned recordset incrementing a counter until a
    Fetch fails, but for larger recordsets, traversing the table multiple
    times would be quite time consuming
    . I am hoping to avoid this if
    possible. Is there an easier way to get the number of records in a
    recordset returned from a stored procedure call?
    Bob

    Bob -
    The cursor type of the ADO Recordset object affects whether the number of records can be determined. The Recordset.RecordCount property will return -1 for a forward-only cursor; the actual count for a static or keyset cursor; and either -1 or the actual count for a dynamic cursor, depending on the data source.
    Because ADO does not let me set the cursor type for command objects which is what a stored procedure requires, it is up to the data source to determine the type of cursor and the support for record count.
    Scott Richardson (NI)
    Scott Richardson
    National Instruments

  • Variable number of parameters in a procedure

    Hello !
    I have a form in a procedure with dynamic inputs type "checkbox" (one checkbox by record of a table).
    The action of the form is another procedure. There is a variable number of parameters (depending on checked inputs).
    How can I do for retreiving these variable data within a single variable in my second procedure ?
    Thanks for help and sample
    null

    What u can do is use Javascript and pass all the selected checkbox Ids as a dilimited string..which u can read in second procedure and can perform appropriate action. for example if you have check box named as chk1,chk2,chk3,chk4 n so on..
    now if chk1,chk3,chk4 are checked then pass this string in the hidden field "1|3|4"which is a |(pipe) delimited string..

  • Number of records in internal table

    Hi
    How can I tjeck an internal table for the number of records it contains (even if it contains 0).
    Thanks in advance, regards
    Torben

    Hi,
    DESCRIBE TABLE itab.
    Effect
    Returns the attributes of the internal table itab. You must use at least one of the additions listed below:
    Note
    The DESCRIBE statement cannot be used for all ABAP types. In connection with ABAP Objects, SAP has introduced a RTTI concept based on system classes to determine type attributes at runtime. This concept applies to all ABAP types and as such covers all the functions of the DESCRIBE TABLE statement.
    Extras:
    1. ... LINES n
    2. ... OCCURS n
    3. ... KIND   k
    Addition 1
    ... LINES n
    Effect
    Places the number of filled lines of the table t in the field lin. The value returned to lin has type I.
    Note
    The number of filled lines of the table itab can also be ascertained using the predefined function lines( itab ).
    Example
    DATA: N    TYPE I,
          ITAB TYPE TABLE OF I.
    CLEAR ITAB.
    APPEND 36 TO ITAB.
    DESCRIBE TABLE ITAB LINES N.
    Result: N contains the value 1.
    Addition 2
    ... OCCURS n
    Effect
    Passes the size of the OCCURS parameter from the table definition (as defined with DATA) to the variable n. The value returned to n has type I.
    Example
    DATA: N1    TYPE I,
          N2    TYPE I,
          ITAB1 TYPE TABLE OF I INITIAL SIZE 10,
          ITAB2 TYPE I OCCURS 5.
    DESCRIBE TABLE ITAB1 OCCURS N1.
    DESCRIBE TABLE ITAB2 OCCURS N2.
    Result: OCC contains the value 10 and N2 the value 5.
    Addition 3
    ... KIND k
    Effect
    Writes the table type from itab to the variables n. The value returned to k is of type C. The constants SYDES_KIND-STANDARD, SYDES_KIND-SORTED and SYDES_KIND-HASHED are defined in the type group SYDES for the return values.
    Example
    Generic FORM routine any table type
    TYPE-POOLS: SYDES.
    FORM GENERIC_FORM USING ITAB TYPE ANY TABLE.
      DATA: K TYPE C.
      DESCRIBE TABLE ITAB KIND K.
      CASE K.
        WHEN SYDES_KIND-STANDARD.
        WHEN SYDES_KIND-SORTED.
        WHEN SYDES_KIND-HASHED.
      ENDCASE.
    ENDFORM.
    Notes
    Performance: The runtime for executing the DESCRIBE TABLE statement is approximately 4 msn (standardized microseconds).
    The DESCRIBE TABLE statement also passes values to the SY-TFILL and SY-TLENG System fields
    Additional help
    Determining the Attributesof Internal Tables
    Thanks,
    Sankar M

  • Number of records in a standard table

    Hi,
    How to find number of records, without fetching them into a internal table?
    is there any command for that?
    I want to know the number of records of a standard table in a report.
    Thanks

    Hi,
    If you want to know the number of records in your internal table after select statement.
    You can use the below statement.
    data : wa_lines like sy-tfill.
    DESCRIBE TABLE itab LINES WS_LINES.
    In wa_lines you will have the number of records.
    If you want to know the number of records from standard itself.
    You can use below :
    select count(*) from table into variable
    endselect.
    Thanks,
    Sriram Ponna.

Maybe you are looking for