Sort B1 DataTable - Code Inside...

Hi
I hope this will help you ...
In case you know a  better way to implement this - please post your code...
[B1Listener(BoEventTypes.et_ITEM_PRESSED, false)]
        public virtual void OnAfterItemPressed(ItemEvent pVal)
            bool ActionSuccess = pVal.ActionSuccess;
            Form oForm = B1Connections.theAppl.Forms.Item(pVal.FormUID);
            if (pVal.Row < 0)
                //click on headers...
                //call sort DT according to Col.
                Grid oGrid = (Grid) oForm.Items.Item("CFLG").Specific;
                DataTable oDT = oGrid.DataTable;
                oForm.Freeze(true);
                SortDT(ref oDT , pVal.ColUID);
                oForm.Freeze(false);
        public static bool SortDT(ref DataTable oDT, string ColName)
            //Copy To System DT
            System.Data.DataTable oSysDT = new System.Data.DataTable();
            // Add Cols
            for (int iCol = 0; iCol < oDT.Columns.Count; iCol++)
                oSysDT.Columns.Add(oDT.Columns.Item(iCol).Name);
            for (int iRow = 0; iRow < oDT.Rows.Count; iRow++)
                System.Data.DataRow oRow =  oSysDT.NewRow();
                for (int iCol = 0; iCol < oDT.Columns.Count; iCol++)
                    oRow[iCol] = oDT.GetValue(iCol, iRow);
                oSysDT.Rows.Add(oRow);
            //Sort DT
            SortSystemDataTable(oSysDT, ColName);
            //Copy Sorted table to B1DT
            oDT.Rows.Clear();
            oDT.Rows.Add(oSysDT.Rows.Count);
            for (int iRowCount = 0; iRowCount < oSysDT.Rows.Count; iRowCount++)
                for (int iColCount = 0; iColCount < oSysDT.Columns.Count; iColCount++)
                    string scol = oDT.Columns.Item(iColCount).Name;
                    int icol = oSysDT.Columns.IndexOf(scol);
                    string sValue = oSysDT.Rows[iRowCount].ItemArray[icol].ToString();
                    if (oDT.Columns.Item(iColCount).Type == BoFieldsType.ft_Date)
                        if (sValue.Length > 0)
                            DateTime dDate = DateTime.Parse(sValue);
                            oDT.SetValue(iColCount, iRowCount, dDate);
                    else
                        if (sValue.Length > 0)
                            oDT.SetValue(iColCount, iRowCount, sValue);
            return true;
        private static void SortSystemDataTable(System.Data.DataTable oDT, string Sort)
            System.Data.DataTable newDT = oDT.Clone();
            int rowCount = oDT.Rows.Count;
            System.Data.DataRow[] foundRows = oDT.Select(null, Sort); // Sort with Column name
            for (int i = 0; i < rowCount; i++)
                object[] arr = new object[oDT.Columns.Count];
                for (int j = 0; j < oDT.Columns.Count; j++)
                    arr[j] = foundRows<i>[j];
                System.Data.DataRow data_row = newDT.NewRow();
                data_row.ItemArray = arr;
                newDT.Rows.Add(data_row);
            //clear the incoming dt
            oDT.Rows.Clear();
            for (int i = 0; i < newDT.Rows.Count; i++)
                object[] arr = new object[oDT.Columns.Count];
                for (int j = 0; j < oDT.Columns.Count; j++)
                    arr[j] = newDT.Rows<i>[j];
                System.Data.DataRow data_row = oDT.NewRow();
                data_row.ItemArray = arr;
                oDT.Rows.Add(data_row);
Enjoy,
J.

J,
If you search the Business One SDK forum on this topic you will find many posts that may help you.  Here is one as an example ...
Re: sorting db datatable
HTH,
Eddy

Similar Messages

  • Looking for a sort of "activity code" in transactions ME51N/ME52N/ME53N

    Hi all experts, got an - I hope - interesting question to ask you.
    I have an user exit that is executed on every step done in creation/modify of a Purchase requisition. In this code (custom), executed from the transactions ME51(n)/ME52(n) and ME53(n) there's something like:
    GET PARAMETER ID 'BAN' FIELD r_banfn. "Purchase Requisition number
    GET PARAMETER ID 'BFC' FIELD r_frgab. "Release strategy
    r_banfn should contain the number of the purchase requisition I'm working on. So far, so good.
    The problem is that if in ANY transaction I press the New Document button, I can notice in debug that r_banfn contains the number of the purchase requisition that WAS active before pressing the "create new" button.
    That's not good because that r_banfn value is then used to some checks, and should then be blank in case of creation of a new purchase requisitions.
    I'm then asking you if there's a way in my user exit to distinguish between the two cases, which are:
    -1- I'm modifying an existing purchase requisition (so, the field in r_banfn IS correct);
    -2- I'm CREATING a new document (so, r_banfn value is NOT correct and should be set to blank).
    This distinction must be coded into the previously cited user exit and should affect ME51(n), ME52(n) and ME53(n), from which the user can either create a new RdA or modify an existing one.
    We tried to manage the situation as follow, but without success:
    IF NOT r_banfn IS INITIAL.
      CALL FUNCTION 'ENQUEUE_EMEBANE'
           EXPORTING
                banfn          = r_banfn
           EXCEPTIONS
                foreign_lock   = 1
                system_failure = 2
                OTHERS         = 3.
      IF sy-subrc NE 0.
    * Can't lock --> means I'm actually working in modify mode on it
    * leave it as is
      ELSE.
    * locked --> that means I'm not working on this purchase requisition
    * first dequeue the locked purchase req, then set r_banfn to blank.
        CALL FUNCTION 'DEQUEUE_EMEBANE'
             EXPORTING
                  banfn = r_banfn.
    *   clear the variable -> I'm in CREATE mode.
        CLEAR r_banfn.
      ENDIF.
    ENDIF.
    The code is quite self-explaining but doesn't work because it seems that the "enqueue" phase goes ok even tho we're working on modification on the purchase requisition.
    I'm guessing if there's a sort of "activity code" (create? modify? view?) I can catch @ runtime to solve this task.
    Thanks in advance, as usual
    Matteo
    Edited by: Matteo Montalto on Mar 19, 2009 5:15 PM
    Sorry, I edited the title in order to make it more explicative. :-P

    >
    Hi Sandipan, sorry for the late, I tried to manage this task but without success.
    The user exit I'm working on in EXIT_SAPLBBPK_001.
    FUNCTION EXIT_SAPLBBPK_001.
    *"*"Lokale Schnittstelle:
    *"  IMPORTING
    *"     VALUE(IM_BBPDECDATA) LIKE  BBPDECDATA STRUCTURE  BBPDECDATA
    *"     VALUE(IV_MANU_PROF) TYPE  MANPRC OPTIONAL
    *"  CHANGING
    *"     VALUE(CH_PROFILE) LIKE  T160EX-EPROFILE
      INCLUDE ZXBBPU04.
    ENDFUNCTION.
    It includes ZXBBPU04, in which I have to understand if I'm working on a Purch. requisition in MODIFY mode or in CREATE mode.

  • Call function '' in update task - code inside is BDC

    hi to all,
    in using call function '' in update task
    the code inside is bdc. is this possible? 
    my scenario is from VA01 then post billing to VF01,
    i am using user-exit MV45AFZZ in subroutine userexit_save_document.
    i need to post billing after va01 save.
    thanks to all.

    To debug in the update task, you have to set that option on in the debugger.
    If the user exit runs in the update task, then you must have something like: CALL FUNCTION MODULE my_fm_to_do_BDC STARTING NEW TASK.   ( This function module should wait until the SD is created.  You might want to check in a loop, with a WAIT command.   Once it is created, then you start your BDC and CALL TRANSACTION. )  This is NOT an update function module.  It may need to be RFC enabled - I'm not certain at the moment.
    If the user exit doesn't run in the update task, you need to create, and call from the user exit, an update function module that calls your function module "my_fm_to_do_BDC" STARTING NEW TASK. 
    The attribute "collective run", which is V3, means that the update task won't run that function module until a regularly scheduled job on the application server runs.  For processing to run during the rest of the SD save, you must use V1 (could be run in any order with other V1s) or V2 (Will run after V1, but in any order with other V2s).  Typically, I use V2 for this kind of task.
    matt

  • Read barcode or QR code inside image and save it in the file as metadata

    Maybe someone can help me with this question...
    All product photos contain a barcode or QR-code. It is visible inside the image.
    The customer is looking for a way (a plug-in) that is able to find the code inside the image, read it and place the information found in a preselected Metadata field of the image it self.
    Can anyone tell me if this already exists or is there anyone who can develop it? If yes, than please let me know
    Regards,
    Pieter

    It would be absolutely incredibly useful to me as a volume photographer, and I suspect other photographers too.  Anybody who needs to link data to images or catalogue images would be the target market.
    Let me outline a conversation that I had with a Lightroom developer at TTG recently, who unfortunately can't help me...
    Original Conversation is at:  Lightroom 6 (Page 1) — General — Community @ The Turning Gate (post 17 onwards).
    Automatically matching and syncing data to pictures is a huge software industry in its own right, believe me.
    As a school photographer (though not solely), matching student IDs to their pictures makes everything so much easier and is vital to update student record databases with images of pupils.  But it's also very relevant to other sectors such as events and sports photographers.  Imagine if this data could be incorporated into TTG database search facility.... (Do we have a swoon smiley?)
    Several pieces of commercial software is available, but most rely on the camera being permanently tethered to a laptop and using a barcode scanner to renames files as they come in.  This is a crap, restrictive system but is the one the vast majority of people use.  An example of this is the Australian Timestone software (http://timestonesoftware.com) which is very popular, but runs into the thousands of UK Pounds for a licence.
    An American photographer called Mike Fulton wrote a piece of software called fotovelocity.net which does exactly what I prefer - to photograph the pupil with a barcode somewhere in the image that later gets read by the software and data appended to the metadata of the image.  This is slightly cheaper than Timestone, but still runs into the thousands and he not interested in dealing with anybody outside the US.  
    If Lightroom can read and guess faces to add naming data, then it must surely be an easy upgrade to read an easily scannable QR code?
    and ...
    Has to be relevant to more than just me, surely?
    Imagine all the events / dance meets / clubs / nurseries / schools / football photographers that would use this.  Admittedly, this is all volume 'hot-dog' photography and not the artistic side, but it puts a fairly nice roof over my head.
    With schools I get a database beforehand, but for most events you don't need to know anything about the attendees to the event beforehand, as you just print out labels that have qr codes with sequenced numbers on them which the portrait subject (or their parents) then keep.  They then either visit a printing booth and type the code or take it home and type the code into their browsers and #kabam# up comes their images for purchase.  How they run it so that only the first image has the barcode visible yet all subsequent images retain the data from the first image until another barcode is detected I don't know.  I guess it must be that a numeric sequence must also be appended to the data from the barcode.
    It's a wonderful system for photographers, which is why it costs megabucks.
    I will admit though, that the commercial software tends to lab integrate as well, so there is more than just barcode reading.  Unfortunately, this ties you in to the system that your preferred lab uses, usually Timestone in the UK, and hence why people have to pay those silly license prices.
    If you need a sample image with a QR code in just let me know.
    Maybe fotoveolcity instructional videos may give you an impression of how this type of software flows and performs.
    General Volume Workflow ‹ Foto Velocity

  • Regarding use of java code inside javascript

    Hi ,
    I have doubt regarding how to use java code inside javascript,
    i am giving my application code here
    <%@page import="java.util.*"%>
    <%@ page import="com.suuny.sard.pmt.pat.*"%>
    <SCRIPT LANGUAGE="JavaScript">
    function fun(){
         var ac=document.login.Projectname.options[document.login.Projectname.selectedIndex].value;
         var c = document.login.task1.value;
         alert(ac);
         alert(c);
         return true;
    </SCRIPT>
    <form name="login" action="/pmt/jsp/Leavemanagement/Leave_Ems_HomePage.jsp" method="get" encType="x-www-form-encoded" >
    <table width="100%" Align="Center" cellspacing="0" cellpadding="0" border="0">
    <tr class="tablerow"><td colspan="6" align="center"><font class="pagehead" align="center">Create Tasks</font></td></tr>
         <tr class="tableheader">
              <th>Project
              <th>Task-Id
              <th>TaskName
              <th>Assigned To
              <th>description
              <th>Milestone
         </tr>
         <%
              for(int i=1;i<2;i++){%>
                   <tr class="tablerow"><td align="center">
                   <select class="SELECT" NAME="Projectname" VALUE=" " onchange="return fun();" >
                   <!--<option value=""> </option>-->
                   <%
                        ArrayList ar =null;
                        ArrayList projectids=null;
                        Hashtable ht = new Hashtable();
                        ProjectNames pnames=new ProjectNames();
                   ht = pnames.getProjectNames();
                        ar=(ArrayList)ht.get("projects");
                        projectids=(ArrayList)ht.get("projectIds");
                        for(int j=0;j<ar.size();j++){
                        out.println("<option value=\""+projectids.get(j)+"\">"+ar.get(j)+"</option>");
                   %>
    </select>
         <%
                   out.println("<td align=\"center\"><input type=\"text\" name=\"task"+i+"\"value=\"\" size=\"25\"></td>");
                   out.println("<td align=\"center\"><input type=\"text\" name=\"taskname"+i+"\"value=\"\" size=\"25\"></td>");
              %>
              <td align="center">
                             <select class="SELECT" NAME="Projectname1" VALUE=" ">
                             <!--<option value=""> </option>-->
                             <%
                                  ArrayList ar1 =null;
                             ar1 = pnames.getProjectResource("VXML02");
                                  for(int j=0;j<ar1.size();j++){
                                  out.println("<option value=\""+ar1.get(j)+"\">"+ar1.get(j)+"</option>");
                             %>
    </select>
              <%
                   out.println("<td align=\"center\"><input type=\"text\" name=\"description"+i+"\"value=\"\" size=\"25\"></td>");
                   out.println("<td align=\"center\"><input type=\"text\" name=\"milestone"+i+"\"value=\"\" size=\"25\"></td><tr>");
              out.println("<tr class=\"tablerow\"><td colspan=\"6\" align=\"center\"><input class=\"txtbuttonsmall\" type=\"submit\" value=\"save\"></td>");
         %>
    </Table>
    </form>
    My question is :
    I selected one project from first combo box ,i need project members corresponding to the project.
    In my code "pnames.getProjectResource("VXML02");" in this function iam passing one static projrct value,but i need dynamically selected project from first combo box(<select class="SELECT" NAME="Projectname" VALUE=" " onchange="return fun();" >),so please help me guys.

    Hi Marco,
    I "executed" some java code within XSLs file. I have quoted the word executed because I didn't really run java code, but I used a simply trick that I describe you below.
    Into your XSLs put an iframe which is hided (it has an height of 0 pixel). As src of the iframe put the address of a portal component which execute your code (in my case calculate some PCD URL of some pages into a defined role). As result of component execution, I use the response.write method in order to execute some jscript code, which is able to interact with the HTML generated by XSLs files, for example in my case response.write put the PCD URL into a drop down list placed into the "edit" form.
    This works fine. I don't know if is suitable also for your case, anyway could be a hint, but pay attention to Roland's recommendations.
    Ciao
    Roberto

  • How to use Java code inside WebDynpro-ABAP

    Hi,
        How to use Java code inside WebDynpro-ABAP.
    Could any one provide sample code.
    Cheers,
    Sam

    Hi Sam,
    We can't Bring Java Inside the ABAP. Both are running in different Environments.
    and also ABAP Codes are runs on BASIS.
    -Basis is a middleware between ABAP codes and Ur OS.
    -Contains set of programs to load,RUN,intepret the ABAP program..
    So Both are Different.
    Regards,
    Ramganesan K.

  • Servlet with no dynamic code inside jsp pages

    Hello,
              I saw that a servlet is created even if there is no dynamic code inside jsp pages (scriplets & tags). Is it possible to avoid it on bea side ? (I am using portal 8).
              By the way, do you know if is it possible to define apache in order to avoid to send to bea the jsp which have no dynamic code inside ?
              thank you !

    JSP's always generate a servlet on all web containers. Apache/Tomcat is no
              different. If you have static content, make it an HTML page.
              Bill
              "hournon jc" <[email protected]> wrote in message
              news:22255787.1103297053148.JavaMail.root@jserv5...
              > Hello,
              >
              > I saw that a servlet is created even if there is no dynamic code inside
              jsp pages (scriplets & tags). Is it possible to avoid it on bea side ? (I am
              using portal 8).
              >
              > By the way, do you know if is it possible to define apache in order to
              avoid to send to bea the jsp which have no dynamic code inside ?
              >
              > thank you !
              

  • Sorting in dataTable

    If anyone had played with display arena .. plss plss let me know ..
    can we do sorting in dataTable .. i dont see any tags attributes around ..
    if its not at all possible in jsp , then only i can get in bean coding side ..

    use bean coding style :)

  • When i copy code from DW to BC it change the code inside BC

    Hi
    I'm uploaded a html page to a BC account from Dreamweaver and BC changed some of the code,
    I tryed to open the Site Manager / Pages and the page i uploaded and did a copy & past to get the code inside, but it still changes the code.
    Im trying to get the code <i class="icon-caret-down"></i> in but it change that code to <em class="icon-caret-down"></em>
    Anyone know why this is happening or how i can go about this??
    Best
    Morten Håland - Sitespark

    The editor inside BC is XHTML compliant and will edit things into that format unfortunatly. Try to avoid using it for anything other then content.

  • Error running managed code inside DllMain or image initialization

    I have a LabView 7.1 DLL, and am calling it from a Visual C++ application.  I load the DLL dynamically at runtime using LoadLibrary.  When I call the function, I get this:
    <mda:msg xmlns:mda="http://schemas.microsoft.com/CLR/2004/10/mda">
      <!--
           DLL 'C:\Program Files\National Instruments\Shared\LabVIEW
           Run-Time\7.1\DNCompInfo.dll' is attempting managed execution inside OS Loader
           lock. Do not attempt to run managed code inside a DllMain or image
           initialization function since doing so can cause the application to hang.
       -->
      <mda:loaderLockMsg break="true"/>
    </mda:msg>
    in the Visual C++ debug window.
    I have been through the pages on this website about creating LabView DLLs and calling them.  I have also created very small vi's and exported them, but with the same error.  I have uninstalled LabView 7.1, and reinstalled it.
    Any ideas?

    Hi
    What version of C++ are you using?
    If you could you post your small VI and associated code I will have a look at it and see if I can get it running with out any errors.
    You said you have looked at some help material on the website. Have you tried any of the example pieces of code?
    Here is a link for one.
    Calling a LabVIEW DLL in Visual C++ that Passes Array Handles by Reference
    http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=D67C2540A4CE3182E034080020E74861&p_...
    See if you can run this with out any errors if you still get the same error with this please let me know
    Regards
    Tim
    AE NI UK and Ireland

  • Import a compiled .class or include a .jsp with a class code inside?

    which is better and faster, to import a class file or a jsp file that has a class code inside?

    I apologize but this is a clarification of this problem. We are having a problem dynamically reloading java classes that are referenced by jsp's and servlets. The problem DOES NOT exist when trying to reload jsps or servlets themselves. We would like to reload these classes without having to restart the processes. Any thoughts would be helpful. Thanks.

  • How to speed up my code inside the for loops,

    how to speed up my code inside the for loops using c# WinForm.

    Hi  John,
    Please take a look at the reply from Wyck in the following thread.
    How to speed up for loop?
    His answer is very comprehensive.   Thanks.
    Best regards,
    kristin
    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.

  • Can i write Html code inside JSP method???

    hi i am newbie to jsp and servlets. i am working on a project where i have to use same html code for two conditions in jsp. my question is can i write that html code inside any method in jsp?? and then can i call that method within that if and else scope. can anyone help me with this??

    I don't think that does what you think it does.
    <%!
    void renderStateSelect(String default) { %>Creates a method with that signature and an open brace...
    <select name="state"> puts:
    out.println("<select name=\"state\">");
    into the _jspService method
    <%!
    // logic to loop thru states
    %>Puts the loop logic after the brace opening up the method renderStateSelect
    </select>puts
    out.println("</select>");
    in the _jspService method
    <%!
    %>Closes the renderStateSelect method.
    So if I do this:
    <html>
    <body>
    <%!
    void renderStateSelect(String def) { %>
    <select name="state">
    <%!
    // logic to loop thru states
    %>
    </select>
    <%!
    %>
    Hello<br/>
    <% renderStateSelect("none"); %>
    Everybody
    </body>
    </html>The html output is:
    <html>
    <body>
    <select name="state">
    </select>
    Hello<br/>
    Everybody
    </body>
    </html> The 'renderStateSelect method does not render the state select. The _jspService method does, in place where the HTML is written in the JSP file.  As another look, the translated servlet looks like this:
    package org.apache.jsp;
    public final class IsThisOk_jsp extends org.apache.jasper.runtime.HttpJspBase
        implements org.apache.jasper.runtime.JspSourceDependent {
    void renderStateSelect(String def) {
    // logic to loop thru states
      public void _jspService(HttpServletRequest request, HttpServletResponse response)
            throws java.io.IOException, ServletException {
        try {
          out.write("<html>\r\n<body>\r\n");
          out.write("<select name=\"state\">\r\n");
          out.write("</select>\r\n");
          out.write(" \r\nHello<br/>\r\n");
    renderStateSelect("none");
          out.write("\r\nEverybody\r\n</body>\r\n</html>\r\n ");
    }See. Any plain HTML code you put outside of the <%! %> tags is converted to out.printlns inside the _jspService method (in place where they occured in the JSP, not where the method you want to do the rendering is called...)
    So unless I completely misunderstood your intent here, this apprach does not work.

  • Print Campaign letters sorted by ZIP code

    Hello SDN,
    we want to print out the letters of a Campaign soted by the ZIP Code. We have 6000 Business Partners in our Target Group. If we not print them sorted by ZIP Code we had to pay 0.45 Euro per letter. If we print them sorted by ZIP Code it costs us only 0.25 Euro. That are 1200 Euro in total.
    Is there a BAdI or Customizing which we can set up to get the output sorted by ZIP Code? I found no setting for our communication channel "Letter with Activity creation".
    Best regards
    Gregor

    Hello Christoph,
    the print is done through a Campaign Channel. It uses a stripped down Version of smartforms build in transaction CRMD_EMAIL. There is no BAdI which I could use to influence the sorting when the printing is started during Campaign execution.
    Regards
    Gregor

  • HELP NEED FOR INVOKING THE JAVA CODE INSIDE JSP

    Hello,
    any one knows how to Write a java code inside the .jsp files... please if any one knows it please ....help me .....

    hi .
    Use scriptlets , for example :
    <html>
    <%
    int x;
    for(x=1;x<=5;x++)
    out.println(x);
    %>
    </html>

Maybe you are looking for

  • Configuring Access Requests in SharePoint 2013

    Hello everyone. we built our SP2013 farm last year and just now taking a deep dive into it. One of the issues I have run into, is the site access request notifications. I can see the requests in SharePoint and grant access from there but no email not

  • Best HD Upgrade Strategy?

    I have a MacPro ("Early 2008") 2.8 GHz Quad Core 45-nm Intel Xeon E5462 2008 with 8GB RAM. I am running it as an office server with Mountain Lion Server. Two years ago I upgraded the two harddrives to 3TB each ... but at the time, did not install the

  • MCBZ report how to get total stock qty calculation?

    Dear Guru,         if i checking one material in Tcode:MMBE having unrestricted stock is 356 & reserved qty is 56. After this when i am executing report MCBZ-- Current stock reqmt list & get Total stock qty is 120 for same material. can any one tell

  • Opening up Word 2011 document and multiple documents open up

    Why is it that when I open up a Word 2011 document, it opens up multiple previous word documents.  How do I change this?

  • Simple but not for me.. Formatting question

    Is there a way to change to format from the Imovie format DV-NTSC to any of these 3g2, 3gp, 3gp2, 3gpp, 3p, asf, avi, divx, divx, dv, dvx, flv, gif, moov, mov, mp4, mpeg4, mpg4, mpe, mpeg, mpg, qt, swf, wmv, xvid. I have looked around and have not gr