Filtering in Document Count

Hi,
  I have a doubt on Query.
I need to display the Count of Closed and Pending  service Orders in the report.
I have info Object 0CRM_USSTAT which contains all the status of the Service Orders.
Based on the document "How to Get the Document Count in a Query using Formula Variable with Processing Type Replacement Path", I can able to count the Service Orders. But i need to display the count only for Closed Service Orders and Pending Service Orders.
Can u pls provide what are the steps i need to perform.
Thanks,
Shahina A

Hi Shahina,
How to Get the Document Count in a Query using Formula Variable with Processing Type Replacement Path :
Pre-requisites:
Document Number (Purchase Order/Sales Order Number) should have been included as a characteristic in the Info Cube. It can be defined as a Line Item dimension for better Query performance.
Summary
In some business scenarios, it may be required to find out the document count for analyzing certain Key Performance Indicators (For example Number of Orders in a given period). This article illustrates the steps to get the Document Count in a Query using Formula variable with processing type as Replacement path. This article also brings forth one of the major differences between Calculated Key Figure and New Formula.
Create a New Calculated Key Figure
The first step is to create a New Calculated Key figure for the Number of Documents/Orders.
Open Query Designer.
Create a new query or open an existing Query.
Drag and drop the required Characteristics and Key figures to the rows and columns depending on your business-reporting requirement.
From the context menu of the Key Figure directory, choose New Calculated Key Figure.
Provide a description, for example Number of Documents/Orders.
The next step is creating a formula variable for getting the document count.
From the context menu for the Formula Variable, choose New Variable. 
Provide the technical name and description for the variable.
Choose the Processing type as Replacement Path.
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). 
Choose Next.
In the Replace Variable with drop down box, choose Attribute Value.
In the Attribute drop down, select Characteristic Reference (Constant 1).
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. 
Open the formula variables directory and use Drag & Drop to transfer the formula variable as shown in the screen shot.
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.
To avoid the warning message, the formula variable is multiplied by 1 as shown in the screen shot.
Choose OK.
In the Properties of Calculated Key Figure dialog box, assign a Technical name for the CKF.
Set the number of Decimal placed to 0.
The most important step here is to set the Time of Calculation to After Aggregation.
Then only the total Number of Documents/Orders will be displayed correctly in the report.
If itu2019s set to Before aggregation, when an existing document is changed in the source and data is loaded to the cube using a new delta request, the document count will be displayed as two instead of one.
By Default the Time of Calculation is set to After Aggregation. 
Choose OK. 
The new calculated key figure is available under Calculated Key Figure in the Key Figure directory, and can be included in the query definition using Drag & Drop as shown in the screen shot below.
You may have to include another Key Figure also in the definition; otherwise an error message will be displayed in the query. If you donu2019t want to display the newly added key figure in the report, you can hide it by choosing Properties from context menu of the key figure and selecting the Hide option.
Save and Execute the Query.
The sample report shown here displays the total number of Documents/Orders for each plant on a daily basis. 
Why Calculated Key figure instead of New Formula?
The replacement of formula variables with the processing type Replacement Path acts differently in calculated key figures and formulas:
If you use a formula variable with u201CReplacement from the Value of an Attributeu201D in a calculated key figure, then the system automatically adds the drilldown according to the reference characteristic for the attribute. The system then evaluates the variables for each characteristic value for the reference characteristic. Afterwards, the calculated key figure is calculated and, subsequently, all of the other operations are executed, meaning all additional, calculated key figures, aggregations, and formulas. The system only calculates the operators, which are assembled in the calculated key figure itself, before the aggregation using the reference characteristic.
If you use a formula variable with Replacement from the Value of an Attribute in a formula element, then the variable is only calculated if the reference characteristic is uniquely specified in the respective row, column, or in the filter.

Similar Messages

  • Oracle Text - Problem with filtering binary documents (.doc, .pdf, etc...)

    Hi, I have a problem with filtering binary documents (.doc, .pdf, etc...). I use SQL*PLUS for remote access to Oracle 10.2 on Linux and I create table:
    CREATE TABLE test (id NUMBER PRIMARY KEY, text VARCHAR2(100));
    I insert to this table:
    INSERT into test values(1, 'PATH/text1.doc‘);
    INSERT into test values(2,'PATH/text2.doc‘);
    and then:
    CREATE INDEX test_index ON test(text) indextype is ctxsys.context
    parameters (’datastore ctxsys.file_datastore
    filter ctxsys.auto_filter’);
    Message "Index created" is displayed, but objects: DR$test_index$I, DR$test_index$K, DR$test_index$N, DR$test_index$R and DR$test_index$P are empty => index wasn´t created probably.
    I don´t know, where is bug, either bug is somewhere in this code or on the server (wrong installation oracle or constraint privileges). Do you know in what is bug?

    The following is an excerpt from the 10g online documentation. Note the items that I have put in bold.
    "FILE_DATASTORE
    The FILE_DATASTORE type is used for text stored in files accessed through the local file system.
    Note:
    FILE_DATASTORE may not work with certain types of remote mounted file systems.
    FILE_DATASTORE has the following attribute(s):
    Table 2-4 FILE_DATASTORE Attributes
    Attribute Attribute Value
    path path1:path2:pathn
    path
    Specify the full directory path name of the files stored externally in a file system. When you specify the full directory path as such, you need only include file names in your text column.
    You can specify multiple paths for path, with each path separated by a colon (:) on UNIX and semicolon(;) on Windows. File names are stored in the text column in the text table.
    If you do not specify a path for external files with this attribute, Oracle Text requires that the path be included in the file names stored in the text column.
    PATH Attribute Limitations
    The PATH attribute has the following limitations:
    If you specify a PATH attribute, you can only use a simple filename in the indexed column. You cannot combine the PATH attribute with a path as part of the filename. If the files exist in multiple folders or directories, you must leave the PATH attribute unset, and include the full file name, with PATH, in the indexed column.
    On Windows systems, the files must be located on a local drive. They cannot be on a remote drive, whether the remote drive is mapped to a local drive letter."
    With accessible paths and files, you get something like:
    SCOTT@orcl_11g> CREATE TABLE test (id NUMBER PRIMARY KEY, text VARCHAR2(100));
    Table created.
    SCOTT@orcl_11g>
    SCOTT@orcl_11g>
    SCOTT@orcl_11g> INSERT into test values(1,'c:\oracle11g\banana.pdf');
    1 row created.
    SCOTT@orcl_11g> INSERT into test values(2,'c:\oracle11g\cranberry.pdf');
    1 row created.
    SCOTT@orcl_11g>
    SCOTT@orcl_11g> CREATE INDEX test_index ON test(text) indextype is ctxsys.context
      2  parameters ('datastore ctxsys.file_datastore
      3  filter ctxsys.auto_filter');
    Index created.
    SCOTT@orcl_11g>
    SCOTT@orcl_11g> select count(*) from dr$test_index$i
      2  /
      COUNT(*)
           608
    SCOTT@orcl_11g> In the following, I used a non-existent path and non-existent file name, which produces the same results as when you use a remote path that does not exist locally.
    SCOTT@orcl_11g> CREATE TABLE test (id NUMBER PRIMARY KEY, text VARCHAR2(100));
    Table created.
    SCOTT@orcl_11g>
    SCOTT@orcl_11g>
    SCOTT@orcl_11g> INSERT into test values(3,'c:\nosuchpath\nosuchfile.pdf');
    1 row created.
    SCOTT@orcl_11g>
    SCOTT@orcl_11g> CREATE INDEX test_index ON test(text) indextype is ctxsys.context
      2  parameters ('datastore ctxsys.file_datastore
      3  filter ctxsys.auto_filter');
    Index created.
    SCOTT@orcl_11g>
    SCOTT@orcl_11g> select count(*) from dr$test_index$i
      2  /
      COUNT(*)
             0
    SCOTT@orcl_11g>

  • Retrieve document count in document library

    Guys, I'm trying to figure out how I can get the document count in a document library. I suspect we've reached the magical number of 5000 documents in a library which causes sync issues, and I need a way to find out if this is the case. I spend the last
    45 minutes searching the web for a solution just to count the documents in a library, but apparently, Sharepoint does not offer an easy way to view this information. I've found custom webparts and even apps to get the document count, but they require some
    in-depth Sharepoint knowledge I don't have.
    One of the sites I found:
    http://www.c-sharpcorner.com/UploadFile/anavijai/how-to-get-the-number-of-items-inside-the-folder-in-sharepoi/
    Is there another "easy" way to view the amount of documents stored in the document library ona Sharepoint Online site? I tried to use the "Browse with explorer" button to count al the documents. It works, but it counts about 4800 documents,
    so it probably does not count all the items stored.

    Hi Tom,
    According to your description, my understanding is that you want to retrieve the document count in document library.
    I suggest you can query all document in all folders using Client Object Model. Before you use Client Object Model, you need to install the SharePoint Componments SDK firstly.
    Here is a code snippet for your reference:
    ClientContext clientContext = new ClientContext("your site");
    Microsoft.SharePoint.Client.List spList = clientContext.Web.Lists.GetByTitle("Documents");
    clientContext.Load(spList);
    clientContext.ExecuteQuery();
    if (spList != null && spList.ItemCount > 0)
    Microsoft.SharePoint.Client.CamlQuery camlQuery = new CamlQuery();
    camlQuery.ViewXml =
    @"<View Scope='RecursiveAll'>
    <Query>
    <Where><Eq><FieldRef Name='FSObjType' /><Value Type='Integer'>0</Value></Eq></Where>
    </Query>
    </View>";
    ListItemCollection listItems = spList.GetItems(camlQuery);
    clientContext.Load(listItems);
    clientContext.ExecuteQuery();
    Console.WriteLine(listItems.Count);
    Console.ReadKey();
    Here are some detailed articles for your reference:
    SharePoint Server 2013 Client Components SDK
    Complete basic operations using SharePoint 2013 client library code
    Best Regards
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Zhengyu Guo
    TechNet Community Support

  • PDF Document Counting Form Field

    I've searched and can't seem to find a solution to this - is there a way to include a document counter so that when a person opens or saves a pdf, it shows the number of that pdf. If I open it, it will show Doc #1 and the next person to open/save it, shows Doc #2 and so forth.
    Thank you!!!

    I know nothing about programing.  However, I was able to create a stamp following the directions at http://blogs.adobe.com/acrolaw/2009/05/add_dynamic_exhibit_stamps_in_ac.html,
    The problem is that I need the stamp value to increment each time I stamp something.  For example, if I have a binder with 40 emails, I want to be able to just go through the pages and stamp each one with the number on the stamp incrementing by one.  Can you or anyone tell me how to do this - in language suitable for a "dummie"?  Thank you.  My email is [email protected] Thanks again.

  • Document Counter in cube

    Hi, Can someone please suggest me on the following issue:
    I am trying to add Document count keyfigure and also maintain its history in the Cube which is already there in the ODS.The ODS is feeding the Cube and I want report on the Cube and not on the ods.
    Note: The cube already contains the Document Item Counter.
    Also, is there any way that I can derive Document Count from the Document Item Counter KF using Replacement path variable.
    Thanks,
    sruthi

    Hi,
    Just create one Line Item Dimension in infoCube for Document Number, in BEx Designer create one Formula Variable using Replacement Path.
    Create a formula variable of type Replacement Path, assign the Reference Characteristic to that here I think Document Number, in second Tab Replacement Path Define Replace Var. with -> InfoObject, Replace with -> Attrib. value, Attribute -> Char. Ref.
    After Creating Formula Variable create Calculated Key Figure using this formula variable in Aggregation define Calculation after Aggregation.
    Regards,
    Rajdeep.

  • Document Count

    Hello Gurus,
    I have a requirement to display the document count of Document numbers.
    I am querying on an infoset, which has a Cube and an DSO. The cube contains header data. Hence there is 1 count against the document number. The DSO holds item details, which would have more than 1 item per document number.
    When I execute the query I would like to see Count = 1, against Doc no. 10001, which has 3 line items in the DSO. Instead its showing the Count = 3.
    Is there a way around for this.
    Thanks in advance

    Hi,
        Just refer this document,
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/009819ab-c96e-2910-bbb2-c85f7bdec04a
    Hopefully this will work on Infoset also.
    Regards,

  • Calculated keyfig for Document count with exclusions

    Hi,
    I have to create a ckf document count with exclusion, with the following logic
    "If RFK_MR8MCOUNT ==0 then count equal to 1
    Else If RFK_MR8MCOUNT <>0 then count equal to 0"
    RFK_MR8MCOUNT I already have it.
    Pls guide me which datafunction to use & how to implement it in the formula editor.
    Regards,
    Shreesh.

    I don't get all the formula's posted in this thread, they don't make any sense. For example (and all others like this one):
    NODIM((( X == 0 )1 + (Not( X == 0 ))0 ))
    First off, NODIM on a logical expression makes no sense at all, there is no dimension to a simple 0 or 1
    Second, (X == 0) will result in 0 or 1 (true or false), the *1 is of no added value
    Third, (Not(X==0)) * 0 will allways result in 0. ALLWAYS!
    You can get the same result as the above formula by using:
    (X==0)
    If that is what you need, a reversal of your count statement, use it.
    Kind regards,
    Alex

  • CF8 verity french reports wrong document count

    I had to rebuild a number of collections that use the verity
    language packs in migtrating to 8. All of the document counts
    displayed in the cfadministrator and by calling #recordsSearched#
    come out correctly EXCEPT for the french language one. I deleted
    and rebuilt the collection 3 times, same results each time. As near
    as I can tell, the collection is behaving correctly in terms of
    finding items- no duplicates displayed, and the most I can find
    with any search is 55 documents (expected total)
    Since I am pulling from a database, I know exactly how many
    records I have (76), 55 of which have electronic versions and get
    indexed. I looped a query to index the documents and output the
    title and action each time to visually verifiy that it looped 76
    times, and did the indexing 55 times. Yet my document count is 133
    with each build.
    Has anyone else seen anything similar? It's not a fatal
    problem by any means, but it is weird and I would love to know that
    I can rely on the recordSearched returned. (Arabic, Spanish,
    Russian, Portuguese, English were all fine.)

    CF_Ninja,
    I get your point. What you discovered isn't new, and didn't start with Adobe. In fact, it is so common in commercial software, you can even call it a new Murphy's law. If version s is the latest version of a given software(say, Coldfusion 9), and there has been a switch from module m1 in version s-1 to module m2 in version s (say, the switch from Verity in CF8 to Solr in CF9), then the module m1 will invariably be crappy.
    The developers of CF8, already with a euphoric eye on the future use of Solr, would inadvertently have ignored any further development of Verity. It's only human to think: Why waste all that effort on an end-of-life product?
    I share your choice. The Coldfusion Jedi has a good comparison of Verity and Solr

  • Document count in query

    Hi All
    I have 2 queries, query A and query B between these queries in tcode RSBBS i have created a report to report link. Query A shows summarised car mileage data such as total miles and total cost, while query B shows more detalied info about the milegae such as trave location travel reason etc. The report to report works fine as the user can right click from a line  from query A and go to to query relating to that line in Query B with the more detailed data.
    Now i want to create a document counter that will count how many records in query B, the problem i am facing is that because Query A and Query B are based on different infoprovider, when I am creating my formula variable in reference characteristic i cannot select the info object i need to count the lines because of the fact they are based on different info provider.
    Does anyone have any workarounds on how i could achive this.
    regards
    Forhad

    Hi,
    You can create a multiprovider on the two info providers.
    -Vikram

  • Question about metadata filtering and document sets

    Hello,
    I have a question about the metadata filtering when using document sets.
    When i use the metadata filter for example for "Installatie: P00001" it shows.
    But i wan't to show only the document set and not all the documents. Is this possible OOTB?

    Hi striker,
    You can add the "Content Type" in Hierarchy Fields for your list, then click the "Document Set" to filter the document set type item, then you can input the "P00001" in Installatle key filter, click apply, then it should show only document set
    items with field value P00001.
    http://office.microsoft.com/en-001/sharepoint-help/set-up-metadata-navigation-for-a-list-or-library-HA102832523.aspx
    Thanks
    Daniel Yang
    TechNet Community Support

  • Document Count when Condition is Active

    Hi Experts
    I have the following scenario
    I have a Calculated Key Figure which by formula variable *1 calculates the number documents.
    The count works correctly as it gives me the proper count of the documents that make up the amount on that line. Let suppose it was 180 documents and that 175 of these have amount =0.
    However after applying a condition that would not display the records whose amount = 0, I would expect the count to change to 5,  but still gives me 180.  The document number is not a field in the default view of the report.  If I bring the docuemnt number with my condition active, it displays the 5 reports.  Puts a one in the counter and the result row display 5.
    If document number is not in the view, I get 180 when its supposed to be 5. 
    Am I missing a setting on the Calculated Key Figure.  I have calculate single values as Total, I have reference characteristic: Document Number, and the CKF has Aggregation: After
    Thanks in advance.

    Thanks Ananda
    But what I am really looking for is an unique document number counter.
    I have several records (updates, etc.) that roll up in the document level to make up my amount.
    I dont want a record count.  I want a document number counter that will work when the condition is applied.

  • Document count limit under folders

    We are trying to figure out what the library file count restriction is for items under a folder.
    We can see here:
    http://technet.microsoft.com/en-us/library/cc262787(v=office.15).aspx#ListLibrary
    Documents :: 30,000,000 per library >> You can create very large document libraries by nesting folders, or using standard views and site hierarchy. This value may vary depending on how documents and folders are organized, and by the type and size of
    documents stored.
    Does that mean there is a file count limit of some sort under folders for a library?
    Thank you!

    +1 on Paul's comments.
    In the document you referenced,
    http://technet.microsoft.com/en-us/library/cc262787(v=office.15).aspx#ListLibrary, you will see that the 30,000,000 is a "Supported" number. Microsoft defines three kinds of limits.
    Boundaries: Static limits that cannot be exceeded by design
    Thresholds: Configurable limits that can be exceeded to accommodate specific requirements
    Supported limits: Configurable limits that have been set by default to a tested value
    The actual limit on documents is based on restrictions in SQL Server, which is much larger than 30,000,000.
    The guidance for number of items per view (or max displayed in a page or retrieved via code in a single batch) is 2000 for SharePoint 2007 and 5000 for SharePoint 2010 and 2013. The 2000 limit was based on "testing" and the 5000 is based on a SQL Server
    restriction. Note that in the referenced page the 5000 is listed as a "Threshold" and that you can change this in Central Administration. But, SQL server escalates from row locks to a table lock at 5000 rows. As all documents in all libraries in all sites
    in a site collection (and possibly in an entire web application) are stored in a single table, one user exceeding 5000 rows in a request would be locking all other users out for the duration of the request.
    Folders, grouped views and the 5000 "Threshold" are all ways of limiting problem sized requests. Bottom line, the size of a library or a folder is practically unlimited, while the maximum number of items displayed in a single request should never exceed
    5000.
    http://technet.microsoft.com/en-us/library/cc262787(v=office.15).aspx#ListLibrary
    Mike Smith TechTrainingNotes.blogspot.com
    Books:
    SharePoint 2007 2010 Customization for the Site Owner,
    SharePoint 2010 Security for the Site Owner

  • Filtering of documents in KM

    Hi,
    I have created a repository in km, say, documents/demodocs in which user1 and user2 can add the documents. But the documents added by user1 should not be visible to user2 and vice-versa.
    How can I achieve this ?
    Helpful answers will be rewarded.
    Regards,
    Saurabh

    Hi Saurabh,
    You didn't mention the 90000 users...
    How about this, perhaps is a little tricky .. but...:
    1. create a folder for example /docs/test
    2. create a group yourGroup, and add all the users to that group.
    3. In the KM Content give ownership permission to that group over the folder test, you have to remove any detail and permission command from any Navigation iView that users have access to, because of course they can change the permissions over the folder test if you let them.
    4. Develop your own upload program
    https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/1750In
    5.  Once the file is uploaded, inside the same program, first create a new acl, the document inherits the acl from the parent folder, so add the user as owner and remove the group.
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/1070413a-29e7-2a10-cc81-cdc92cdd231b
    like this
    IUMPrincipal groupToBeRemoved =WPUMFactory.getGroupFactory().getGroup("yourGroup");
              ISecurityManager sm = resource.getRepositoryManager(). getSecurityManager(resource);
              if(sm != null && (sm instanceof IAclSecurityManager)) {
                   IAclSecurityManager asm = (IAclSecurityManager)sm;
                   IResourceAclManager ram = asm.getAclManager();
                   IResourceAcl ra = ram.getAcl(resource);
                   if(ra == null){
                        ra = ram.createAcl(resource);
                        ra.addOwner(resource.getContext().getUser());
                        ra.removeOwner(groupToBeRemoved);
    Now, You have a folder with documents from different users, user A can't see files from user B, but in the upload program you have to take special care about the names of the files to upload.  If user A wants to upload the file name foo.txt and the user B already did upload a file with that name, your program  gonna generate an
    NameAlreadyExistsException.
    Hope this help...
    regards
    DV

  • Filtering- Getting count of distinct doc after filtering

    HI Gurus!
    I have a report that shows the sales order report . In its ALV ouptput I have created a count column which gives me the number of lines in the report and also I have created the top of page in which it gives me the number of distinct sales document numbers count . I.e for a particular selection the count of line items are say 765 and the number of distinct sales documents are 70  which I have printed on the top of the page in the layout. Now if we do some kind of filtering process in the output the number of sales documents printed on top of page remains the same while the coumnt of line items changes a sper the filtering . The count on the top of page for the sales order dosent change as it prints the number from the internal table which is understandable. But is there a possibility that I create another column next to the sales doc number column and at the beginning of each of the new sales document it prints one and for all the other duplicates it prints 0 and then do the sum for it , so that even on filtering it gives me the count that remains after filter while the total number of distinct sale doc remains on top from the internal table.
    Is this possible to do so that I get thenumber of sales doc even after filter process?
    If so please advice how to get it.
    Regards

    Well as of now my report does sommething like this.
    *& Report  ZSD_SALES_ORDERS                                            *
    *&         Sales Orders Report (tcode zva05)                           *
    *&         i.e. For 'admins'/oil field application                     *
    report  zztest message-id zsd no standard page heading.
    * For ALV usage
    type-pools: slis.
    data: gs_layout   type slis_layout_alv,
          tp_print    type slis_print_alv,
          gt_sort     type slis_t_sortinfo_alv,
          gt_events   type slis_t_event,
          t_fieldcat  type slis_t_fieldcat_alv with header line,
          repid       type syrepid,               " ABAP Program.
          gt_list_top_of_page type slis_t_listheader,     " Top of page text.
          alv_variant   type disvariant.           " Customize Disp. Variant
    data: w_field    type slis_fieldcat_alv.
    data: gs_list_top_of_page type slis_listheader.
    data: l_count type I.
    data: count1 type I.
    tables: vbak, vbap, vbpa, knvv.
    * Definition of selection screen                                       *
    *   By plant, storage location, sold-to customers, material and        *
    *   posting date of the sales orders                                   *
    selection-screen begin of block one with frame title text-001.
    parameters:     p_vkorg  type vkorg obligatory memory id vko,"DEVK906677
                    p_vtweg  type vtweg obligatory default '01',
                    p_spart  type spart obligatory default '01'.
    select-options: s_vkbur  for  vbak-vkbur,      " Sales Office     "DEVK906677
                    s_kunnr  for  vbak-kunnr.      " Sold-to customer number.
    select-options: s_shipto for  vbap-oid_ship,   " Ship-to customer number.
                    s_billto for  vbpa-kunnr,      " bill-to from S.O. header.
                    s_load   for  vbpa-kunnr,      " Load confirmation contact.
                    s_truck  for  vbap-oid_extbol. " Trucking ticket number.
    select-options: s_werks for vbap-werks obligatory no intervals. " Plant.
    select-options: s_lgort for vbap-lgort.        " Storage location.
    select-options: s_matnr for vbap-matnr.        " Material number.
    select-options: s_konda for knvv-konda.        " price group
    selection-screen skip 1.
    select-options: s_vdatu for vbak-vdatu default sy-datum.
    selection-screen end of block one.
    * ALV display layout
    selection-screen begin of block layout with frame title text-003.
    parameters: pa_vari type slis_vari default ' '. " Display variant.
    selection-screen end of block layout.
    selection-screen begin of block two with frame title text-028.
    selection-screen comment: /1(79) text-029.
    selection-screen comment: /1(79) text-030.
    selection-screen comment: /1(79) text-031.
    selection-screen comment: /1(79) text-032.
    selection-screen comment: /1(79) text-033.
    selection-screen comment: /1(79) text-034.
    selection-screen comment: /1(79) text-035.
    selection-screen comment: /1(79) text-036.
    selection-screen end of block two.
    * Data Definitions                                                     *
    * Storing Extracted Info.
    types: begin of t_extract,
             vbeln        type vbeln_va,   " Sales order number.
             augru        type augru,      " order reason
             vdatu        type edatu_vbak, " Requested delivery date.
             kunnr        type kunag,      " Sold-to customer number.
             posnr        type posnr_va,   " Item number.
             matnr        type matnr,      " Material number.
             vrkme        type vrkme,      " Sales UoM.
             mseh3        type mseh3,      " UoM text.
             netwr        type netwr_ap,   " Net value of the order item.
             kwmeng       type p length 13 decimals 1, " Quantity.
             werks        type werks_d,    " Plant.
             lgort        type lgort_d,    " Storage location.
             oid_extbol   type oid_extbol, " External BOL or truck ticker header.
             maktx        type maktx,      " Material description.
             soldto_name  type name1_gp,   " Sold-to name.
             oid_ship     type kunwe,      " Ship-to customer number.
             shipto_name  type name1_gp,   " Ship-to name.
             billto       type kunre,      " Bill-to customer number.
             billto_name  type name1_gp,   " Bill-to name.
             load_contact type kunnr,      " Load confirmation contact.
             load_name    type name1_gp,   " Load confirmation contact name.
             truck        type kunnr,      " Truck company number.
             truck_name   type name1_gp,   " Truck company name.
             bstkd        type bstkd,      " PO number.
             ihrez        type ihrez,      " AFE number per the contract/sales order.
             delivery     type vbeln_vl,   " Delivery number.
             posnr_vl     type posnr_vl,   " Delivery item number.
             bill_vbeln   type vbeln_vf,   " Invoice number.
             bill_posnr   type posnr_vf,   " Invoice item number.
             bill_netwr   type netwr_fp,   " Invoice net value.
             statu        type stats,      " Document status.
             auart        type auart,      " order type
             vkorg        type vkorg,      " sales org.
             vtweg        type vtweg,      " distrbtn channel
             spart        type spart,      " division
             vkbur        like vbak-vkbur, " Sales Office DEVK906677
             konda        type konda,      " price group
             tdline       type tdline,     " text for customer account reference
             count        type I ,
             count1       type I,
           end of t_extract.
    data :
          it_extract  type table of t_extract with header line,
          it_extract2 type table of t_extract with header line.
    data: it_text type table of tline with header line.
    data: w_index type sy-index,
          w_tdname type tdobname.
    constants: c_minus1       type netwr_ap value '1.00-'.
    *RANGES: r_auart FOR vbak-auart.
    data: r_auart type range of t_extract-auart,
          r_auart_line like line of r_auart.
    * initialization
    initialization.
      gs_layout-colwidth_optimize = 'X'.
      tp_print-no_print_listinfos = 'X'.
      tp_print-no_coverpage = 'X'.
      perform set_fieldcat.
      perform alv_eventtab_build using:
    **    Event name     Form to execute     Event internal table
       'TOP_OF_PAGE'  'TOP_OF_PAGE'       gt_events[].
    * changed to exclude following order types
      r_auart_line-sign   = 'I'.
      r_auart_line-option = 'EQ'.
      r_auart_line-low    = 'ZEQ'.
      clear r_auart_line-high.
      append r_auart_line to r_auart.
    * credit memo
      r_auart_line-sign   = 'I'.
      r_auart_line-option = 'EQ'.
      r_auart_line-low    = 'ZPRC'.
      clear r_auart_line-high.
      append r_auart_line to r_auart.
    * debit memo
      r_auart_line-sign   = 'I'.
      r_auart_line-option = 'EQ'.
      r_auart_line-low    = 'ZPRD'.
      clear r_auart_line-high.
      append r_auart_line to r_auart.
      r_auart_line-sign   = 'I'.
      r_auart_line-option = 'EQ'.
      r_auart_line-low    = 'ZDR'.
      clear r_auart_line-high.
      append r_auart_line to r_auart.
    * Industry sales order correction
      r_auart_line-sign   = 'I'.
      r_auart_line-option = 'EQ'.
      r_auart_line-low    = 'ZSOC'.
      clear r_auart_line-high.
      append r_auart_line to r_auart.
    * oilfield FF correction
      r_auart_line-sign   = 'I'.
      r_auart_line-option = 'EQ'.
      r_auart_line-low    = 'ZOCF'.
      clear r_auart_line-high.
      append r_auart_line to r_auart.
    * oilfield WP correction
      r_auart_line-sign   = 'I'.
      r_auart_line-option = 'EQ'.
      r_auart_line-low    = 'ZOCW'.
      clear r_auart_line-high.
      append r_auart_line to r_auart.
    * Dropdown list for all created ALV layouts, global or user-specific
    at selection-screen on value-request for pa_vari.
      perform alv_variant_f4 changing pa_vari.
    * Main BODY of processing logic
    start-of-selection.
      perform extract_data.
    end-of-selection.
      if not it_extract[] is initial.
    * Build headings for report.
        perform build_top_of_page  using gt_list_top_of_page[].
        perform call_alv.
      endif.
    *&      Form  EXTRACT_KEY_DATA
    * Retreive the data for the report.
    form extract_data.
      clear: it_extract.  refresh: it_extract.
    * orders
      select vbak~vbeln vbak~auart vbak~augru vbak~vkorg vbak~vtweg
             vbak~spart vbak~vdatu vbak~kunnr vbak~vkbur
             vbap~posnr vbap~matnr vbap~vrkme vbap~netwr vbap~kwmeng
             vbap~werks vbap~lgort vbap~oid_extbol vbap~oid_ship
        into corresponding fields of table it_extract
        from vbak inner join vbap
             on  vbak~mandt = vbap~mandt
             and vbak~vbeln = vbap~vbeln where
        vbak~auart not in r_auart and
        vbak~vkorg eq p_vkorg and
        vbak~vtweg eq p_vtweg and
        vbak~spart eq p_spart and
        vbak~vkbur in s_vkbur and                               "DEVK906677
        vbak~vdatu in s_vdatu and
        vbak~kunnr in s_kunnr and
        vbap~matnr in s_matnr and
        vbap~werks in s_werks and
        vbap~lgort in s_lgort and
        vbap~oid_extbol in s_truck and
        vbap~oid_ship in s_shipto .
      if sy-subrc <> 0.
        message i000 with text-002 ' ' ' ' ' '.
      endif.
      sort it_extract by vbeln.
      check sy-subrc = 0.
      loop at it_extract.
    * Retrieve and select by load confirmation contacts from header
        select single kunnr from vbpa into it_extract-load_contact
         where vbeln = it_extract-vbeln
           and posnr = '000000'
           and parvw = 'ZB'.
        if it_extract-load_contact in s_load.
          it_extract-load_name = zcl_kna1=>get_name1( it_extract-load_contact ).
        else.
          delete it_extract.
          continue.
        endif.
    * Retrieve and select by sales order bill-to on header level
    * as well as lookup bill-to customer name/description
        select single kunnr from vbpa into it_extract-billto
         where vbeln = it_extract-vbeln
           and posnr = '000000'
           and parvw = 'RE'.
        if sy-subrc = 0.
          if s_billto is initial.
            it_extract-billto_name = zcl_kna1=>get_name1( it_extract-billto ).
          else.
            if it_extract-billto in s_billto.
              it_extract-billto_name = zcl_kna1=>get_name1( it_extract-billto ).
            else.
              delete it_extract.
              continue.
            endif.
          endif.
        else.
    * Newalta - always has bill-to, following will not occur but included
    *           as good programming practice.
          it_extract-billto_name = it_extract-billto.
        endif.
    * Retrieve and select by price group of sold-to
        select single konda from knvv into it_extract-konda
         where kunnr = it_extract-kunnr
           and vkorg = it_extract-vkorg
           and vtweg = it_extract-vtweg
           and spart = it_extract-spart.
        if sy-subrc = 0.
          if not ( it_extract-konda in s_konda ).
            delete it_extract.
            continue.
          endif.
        endif.
    * Retrieve trucking company customer
        select single kunnr from vbpa into it_extract-truck where
          vbeln = it_extract-vbeln and
          posnr = '000000' and
          parvw = 'ZT'.
        if sy-subrc = 0.
          it_extract-truck_name = zcl_kna1=>get_name1( it_extract-truck ).
        endif.
    * Retrieve sold-to name
        it_extract-soldto_name = zcl_kna1=>get_name1( it_extract-kunnr ).
    * Retrieve ship-to name
        it_extract-shipto_name = zcl_kna1=>get_name1( it_extract-oid_ship ).
    * lookup P.O.
        select single bstkd ihrez from vbkd into (it_extract-bstkd, it_extract-ihrez)
         where vbeln = it_extract-vbeln
           and posnr = '000000'.
    * Retreive the material description.
        it_extract-maktx = zcl_material=>get_maktx( it_extract-matnr ).
    * cosmetic change of material number, donot display leading zeros.
        shift it_extract-matnr left deleting leading '0'.
    * translate unit of measure
        it_extract-mseh3 = it_extract-vrkme.
        select single mseh3 from t006a into it_extract-mseh3
         where spras = sy-langu
           and msehi = it_extract-vrkme.
        w_tdname = it_extract-vbeln.
    * read customer account reference which is under 'text'
        call function 'READ_TEXT'
          exporting
            client                        = sy-mandt
            id                            = 'Z010'
            language                      = sy-langu
            name                          = w_tdname
            object                        = 'VBBK'
    *   ARCHIVE_HANDLE                = 0
    *   LOCAL_CAT                     = ' '
    * IMPORTING
    *   HEADER                        =
          tables
            lines                         = it_text
          exceptions
            id                            = 1
            language                      = 2
            name                          = 3
            not_found                     = 4
            object                        = 5
            reference_check               = 6
            wrong_access_to_archive       = 7
            others                        = 8.
        if sy-subrc = 0.
          read table it_text index 1.
          if sy-subrc = 0.
            it_extract-tdline = it_text-tdline.
          else.
            clear it_extract-tdline.
          endif.
        else.
          clear it_extract-tdline.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        endif.
    * Get the delivery item.
        call method zcl_vbap=>get_delivery
          EXPORTING
            itp_vbeln = it_extract-vbeln
            itp_posnr = it_extract-posnr
          IMPORTING
            etp_vbeln = it_extract-delivery
            etp_posnr = it_extract-posnr_vl.
        if it_extract-delivery is not initial.
          perform process_deliveries.
        else.
          perform invoice_process.
        endif.
        it_extract-count =   1.
        move-corresponding it_extract to it_extract2.
        append it_extract2.
        at new vbeln.
          count1 = count1 +  1.
        endat.
      endloop.
    endform.                    " EXTRACT_DATA
    *&      Form  SET_FIELDCAT
    * Create the field catalogue.
    form set_fieldcat .
      clear w_field.
      clear t_fieldcat.  refresh t_fieldcat.
      w_field-col_pos = 1.
      w_field-fieldname = 'VBELN'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Document.Nbr'.
      w_field-emphasize = 'X'.
      w_field-hotspot   = 'X'.
      append w_field to t_fieldcat.
      clear w_field.
      w_field-col_pos = 2 .
      w_field-fieldname = 'POSNR'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Item'(023).
      append w_field to t_fieldcat.
      clear w_field.
      w_field-col_pos = 3 .
      w_field-fieldname = 'VDATU'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Req. Del. Date'(005).
      append w_field to t_fieldcat.
      w_field-col_pos = 4 .
      w_field-fieldname = 'SOLDTO_NAME'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Sold-to'(006).
      append w_field to t_fieldcat.
      w_field-col_pos = 5 .
      w_field-fieldname = 'MATNR'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Material'(007).
      append w_field to t_fieldcat.
      w_field-col_pos = 6 .
      w_field-fieldname = 'KWMENG'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Quantity'(008).
      append w_field to t_fieldcat.
      w_field-col_pos = 7.
      w_field-fieldname = 'MSEH3'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'UOM'(009).
      append w_field to t_fieldcat.
      w_field-col_pos = 8 .
      w_field-fieldname = 'BILL_VBELN'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Invoice #'(010).
      w_field-emphasize = 'X'.
      w_field-hotspot   = 'X'.
      append w_field to t_fieldcat.
      clear w_field.
      w_field-col_pos = 9 .
      w_field-fieldname = 'BILL_NETWR'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Values'(011).
      append w_field to t_fieldcat.
      w_field-col_pos = 10.
      w_field-fieldname = 'WERKS'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Plant'(012).
      append w_field to t_fieldcat.
      w_field-col_pos = 11.
      w_field-fieldname = 'LGORT'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Storage Loc'(013).
      append w_field to t_fieldcat.
      w_field-col_pos = 12 .
      w_field-fieldname = 'MAKTX'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Description'(014).
      append w_field to t_fieldcat.
      w_field-col_pos = 13 .
      w_field-fieldname = 'SHIPTO_NAME'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Ship-to'(015).
      append w_field to t_fieldcat.
      w_field-col_pos = 14 .
      w_field-fieldname = 'BILLTO_NAME'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Bill-to'(016).
      append w_field to t_fieldcat.
      w_field-col_pos = 15 .
      w_field-fieldname = 'LOAD_NAME'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Load Contact'(017).
      append w_field to t_fieldcat.
      w_field-col_pos = 16 .
      w_field-fieldname = 'TRUCK_NAME'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Truck Comp.'(018).
      append w_field to t_fieldcat.
      w_field-col_pos = 17 .
      w_field-fieldname = 'BSTKD'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'P.O.'(019).
      append w_field to t_fieldcat.
      w_field-col_pos = 18 .
      w_field-fieldname = 'IHREZ'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'AFE Nbr'(020).
      append w_field to t_fieldcat.
      w_field-col_pos = 19 .
      w_field-fieldname = 'OID_EXTBOL'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Truck Ticket'(021).
      append w_field to t_fieldcat.
      w_field-col_pos = 20.
      w_field-fieldname = 'STATU'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Status'(022).
      append w_field to t_fieldcat.
      w_field-col_pos = 21.
      w_field-fieldname = 'AUGRU'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Ord.Reason'(024).
      append w_field to t_fieldcat.
      w_field-col_pos = 22.
      w_field-fieldname = 'TDLINE'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'cstmr.acct.ref.'(027).
      append w_field to t_fieldcat.
      w_field-col_pos = 23 .                                    "DEVK906678
      w_field-fieldname = 'VKBUR'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Sales Office'(037).
      append w_field to t_fieldcat.
      w_field-col_pos = 24.
      w_field-fieldname = 'KUNNR'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Sold-to Customer'(038).
      append w_field to t_fieldcat.
      w_field-col_pos = 25.
      w_field-fieldname = 'OID_SHIP'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Ship-to Customer'(039).
      append w_field to t_fieldcat.
      w_field-col_pos = 26.
      w_field-fieldname = 'BILLTO'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Bill-to Customer'(040).
      append w_field to t_fieldcat.
      w_field-col_pos = 27.
      w_field-fieldname = 'COUNT'.
      w_field-tabname = IT_EXTRACT2.
      w_field-seltext_l = 'Count of line items'(042).
      w_field-do_sum = 'X'.
      append w_field to t_fieldcat.
    endform.                    " SET_FIELDCAT
    *&      Form  CALL_ALV
    * Call the ALV Grid function.
    form call_alv .
      sort it_extract by lgort vbeln.
    * repid is necessary since the ALV F.M. does not work properly with
    * sy-repid.
      repid = sy-repid.
      alv_variant-variant  = pa_vari.
      alv_variant-report   = sy-repid.
      alv_variant-username = sy-uname.
      call function 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program      = repid
          i_callback_user_command = 'USER_COMMAND'
          is_layout               = gs_layout
          it_fieldcat             = t_fieldcat[]
          it_sort                 = gt_sort[]
          i_default               = 'X'
          i_save                  = 'A'
          is_variant              = alv_variant
          it_events               = gt_events[]
          is_print                = tp_print
        TABLES
          t_outtab                = IT_EXTRACT2
        EXCEPTIONS
          program_error           = 1
          others                  = 2.
      if sy-subrc ne 0.
        message w000 with text-004 ' ' ' ' ' '.
      endif.
    endform.                    " CALL_ALV
    *&      Form  build_top_of_page
    * Build heading for report.                                            *
    *      -->P_GT_LIST_TOP_OF_PAGE[]  Header stuff for report
    form build_top_of_page using   e04_lt_top_of_page type slis_t_listheader.
      data: ls_line type slis_listheader.  "Header table for top of page
    * construct 'top of page' info. to display. In this case, one line.
      data: w_selections(40) type c,
            w_date_from(10) type c,
            w_date_to(10) type c.
      write: s_vdatu-low to w_date_from dd/mm/yyyy.
      if s_vdatu-high is not initial.
        write: s_vdatu-high to w_date_to dd/mm/yyyy.
        clear w_selections.
        concatenate 'Del.Req.Date: ' w_date_from 'To' w_date_to
        into w_selections separated by space.
        clear ls_line.
        ls_line-typ  = 'H'.
        ls_line-info = w_selections.
        append ls_line to e04_lt_top_of_page.
        gs_list_top_of_page-typ = 'S'.
        gs_list_top_of_page-info = ' Total number of Sales Documents :'.
        append gs_list_top_of_page to gt_list_top_of_page.
        gs_list_top_of_page-typ  = 'S'.
        gs_list_top_of_page-info =  count1 .
        append gs_list_top_of_page to gt_list_top_of_page.
      else.
        clear w_date_to.
        concatenate 'Del.Req.Date: ' w_date_from
             into w_selections separated by space.
        clear ls_line.
        ls_line-typ  = 'H'.
        ls_line-info = w_selections.
        append ls_line to e04_lt_top_of_page.
      endif.
    endform.                    " build_top_of_page
    *&      Form  alv_eventtab_build
    *     Pass list of events to be triggered by the ALV function module
    form alv_eventtab_build using  u_name  type slis_alv_event-name
                                   u_form  type slis_alv_event-form
                                   alv_lt_events  type slis_t_event.
      data: ls_event type slis_alv_event.   " structure for event handling
      ls_event-name = u_name.
      ls_event-form = u_form.
      append ls_event to alv_lt_events.
    endform.                    " alv_eventtab_build
    *       FORM TOP_OF_PAGE                                              *
    form top_of_page.
      call function 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          i_logo             = 'LOGO'
          it_list_commentary = gt_list_top_of_page.
    endform.                    " TOP_OF_PAGE
    *&      Form  process_deliveries
    * Process the delivery related records.
    form process_deliveries .
      data:
        ltp_date  type wadat_ist, " Goods movement date.
        ltp_vbtyp type vbtyp_n,
        ltp_mtart type mtart, " Material type.
        w_lfimg   type lfimg, " Actual quantity delivered (in sales units).
        w_vrkme   type vrkme. " Sales unit of measure.
    * Read delivery quantity and uom.
      select single lfimg vrkme into (w_lfimg, w_vrkme)
        from lips where
        vbeln = it_extract-delivery and
        posnr = it_extract-posnr_vl.
    * these fields have values from vbap. override with lips values
      if sy-subrc = 0.
        it_extract-kwmeng = w_lfimg.
        it_extract-vrkme  = w_vrkme.
    * translate unit of measure
        it_extract-mseh3 = it_extract-vrkme.
        select single mseh3 from t006a into it_extract-mseh3
         where spras = sy-langu
           and msehi = it_extract-vrkme.
      endif.
    * Determine STATUS by reading 'service confirmation', R (goods movemt)
    * it is possible to have multiple 'service confirmation' records for
    * one item. ie. delivery 80010390 in PRD.
    * As long as there is at least one 'service confirmation' record,
    * status is considered 'complete'.
    * Validate the created on date of the goods movement or service confirmation.
      ltp_mtart = zcl_material=>get_mtart( it_extract-matnr ).
    *  ltp_date = zcl_lips=>get_goods_movement_date( itp_vbeln = it_extract-delivery
    *                           itp_posnr = it_extract-posnr_vl itp_mtart = ltp_mtart ).
      call method zcl_lips=>get_goods_mvt_info
        EXPORTING
          itp_vbeln = it_extract-delivery
          itp_posnr = it_extract-posnr_vl
          itp_mtart = ltp_mtart
        IMPORTING
          rtp_date  = ltp_date
          rtp_vbtyp = ltp_vbtyp.
    * 'h' is cancel goods issue
      if ltp_vbtyp = 'h'.
        it_extract-statu = 'Incomplete'(025).
      else.
        if ltp_date is not initial.
          it_extract-statu = 'COMPLETE'(026).
        endif.
      endif.
    * Retrieve the invoice/billing document item.
      call method zcl_lips=>get_invoice
        EXPORTING
          itp_vbeln = it_extract-delivery
          itp_posnr = it_extract-posnr_vl
        IMPORTING
          rtp_vbeln = it_extract-bill_vbeln
          rtp_posnr = it_extract-bill_posnr.
      if it_extract-bill_vbeln is not initial.
    * retrieve net value from the invoice.
        clear it_extract-bill_netwr.
        select single netwr into it_extract-bill_netwr from vbrp
         where vbeln = it_extract-bill_vbeln
           and posnr = it_extract-bill_posnr.
      else.
        it_extract-bill_netwr = it_extract-netwr. " Use order net value.
      endif.
    endform.                    " process_deliveries
    *&      Form  user_command
    * Process the user command.
    *      -->R_UCOMM      User command
    *      -->RS_SELFIELD  Field selected
    form user_command using r_ucomm     like sy-ucomm
                            rs_selfield type slis_selfield.
      data: ltp_vbeln type vbeln.  " Sales document number.
      case  r_ucomm.
        when '&IC1'.
          if ( rs_selfield-fieldname = 'VBELN'
            or rs_selfield-fieldname = 'BILL_VBELN' )
           and rs_selfield-value is not initial.        " Display sales document.
            ltp_vbeln = rs_selfield-value.
            zcl_sales_doc=>display( ltp_vbeln ).
          endif.
      endcase.
    endform.                    "user_command
    *&      Form  invoice_process
    * Process for orders without deliveries.                               *
    form invoice_process .
    * Translate unit of measure.
      select single mseh3 from t006a into it_extract-mseh3
       where spras = sy-langu
         and msehi = it_extract-vrkme.
    * Retrieve the invoice/billing document item.
      call method zcl_vbap=>get_invoice
        EXPORTING
          itp_vbeln = it_extract-vbeln
          itp_posnr = it_extract-posnr
        IMPORTING
          rtp_vbeln = it_extract-bill_vbeln
          rtp_posnr = it_extract-bill_posnr.
      if it_extract-bill_vbeln is not initial.
    * retrieve net value from the invoice.
        clear it_extract-bill_netwr.
        select single netwr into it_extract-bill_netwr from vbrp
         where vbeln = it_extract-bill_vbeln
           and posnr = it_extract-bill_posnr.
      else. " If no Invoice, then status becomes 'incomplete'.
        it_extract-bill_netwr = it_extract-netwr. " Use order net value.
        it_extract-statu = 'Incomplete'(025).
      endif.
    endform.                    " invoice_process
    *&      Form  alv_variant_f4
    * Get the display variant.
    *      <--CTP_VARI  Variant name
    form alv_variant_f4 changing ctp_vari type slis_vari.
      alv_variant-report   = sy-repid.             " Report ID
      alv_variant-username = sy-uname.             " User ID
      call function 'REUSE_ALV_VARIANT_F4'
        EXPORTING
          is_variant = alv_variant
          i_save     = 'A'
        IMPORTING
          es_variant = alv_variant
        EXCEPTIONS
          others     = 1.
      if sy-subrc = 0.
        ctp_vari = alv_variant-variant.
      endif.
    endform.                    " alv_variant_f4

  • Count of Documents

    Hi,
    How can we calculate count of documents using New Calculated key figure apart from  using replacement path.
    Thanks
    krish

    Hi ,
    Instead of doing it at the front end . You can simply write a routine in the end routine .
    Please check the code suggested by me in the below post :
    Re: Count of Sales Doc
    In the front end you can do the following :
    Create a formula (In Rows) and assign a value =1 and then save.
    Now in Aggregation tab fill the below details :
    Exception Aggregation : Select counter for all detailed values.
    Ref. Characteristic: select the object for which you want the count ( billing document etc ).
    Number of documents count in BEx
    Thanks
    Kamal
    Edited by: kamal mehta on Jan 19, 2012 2:59 PM

Maybe you are looking for