Summary count by type

I've been tasked with modifying an existing report (that I did not create) which adds a new column (lets call it "type") and adds a summary page to the end of the report. The new summary page needs to show a count of each "type".
I've added the new column to the original query which works fine. My question is this.... What and where is the best place to add the new summary information (generally speaking). I've already formatted it in a new frame (master group) but was wondering where to get the count from?
Lets say the resulting query returns 50 records with 5 different "types". I want the summary results to look something like this:
TYPE DESCRIPTION
Type 1 10
Type 2 5
Type 3 20
Type 4
Type 5 15
Total 50
Like I said, I've already formatted the page accordingly and put in the fields, I just don't know to calculate the "type description" values from the previously existing query. Does this make sense? Any help you can give to help me get started would be appreciated. Thanks!

Too funny... What do you do Andreas, monitor all these forums??? :)
I'm even weaker on Reports than I am on Forms. As you've suggested, I've already formatted the summary description area in its own Frame. The problem I've experienced in the past is not recognizing the query results if it's in the wrong place. When I try to set the data source in the Property window for the new "summary description fields", it doesn't show. Does that sound familiar at all?
create an additional query fetching the summaries and layout the summary block in its own repeating frame.So I should create a completely separate query (utilizing the same "where" conditions along with the COUNT and SUM values I need) and reference that as the data source? "I think, I think" that makes sense....
Mark

Similar Messages

  • Custom Template for Third Party Balance Summary Report(Java type executable

    Hi Al,l we have a requirment to have a layout with some of the fields from
    Third Party Balance Summary Report( Which is a Java type executable and
    Data definition has Data Template attached(.xml)).
    I tried in below way.
    Coppied the Third Party Balance Summary Report program with same application and parameters
    with. Then defined a Datadefinition with my concurrent prog short name
    attached the same standard .xml file(Not sure what it is) and developed a custom template with
    a custom rtf(excel output type), and submitted the program
    the output is generated in excel but my custom .rtf layout is not getting applied
    rather it is showing same layout as in standard.
    Some thing I am missing here or else it is not the way of changing the
    template.
    If any one know how to do this please let me know.
    My client want only some files from the standard report(no need of new fileds)
    with output type xls.
    Thanks in Advance.
    The same content is posted in Custom Template for Third Party Balance Summary Report(Java type executable sorry for duplicating the thread, just for increase the visibility for my issue I did this.

    I gave up on using a different font or figuring out if I could use Times New Roman's built-in fractions visible in Font Book (as unicodes) and did a work-around based on Michael Wasley's tips in this discussion.
    https://discussions.apple.com/message/11622842#11622842
    I adapted it however and think it looks a little better.
    Font: Times New Roman 12 point
    I used the fraction bar in 12-point (Shift-Option-1) for automatic kerning.
    For the numerator, I changed the font style to superior (12-point).
    For the denominator, I changed the font style to subscript (Shift-Command-hyphen) and reduced the font size to half, or 6-point using the short-cut Shift-Command-<.
    When the fractions occured in my footnotes (9-point), I used 4-point in the denominator; 10- and 11-point, I used 5-point in the denominator. This seemed to produce the best result when printing.
    Thank you, Michael.
    -Dottie

  • GROUP BY (for summary counts) clause in ViewObject ?

    I'm trying to create a ViewObject based off an EntityObject. I want this ViewObject to perform simple summary counts. For example:
    SELECT COL1, COUNT(*)
    FROM TABLE1
    GROUP BY COL1
    but when I try this in Query Expert Mode , JDeveloper wants to pull in all primary key columns but I don't want this b/c I'm trying to perform summary counts. I'm thinking about just creating a view instead and having the EntityObject point to that view. Any other ideas?

    Dear Steve,
    I am following the toystore demo. From the toystore demo, I have included a package, FwkExtensions. Now I wan't to write my own user validation. I have followed the way you have coded for your signin actions. From the login form whenever some one insert his login and password, I get it in ValidateUserAction.java, where the onValidateUser( ) is like:
    public void onValidateUser(DataActionContext ctx)
    HttpServletRequest request = ctx.getHttpServletRequest();
    String target = request.getParameter("target");
    if (isNullOrEmpty(target)) {
    target = "welcome";
    LoginForm loginForm = (LoginForm) ctx.getActionForm();
    final String login = loginForm.getLogin();
    final String password = loginForm.getPassword();
    if (isNullOrEmpty(login)) {
    ctx.getActionErrors().add("username", new ActionError(BLANKLOGIN));
    else if (isNullOrEmpty(password)) {
    ctx.getActionErrors().add("password", new ActionError(BLANKPASSWORD));
    else
    LoginService ls = getLoginService(ctx);
    //Error Starts from the lower part
    if (ls.validateUser(login, password))
    AppUserInfo.signIn(request, loginForm.getLogin());
    ctx.setActionForward(target);
    return;
    else
    ctx.getActionErrors().add(ActionErrors.GLOBAL_ERROR,
    new ActionError(INVALIDLOGIN));
    saveErrors(ctx);
    My DataForwardActionClass is shown below:
    package neplogin.view;
    import toystore.fwk.controller.ToyStoreDataForwardAction;
    import java.text.*;
    import java.util.*;
    import oracle.adf.controller.struts.actions.DataActionContext;
    import neplogin.service.common.LoginService;
    public class[b] LoginServiceDataForwardAction extends ToyStoreDataForwardAction
    private static final String DATACONTROLNAME = "LoginService";
    public LoginServiceDataForwardAction()
    * Return the LoginAppModule custom interface that clients
    * (like the data actions in this project) can use to invoke
    * server-side business logic in a tier-independent way.
    * @param ctx The DataAction context
    * @return The LoginAppModule custom service interface
    protected LoginService getLoginService(DataActionContext ctx) {
    System.out.println("-------------- Login App Module Created Successfully ---------------");
    return (LoginService) getApplicationModule(DATACONTROLNAME, ctx);
    * Mark the LoginService data control to be released in stateless mode
    * at the end of the request.
    * @param ctx The DataAction context
    protected void releaseLoginServiceStateless(DataActionContext ctx) {
    releaseDataControlStateless(DATACONTROLNAME, ctx);
    Whenever I call the method validateUser(login,password) I get Null Pointer Exception. Which implies that my LoginService (ApplicationModule) can't be instantiated. How to instantiate LoginService and how? I couldn't figure it out till now.
    I am using JDeveloper 10.1.2, Default Web Application Framework, contains JSP, Strut and ADF.

  • Counter task types

    Hi, I'd like to understand the subtleties between some of the counter task type options in VeriStand and how they line up with the types of measurements such as those described in chapter 7 in this DAQ manual: http://www.ni.com/pdf/manuals/371596a.pdf
    Specifically, is it possible to implement Method 3 as described on page 7-12 which requires 2 counters? If not, I'd like to see if I can use Method 1b and Method 2. I remember hearing that VeriStand's counters tasks are actually all single counter Count Edges acquisitions. If that's the case, then how would I perform edge timing with the DAQ's 80 MHz timebase?
    Thanks.

    Hi hyong,
    Your best bet for this functionality is to create custom device.  Use the template tool that ships with NI VeriStand, and create a custom device that contains the DAQmx API in order to accomplish the Large Range Frequency Measurement.
    A_Ryan
    AES
    National Instruments

  • Counting Data types inside compiled objects...

    Hi Gurus,
    My requirment is that for any user,we create 'n' no of Functions/Procs/Packages,etc.Now, all these objects will have data-types defined in them.Can i get an overall count of data-types used in a particular user...(going inside the code and checking the data types it has & the count like
    For User : Scott
    COUNT(*) DATA_TYPES
    10 NUMBER
    4521 VARCHAR2
    239 XMLTYPE..
    etc..
    Hope some one helps...

    Query and Count using the dictionary view ALL_ARGUMENTS

  • StandardListItem counter property type issue

    Hi,
    I am using a simple Gateway service I have written with 1 Entity set and 3 properties in the entity.
    I am trying to bind it to a sap.m.List control.
    I seem to be having a problem with the counter property in the sap.m.StandardListItem
    See code below:
    var oListItem = new sap.m.StandardListItem({ icon: "{Icon}", title : "{WorkflowName}", counter: "{Count}" });
    What's happening is it only displays 1 row in the list without any counter. See screenshot below:
    However when I remove the counter property, it displays the correct number of rows, but obviously without any counter as expected.
    var oListItem = new sap.m.StandardListItem({ icon: "{Icon}", title : "{WorkflowName}" });
    See screenshot below:
    The when testing it with a harcoded int value in counter, it seems to show the counter:
    var oListItem = new sap.m.StandardListItem({ icon: "{Icon}", title : "{WorkflowName}", counter : 7 });
    See screenshot below:
    There is probably a really simple answer to this around incorrect type, or a missing conversion? Or is there possibly some issue in my GW service?
    See entity type definition:
    I have searched through SCN and the UI5 API's and Developer guide, and didn't seem to come up with any examples.
    Thanks,
    Brad

    Hi Chandra,
    Thanks, but I probably should have mentioned, before building the GW service I tried it with static JSON Data and it worked perfectly. See code below. So it is definitely something about that property and the ODataModel being used now. Below is the static data I used before
    var jsonData = {
      "Workflows" : [
      "WorkflowName" : "PO Approvals",
      "Icon" : "sap-icon://payment-approval",
      "Count" : 6
      "WorkflowName" : "FI Journal Approvals",
      "Icon" : "sap-icon://customer-financial-fact-sheet",
      "Count" : 11
      "WorkflowName" : "Shopping Cart Approvals",
      "Icon" : "sap-icon://cart-approval",
      "Count" : 19
      "WorkflowName" : "Sales Order Approvals",
      "Icon" : "sap-icon://payment-approval",
      "Count" : 4
      "WorkflowName" : "Leave Approvals",
      "Icon" : "sap-icon://hr-approval",
      "Count" : 8
      "WorkflowName" : "PR Approvals",
      "Icon" : "sap-icon://request",
      "Count" : 12
    var oModel = new sap.ui.model.json.JSONModel();
    oModel.setData(jsonData);
    Cheers,
    Brad

  • Query to get summary for two types of row data

    Hi Friends,
    I have tried using aggregate functions and thought of using analytic functions and still trying... But I am sure some analytic function expert can quickly help me out in this.
    With this data.
    BID_ELMT_SEQ_ID     PRF_NO          BID_REQ_DT          BID_ATRB_TYP_CD          BID_ATRB_VAL
    3575758          1          1/24/2011 2:27:32 PM     MINDAYS               1
    3575758          1          1/24/2011 2:27:32 PM     WRAPDAYS          1-0
    3575759          2          1/24/2011 2:27:32 PM     MINDAYS               1
    3575759          2          1/24/2011 2:27:32 PM     WRAPDAYS          1-0
    3575760          3          1/24/2011 2:27:32 PM     MINDAYS               1
    3575760          3          1/24/2011 2:27:32 PM     WRAPDAYS          1-0
    3575761          4          1/24/2011 2:27:32 PM     MINDAYS               1
    3575761          4          1/24/2011 2:27:32 PM     WRAPDAYS          1-0 Is it possible to retrieve an output similar to this ? In short , the row values of BID_ATRB_TYP_CD to be grouped into two columns and values fetched for this
    BID_ELMT_SEQ_ID     PRF_NO          BID_REQ_DT          MIN_DAYS_VAL     WRAP_DAYS_VAL
    3575758          1          1/24/2011 14:27          1          1-0
    3575759          2          1/24/2011 14:27          1          1-0
    3575760          3          1/24/2011 14:27          1          1-0
    3575761          4          1/24/2011 14:27          1          1-0 Regards,
    SSN

    Looks pretty simple to me - I haven't tried it yet.
    Can you share what you have tried so far and what has been the outcome of that effort?

  • How would I create a Summary Chart for the Current Year Using a Count by Month?

    Post Author: MarkS
    CA Forum: Charts and Graphs
    I have a data set of 3 date fields.  I would like to create a summary counting all of the occurrances of each of these dates per month, similar to using a SumProduct() command in excel.
    For example, my data is as follows:
    Registered Date  |    Application Date   |   Sale Date
    1/1/2007             |      2/1/2007            |     2/20/2007    
    1/10/2007           |      2/1/2007            |     3/20/2007
    2/20/2007           |      3/10/2007          |     3/20/2007
    I would like to summarize this information by month as follows:
                          |  Jan '07   |   Feb '07  |  Mar '07  |  TOTAL
    Registered      |      2        |   1           |    0         |   3
    Applications    |     0         |   2           |   1          |  3
    Sales             |     0         |   1            |  2            |  3
    TOTAL           |   2            |  4            |  3            | 9
    Is there any way to do this?

    Post Author: V361
    CA Forum: Charts and Graphs
    Yes, but it will require some effort. Group on "Sale Date"  Change the group to group by month.   You can then create a running total for "Registered Date","Application Date"," Sale Date"      For Registered date, I used Field to summarize Registered Date,  Type of summary was count, Evaluate use a formula, reset on change of group 1 (I only have one group, "Sale Date")  The formula will look like this.
    month ({Registered Date  }) in &#91;1,2,3,4,5,6,7,8,9,10,11,12&#93;
    You would build your other running totals (Counts) using the same methods,
    Once you have these, you should be able to create your chart.

  • Summary list of counts

    I'm trying to display a summary count of distinct values in a table based on their group category in a lookup table.
    The query for the summary page looks like this...
    SELECT rfs_category, lookup_value_desc, COUNT (*) the_count
    FROM seeker_rfs LEFT OUTER JOIN lookup_type_values
    ON rfs_category = lookup_value
    GROUP BY rfs_category, lookup_value_desc
    What I want on my summary page is a list with the lookup_value_desc and it's corresponding count (number of records in the seeker_rfs Table with that value). As they add more categories to the lookup table, the list would become longer dynamically without having to change the report.
    The min and max records per page are "0" and Page Break Properties are set to "No" yet it keeps page breaking on each individual category value (distinct lookup_value_desc).
    How can I get the result set into a single list of values with their counts w/o page breaking?
    Edited by: Mark Folden on Nov 19, 2008 6:57 AM

    Thank you Andreas, it was the Column/Break Order Property.
    I am not fond of this tool! Between the MG and RG's I must have changed the "Page Break" and "Base Printing On" Properties a thousand times (I kid you not) with basically NO effect on the report output what-so-ever. That's what was so frustrating. No matter what changes I made to the various properties, it never changed the report ouput! I was basically just relegated to going through the properties one by one making changes until I found it.
    Not an intuitive tool, especially for a beginning novice like myself with no training. I think I now understand why the person I inherited this project from hated it so much. I much prefer Forms! (not to mention the increased availability of resources on that forum)
    Thanks again Andreas...
    M

  • SQL Server Usage Summary page, the count of user/device: does not show for SQL Server 2008

    Does MAP tool capture User Summary  (count of users, their details) for SQL Server 2008? 
    At my end, its working for SQL Server 2012 but not showing User Summary for SQL Server 2008..
    Does the User Summary only works for SQL Server 2008 Enterprise edition as one of the thread points out?

    This is from the
    Wiki article:
    SQL Server 2008 Enterprise and Datacenter Editions introduced audit event configuration for Windows security logging, which enabled SQL Server 2008 to log logon events to the Windows Security log. The table below shows which versions and editions have the Audit
    feature that is needed to record the logon events. MAP cannot obtain user and device access information for any other editions or any older versions of SQL Server.
    Datacenter
    Enterprise
    Business Intelligence
    Standard
    Workgroup
    Web
    Express
    SQL Server 2008
    N/A
    Yes
    N/A
    No
    No
    No
    No
    SQL Server 2008 R2
    Yes
    Yes
    N/A
    No
    No
    No
    No
    SQL Server 2012
    N/A
    Yes
    Yes
    Yes
    N/A
    Yes
    Yes
    Please remember to click "Mark as Answer" on the post that helps you, and to click
    "Unmark as Answer" if a marked post does not actually answer your question. Please
    VOTE as HELPFUL if the post helps you. This can be beneficial to other community members reading the thread.

  • Counting types of characters using REGEXP

    Hi,
    Is there a simle way to count the types of characters per words in a sentence using regexp?
    I'm trying to get the number of upper and lowercase chars for every [:lower:] and[:upper:] patterns:
    For example
    'John Bell' -> 'A(1)a(3) A(1)a(3)'
    'Frederic McLaughing' -> 'A(1)a(7) A(1)a(1)A(1)a(7)'
    Thanks for your help
    -S.

    MODEL clause to the rescue! You read my mind Volder. ;-) Though I didn't want to work on a MODEL solution until after I knew for sure the OP could use it. Too many times they end up saying "but I'm on Oracle 8" after the fact.
    In hindsight I should have guessed they had 10g because of the fact they asked for a REGEXP solution.
    Regardless, here's what I was thinking, though it doesn't seem as efficient as your approach.
    set null "(null)"
    column s format a30
    column t format a30
    with t as
      ( select 'John Bell' str from dual union all
        select 'Frederic McLaughing' from dual union all
        select null from dual
    select str, s from t
    model
    partition by (str)
    dimension by (0 dim)
    measures
    ( regexp_replace(regexp_replace(str,'[[:lower:]]','x'),'[[:upper:]]','X') s )
    rules iterate(100) -- set this to maximum word size
    ( s[0] =
         replace
         ( s[0],
           rpad( 'X', 100-iteration_number, 'X' ),
           'A(' || to_char(100-iteration_number) || ')'
       s[0] =
         replace
         ( s[0],
           rpad( 'x', 100-iteration_number, 'x' ),
           'a(' || to_char(100-iteration_number) || ')'
    order by 1
    STR                 S
    Frederic McLaughing A(1)a(7) A(1)a(1)A(1)a(7)
    John Bell           A(1)a(3) A(1)a(3)
    (null)              (null)--
    Joe Fuda
    SQL Snippets

  • Count statistics of type of user logging in

    I have an adf application with security.  Once the user logs in successfully, the application redirects to the welcome page.
    I want to count the type of user logged in(rrole), the date and user id and record it in the database.  IT should only record the
    information once when the user logs in successfully before redirecting to the welcome page.  The login page is an html page.
    How do I accomplish this?
    Veena

    Right click on the database, select edit properties.In the dimensions tab you can see the required information.
    Use the below Maxl command.
    query database <<appname>>.<<dbname>> get dbstats dimension;

  • RG1 summary of Finished goods-report.

    Hi Folks,
    RG1 summary of Finished goods-report.
    The closing balance for a particular material number during the month Jan 2007 is showing 1.00 but the opening balance for the same material number during the month February 2007 is showing 0.00 but not 1.00.
    I mean to say the closing balance in January 2007 is not carrying forward into the month Feb 2007.May I know how to go ahead with this problem.
    What is the concept of UPDATE RULES of the table.?
    The previous developer has developed the following report.
    REPORT zxxx MESSAGE-ID z_apd.
    *& Includes *
    INCLUDE <icon>.
    *& Tables *
    TABLES : j_1irg1,
    j_2irg1bal,
    z2irg1bal,
    ser03,
    objk.
    *& Selection Screen *
    SELECTION-SCREEN : BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
    PARAMETERS : p_exgrp TYPE j_1irg1-exgrp OBLIGATORY,
    p_stdate LIKE sy-datum OBLIGATORY,
    p_endate LIKE sy-datum OBLIGATORY.
    SELECT-OPTIONS s_chapid FOR j_1irg1-chapid .
    SELECTION-SCREEN : END OF BLOCK blk1.
    *& Data Declaration *
    Internal Tables
    DATA : it_display TYPE TABLE OF zj1irg1,
    it_final TYPE TABLE OF zj1irg1,
    it_alv TYPE TABLE OF zj1irg1,
    Work Areas
    wa_display TYPE zj1irg1,
    wa_alv TYPE zj1irg1,
    it_display1 TYPE TABLE OF zj1irg1,
    wa_display1 TYPE zj1irg1,
    wa_alv1 TYPE zj1irg1.
    DATA: BEGIN OF it_itab OCCURS 0.
    INCLUDE STRUCTURE zj1irg1.
    DATA: END OF it_itab.
    DATA : BEGIN OF itab1 OCCURS 0,
    matnr LIKE j_1irg1-matnr,
    END OF itab1.
    DATA : BEGIN OF itab2 OCCURS 0,
    cpudt LIKE j_1irg1-cpudt,
    END OF itab2.
    DATA : BEGIN OF itab3 OCCURS 0.
    INCLUDE STRUCTURE j_1irg1.
    DATA: END OF itab3.
    DATA : itab4 LIKE j_1irg1 OCCURS 0 WITH HEADER LINE,
    itab5 LIKE j_1irg1 OCCURS 0 WITH HEADER LINE.
    DATA : BEGIN OF itab6 OCCURS 0.
    INCLUDE STRUCTURE j_1irg1.
    DATA : sernr LIKE objk-sernr.
    DATA: END OF itab6.
    DATA : BEGIN OF itab61 OCCURS 0.
    INCLUDE STRUCTURE j_1irg1.
    DATA: sernr LIKE objk-sernr.
    DATA: END OF itab61.
    DATA : itab7 LIKE j_2irg1bal OCCURS 0 WITH HEADER LINE,
    it_bal LIKE j_2irg1bal OCCURS 0 WITH HEADER LINE,
    it_bal1 LIKE j_2irg1bal OCCURS 0 WITH HEADER LINE.
    DATA: qty_menge LIKE j_1irg1-menge,
    iss_menge LIKE j_1irg1-menge,
    tot_menge LIKE j_1irg1-menge,
    op_menge LIKE j_1irg1-menge,
    matnr LIKE j_1irg1-matnr,
    exgrp LIKE j_1irg1-exgrp ,
    cpudt LIKE j_1irg1-cpudt.
    *for checcking lines of itab
    DATA: n1 TYPE i.
    Others
    DATA : v_bwart TYPE mseg-bwart,
    v_index TYPE i,
    v_index1 TYPE i,
    count(4) TYPE n VALUE '0',
    neg TYPE char1 VALUE '-',
    menge TYPE char16,
    count_1 TYPE i,
    count_2 TYPE i,
    count_3 TYPE i,
    count12(4) TYPE n VALUE '0',
    count13(4) TYPE n VALUE '0'.
    *Ranges
    RANGES: v_bwart1 FOR mseg-bwart.
    For ALV Display
    DATA : gs_variant TYPE disvariant,
    gs_layout TYPE lvc_s_layo,
    c_stk TYPE scrfname VALUE 'ZRG1',
    custom_container TYPE REF TO cl_gui_custom_container.
    CLASS lcl_event_receiver DEFINITION DEFERRED.
    DATA : grid1 TYPE REF TO cl_gui_alv_grid,
    event_receiver TYPE REF TO lcl_event_receiver,
    ok_code TYPE sy-ucomm,
    it_fieldcatalog TYPE lvc_t_fcat,
    wafieldcatlog TYPE LINE OF lvc_t_fcat,
    lt_rows TYPE lvc_t_row,
    wa_rows TYPE LINE OF lvc_t_row.
    *& Start of Selection *
    START-OF-SELECTION.
    IMPORT s_chapid FROM MEMORY ID 'SCHAPID'.
    PERFORM get_data.
    IF it_display[] IS INITIAL.
    No Details Available
    MESSAGE i017(z_apd) WITH text-005.
    STOP.
    ELSE.
    Display the Details on the Screen
    sort it_display by matnr.
    *sort it_display by cpudt RISINDR RISINDI matnr.
    LOOP AT it_display INTO wa_display.
    ON CHANGE OF wa_display-matnr.
    *insert
    *Check record exits
    SELECT SINGLE * FROM z2irg1bal
    WHERE
    exgrp = exgrp AND
    matnr = matnr AND
    form = 'P' AND
    cb_finish = tot_menge AND
    datum = cpudt.
    *If record does not exists
    *Update balance Table.
    IF count12 GE 1.
    IF sy-subrc NE 0.
    z2irg1bal-mandt = sy-mandt.
    z2irg1bal-exgrp = exgrp.
    z2irg1bal-matnr = matnr.
    z2irg1bal-form = 'P'.
    z2irg1bal-cb_finish = tot_menge.
    z2irg1bal-datum = cpudt.
    INSERT z2irg1bal ."values wa_display.
    COMMIT WORK.
    ENDIF.
    Start of Insertion
    IF sy-subrc EQ 0.
    z2irg1bal-mandt = sy-mandt.
    z2irg1bal-exgrp = exgrp.
    z2irg1bal-matnr = matnr.
    z2irg1bal-form = 'P'.
    z2irg1bal-cb_finish = tot_menge.
    z2irg1bal-datum = cpudt.
    UPDATE z2irg1bal SET cb_finish = z2irg1bal-cb_finish
    WHERE exgrp = z2irg1bal-exgrp AND
    datum = z2irg1bal-datum AND
    matnr = z2irg1bal-matnr AND
    form = 'P'.
    ENDIF.
    End of Insertion.
    ENDIF.
    CLEAR: qty_menge,
    iss_menge,
    tot_menge,
    count,
    matnr,
    cpudt,
    exgrp.
    ENDON.
    loop at itab6.
    AT NEW matnr.
    v_index = 1.
    count = count + 1 .
    ENDAT.
    IF v_index = 1.
    CLEAR v_index.
    *INsert for adding start
    IF wa_display-risind = 'R'.
    *wa_display-OP_FINISH = wa_display-OP_FINISH +
    wa_display-CB_FINISH +
    wa_display-MENGE.
    wa_display-op_finish = wa_display-menge.
    qty_menge = wa_display-op_finish.
    IF wa_display-status = space.
    tot_menge = tot_menge + qty_menge + wa_display-cb_finish .
    ELSE.
    tot_menge = tot_menge - qty_menge + wa_display-cb_finish.
    ENDIF.
    *tot_menge = op_menge.
    op_menge = tot_menge.
    ELSE.
    *Qty Issued
    wa_display-op_bond = wa_display-op_finish - wa_display-menge.
    IF wa_display-op_bond LT 0.
    iss_menge = wa_display-op_bond.
    iss_menge = ABS( iss_menge ).
    *Start of modification
    tot_MENGE = tot_MENGE - iss_MENGE ."
    IF count LE 1.
    tot_menge = wa_display-cb_finish - iss_menge ."
    ELSE.
    tot_menge = tot_menge - iss_menge ."
    ENDIF.
    *End of modification
    op_menge = tot_menge.
    ENDIF.
    ENDIF.
    *wa_display-MENGE_FINI = wa_display-OP_FINISH - wa_display-OP_BOND.
    *tot_MENGE = tot_MENGE + qty_MENGE - iss_MENGE .
    wa_display-menge_fini = tot_menge.
    **matnr for insert
    matnr = wa_display-matnr.
    *excise group
    exgrp = wa_display-exgrp.
    *Date
    cpudt = wa_display-cpudt.
    *Opening Balance
    *Insert start
    *if count le 1.
    if wa_display-RISIND = 'R'.
    wa_display-CB_FINISH = wa_display-CB_FINISH + qty_MENGE.
    else.
    wa_display-CB_FINISH = wa_display-CB_FINISH - iss_MENGE.
    endif.
    *endif.
    *Insert End
    IF count GT 1.
    IF wa_display-risind = 'R'.
    wa_display-cb_finish = tot_menge - qty_menge.
    ELSE.
    wa_display-cb_finish = tot_menge + iss_menge.
    ENDIF.
    ENDIF.
    *check it_display-SERIALNO = wa_display-SERIALNO.
    MODIFY it_display FROM wa_display.
    *INsert for adding end
    *move-corresponding wa_display to it_itab.
    *append it_itab.
    *check it_itab-SERIALNO = wa_display-SERIALNO.
    *if sy-subrc = 0.
    *endif.
    *Insert to update closng to balance to Rg1bal table
    *start
    count12 = count12 + 1.
    *for last record
    AT LAST.
    *Check record exits
    SELECT SINGLE * FROM z2irg1bal
    WHERE
    exgrp = exgrp AND
    matnr = matnr AND
    form = 'P' AND
    cb_finish = tot_menge AND
    datum = cpudt.
    *If record does not exists
    *Update balance Table.
    IF count12 GE 1.
    IF sy-subrc NE 0.
    z2irg1bal-mandt = sy-mandt.
    z2irg1bal-exgrp = exgrp.
    z2irg1bal-matnr = matnr.
    z2irg1bal-form = 'P'.
    z2irg1bal-cb_finish = tot_menge.
    z2irg1bal-datum = cpudt.
    INSERT z2irg1bal ."values wa_display.
    COMMIT WORK.
    Start of Insertion
    IF sy-subrc EQ 0.
    z2irg1bal-mandt = sy-mandt.
    z2irg1bal-exgrp = exgrp.
    z2irg1bal-matnr = matnr.
    z2irg1bal-form = 'P'.
    z2irg1bal-cb_finish = tot_menge.
    z2irg1bal-datum = cpudt.
    UPDATE z2irg1bal SET cb_finish = z2irg1bal-cb_finish
    WHERE exgrp = z2irg1bal-exgrp AND
    datum = z2irg1bal-datum AND
    matnr = z2irg1bal-matnr AND
    form = 'P'.
    ENDIF.
    End of Insertion
    ENDIF.
    ENDIF.
    ENDAT.
    *Insert to update closng to balance to Rg1bal table
    *end
    MOVE-CORRESPONDING wa_display TO wa_alv.
    APPEND wa_alv TO it_alv.
    append itab6 to it_alv.
    ENDIF.
    ENDLOOP.
    loop at it_alv into wa_alv.
    wa_alv-exgrp = wa_alv-exgrp.
    wa_alv-SYEAR = wa_alv-syear.
    wa_alv-SERIALNO = wa_alv-SERIALNO.
    endloop.
    EXPORT it_alv TO MEMORY ID 'ABCD'.
    call screen 100.
    ENDIF.
    *& End of Selection *
    END-OF-SELECTION.
    *& Class Definition *
    CLASS lcl_event_receiver DEFINITION.
    PUBLIC SECTION.
    METHODS:
    handle_toolbar
    FOR EVENT toolbar OF cl_gui_alv_grid
    IMPORTING e_object e_interactive,
    handle_user_command
    FOR EVENT user_command OF cl_gui_alv_grid
    IMPORTING e_ucomm,
    handle_double_click
    FOR EVENT double_click OF cl_gui_alv_grid
    IMPORTING e_row e_column.
    PRIVATE SECTION.
    ENDCLASS. "lcl_event_receiver DEFINITION
    *& Class Implementation *
    CLASS lcl_event_receiver IMPLEMENTATION.
    METHOD handle_toolbar.
    Local Variables
    DATA: ls_toolbar TYPE stb_button.
    append a separator to normal toolbar
    CLEAR ls_toolbar.
    MOVE 3 TO ls_toolbar-butn_type.
    APPEND ls_toolbar TO e_object->mt_toolbar.
    append an icon to to show printing
    CLEAR ls_toolbar.
    MOVE 'PRINT' TO ls_toolbar-function.
    MOVE icon_print TO ls_toolbar-icon.
    MOVE 'Print Receipts' TO ls_toolbar-quickinfo.
    MOVE ' Print' TO ls_toolbar-text.
    MOVE ' ' TO ls_toolbar-disabled.
    APPEND ls_toolbar TO e_object->mt_toolbar.
    ENDMETHOD. " Handle_toolbar
    METHOD handle_user_command.
    CASE e_ucomm.
    WHEN 'PRINT'.
    REFRESH : lt_rows , it_final.
    CALL METHOD grid1->get_selected_rows
    IMPORTING
    et_index_rows = lt_rows.
    CALL METHOD cl_gui_cfw=>flush.
    LOOP AT lt_rows INTO wa_rows.
    READ TABLE it_alv INDEX wa_rows-index INTO wa_alv.
    LOOP AT it_display INTO wa_display
    WHERE mblnr = wa_alv-mblnr.
    APPEND wa_display TO it_final.
    ENDLOOP.
    ENDLOOP.
    perform display_form.
    ENDCASE.
    ENDMETHOD. "handle_user_command
    METHOD handle_double_click.
    IF e_column = 'MBLNR'.
    READ TABLE it_alv INDEX e_row-index INTO wa_alv.
    IF sy-subrc = 0.
    REFRESH it_final.
    LOOP AT it_display INTO wa_display
    WHERE mblnr = wa_alv-mblnr.
    APPEND wa_display TO it_final.
    ENDLOOP.
    PERFORM call_migo.
    ENDIF.
    ENDIF.
    ENDMETHOD. "handle_double_click
    ENDCLASS. "lcl_event_receiver IMPLEMENTATION
    *& Form get_data
    text
    --> p1 text
    <-- p2 text
    FORM get_data .
    *Select only for matnr and chapid from table
    SELECT matnr FROM j_1irg1
    APPENDING CORRESPONDING FIELDS OF TABLE itab1
    WHERE exgrp = p_exgrp
    AND
    WERKS = P_WERKS
    and
    MATNR in s_MATNR
    and
    CPUDT in s_CPUDT.
    cpudt BETWEEN p_stdate AND p_endate
    AND
    *Chapid
    chapid IN s_chapid
    ORDER BY matnr.
    SORT itab1 BY matnr. " for performance
    DELETE ADJACENT DUPLICATES FROM itab1 COMPARING matnr .
    SELECT cpudt FROM j_1irg1
    APPENDING CORRESPONDING FIELDS OF TABLE itab2
    WHERE exgrp = p_exgrp
    AND
    cpudt BETWEEN p_stdate AND p_endate
    AND
    *Chapid
    chapid IN s_chapid
    ORDER BY cpudt.
    SORT itab2 BY cpudt. " for Performance
    DELETE ADJACENT DUPLICATES FROM itab2 COMPARING cpudt .
    LOOP AT itab1.
    LOOP AT itab2.
    *on change of itab1-matnr or itab2-cpudt.
    *select * from J_1IRG1
    CLEAR itab3.
    SELECT * FROM j_1irg1
    *into itab3
    APPENDING CORRESPONDING FIELDS OF TABLE itab3
    WHERE matnr = itab1-matnr
    AND
    cpudt = itab2-cpudt.
    *count = count + 1.
    IF sy-subrc EQ 0.
    LOOP AT itab3.
    *count = count + 1.
    *READ TABLE itab3 INDEX count."1.
    IF itab3-risind = 'R'.
    MOVE-CORRESPONDING itab3 TO itab4.
    APPEND itab4.
    DELETE itab3.
    MOVE-CORRESPONDING itab4 TO itab6.
    APPEND itab6.
    CLEAR itab4.
    ELSE.
    MOVE-CORRESPONDING itab3 TO itab5.
    APPEND itab5.
    DELETE itab3.
    MOVE-CORRESPONDING itab5 TO itab6.
    APPEND itab6.
    CLEAR itab5.
    ENDIF.
    ENDLOOP.
    ENDIF.
    *endon.
    ENDLOOP.
    ENDLOOP.
    SELECT * FROM z2irg1bal
    APPENDING CORRESPONDING FIELDS OF TABLE itab7
    WHERE exgrp = p_exgrp
    AND
    datum LE p_stdate
    ORDER BY datum.
    SORT itab7 BY datum.
    DELETE ADJACENT DUPLICATES FROM itab7 COMPARING datum .
    *insert Start
    LOOP AT itab6.
    DELETE itab7 WHERE matnr NE itab6-matnr.
    ENDLOOP.
    *insert End
    *insert Start
    LOOP AT itab6.
    CLEAR itab61. REFRESH itab61.
    CLEAR wa_display.
    MOVE-CORRESPONDING itab6 TO wa_display.
    EQPT Serno
    count13 = 1.
    SELECT SINGLE obknr FROM ser03 INTO ser03-obknr WHERE
    mblnr EQ itab6-mblnr
    AND mjahr EQ itab6-mjahr.
    IF sy-subrc EQ 0.
    SELECT sernr FROM objk INTO CORRESPONDING
    FIELDS OF TABLE itab61 WHERE
    obknr EQ ser03-obknr.
    DESCRIBE TABLE itab61 LINES n1.
    *do N1 times.
    LOOP AT itab61.
    IF count13 EQ 1.
    wa_display-sernr = itab61-sernr.
    ENDIF.
    IF count13 EQ 2.
    wa_display-sernr1 = itab61-sernr.
    ENDIF.
    IF count13 EQ 3.
    wa_display-sernr2 = itab61-sernr.
    ENDIF.
    IF count13 EQ 4.
    wa_display-sernr3 = itab61-sernr.
    ENDIF.
    IF count13 EQ 5.
    wa_display-sernr4 = itab61-sernr.
    ENDIF.
    IF count13 EQ 6.
    wa_display-sernr5 = itab61-sernr.
    ENDIF.
    IF count13 EQ 7.
    wa_display-sernr6 = itab61-sernr.
    ENDIF.
    if count13 eq 8.
    objk-SERNR8 = objk-SERNR.
    endif.
    if count13 eq 9.
    objk-SERNR9 = objk-SERNR.
    endif.
    count13 = count13 + 1.
    endselect.
    ENDLOOP.
    *enddo.
    ENDIF.
    endif.
    *End of Modification Eqpt Serial No
    MOVE-CORRESPONDING itab6 TO wa_display.
    SELECT * FROM z2irg1bal
    APPENDING CORRESPONDING FIELDS OF TABLE it_bal1
    WHERE matnr = itab6-matnr
    AND datum LE p_stdate
    AND exgrp = itab6-exgrp.
    SORT it_bal1 DESCENDING .
    READ TABLE it_bal1 INDEX 1.
    ON CHANGE OF itab6-matnr .
    wa_display-cb_finish = it_bal1-cb_finish.
    ENDON.
    AT LAST ."matnr.
    wa_display-cb_finish = it_bal1-cb_finish.
    ENDAT.
    APPEND wa_display TO it_display .
    CLEAR wa_display-cb_finish.
    CLEAR it_bal1. REFRESH it_bal1.
    ENDLOOP.
    SELECT * FROM j_1irg1
    APPENDING CORRESPONDING FIELDS OF TABLE it_itab
    WHERE exgrp = p_exgrp
    AND
    cpudt BETWEEN p_stdate AND p_endate.
    DESCRIBE TABLE it_itab[] LINES count_1.
    count_3 = count_1 + 1.
    DESCRIBE TABLE it_display[] LINES count_2.
    IF it_display IS NOT INITIAL.
    DELETE it_display FROM count_3 TO count_2.
    ENDIF.
    *start of insertion
    DELETE it_display WHERE status = 'C'.
    LOOP AT it_display INTO wa_display.
    CLEAR wa_display-cb_finish.
    MODIFY it_display FROM wa_display.
    ON CHANGE OF wa_display-matnr .
    SELECT * FROM z2irg1bal
    INTO CORRESPONDING FIELDS OF TABLE it_bal1
    WHERE matnr = wa_display-matnr
    AND datum LE p_stdate
    AND exgrp = wa_display-exgrp.
    IF sy-subrc = 0.
    SORT it_bal1 DESCENDING .
    READ TABLE it_bal1 INDEX 1.
    wa_display-cb_finish = it_bal1-cb_finish.
    MODIFY it_display FROM wa_display.
    ENDIF.
    ENDON.
    ENDLOOP.
    *End of insertion
    ENDFORM. " get_data
    *& Module STATUS_0100 OUTPUT
    text
    MODULE status_0100 OUTPUT.
    SET PF-STATUS 'ZRG1'.
    SET TITLEBAR 'ZRG1'.
    DATA: lt_exclude TYPE ui_functions.
    IF custom_container IS INITIAL.
    Create the Custom Container
    CREATE OBJECT custom_container
    EXPORTING
    container_name = c_stk.
    Create an instance of alv control
    CREATE OBJECT grid1
    EXPORTING
    i_parent = custom_container.
    Layout Settings
    gs_layout-sel_mode = 'A'. " Multiple Lines
    MOVE 'RG1 Register' TO gs_layout-grid_title.
    Prepare the Field Catalog
    PERFORM prepare_catalog.
    To Exclude the PRINT Button from the Standard toolbar of ALV
    PERFORM exclude_tb_functions CHANGING lt_exclude.
    Display the List for ALV Display
    CALL METHOD grid1->set_table_for_first_display
    EXPORTING
    it_toolbar_excluding = lt_exclude
    is_layout = gs_layout
    CHANGING
    it_fieldcatalog = it_fieldcatalog[]
    it_outtab = it_alv[].
    CREATE OBJECT event_receiver.
    SET HANDLER event_receiver->handle_user_command FOR grid1.
    SET HANDLER event_receiver->handle_toolbar FOR grid1.
    SET HANDLER event_receiver->handle_double_click FOR grid1.
    CALL METHOD grid1->set_toolbar_interactive.
    ENDIF.
    CALL METHOD cl_gui_control=>set_focus
    EXPORTING
    control = grid1.
    ENDMODULE. " STATUS_0100 OUTPUT
    *& Form exclude_tb_functions
    text
    <--P_LT_EXCLUDE text
    FORM exclude_tb_functions CHANGING pt_exclude TYPE ui_functions.
    Local Varaibles
    DATA ls_exclude TYPE ui_func.
    ls_exclude = cl_gui_alv_grid=>mc_fc_print.
    APPEND ls_exclude TO pt_exclude.
    ENDFORM. " exclude_tb_functions
    *& Form prepare_catalog
    text
    --> p1 text
    <-- p2 text
    FORM prepare_catalog .
    DATA : v_index TYPE i.
    *Entry Date
    v_index = v_index + 1.
    wafieldcatlog-fieldname = 'CPUDT'.
    wafieldcatlog-tabname = 'IT_ALV'.
    wafieldcatlog-seltext = 'RG1 Entry Date'.
    wafieldcatlog-reptext = 'RG1 Entry Date'.
    wafieldcatlog-hotspot = ' '.
    wafieldcatlog-col_pos = v_index.
    APPEND wafieldcatlog TO it_fieldcatalog.
    CLEAR wafieldcatlog-reptext.
    CLEAR wafieldcatlog-key.
    *Serial No
    v_index = v_index + 1.
    wafieldcatlog-fieldname = 'SERIALNO'.
    wafieldcatlog-tabname = 'IT_ALV'.
    wafieldcatlog-seltext = 'RG1 serial number'.
    wafieldcatlog-reptext = 'RG1 serial number'.
    wafieldcatlog-hotspot = ' '.
    wafieldcatlog-col_pos = v_index.
    APPEND wafieldcatlog TO it_fieldcatalog.
    CLEAR wafieldcatlog-reptext.
    CLEAR wafieldcatlog-key.
    v_index = v_index + 1.
    wafieldcatlog-fieldname = 'CHAPID'.
    wafieldcatlog-tabname = 'IT_ALV'.
    wafieldcatlog-seltext = 'Chapter ID'.
    wafieldcatlog-reptext = 'Chapter ID'.
    wafieldcatlog-hotspot = ' '.
    wafieldcatlog-col_pos = v_index.
    APPEND wafieldcatlog TO it_fieldcatalog.
    CLEAR wafieldcatlog-reptext.
    CLEAR wafieldcatlog-key.
    v_index = v_index + 1.
    wafieldcatlog-fieldname = 'MBLNR'.
    wafieldcatlog-tabname = 'IT_ALV'.
    wafieldcatlog-seltext = 'Number of Material Document'.
    wafieldcatlog-reptext = 'Number of Material Document'.
    wafieldcatlog-hotspot = ' '.
    wafieldcatlog-col_pos = v_index.
    APPEND wafieldcatlog TO it_fieldcatalog.
    CLEAR wafieldcatlog-reptext.
    CLEAR wafieldcatlog-key.
    *Item
    v_index = v_index + 1.
    wafieldcatlog-fieldname = 'ZEILE'.
    wafieldcatlog-tabname = 'IT_ALV'.
    wafieldcatlog-seltext = 'Item in Material Document'.
    wafieldcatlog-reptext = 'Item in Material Document'.
    wafieldcatlog-hotspot = ' '.
    wafieldcatlog-col_pos = v_index.
    APPEND wafieldcatlog TO it_fieldcatalog.
    CLEAR wafieldcatlog-reptext.
    CLEAR wafieldcatlog-key.
    v_index = v_index + 1.
    wafieldcatlog-fieldname = 'BWART'.
    wafieldcatlog-tabname = 'IT_ALV'.
    wafieldcatlog-seltext = 'Movement Type'.
    wafieldcatlog-reptext = 'Movement Type'.
    wafieldcatlog-hotspot = ' '.
    wafieldcatlog-col_pos = v_index.
    APPEND wafieldcatlog TO it_fieldcatalog.
    CLEAR wafieldcatlog-reptext.
    CLEAR wafieldcatlog-key.
    v_index = v_index + 1.
    wafieldcatlog-fieldname = 'MENGE'.
    wafieldcatlog-tabname = 'IT_ALV'.
    wafieldcatlog-seltext = 'Quantity'.
    wafieldcatlog-reptext = 'Quantity'.
    wafieldcatlog-hotspot = ' '.
    wafieldcatlog-col_pos = v_index.
    wafieldcatlog-DO_SUM = 'X'.
    append wafieldcatlog to it_fieldcatalog.
    clear wafieldcatlog-reptext.
    clear wafieldcatlog-key.
    *Base Unit of Measure
    v_index = v_index + 1.
    wafieldcatlog-fieldname = 'MEINS'.
    wafieldcatlog-tabname = 'IT_ALV'.
    wafieldcatlog-seltext = 'Base Unit of Measure'.
    wafieldcatlog-reptext = 'Base Unit of Measure'.
    wafieldcatlog-hotspot = ' '.
    wafieldcatlog-col_pos = v_index.
    wafieldcatlog-do_sum = 'X'.
    APPEND wafieldcatlog TO it_fieldcatalog.
    CLEAR wafieldcatlog-reptext.
    CLEAR wafieldcatlog-key.
    v_index = v_index + 1.
    wafieldcatlog-fieldname = 'RISIND'.
    wafieldcatlog-tabname = 'IT_ALV'.
    wafieldcatlog-seltext = 'Goods Movement Direction'.
    wafieldcatlog-reptext = 'Goods Movement Direction'.
    wafieldcatlog-hotspot = ' '.
    wafieldcatlog-col_pos = v_index.
    APPEND wafieldcatlog TO it_fieldcatalog.
    CLEAR wafieldcatlog-reptext.
    CLEAR wafieldcatlog-key.
    *Material Number
    v_index = v_index + 1.
    wafieldcatlog-fieldname = 'MATNR'.
    wafieldcatlog-tabname = 'IT_ALV'.
    wafieldcatlog-seltext = 'Material Number'.
    wafieldcatlog-reptext = 'Material Number'.
    wafieldcatlog-hotspot = ' '.
    wafieldcatlog-col_pos = v_index.
    APPEND wafieldcatlog TO it_fieldcatalog.
    CLEAR wafieldcatlog-reptext.
    CLEAR wafieldcatlog-key.
    *CB_FINISH
    v_index = v_index + 1.
    wafieldcatlog-fieldname = 'CB_FINISH'.
    wafieldcatlog-tabname = 'IT_ALV'.
    wafieldcatlog-seltext = 'Opening Balance'.
    wafieldcatlog-reptext = 'Opening Balance'.
    wafieldcatlog-hotspot = ' '.
    wafieldcatlog-col_pos = v_index.
    APPEND wafieldcatlog TO it_fieldcatalog.
    CLEAR wafieldcatlog-reptext.
    CLEAR wafieldcatlog-key.
    *materail manufactured
    v_index = v_index + 1.
    wafieldcatlog-fieldname = 'OP_FINISH'.
    wafieldcatlog-tabname = 'IT_ALV'.
    wafieldcatlog-seltext = 'Qty Manufactured'.
    wafieldcatlog-reptext = 'Qty Manufactured'.
    wafieldcatlog-hotspot = ' '.
    wafieldcatlog-col_pos = v_index.
    APPEND wafieldcatlog TO it_fieldcatalog.
    CLEAR wafieldcatlog-reptext.
    CLEAR wafieldcatlog-key.
    *Material Issued
    v_index = v_index + 1.
    wafieldcatlog-fieldname = 'OP_BOND'.
    wafieldcatlog-tabname = 'IT_ALV'.
    wafieldcatlog-seltext = 'Qty Issue'.
    wafieldcatlog-reptext = 'Qty Issue'.
    wafieldcatlog-hotspot = ' '.
    wafieldcatlog-col_pos = v_index.
    APPEND wafieldcatlog TO it_fieldcatalog.
    CLEAR wafieldcatlog-reptext.
    CLEAR wafieldcatlog-key.
    *Total
    v_index = v_index + 1.
    wafieldcatlog-fieldname = 'MENGE_FINI'.
    wafieldcatlog-tabname = 'IT_ALV'.
    wafieldcatlog-seltext = 'Closing Balance'.
    wafieldcatlog-reptext = 'Closing Balance'.
    wafieldcatlog-hotspot = ' '.
    wafieldcatlog-col_pos = v_index.
    APPEND wafieldcatlog TO it_fieldcatalog.
    CLEAR wafieldcatlog-reptext.
    CLEAR wafieldcatlog-key.
    *Material Description
    v_index = v_index + 1.
    wafieldcatlog-fieldname = 'MAKTX'.
    wafieldcatlog-tabname = 'IT_ALV'.
    wafieldcatlog-seltext = 'Material Description'.
    wafieldcatlog-reptext = 'Material Description'.
    wafieldcatlog-hotspot = ' '.
    wafieldcatlog-col_pos = v_index.
    APPEND wafieldcatlog TO it_fieldcatalog.
    CLEAR wafieldcatlog-reptext.
    CLEAR wafieldcatlog-key.
    *Storage Location
    v_index = v_index + 1.
    wafieldcatlog-fieldname = 'LGORT'.
    wafieldcatlog-tabname = 'IT_ALV'.
    wafieldcatlog-seltext = 'Storage Location'.
    wafieldcatlog-reptext = 'Storage Location'.
    wafieldcatlog-hotspot = ' '.
    wafieldcatlog-col_pos = v_index.
    APPEND wafieldcatlog TO it_fieldcatalog.
    CLEAR wafieldcatlog-reptext.
    CLEAR wafieldcatlog-key.
    *Goods Movement Direction
    v_index = v_index + 1.
    wafieldcatlog-fieldname = 'RISIND'.
    wafieldcatlog-tabname = 'IT_ALV'.
    wafieldcatlog-seltext = 'Goods Movement Direction'.
    wafieldcatlog-reptext = 'Goods Movement Direction'.
    wafieldcatlog-hotspot = ' '.
    wafieldcatlog-col_pos = v_index.
    APPEND wafieldcatlog TO it_fieldcatalog.
    CLEAR wafieldcatlog-reptext.
    CLEAR wafieldcatlog-key.
    *Reference Document 1
    v_index = v_index + 1.
    wafieldcatlog-fieldname = 'RDOC1'.
    wafieldcatlog-tabname = 'IT_ALV'.
    wafieldcatlog-seltext = 'Reference Document 1'.
    wafieldcatlog-reptext = 'Reference Document 1'.
    wafieldcatlog-hotspot = ' '.
    wafieldcatlog-col_pos = v_index.
    APPEND wafieldcatlog TO it_fieldcatalog.
    CLEAR wafieldcatlog-reptext.
    CLEAR wafieldcatlog-key.
    *Excise Duty Base Amount
    v_index = v_index + 1.
    wafieldcatlog-fieldname = 'EXBAS'.
    wafieldcatlog-tabname = 'IT_ALV'.
    wafieldcatlog-seltext = 'Excise Duty Base Amount'.
    wafieldcatlog-reptext = 'Excise Duty Base Amount'.
    wafieldcatlog-hotspot = ' '.
    wafieldcatlog-col_pos = v_index.
    APPEND wafieldcatlog TO it_fieldcatalog.
    CLEAR wafieldcatlog-reptext.
    CLEAR wafieldcatlog-key.
    *Basic Excise Duty
    v_index = v_index + 1.
    wafieldcatlog-fieldname = 'EXBED'.
    wafieldcatlog-tabname = 'IT_ALV'.
    wafieldcatlog-seltext = 'Basic Excise Duty'.
    wafieldcatlog-reptext = 'Basic Excise Duty'.
    wafieldcatlog-hotspot = ' '.
    wafieldcatlog-col_pos = v_index.
    APPEND wafieldcatlog TO it_fieldcatalog.
    CLEAR wafieldcatlog-reptext.
    CLEAR wafieldcatlog-key.
    *Additional Excise Duty
    v_index = v_index + 1.
    wafieldcatlog-fieldname = 'EXAED'.
    wafieldcatlog-tabname = 'IT_ALV'.
    wafieldcatlog-seltext = 'Additional Excise Duty'.
    wafieldcatlog-reptext = 'Additional Excise Duty'.
    wafieldcatlog-hotspot = ' '.
    wafieldcatlog-col_pos = v_index.
    APPEND wafieldcatlog TO it_fieldcatalog.
    CLEAR wafieldcatlog-reptext.
    CLEAR wafieldcatlog-key.
    *Special Excise Duty
    v_index = v_index + 1.
    wafieldcatlog-fieldname = 'EXSED'.
    wafieldcatlog-tabname = 'IT_ALV'.
    wafieldcatlog-seltext = 'Special Excise Duty'.
    wafieldcatlog-reptext = 'Special Excise Duty'.
    wafieldcatlog-hotspot = ' '.
    wafieldcatlog-col_pos = v_index.
    APPEND wafieldcatlog TO it_fieldcatalog.
    CLEAR wafieldcatlog-reptext.
    CLEAR wafieldcatlog-key.
    *Cess amount
    v_index = v_index + 1.
    wafieldcatlog-fieldname = 'CESS'.
    wafieldcatlog-tabname = 'IT_ALV'.
    wafieldcatlog-seltext = 'Cess amount'.
    wafieldcatlog-reptext = 'Cess amount'.
    wafieldcatlog-hotspot = ' '.
    wafieldcatlog-col_pos = v_index.
    APPEND wafieldcatlog TO it_fieldcatalog.
    CLEAR wafieldcatlog-reptext.
    CLEAR wafieldcatlog-key.
    *ECS Value
    v_index = v_index + 1.
    wafieldcatlog-fieldname = 'ECS'.
    wafieldcatlog-tabname = 'IT_ALV'.
    wafieldcatlog-seltext = 'ECS Value'.
    wafieldcatlog-reptext = 'ECS Value'.
    wafieldcatlog-hotspot = ' '.
    wafieldcatlog-col_pos = v_index.
    APPEND wafieldcatlog TO it_fieldcatalog.
    CLEAR wafieldcatlog-reptext.
    CLEAR wafieldcatlog-key.
    **Register Entry Status
    v_index = v_index + 1.
    wafieldcatlog-fieldname = 'STATUS'.
    wafieldcatlog-tabname = 'IT_ALV'.
    wafieldcatlog-seltext = 'Register Entry Status'.
    wafieldcatlog-reptext = 'Register Entry Status'.
    wafieldcatlog-hotspot = ' '.
    wafieldcatlog-col_pos = v_index.
    append wafieldcatlog to it_fieldcatalog.
    clear wafieldcatlog-reptext.
    clear wafieldcatlog-key.
    *EQPT Serno 1 Value
    v_index = v_index + 1.
    wafieldcatlog-fieldname = 'SERNR'.
    wafieldcatlog-tabname = 'IT_ALV'.
    wafieldcatlog-seltext = 'Serial number'.
    wafieldcatlog-reptext = 'Serial number'.
    wafieldcatlog-hotspot = ' '.
    wafieldcatlog-col_pos = v_index.
    APPEND wafieldcatlog TO it_fieldcatalog.
    CLEAR wafieldcatlog-reptext.
    CLEAR wafieldcatlog-key.
    *EQPT Serno 2 Value
    v_index = v_index + 1.
    wafieldcatlog-fieldname = 'SERNR1'.
    wafieldcatlog-tabname = 'IT_ALV'.
    wafieldcatlog-seltext = 'Serial number'.
    wafieldcatlog-reptext = 'Serial number'.
    wafieldcatlog-hotspot = ' '.
    wafieldcatlog-col_pos = v_index.
    APPEND wafieldcatlog TO it_fieldcatalog.
    CLEAR wafieldcatlog-reptext.
    CLEAR wafieldcatlog-key.
    *EQPT Serno 3 Value
    v_index = v_index + 1.
    wafieldcatlog-fieldname = 'SERNR2'.
    wafieldcatlog-tabname = 'IT_ALV'.
    wafieldcatlog-seltext = 'Serial number'.
    wafieldcatlog-reptext = 'Serial number'.
    wafieldcatlog-hotspot = ' '.
    wafieldcatlog-col_pos = v_index.
    APPEND wafieldcatlog TO it_fieldcatalog.
    CLEAR wafieldcatlog-reptext.
    CLEAR wafieldcatlog-key.
    *EQPT Serno 4 Value
    v_index = v_index + 1.
    wafieldcatlog-fieldname = 'SERNR3'.
    wafieldcatlog-tabname = 'IT_ALV'.
    wafieldcatlog-seltext = 'Serial number'.
    wafieldcatlog-reptext = 'Serial number'.
    wafieldcatlog-hotspot = ' '.
    wafieldcatlog-col_pos = v_index.
    APPEND wafieldcatlog TO it_fieldcatalog.
    CLEAR wafieldcatlog-reptext.
    CLEAR wafieldcatlog-key.
    *EQPT Serno 5 Value
    v_index = v_index + 1.
    wafieldcatlog-fieldname = 'SERNR4'.
    wafieldcatlog-tabname = 'IT_ALV'.
    wafieldcatlog-seltext = 'Serial number'.
    wafieldcatlog-reptext = 'Serial number'.
    wafieldcatlog-hotspot = ' '.
    wafieldcatlog-col_pos = v_index.
    APPEND wafieldcatlog TO it_fieldcatalog.
    CLEAR wafieldcatlog-reptext.
    CLEAR wafieldcatlog-key.
    *EQPT Serno 6 Value
    v_index = v_index + 1.
    wafieldcatlog-fieldname = 'SERNR5'.
    wafieldcatlog-tabname = 'IT_ALV'.
    wafieldcatlog-seltext = 'Serial number'.
    wafieldcatlog-reptext = 'Serial number'.
    wafieldcatlog-hotspot = ' '.
    wafieldcatlog-col_pos = v_index.
    APPEND wafieldcatlog TO it_fieldcatalog.
    CLEAR wafieldcatlog-reptext.
    CLEAR wafieldcatlog-key.
    *EQPT Serno 7 Value
    v_index = v_index + 1.
    wafieldcatlog-fieldname = 'SERNR6'.
    wafieldcatlog-tabname = 'IT_ALV'.
    wafieldcatlog-seltext = 'Serial number'.
    wafieldcatlog-reptext = 'Serial number'.
    wafieldcatlog-hotspot = ' '.
    wafieldcatlog-col_pos = v_index.
    APPEND wafieldcatlog TO it_fieldcatalog.
    CLEAR wafieldcatlog-reptext.
    CLEAR wafieldcatlog-key.
    ENDFORM. " prepare_catalog
    *& Module USER_COMMAND_0100 INPUT
    text
    MODULE user_command_0100 INPUT.
    IF ok_code = 'EXIT'.
    CALL METHOD grid1->free.
    CALL METHOD cl_gui_cfw=>flush.
    leave program .
    LEAVE TO SCREEN 0.
    ENDIF.
    ENDMODULE. " USER_COMMAND_0100 INPUT
    *& Form call_migo
    text
    --> p1 text
    <-- p2 text
    FORM call_migo .
    CALL FUNCTION 'MIGO_DIALOG' "n547170
    EXPORTING "n547170
    i_action = 'A04' "n547170
    i_refdoc = 'R02' "n547170
    i_notree = 'X' "n547170
    i_no_auth_check = ' ' "n547170
    i_deadend = 'X' "n547170
    i_skip_first_screen = 'X' "n547170
    i_okcode = 'OK_GO' "n547170
    i_mblnr = wa_alv-mblnr "n547170
    i_mjahr = wa_alv-mjahr . "n547170
    ENDFORM. " call_migo

    T.Code: MB5B
    Regards,
    Rajesh Banka
    How to give points: Mark your thread as a question while creating it. In the answers you get, you can assign the points by clicking on the stars to the left. You also get a point yourself for rewarding (one per thread).

  • Stock summary report

    hi
    i am doing stock summary report
    i am checking the data with mc.9 standard report
    the total amount for particular month is not tallying with standard one.
    data is coming with all the materials and with opening nd closing balances...
    but it is taking the stock amount with inclusive of all taxes. i am using the field mseg-dmbtr.
    but i need the material stock amount without taxes.
    i tried with mbew table, but i didn't get closing stock amount.
    values is there correct value in mbew but i am not able to get the correct value..
    tell me anyother tables or give me any soln....
    thanks nd regards
    vidya

    Go through this......
    *& Report  Z_OPEN_CLOSE                                                *
    REPORT  Z_OPEN_CLOSE MESSAGE-ID YW2 LINE-SIZE 231 LINE-COUNT 45
    NO STANDARD PAGE HEADING.
    Type Declaration *
    TYPE-POOLS SLIS.
    Tables *
    TABLES: MKPF, " Material Document: Header Data
            MSEG, " Material Document: Item Data
            MARA,
            MARD,
            S031,
            EKKO,
            EKPO,
            LIKP,
            MAKT,
            J_1IWRKCUS,
            T001W,
            WB2_V_MKPF_MSEG2,
            MMIM_REP_PRINT,
            YW2_STKMOVEMENTS,
            YPLNT,
            MARDH.
    Internal Tables *
    DATA: I_WERKS LIKE J_1IWRKCUS OCCURS 0 WITH HEADER LINE.
    DATA: BEGIN OF I_YPLNT OCCURS 0,
             PPLNT LIKE YPLNT-PPLNT,
             WPLNT LIKE YPLNT-WPLNT,
          END OF I_YPLNT.
    DATA: BEGIN OF I_MKPF OCCURS 0,
            MBLNR LIKE MKPF-MBLNR,
            MJAHR LIKE MKPF-MJAHR,
            BUDAT LIKE MKPF-BUDAT,
            VGART LIKE MKPF-VGART,
            BWART LIKE MSEG-BWART,
            MATNR LIKE MSEG-MATNR,
            WERKS LIKE MSEG-WERKS,
            LGORT LIKE MSEG-LGORT,
            MENGE LIKE MSEG-MENGE,
            MEINS LIKE MSEG-MEINS,
            KUNNR LIKE MSEG-KUNNR,
            ZEILE LIKE MSEG-ZEILE,
            XAUTO LIKE MSEG-XAUTO,
            SHKZG LIKE MSEG-SHKZG,
            MATNR1 LIKE MSEG-MATNR,
          END OF I_MKPF.
    DATA: BEGIN OF I_MARDH OCCURS 0,
           WERKS LIKE MARDH-WERKS,
           MEINS LIKE MARA-MEINS,
           MATNR LIKE MARDH-MATNR,
           LGORT LIKE MARDH-LGORT,
           LABST LIKE MARDH-LABST,
           LFGJA LIKE MARDH-LFGJA, "Added -MB
           LFMON LIKE MARDH-LFMON, "Added -MB
           PERIO(6),
           INSME LIKE MARDH-LABST,
           EINME LIKE MARDH-LABST,
           SPEME LIKE MARDH-LABST,
           RETME LIKE MARDH-LABST,
           O_STK LIKE MARDH-LABST, " Opening Stock
           C_STK LIKE MARDH-LABST, " Closing Stock
          END OF I_MARDH.
    DATA: BEGIN OF I_MARD OCCURS 0,
           WERKS LIKE MARD-WERKS,
           MATNR LIKE MARD-MATNR,
           LGORT LIKE MARD-LGORT,
           LABST LIKE MARD-LABST,
           INSME LIKE MARD-LABST,
           MEINS LIKE MARA-MEINS,
           EINME LIKE MARD-LABST,
           SPEME LIKE MARD-LABST,
           RETME LIKE MARD-LABST,
          END OF I_MARD.
    DATA: I_MARD1 LIKE I_MARD OCCURS 0 WITH HEADER LINE.
    DATA: I_MARDH1 LIKE I_MARDH OCCURS 0 WITH HEADER LINE.
    DATA: BEGIN OF I_MKPF1 OCCURS 0,
            MBLNR LIKE MKPF-MBLNR,
            WERKS LIKE MSEG-WERKS,
            MATNR LIKE MSEG-MATNR,
            BUDAT LIKE MKPF-BUDAT,
            BWART LIKE MSEG-BWART,
            MJAHR LIKE MKPF-MJAHR,
            VGART LIKE MKPF-VGART,
            LGORT LIKE MSEG-LGORT,
            MENGE LIKE MSEG-MENGE,
            MEINS LIKE MSEG-MEINS,
            XAUTO LIKE MSEG-XAUTO,
            SHKZG LIKE MSEG-SHKZG,
          END OF I_MKPF1.
    DATA: BEGIN OF I_MKPF2 OCCURS 0,
           WERKS LIKE MSEG-WERKS,
           MATNR LIKE MSEG-MATNR,
           BUDAT LIKE MKPF-BUDAT,
           BWART LIKE MSEG-BWART,
           MJAHR LIKE MKPF-MJAHR,
           VGART LIKE MKPF-VGART,
           LGORT LIKE MSEG-LGORT,
           MENGE LIKE MSEG-MENGE,
           MEINS LIKE MSEG-MEINS,
           XAUTO LIKE MSEG-XAUTO,
         END OF I_MKPF2.
    DATA: BEGIN OF I_FINAL5 OCCURS 0,
           WERKS LIKE MSEG-WERKS, " Plant
           MATNR LIKE MSEG-MATNR, " Material
           LGORT LIKE MSEG-LGORT, " Storage Location
           BUDAT LIKE MKPF-BUDAT, " Posting Date
           MTART LIKE MARA-MTART, " Material Type
           SPMON LIKE S031-SPMON, " Month
           MAKTX LIKE MAKT-MAKTX, " Description
    meins(3), " UOM
            MEINS LIKE MSEG-MEINS,
            O_STK LIKE MARDH-LABST, " opening stock
            TRECEP LIKE MARDH-LABST, " total receipts
            PRODU LIKE MARDH-LABST, " Net Receipts - Production
            RECEP LIKE MARDH-LABST, " Net Receipts - Receipts
            SAL_RET LIKE MARDH-LABST, " Net Receipts - Sales Return
            TDISP LIKE MARDH-LABST, " total dispatches
            CUSTMR LIKE MARDH-LABST, " Net Dispatches - Customers
            OPLANT LIKE MARDH-LABST, " Net Dispatches - To Other Plant
            TLOSS LIKE MARDH-LABST, " Total Loss
            TRLOSS LIKE MARDH-LABST, " Transit Loss
            WHLOSS LIKE MARDH-LABST, " Warehouse Loss
            C_STK LIKE MARDH-LABST, " Closing Stock
            TRFSTK LIKE MARDH-LABST, "Transfer stock
            MENGE LIKE MSEG-MENGE,
            OTHADJ LIKE MARDH-LABST,
          END OF I_FINAL5.
    DATA: BEGIN OF I_FINAL OCCURS 0,
            WERKS LIKE MSEG-WERKS, " Plant
            MATNR LIKE MSEG-MATNR, " Material
            BUDAT LIKE MKPF-BUDAT, " Posting Date
            MTART LIKE MARA-MTART, " Material Type
            SPMON LIKE S031-SPMON, " Month
            MAKTX LIKE MAKT-MAKTX, " Description
    meins(3), " UOM
            MEINS LIKE MSEG-MEINS,
            O_STK LIKE MARDH-LABST, " opening stock
            TRECEP LIKE MARDH-LABST, " total receipts
            PRODU LIKE MARDH-LABST, " Net Receipts - Production
            RECEP LIKE MARDH-LABST, " Net Receipts - Receipts
            SAL_RET LIKE MARDH-LABST, " Net Receipts - Sales Return
            TDISP LIKE MARDH-LABST, " total dispatches
            CUSTMR LIKE MARDH-LABST, " Net Dispatches - Customers
            OPLANT LIKE MARDH-LABST, " Net Dispatches - To Other Plant
            TRFSTK LIKE MARDH-LABST, "Material Transfer stock
            TRLOSS LIKE MARDH-LABST, " Transit Loss
            WHLOSS LIKE MARDH-LABST, " Warehouse Loss
            TLOSS LIKE MARDH-LABST, " Total Loss
            C_STK LIKE MARDH-LABST, " Closing Stock
            OTHADJ LIKE MARDH-LABST,
           END OF I_FINAL.
    DATA: I_FINAL1 LIKE I_FINAL OCCURS 0 WITH HEADER LINE.
    DATA: BEGIN OF I_FINAL_TEMP OCCURS 0,
            WERKS LIKE MSEG-WERKS, " Plant
            MATNR LIKE MSEG-MATNR, " Material
            MTART LIKE MARA-MTART, " Material Type
            MAKTX LIKE MAKT-MAKTX, " Description
            MEINS LIKE MSEG-MEINS,
            O_STK LIKE MARDH-LABST, " opening stock
            TRECEP LIKE MARDH-LABST, " total receipts
            PRODU LIKE MARDH-LABST, " Net Receipts - Production
            RECEP LIKE MARDH-LABST, " Net Receipts - Receipts
            SAL_RET LIKE MARDH-LABST, " Net Receipts - Sales Return
            TDISP LIKE MARDH-LABST, " total dispatches
            CUSTMR LIKE MARDH-LABST, " Net Dispatches - Customers
            OPLANT LIKE MARDH-LABST, " Net Dispatches - To Other Plant
            TRFSTK LIKE MARDH-LABST, "Material Transfer stock
            TRLOSS LIKE MARDH-LABST, " Transit Loss
            WHLOSS LIKE MARDH-LABST, " Warehouse Loss
            TLOSS LIKE MARDH-LABST, " Total Loss
            C_STK LIKE MARDH-LABST, " Closing Stock
            OTHADJ LIKE MARDH-LABST,
          END OF I_FINAL_TEMP.
    For Materials
    DATA: BEGIN OF I_MARA OCCURS 0,
           MATNR TYPE MARA-MATNR,
           MTART TYPE MARA-MTART,
           MEINS LIKE MARA-MEINS,
           LABST TYPE MARD-LABST,
           MAKTX LIKE MAKT-MAKTX,
          END OF I_MARA.
    DATA: BEGIN OF I_STKMVMNTS OCCURS 0,
           BWART LIKE MSEG-BWART,
           SHKZG LIKE MSEG-SHKZG,
           VZBEW LIKE YW2_STKMOVEMENTS-VZBEW,
          END OF I_STKMVMNTS.
    DATA: BEGIN OF I_FINALT OCCURS 0,
           WERKS LIKE MSEG-WERKS, " Plant
           MATNR LIKE MSEG-MATNR, " Material
           BUDAT LIKE MKPF-BUDAT, " Posting Date
           MTART LIKE MARA-MTART, " Material Type
           SPMON LIKE S031-SPMON, " Month
           MAKTX LIKE MAKT-MAKTX, " Description
    meins(3), " UOM
           MEINS LIKE MSEG-MEINS,
           O_STK LIKE MARDH-LABST, " opening stock
           TRECEP LIKE MARDH-LABST, " total receipts
           PRODU LIKE MARDH-LABST, " Net Receipts - Production
           RECEP LIKE MARDH-LABST, " Net Receipts - Receipts
           SAL_RET LIKE MARDH-LABST, " Net Receipts - Sales Return
           TDISP LIKE MARDH-LABST, " total dispatches
           CUSTMR LIKE MARDH-LABST, " Net Dispatches - Customers
           OPLANT LIKE MARDH-LABST, " Net Dispatches - To Other Plant
           TRFSTK LIKE MARDH-LABST, "Material Transfer stock
           TRLOSS LIKE MARDH-LABST, " Transit Loss
           WHLOSS LIKE MARDH-LABST, " Warehouse Loss
           TLOSS LIKE MARDH-LABST, " Total Loss
           C_STK LIKE MARDH-LABST, " Closing Stock
           OTHADJ LIKE MARDH-LABST,
           MONTH(8) ,
          END OF I_FINALT.
    DATA: IMKPFT LIKE I_MKPF OCCURS 0 WITH HEADER LINE.
    DATA: IMKPFT1 LIKE I_MKPF1 OCCURS 0 WITH HEADER LINE.
    DATA: IMARDT LIKE I_MARD OCCURS 0 WITH HEADER LINE.
    DATA: IMARDHT LIKE I_MARDH OCCURS 0 WITH HEADER LINE.
    DATA: T_FINAL LIKE I_MKPF OCCURS 0 WITH HEADER LINE.
    DATA: IMKPFT2 LIKE I_MKPF OCCURS 0 WITH HEADER LINE.
    FCAT is used for the field catalog
    DATA: FCAT TYPE TABLE OF SLIS_FIELDCAT_ALV WITH NON-UNIQUE DEFAULT KEY
                      WITH HEADER LINE INITIAL SIZE 0,
    for excluding the ICONs from the application toolbar
          FEXC TYPE TABLE OF SLIS_EXTAB WITH NON-UNIQUE DEFAULT KEY
                     WITH HEADER LINE INITIAL SIZE 0,
    FS_LAYO is used for Grid Layout
          FS_LAYO TYPE SLIS_LAYOUT_ALV,
    FEVENTS to handle the events TOP OF PAGE & USER_COMMAND
          FEVENTS TYPE TABLE OF SLIS_ALV_EVENT WITH NON-UNIQUE DEFAULT KEY
                     WITH HEADER LINE INITIAL SIZE 0,
    FHEADER is used for List header
          FHEADER TYPE TABLE OF SLIS_LISTHEADER WITH NON-UNIQUE DEFAULT KEY
                     WITH HEADER LINE INITIAL SIZE 0,
    sort is used for sorting
          FSORT TYPE TABLE OF SLIS_SORTINFO_ALV WITH NON-UNIQUE DEFAULT KEY
                     WITH HEADER LINE INITIAL SIZE 0,
          FCAT1 TYPE TABLE OF SLIS_FIELDCAT_ALV WITH NON-UNIQUE DEFAULT KEY
                    WITH HEADER LINE INITIAL SIZE 0,
          FS_LAYO1 TYPE SLIS_LAYOUT_ALV,
          GT_LIST_TOP_OF_PAGE1 TYPE SLIS_T_LISTHEADER,
          FEVENTS1 TYPE TABLE OF SLIS_ALV_EVENT WITH NON-UNIQUE DEFAULT KEY
                 WITH HEADER LINE INITIAL SIZE 0,
           FHEADER1 TYPE TABLE OF SLIS_LISTHEADER WITH NON-UNIQUE DEFAULT  
                  KEY WITH HEADER LINE INITIAL SIZE 0,
           G_STATU_071 TYPE SLIS_FORMNAME VALUE 'Z_PFSTATUS',
           ALV_VARIANT1 LIKE DISVARIANT.
    Variable Declaration *
    TYPES: TRFF_TYPE_DEC_6_5(6) TYPE P DECIMALS 5.
    DATA: FYEAR(4),
          MON(2),
          FYEAR1(4),
          MON1(2),
          OBAL LIKE MARD-LABST,
          CBAL LIKE MARD-LABST,
          INDEX TYPE I,
          COUNT,
          COUNT1 TYPE I,
          O_STK TYPE P DECIMALS 3,
          C_STK TYPE P DECIMALS 3,
          V_MJAHR LIKE MKPF-MJAHR,
          MONTHS TYPE TRFF_TYPE_DEC_6_5,
          MONTH TYPE I.
    Global variables for handling ALV functionality
    DATA: ALV_KEYINFO TYPE SLIS_KEYINFO_ALV,
          ALV_VARIANT LIKE DISVARIANT,
          ALV_LAYOUT TYPE SLIS_LAYOUT_ALV,
          ALV_REPID LIKE SY-REPID,
          ALV_PRINT TYPE SLIS_PRINT_ALV,
          ALV_DETAIL_FUNC(30),
          ALV_DEFAULT_VARIANT LIKE DISVARIANT-VARIANT,
          ALV_COLOURIZE_FIELDS LIKE MMIM_REP_PRINT-COLOR.
    RANGES: R_BUDAT FOR MKPF-BUDAT.
    *Added by Prabhu for year on 26.4.05.
    DATA: IDATE LIKE R_BUDAT OCCURS 0 WITH HEADER LINE.
    Selection Screen Elements *
    SELECTION-SCREEN BEGIN OF BLOCK BLK WITH FRAME TITLE TEXT-001.
      SELECT-OPTIONS: S_WERKS FOR MARD-WERKS OBLIGATORY NO INTERVALS.
      PARAMETER: P_SPMON LIKE S031-SPMON NO-DISPLAY .
      SELECT-OPTIONS: S_MATNR FOR MARA-MATNR OBLIGATORY,
                      S_LGORT FOR MSEG-LGORT NO-EXTENSION NO INTERVALS,
                      S_MBLNR FOR MKPF-MBLNR,
                      S_BUDAT FOR MKPF-BUDAT OBLIGATORY .
    SELECTION-SCREEN END OF BLOCK BLK.
    SELECTION-SCREEN BEGIN OF BLOCK BLK3 WITH FRAME TITLE TEXT-004.
          PARAMETER : MTART LIKE MARA-MTART DEFAULT 'FERT' NO-DISPLAY.
    SELECTION-SCREEN END OF BLOCK BLK3.
    SELECTION-SCREEN BEGIN OF BLOCK BLK2 WITH FRAME TITLE TEXT-003.
    SELECTION-SCREEN END OF BLOCK BLK2.
    ADDED BY PRABHU FOR DAY-WISE REPORT.
    SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-007.
      PARAMETERS: D1 RADIOBUTTON GROUP P1 DEFAULT 'X',
                  M1 RADIOBUTTON GROUP P1,
                  Y1 RADIOBUTTON GROUP P1.
    SELECTION-SCREEN END OF BLOCK B3.
    SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-006.
    PARAMETERS: ALV_DEF LIKE DISVARIANT-VARIANT.
    SELECTION-SCREEN END OF BLOCK B2.
    DATA: S_BUDAT1 LIKE S_BUDAT OCCURS 0 WITH HEADER LINE."prabhu
    Initialization *
    INITIALIZATION.
      PERFORM ALV_INIT.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR ALV_DEF.
      PERFORM ALV_F4.
    At Selection Screen
    *AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_spmon.
    PERFORM monat_f4.
    At Selection Screen *
    AT SELECTION-SCREEN.
    checking for the layout
      PERFORM ALV_CHECK.
    authorisation check for the Plant
    PERFORM auth_check.
    Validation for the Plant
      PERFORM VALIDITY_CHECK.
      IF MTART NE 'FERT'.
        MESSAGE E041 WITH 'Material Type must be FERT Only...'.
      ENDIF.
      IF D1 = 'X'." On 26.4.05.
        P_SPMON0(4) = S_BUDAT-LOW0(4).
        P_SPMON4(2) = S_BUDAT-LOW4(2).
      ELSE.
        P_SPMON0(4) = S_BUDAT-LOW0(4).
        P_SPMON4(2) = S_BUDAT-LOW4(2).
      ENDIF.
      LOOP AT S_BUDAT.
        IF S_BUDAT-HIGH IS INITIAL.
          S_BUDAT-HIGH = S_BUDAT-LOW.
          MODIFY S_BUDAT.
        ENDIF.
      ENDLOOP.
      IDATE-LOW = S_BUDAT-LOW.
      IDATE-HIGH = S_BUDAT-HIGH.
      CALL FUNCTION 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
        EXPORTING
           I_DATE_FROM = IDATE-LOW
           I_DATE_TO = IDATE-HIGH
       IMPORTING
    E_DAYS =
          E_MONTHS = MONTH
    E_YEARS =
      DATA: I(3) TYPE C.
      I = S_BUDAT-LOW+4(2).
      CLEAR: R_BUDAT.
      REFRESH: R_BUDAT.
    *added by Prabhu for Only for Oneday.on 18.5.5
      IF MONTH EQ '0'.
        MONTH = MONTH + 1.
      ENDIF.
    *added by Prabhu for Only for Oneday.on 18.5.5
      DO MONTH TIMES.
        R_BUDAT-LOW = S_BUDAT-LOW.
        APPEND R_BUDAT.
      ENDDO.
      I = 0.
      LOOP AT R_BUDAT.
        R_BUDAT-LOW4(2) = S_BUDAT-LOW4(2) + I.
        I = I + 1.
        R_BUDAT-LOW+6(2) = '01'.
        MODIFY R_BUDAT.
      ENDLOOP.
      LOOP AT R_BUDAT.
        CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'
           EXPORTING
             DAY_IN = R_BUDAT-LOW
           IMPORTING
             LAST_DAY_OF_MONTH = R_BUDAT-HIGH
          EXCEPTIONS
            DAY_IN_NO_DATE = 1
            OTHERS = 2
        MODIFY R_BUDAT.
      ENDLOOP.
      LOOP AT R_BUDAT.
        IF R_BUDAT-LOW4(2) = S_BUDAT-LOW4(2).
          R_BUDAT-LOW = S_BUDAT-LOW.
          MODIFY R_BUDAT.
        ENDIF.
        IF R_BUDAT-HIGH4(2) = S_BUDAT-HIGH4(2).
          R_BUDAT-HIGH = S_BUDAT-HIGH.
          MODIFY R_BUDAT.
        ENDIF.
    For Summary on 26.4.05.
        IF Y1 = 'X'.
          CLEAR R_BUDAT.
          REFRESH R_BUDAT.
          R_BUDAT-LOW = S_BUDAT-LOW.
          R_BUDAT-HIGH = S_BUDAT-HIGH.
          APPEND R_BUDAT.
          CLEAR R_BUDAT.
        ENDIF.
      ENDLOOP.
    At Selection Screen *
    AT SELECTION-SCREEN OUTPUT.
    Start of Selection *
    START-OF-SELECTION.
      V_MJAHR = P_SPMON+0(4).
    Get plant distinction warehouse/production
      PERFORM GET_PLANT_DISTINCTION.
    Collect the data from various tables
      PERFORM GETDATA_FG_STOCK.
    here the number of rows in the output table is found
      PERFORM OUTPUT_TABLE_CHECK.
    here the top of the page code is written, that is to be displayed
    in the output
      PERFORM Z_TOP_OF_PAGE.
    here ALV layout properties are set
      PERFORM Z_LAYOUT_SETTINGS.
    ALV EVENTS for TOP OF PAGE and for USER COMMAND
      PERFORM Z_ALV_EVENTS.
    The field catalog is defined for the Primary List is defined in
    the subroutine CREATE_FIELD_CATALOG include program ZPRRDOCR_FCAT
      PERFORM Z_CREATE_FIELD_CATALOG.
    This is for displaying the output
      PERFORM Z_REUSE_ALV_GRID_DISPLAY.
    *& Form getdata_fg_stock
    Getting data from standard tables
    FORM GETDATA_FG_STOCK.
    For getting the Start date & end date of the month
    PERFORM get_month_dates.
    Getting the Opening Stock from MARDH table
      IF MON EQ '01'.
        MON1 = MON.
        FYEAR1 = FYEAR.
        MON = '12'.
        FYEAR = FYEAR - 1.
      ELSE.
        MON1 = MON.
        FYEAR1 = FYEAR.
        MON = MON - 1.
        FYEAR = FYEAR.
      ENDIF.
      PERFORM GET_RECORDS_FROM_DB.
    *added for Month Summary on 26.4.05.
      LOOP AT R_BUDAT.
        S_BUDAT-LOW = R_BUDAT-LOW.
        S_BUDAT-HIGH = R_BUDAT-HIGH.
    *for Month
        P_SPMON0(4) = S_BUDAT-LOW0(4).
        P_SPMON4(2) = S_BUDAT-LOW4(2).
    *for summary.
        IF Y1 = 'X'.
          LOOP AT S_BUDAT.
            S_BUDAT1-SIGN = 'I'.
            S_BUDAT1-OPTION = 'NB'.
            S_BUDAT1-LOW = S_BUDAT-LOW.
            S_BUDAT1-HIGH = S_BUDAT-HIGH.
            APPEND S_BUDAT1.
            CLEAR S_BUDAT1.
          ENDLOOP.
        ENDIF.
        IMKPFT[] = I_MKPF[].
        IMKPFT2[] = I_MKPF[].
        IMARDT[] = I_MARD[].
        IMARDHT[] = I_MARDH[].
        PERFORM MONTH_WISE.
        PERFORM PROCESS_MOVEMENTS.
        PERFORM CALCULATE_OPENING_STOCK.
        PERFORM UPDATE_NON_TRANSACTION_ITMS.
        PERFORM DELETE_EMPTY_RECORDS.
        CLEAR: IMARDHT,IMARDT,IMKPFT1,IMKPFT,I_FINAL,I_FINAL5.
        REFRESH: IMARDHT,IMARDT,IMKPFT1,I_FINAL,I_FINAL5,IMKPFT.
      ENDLOOP.
      CLEAR: R_BUDAT.
      REFRESH: R_BUDAT.
    *end of changes for month.
    ENDFORM. " getdata_fg_stock
    FORM MONAT_F4 *
    F4-Hilfe für Monat *
    FORM MONAT_F4.
      DATA: BEGIN OF MF_DYNPFIELDS OCCURS 1.
              INCLUDE STRUCTURE DYNPREAD.
      DATA: END OF MF_DYNPFIELDS.
      DATA: MF_RETURNCODE LIKE SY-SUBRC,
             MF_MONAT LIKE ISELLIST-MONTH,
             MF_HLP_REPID LIKE SY-REPID.
      FIELD-SYMBOLS: .
    Wert von Dynpro lesen
      GET CURSOR FIELD MF_DYNPFIELDS-FIELDNAME.
      APPEND MF_DYNPFIELDS.
      MF_HLP_REPID = SY-REPID.
      DO 2 TIMES.
        CALL FUNCTION 'DYNP_VALUES_READ'
          EXPORTING
            DYNAME               = MF_HLP_REPID
            DYNUMB               = SY-DYNNR
          TABLES
            DYNPFIELDS           = MF_DYNPFIELDS
          EXCEPTIONS
            INVALID_ABAPWORKAREA = 01
            INVALID_DYNPROFIELD  = 02
            INVALID_DYNPRONAME   = 03
            INVALID_DYNPRONUMMER = 04
            INVALID_REQUEST      = 05
            NO_FIELDDESCRIPTION  = 06
            UNDEFIND_ERROR       = 07.
        IF SY-SUBRC = 3.
    Aktuelles Dynpro ist Wertemengenbild
          MF_HLP_REPID = 'SAPLALDB'.
        ELSE.
          READ TABLE MF_DYNPFIELDS INDEX 1.
    Unterstriche durch Blanks ersetzen
          TRANSLATE MF_DYNPFIELDS-FIELDVALUE USING '_ '.
          EXIT.
        ENDIF.
      ENDDO.
      IF SY-SUBRC = 0.
    Konvertierung ins interne Format
        CALL FUNCTION 'CONVERSION_EXIT_PERI_INPUT'
          EXPORTING
            INPUT         = MF_DYNPFIELDS-FIELDVALUE
          IMPORTING
            OUTPUT        = MF_MONAT
          EXCEPTIONS
            ERROR_MESSAGE = 1.
        IF MF_MONAT IS INITIAL.
    Monat ist initial => Vorschlagswert aus akt. Datum ableiten
          MF_MONAT = SY-DATLO(6).
        ENDIF.
        CALL FUNCTION 'POPUP_TO_SELECT_MONTH'
          EXPORTING
            ACTUAL_MONTH               = MF_MONAT
          IMPORTING
            SELECTED_MONTH             = MF_MONAT
            RETURN_CODE                = MF_RETURNCODE
          EXCEPTIONS
            FACTORY_CALENDAR_NOT_FOUND = 01
            HOLIDAY_CALENDAR_NOT_FOUND = 02
            MONTH_NOT_FOUND            = 03.
        IF SY-SUBRC = 0 AND MF_RETURNCODE = 0.
    ASSIGN (MF_DYNPFIELDS-FIELDNAME) TO <MF_FELD>. " ==>> note 148804
    <MF_FELD> = MF_MONAT.
          CALL FUNCTION 'CONVERSION_EXIT_PERI_OUTPUT'
            EXPORTING
              INPUT  = MF_MONAT
            IMPORTING
              OUTPUT = MF_DYNPFIELDS-FIELDVALUE.
          COLLECT MF_DYNPFIELDS.
          CALL FUNCTION 'DYNP_VALUES_UPDATE'
            EXPORTING
              DYNAME               = MF_HLP_REPID
              DYNUMB               = SY-DYNNR
            TABLES
              DYNPFIELDS           = MF_DYNPFIELDS
            EXCEPTIONS
              INVALID_ABAPWORKAREA = 01
              INVALID_DYNPROFIELD  = 02
              INVALID_DYNPRONAME   = 03
              INVALID_DYNPRONUMMER = 04
              INVALID_REQUEST      = 05
              NO_FIELDDESCRIPTION  = 06
              UNDEFIND_ERROR       = 07. "<<== note 148804
        ENDIF.
      ENDIF.
    ENDFORM.                                                    "MONAT_F4
    *& Form get_month_dates
    Calculating the Month Start & End Date
    FORM GET_MONTH_DATES.
      IF M1 = 'X'.
        FYEAR = P_SPMON+0(4).
        MON = P_SPMON+4(2).
        CONCATENATE FYEAR MON '01' INTO R_BUDAT-LOW.
        R_BUDAT-SIGN = 'I'.
        R_BUDAT-OPTION = 'BT'.
        CALL FUNCTION 'BKK_GET_MONTH_LASTDAY'
          EXPORTING
            I_DATE = R_BUDAT-LOW
          IMPORTING
            E_DATE = R_BUDAT-HIGH.
        APPEND R_BUDAT.
        CLEAR S_BUDAT.
        REFRESH S_BUDAT.
        S_BUDAT-SIGN = 'I'.
        S_BUDAT-OPTION = 'BT'.
        S_BUDAT-LOW = R_BUDAT-LOW.
        S_BUDAT-HIGH = R_BUDAT-HIGH.
        APPEND S_BUDAT.
      ELSE.
        FYEAR = P_SPMON+0(4).
        MON = P_SPMON+4(2).
        CONCATENATE FYEAR MON '01' INTO R_BUDAT-LOW.
        R_BUDAT-SIGN = 'I'.
        R_BUDAT-OPTION = 'BT'.
        CALL FUNCTION 'BKK_GET_MONTH_LASTDAY'
          EXPORTING
            I_DATE = R_BUDAT-LOW
          IMPORTING
            E_DATE = R_BUDAT-HIGH.
        APPEND R_BUDAT.
      ENDIF.
    ENDFORM. " get_month_dates
    *& Form output_table_Check
    checking for records for output
    FORM OUTPUT_TABLE_CHECK .
      DESCRIBE TABLE I_FINALT LINES INDEX.
      IF INDEX EQ 0.
        MESSAGE I041 WITH TEXT-005.
        LEAVE LIST-PROCESSING.
      ENDIF.
    ENDFORM. "OUTPUT_TABLE_CHECK
    *& Form Z_TOP_OF_PAGE
    for setting the details in the top of page *
    has no formal paramters *
    FORM Z_TOP_OF_PAGE.
      DATA: V_MON(2),
      V_YR(40),
      V_FIN(18),
      V_FIN1(48),
      LOW(10),
      HIGH(10).
      V_MON = P_SPMON+4(2).
      V_YR = P_SPMON+0(4).
      FHEADER-TYP = 'H'.
      FHEADER-INFO = 'Stock Register Report (FG Stock)'.
      APPEND FHEADER.
      CLEAR FHEADER.
    *if m1 = 'X'.
    CONCATENATE 'Month = ' v_mon '.' v_yr INTO v_fin.
    fheader-typ = 'H'.
    fheader-info = v_fin.
    APPEND fheader.
    CLEAR fheader.
    *endif."prabhu on 18.5.5
      IF D1 = 'X'.
        CLEAR S_BUDAT.
        LOOP AT S_BUDAT.
          CONCATENATE S_BUDAT-LOW6(2) '/' S_BUDAT-LOW4(2) '/'
          S_BUDAT-LOW+0(4) INTO LOW.
          CONCATENATE S_BUDAT-HIGH6(2) '/' S_BUDAT-HIGH4(2) '/'
          S_BUDAT-HIGH+0(4) INTO HIGH.
          CONCATENATE 'Date = ' LOW ' - ' HIGH INTO V_FIN1.
          FHEADER-TYP = 'H'.
          FHEADER-INFO = V_FIN1.
          APPEND FHEADER.
          CLEAR FHEADER.
        ENDLOOP.
      ENDIF.
    ENDFORM. " Z_TOP_OF_PAGE
    *& Form Z_LAYOUT_SETTINGS
    this is done for setting the properties for the layout of the *
    grid *
    has no formal paramters *
    FORM Z_LAYOUT_SETTINGS.
      FS_LAYO-ZEBRA = 'X'. " Output in Zebra pattern
      FS_LAYO-DETAIL_POPUP = 'X'. " A popup window appears to give
      FS_LAYO-DETAIL_TITLEBAR = TEXT-022.
      FS_LAYO-COLWIDTH_OPTIMIZE = 'X'.
    ENDFORM. " Z_LAYOUT_SETTINGS
    *& Form Z_ALV_EVENTS
    This is used for handling the events TOP OF PAGE and the USER *
    COMMAND event *
    has no formal paramters *
    FORM Z_ALV_EVENTS.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          I_LIST_TYPE = 0
        IMPORTING
          ET_EVENTS   = FEVENTS[].
      READ TABLE FEVENTS WITH KEY NAME = 'TOP_OF_PAGE'.
      IF SY-SUBRC = 0.
        FEVENTS-FORM = 'Z_TOPOFPAGE'.
        MODIFY FEVENTS INDEX SY-TABIX.
        CLEAR FEVENTS.
      ENDIF.
      READ TABLE FEVENTS WITH KEY NAME = 'USER_COMMAND'.
      IF SY-SUBRC = 0.
        FEVENTS-FORM = 'Z_USER_COMMAND'.
        MODIFY FEVENTS INDEX SY-TABIX.
        CLEAR FEVENTS.
      ENDIF.
    ENDFORM. "Z_ALV_EVENTS
    *& Form Z_CREATE_FIELD_CATALOG
    here the field catalog is created for the primary list *
    no formal parameters *
    FORM Z_CREATE_FIELD_CATALOG.
    for the Plant
      FCAT-FIELDNAME = 'WERKS'.
      FCAT-KEY = 'X'.
      FCAT-OUTPUTLEN = '000005'.
      FCAT-JUST = 'L'.
      FCAT-SELTEXT_M = 'Plant'.
      FCAT-DDICTXT = 'M'.
      FCAT-INTTYPE = 'C'.
      FCAT-DATATYPE = 'CHAR'.
      APPEND FCAT.
      CLEAR FCAT.
    for the Material Type
      FCAT-FIELDNAME = 'MTART'.
      FCAT-KEY = 'X'.
      FCAT-OUTPUTLEN = '000006'.
      FCAT-JUST = 'L'.
      FCAT-SELTEXT_M = 'MatTyp'.
      FCAT-DDICTXT = 'M'.
      FCAT-INTTYPE = 'C'.
      FCAT-DATATYPE = 'CHAR'.
      APPEND FCAT.
      CLEAR FCAT.
    for the Material No.
      FCAT-FIELDNAME = 'MATNR'.
      FCAT-KEY = 'X'.
    fcat-hotspot = 'X'.
      FCAT-OUTPUTLEN = '000018'.
      FCAT-JUST = 'L'.
      FCAT-SELTEXT_M = 'Material'.
      FCAT-DDICTXT = 'M'.
      FCAT-INTTYPE = 'C'.
      FCAT-DATATYPE = 'CHAR'.
      APPEND FCAT.
      CLEAR FCAT.
    for the Material Description
      FCAT-FIELDNAME = 'MAKTX'.
      FCAT-KEY = ''.
      FCAT-OUTPUTLEN = '000040'.
      FCAT-JUST = 'L'.
      FCAT-SELTEXT_M = 'Description'.
      FCAT-DDICTXT = 'M'.
      FCAT-INTTYPE = 'C'.
      FCAT-DATATYPE = 'CHAR'.
      APPEND FCAT.
      CLEAR FCAT.
    for the Unit of Measure
      FCAT-FIELDNAME = 'MEINS'.
      FCAT-KEY = ''.
      FCAT-OUTPUTLEN = '03'.
      FCAT-JUST = 'C'.
      FCAT-SELTEXT_M = 'UOM'.
      FCAT-DDICTXT = 'M'.
      FCAT-INTTYPE = 'C'.
      FCAT-DATATYPE = 'UNIT'.
      APPEND FCAT.
      CLEAR FCAT.
    for the Plant
      FCAT-FIELDNAME = 'MONTH'.
      FCAT-KEY = 'X'.
      FCAT-OUTPUTLEN = '08'.
      FCAT-JUST = 'L'.
      FCAT-SELTEXT_M = 'MONTH'.
      FCAT-DDICTXT = 'M'.
      FCAT-INTTYPE = 'C'.
      FCAT-DATATYPE = 'CHAR'.
      APPEND FCAT.
      CLEAR FCAT.
    for the Opening Stock
      FCAT-FIELDNAME = 'C_STK'.
      FCAT-HOTSPOT = ' '.
      FCAT-OUTPUTLEN = '000016'.
      FCAT-JUST = 'L'.
      FCAT-SELTEXT_M = 'Opening Stock'.
      FCAT-DDICTXT = 'M'.
      FCAT-INTTYPE = 'Q'.
      FCAT-DATATYPE = 'QUAN'.
    fcat-do_sum = 'X'.
      FCAT-JUST = 'R'.
      FCAT-NO_ZERO = 'X'.
      APPEND FCAT.
      CLEAR FCAT.
    for the Total Receipts
      FCAT-FIELDNAME = 'TRECEP'.
      FCAT-HOTSPOT = ' '.
      FCAT-OUTPUTLEN = '000016'.
      FCAT-JUST = 'L'.
      FCAT-SELTEXT_M = 'Total Receipts'.
      FCAT-DDICTXT = 'M'.
      FCAT-INTTYPE = 'Q'.
      FCAT-DATATYPE = 'QUAN'.
      FCAT-DO_SUM = 'X'.
      FCAT-JUST = 'R'.
      FCAT-NO_ZERO = 'X'.
      APPEND FCAT.
      CLEAR FCAT.
    for the Production
      FCAT-FIELDNAME = 'PRODU'.
      FCAT-HOTSPOT = ' '.
      FCAT-OUTPUTLEN = '000016'.
      FCAT-JUST = 'L'.
      FCAT-SELTEXT_M = 'Production'.
      FCAT-DDICTXT = 'M'.
      FCAT-INTTYPE = 'Q'.
      FCAT-DATATYPE = 'QUAN'.
      FCAT-DO_SUM = 'X'.
      FCAT-JUST = 'R'.
      FCAT-NO_ZERO = 'X'.
      APPEND FCAT.
      CLEAR FCAT.
    for the Other Plant Receipts
      FCAT-FIELDNAME = 'RECEP'.
      FCAT-HOTSPOT = ' '.
      FCAT-OUTPUTLEN = '000016'.
      FCAT-JUST = 'L'.
      FCAT-SELTEXT_M = 'Othr Plnt Recpts'.
      FCAT-DDICTXT = 'M'.
      FCAT-INTTYPE = 'Q'.
      FCAT-DATATYPE = 'QUAN'.
      FCAT-DO_SUM = 'X'.
      FCAT-JUST = 'R'.
      FCAT-NO_ZERO = 'X'.
      APPEND FCAT.
      CLEAR FCAT.
    Sales Return
      FCAT-FIELDNAME = 'SAL_RET'.
      FCAT-HOTSPOT = ' '.
      FCAT-OUTPUTLEN = '000016'.
      FCAT-JUST = 'L'.
      FCAT-SELTEXT_M = 'Sales Return'.
      FCAT-DDICTXT = 'M'.
      FCAT-INTTYPE = 'Q'.
      FCAT-DATATYPE = 'QUAN'.
      FCAT-DO_SUM = 'X'.
      FCAT-JUST = 'R'.
      FCAT-NO_ZERO = 'X'.
      APPEND FCAT.
      CLEAR FCAT.
    Total Dispatches
      FCAT-FIELDNAME = 'TDISP'.
      FCAT-HOTSPOT = ' '.
      FCAT-OUTPUTLEN = '000016'.
      FCAT-JUST = 'L'.
      FCAT-SELTEXT_M = 'Total Dispatches'.
      FCAT-DDICTXT = 'M'.
      FCAT-INTTYPE = 'Q'.
      FCAT-DATATYPE = 'QUAN'.
      FCAT-DO_SUM = 'X'.
      FCAT-JUST = 'R'.
      FCAT-NO_ZERO = 'X'.
      APPEND FCAT.
      CLEAR FCAT.

  • Problem when summery the data type of interval day to second

    hi
    i write a program calculate periods of time and summary it then i used interval day to second data type
    oracle support basic 4 math operation (+,-,*,/) on interval
    but although oracle does not support summary function like sum() ,avg(),count()!! this is a problem here
    the walkaround it by use oracle data cartdrage advanced future like follows steps :
    *1- i create type and i call it for ex: DAY_TO_SECOND_SUM_TYPE*
    CREATE OR REPLACE  DAY_TO_SECOND_SUM_TYPE    /*TYPE                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        as object
    +(TOTAL INTERVAL day to SECOND , /* type header*/+
    STATIC FUNCTION ODCIAggregateInitialize(SCTX IN OUT DAY_TO_SECOND_SUM_TYPE) return number,
    member function ODCIAggregateIterate( self in out DAY_TO_SECOND_SUM_TYPE,value in interval  day to second) return number,
    member function ODCIAggregateTerminate(self in DAY_TO_SECOND_SUM_TYPE,returnvalue out interval day to second , flags in number) return number,
    member function ODCIAggregateMerge(self in out DAY_TO_SECOND_SUM_TYPE,ctx2 in DAY_TO_SECOND_SUM_TYPE) return number
    +)+
    +/+
    CREATE OR REPLACE TYPE "DAY_TO_SECOND_SUM_TYPE"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            as object
    +(TOTAL INTERVAL day to SECOND ,+
    STATIC FUNCTION ODCIAggregateInitialize(SCTX IN OUT DAY_TO_SECOND_SUM_TYPE) return number,
    member function ODCIAggregateIterate( self in out DAY_TO_SECOND_SUM_TYPE,value in interval  day to second) return number,
    member function ODCIAggregateTerminate(self in DAY_TO_SECOND_SUM_TYPE,returnvalue out interval day to second , flags in number) return number,
    member function ODCIAggregateMerge(self in out DAY_TO_SECOND_SUM_TYPE,ctx2 in DAY_TO_SECOND_SUM_TYPE) return number
    +)+
    create or replace type body DAY_TO_SECOND_SUM_TYPE as /* type body*/
    static function ODCIAggregateInitialize(sctx in out DAY_TO_SECOND_SUM_TYPE) return number is
    begin
    sctx := DAY_TO_SECOND_SUM_TYPE(numtodsinterval(0,'second'));
    return odciconst.Success;
    end;
    member function ODCIAggregateIterate( self in out DAY_TO_SECOND_SUM_TYPE,value in interval  day to second) return number is
    begin
    self.total := self.total value;+
    return odciconst.Success;
    end ;
    member function ODCIAggregateTerminate(self in DAY_TO_SECOND_SUM_TYPE,returnvalue out interval day to second , flags in number) return number is
    begin
    returnvalue := self.total;
    return odciconst.Success;
    end;
    member function ODCIAggregateMerge(self in out DAY_TO_SECOND_SUM_TYPE,ctx2 in DAY_TO_SECOND_SUM_TYPE) return number is
    begin
    self.total := self.total ctx2.total;+
    return odciconst.Success;
    end;
    end;
    +/+
    *2- i create artificial function to summary using that type let as called for ex: ds_sum as follows :*
    create or replace function ds_sum( input interval day to second   ) return interval day to second
    parallel_enable aggregate
    using DAY_TO_SECOND_SUM_TYPE
    +/+
    at last i used the function to summary intervals and its work so good but when the result of calculated summary value exceed the default precision of interval : INTERVAL DAY(2) TO SECOND(6)
    i get an error :
    ORA-01873 the leading precision of the interval is too small
    Cause: The leading precision of the interval is too small to store the specified
    interval .
    Action: Increase the leading precision of the interval or specify an interval with
    a smaller leading precision
    although i can determine the precision of interval the declaration of the new type to maximum like :
    +...........+
    CREATE OR REPLACE TYPE "DAY_TO_SECOND_SUM_TYPE"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            as object
    +(TOTAL INTERVAL day(9) to SECOND(6) ...........+
    +.......................+
    but the problem remain (in fact the error move from one functions of type to another function )
    due i can't determine the precision of data type when i define function in PL/SQL it is illegal*
    HOW CAN I SOLVE THIS PROBLEM AND BE ABLE TO SUMMARY INTERVAL DATA TYPE WHAT EVER THE RESULT OF SUMMARY IS HUGE
    Edited by: user1193723 on Jun 18, 2009 4:35 AM
    Edited by: user1193723 on Jun 18, 2009 4:36 AM
    Edited by: user1193723 on Jun 18, 2009 4:37 AM
    Edited by: user1193723 on Jun 18, 2009 4:38 AM
    Edited by: user1193723 on Jun 18, 2009 4:38 AM
    Edited by: user1193723 on Jun 18, 2009 4:40 AM

    hi,
    Instead of 'interval day to second' in method declaration use internal datatype 'DSINTERVAL_UNCONSTRAINED'.
    There are more unconstrained types in oracle.
    Bartek

Maybe you are looking for

  • CUBE Not getting All records from DSO

    Hi Experts , We have a situation where we have to load data from a DSO to a Cube . The DSO contains only 9 records and while we r loading the data into cube , the cube is only getting 2 records . Thus 7 records are missing. Also The Cube contains mor

  • I have the exact same issue

    I am having the exact same issue.  Only difference is I am using 2 RV180's.  Same firmware version and same symptoms.  My setup crashes every 2-3.5 days and I can NEVER get it to re-establish using the GUI, I always have to re-boot one side or the ot

  • Join query to get the constraint type ,column type and table name

    Hi ,This is my query select table_name  , column_name  from user_cons_columns where table_name='EMP_CLASS' table_name     column_name emp_class        empno emp_class        deptno select constraint_type,table_name  from user_constraints where table_

  • How can u  triger IDOCS wen ever vendor no. changes in XK02 Using BADI's

    Hi all            When ever i change the vendor no.. in XK02,the idoc have to  be triggrer using BADI in ECC6.0 version.Pls Any one help me how to create BADI AND IDOC IN ECC6.0.I am  new to both IDOCS and BADI. Given badi name was -- VENDOR_ADD_DATA

  • Kernel Error on Boot, wont Start up

    So i was updating the new updates for my macbook (Has Tiger, not leopard) and after the updates it restarted. Upon booting, it loaded the apple logo and that little spinner then it just went into the kernel panic mode. I tried inserting the Mac OS X