Clear Custom Control Area

Hi Experts,
I am using custom-control to embed an excel file in SAP. The problem is that when I m trying to open another excel file the one opened before still exists. I have debugged the program and found that the code is opening the new excel file but it is hidden behind the one opened before that file. I am using interface I_OI_DOCUMENT_PROXY and method 'OPEN_DOCUMENT' to embed the the excel file. I tried 'CLOSE_DOCUMENT', 'CLEAR_DOCUMENT' & 'CLEAR_SELECTION' methods but of no use.
Below is the code I am using to embed an excel file into SAP. Hope this will help to understand the problem.
******Begin of Code**********************************
  IF NOT firsttime IS INITIAL.
    CLEAR firsttime.
    CLEAR: is_gui_container,
           l_document_url.
    lv_cnt = lv_cnt + 1.
    CALL METHOD c_oi_ole_control_creator=>get_ole_container_control
      IMPORTING
        control = g_control
        retcode = g_retcode.
    CALL METHOD c_oi_errors=>show_message
      EXPORTING
        type = 'E'.
    CREATE OBJECT g_container
      EXPORTING
         container_name = 'CONT1'
      EXCEPTIONS
         cntl_error                  = 1
         cntl_system_error           = 2
         create_error                = 3
         lifetime_error              = 4
         lifetime_dynpro_dynpro_link = 5.
    is_gui_container-application_name = 'Our test'.
    is_gui_container-container_name   = 'CONT1'.
    is_gui_container-rep_id           = sy-repid .
    is_gui_container-dynpro_nr        = '0100'.
    PERFORM pc_has_excel_or_excel2003.
    CALL METHOD g_control->destroy_control.
    CALL METHOD g_control->init_control
      EXPORTING
        r3_application_name      = is_gui_container-application_name
        inplace_enabled          = 'X'
        inplace_scroll_documents = 'X'
        parent                   = g_container
        register_on_close_event  = ' '
        register_on_custom_event = ' '
        rep_id                   = is_gui_container-rep_id
        dynpro_nr                = is_gui_container-dynpro_nr
      IMPORTING
        retcode                  = g_retcode.
    CALL METHOD c_oi_errors=>show_message
      EXPORTING
        type = 'E'.
    CALL METHOD g_control->get_table_collection
      IMPORTING
        table_collection = g_table_coll
        retcode          = g_retcode.
    CALL METHOD g_control->get_document_proxy
      EXPORTING
        document_type  = soi_doctype_excel97_sheet
      IMPORTING
        document_proxy = g_document
        retcode        = g_retcode.
    CALL METHOD c_oi_errors=>show_message
      EXPORTING
        type = 'E'.
    CONCATENATE 'file://' p_file INTO l_document_url.
    CALL METHOD g_document->clear_selection
      EXPORTING
        no_flush = ' '
      IMPORTING
        retcode  = g_retcode.
    CALL METHOD g_document->open_document
      EXPORTING
        document_url = l_document_url
        open_inplace = 'X'
      IMPORTING
        retcode      = g_retcode.
  ENDIF.
******End of Code*************************************
Let me know if you want more details.

Hi Rajesh,
  Try to Rrefresh that custom control, I had a similar problem with table control then i used the below method to solve that problem.
set row & column to be stable after refresh
    CLEAR l_s_stable.
    l_s_stable-row = 'X'.
    l_s_stable-col = 'X'.
    CALL METHOD alvgrid->refresh_table_display
      EXPORTING
        is_stable      = l_s_stable
        i_soft_refresh = 'X'..
if you search you may find out any other similar methods for your requirements..
Reward with points if usefull..
Regards,
Srinivas.

Similar Messages

  • How to use the custom control ?

    Hi Friends,
    plz help to use of  custom control in screen painter ?
    and how to use the custom control ?
    Thanking you.
    Regards,
    Subash.

    HI,
    Screen Elements
    A screen can contain a wide variety of elements, either for displaying field contents, or for allowing the user to interact with the program (for example, filling out input fields or choosing pushbutton functions). You use the Screen Painter to arrange elements on the screen.
    You can use the following elements:
    ·        Text fields
    Display elements, which cannot be changed either by the user or by the ABAP program.
    ·        Input/output fields and templates
    Used to display data from the ABAP program or for entering data on the screen. Linked to screen fields.
    ·        Dropdown list boxes
    Special input/output fields that allow users to choose one entry from a fixed list of possible entries.
    ·        Checkbox elements
    Special input/output fields that the user can either select (value ‘X’) or deselect (value SPACE). Checkbox elements can be linked with function codes.
    ·        Radio button elements
    Special input/output fields that are combined into groups. Within a radio button group, only a single button can be selected at any one time. When the user selects one button, all of the others are automatically deselected. Radio button elements can be linked with function codes.
    ·        Pushbuttons
    Elements on the screen that trigger the PAI event of the screen flow logic when chosen by the user. There is a function code attached to each pushbutton, which is passed to the ABAP program when it is chosen.
    ·        Frame
    Pure display elements that group together elements on the screen, such as radio button groups.
    ·        Subscreens
    Area on the screen in which you can place another screen.
    ·        Table controls
    Tabular input/output fields.
    ·        Tabstrip controls
    Areas on the screen in which you can switch between various pages.
    ·        Custom Controls
    Areas on the screen in which you can display controls. Controls are software components of the presentation server.
    ·        Status icons
    Display elements, indicating the status of the application program.
    ·        OK field
    Every screen has a twenty-character OK_CODE field (also known as the function code field) that is not displayed directly on the screen. User actions that trigger the PAI event also place the corresponding function code into this field, from where it is passed to the ABAP program. You can also use the command field in the standard toolbar to enter the OK field. To be able to use the OK field, you need to assign a name to it.
    All screen elements have a set of attributes, some of which are set automatically, others of which have to be specified in the Screen Painter. They determine things such as the layout of the screen elements on the screen. You can set the attributes of screen elements in the Screen Painter - either for a single element, or using the element list, which lists all of the elements belonging to the current screen. Some of the attributes that you set statically in the Screen Painter can be overwritten dynamically in the ABAP program.
    with regards,
    sowjanyagosala

  • How to get the cursor field on custom cotrol area

    Hi all,
    I crated a custom contorol area on  Dynpro screen.
    I'd like to get the cursor when i set the cursor on custom control area.
    I tried 'GET CURSOR FIELD w_xxx AREA w_yyy', but I can't get that.
    I don't know how.
    If you know that, please let me know.
    Regards.
    Rie.

    You have to use set_focus method of CL_GUI_CUSTOM_CONTAINER.
      CALL METHOD me->txt_container->set_focus
        EXPORTING
          control = me->txt_editor.

  • Using custom control in Infopath 2013 to populate a Custom List in Sharepoint

    Is there any way to add custom controls, such as InkCapture, to sharepoint list forms? My specific application requires me to use a sharepoint Custom List so I developed a form in Infopath to serve as the data entry point. Unfortunately there is no option
    to add or use custom controls when editing my form in Infopath.
    When I create a Form Library all my custom controls are available to use.
    Any ideas?
    Much Appreciated!

    Hi,
    InfoPath is only a forms editing tool and does not provide for grid editing or other expected features like adding any custom control, you can design a template
    part to reuse in multiple form template here you can create your own custom control by using existing control in InfoPath and you have facility to write code to implement any business logic that’s called template part and you can add this template part in
    your any InfoPath form over and over. Here is the link for creating the custom template part in InfoPath.
    https://support.office.com/en-za/article/Design-a-template-part-to-reuse-in-multiple-form-templates-cfcb14e0-059b-4b0e-a200-3faa409f52f0
    Here is the list of features that you can use in List form, InfoPath form and using SharePoint designer you can choose as per your nee.
    http://go.limeleap.com/community/bid/300409/SharePoint-Forms-Comparison-Lists-vs-SP-Designer-vs-InfoPath
    Krishana Kumar http://www.mosstechnet-kk.com
    Please mark the replies and Proposed as answer if they help and solve your issue

  • Using a Meter control in LV Touch Panel, and using shared variables that are custom controls.

    I Just started using LV touch Panel module with an NI TPC-2106.
    I have two differenct problems:
    1) I was planning on using the "Meter" control quite a bit. I can set up the meter exactly how I like on the host PC, but on the touch Panel computer it seems to ignore my adjustments, mainly the start and end of the scale - i.e. I would like control to run from 0 to 360 with 0 straight up, using the entire circle. However, on the Touch panel computer it always puts 0 at about 7 o'clock and 360 at about 5 o'clock. I have also tried adding markers to no avail.
    2) I am communicating with a compact fieldpoint controller. I can creat a shared variable that is a simple double with no problems. However, I have some shared variables that use a custom control for the variable type - bascially a cluster with a couble doubles, a time stamp, and an enumeration. It lets me drag the shared variable into my diagram, but it seems to ignore it when I run it.

    Ipshita_C,
    - I am using LV 8.6.1f1and LV Touch Panel 8.6.1.
    - I have attached a simplified VI that shows how I want to use the meter. Notice that the placement of the endpoitns does not work correctly on the touch panel, and that it ignores the arbitrary markers that I placed.
    - I also have included an XY graph control that displays on the TPC with margins around the graph area that I removed from the graph control.
    - For the shared variable, it appears to be an issue related to the touch panel, not fieldpoint. I found another thread in this forum that mentioned that clusters containing Enumerations do not work in shared variables on the touch panel. I changed the enumeration to an integer and it now works fine.
    In general, there seem to be a disappointing number of limitations in the touch panel implementation. My biggest concern is that I have not found any documentation from NI that lists these limitations. I seem to have to try things out and see what works and what does not work. Can you point me to a comprehensive list of touch panel modules limitations?
    Attachments:
    test 2.vi ‏10 KB

  • Customer invoices are not getting cleared when lockbox file imported in sap

    Hello ,
      When the lockbox file is imported into SAP , it is not able to clear customer invoices. It creates SAP documents and payment advices but not able to apply the payments to customers accounts.
      Can anyone suggest on this with possible solutions.
    Regards,
    suresh

    Hi,
    You have to check the invoices are being match. The options are the following according to selection screen in FLB2:
    Document numbers (BELNR)
    Reference document numbers (XBLNR)
    Document number first, if not found: reference doc. number
    Reference document number first, if not found: doc. number
    Document number first, then reference and amount
    You have to check if the information which is coming in the file is the same present in the invocies in the ERP.
    Also check the settings in OBAX and OBAy.
    REgards,
    Renan Correa

  • Cretit control area field - Customer master - mass change

    Hi Gurus:
    I want to use the customer master mass change program (T.code XD99) to assign a default credit control area for all the customers. However when i try to save the mass changes it does not update the credit control area, and shows an information message "0000500004 : No batch input data for screen SAPMF02D 0900" . Did anybody come across such situation ? and how to resolve this ?
    Thanks in advance.

    Refer to note 552066, The system is attempting to maintain some ETM data that may not be relevant. May be this applies to you.
    Symptom
    During the start of the mass maintenance with Transaction XD99, the system generates batch input sessions for the import of the data in the background. In the process the system also tries to supply fields RF02D-D0900 and RF02D-D0910 on screen SAPMF02D 101 with data, although these fields do not exist on the screen. Then the batch input processing terminates.
    Solution
    The correction of the source code for the generation of the batch input data is described in the corresponding correction instruction. A solution that allows also the mass maintenance of ETM data with Transaction XD99 is in preparation.

  • Customer created in multiple credit control areas.

    Dear  friends,
    In our current system, whenever a business partner is created, the business partner is being created in all the credit control areas that are permitted for that company code, despithe business partner having only one credit control area assigned in the sales view of his business partner data.
    How can I control so that a business partner is only created against one of the allowable credit control areas?
    Henry

    Hi henry,
    You can mantain overall credit limit for customer created in all CCA's.
    Goto FD32, select CCA and central data, you can mainatin overall credit limit for all credit control areas (CCA) and current CCA credit limit.

  • FI-AR-CR Customer Sales per Credit Control Area

    Hi,
    Do you know any table or funtion that may calculate the Customer Sales Volume per Credit Control Area? I need to calculate a customer specfic DSO (Day Sales Outstanding) figure. The standard AR Summary doesn't return such information. This nay be obtained via BSEG, but it requires a complex query.
    I have found the function module CUSTOMER_BALANCE, but it returns customer sales per company code, which still requires additional calculation to totalize the balances for all the company codes that belong to a credit control area which the customer is assigned to.
    I appreciate any input that may provide a simplier solution for this question.
    Thanks and regards.
    Gonçalo

    Hi,
    I have decided to use the function module CUSTOMER_DSO_CALCULATION, and I will try get the sales volume from some internal variable that this FM uses to calculate the standard DSO. Then I'll store it on a  Z table in order to compute the new specific DSO
    Thanks and regards,
    Gonçalo

  • To determine the credit control areas for the customer

    Hi all,
    Two credit control areas will be maintained for a customer. During sales order entry, based on material group of the material specified, credit control area should be determined through user exit.
    May i have which user exit will help me, also i used USER_CREDIT_CHECK1. Its not working.
    Expecting reply

    You can not set the credit control at material level it is at company code level only and we can give credit limit to customer code wise
    If having any other requirment please let me know about it
    Points if helpfull
    Rg Ajit

  • To determine the Two credit control areas for the customer

    Hi all,
    Two credit control areas will be maintained for a customer. During sales order entry, based on material group of the material specified, credit control area should be determined through user exit.
    May i have which user exit will help me, also i used USER_CREDIT_CHECK1. Its not working.
    Expecting reply

    hi Ravi,
    USER_CREDIT_CHECK1 is not an exit, do you know what are you talking about?
    Eric Cartman

  • How to have custom control in DataGridView display object's value?

    I have a sample project located
    here
    The project has a main form `Form1` where the user can enter customers in a datagridview. The `CustomerType` column is a custom control and when the user clicks the button, a search form `Form2` pops up.
    The search form is populated with a list of type `CustomerType`. The user can select a record by double-clicking on the row, and this object should be set in the custom control. The `DataGridView` should then display the `Description` property but in the background
    each cell should hold the value (ie. the `CustomerType` instance).
    The relevant code is located in the following classes:
    The column class:
    public class DataGridViewCustomerTypeColumn : DataGridViewColumn
    public DataGridViewCustomerTypeColumn()
    : base(new CustomerTypeCell())
    public override DataGridViewCell CellTemplate
    get { return base.CellTemplate; }
    set
    if (value != null && !value.GetType().IsAssignableFrom(typeof(CustomerTypeCell)))
    throw new InvalidCastException("Should be CustomerTypeCell.");
    base.CellTemplate = value;
    The cell class:
    public class CustomerTypeCell : DataGridViewTextBoxCell
    public CustomerTypeCell()
    : base()
    public override void InitializeEditingControl(int rowIndex, object initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle)
    base.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle);
    CustomerTypeSearch ctl = DataGridView.EditingControl as CustomerTypeSearch;
    if (this.Value == null)
    ctl.Value = (CustomerType)this.DefaultNewRowValue;
    else
    ctl.Value = (CustomerType)this.Value;
    public override Type EditType
    get { return typeof(CustomerTypeSearch); }
    public override Type ValueType
    get { return typeof(CustomerType); }
    public override object DefaultNewRowValue
    get { return null; }
    And the custom control:
    public partial class CustomerTypeSearch : UserControl, IDataGridViewEditingControl
    private DataGridView dataGridView;
    private int rowIndex;
    private bool valueChanged = false;
    private CustomerType value;
    public CustomerTypeSearch()
    InitializeComponent();
    public CustomerType Value
    get { return this.value; }
    set
    this.value = value;
    if (value != null)
    textBoxSearch.Text = value.Description;
    else
    textBoxSearch.Clear();
    private void buttonSearch_Click(object sender, EventArgs e)
    Form2 f = new Form2();
    DialogResult dr = f.ShowDialog(this);
    if (dr == DialogResult.OK)
    Value = f.SelectedValue;
    #region IDataGridViewEditingControl implementation
    public object EditingControlFormattedValue
    get
    if (this.value != null)
    return this.value.Description;
    else
    return null;
    set
    if (this.value != null)
    this.value.Description = (string)value;
    public object GetEditingControlFormattedValue(DataGridViewDataErrorContexts context)
    return EditingControlFormattedValue;
    public void ApplyCellStyleToEditingControl(DataGridViewCellStyle dataGridViewCellStyle)
    this.BorderStyle = BorderStyle.None;
    this.Font = dataGridViewCellStyle.Font;
    public int EditingControlRowIndex
    get { return rowIndex; }
    set { rowIndex = value; }
    public bool EditingControlWantsInputKey(Keys key, bool dataGridViewWantsInputKey)
    return false;
    public void PrepareEditingControlForEdit(bool selectAll)
    //No preparation needs to be done
    public bool RepositionEditingControlOnValueChange
    get { return false; }
    public DataGridView EditingControlDataGridView
    get { return dataGridView; }
    set { dataGridView = value; }
    public bool EditingControlValueChanged
    get { return valueChanged; }
    set { valueChanged = value; }
    public Cursor EditingPanelCursor
    get { return base.Cursor; }
    #endregion
    private void CustomerTypeSearch_Resize(object sender, EventArgs e)
    buttonSearch.Left = this.Width - buttonSearch.Width;
    textBoxSearch.Width = buttonSearch.Left;
    However, the `DataGridView` is not displaying the text and it also is not keeping the `CustomerType` value for each cell.
    What am I missing?
    Marketplace: [url=http://tinyurl.com/75gc58b]Itza[/url] - Review: [url=http://tinyurl.com/ctdz422]Itza Update[/url]

    Hello,
    1. To display the text, we need to override the ToString method for CustomerType
    public class CustomerType
    public int Id { get; set; }
    public string Description { get; set; }
    public CustomerType(int id, string description)
    this.Id = id;
    this.Description = description;
    public override string ToString()
    return this.Description.ToString();
    2. To get the cell's value changed, we could pass the cell instance to that editing control and get its value changed with the following way.
    public partial class CustomerTypeSearch : UserControl, IDataGridViewEditingControl
    private DataGridView dataGridView;
    private int rowIndex;
    private bool valueChanged = false;
    private CustomerTypeCell currentCell = null;
    public CustomerTypeCell OwnerCell
    get { return currentCell; }
    set
    currentCell = null;
    currentCell = value;
    public CustomerTypeSearch()
    InitializeComponent();
    private void buttonSearch_Click(object sender, EventArgs e)
    Form2 f = new Form2();
    DialogResult dr = f.ShowDialog(this);
    if (dr == DialogResult.OK)
    currentCell.Value = f.SelectedValue;
    this.textBoxSearch.Text = f.SelectedValue.Description;
    #region IDataGridViewEditingControl implementation
    public object EditingControlFormattedValue
    get
    if (this.currentCell.Value != null)
    return (this.currentCell.Value as CustomerType).Description;
    else
    return null;
    set
    if (this.currentCell != null)
    (this.currentCell.Value as CustomerType).Description = (string)value;
    public object GetEditingControlFormattedValue(DataGridViewDataErrorContexts context)
    return EditingControlFormattedValue;
    public void ApplyCellStyleToEditingControl(DataGridViewCellStyle dataGridViewCellStyle)
    this.BorderStyle = BorderStyle.None;
    this.Font = dataGridViewCellStyle.Font;
    public int EditingControlRowIndex
    get { return rowIndex; }
    set { rowIndex = value; }
    public bool EditingControlWantsInputKey(Keys key, bool dataGridViewWantsInputKey)
    return false;
    public void PrepareEditingControlForEdit(bool selectAll)
    //No preparation needs to be done
    public bool RepositionEditingControlOnValueChange
    get { return false; }
    public DataGridView EditingControlDataGridView
    get { return dataGridView; }
    set { dataGridView = value; }
    public bool EditingControlValueChanged
    get { return valueChanged; }
    set { valueChanged = value; }
    public Cursor EditingPanelCursor
    get { return base.Cursor; }
    #endregion
    private void CustomerTypeSearch_Resize(object sender, EventArgs e)
    buttonSearch.Left = this.Width - buttonSearch.Width;
    textBoxSearch.Width = buttonSearch.Left;
    Cell:
    public class CustomerTypeCell : DataGridViewTextBoxCell
    public CustomerTypeCell()
    : base()
    public override void InitializeEditingControl(int rowIndex, object initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle)
    base.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle);
    CustomerTypeSearch ctl = DataGridView.EditingControl as CustomerTypeSearch;
    ctl.OwnerCell = this;
    public override Type EditType
    get { return typeof(CustomerTypeSearch); }
    public override Type ValueType
    get { return typeof(CustomerType); }
    public override object DefaultNewRowValue
    get { return null; }
    Result:
    Regards,
    Carl
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Charge off difference whening clearing customer open item with bank receipt

    Hi,
    Our company users will use F-32 to clear customer open item with bank receipt, sometimes, our invoice is 100 RMB issue to customer, the customer finally pay 99.98, then in F-32, we use charge off difference to post 0.02 difference to a account.
    The user then want to control this, saying for example, if the customer pay only 90, whening using charge off differnce, the system will pop up a error message.
    Can this be done in SAP, or we need to use user exit, then which user exit?
    Thanks.

    Dear,
    This is done through customer tolerance group using transaction OBA3. Here enter the maximum amount in Loss under the Permitted Payment Differences. you are able to hold tolerance for customer clearing.
    Is this what you wanted?
    Regards,
    Chintan Joshi.

  • I want to know how to clear the text area by the push off my next question button and ask a new ques

    I want to know how to clear the text area by the push off my next question button and ask a new question - also I want to know how to code in my project to where a user can enter a math question in one border container and the answer enters into the next container
    heres my code so far
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" backgroundColor="#1E5C75">
        <fx:Script>
            <![CDATA[
                protected function button1_clickHandler(event:MouseEvent):void
                    //convert text area into labelid to be identified by actionscript
                    richTextLabel.text = myArea.text;
            ]]>
        </fx:Script>
        <fx:Declarations>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
        </fx:Declarations>
        <!--container 1-->
        <s:BorderContainer borderWeight="7" x="28" y="10" width="200" height="138">
            <s:layout>
                <s:VerticalLayout paddingTop="10" paddingBottom="10"
                                  paddingLeft="10" paddingRight="10"/>
            </s:layout>
            <!--data Entry control-->
            <s:TextArea id="myArea" width="153" height="68"/>
            <!--end of data entry control-->
            <s:Button width="151" label="ask a question" click="button1_clickHandler(event)"/>
        </s:BorderContainer>
        <!--container2-->
        <s:BorderContainer borderWeight="7" x="509" y="10" width="200" height="138">
            <s:layout>
                <s:VerticalLayout paddingTop="10" paddingBottom="10"
                                  paddingLeft="10" paddingRight="10"/>
            </s:layout>
    <!--data entry control-->
            <!--convert tne data entry control into a label id in actionscript-->
            <s:Label id="richTextLabel" width="153" height="68"/>
            <s:Button width="151" label="next question" click="button1_clickHandler(event)"/>
        </s:BorderContainer>
        </s:Application>

    This is a user to user support forum.  We are all iphone users just like you.
    You are not addressing Apple here at all.
    This is an odd way to ask your fellow iphone users for help. Berating oterh users will not help you.
    "it's too fragile"
    No it is not.  i have never damaged one, nor has anyone I know.
    " U loose data when Ur phone is locked"
    No you don't.  Why do you think this?
    "and there is no customer support!!!  "
    Wrong yet again.  Apple has an 800 number and they have many retail stores and they have support articles that you can access using the search bar. Or you can contact them throgh express lane online
    "but I will go back with Blackberry "
    Please do.
    Good ridance

  • TOP of PAGE  using ABAP oo with single CUSTOM CONTROL

    Can anybody please tell me how to handle TOP_OF_PAGE using ABAP OBJECTS with a SINGLE CUSTOM CONTROL and not with  SPLIT CONTAINER(i.e. using single CL_GUI_CUSTOM_CONTAINER and single grid CL_GUI_ALV_GRID  ). Is it possible if so Please help me out?

    Hi Ravi,
    Here is my code. i didn't handle the top_of_page event yet but created a method to handle.
    REPORT  ZSATEESH_ALV_CONTAINER MESSAGE-ID ZZ
                      LINE-SIZE 150 NO STANDARD PAGE HEADING.
    PROGRAM id        :  ZSATEESH_ALV_CONTAINER                         *
    Title             : Sales document report                           *
    Author            : Sateesh                                         *
    Date              :                                                 *
    CR#               :                                                 *
    Dev Initiative    :
    Description       :ALV GRID/LIST Report which displays the sales
                          document header data using ABAP Objects.
                              Modification Log
    Corr. no        date       programmer        description
                    TYPES Declaration
    *--Type for the Header Sales data
    TYPES: BEGIN OF TY_VBAK ,
            INDICAT LIKE ICON-ID,               " Icon
            VBELN   LIKE VBAK-VBELN,            " Sales Document
            AUDAT   LIKE VBAK-AUDAT,            " Document date
            VBTYP   LIKE VBAK-VBTYP,            " SD document category
            AUART   LIKE VBAK-AUART,            " Sales Document Type
            AUGRU   LIKE VBAK-AUGRU,            " Order reason
            NETWR   LIKE VBAK-NETWR,            " Net Value
            WAERK   LIKE VBAK-WAERK,            " SD document currency
         END OF TY_VBAK.
                    DATA Declaration
    *--Tableto hold the header sales data
    DATA: TB_VBAK  TYPE  STANDARD TABLE OF TY_VBAK.
    *--Table to hold the Icons
    DATA: BEGIN OF TB_ICON OCCURS 0,
            ID   TYPE ICON-ID,                  " Icon
            NAME TYPE ICON-NAME,                " Name of an Icon
          END OF TB_ICON.
    *--Declaration of ALV Grid Tables
    DATA: TB_FDCAT         TYPE LVC_T_FCAT,     " Fieldcatalog
          TB_SORT          TYPE LVC_T_SORT.     " Sorting
    DATA: OK_CODE          LIKE SY-UCOMM.       " sy-ucomm
    *--Reference variables for container and grid control.
    DATA: CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
                                                " Container reference
          OBJ_ALV_GRID     TYPE REF TO CL_GUI_ALV_GRID.
    " Alv Grid reference
                      S T R U C T U R E S
    DATA: X_FDCAT          TYPE LVC_S_FCAT,     " Fieldcatalog
          X_LAYOUT         TYPE LVC_S_LAYO,     " layout
          X_SORT           TYPE LVC_S_SORT,     " Sorting
          X_VBAK           TYPE TY_VBAK,        " sales header stucture
          X_ICON           LIKE TB_ICON.        " icons structure
                      C O N S T A N T S
    *--Declaration of Constants
    CONSTANTS :
                C_GREEN(40)    TYPE  C VALUE 'ICON_GREEN_LIGHT',
                C_RED(40)      TYPE  C VALUE 'ICON_RED_LIGHT',
                C_YELLOW(40)   TYPE  C VALUE 'ICON_YELLOW_LIGHT',
                C_X            TYPE  C VALUE 'X'.      " Flag
                      SELECTION SCREEN
    *--Block 1.
    SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    PARAMETER: P_AUDAT LIKE VBAK-AUDAT
                       DEFAULT '20050101'(003).    " doc date.
    SELECTION-SCREEN: END OF BLOCK B1.
    *--bLOCK 2.
    SELECTION-SCREEN : BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.
    PARAMETER :P_ALVDIS AS CHECKBOX.              " For List/Grid
    SELECTION-SCREEN : END OF BLOCK B2.
          Class LC_VBAK  definition
    CLASS  LC_VBAK DEFINITION.
      PUBLIC SECTION.
        METHODS: VBAK_POPULATE,                 " sales header population
                 ICON_POPULATE,                 " Icons population
                 FINAL_POPULATE,                " Final ALV population
                 DISPLAY,                      " Displaying ALV
                 TOP_OF_PAGE FOR EVENT TOP_OF_PAGE OF CL_GUI_ALV_GRID
                                               IMPORTING E_DYNDOC_ID.
    ENDCLASS.                    "LC_VBAK DEFINITION
          Class LC_VBAK IMPLEMENTATION
    CLASS LC_VBAK IMPLEMENTATION.
      METHOD VBAK_POPULATE.
    *-- selecting from VBAK
        SELECT VBELN
                AUDAT
                VBTYP
                AUART
                AUGRU
                NETWR
                WAERK
                INTO   CORRESPONDING FIELDS OF TABLE TB_VBAK
                FROM VBAK
                WHERE AUDAT > P_AUDAT AND
                NETWR  > 0.
        IF SY-SUBRC <> 0.
          SORT TB_VBAK  BY AUART VBTYP WAERK .
        ENDIF.
      ENDMETHOD .                    "VBAK_POPULATE
      METHOD ICON_POPULATE.
    *--selecting from ICON table
        SELECT ID
               NAME
               INTO TABLE TB_ICON
               FROM ICON.
        IF SY-SUBRC = 0.
          SORT TB_ICON BY NAME .
        ENDIF.
      ENDMETHOD .                    "ICON_POPULATE
      METHOD FINAL_POPULATE.
    *--looping through VBAK table into the work area
        LOOP AT TB_VBAK INTO X_VBAK .
          IF X_VBAK-NETWR <= 10.
    *--Reading the ICON table into work area comparing field NAME
            READ TABLE TB_ICON INTO X_ICON WITH KEY NAME = C_GREEN
                                                     BINARY SEARCH.
            IF SY-SUBRC = 0.
              X_VBAK-INDICAT =  X_ICON-ID.
    *--modifying the TB_VBAK table
              MODIFY TB_VBAK FROM X_VBAK.
            ENDIF.
          ELSEIF X_VBAK-NETWR > 10 AND X_VBAK-NETWR < 100.
    *--Reading the ICON table into work area comparing field NAME
            READ TABLE TB_ICON INTO X_ICON WITH KEY NAME = C_YELLOW
                                                     BINARY SEARCH.
            IF SY-SUBRC = 0.
              X_VBAK-INDICAT =  X_ICON-ID.
    *--modifying the TB_VBAK table
              MODIFY TB_VBAK FROM X_VBAK.
            ENDIF.
          ELSEIF X_VBAK-NETWR >= 100.
    *--Reading the ICON table into work area comparing field NAME
            READ TABLE TB_ICON INTO X_ICON WITH KEY NAME = C_RED
                                                     BINARY SEARCH.
            IF SY-SUBRC = 0.
              X_VBAK-INDICAT =  X_ICON-ID.
    *--modifying the TB_VBAK table
              MODIFY TB_VBAK FROM X_VBAK.
            ENDIF.
          ENDIF.
        ENDLOOP.
      ENDMETHOD.                    "FINAL_POPULATE
          METHOD top_of_page                                            *
      METHOD TOP_OF_PAGE.
        PERFORM EVENT_TOP_OF_PAGE USING E_DYNDOC_ID.
      ENDMETHOD.                    "top_of_page
      METHOD DISPLAY.
    *--Building fieldcatalog table
        PERFORM FIELDCATLOG.
    *--FOr making the Layout settings
        PERFORM LAYOUT.
    *--For sorting the fields
        PERFORM SORTING.
    *--perform for displaying the ALV
        PERFORM ALV_GRID_DISPLAY.
      ENDMETHOD.                    "DISPLAY
    ENDCLASS.                    "LC_VBAK IMPLEMENTATION
    *&      Form  FIELDCATLOG
         Building the FIELDCATALOG
    FORM FIELDCATLOG .
      CLEAR: X_FDCAT,TB_FDCAT[].
      X_FDCAT-ROW_POS   = 1.
      X_FDCAT-COL_POS   = 1.
      X_FDCAT-FIELDNAME = 'INDICAT'(004) .
      X_FDCAT-TABNAME   = 'TB_VBAK'(005).
      X_FDCAT-SCRTEXT_L = 'STATUS_INDICATOR'(006).
      APPEND X_FDCAT TO TB_FDCAT.
      X_FDCAT-ROW_POS   = 1.
      X_FDCAT-COL_POS   = 2.
      X_FDCAT-FIELDNAME = 'VBELN'(007) .
      X_FDCAT-TABNAME   = 'TB_VBAK'(005).
      X_FDCAT-SCRTEXT_L = 'SALES DOC'(008).
      APPEND X_FDCAT TO TB_FDCAT.
      X_FDCAT-ROW_POS   = 1.
      X_FDCAT-COL_POS   = 3.
      X_FDCAT-FIELDNAME = 'AUDAT'(009) .
      X_FDCAT-TABNAME   = 'TB_VBAK'.
      X_FDCAT-SCRTEXT_L = 'DOC DATE'(010).
      APPEND X_FDCAT TO TB_FDCAT.
      X_FDCAT-ROW_POS   = 1.
      X_FDCAT-COL_POS   = 4.
      X_FDCAT-FIELDNAME = 'VBTYP'(011) .
      X_FDCAT-TABNAME   = 'TB_VBAK'.
      X_FDCAT-SCRTEXT_L = 'SALES CATEGORY'(012).
      APPEND X_FDCAT TO TB_FDCAT.
      X_FDCAT-ROW_POS   = 1.
      X_FDCAT-COL_POS   = 5.
      X_FDCAT-FIELDNAME = 'AUART'(013) .
      X_FDCAT-TABNAME   = 'TB_VBAK'.
      X_FDCAT-SCRTEXT_L = 'DOC TYPE'(014).
      APPEND X_FDCAT TO TB_FDCAT.
      X_FDCAT-ROW_POS   = 1.
      X_FDCAT-COL_POS   = 6.
      X_FDCAT-FIELDNAME = 'AUGRU'(015) .
      X_FDCAT-TABNAME   = 'TB_VBAK'.
      X_FDCAT-SCRTEXT_L = 'REASON'(016).
      APPEND X_FDCAT TO TB_FDCAT.
      X_FDCAT-ROW_POS   = 1.
      X_FDCAT-COL_POS   = 7.
      X_FDCAT-FIELDNAME = 'NETWR'(017) .
      X_FDCAT-TABNAME   = 'TB_VBAK'.
      X_FDCAT-SCRTEXT_L = 'NET VALUE'(018).
      X_FDCAT-DO_SUM   = C_X.
      APPEND X_FDCAT TO TB_FDCAT.
      X_FDCAT-ROW_POS   = 1.
      X_FDCAT-COL_POS   = 8.
      X_FDCAT-FIELDNAME = 'WAERK'(019) .
      X_FDCAT-TABNAME   = 'TB_VBAK'.
      X_FDCAT-SCRTEXT_L = 'UNIT'(020).
      APPEND X_FDCAT TO TB_FDCAT.
    ENDFORM.                    " FIELDCATLOG
    *&      Module  STATUS_0007  OUTPUT
          module for setting the pf status
    MODULE STATUS_0007 OUTPUT.
      SET PF-STATUS 'ZSTATUS'.
    SET TITLEBAR 'xxx'.
    ENDMODULE.                 " STATUS_0007  OUTPUT
    *&      Module  USER_COMMAND_0007  INPUT
          module  for handling the user commands
    MODULE USER_COMMAND_0007 INPUT.
      OK_CODE = SY-UCOMM.
      CASE OK_CODE.
        WHEN 'BACK'.
          LEAVE TO SCREEN 0.
        WHEN 'CANCEL'.
          LEAVE TO SCREEN 0.
        WHEN 'EXIT'.
          LEAVE TO SCREEN 0.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0007  INPUT
    *&      Form  LAYOUT
          ALV Layout settings
    FORM LAYOUT .
      CLEAR X_LAYOUT.
    *-- making Layout settings
      X_LAYOUT-GRID_TITLE = 'Sales Header Document'(021).
      X_LAYOUT-ZEBRA      = C_X.
      IF P_ALVDIS =  C_X.
        X_LAYOUT-NO_HGRIDLN = C_X.
        X_LAYOUT-NO_VGRIDLN = C_X.
      ENDIF.
    ENDFORM.                    " LAYOUT
    *&      Form  SORTING
          sub routine for sorting criteria
    FORM SORTING .
      CLEAR X_SORT.
      X_SORT-SPOS = '1'(022).
      X_SORT-FIELDNAME = 'AUART'.
      X_SORT-UP        = C_X.
      APPEND X_SORT TO TB_SORT.
      CLEAR X_SORT.
      X_SORT-SPOS = '2'(023).
      X_SORT-FIELDNAME = 'VBTYP'.
      X_SORT-UP        = C_X.
      APPEND X_SORT TO TB_SORT.
      CLEAR X_SORT.
      X_SORT-SPOS = '3'(024).
      X_SORT-FIELDNAME = 'WAERK'.
      X_SORT-UP        = C_X.
      X_SORT-SUBTOT    = C_X.
      APPEND X_SORT TO TB_SORT.
    ENDFORM.                    " SORTING
    *&      Form  CREATE_CONTAINER_OBJECT
          subroutine to create object of container
    FORM CREATE_CONTAINER_OBJECT .
      CREATE OBJECT CUSTOM_CONTAINER
        EXPORTING
          CONTAINER_NAME              = 'CUST_CONTROL'(025)
        EXCEPTIONS
          CNTL_ERROR                  = 1
          CNTL_SYSTEM_ERROR           = 2
          CREATE_ERROR                = 3
          LIFETIME_ERROR              = 4
          LIFETIME_DYNPRO_DYNPRO_LINK = 5
          OTHERS                      = 6
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                   WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " CREATE_CONTAINER_OBJECT
    *&      Form  CREATE_ALV_GRID_OBJECT
          subroutine to create object of ALV GRID
    FORM CREATE_ALV_GRID_OBJECT .
      CREATE OBJECT OBJ_ALV_GRID
        EXPORTING
          I_PARENT          = CUSTOM_CONTAINER
        EXCEPTIONS
          ERROR_CNTL_CREATE = 1
          ERROR_CNTL_INIT   = 2
          ERROR_CNTL_LINK   = 3
          ERROR_DP_CREATE   = 4
          OTHERS            = 5
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                   WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " CREATE_ALV_GRID_OBJECT
    *&      Form  ALV_GRID_DISPLAY
          subroutine to call method for displaying the ALV GRID
    FORM ALV_GRID_DISPLAY .
      CALL METHOD OBJ_ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY
        EXPORTING
          IS_LAYOUT                     = X_LAYOUT
        CHANGING
          IT_OUTTAB                     = TB_VBAK
          IT_FIELDCATALOG               = TB_FDCAT
          IT_SORT                       = TB_SORT
        EXCEPTIONS
          INVALID_PARAMETER_COMBINATION = 1
          PROGRAM_ERROR                 = 2
          TOO_MANY_LINES                = 3
          OTHERS                        = 4.
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                   WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CALL SCREEN 0007.
    ENDFORM.                    " ALV_GRID_DISPLAY
                    START OF SELECTION
    START-OF-SELECTION.
    *--Creating a reference variable for the class LC_VBAK
      DATA : OBJ1 TYPE REF TO LC_VBAK.
    *--Creating a container object
      PERFORM CREATE_CONTAINER_OBJECT.
    *--Creating a ALV GRID control object
      PERFORM CREATE_ALV_GRID_OBJECT.
    *--Creating a object of class LC_VBAK
      CREATE OBJECT OBJ1.
    *--calling vbak population method
      CALL METHOD OBJ1->VBAK_POPULATE.
    *--calling icon population method
      CALL METHOD OBJ1->ICON_POPULATE.
    *--calling fianl table population method
      CALL METHOD OBJ1->FINAL_POPULATE.
    *--calling final  method for display
      CALL METHOD OBJ1->DISPLAY.
    *&      Form  EVENT_TOP_OF_PAGE
          text
         -->P_E_DYNDOC_ID  text
    FORM EVENT_TOP_OF_PAGE  USING    P_E_DYNDOC_ID TYPE REF TO
                                                      CL_DD_DOCUMENT.
    ENDFORM.                    " EVENT_TOP_OF_PAGE

Maybe you are looking for

  • Table Name for Sales Order Header Text.

    Hi. Whats the Table name for Sales Order Header Text??? Reg, Amol

  • PO form font problem

    Hi,       I have an issue with font with PO form. The form is prinitng coming up correctly but the font is different for different documents. Can anybody has some idea on this? plz clarify. Thanks bpr <MOVED BY MODERATOR TO THE CORRECT FORUM> Edited

  • Enhance OM infotype

    Hi I want to enhance infotype 1050 with a note. Could anyone explain (just in short) how i could do that? I can imagine how to enhance with a single entry field - but in this case i want a note (like in 1002 or something like that). Is there an easy

  • Database access through Beans

    My question is about high level design. I've written some JSP pages and some very simple JavaBeans that work on Tomcat. Now I'm trying to design a Database access layer I want to have a connection pool class and some other business logic classes comm

  • Interpolation between two series of data

    Hello everybody, i need to make an interpolation on a curve which have an interruption. It's a 1D array of data with a serie of NaN inside. I don't know hot to use the different type of interpolation in this case. I tried but i failed. Find here a pi