Sorting a List containing Symbols?

Hi,
My problem relates to ordering results from a Hibernate query.
I'm using Hibernate to return all records from a specific database table in the form of a List. The query contains an "order by" clause, and so my results look something like this (results ordered firstly alphanumerically, then alphabetically):
1
2
9
A
B
C
Z
The "problem" occurs when I retrieve records that contain symbols. I was hoping that such records would appear at the beginning of my retrieved records, and indeed that is the case for the majority of symbols, i.e.
$
1
2
9
A
B
C
Z
However, for some reason, certain symbols are appearing at the END of my results. So my list of results looks something like this...
$
1
2
9
A
B
C
Z

I assume that this ordering is the default one for Oracle.
I want to sort my list of results so that ALL symbols appear at the beginning of the list. I was thinking about using some sort of Comparator, i.e.
List result = Collections.sort(q.list(), new YourComparator());
However, I'm not sure what code would go inside YourComparator() to compare symbols and order them accordingly. Perhaps comparing the ASCII codes might be an idea(?)
Another solution might be to loop through each of my results and add the symbols and "non symbols" to separate lists, then order each list separately and combine them at the end. However this would probably have a major processing overhead.
Any other (simpler) suggestions?
Thanks in advance.

If there are non-ASCII characters in your data, ASCII values probably won't do the job. If so, look at some of the static methods of the Character class. You should be able to build your own Comparator.

Similar Messages

  • Sort a 'std::list' containing classes/structures

    Hi all,
    I find that std::sort' cannot be used to sort 'std::list' because it requires a random access iterator which is not available for a list. Although that works for dqueue without any problem. Is any body know about any workaround for std::list sorting. I have one using template but i required without using template. ??
    Using template
    #include <iostream>
    #include <algorithm>
    #include <list>
    using namespace std;
    typedef struct xx {
    int a;
    int b;
    bool operator<(const xx& src) const;
    bool operator>(const xx& src) const;
    } X;
    bool xx::operator<(const xx& src) const
    if (b <= src.b) return true;
    return false;
    bool xx::operator>(const xx& src) const
    if (b > src.b) return true;
    return false;
    template<typename T>
    class PtrClass
    public:
    T *m_src;
    PtrClass(T &src):m_src(&src)
    bool operator<(const PtrClass& src) const
    return m_src->operator<(*src.m_src);
    bool operator>(const PtrClass& src) const
    return m_src->operator>(*src.m_src);
    int main()
    X o1 = {1, 9};
    X o2 = {2, 8};
    X o3 = {3, 7};
    list<PtrClass<X> > l;
    list<PtrClass<X> >::iterator it;
    l.push_back(o1);
    l.push_back(o2);
    l.push_back(o3);
    cout << " BEFORE ______"<<endl;
    for(it = l.begin(); it != l.end(); it++)
         cout << "Inside"<<endl;
    l.sort();
    cout << " AFTER ______"<<endl;
    for(it = l.begin(); it != l.end(); it++)
         cout << "Inside"<<endl;
    return 0;
    }

    1. You can use std::list::sort method.
    2. You can use std::set instead of std::list.

  • Alv list contains no data

    I am working with a custom table zscs_record.
    data is being fetched in the perform upload_workarea.
    but the list contains no data.
    there might be any problem with the display_log.
    if anybody plz can find where is the mistake full points will be rewarded.
    just copy the program and execute it.
    REPORT yreport1 LINE-SIZE 260
    NO STANDARD PAGE HEADING
    MESSAGE-ID zsc_supply_chain.
              T Y P E -  P O O L S                           *
    TYPE-POOLS: SLIS.
          C o n s t a n t    V A R I A B L E S                  *
    CONSTANTS: c_e                TYPE  char1        VALUE  'E',
               c_a                TYPE  char1        VALUE  'A',
               c_s                TYPE  char1        VALUE  'S',
               c_x                TYPE  char1        VALUE  'X',
               c_dynpro_0201(4)   TYPE  c            VALUE  '0201',
               c_prognam(12)      TYPE  c            VALUE  'SAPRCKM_MR22',
               c_dynpro_1000(4)   TYPE  c            VALUE  '1000',
               c_dynpro_0120(4)   TYPE  c            VALUE  '0120',
               c_okcode(10)       TYPE  c            VALUE  'BDC_OKCODE',
               c_entr(5)          TYPE  c            VALUE  '=ENTR',
               c_dummy(6)         TYPE  c            VALUE  '=DUMMY',
               c_down(5)          TYPE  c            VALUE  '=DOWN',
               c_save(5)          TYPE  c            VALUE  '=SAVE',
               c_back(5)          TYPE  c            VALUE  '=BACK',
               c_onli(5)          TYPE  c            VALUE  '=ONLI',
               c_ee(3)            TYPE  c            VALUE  '/EE',
               c_one              TYPE  ckml_kongr   VALUE  '1'   ,
               c_bkpf(4)          TYPE  c            VALUE  'BKPF',
               c_wfp              TYPE  bukrs        VALUE  'WFP',
               c_sa               TYPE  blart        VALUE  'SA',
               c_ags              TYPE  ktosl        VALUE  'AGS',
               c_usd              TYPE  waers_iso    VALUE  'USD',
               c_budat(14)        TYPE  c            VALUE  'MR21HEAD-BUDAT',
               c_bukrs(14)        TYPE  c            VALUE  'MR21HEAD-BUKRS',
               c_werks(14)        TYPE  c            VALUE  'MR21HEAD-WERKS',
               c_xblnr(14)        TYPE  c            VALUE  'MR21HEAD-XBLNR',
               c_kongr(14)        TYPE  c            VALUE  'CKMLKONT-KONGR',
               c_bktxt(14)        TYPE  c            VALUE  'MR21HEAD-BKTXT',
               c_mr22             TYPE  tstc-tcode   VALUE  'MR22',
               c_f13              TYPE  tstc-tcode   VALUE  'F.13',
               c_n(1)             TYPE  c            VALUE  'N',
               c_bag              TYPE  char9        VALUE  '%Bagging%',
               c_ltsh             TYPE  char12       VALUE  '%LTSH%Clear%',
               c_trnsf            TYPE  char30       VALUE  '%Transformation%Clear%',
               c_ste              TYPE  char20       VALUE  '%Stevedoring%Clear%',
               c_mat              TYPE  char30       VALUE  '%Material%Revaluation',
               c_mat1             TYPE  char8        VALUE  'MATERIAL',
               c_rev              TYPE  char10       VALUE  'REVOLUTION',
               c_tabname          TYPE  tabname      VALUE  'ZSCT_RECORD',
               c_prognam3(7)      TYPE  c            VALUE  'SAPF124',
               c_prognam4(8)      TYPE  c            VALUE  'SAPMSSY0',
               c_cursor(10)       TYPE  c            VALUE  'BDC_CURSOR',
               c_konts_low(9)     TYPE  c            VALUE  'KONTS-LOW',
               c_bukrx_low(9)     TYPE  c            VALUE  'BUKRX-LOW',
               c_saknr(7)         TYPE  c            VALUE  'X_SAKNR',
               c_augdt(5)         TYPE  c            VALUE  'AUGDT',
               c_testl(5)         TYPE  c            VALUE  'TESTL',
               c_xausbel(7)       TYPE  c            VALUE  'XAUSBEL',
               c_xnausbel(8)      TYPE  c            VALUE  'XNAUSBEL',
               c_fehler(8)        TYPE  c            VALUE  'X_FEHLER',
               c_mr21(23)         TYPE  c            VALUE  'MR21HEAD-SCREEN_VARIANT',
               c_lagmat(18)       TYPE  c            VALUE  'LAGERMATERIAL_0250',
               c_psp(30)          TYPE  c            VALUE  'PSP-ELEMENT - OHNE BWKEY_0250',
               c_ckmatnr(20)      TYPE  c            VALUE  'CKI_MR22_0250-MATNR(',
               c_ckzuumb(20)      TYPE  c            VALUE  'CKI_MR22_0250-ZUUMB(',
               c_ckpspnr(20)      TYPE  c            VALUE  'CKI_MR22_0250-PSPNR(',
               c_ckbwkey(20)      TYPE  c            VALUE  'CKI_MR22_0250-BWKEY(',
               c_sp(1)            TYPE  c            VALUE  ')',
               c_shkzg1           TYPE  shkzg        VALUE 'H',
               c_shkzg2           TYPE  shkzg        VALUE 'S',
    *For ALV column positions
            c_col_pos1            TYPE            sycucol             VALUE '01',
            c_col_pos2            TYPE            sycucol             VALUE '02',
            c_col_pos3            TYPE            sycucol             VALUE '03',
            c_col_pos4            TYPE            sycucol             VALUE '04',
            c_col_pos5            TYPE            sycucol             VALUE '05',
            c_col_pos6            TYPE            sycucol             VALUE '06',
            c_col_pos7            TYPE            sycucol             VALUE '07',
            c_col_pos8            TYPE            sycucol             VALUE '08',
            c_col_pos9            TYPE            sycucol             VALUE '09',
            c_col_pos10           TYPE            sycucol             VALUE '10',
            c_col_pos11           TYPE            sycucol             VALUE '11',
            c_col_pos12           TYPE            sycucol             VALUE '12',
            c_col_pos13           TYPE            sycucol             VALUE '13',
            c_col_pos14           TYPE            sycucol             VALUE '14',
            c_col_pos15           TYPE            sycucol             VALUE '15',
    *For ALV Field Names of final Table
            c_fld_recid           TYPE            slis_fieldname      VALUE  'RECID',          "Record ID number
            c_fld_kongr           TYPE            slis_fieldname      VALUE  'KONGR',          "Reason code
            c_fld_hkont           TYPE            slis_fieldname      VALUE  'HKONT',          "GL Account
            c_fld_projk           TYPE            slis_fieldname      VALUE  'PROJK',          "Project code
            c_fld_werks           TYPE            slis_fieldname      VALUE  'WERKS',          "Plant
            c_fld_matnr           TYPE            slis_fieldname      VALUE  'MATNR',          "Commodity
            c_fld_zcptp           TYPE            slis_fieldname      VALUE  'ZCPTP',          "Cose portion to be posted
            c_fld_zerrf           TYPE            slis_fieldname      VALUE  'ZERRF',          "Success flag
            c_fld_zerrc           TYPE            slis_fieldname      VALUE  'ZERRC',          "Error code
            c_fld_zertx           TYPE            slis_fieldname      VALUE  'ZERTX',          "Error txt
            c_fld_hkont1          TYPE            slis_fieldname      VALUE  'HKONT',
            c_fld_opbal           TYPE            slis_fieldname      VALUE  'OPBAL',
            c_fld_exp             TYPE            slis_fieldname      VALUE  'EXP',
            c_fld_cap             TYPE            slis_fieldname      VALUE  'CAP',
            c_fld_err             TYPE            slis_fieldname      VALUE  'ERR',
            c_table               TYPE            slis_tabname        VALUE  'i_log_disp'.
    *T Y P E S                                                            *
    *Structure for uploading the data for further processing
    TYPES: BEGIN OF t_zscs_record ,
               recid      TYPE zderecid,                       "Record id number
               zerrf      TYPE zdeerrf,                        "Processed \ not processed flag - FLAG X Success Blank
               cpudt      TYPE cpudt,                          "Day On Which Accounting Document Was Entered
               kongr      TYPE ckml_kongr,                     "Account Assignment Reason
               hkont      TYPE hkont,                          "General Ledger Account
               projk      TYPE char30,                          "WBS Element
               werks      TYPE werks_d,                        "Plant
               matnr      TYPE matnr,                          "Material Number
               zcptp      TYPE zdecptp,                        "cost portion to be posted
               belnr      TYPE belnr_d,                        "Accounting Document Number
               zerrc      TYPE zdeerrc,                        "Error code
               zertx      TYPE zdeertx,                        "Error text
               set        TYPE numc2,
           END OF t_zscs_record ,
    *Structre for modified WBS element
           BEGIN OF t_zscs_record_m ,
               recid      TYPE zderecid,                       "Record id number
               zerrf      TYPE zdeerrf,                        "Processed \ not processed flag - FLAG X Success Blank
               cpudt      TYPE cpudt,                          "Day On Which Accounting Document Was Entered
               kongr      TYPE ckml_kongr,                     "Account Assignment Reason
               hkont      TYPE hkont,                          "General Ledger Account
               projk      TYPE char24,
               werks      TYPE werks_d,                        "Plant
               matnr      TYPE matnr,                          "Material Number
               zcptp      TYPE zdecptp,                        "cost portion to be posted
               belnr      TYPE belnr_d,                        "Accounting Document Number
               zerrc      TYPE zdeerrc,                        "Error code
               zertx      TYPE zdeertx,                        "Error text
               set        TYPE numc2,
           END OF t_zscs_record_m,
    *Structure for retrieving data from custom table ZSCT_AUTOINV
           BEGIN OF t_zsct_autoinv,
               saknr      TYPE saknr,                          "G/L Account Number
               fipos      TYPE fm_fipex,                       "Commitment Item
               geber      TYPE bp_geber,                       "Fund
               saknr_off  TYPE saknr,                          "G/L Account Number
               fipos_off  TYPE fm_fipex,                       "Commitment Item
           END OF t_zsct_autoinv,
    *Structure for retrieving data from database table FMBDT
           BEGIN OF t_fmbdt,
               rldnr      TYPE rldnr,                          "Ledger
               rrcty      TYPE rrcty,                          "Record Type
               rvers      TYPE versn,                          "Version
               ryear      TYPE gjahr,                          "Fiscal Year
               robjnr     TYPE gobjnr_r,                       "Object number for objects (account assignment elements)
               cobjnr     TYPE gobjnr_c,                       "Object number for transaction attributes
               sobjnr     TYPE gobjnr_s,                       "Object number for partner objects (accnt assignmnt elements)
               rtcur      TYPE rtcur,                          "Currency Key
               drcrk      TYPE shkzg,                          "Debit/Credit Indicator
               rpmax      TYPE rpmax,                          "period
               rfund      TYPE fm_fund,                        "Fund
               rfundsctr  TYPE fistl,                          "Funds Center
               rmeasure   TYPE fm_measure,                     "Funded Program
           END OF t_fmbdt,
    *Structure for retrieveing data from table SKAT
           BEGIN OF t_skat,
               spras      TYPE spras,                          "Language Key
               ktopl      TYPE ktopl,                          "Chart of Accounts
               saknr      TYPE saknr,                          "G/L Account Number
               txt50      TYPE txt50_skat,                     "G/L Account Long Text
           END OF  t_skat,
    *Structure for tracking the errors occured during document posting
    *through standard BAPI
           BEGIN OF t_error_bapi,
               number     TYPE symsgno,
               message    TYPE bapi_msg,
               recid      TYPE zderecid,
               set        TYPE numc2,
           END OF t_error_bapi,
    *Structure for tracking the success occured during document posting
    *through standard BAPI
           BEGIN OF t_suc_bapi,
               belnr      TYPE belnr_d,
               message    TYPE bapi_msg,
               recid      TYPE zderecid,
               set        TYPE numc2,
           END OF t_suc_bapi,
    *Structure for tracking the errors occured during document posting
    *through MR22 transaction code
            BEGIN OF t_error_bdc,
               recid      TYPE zderecid,                       "Record id number
               number     TYPE symsgno,
               message    TYPE bapi_msg,
               set        TYPE numc2,
           END OF t_error_bdc,
    *Structure for tracking the document no. occured during successful posting
    *through MR22 transaction code
             BEGIN OF t_suc_bdc,
               recid      TYPE zderecid,                       "Record id number
               var        TYPE sy-msgv1,
               message    TYPE bapi_msg,
               set        TYPE numc2,
             END OF t_suc_bdc,
             BEGIN OF t_log_disp,
             recid      TYPE  zderecid,                       "Record id number
             kongr      TYPE  ckml_kongr,                     "Account Assignment Reason
             hkont      TYPE  hkont,                          "General Ledger Account
             projk      TYPE  char30,                         "WBS Element
             werks      TYPE  werks_d,                        "Plant
             matnr      TYPE  matnr,                          "Material Number
             zcptp      TYPE  zdecptp,                        "cost portion to be posted
             zerrf      TYPE  zdeerrf,                        "Processed \ not processed flag - FLAG X Success Blank
             zerrc      TYPE  zdeerrc,                        "Error code
             zertx      TYPE  zdeertx,                        "Error text
             hkont1     TYPE  hkont,
             opbal      TYPE  dmbtr,
             exp        TYPE  dmbtr,
             cap        TYPE  dmbtr,
             err        TYPE  dmbtr,
             END OF  t_log_disp.
    *Field symbols declared for BAPIRET2
    FIELD-SYMBOLS: <fs_return> TYPE bapiret2.
          G l o b a l   W O R K A R E A S                                     *
    DATA: w_zscs_record     TYPE t_zscs_record,
          w_zscs_record_mod TYPE t_zscs_record,
          w_fmbdt           TYPE t_fmbdt,
          w_bapi            TYPE t_zscs_record,
          w_bdc             TYPE t_zscs_record,
          w_temp            TYPE t_zscs_record,                 "#EC NEEDED
          w_bapiheader      TYPE bapiache09,
          w_return          TYPE bapiret2,
          w_accoutgl        TYPE bapiacgl09,
          w_currency        TYPE bapiaccr09,
          w_bdcdata         TYPE bdcdata,
          w_messtab         TYPE bdcmsgcoll,
          w_error_bapi      TYPE t_error_bapi,
          w_suc_bapi        TYPE t_suc_bapi,
          w_error_bdc       TYPE t_error_bdc,
          w_suc_bdc         TYPE t_suc_bdc,
          w_fieldcatalog    TYPE slis_fieldcat_alv,           "Workarea for populating fieldcatalog
          w_log_disp        TYPE t_log_disp.
            I n t e r n a l   T a b l e s                                     *
    DATA: i_zscs_record     TYPE  STANDARD TABLE OF t_zscs_record,
          i_zscs_record1    TYPE  STANDARD TABLE OF t_zscs_record,
          i_bapi            TYPE  STANDARD TABLE OF t_zscs_record,
          i_bdc             TYPE  STANDARD TABLE OF t_zscs_record,
          i_fmbdt           TYPE  STANDARD TABLE OF t_fmbdt,
          i_accoutgl        TYPE  STANDARD TABLE OF bapiacgl09,
          i_currency        TYPE  STANDARD TABLE OF bapiaccr09,
          i_return          TYPE  STANDARD TABLE OF bapiret2,
          i_bdcdata         TYPE  STANDARD TABLE OF bdcdata INITIAL SIZE 0,
          i_messtab         TYPE  STANDARD TABLE OF bdcmsgcoll INITIAL SIZE 0,
          i_bdcdata1        TYPE  STANDARD TABLE OF bdcdata INITIAL SIZE 0,
          i_messtab1        TYPE  STANDARD TABLE OF bdcmsgcoll INITIAL SIZE 0,"#EC NEEDED
          i_autoinv         TYPE  STANDARD TABLE OF t_zsct_autoinv,
          i_autoinv1        TYPE  STANDARD TABLE OF t_zsct_autoinv,
          i_error_bapi      TYPE  STANDARD TABLE OF t_error_bapi,
          i_suc_bapi        TYPE  STANDARD TABLE OF t_suc_bapi,
          i_error_bdc       TYPE  STANDARD TABLE OF t_error_bdc,
          i_suc_bdc         TYPE  STANDARD TABLE OF t_suc_bdc,
          i_fieldcatalog    TYPE  slis_t_fieldcat_alv,
          i_log_disp        TYPE STANDARD TABLE OF t_log_disp.              "internal table for final log display
          G l o b a l   V A R I A B L E S                                     *
    DATA: v_rec          TYPE      string,
          v_rec1         TYPE      string,
          v_count        TYPE      numc2    VALUE 1,
          v_flag         TYPE      char1,                                "#EC NEEDED
          v_subrc        TYPE      sysubrc,
          v_objkey       TYPE      awkey,
          v_amt          TYPE      zdecptp,
          v_txt50        TYPE      txt50_skat,
          v_pspid        TYPE      ps_pspid,                             "#EC NEEDED
          v_totexppe     TYPE      zdecptp,
          v_totcapit     TYPE      zdecptp,
          v_toterror     TYPE      zdecptp,
          v_todmbtr      TYPE      dmbtr,
          v_repid        TYPE      sy-repid.
          S E L E C T I O N - S C R E E N   D E F I N I T I O N          *
                     S E L E C T I O N - S C R E E N                     *
    *Begin of inv selection block
    SELECTION-SCREEN BEGIN OF BLOCK inv WITH FRAME TITLE text-001.
    PARAMETERS: p_pstdat  TYPE budat DEFAULT sy-datum,                               "Posting Date
                p_rtmode AS CHECKBOX DEFAULT c_x,                                    "Run in test mode
                p_prsall RADIOBUTTON GROUP rad DEFAULT 'X' USER-COMMAND com,         "Process All
                p_cstcpt RADIOBUTTON GROUP rad,                                      "Process cost to be capitalized
                p_cstexp RADIOBUTTON GROUP rad,                                      "Process cost to be expensed
                p_exauto AS CHECKBOX.                                                "Execute Automatic Clearing
    SELECTION-SCREEN END OF BLOCK inv.
    *End of inv selection block
           I N I T I A L I Z A T I O N                                        *
    INITIALIZATION.
    Subroutine for clearing the memory space
      PERFORM clear_memory.                                                          "To clear the memory space.
           A T   S E L E C T I O N - S C R E E N  O U T P U T                 *
    AT SELECTION-SCREEN OUTPUT.
    For checking the Clearing program through transaction code F.13 only
    when user selects the radio button Process All
      IF p_prsall = c_x.                                           "Process All
        p_exauto = c_x.                                            "Execute Automatic Clearing
      ELSE.
        p_exauto = ' '.                                            "Execute Automatic Clearing
      ENDIF.
      MODIFY SCREEN.
                              START OF SELECTION              *
    START-OF-SELECTION.
    Subroutine for uploading data from custom database table
    ZSCT_RECORD based on the condition selected by user
      PERFORM upload_workarea.
                              END OF SELECTION                 *
    END-OF-SELECTION.
    Subroutine for populating the respective internal tables
    for posting the documents either through standard BAPI or MR22 transaction code
      PERFORM populate_bapi_bdc.
      IF NOT i_bapi[] IS INITIAL.
    Subroutine for posting documents through standard BAPI
        PERFORM post_bapi.
      ENDIF.
    IF NOT i_bdc[] IS INITIAL.
    Subroutine for posting documents through MR22 transaction code
        PERFORM call_transaction_mr22.
      ENDIF.
    Subroutine for automatic clearing
      IF p_exauto = c_x.
        PERFORM clear_f13.
      ENDIF.
    IF ( ( i_error_bapi IS NOT INITIAL ) OR ( i_error_bdc IS NOT INITIAL ) ).
    Subroutine for displaying the log file
      PERFORM display_log.
    ENDIF.
      PERFORM FINAL_list.
    *&      Form  CLEAR_MEMORY
          text
    form CLEAR_MEMORY.
    Refreshing the global internal tables
      REFRESH: i_zscs_record,
               i_zscs_record1,
               i_bapi,
               i_bdc,
               i_fmbdt,
               i_accoutgl,
               i_currency,
               i_return,
               i_bdcdata,
               i_messtab,
               i_bdcdata1,
               i_messtab1,
               i_autoinv,
               i_error_bapi,
               i_suc_bapi,
               i_error_bdc,
               i_suc_bdc.
    Clearing the global work areas
      CLEAR:   w_zscs_record,
               w_zscs_record_mod,
               w_fmbdt,
               w_bapi,
               w_bdc,
               w_temp,
               w_bapiheader,
               w_return,
               w_accoutgl,
               w_currency,
               w_bdcdata,
               w_messtab,
               w_error_bapi,
               w_suc_bapi,
               w_error_bdc,
               w_suc_bdc,
    *Clearing the global variables
               v_rec,
               v_rec1,
               v_flag,
               v_subrc,
               v_objkey,
               v_amt,
               v_pspid.
    endform.                    " CLEAR_MEMORY
    *&      Form  UPLOAD_WORKAREA
       Subroutine for uploading data from custom database table          *
          ZSCT_RECORD based on the condition selected by user            *
    form UPLOAD_WORKAREA .
      IF p_prsall = c_x.
    Selecting the non processed data from table ZSCT_RECORD
        SELECT  recid                                       "#EC CI_NOFIRST         "Record id number
                zerrf                                                               "Processed\not processed flag
                cpudt                                                               "Day On Which Accounting Document Was Entered
                kongr                                                               "Account Assignment Reason
                hkont                                                               "General Ledger Account
                projk                                                               "WBS Element
                werks                                                               "Plant
                matnr                                                               "Material Number
                zcptp                                                               "cost portion to be posted
                belnr                                                               "Accounting Document Number
                zerrc                                                               "Error code
                zertx                                                               "Error text
        FROM zsct_record
        INTO TABLE i_zscs_record
        WHERE zerrf NE space
        AND cpudt = '20081022'.
        IF sy-subrc NE 0.
          MESSAGE  text-021 TYPE 'I'.
          LEAVE LIST-PROCESSING.
        ENDIF.
      ELSEIF p_cstcpt = c_x.
    Selecting the non processed data from table ZSCT_RECORD
        SELECT  recid                                       "#EC CI_NOFIRST
                zerrf
                cpudt
                kongr
                hkont
                projk
                werks
                matnr
                zcptp
                belnr
                zerrc
                zertx
        FROM zsct_record
        INTO TABLE i_zscs_record
        WHERE zerrf NE space
        AND   kongr <> c_e.
        IF sy-subrc NE 0.
          MESSAGE  text-021 TYPE 'I'.
          LEAVE LIST-PROCESSING.
        ENDIF.
      ELSEIF p_cstexp = c_x.
    Selecting the non processed data from table ZSCT_RECORD
        SELECT  recid                                        "#EC CI_NOFIRST
                zerrf
                cpudt
                kongr
                hkont
                projk
                werks
                matnr
                zcptp
                belnr
                zerrc
                zertx
        FROM zsct_record
        INTO TABLE i_zscs_record
        WHERE zerrf NE space
        AND   kongr EQ c_e.
        IF sy-subrc NE 0.
          MESSAGE  text-021 TYPE 'I'.
          LEAVE LIST-PROCESSING.
        ENDIF.
      ENDIF.
      IF sy-subrc = 0.
    Sort the internal table by record id
        SORT i_zscs_record BY recid.
      ENDIF.
    endform.                    " UPLOAD_WORKAREA
    *&      Form  POPULATE_BAPI_BDC                   *
    Subroutine for posting documents through standard BAPI   *
    FORM populate_bapi_bdc.
      DATA: v_tabix TYPE sy-tabix.
    Sort the data retrieved from ZSCT_RECORD by KONGR,HKONT & PROJK
      SORT i_zscs_record BY kongr hkont projk.
      IF NOT i_zscs_record IS INITIAL.
        LOOP AT i_zscs_record INTO w_zscs_record_mod.
          v_tabix = sy-tabix.
      Check if the record id is initial
          IF NOT w_zscs_record_mod-recid IS INITIAL.
            CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
              EXPORTING
                input  = w_zscs_record_mod-recid
              IMPORTING
                output = w_zscs_record-recid.
          ENDIF.
      Check if the reason code is initial
          IF NOT w_zscs_record_mod-kongr IS INITIAL.
            CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
              EXPORTING
                input  = w_zscs_record_mod-kongr
              IMPORTING
                output = w_zscs_record-kongr.
          ENDIF.
      Assign the values
          w_zscs_record-hkont = w_zscs_record_mod-hkont.
          CALL FUNCTION 'CONVERSION_EXIT_ABPSP_OUTPUT'
            EXPORTING
              input  = w_zscs_record_mod-projk
            IMPORTING
              output = w_zscs_record-projk.
          w_zscs_record-werks = w_zscs_record_mod-werks.
          w_zscs_record-matnr = w_zscs_record_mod-matnr.
          w_zscs_record-zcptp = w_zscs_record_mod-zcptp.
          w_zscs_record-cpudt = w_zscs_record_mod-cpudt.
      Concatenate  KONGR,HKONT & PROJK value to make an unique combination to populate the separete
      internal table relevant for posting through BAPI and MR22 transaction
          CONCATENATE w_zscs_record-kongr w_zscs_record-hkont w_zscs_record-projk INTO v_rec.
          IF v_tabix NE 1.
            IF v_rec1 = v_rec.
              v_count = v_count.                                "#EC NEEDED
            ELSE.
              v_count = v_count + 1.
            ENDIF.
          ENDIF.
      Populate the set number into the two different internal table
      relevant for posting through BAPI and MR22 transaction
          w_zscs_record-set = v_count.
      If the KONGR (Reason code) value is equal to 'E' then the
      posting will be occur through standard BAPI
          IF w_zscs_record-kongr = c_e.
            APPEND w_zscs_record TO i_bapi.
      If the KONGR (Reason code) value is not equal to 'E' then the
      posting will be occur through MR22 transaction code
          ELSEIF w_zscs_record-kongr NE c_e.
            APPEND w_zscs_record TO i_bdc.
          ENDIF.
          v_rec1 = v_rec.
      Clear the memory
          CLEAR: w_zscs_record,
                 v_rec.
        ENDLOOP.
      ENDIF.
    endform.                    " POPULATE_BAPI_BDC
    *&      Form  POST_BAPI
          text
    form POST_BAPI .
    Local structre declaration
      TYPES:
          Structre for populating record id
            BEGIN OF lt_recid,
              recid TYPE zderecid,
             END OF   lt_recid,
           Structre for table PRPS
             BEGIN OF lt_prps,
              pspnr      TYPE ps_intnr,           "WBS Element
              posid      TYPE ps_posid,           "Work Breakdown Structure Element (WBS Element)
              pgsbr      TYPE ps_pgsbr,           "Business area for WBS element
              func_area  TYPE fkber,              "Functional Area
             END OF lt_prps .
    Local data declaration
      DATA: lw_bapi    TYPE t_zscs_record,
            lw_bapi1   TYPE t_zscs_record,
            lw_recid   TYPE lt_recid,
            li_recid   TYPE STANDARD TABLE OF lt_recid,         "#EC NEEDED
            li_prps    TYPE STANDARD TABLE OF lt_prps,
            lw_prps    TYPE lt_prps,
            li_temp    TYPE STANDARD TABLE OF t_zscs_record,
            li_temp1   TYPE STANDARD TABLE OF t_zscs_record,
            li_bapi    TYPE STANDARD TABLE OF t_zscs_record,
            li_bapi_m  TYPE STANDARD TABLE OF t_zscs_record_m,
            lw_bapi_m  TYPE t_zscs_record_m,
            li_skat    TYPE STANDARD TABLE OF t_skat,
            li_skat1   TYPE STANDARD TABLE OF t_skat,
            li_skat2   TYPE STANDARD TABLE OF t_skat,
            lw_temp    TYPE t_zscs_record,
            li_autoinv TYPE STANDARD TABLE OF t_zsct_autoinv,
            lw_autoinv TYPE t_zsct_autoinv,
            lv_count   TYPE numc10,
            lw_skat    TYPE t_skat,
            lw_skat1   TYPE t_skat,                             "#EC NEEDED
            lw_skat2   TYPE t_skat,                             "#EC NEEDED
            lv_count1  TYPE numc10,
            lw_index   TYPE sy-index.
    Assigning the I_BAPI data to a local internal table
      li_temp[] = i_bapi[].
      li_bapi[] = i_bapi[].
      li_temp1[] = i_bapi[].
    Sort the internal table by SET
      SORT i_bapi BY set.
    Sort the internal table LI_TEMP by SET
      SORT li_temp BY set.
    Delete adjacent duplicates from LI_TEMP compring SET
      DELETE ADJACENT DUPLICATES FROM li_temp COMPARING set.
    Sort the internal table LI_TEMP1 by PROJK
      SORT li_temp1 BY projk.
    Delete adjacent duplicates from LI_TEMP1 compring PROJK
      DELETE ADJACENT DUPLICATES FROM li_temp1 COMPARING projk.
    Sort the internal table LI_BAPI by HKONT
      SORT li_bapi BY hkont.
    Delete adjacent duplicates from LI_BAPI compring HKONT
      DELETE ADJACENT DUPLICATES FROM li_bapi COMPARING hkont.
    Check if the li_bapi is initial or not
      IF NOT li_bapi[] IS INITIAL.
    Retrieve the text information from database table SKAT
    for all the G/L Account relevant to LTSH Overland Clearing Account/
    Transformation Clearing / Stevedoring Clearing Account / Bagging Clearing Account
        SELECT  spras                                     "#EC CI_SGLSELECT
                ktopl
                saknr
                txt50
          FROM skat
          INTO TABLE li_skat
          FOR ALL ENTRIES IN li_bapi
          WHERE spras = c_e
          AND   saknr = li_bapi-hkont
           AND ( txt50 LIKE c_bag
             OR  txt50 LIKE c_ltsh
             OR  txt50 LIKE c_trnsf
             OR  txt50 LIKE c_ste
             OR  txt50 LIKE c_mat ).
        IF sy-subrc EQ 0.
          SORT li_skat1 BY saknr.
        ENDIF.
    Spiliting the internal table with respect to the TXT50
        LOOP AT li_skat INTO lw_skat.
          v_txt50 = lw_skat-txt50.
          TRANSLATE v_txt50 TO UPPER CASE.                    "#EC SYNTCHAR
          IF v_txt50 CS c_mat1 AND
             v_txt50 CS c_rev.
         Internal table regaring all the G/L Account relevant to Material revolution Account
            APPEND lw_skat TO li_skat2.
          ELSE.
         Internal table regaring all the G/L Account relevant to LTSH Overland Clearing Account/
         Transformation Clearing / Stevedoring Clearing Account / Bagging Clearing Account
            APPEND lw_skat TO li_skat1.
          ENDIF.
          CLEAR: lw_skat,
                 v_txt50.
        ENDLOOP.
        REFRESH: li_skat.
      Retrieve required data from custom table ZSCT_AUTOINV
        SELECT saknr
               fipos
               geber
               saknr_off
               fipos_off
          FROM zsct_autoinv
          INTO TABLE li_autoinv
           FOR ALL ENTRIES IN li_bapi
           WHERE saknr = li_bapi-hkont.
        IF sy-subrc = 0.
      Sort li_autoinv by GEBER
          i_autoinv1 = li_autoinv.
          SORT li_autoinv BY geber.
      Delete adjacent duplicates from li_autoinv comparing GEBER
          DELETE ADJACENT DUPLICATES FROM li_autoinv COMPARING geber.
        ENDIF.
        IF NOT li_autoinv[] IS INITIAL.
      Retrieve required data from database table FMBDT
          SELECT  rldnr
                  rrcty
                  rvers
                  ryear
                  robjnr
                  cobjnr
                  sobjnr
                  rtcur
                  drcrk
                  rpmax
                  rfund
                  rfundsctr
                  rmeasure
            FROM fmbdt                                      "#EC CI_NOFIRST
          INTO TABLE i_fmbdt
          FOR ALL ENTRIES IN li_autoinv
          WHERE ryear = p_pstdat+0(4)
          AND   rfund = li_autoinv-geber.
        ENDIF.
        IF sy-subrc = 0.
          SORT i_fmbdt BY rfund.
        ENDIF.
      ENDIF.
    Populate the internal table with the modified WBS element
    value for further processing
      LOOP AT i_bapi INTO w_bapi.
        lw_bapi_m-recid = w_bapi-recid.
        lw_bapi_m-zerrf = w_bapi-zerrf.
        lw_bapi_m-cpudt = w_bapi-cpudt.
        lw_bapi_m-kongr = w_bapi-kongr.
        lw_bapi_m-hkont = w_bapi-hkont.
        lw_bapi_m-projk = w_bapi-projk.
        lw_bapi_m-werks = w_bapi-werks.
        lw_bapi_m-matnr = w_bapi-matnr.
        lw_bapi_m-zcptp = w_bapi-zcptp.
        lw_bapi_m-belnr = w_bapi-belnr.
        lw_bapi_m-zerrc = w_bapi-zerrc.
        lw_bapi_m-zertx = w_bapi-zertx.
        lw_bapi_m-set   = w_bapi-set.
        APPEND lw_bapi_m TO li_bapi_m.
        CLEAR: lw_bapi_m.
      ENDLOOP.
    Sort LI_BAPI_M by WBS element
      SORT li_bapi_m BY projk.
    Delete adjacent duplicates from LI_BAPI_M comparing WBS element
      DELETE ADJACENT DUPLICATES FROM li_bapi_m COMPARING projk.
    Check if LI_BAPI_M is initial
      IF NOT li_bapi_m[] IS INITIAL.
    Retrieve the required data from table PRPS for all the
    WBS element
        SELECT  pspnr
                posid
                pgsbr
                func_area
           FROM prps
           INTO TABLE li_prps
           FOR ALL ENTRIES IN li_bapi_m
           WHERE posid = li_bapi_m-projk.
        IF sy-subrc = 0.
          SORT li_prps BY posid.
        ENDIF.
      ENDIF.
      lw_index = 1.
      LOOP AT li_temp INTO lw_temp.
        w_temp = lw_temp.
      clearing workares
        CLEAR: w_bapiheader,
               lv_count,
               v_amt.
    ****Populating the BAPIHEADER*******
      Reference Transaction
        w_bapiheader-bus_act    = c_bkpf.
      User Name
        w_bapiheader-username   = sy-uname.
      Document Header Text
        w_bapiheader-header_txt = text-020.
      Company Code
        w_bapiheader-comp_code  = c_wfp.
      Document Date in the Document
        w_bapiheader-doc_date   = p_pstdat.
      Posting Date in the Document
        w_bapiheader-pstng_date = p_pstdat.
      Fiscal Year
        w_bapiheader-fisc_year  = p_pstdat+0(4).
      Fiscal Period
        w_bapiheader-fis_period = p_pstdat+4(2).
      Document Type
        w_bapiheader-doc_type   = c_sa.
      Reference Document Number
        w_bapiheader-ref_doc_no = sy-datum.
      Initialize the counter
        lv_count = 1.
        lv_count1 = 1.
        LOOP AT i_bapi INTO lw_bapi FROM lw_index.
          IF lw_temp-set NE lw_bapi-set.
            lw_index = sy-tabix.
            EXIT.
          ELSE.
            lw_bapi1 = lw_bapi.
            CLEAR: v_pspid.
            READ TABLE li_prps INTO lw_prps WITH KEY posid = lw_bapi-projk BINARY SEARCH.
            IF sy-subrc = 0.
              w_accoutgl-bus_area    = lw_prps-pgsbr.
              w_accoutgl-func_area   = lw_prps-func_area.
            ENDIF.
    *****Populating the internal table regarding G/L account item***********
            w_accoutgl-itemno_acc  = lv_count.
            w_accoutgl-acct_key    = c_ags.
            w_accoutgl-acct_type   = c_s.
            w_accoutgl-grant_nbr   = text-019.
            w_accoutgl-wbs_element = lw_bapi-projk.
            READ TABLE i_autoinv1  INTO lw_autoinv WITH KEY saknr = lw_bapi-hkont.
            IF sy-subrc = 0.
          Get the information for the G/L accounts relevant for LTSH OVERland Clearing account or
          Transformation Clearing Account Stevedoring Clearing Account or Bagging Clearing Account
              READ TABLE li_skat1 INTO lw_skat1 WITH KEY saknr = lw_autoinv-saknr BINARY SEARCH.
              IF sy-subrc = 0.
                w_accoutgl-gl_account  = lw_bapi-hkont.
                IF NOT lw_autoinv-fipos EQ space.
                  CALL FUNCTION 'CONVERSION_EXIT_FMCIS_INPUT'
                    EXPORTING
                      input  = lw_autoinv-fipos
                    IMPORTING
                      output = w_accoutgl-cmmt_item.
                ELSE.
                  w_accoutgl-cmmt_item   = lw_autoinv-saknr.
                ENDIF.
                w_currency-amt_doccur   =  lw_bapi-zcptp * ( -1 ).
              ENDIF.

    Debug. and find the problem . since you are not using the standadrd tables , they are custom tables. so try to find the reason using debugging. may be you don't have data which satisfies the selection criteria.

  • Help with using mergesort to sort a list of names alphabetically?

    Hi, I'm trying to sort a list of names alphabetically, case-insensitive by using the mergesort technique.
    I wrote this code and when I trace it through on paper with an example array of names, it should work, but when I run it with an actual txt file, it's not correctly alphabetical.
    I'd appreciate it if someone could take a look at my code and give me some ideas on what my problem might be.
    Thanks in advance! (note: I also posted this question to java-forums.org, as I've been working on this little problem for over five hours and am in desperate need of some help!)
    public static void mergeSort(String[] names) 
            if (names.length >= 2) 
                String[] left = new String[names.length/2]; 
                String[] right = new String[names.length-names.length/2]; 
                for (int i = 0; i < left.length; i++) 
                    left[i] = names;
    for (int i = 0; i < right.length; i++)
    right[i] = names[i + names.length/2];
    mergeSort(left);
    mergeSort(right);
    merge(names, left, right);
    // pre : result is empty; list1 is sorted; list2 is sorted
    // post: result contains result of merging sorted lists;
    // add merge method below
    public static void merge(String[] names, String[] left, String[] right)
    int i1 = 0;
    int i2 = 0;
    for (int i = 0; i < names.length; i++)
    if (i2 >= right.length || (i1 < left.length && left[i1].compareToIgnoreCase(right[i1])<0))
    names[i] = left[i1];
    i1++;
    } else
    names[i] = right[i2];
    i2++;

    Welcome to the forum.
    Please read this to learn hot to format your code (and other things relevant for this forum):
    https://forums.oracle.com/forums/ann.jspa?annID=1535
    923566 wrote:
    Hi, I'm trying to sort a list of names alphabetically, case-insensitive by using the mergesort technique.
    I wrote this codeDo you know the <tt>TreeSet</tt> class?
    http://docs.oracle.com/javase/7/docs/api/java/util/TreeSet.html
    With that sorting Strings is a two liner:
    http://www.java2s.com/Code/Java/Collections-Data-Structure/TreeSetDemo.htm
    bye
    TPD

  • LINQ sorting on List Object - Various Object Type

    I try to sort a List<Object> where the Object are different classes but all share the same Property Name for instance.
    I got a Base Class where Class A and Class B inherit from the Base Class.
    So during the Linq query I cannot specify with object type this is.
    Problem here "from ?????Entry_Global?????? list in Entries"
    Thanks for helping.
    ////Entries is a List<Object> which consist of class object as following\\\\\
    public abstract class EntryBase<T>
    private string _Name;
    public string Name
    get { return this._Name; }
    set { this.SetProperty(ref this._Name, value); }
    public class Entry_Global : EntryBase<Entry_Global>
    public class Entry_CC : EntryBase<Entry_CC>
    private string _url; //Web url
    public string Url
    get { return this._url; }
    set { this.SetProperty(ref this._url, value.Contains("http") ? value : "http://" + value); }
    public List<Object> SortBy()
    IEnumerable<KeyedList<string, object>> groupedEntryList = null;
    //The proble reside in the fact that list is not only one type
    //so when comes in the orderby "Name" it doesn't know Name
    //or any other properties which are all common to all those class
    //It does not want to convert Entry_CC or Entry_Global to EntryBase
    groupedEntryList =
    from ?????Entry_Global?????? list in Entries
    orderby list.Name
    orderby list.CategoryRef.Name
    group list by list.CategoryRef.Name into listByGroup
    select new KeyedList<string, object>(listByGroup);
    return groupedEntryList.ToList<object>();

    Entry_Global and Entry_CC don't share the same base class since EntryBase<Entry_Global> and EntryBase<Entry_CC> are two totally different types so you cannot cast the objects in the List<object> to a common base class in this case.
    You could cast from object to dynamic though:
    public List<Object> SortBy()
    List<object> objects = new List<object>();
    objects.Add(new Entry_Global { Name = "K" });
    objects.Add(new Entry_CC { Name = "A" });
    objects.Add(new Entry_Global { Name = "I" });
    objects.Add(new Entry_CC { Name = "C" });
    var sortedObjectsByName = (from o in objects
    let t = (dynamic)o
    orderby t.Name
    select o).ToList();
    return sortedObjectsByName;
    The dynamic keyword makes a type bypass static type checking at compile-time:
    https://msdn.microsoft.com/en-us/library/dd264736.aspx. This basically means that a dynamic type is considered to have any property of any name at compile time. Of course you will get an exception at runtime if the type doesn't have a Name property but
    providied that all objects in the List<T> to be sorted are of type EntryBase<T> you will be safe as long as the EntryBase<T> type defines the Name property that you sort by.
    Please remember to close your threads by marking helpful posts as answer and please start a new thread if you have a new question.

  • Sorting linked lists - Help

    I am writing a program for an assignment that reads a file containing population growth for all the Counties in the U.S. I'm required to use a link list to store the data. They want me to sort the data based on certain criteria. My first problem is that as each new County instance is created, it is to be inserted into this linked list in alphabetical order first by county name.
    My understanding of linked lists is that they cannot be randomly accessed like a vector or an array. So is it possible to do this without using a vector or an array? And how would I go about it?
    thanks.

    Can you create a second, sorted linked list?The prof. didn't specify whether or not I can use a second list.
    Are you prohibited from using the collections framework (probably, if it is a school assignment!)Not really sure on this one. Again it is not specified in the assignment
    (Why would they have you store this data in a linked list??)I their reasoning is to have us learn how to implement linked list because it can grow or shrink when necessary.(Other than that I don't understand the practicality of it either)
    Are you using a doubly linked list (forwards and backwards)?The assignment does not specify a certain linked list to use.
    Did your prof mention any sort algorithms you might use? He states later in the assignment that I have to generate different growth reports by using MergeSort.
    I appreciate your help and comments. Unfortunately my prof. is very vague about the assignment and its implementation in his outline. He just kind of throws us into it hoping that we will figure it out.

  • Sorting a List object

    Hi!
    I have a List object or component (java.awt.List) in my app.
    I try to order it using Collections.sort(my_list) but I recieve this message which I dont understand:
    The method sort(List<T>) in the type Collections is not applicable for the arguments (List)
    By the way, I would like to order it using a numeric order, not an ascii order, so I guess I have to use "implements Comparable", but how can I use that if my List contains Strings?
    I mean, my List has:
    20 bla bla
    9 bla bla
    and I want this:
    9 bla bla
    20 bla bla bla
    Any advice?
    Thanks a lot for your time.
    Edited by: Ricardo_Ruiz_Lopez on Dec 26, 2007 9:27 AM

    You are mixing up two different kinds of Lists. One is the AWT List (java.awt.List) which is what you are using and can be thought of more as a visual component.
    http://java.sun.com/javase/6/docs/api/java/awt/List.html
    The other is the utility Collections List (java.util.List) which is purely a data construct.
    http://java.sun.com/javase/6/docs/api/java/util/List.html
    So, bottom line is, the Collections.sort( ) won't work with the AWT list. You'll have to extract your data model which I think may be a String[] and sort that, then possibly re-insert with add(String item, int index) (I'm not sure on this part).
    Edited by: Encephalopathic on Dec 26, 2007 9:44 AM

  • How to make List.contains(Object) work when you write your own .equals func

    I have a list of objcts of a class defined by me. I want to use the List.contains(String name) function to tell me if it contains an object of that name. I have overriden the .equals function as shown in [1]. I then use the code at [2] to to test it, with a bit of debugger output as shown in [3]. It is not working, my overriden method is not getting called by List.contains(String name).
    Can anyone tell me how to get this to work?
    [1]     @Override public boolean equals(Object esId) {
            if(esId.getClass().isAssignableFrom(String.class)) {
                System.out.println("object name " + this.eslimId + " compare to " + esId + " = " + this.eslimId.equals(esId));
                return this.eslimId.equals(esId);
            } else {
                System.out.println("wrong class");
                return super.equals(esId);
        }[2] graphics.getProcedures() returns private List<ProcedureGraphicSet> procedures;
    System.out.println( " graphics.getProcedures().get(0).equals(\"ESLIM_009\")= " + graphics.getProcedures().get(0).equals("ESLIM_009"));
    System.out.println( " graphics.getProcedures().contains(\"ESLIM_009\")= " + graphics.getProcedures().contains("ESLIM_009"));[3]
    object name ESLIM_009 compare to ESLIM_009 = true
    graphics.getProcedures().get(0).equals("ESLIM_009")= true
    graphics.getProcedures().contains("ESLIM_009")= false

    This is a gross violation of the contract for the equals method, and you are basically getting bitten by that. The equals method must be symmetric, meaning this must hold for all objects A and B:
    A.equals(B) == B.equals(A)This does not hold for your equals method because for any string A and custom object B:
    A.equals(B) == falseAnd, apparently, the List.contains() method is choosing to compare objects that way.
    You must iterate through the list and check the names yourself, or use some sort of functional package which provides a List.contains() type method which takes a Predicate object of some sort.
    Edited by: jtahlborn on Feb 11, 2008 11:03 AM
    Edited by: jtahlborn on Feb 11, 2008 11:03 AM

  • How to sort a list with numbers?

    Hi!
    How do i sort a list like this:
    ["Amningsnapp 6.c", "Anti-Colic Nappflaska 6.b", "Barn/Baby Underjams Girls 5.b", "Hår Gummisnodd 1.c", "Leksaker 7.a", "Pincett 2.a", "Protes Rengöring 3.a", "Sprayflaska Plast 4.b"]
    ...so that I get a list in number order like this instead:
    ["Hår Gummisnodd 1.c","Pincett 2.a","Protes Rengöring 3.a","Sprayflaska Plast 4.b","Barn/Baby Underjams Girls 5.b","Anti-Colic Nappflaska 6.b","Amningsnapp 6.c","Leksaker 7.a"]
    On mouseUp
    currentItem = the mouseLine
      if the doubleClick = TRUE then
        handlingslista.add (field(12).line[currentItem])
        sort handlingslista
        set x = count (handlingslista)
        repeat with i = 1 to x
          put handlingslista[i] into member(17).line[i]
        end repeat
      end if
    end
    --This is what the list handlingslista contains:
    ["Amningsnapp 6.b", "Anti-Colic Nappflaska 6.b", "Barn/Baby Underjams Girls 5.b", "Hår Gummisnodd 1.c", "Leksaker 7.a", "Pincett 2.a", "Protes Rengöring 3.a", "Sprayflaska Plast 4.b"]

    Assuming the number always occurs as the last word, you could temporarily store the items in the form ["6.c", "Hår Gummisnodd 1.c"], therefore resulting them being sorted lexicographically based on the last word, like this:
    handlingslista = ["Amningsnapp 6.c", "Anti-Colic Nappflaska 6.b", "Barn/Baby Underjams Girls 5.b", "Hår Gummisnodd 1.c", "Leksaker 7.a", "Pincett 2.a", "Protes Rengöring 3.a", "Sprayflaska Plast 4.b"]
    repeat with n = handlingslista.count down to 1
      handlingslista[n] = [the last word of handlingslista[n], handlingslista[n]]
    end repeat
    handlingslista.sort()
    repeat with n = handlingslista.count down to 1
      handlingslista[n] = handlingslista[n][2]
    end repeat
    put handlingslista
    -- ["Hår Gummisnodd 1.c", "Pincett 2.a", "Protes Rengöring 3.a", "Sprayflaska Plast 4.b", "Barn/Baby Underjams Girls 5.b", "Anti-Colic Nappflaska 6.b", "Amningsnapp 6.c", "Leksaker 7.a"]
    Alternatively, you could use Javascript, in which Arrays can be sorted based on an arbitrary ordering: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/sort.

  • Sorting a list of different class objects

    Hi All ,
    How to sort a List a.which contains objects of different Classes, b. objects of same class . Is it possible to sort these by implementing Comparable interface .
    Thanks ,
    Rajesh Reddy

    rajeshreddyk wrote:
    Hi All ,
    How to sort a List a.which contains objects of different Classes, b. objects of same class . Is it possible to sort these by implementing Comparable interface .Well, if objects of different classes are kept in the same List and you want to sort them together they at least have that in common. They're Comparable-able. -:) To manifest that the different classes could all implement a Comparableable interface (or maybe Intercomparable would be a better choise of name.)

  • Sort Xml list

    Hello,
    I am trying to learn actionscript 3 for work and have a very
    specific project I need it for. I have been searching every
    available tutorial have bought a few books to read but I cannot
    find out how to do a few simple things.
    The main thing I need to do right now is sort an xml list by
    the date of an event before I start picking which nodes to display.
    (<dt_event_start>) I need the function to be able to sort by
    date or by alpha for a different xml list I will be sorting later,
    not both at the same time, just one or the other. My code is sparse
    right now, all it does is pick events in a certain city and write
    them all in one big list to a text box on screen. Later I will have
    to separate out each part to make a header for each event and
    choose which nodes to display, so i need to sort the xml list
    before I start displaying the nodes in separate text boxes within a
    larger container repeated with a loop through the list.
    included is one xml entry and the as3 code i have so far
    Any help would be greatly appreciated and then I can go
    looking for the other code I need.

    This thread was "imported" from the old forums -- most, if not all, code seems to have disappeared. But here are the sort functions I posted:
    function sortXML(source:XML, elementName:Object, fieldName:Object,
    options:Object = null):XML
         // list of elements we're going to sort
         var list:XMLList=source.elements("*").(name()==elementName);
         // list of elements not included in the sort -
         // we place these back into the source node at the end
         var excludeList:XMLList=source.elements("*").(name()!=elementName);
         list= sortXMLList(list,fieldName,options);
         list += excludeList;
         source.setChildren(list);
         return source;
    function sortXMLList(list:XMLList, fieldName:Object, options:Object =
    null):XMLList
         var arr:Array = new Array();
         var ch:XML;
         for each(ch in list)
               arr.push(ch);
         var resultArr:Array = fieldName==null ?
               options==null ? arr.sort() :arr.sort(options)
               : arr.sortOn(fieldName, options);
         var result:XMLList = new XMLList();
         for(var i:int=0; i<resultArr.length; i++)
               result += resultArr[i];
         return result;

  • Shell script: do pks/pkb files contain symbol "/".

    I have folder which contains files and subfolders with files.
    I want to determine if all "*.pks" and "*.pkb" files in all those folders contain symbol "/". This symbol usually is the last symbol inside the file.
    Can shell script go through all those files and output wheter or not all those files contain "/" at the end. It should output the files, which doesn't have "/" inside.
    Example file:
    <PKG_INTRA_PRODUCT_PRD_TYPE.pkb>
    create or replace
    package body PKG_INTRA_PRODUCT_PRD_TYPE
    as
    function IS_INTEGER (
       i_source in varchar2
    return boolean
    is
    begin
       if regexp_like (i_source, '^[1-9]+[0-9]*$') then
          return true;
       else
          return false;
       end if;
    end IS_INTEGER;
    end PKG_INTRA_PRODUCT_PRD_TYPE;
    </PKG_INTRA_PRODUCT_PRD_TYPE.pkb>As you see it contains "/" at the end, and this is correct, we don't have to output this file name.
    And, all subfolders below the execution folder must be analyzed.

    So, you want a list of the files which do not contain a slash:
    #!/bin/bash
    find ${@:-.} -type f -print | egrep -e '^.*[.](pks|pkb)$' | xargs -r awk '
        if( FILENAME != old_FILENAME ) {
            if( !saw_slash && (old_FILENAME != "" ) )    {
                print old_FILENAME
            old_FILENAME = FILENAME
            saw_slash = 0
        saw_slash = 0
    END {
        if( saw_slash ) {
            print old_FILENAME
    'Run it like this:
    $ ./code
    $ ./code /
    $ ./code /tmp /var/tmpWithout an argument, searches the directory tree beginning with the current directory. Otherwise, give it a list of the directories you would like to search.

  • Open a SharePoint List item in Modal Pop up in SP 2013 fails after you filter or sort the list

    Sorry for the long post. This has been killing me. I had this script working perfectly fine in SharePoint 2010 (online) and basically i have a source custom list (list A) with a hyperlink column and a Destination List with say title and my name.
    Source List (list A) looks like this with these 2 columns
    Title    Test Link
    A         Link 1
    B         Link 2 
    C         Link 3
    Each of these links link to the actual list item in the destination list, so for example, link 1 is/sites/2013DevSite/Lists/Destination%20List/EditForm.aspx?ID=1
    So basically i want anytime the Link are clicked that point to another list's item to open in a modal dialog and the script below worked perfectly fine in SharePoint 2010 (online)
    <script language="javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript"></script>
    <script language ="javascript" type="text/javascript">   
    jQuery(document).ready(function() {
    jQuery('a[href*="EditForm.aspx"]').each(function (i, e) {
    // Store the A tag's current href in a variable
    var currentHref = jQuery(e).attr('href');
    jQuery(e).attr({
    'href': 'javascript:void(0);', 
    // Use the stored href as argument for the ShowInModal functions parameter.
    'onclick': 'ShowInModal("' + currentHref + '");'
    function ShowInModal(href) {
    SP.UI.ModalDialog.showModalDialog({title: "Edit Item", url: href});    
    </script>
    All it does is find the href tags for that particular value Editform.aspx and the pop modal works in SP 2010 online. So the site page is designed in such a way there is a content editor web part with the reference to this javascript file and the sharepoint
    list is right beneath it and this worked perfectly opening in modal windows in SP 2010.
    Since migration to 2013, this is what exactly happens
    1.) when you come to the site page, the modal works,
    2.) If you filter or sort on say the Title or Test Link column in Source list (lets say you select the Value A), the script does not fire at all, if i hover over the hyperlink, the who hyperlink is shown and does not open the hyperlink in the modal pop up.
    - This is important because i want to be able to sort on a particular item...
    Could someone please let me know what am i doing wrong and why is this not working when i sort the list. Thanks for all the help.
    Once again i am trying to open a sharepoint list item in Sharepoint 2013 from another list using Jquery

    A ListItem has its own unique row id so in all likelihood, an insert with the same data will result in a new list entry. The Lists Web Service however, has an UpdateListItem method which will take an update request. [refer
    http://msdn.microsoft.com/en-us/library/office/websvclists.lists.updatelistitems(v=office.15).aspx ]
    There is another note in the conference (marked answered) to your List Item Update problem. Probably worth a try too. [refer
    http://social.msdn.microsoft.com/Forums/en-US/bee8f6c6-3259-4764-bafa-6689f5fd6ec9/how-to-update-an-existing-item-in-a-sharepoint-list-using-the-wss-adapter-for-biztalk?forum=biztalkgeneral ]
    Regards.

  • F101 list contain no data in posting tab

    I have made the configuration for OBBV and OBBU for Chart of Accounts. When I execute F101 for regrouping of customers and vendors and tick generate postings, the list is getting generated. When I click the tab "Postings"  it shows "Posting in Batch input session, List contains no data). There is no batch input session being created in order to post them in SM35.
    Please let me know whether there are any steps that are missing.
    Thanks,
    Imdad

    Hi
    Is there anyone who can answer me
    regards

  • Doc type AB - List contains no Data

    Hi SAP team,
    I am facing an issue that I could not find a similar one in here.
    When FB03 is displayed, no items are shown. It shows, however, List Contains no Data.
    In the Header option, I can view that the documents were entered by a Batch ID under t_code FBS1
    Document Header Text says: Autom. Clearing SAPF124
    Document Status B
    Can anyone shed any light as to why FB03 has nothing (this has been happening for many years) and what is the meaning of Doc Status B ?
    This is not a layout issue as many threads have mentioned. This must be something else that the Batch ID is running.
    Any help is welcome
    Regards
    Roger

    Thank you for your valuable input.
    One topic only needs clarification.
    Any idea of what Document Status A and Status B means?
    (you can see this A B status in the header icon - FB03)
    Regards,
    Rogerio

Maybe you are looking for

  • Can't parse xml file in jar file when  can't connect to web server

    My JNLP application throw ConnectException when trying to parse xml during web server offline. Steps, 1. JNLP application has been launched once and all related jar and xml files are already downloaded to local cache. 2. Then I close web server to te

  • Adding two 2-D Arrays to then save

    I am trying to build two 2-D arrays to then save as a spreadsheet file. This process happens in while loop and I need to enable indexing when I feed the wire out. When I do this I use the build array fucntion but then it creates a 3-D array which I c

  • Compressor Plug-in

    I have version 2.01 and would like to have the iPod encoder added to the Quicktime Export Components (I currently have 3G, Windows Media, Real Media, and AVI). Where do I find the plug-in? It's not obvious on the Compressor support page. Power Mac G5

  • Output PDF on file system? (EBS)

    Hi all, When you run a BI Publisher report with a concurrent program, is the output PDF stored somewhere on the file system? (Where..) Thanks in advance! Best Regards, Matilda Smeds

  • Connect to an XServ using ARD to check on an FM 5.5 Server

    Need some help. I have Filemaker Server running on an XServ at another LAN location probably on another subnet. I have apple remote desktop on my computer with the FM server name in the Master List in the main window. I just need to verify that an ex