Grid cell displaying 1 when value is 0

Why is it that grid column cells sometimes display 1 when the value in the cell is actually 0? Here is the scenario - I have a column in my grid with the following definition:
AttributeInfo SalesDollarsMasterCol = new AttributeInfo(java.sql.Types.NUMERIC);
The column is set up the following way:
SalesDollarsMasterCol.setName("SalesDollars");
SalesDollarsMasterCol.setColumnWidth(50);
SalesDollarsMasterCol.setUpdateable(false);
SalesDollarsMasterCol.setFormatterInfo(new FormatterInfo(DefaultFormatManager.NUMERIC_VALUE,"###,###,##0"));
SalesDollarsMasterCol.setLabel("Sales $");
SalesDollarsMasterCol.setDisplayed(true);
SalesDollarsMasterCol.setSortingEnabled(true);
When I display my grid, and there is a 0 value in SalesDollars, a 1 sometimes appears. To double check that I have a 0 value in SalesDollars, I get the actual Number value from the cell and print it out in the message window using getDoubleValue(), and the value is 0.0.
What's even stranger is that I can click in the cell, then click in another cell in the same row and the number changes to 0. But, when I navigate out of the row, the number changes back to 1.
Is this a bug in JDeveloper, or is it something I'm doing? I'm using JDeveloper 3.2.2 Build 915 on Windows 2000 and Oracle 8.1.7.

I think u can use SRW.SET_FIELD_NUM in the format trigger to set the value conditionally.
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Sanjay Sharma ([email protected]):
Hi All,
I have two querries of master-detail type. Master has groups of types and subtypes. I have set the detail column property to display 0 when there is no value for the master type-subtype combination. But the detail colum displays balnk and not Zero. I am using report 6i. How can I dispaly 0 for null value in detail record. any one with solution. Sanjay<HR></BLOCKQUOTE>
null

Similar Messages

  • WEB DYNPRO ALV GRID : CELL CONTENT - Initial Value

    I created a sort of 'Timesheet' in web dynpro...
    Unfortunatly, for all days of the month it displays '0.00' as initial value...
    Is it possible to not display this initial value or display space/empty ?
    In gui alv it is possible, I don't know if it could be done in web dynpro

    Hi,
    For the node to which the ALV is bound. For the column (context attribute) check the property of the attribute check the formatting propertioes as ZEROS AS BLANKS
    for ex: price is the context attrbiute check the properties.
    This FORMATTING options for the context attribute is found in the latest verions like EHP4.
    Regards,
    Lekha.

  • Displaying a multi-line text block in an ALV grid cell

    Can I display a multi-line text block (i.e. a paragraph of text) in an ALV grid cell?
    If yes, what properties do I set in the Field Catalaog (I tried the style and that didnt seem to work)
    Thanks

    By default ALV Grid merges fields with same values vertically.
    Isn't that only when the column is part of the sort key? You also have to consider the user changing the sort sequence, which can make the text jumbled up. In one of my reports I have made the cell a hotspot and displayed the text in a popup. Of course you cannot print it.
    Cheers,
    Ramki.

  • How do I assign images to grid cells based on their random number value?

    Hello everyone!
         I need a good point (or shove) in the correct direction.
    Background
         I've created (with previous help from this forum) a 12 x 9 random number grid which cycles through the numbers 1 to 9 a total of twelve times each. I've then created a button which shuffles the current grid's cells each time it is clicked. I now want to use 9 images that I have imported as individual symbols into the library (I have given them each their own class titled "skin1," "skin2," ... "skin9") as cell labels or the equivalent. I have also set the images up as individual movie clips (using the .Sprite class as the extended base class but keeping the actual image class names in line with their object name, i.e. the "skin1" image is the "skin1.as" class).
    Question
         How do I assign these images to the grid cells based on their respective values (ranging from 1 to 9) and have them populate the grid each time I click the "shuffle" button? So for example, in my grid the numbers 1 through 9 randomly appear 12 times each. Every time the number 4 appears in a cell, I want it to be assigned to the image "skin4" (which is just a graphic that looks like a button and has a fancy number "4" printed on it). Below is a chunk of the code I am using to draw the grid cells with:
    // Creates a grid cell when called by generateGrid().
    private funciton drawCell(_numeral:int):Sprite
              This is the code I am currently implementing to populate the grids with (although I
              don't want to use text labels as I want to fill each grid with an image according
              to its numerical value (1 to 9).
         var _label:TextField = new TextField();
         _label.multiline = _label.wordWrap = false;
         _label.autoSize = "center";
         _label.text = String(_numeral);
         // Add numerical label to cell array.
         cellLabels.push(_label);
         var _s:Sprite = new Sprite();
         _s.graphics.lineStyle(2, 0x019000);
         _s.graphics.drawRect(30, 0, cellW, CellH);
         _s.addChild(_label);
         return _s;
         While the following isn't working code, it will hopefully demonstrate what I want to achieve inside this function so I don't have to use the above snippet for text labels:
         //This will "hopefully" create an array of all 9 images by calling their classes.      var _imageArray:Array = [skin1, skin2, skin3, skin4, skin5 , skin6, skin7, skin8, skin9];      // This is what I want to happen for each cell using the above image array:      for (i = 0; i < cells; i++)      {           if (_numeral == 1)           {                // Insert skin1 image for each instance of #1 in the grid.           }           if (_numeral == 2)           {                // Insert skin2 image for each instance of #2 in the grid.           }           ...           if (_numeral == 9)           {                // Insert skin9 image for each instance of #9 in the grid.           }      } 
         Again, I don't want to use text labels. I have a custom skin graphic that I want to go over each number on the grid based on its numerical value (1 to 9). Any help with this is much appreciated!

    kglad,
         Thank you for your help with this one. Using the code below, I have successfully populated my grid cells with the desired corresponding graphics. I noticed one thing though regarding my use of the shuffle button with this particular implementation: even though the numerical values residing in each cell get shuffled, the original images remain in the grid rather than being replaced by new ones. The first code snippet below is the revised cell drawing function including your help; the second snippet shows you my simple shuffle button function (where the problem lies, I think).
    Snippet #1:
         // Creates a grid cell when called by generateGrid().
         private function drawCell(_numeral:int):Sprite
              var _label:TextField = new TextField();
              _label.multiline = _label.wordWrap = false;
              _label.autoSize = "center";
              // Creates a label that represents the numerical value of the cell.
              cellLabels.push(_label);
              var _s:Sprite = new Sprite();
              _s.graphics.lineStyle(2, 0x019000);
              _s.graphics.drawRect(30, 0, cellW, cellH);
              // Physically adds the labels to the grid.
              _s.addChild(_label);
              // Assigns a graphic class to a cell based on its numerical value.
              var _classRef:Class = Class(getDefinitionByName("skin" + _numeral));
              // Undefined variable for holding graphic classes.
              var _image:* = new _classRef();
              // Lines the images up with the grid cells.
              _image.x = 30;
              // Physically adds a graphic on top of a cell label.
              _s.addChild(_image);
              return _s;
         So far so good (although I question needing text labels at all if they are just going to remain invisible underneath the images, but enough about that for now). This next part is the reason that the images won't shuffle with the cell values, I think.
    Snippet #2:
         // When shuffleButton is clicked, this event shuffles
         // the number array and fills the cellLabels with the new values.
         private function onButtonShuffleClick(e:MouseEvent):void
              // Shuffles the number array.
              shuffle(numbers);
              // Verifies the array has been shuffled.
              trace("After shuffle:", numbers);
              // Loop replaces old cellLabels with new number array values.
              for (var i:int = 0; i < cells; i++)
                   cellLabels[i].text = String(numbers[i]);
         As you can see, it never replaces the original images that populate the grid. I tried using the _s.removeChild(image) function but that didn't work, nor would copying/pasting some of the code from snippet #1 directly into this function as it would cause another instance of the images to be placed over top of the existing ones rather than actually swapping them out. Any continued help here is greatly appreciated!
         PS Is there a quicker method for posting code into these forums without having to type it all out by hand again (i.e. copy/paste or drag/drop from my .fla or Notepad file directly into this thread)?

  • How do I get a 0 to display when a count = 0 (zero)? (The cell is blank)...

    (Running Business Objects Release 2 (Web-I), No other reporting modules)
    How do I get a 0 to display when a count = 0 (zero)? (The cell is blank)...
    In my reports, I count the number of tests of one of our products and another count on the number of failures.  I then use a simple formula to give me the defect rate percentage (DR%)
    The universe objects used in the calculation are:
    Assembly Number (dimension)
    Human Sn (dimension)
    Test Code Description (dimension)
    I created a variable (called [Count Assys]) that counts the number of Assemblies Tested:
    Formula: =Count([Assembly Number];All)
    Another variable (called [Failed Count]) counts the number of failed tests:
    Formula: =Count([Test Code Description];All) Where ([Test Code Description] <> "FUNCTIONAL TESTS PASSED")
    NOTE: There is a "not equal to sign" between [Test Code Description] and "FUNCTIONAL..." above, but the forum is blanking it when I preview the message.  Not a big deal, but it may be important for someone looking to help...
    I then have a third variable called [DR%] that divides [Failed Count] into the number of [Count Assys], which yields a number formatted as a percentage.
    Formula: =[Failed Count]/[Count Assys]
    The above works great! 
    The problem is: when I have a zero defect count (everything passes), the cell is blank, so the percentage variable remains blank.  I want a zero (0) to appear if nothing failed so the percentage appears as 0%
    I've searched this forum completely and have tried several Properties changes and different variable strings (like =If([Failed Count]<1,0) and the cell stays blank and cannot come up with an answer.
    This one seems simple to me, but everything I've tried has yielded zero <smile> results.
    Thanks,
    Charles
    Edited by: Charles Norman on Dec 9, 2008 12:44 PM
    Edited by: Charles Norman on Dec 9, 2008 12:47 PM

    Hi Charles,
    Use [Dr%] Variable formula as =if(IsNull([Dr%]);0;[DR%])
    Here IsNull returns the Boolean value of variable [Dr%] if its true then inserts 0 else the percentage values of failed tests based on the  total number of assembly tests performed.
    I Hope this is what you want to achieve....
    Thanks....
    Pratik

  • #VALUE! displayed when opening Offline documents with BPC logged on

    SITUATION
    The offline documents (by using Park N Go) open fine in Excel, though, when these documents are opened after logging on to BPC, cells display #VALUE! instead. This gives my users a hard time opening distributed reports when they are in BPC session
    DATA
    Macro IS enabled when opening these offline documents
    We are on Office 2007 and BPC 5.1 & BPC 7.0. This particular issue occurs to both versions of BPC
    Please let me know if you have a workaround, or this is a bug? Thank you!
    Sincerely,
    Brian Hsu

    Hi Brian,
    I can suggest you 2 things.
    1. Before doing the offline distribution, go to the template, go to workbook options and select the boxes for expansion and refreshing workbook, when opened / when CV is changed. Save this template and then do the "park n go".
    2. When the saved offline file is opened, this time you should not get #VALUE. If you still get the same values, then go to "park n go" and click on "set to live data and live current view".
    Hope this helps.

  • How to display tooltip in ALV GRID CELL?

    Hello,
    I'm trying to display dynamic tootips for data in ALV GRID Cells.
    My ALV Gid Cells content does not display Icon or symbol or Exception but pure data (In my case dates).
    Is there a way to do display a toolip that will change dynamicaly according to a rule.
    I took a look at the BCALV_DEMO_TOOLTIP program
    but it does not answer my expectation since it display
    toltip for Icon or symbol or Exception.
    Can someone help on this case.
    Best regards
    Harry

    Hai Harry
    •     icon
    value set: SPACE, 'X'           'X' = column contents to be output as an icon.
    The caller must consider the printability of icons.
    •     symbol
    value set: SPACE, 'X'          'X' = column contents are to be output as a symbol.
    The internal output table column must be a valid symbol character.
    The caller must consider the printability of symbols.
    Symbols can usually be printed, but may not always be output correctly, depending on the printer configuration.
    Thanks & regards
    Sreenu

  • Value "null" is displayed when retrieving null values from database

    Hi,
    I'm retrieving a record from Oracle database using a ResultSet rs and displaying the values on screen. Some of the columns do not have any data.
    The statements are:
    ResultSet rs
    st=con.createStatement();
    rs=st.executeQuery(............)
    out.println("<input name='punch_line' type='text' value='"+rs.getString(7)+"'>");
    The problem is that there is no value in the database column rs.getString(7). Ideally when the value is null, the field should not display anything. But in my case it is displaying the text "null".
    Can anyone let me know how can I display a blank value instead of displaying the text "null"?
    Thanks,
    Sridhar

    api >
    String getString(int columnIndex)
    Gets the value of the designated column in
    column in the current row of this ResultSet object as
    a String in the Java programming language.
    so null is returned as string object..NO.
    http://java.sun.com/j2se/1.5.0/docs/api/java/sql/ResultSet.html
    Returns:
    the column value; if the value is SQL NULL, the value returned is null
    The Java literal null is returned, not the String "null". The JDBC API provides a method wasNull() to detect if the previous accessed column returned a SQL NULL.

  • When i change the value of a combo box using a property node it displays the value not the item label

    I am using a combo box as a select list for text serial commands.  I have items like "engineering", "GUI", and "Scan" for the commands "MDE", "MDN", and MDS respectively which i have input as the corresponding value in the combo box.  so for example the label "engineering" has the value "MDE" in the combo box items list.  when the Vi starts it needs to read the current value MDE, MDN, or MDS and then i want it to display on the front panel the item text corresponding to that command value.
    To do this i have tried to read the serial command, ie MDS and then wire that to a "value" property of a property node of the combo-box, but instead of displaying the corresponding item label, "Scan", it displays the value "MDS" on the front panel instead.  i want the front panel to use the label text when choosing and displaying but the block diagram to use the serial commands.  Can this be done with a combo box?  I'm trying to use a combo box so i can keep it all text and avoid having to build a case statement to convert enums or rings from a numerical value to the text command.
    The correct text value is wired to the value property and it does exist in the combo-box.  I have unchecked "values match items" and selected to not allow undefined values.

    Don't use the value property node.  Use the Text.Text property node.  When creating the property node, select Text, then in the next pop-up box, select Text.
    - tbob
    Inventor of the WORM Global

  • When I add a date to a cell, how can I let another cell display a date that is 30 days later?

    when I add a date to a cell, how can I let another cell display a date that is 30 days later?

    =[cell reference] +30

  • When I display the view-formula command , the information in the cell displays vertically and it is very hard to read. I want it to go back to the horizontal display I have had all along. Thanks

    When I display the view-formula command , the information in the cell displays vertically and it is very hard to read. I want it to go back to the horizontal display I have had all along. Thanks

    Allan:
    Sorry, I forgot to mention that I am working with Excel for Mac.

  • Calling and displaying BAPI  values when the initial view is displayed

    hi Gurus,
    I am creating an application where I am calling a BAPI.
    Now my problem is that the values should be called and displayed when I am starting the application ie in the first view itself.
    Is there any way to execute the BAPI so as to retrieve the values from back end and get the values displayed in the initial screen/view.
    Or else is there any onPageLoad method which can be used in such cases.
    please help me how to go ahead.
    Thanks and regards,
    kris

    Hi
    Create a method in controller and insert the code,
    wdContext.current<BAPI>Element().modelObject().execute();
    And call the method in view, and check the size of BAPI's output node.If it is greater than 0, your BAPI is returning something. using any loop and get the Output
    Saravanan K

  • Disable sort when values in grid change (on propertyChange)

    I don't want my grid reordering itself on every propertyChanged event that would cause the sort order to change, can I prevent this somehow?
    I understand this is default behavior but it's not an option for our customer, and it is really annoying when the 1000 row grid is re-ordered every time user changes any values, not to mention slow.
    I tried returning 0 from sortComparer with no luck, grid still seems to reorder itself according to original data provider and not the sorted view when sort() was set.
    Specifically using AdvancedDataGrid and I'm starting to run out of ideas. Do I reset the dataprovider every time I decide to change my sort? I'm already intercepting headerRelease and setting sort explicitly as well as calling sort from controls outside the grid. How would I get the currently sorted list from my ArrayCollection, does the baseclass CollectionView have a current sorted view? Is there really no way to take a snapshot or current view and set it to current? Is there a way to tell sort() to physically move the rows instead of maintaining a view?
    What I found online:
    http://www.actionscript.org/forums/showthread.php3?t=199554
    Not an option since grid is sortable, I just want to suppress the updates AFTER initial sort

    My fix is less than ideal. As far as I can tell, you have 2 options (reimplement ListCollectionView or monkey patch it). The place where all the magic happens is a private method so there is no clean way to extend class.
    Make your own ArrayCollection and ListCollectionView and modify them. You can just copy paste them and use as your own. This is a lot of work if you want to replace them correctly so might be easier to just monkey patch them (copy paste classes exactly into your own project and make folders like mx.collections.aaa) google flex monkey patch for more info.
    Here is what I did.
    I introduced a new variable to ListCollectionView.as
    * Prevents collection from reordering itself when values change, list is only re-ordered on refresh()
    public var enablePostSortReorder:Boolean = true; //this is what framwork does by default, set to false to do what you want but better do this in yoru ArrayColleciton class (see below)
    In private function handlePropertyChangeEvents(events:Array):void
    Change
    if (sort || filterFunction != null)
    to
    if (enablePostSortReorder && (sort || filterFunction != null))
    You will probably also want to extend ArrayCollection. i.e.
    public class CustomArrayCollection extends ArrayCollection
    public function CustomArrayCollection(source:Array = null)
            super();
            enablePostSortReorder = false;
            this.source = source;
    Hope this helps you, I've been using this solution for a while now in a very big ADG.

  • Dump when trying to display characteristic values in QUERY DESIGNER

    Hi Experts,
    Life seems to become a struggle with 7.0 for me :-(.
    My current problem:
    If I try to display characteristic values  in Query Designer (left section of screnn, wthin dimensions) system dumps frequently.
    It's that kind of dump, that doen't help really (to my oponion)_
    What happened?
        The exception 'CX_RSR_X_MESSAGE' was raised, but it was not caught anywhere
         along
        the call hierarchy.
        Since exceptions represent error situations and this error was not
        adequately responded to, the running ABAP program
         'CL_RSBOLAP_BICS_SERVICES======CP' has to be
        terminated.
    How to correct the error
        If the error occures in a non-modified SAP program, you may be able to
        find an interim solution in an SAP Note.
        If you have access to SAP Notes, carry out a search with the following
        keywords:
        "UNCAUGHT_EXCEPTION" "CX_RSR_X_MESSAGE"
        "CL_RSBOLAP_BICS_SERVICES======CP" or "CL_RSBOLAP_BICS_SERVICES======CM003"
        "HANDLE_UNCAUGHT_EXCEPTION"
    ... etc.
    BW 79, SP21
    GUI 7100.4.14.3136
    Any ideas?
    Thanks in Advance and Regards
    Joe

    Hi Vikram,
    Thanks for reply. Reinstalling GUI was successful, but - error still occurs. ..
    Regards
    Joe
    Edited by: J.F.B. on May 28, 2010 3:02 PM

  • Button in alv grid cell using REUSE_ALV_GRID_DISPLAY

    Hi all,
      I want to make the contents of 2 columns of my alv grid as push button with values as text on it. I am not using classes or methods but alv grid fm. On clicking the button one dialog box has to pop up which gives edit option for the values in that coloumn, my question is how to introduce button in alv grid cell? if i can use t_fieldcatalog-icon, then please give me the complete steps for that.
    Thanks.

    this may helps u
    u need to copy stadard screen elemetn to MARATAB1(at PF -STATUS)
    You should copy the 'STANDARD' GUI status from program <b>SAPLSLVC_FULLSCREEN</b>
    type this one in SE41 program name is:<b>SAPLSLVC_FULLSCREEN</b>
    status : <b>STANDARD_FULLSCREEN</b>
    and copy it ...
             Type-pool
    type-pools slis.
             Tables
    tables: mara,sscrfields.
           Selection screen
    select-options: s_matnr for mara-matnr.
    PARAMETERS: p_email TYPE somlreci1-receiver.
    TYPES: BEGIN OF t_charmara,
      matnr(18)  TYPE c,                   " Material Number
      ernam(12)  TYPE c,                   " Person Credited
      aenam(12)  TYPE c,                   " Person Changed Object
      pstat(15)  TYPE c,                   " Maintenance Status
    END OF t_charmara.
             Data Declarations
    data: rt_extab    type slis_t_extab,   " Table of inactive function
                                           codes
          wa_charmara TYPE t_charmara,     " work area of mara Table
          fs_fieldcat type slis_t_fieldcat_alv,
                                           " Field catalog with field
                                           descriptions
          t_fieldcat  like line of fs_fieldcat,
                                           " Table of Field catalog
          r_ucomm     like sy-ucomm,       " User Command
          rs_selfield TYPE slis_selfield.  " cursor position ALV
    data: filedlayout   type slis_layout_alv,
          heading       type slis_t_listheader with header line,
          t_event       type slis_t_event.
    data: fs_event      like line of t_event.
    data: fs_sort type slis_sortinfo_alv,
           t_sort type slis_t_sortinfo_alv.
    data: w_char(200) type c,
          w_matnr     type mara-matnr.
    fs_sort-fieldname = 'MATNR'.
    fs_sort-up        = 'X'.
    fs_sort-group     = '*'.
    append fs_sort to t_sort.
    clear fS_sort.
    DATA:   t_packing_list  LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
            t_contents      LIKE solisti1   OCCURS 0 WITH HEADER LINE,
            t_receivers     LIKE somlreci1  OCCURS 0 WITH HEADER LINE,
            t_attachment    LIKE solisti1   OCCURS 0 WITH HEADER LINE,
            t_object_header LIKE solisti1   OCCURS 0 WITH HEADER LINE,
            w_cnt           TYPE i,
            w_sent_all(1)   TYPE c,
            w_doc_data      LIKE sodocchgi1,
            gd_error        TYPE sy-subrc,
            gd_reciever     TYPE sy-subrc.
             Internal Tables
    data: begin of it_mara occurs 0,
            matnr like mara-matnr,         " Material Number
            ernam like mara-ernam,         " Person Credited
            aenam like mara-aenam,         " Person Changed Object
            pstat like mara-pstat,         " Maintenance Status
          end of it_mara.
    DATA:   it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
                    WITH HEADER LINE.
    DATA:   it_attach TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
                    WITH HEADER LINE.
    *at selection-screen on field event
    AT SELECTION-SCREEN on s_matnr.
    PERFORM f0100_VALIDATE_MATERIAL_NUMBER.
    start-of-selection.
    retrive Data from the data base table Mara
    perform retrive_data_from_mara.
    end-of-selection.
    *Field catalog with field descriptions
    perform fieldcat.
    *perform top_of_page.
    PERFORM EVENT_LIST.
    *ALV Grid Display
    perform alv_display.
    Creating one Push button ENTER
    perform maratab1 USING    RT_EXTAB.
    *&      Form  f0100_VALIDATE_MATERIAL_NUMBER
          text
    There are no interface parameters to be passed to this subroutine
    FORM F0100_VALIDATE_MATERIAL_NUMBER .
    select matnr                          " Material Number
       from mara
      up to 1 rows
       into mara-matnr
      where matnr in s_matnr.
      endselect.
    IF sy-subrc NE 0.
          clear sscrfields-ucomm.
          MESSAGE e000 WITH 'Enter valid Material number'(003).
        ENDIF.                             " IF sy-subrc NE 0
    ENDFORM.                               " f0100_VALIDATE_MATERIAL_NUMBER
    *&      Form  retrive_data_from_mara
          text
    *There are no interface parameters to be passed to this subroutine
    FORM retrive_data_from_mara .
    select   matnr                         " Material Number
             ernam                         " Person Credited
             aenam                         " Person Changed Object
             pstat                         " Maintenance Status
        from mara
        into table It_mara
       where matnr in s_matnr.
    IF sy-subrc NE 0.
          MESSAGE i001 WITH 'Records are not found'.
          exit.
          stop.
        ENDIF.                             " IF sy-subrc NE 0
    ENDFORM.                               " retrive_data_from_mara
    *&      Form  fieldcat
          text
    *There are no interface parameters to be passed to this subroutine
    FORM fieldcat .
    *field catalog for MATNR
      t_FIELDCAT-REF_TABNAME = 'MARA'.
      t_fieldcat-fieldname   = 'MATNR'.
      t_fieldcat-col_pos     = 1.
      append t_fieldcat to fs_fieldcat.
      clear t_fieldcat.
    *field catalog for ERNAM
      t_FIELDCAT-REF_TABNAME = 'MARA'.
      t_fieldcat-fieldname   = 'ERNAM'.
      t_fieldcat-col_pos     = 2.
      append t_fieldcat to fs_fieldcat.
      clear t_fieldcat.
    *field catalog for AENAM
      t_FIELDCAT-REF_TABNAME = 'MARA'.
      t_fieldcat-fieldname   = 'AENAM'.
      t_fieldcat-col_pos     = 3.
      append t_fieldcat to fs_fieldcat.
      clear t_fieldcat.
    *field catalog for PSTAT
      t_FIELDCAT-REF_TABNAME = 'MARA'.
      t_fieldcat-fieldname   = 'PSTAT'.
      t_fieldcat-col_pos     = 4.
      append t_fieldcat to fs_fieldcat.
      clear t_fieldcat.
    ENDFORM.                               " fieldcat
    *&      Form  EVENT_LIST
          text
    *There are no interface parameters to be passed to this subroutine
    FORM EVENT_LIST .
      fs_event-name ='TOP_OF_PAGE'.
      fs_event-form = 'TOP_PAGE'.
      append fs_event TO t_EVENT.
      CLEAR FS_EVENT.
      fs_event-name ='END_OF_PAGE'.
      fs_event-form = 'END_PAGE'.
      append fs_event TO t_EVENT.
      CLEAR FS_EVENT.
      fs_event-name ='END_OF_LIST'.
      fs_event-form = 'LIST_END'.
      append fs_event TO t_EVENT.
      CLEAR FS_EVENT.
    ENDFORM.                               " EVENT_LIST
    *&      Form  alv_display
          text
    *There are no interface parameters to be passed to this subroutine
    FORM alv_display .
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      I_INTERFACE_CHECK              = ' '
      I_BYPASSING_BUFFER             =
      I_BUFFER_ACTIVE                = ' '
       I_CALLBACK_PROGRAM             = SY-REPID
       I_CALLBACK_PF_STATUS_SET       = 'MARATAB1'
       I_CALLBACK_USER_COMMAND        = 'USER_COMMAND'
      I_STRUCTURE_NAME               =
      IS_LAYOUT                      =
       IT_FIELDCAT                    = FS_FIELDCAT
      IT_EXCLUDING                   =
      IT_SPECIAL_GROUPS              =
       IT_SORT                        = T_SORT
      IT_FILTER                      =
      IS_SEL_HIDE                    =
      I_DEFAULT                      = 'X'
      I_SAVE                         = ' '
      IS_VARIANT                     =
       IT_EVENTS                      = T_EVENT
      IT_EVENT_EXIT                  =
      IS_PRINT                       =
      IS_REPREP_ID                   =
      I_SCREEN_START_COLUMN          = 0
      I_SCREEN_START_LINE            = 0
      I_SCREEN_END_COLUMN            = 0
      I_SCREEN_END_LINE              = 0
      IR_SALV_LIST_ADAPTER           =
      IT_EXCEPT_QINFO                =
      I_SUPPRESS_EMPTY_DATA          = ABAP_FALSE
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER        =
      ES_EXIT_CAUSED_BY_USER         =
      TABLES
        T_OUTTAB                       = IT_MARA[]
    EXCEPTIONS
      PROGRAM_ERROR                  = 1
      OTHERS                         = 2
    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.                               " alv_display
    form TOP_PAGE.
      data:tbl_listheader type slis_t_listheader,
            wa_listheader type slis_listheader .
       wa_listheader-typ = 'S'.
       wa_listheader-info = 'Created by : Vijay Pawar'.
       append wa_listheader to tbl_listheader.
       wa_listheader-typ = 'S'.
       concatenate ' Date ' sy-datum into
                  wa_listheader-info separated by space.
        append wa_listheader to tbl_listheader.
       wa_listheader-typ = 'S'.
       concatenate ' From ' s_matnr-low '  To  ' s_matnr-high into
                           wa_listheader-info separated by space.
       append wa_listheader to tbl_listheader.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
      EXPORTING
        IT_LIST_COMMENTARY       = tbl_listheader
      I_LOGO                   =
      I_END_OF_LIST_GRID       =
      I_ALV_FORM               =
    endform.                               " form TOP_PAGE.
    form END_PAGE.
      STATICS W_PAGE TYPE I .
      data:tbl_listheader type slis_t_listheader,
            wa_listheader type slis_listheader .
      wa_listheader-typ   = 'S'.
      wa_listheader-info  = W_PAGE.
      append wa_listheader to tbl_listheader.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
      EXPORTING
        IT_LIST_COMMENTARY       = tbl_listheader
      I_LOGO                   =
      I_END_OF_LIST_GRID       =
      I_ALV_FORM               =
    add 1 to w_page.
    endform.                               " form END_PAGE.
    form list_end.
      data:tbl_listheader type slis_t_listheader,
      wa_listheader type slis_listheader .
      wa_listheader-typ = 'S'.
      wa_listheader-info = '......................................Last Page'
      append wa_listheader to tbl_listheader.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
      EXPORTING
        IT_LIST_COMMENTARY       = tbl_listheader
      I_LOGO                   =
      I_END_OF_LIST_GRID       =
      I_ALV_FORM               =
    endform.                               " form list_end.
    *&      Form  maratab1
          text
         -->P_RT_EXTAB  text
    FORM maratab1  USING    P_RT_EXTAB.
      SET PF-STATUS 'MARATAB1' EXCLUDING rt_extab.
    ENDFORM.                               " maratab1
    FORM user_command  USING r_ucomm LIKE sy-ucomm
                         rs_selfield TYPE slis_selfield.
    case r_ucomm.
       when 'ENTER'.
       perform bulid_xls_data_table.
       PERFORM send_file_as_email_attachment
                                      tables it_message
                                             it_attach
                                       using p_email "'[email protected]'
                                    'Example .xls documnet attachment'
                                             'XLS'
                                             'filename'
                                    changing gd_error
                                             gd_reciever.
        perform populate_email_message_body.
        PERFORM initiate_mail_execute_program.
      endcase.                             " case r_ucomm.
    endform.                               " FORM user_command
    perform populate_email_message_body.
    PERFORM initiate_mail_execute_program.
         CALL FUNCTION 'RH_START_EXCEL_WITH_DATA'
    EXPORTING
       DATA_FILENAME             = 'MARA.XLS'
       DATA_PATH_FLAG            = 'W'
      DATA_ENVIRONMENT          =
       DATA_TABLE                = ITAB[]
      MACRO_FILENAME            =
      MACRO_PATH_FLAG           = 'E'
      MACRO_ENVIRONMENT         =
       WAIT                      = 'X'
      DELETE_FILE               = 'X'
    EXCEPTIONS
       NO_BATCH                  = 1
       EXCEL_NOT_INSTALLED       = 2
       INTERNAL_ERROR            = 3
       CANCELLED                 = 4
       DOWNLOAD_ERROR            = 5
       NO_AUTHORITY              = 6
       FILE_NOT_DELETED          = 7
       OTHERS                    = 8
       IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
       ENDIF.
       leave to list-processing.
    endcase.
    *&      Form  bulid_xls_data_table
          text
    *There are no interface parameters to be passed to this subroutine
    FORM bulid_xls_data_table .
    CONSTANTS: con_cret TYPE x VALUE '0D',  "OK for non Unicode
                con_tab TYPE x VALUE '09'.   "OK for non Unicode
    *If you have Unicode check active in program attributes thnen you will
    *need to declare constants as follows
    *class cl_abap_char_utilities definition load.
    constants:
        con_tab  type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
        con_cret type c value cl_abap_char_utilities=>CR_LF.
      CONCATENATE 'matnr' 'ernam' 'aenam' 'pstat'
             INTO it_attach SEPARATED BY con_tab.
      CONCATENATE con_cret it_attach  INTO it_attach.
      APPEND  it_attach.
      LOOP AT It_mara INTO wa_charmara.
        CONCATENATE wa_charmara-matnr wa_charmara-ernam
                    wa_charmara-aenam wa_charmara-pstat
               INTO it_attach SEPARATED BY con_tab.
        CONCATENATE con_cret it_attach  INTO it_attach.
        APPEND  it_attach.
      ENDLOOP.                             " LOOP AT it_mara INTO...
    ENDFORM.                               " bulid_xls_data_table
    *&      Form  send_file_as_email_attachment
       Send email
         -->P_IT_MESSAGE  text
         -->P_IT_ATTACH  text
         -->P_P_EMAIL  text
         -->P_0387   text
         -->P_0388   text
         -->P_0389   text
         -->P_0390   text
         -->P_0391   text
         -->P_0392   text
         <--P_GD_ERROR  text
         <--P_GD_RECIEVER  text
    FORM send_file_as_email_attachment tables pit_message
                                              pit_attach
                                        using p_email
                                              p_mtitle
                                              p_format
                                              p_filename
                                              p_attdescription
                                              p_sender_address
                                              p_sender_addres_type
                                     changing p_error
                                              p_reciever.
      DATA: ld_error               TYPE sy-subrc,
            ld_reciever            TYPE sy-subrc,
            ld_mtitle              LIKE sodocchgi1-obj_descr,
            ld_email               LIKE  somlreci1-receiver,
            ld_format              TYPE  so_obj_tp ,
            ld_attdescription      TYPE  so_obj_nam ,
            ld_attfilename         TYPE  so_obj_des ,
            ld_sender_address      LIKE  soextreci1-receiver,
            ld_sender_address_type LIKE  soextreci1-adr_typ,
            ld_receiver            LIKE  sy-subrc.
      ld_email               = p_email.
      ld_mtitle              = p_mtitle.
      ld_format              = p_format.
      ld_attdescription      = p_attdescription.
      ld_attfilename         = p_filename.
      ld_sender_address      = p_sender_address.
      ld_sender_address_type = p_sender_addres_type.
    Fill the document data.
      w_doc_data-doc_size = 1.
    Populate the subject/generic message attributes
      w_doc_data-obj_langu = sy-langu.
      w_doc_data-obj_name  = 'SAPRPT'.
      w_doc_data-obj_descr = ld_mtitle .
      w_doc_data-sensitivty = 'F'.
    Fill the document data and get size of attachment
      CLEAR w_doc_data.
      READ TABLE it_attach INDEX w_cnt.
      w_doc_data-doc_size =
         ( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
      w_doc_data-obj_langu  = sy-langu.
      w_doc_data-obj_name   = 'SAPRPT'.
      w_doc_data-obj_descr  = ld_mtitle.
      w_doc_data-sensitivty = 'F'.
      CLEAR t_attachment.
      REFRESH t_attachment.
      t_attachment[] = pit_attach[].
    Describe the body of the message
      CLEAR t_packing_list.
      REFRESH t_packing_list.
      t_packing_list-transf_bin  = space.
      t_packing_list-head_start  = 1.
      t_packing_list-head_num    = 0.
      t_packing_list-body_start  = 1.
      DESCRIBE TABLE it_message LINES t_packing_list-body_num.
      t_packing_list-doc_type    = 'RAW'.
      APPEND t_packing_list.
    Create attachment notification
      t_packing_list-transf_bin = 'X'.
      t_packing_list-head_start = 1.
      t_packing_list-head_num   = 1.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
      t_packing_list-doc_type   =  ld_format.
      t_packing_list-obj_descr  =  ld_attdescription.
      t_packing_list-obj_name   =  ld_attfilename.
      t_packing_list-doc_size   =  t_packing_list-body_num * 255.
      APPEND t_packing_list.
    Add the recipients email address
      CLEAR t_receivers.
      REFRESH t_receivers.
      t_receivers-receiver   = ld_email.
      t_receivers-rec_type   = 'U'.
      t_receivers-com_type   = 'INT'.
      t_receivers-notif_del  = 'X'.
      t_receivers-notif_ndel = 'X'.
      APPEND t_receivers.
      CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
           EXPORTING
                document_data              = w_doc_data
                put_in_outbox              = 'X'
                sender_address             = ld_sender_address
                sender_address_type        = ld_sender_address_type
                commit_work                = 'X'
           IMPORTING
                sent_to_all                = w_sent_all
           TABLES
                packing_list               = t_packing_list
                contents_bin               = t_attachment
                contents_txt               = it_message
                receivers                  = t_receivers
           EXCEPTIONS
                too_many_receivers         = 1
                document_not_sent          = 2
                document_type_not_exist    = 3
                operation_no_authorization = 4
                parameter_error            = 5
                x_error                    = 6
                enqueue_error              = 7
                OTHERS                     = 8.
    Populate zerror return code
      ld_error = sy-subrc.
    Populate zreceiver return code
      LOOP AT t_receivers.
        ld_receiver = t_receivers-retrn_code.
      ENDLOOP.
    ENDFORM.                               " send_file_as_email_attachment
    *&      Form  INITIATE_MAIL_EXECUTE_PROGRAM
          Instructs mail send program for SAPCONNECT to send email.
    FORM initiate_mail_execute_program.
      WAIT UP TO 2 SECONDS.
      SUBMIT rsconn01 WITH mode = 'INT'
                    WITH output = 'X'
                    AND RETURN.
    ENDFORM.                               " INITIATE_MAIL_EXECUTE_PROGRAM
    *&      Form  POPULATE_EMAIL_MESSAGE_BODY
           Populate message body text
    form populate_email_message_body.
      REFRESH it_message.
      it_message = 'Please find attached a list test mara records'.
      APPEND it_message.
    endform.                               "form populate_email_message_bod
    rewards if it helps u

Maybe you are looking for

  • How to delete file names from Adobe Reader list

    How can I delete file names from the Adobe Reader list?  I have deleted the file & it's empty, but deleted file names remain in my list & it's very annoying.  I can't seem to find an option anywhere to delete the file names.

  • How to put up a calendar in VI for date selection?

    Hi all, I need to put up a calendar in my VI for date selection to view historical data like we find on websites of travel agents? & also guide me how to get this kind of calendar..... please guide me... Thanking You, Vaibhav Gandhi B.E. Instrumentat

  • Missing header of multipart after a writeTo(). Help!

    Hello! What I want is to get the pure MIME message from a writeTo() method. And I don't want to use MimeMessage since it needs a Session -that I don't have-. Basicaly, I create a MimeMultipart with different MimeBodyParts. Then I ask writeTo() on the

  • ALinks not working?

    Hi, For some reason I've never been able to get bookmarks (ALinks to objects on the same page or within the same topic) to work for me with OHJ. Couldn't with previous 4.1 releases, and still can't get it to work with the current one. Anyone else hav

  • IMac - will my raid set be recognized after a fresh install?

    I  own an iMac late 2012 and I installed an external raid with two Lacie thunderbolt disks. Will my raid be recognized after a fresh install of mavericks? Software  OS X 10.9.1 (13B42), Grafica  NVIDIA GeForce GTX 660M 512 MB Memoria  8 GB 1600 MHz D