Fetch the data from the Data base based on selection criteria in ABAP

Hi
I am new to ABAP and working on the Screen where User Enters Company code from and to , Document no and to, I have defined as specified below
  SELECT-OPTIONS Company     FOR p_ccode.
  SELECT-OPTIONS Document    FOR p_fdocnr.
  SELECT-OPTIONS Year           FOR p_fyear.
When I debug in the pgm I get the values as
IBT11001100 (From and To Company Code)
IBT23234241002323424246 (From and To doc no)
IBT20092009 (From and To Year)
How can write a SQL select statement to fetch the data from the Database based on the above inputs
Thanks
PR

Moderator message:
Sorry - this isn't an ABAP training forum. Please press F1 on SELECT-OPTIONS and/or SELECT.
Thread locked.
Rob

Similar Messages

  • How to dynamically display the data from a table base on row selection of another table in ADF

    Hi ,
    I have a requirement in ADF. I need to change the data of a table  based on row selection of another Table . Both the table have a Parent Child relationship between them. They have a common attribute say department_id.
                                                                                         For this I created bind variable in view object of employees table and wrote a where clause in the sql query using that bind variable. Then I created method for selection listener of department Table in java bean.
    My method is following
        public void onrowselection(SelectionEvent selectionEvent) {
            RichTable richTable = (RichTable)selectionEvent.getSource();
                            CollectionModel tableModel = (CollectionModel)richTable.getValue();
                            JUCtrlHierBinding adfTableBinding = (JUCtrlHierBinding)tableModel.getWrappedData();
                            Object selectedRowData = richTable.getSelectedRowData();
                            JUCtrlHierNodeBinding nodeBinding = (JUCtrlHierNodeBinding)selectedRowData;
                    oracle.jbo.domain.Number newVal = (oracle.jbo.domain.Number) nodeBinding.getAttribute("DepartmentId");
                    Number pallet = newVal.bigDecimalValue();
                    System.out.println("Selected values " + pallet);
            BindingContext bindingctx = BindingContext.getCurrent();
                          BindingContainer bindings = bindingctx.getCurrentBindingsEntry();
                          DCBindingContainer bindingsImpl = (DCBindingContainer) bindings;
                  DCIteratorBinding dciter = bindingsImpl.findIteratorBinding("EmployeesView1Iterator");//access the iterator by its ID value in the PageDef file
                          ViewObject vo =dciter.getViewObject();
                          vo.setNamedWhereClauseParam("DepartmentId", pallet);//enter your value
                          vo.executeQuery();
    It is printing the selected value of department id from department table in the log. But it is not able to pass the value to employees view. It is showing the following error in the log
    "Definition DepartmentId of type Variable is not found in EmployeesView1."
    I will be very thankful if someone helps me to solve this errror or is there any other way to achieve the same requirement.
    Thanks
    Nilesh

    Note quite sure why you simply wont create a viewlink for the viewobject the tables are based on..
    The viewlink attribute will be based on the departmentId and it's a simple master detail relationship which automatically uses ppr.
    However, if both tables are on the same page; using your hack about;
    On the underlying viewobject, define a viewcriteria e.g. "listById" and set your bind variable here.
    I would bind table two to a RichTable component:
    RichTable t2;
    public void onrowselection(SelectionEvent selectionEvent) {
            RichTable richTable = (RichTable)selectionEvent.getSource();
                            CollectionModel tableModel = (CollectionModel)richTable.getValue();
                            JUCtrlHierBinding adfTableBinding = (JUCtrlHierBinding)tableModel.getWrappedData();
                            Object selectedRowData = richTable.getSelectedRowData();
                            JUCtrlHierNodeBinding nodeBinding = (JUCtrlHierNodeBinding)selectedRowData;
                    oracle.jbo.domain.Number newVal = (oracle.jbo.domain.Number) nodeBinding.getAttribute("DepartmentId");
                    Number pallet = newVal.bigDecimalValue();
                    System.out.println("Selected values " + pallet);
                   refreshTable2(pallet);
            BindingContext bindingctx = BindingContext.getCurrent();
                          BindingContainer bindings = bindingctx.getCurrentBindingsEntry();
                          DCBindingContainer bindingsImpl = (DCBindingContainer) bindings;
                  DCIteratorBinding dciter = bindingsImpl.findIteratorBinding("EmployeesView1Iterator");//access the iterator by its ID value in the PageDef file
                          ViewObject vo =dciter.getViewObject();
                          vo.setNamedWhereClauseParam("DepartmentId", pallet);//enter your value
                          vo.executeQuery();
    private void refreshTable2(Number pallet){
    RichTable x=getT2();
    CollectionModel cm=(CollectionModel)x.getValue();
    JUCtrlHierBinding jcb=(JUCtrlHierBinding)cm.getWrappedData();
    BindingContainer bindings = bindingctx.getCurrentBindingsEntry();
    DCBindingContainer bindingsImpl = (DCBindingContainer) bindings;
    DCIteratorBinding dciter = bindingsImpl.findIteratorBinding(jcb.getName()+"Iterator");
    ViewObject vo =dciter.getViewObject();
    ViewCriteriaManager vcm=vo.getViewCriteriaManager();
    ViewCriteria vc=vcm.getViewCriteria("listById");
    vo.applyViewCriteria(vc);
    vo.setNamedWhereClauseParam("DepartmentId",pallet);
    vo.executeQuery();
    AdfFacesContext.getCurrentInstance().addPartialTarget(getT2());

  • How to dispaly datas from the table, base on the selection screen

    hi there gurus,
    im currently developing a stock aging report,
    i have completed one program but it do not allow me to excutes the program althought the syntax is correct.
    i would to get some ideas from you, regarding how to extract the datas from the tables?
    my selction screen will be, mat number, date, and gl account.
    and the out put datas are, mbew-matnr, makt-maktx, mbew-lbkum, mara_meins, mbew-salk3,and the consumptions for the past 12months and the values for it.
    can u plz guide me with this,
    thank you,.
    this is kind of very urgent program that i need to finish , plz help me.

    here is the total code the i do
    REPORT  ZSTK_AGING_REP2.
    *TABLES
    TABLES: mseg,
            mara,
            makt,
            SKAT,
            SKA1,
            MARV,
            T001,
            T030,
            T149D,
            AM07M,
            MCMSEG,
            T001K,
            T001W,
            T134M,
            vbak,
            mbew,
    mcon, rmcb0, marc, t024w,  mvke, v134w, t438a, propf, maprf, t000, t024e
    , tvko.
    DATA: BEGIN OF ta_material OCCURS 2,
           werks LIKE mard-werks,
           lgort LIKE mard-lgort,
           matnr LIKE mard-matnr,
           labst LIKE mard-labst,
           umlme LIKE mard-umlme,
           insme LIKE mard-insme,
           einme LIKE mard-einme,
           speme LIKE mard-speme,
           retme LIKE mard-retme,
           verpr LIKE mbew-verpr,
           maktx LIKE makt-maktx,
           meins LIKE mara-meins,
          bukrs LIKE t001-bukrs,
          konto LIKE t030-konts,
          butxt LIKE t001-butxt,
          txt50 LIKE skat-txt50,
          MABTR LIKE MCMSEG-DMBTR,
          SKBTR LIKE MCMSEG-DMBTR,
          WAERS LIKE T001-WAERS,
          WAER2 LIKE T001-WAERS,
          BWKEY LIKE MBEW-BWKEY,
          LBKUM LIKE MBEW-LBKUM,
         MEINS LIKE MARA-MEINS,
             SALK3 LIKE MBEW-SALK3,
             WAERS1 LIKE T001-WAERS,
             BUKRS1 LIKE T001-BUKRS,
             KONTO1 LIKE T030-KONTS,
            lbkum LIKE mbew-lbkum,
              erdat LIKE vbak-erdat,
          END OF ta_material.
    DATA: BEGIN OF ta_mseg OCCURS 2,
            mblnr LIKE mseg-mblnr,
    *->Begin of KL02+ -
            mjahr like mseg-mjahr,
            zeile like mseg-zeile,
    *->End of KL02+ -
            meins LIKE mseg-meins,
            menge LIKE mseg-menge,
            werks LIKE mseg-werks,
            lgort LIKE mseg-lgort,
            matnr LIKE mseg-matnr,
            budat LIKE mkpf-budat,
            saknr LIKE SKA1-SAKNR,
          END OF ta_mseg.
    single recs based on MATNR
    DATA: BEGIN OF i_matnr OCCURS 0,
            werks LIKE mard-werks,
            lgort LIKE mard-lgort,
            matnr LIKE mard-matnr,
            maktx LIKE makt-maktx,
            mblnr LIKE mseg-mblnr,
            verpr LIKE mbew-verpr,
            labst LIKE mard-labst,                    "Valuated stock with
    *unrestricted use
            umlme LIKE mard-umlme,                    "Stock in transfer
    *(from one storage location to another)
            insme LIKE mard-insme,                    "Stock in quality
    *inspection
            einme LIKE mard-einme,                    "Total Stock of All
    *Restricted Batches
            speme LIKE mard-speme,                    "Blocked stock
            retme LIKE mard-retme,                    "Blocked Stock Returns
            meins LIKE mara-meins,                    "base unit
          bukrs LIKE t001-bukrs,
          konto LIKE t030-konts,
          butxt LIKE t001-butxt,
          txt50 LIKE skat-txt50,
          MABTR LIKE MCMSEG-DMBTR,
          SKBTR LIKE MCMSEG-DMBTR,
          WAERS LIKE T001-WAERS,
          WAER2 LIKE T001-WAERS,
          BWKEY LIKE MBEW-BWKEY,
          LBKUM LIKE MBEW-LBKUM,
         MEINS LIKE MARA-MEINS,
             SALK3 LIKE MBEW-SALK3,
             WAERS1 LIKE T001-WAERS,
             BUKRS1 LIKE T001-BUKRS,
             KONTO1 LIKE T030-KONTS,
            lbkum LIKE mbew-lbkum,
           END OF i_matnr.
    recs based on MBLNR
    DATA: BEGIN OF i_mblnr OCCURS 0,
            mblnr LIKE mseg-mblnr,
            werks LIKE mseg-werks,
            lgort LIKE mseg-lgort,
            matnr LIKE mseg-matnr,
            menge LIKE mseg-menge,
            meint LIKE mseg-meins,
            budat LIKE mkpf-budat,
         bukrs LIKE t001-bukrs,
         konts LIKE t030-konts,
         butxt LIKE t001-butxt,
         txt50 LIKE skat-txt50,
         MABTR LIKE MCMSEG-DMBTR,
         SKBTR LIKE MCMSEG-DMBTR,
         WAERS LIKE T001-WAERS,
         WAER2 LIKE T001-WAERS,
         BWKEY LIKE MBEW-BWKEY,
          LBKUM LIKE MBEW-LBKUM,
         MEINS LIKE MARA-MEINS,
             SALK3 LIKE MBEW-SALK3,
             WAERS1 LIKE T001-WAERS,
             BUKRS1 LIKE T001-BUKRS,
             KONTO1 LIKE T030-KONTS,
           END OF i_mblnr.
    TYPES: BEGIN OF t_mat,
            lgort LIKE mseg-lgort,
            werks LIKE mseg-werks,
            matnr LIKE mseg-matnr,
            mblnr LIKE mseg-mblnr,
            maktx LIKE makt-maktx,
            meins LIKE mara-meins,
    meng0 LIKE mbew-lbkum,
    value0 LIKE mbew-salk3,
           meng0  LIKE mard-labst,                   "0 to 10 days
           value0 LIKE mseg-dmbtr,
           meng1  LIKE mard-labst,                   "11 to 30 days
           value1 LIKE mseg-dmbtr,
           meng2 LIKE mard-labst,                   "31 to 60 days
           value2 LIKE mseg-dmbtr,
           meng3 LIKE mard-labst,                   "61-90
           value3 LIKE mseg-dmbtr,
           meng4 LIKE mard-labst,                   "90 days onwards
           value4 LIKE mseg-dmbtr,
           END OF t_mat.
    DATA: i_mat2 TYPE t_mat OCCURS 0 WITH HEADER LINE.
    TYPES: BEGIN OF t_mat2,
            lgort LIKE mard-lgort,                    " storage location
            cnt0(5),
            cnt1(5),
            cnt2(5),
            cnt3(5),
            cnt4(5),
       meng0 LIKE mbew-lbkum,
    value0 LIKE mbew-salk3,
           meng0  LIKE mard-labst,                   "0 to 10 days
           value0 LIKE mseg-dmbtr,
           meng1  LIKE mard-labst,                   "11 to 30 days
           value1 LIKE mseg-dmbtr,
           meng2 LIKE mard-labst,                   "31 to 60 days
           value2 LIKE mseg-dmbtr,
           meng3 LIKE mard-labst,                   "61-90
           value3 LIKE mseg-dmbtr,
           meng4 LIKE mard-labst,                   "90 days onwards
           value4 LIKE mseg-dmbtr,
           END OF t_mat2.
    DATA: i_matsum TYPE t_mat2 OCCURS 0 WITH HEADER LINE.
    DATA:  w_mengb TYPE mbew-lbkum,
           w_workqyt TYPE mbew-lbkum,
           w_index TYPE sy-tabix,
    *DATA: w_mengb TYPE mard-labst,     "tmp Balance qty
         w_workqty TYPE mard-labst,   "Work qty
         w_index TYPE sy-tabix,
          w_days(5)  TYPE n,           "duration difference (days)
          w_mths(5)  TYPE n,           "duration difference (mths)
          w_dat1 TYPE sy-datum,        "date
          w_dat2 TYPE sy-datum,        "today's date
          w_detl(1) TYPE c,
          w_summ(1) TYPE c,
          w_denom TYPE i,
          w_numer TYPE i,
          w_conv TYPE i,
          w_ttlcnt TYPE i,
          w_cnt TYPE i,
          v_topofpage(1),
         w_meng LIKE mard-labst,
           w_meng LIKE mbew-lbkum,
    *sapscript values
          w_title(20) TYPE c.              "Summary / Detail Report
    DATA: lv_peinh LIKE mbew-peinh,  "Price Unit
          lv_verpr LIKE mbew-verpr.  "Moving Price
    proram comes here
    SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS: s_werks FOR mseg-werks,
                    s_lgort FOR mseg-lgort,
                    s_matnr FOR mara-matnr,
                    s_saknr FOR ska1-saknr,
                    S_ERDAT FOR VBAK-ERDAT.
    PARAMETERS: pck_detl RADIOBUTTON GROUP rep1,
                pck_summ RADIOBUTTON GROUP rep1,
                pck_dtsm RADIOBUTTON GROUP rep1 DEFAULT 'X'.
    SELECTION-SCREEN END OF BLOCK blk1.
    top of the page
      TOP-OF-PAGE.
      PERFORM  f_top_of_page.
      FORM f_top_of_page .
      IF v_topofpage = 'D'.
    *-->Report header for detail report
        WRITE:/2 'Printed By :', sy-uname,
               80 'Stock Aging Report - Detail',
               180 'Printed on:', sy-datum, sy-timlo,
               220 'Page:', sy-pagno.
        WRITE:/,/,/.
        WRITE:/2 'Storage',
               10 'Matl ID',
               22 'Matl Description',
               61 'UOM',
               78 '<--=<QTY ON THIS DATE -->',
              78 '<-- =< 10 days -->',
              112 '<--11 to 30 days -->',
              148 '<--31 to 60 days -->',
              181 '<--61 to 90 days -->',
              216 '<-- > 90 days -->',
               /2 'Location',
               76 'Qty',
               92 'Value'.
              112 'Qty',
              128 'Value',
              148 'Qty',
              164 'Value',
              181 'Qty',
              195 'Value',
              216 'Qty',
              231 'Value'.
        WRITE:/2 sy-uline(235).
      ELSE.
    *-->Report header for Summary report
        WRITE:/2 'Printed By :', sy-uname,
               80 'Stock Aging Report - Summary',
               180 'Printed on:', sy-datum, sy-timlo,
               220 'Page:', sy-pagno.
        WRITE:/,/,/.
        WRITE:/2 'Storage',
               10 'Matl ID',
               22 'Matl Description',
               61 'UOM',
               78 '<--< QTY ON THIS DATE -->',
              78 '<-- < 10 days -->',
              112 '<--11 to 30 days -->',
              148 '<--31 to 60 days -->',
              181 '<--61 to 90 days -->',
              216 '<-- > 90 days -->',
               /2 'Location',
               76 'Qty',
               92 'Value'.
              112 'Qty',
              128 'Value',
              148 'Qty',
              164 'Value',
              181 'Qty',
              195 'Value',
              216 'Qty',
              231 'Value'.
        WRITE:/2 sy-uline(235).
      ENDIF.
    ENDFORM.                    " f_top_of_page
    *start-of-selection
    *PERFOM f_data_selection.
    FORM f_data_selection.
      SELECT a~werks
             a~lgort
             a~matnr
            a~saknr
            a~lbkum
            a~erdat
            a~labst
             a~umlme
             a~insme
             a~einme
             a~speme
             a~retme
           b~verpr    "this field no long been used
             c~maktx
             d~meins
             INTO CORRESPONDING FIELDS OF TABLE ta_material
             FROM mard AS a
             INNER JOIN makt AS c ON amatnr = cmatnr
             INNER JOIN mara AS d ON amatnr = dmatnr
             WHERE a~matnr IN s_matnr
               AND a~werks IN s_werks
               AND a~lgort IN s_lgort
              AND a~saknr IN s_saknr
              AND a~erdat IN s_erdat
               AND c~spras = 'EN'.
    *--> SC01 - End  of Insertion **
    *-->Select material documents
      SELECT a~mblnr
            a~mjahr
            a~zeile
            a~meins
            a~menge
            a~werks
            a~lgort
            a~matnr
            b~budat
            INTO CORRESPONDING FIELDS OF TABLE ta_mseg
      FROM mseg AS a INNER JOIN mkpf AS b
      ON amblnr = bmblnr
      AND amjahr = bmjahr
      FOR ALL ENTRIES IN ta_material
      WHERE matnr = ta_material-matnr
      AND a~werks = ta_material-werks
      AND a~lgort = ta_material-lgort
      AND algort NE aumlgo
      AND a~shkzg = 'S'
      AND a~smbln EQ space
      AND a~smblp EQ space.
    *--> SC03 - Start of Insertion **
    If MBLNR exist in MSEG-SMBLN and this
    record's SHKZG = 'H'. Remove it from the table.
    This is becuase this particular record has already been reverse.
      LOOP AT ta_mseg.
        SELECT SINGLE *
                 FROM mseg
                WHERE smbln = ta_mseg-mblnr
    *->Begin of KL02+ -
                  and SMBLP = ta_mseg-zeile.
                 AND shkzg = 'H'.  "return.           " KL02-
    *->End of KL02+ -
        IF sy-subrc = 0.
          DELETE ta_mseg.
        ENDIF.
      ENDLOOP.
    *--> SC03 - Enf   of Insertion **
    ENDFORM.                    " f_data_selection
    *IMPORTANT , NEED TO CHECK LATER
    FORM f_data_preparation.
    *-->Append data for report details
      LOOP AT ta_material.
        DATA: ta_msegtemp LIKE ta_mseg OCCURS 2 WITH HEADER LINE.
    *-->Loop at all material documents into a temp table
        REFRESH ta_msegtemp. CLEAR ta_msegtemp.
        LOOP AT ta_mseg WHERE matnr = ta_material-matnr AND
                              werks = ta_material-werks AND
                              lgort = ta_material-lgort.
          ta_msegtemp = ta_mseg. APPEND ta_msegtemp.
        ENDLOOP.
    *-->Add up all the stock for the material
        CLEAR w_mengb.
        w_mengb = ta_material-labst +
                        ta_material-umlme +
                        ta_material-insme +
                        ta_material-einme +
                        ta_material-speme +
                        ta_material-retme.
        IF w_mengb IS INITIAL.
          CONTINUE.
        ENDIF.
    *-->sort msegtemp by posting date
        SORT ta_msegtemp BY budat DESCENDING.
    *-->get the values from the material documents into the report output
        LOOP AT ta_msegtemp.
    *->Begin of KL02- -
         CALL FUNCTION 'HRCM_TIME_PERIOD_CALCULATE'
           EXPORTING
             begda               = ta_msegtemp-budat
             endda               = sy-datum
           IMPORTING
            NOYRS               =
             nomns               = w_mths
             nodys               = w_days
          EXCEPTIONS
            invalid_dates       = 1
            overflow            = 2
            OTHERS              = 3
    *->End of KL02- -
    *->Begin of KL02+ -
    *-->Get the days difference btw two dates
          clear w_days.
          w_days = sy-datum - ta_msegtemp-budat.
    *--> Include today's date into calculation
          w_days = w_days + 1.
    *->End of KL02+ -
    check base unit, do conversion
          IF ta_material-meins <> ta_msegtemp-meins.
            CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
              EXPORTING
                i_matnr              = ta_material-matnr
                i_in_me              = ta_msegtemp-meins
                i_out_me             = ta_material-meins
                i_menge              = ta_msegtemp-menge
              IMPORTING
                e_menge              = ta_msegtemp-menge
              EXCEPTIONS
                error_in_application = 1
                error                = 2
                OTHERS               = 3.
          ENDIF.
    *--> SC01 - Start of Insertion **
          SELECT SINGLE peinh
                        verpr
                   INTO (lv_peinh,
                         lv_verpr)
                   FROM mbew
                  WHERE matnr = ta_material-matnr
                    AND bwkey = ta_material-werks.
          IF sy-subrc = 0.
            ta_material-verpr = lv_verpr.
          ENDIF.
    *--> SC01 - End   of Insertion **
    *-->check whether the mseg value is LE than the stock value
          IF ta_msegtemp-menge LE w_mengb.
    *-->Days < 10 days
            IF w_days  LE 1 AND w_days EQ 366.
              i_mat2-meng0 = i_mat2-meng0 + ta_msegtemp-menge.
              IF NOT lv_peinh EQ 0.
                i_mat2-value0 = ( i_mat2-meng0 / lv_peinh ) *
    ta_material-verpr."+SC01
              ENDIF.
    **-->Days 11 - 30 days
           ELSEIF w_days >= 11 AND w_days =< 30.
             i_mat2-meng1 = i_mat2-meng1 + ta_msegtemp-menge.
             IF NOT lv_peinh EQ 0.
               i_mat2-value1 = ( i_mat2-meng1 / lv_peinh ) *
    *ta_material-verpr."+SC01
             ENDIF.
    **-->Days 31-60 days
           ELSEIF w_days >= 31 AND w_days =< 60.
             i_mat2-meng2 = i_mat2-meng2 + ta_msegtemp-menge.
             IF NOT lv_peinh EQ 0.
               i_mat2-value2 = ( i_mat2-meng2 / lv_peinh ) *
    *ta_material-verpr."+SC01
             ENDIF.
    **-->Days 61-90 days
           ELSEIF w_days >= 61 AND w_days =< 90.
             i_mat2-meng3 = i_mat2-meng3 + ta_msegtemp-menge.
             IF NOT lv_peinh EQ 0.
               i_mat2-value3 = ( i_mat2-meng3 / lv_peinh ) *
    *ta_material-verpr.
             ENDIF.
    **-->Days > 90 days
           ELSEIF w_days > 90.
             i_mat2-meng4 = i_mat2-meng4 + ta_msegtemp-menge.
             IF NOT lv_peinh EQ 0.
               i_mat2-value4 = ( i_mat2-meng4 / lv_peinh ) *
    *ta_material-verpr.
             ENDIF.
           ENDIF.
    *->End of KL002+
            w_mengb = w_mengb - ta_msegtemp-menge.
          ELSE.
            IF NOT w_mengb LE 0 .
                 IF NOT lv_peinh EQ 0.
    **->End of KL001+
                   i_mat2-value0 = ( i_mat2-meng0 / lv_peinh )
    *ta_material-verpr."+SC01
    **->Begin of KL001+
                 ENDIF.
               ELSEIF w_days GE 22.
                 i_mat2-meng3 = i_mat2-meng3 + w_mengb.
                 IF NOT lv_peinh EQ 0.
                   i_mat2-value3 = ( i_mat2-meng3 / lv_peinh )
    *ta_material-verpr.
                 ENDIF.
    **->End of KL001+
               ENDIF.
    **--> SC02 - End  of Insertioin **
           ENDIF.
    *->End of KL002-
    *->Begin of KL002+
    *--> < 10 days
                     IF w_days EQ 1 AND w_days LE 366.
              i_mat2-meng0 = i_mat2-meng0 + ta_msegtemp-menge.
              IF NOT lv_peinh EQ 0.
                i_mat2-value0 = ( i_mat2-meng0 / lv_peinh ) *
    ta_material-verpr."+SC01
              ENDIF.
             ELSEIF w_days >= 11 AND w_days =< 30.
               i_mat2-meng1 = i_mat2-meng1 + w_mengb.
               IF NOT lv_peinh EQ 0.
                 i_mat2-value1 = ( i_mat2-meng1 / lv_peinh ) *
    *ta_material-verpr.
               ENDIF.
    **--> 31 - 60 days
             ELSEIF w_days >= 31 AND w_days =< 60.
               i_mat2-meng2 = i_mat2-meng2 + w_mengb.
               IF NOT lv_peinh EQ 0.
                 i_mat2-value2 = ( i_mat2-meng2 / lv_peinh ) *
    *ta_material-verpr.
               ENDIF.
    **--> 61 - 90 days
             ELSEIF w_days >= 61 AND w_days =< 90.
               i_mat2-meng3 = i_mat2-meng3 + w_mengb.
               IF NOT lv_peinh EQ 0.
                 i_mat2-value3 = ( i_mat2-meng3 / lv_peinh ) *
    *ta_material-verpr.
               ENDIF.
    **--> > 90 days
             ELSEIF w_days > 90.
               i_mat2-meng4 = i_mat2-meng4 + w_mengb.
               IF NOT lv_peinh EQ 0.
                 i_mat2-value4 = ( i_mat2-meng4 / lv_peinh ) *
    *ta_material-verpr.
               ENDIF.
              ENDIF.
    *->End of KL002+
              w_mengb = 0.
            ENDIF. " check stock value NE zero
          ENDIF.   "check Mat doc amount is LE than the stock value
    ENDIF.
        ENDLOOP. " msegtemp
    *-->append i_mat2 values
        i_mat2-werks = ta_material-werks.
        i_mat2-lgort = ta_material-lgort.
        i_mat2-matnr = ta_material-matnr.
        i_mat2-maktx = ta_material-maktx.
        i_mat2-meins = ta_material-meins.
        APPEND i_mat2. CLEAR i_mat2.
      ENDLOOP. " ta_material
    *-->Append data for summary data
      DATA: i_lgort LIKE i_mat2 OCCURS 2 WITH HEADER LINE.
      i_lgort[] = i_mat2[].
      SORT i_lgort BY werks lgort.
      DELETE ADJACENT DUPLICATES FROM i_lgort COMPARING werks lgort.
      DATA: v_cnt0(5), v_cnt1(5), v_cnt2(5), v_cnt3(5), v_cnt4(5),
            v_value0 LIKE i_matsum-value0.
           v_value1 LIKE i_matsum-value1,
           v_value2 LIKE i_matsum-value2,
           v_value3 LIKE i_matsum-value3,
           v_value4 LIKE i_matsum-value4.
      LOOP AT i_lgort.
        CLEAR v_cnt0. CLEAR v_value0.
      CLEAR v_cnt1. CLEAR v_value1.
       CLEAR v_cnt2. CLEAR v_value2.
       CLEAR v_cnt3. CLEAR v_value3.
       CLEAR v_cnt4. CLEAR v_value4.
        LOOP AT i_mat2 WHERE lgort = i_lgort-lgort AND
                             werks = i_lgort-werks.
          IF NOT i_mat2-meng0 IS INITIAL.
            v_cnt0 = v_cnt0 + 1.
            v_value0 = v_value0 + i_mat2-value0.
          ENDIF.
         IF NOT i_mat2-meng1 IS INITIAL.
           v_cnt1 = v_cnt1 + 1.
           v_value1 = v_value1 + i_mat2-value1.
         ENDIF.
         IF NOT i_mat2-meng2 IS INITIAL.
           v_cnt2 = v_cnt2 + 1.
           v_value2 = v_value2 + i_mat2-value2.
         ENDIF.
         IF NOT i_mat2-meng3 IS INITIAL.
           v_cnt3 = v_cnt3 + 1.
           v_value3 = v_value3 + i_mat2-value3.
         ENDIF.
         IF NOT i_mat2-meng4 IS INITIAL.
           v_cnt4 = v_cnt4 + 1.
           v_value4 = v_value4 + i_mat2-value4.
         ENDIF.
        ENDLOOP.
        CLEAR i_matsum.
        i_matsum-lgort = i_mat2-lgort.
        IF v_cnt0 NE space.
          i_matsum-cnt0 = v_cnt0.
          i_matsum-value0 = v_value0.
          APPEND i_matsum.
        ENDIF.
       CLEAR i_matsum.
       i_matsum-lgort = i_mat2-lgort.
       IF v_cnt1 NE space.
         i_matsum-cnt1 = v_cnt1.
         i_matsum-value1 = v_value1.
         APPEND i_matsum.
       ENDIF.
       CLEAR i_matsum.
       i_matsum-lgort = i_mat2-lgort.
       IF v_cnt2 NE space.
         i_matsum-cnt2 = v_cnt2.
         i_matsum-value2 = v_value2.
         APPEND i_matsum.
       ENDIF.
       CLEAR i_matsum.
       i_matsum-lgort = i_mat2-lgort.
       IF v_cnt3 NE space.
         i_matsum-cnt3 = v_cnt3.
         i_matsum-value3 = v_value3.
         APPEND i_matsum.
       ENDIF.
       CLEAR i_matsum.
       i_matsum-lgort = i_mat2-lgort.
       IF v_cnt4 NE space.
         i_matsum-cnt4 = v_cnt4.
         i_matsum-value4 = v_value4.
         APPEND i_matsum.
       ENDIF.
      ENDLOOP.
    ENDFORM.                    "f_data_preparation
    *IMPORTANT , NEED TO CHECK LATER
    FORM f_display_data .
      IF pck_dtsm = 'X'.
    *-->Display detail
        v_topofpage = 'D'.
        PERFORM f_display_detail.
    *-->display summary
        v_topofpage = 'S'.
        NEW-PAGE.
        PERFORM f_display_summary.
      ELSEIF pck_detl = 'X'.
    *-->Display detail
        v_topofpage = 'D'.
        PERFORM f_display_detail.
      ELSEIF pck_summ = 'X'.
    *-->display summary
        v_topofpage = 'S'.
        PERFORM f_display_summary.
      ENDIF.
    ENDFORM.                    " f_display_data
    FORM f_display_detail .
      v_topofpage = 'D'.
      SORT i_mat2 BY werks lgort.
    *DATA: v_count(5),
    DATA: v_count,
            v_va1 LIKE i_mat2-value0.
           v_va2 LIKE i_mat2-value0,
           v_va3 LIKE i_mat2-value0,
           v_va4 LIKE i_mat2-value0,
           v_va5 LIKE i_mat2-value0.
      LOOP AT i_mat2.
        WRITE:/2 i_mat2-lgort,
              10 i_mat2-matnr,
              22 i_mat2-maktx(38),
              61 i_mat2-meins,
              64 i_mat2-meng0,
              82 i_mat2-value0.
             100 i_mat2-meng1,
             118 i_mat2-value1,
             136 i_mat2-meng2,
             154 i_mat2-value2,
             169 i_mat2-meng3,
             186 i_mat2-value3,
             204 i_mat2-meng4,
             222 i_mat2-value4.
    *-->Set counter and add up all values by lgort
        v_count = v_count + 1.
         v_va1 = v_va1 + i_mat2-value0.
       v_va2 = v_va2 + i_mat2-value1.
       v_va3 = v_va3 + i_mat2-value2.
       v_va4 = v_va4 + i_mat2-value3.
       v_va5 = v_va5 + i_mat2-value4.
        AT END OF lgort.
          WRITE:/10 'Cnt:',
                 15 v_count,
                 55 'Subtotal',
                 82 v_va1.
                118 v_va2,
                154 v_va3,
                186 v_va4,
                222 v_va5.
          CLEAR v_count. CLEAR v_va1.
         CLEAR v_va2. CLEAR v_va3. CLEAR v_va4. clear v_va5.
        ENDAT.
      ENDLOOP.
    ENDFORM.                    " f_display_detail
    FORM f_display_summary .
      v_topofpage = 'S'.
      LOOP AT i_matsum.
        IF NOT i_matsum-cnt0 IS INITIAL.
          WRITE:/2  i_matsum-lgort,
                 10 'Cnt:',15 i_matsum-cnt0,
                 82 i_matsum-value0.
        ENDIF.
       IF NOT i_matsum-cnt1 IS INITIAL.
         WRITE:/2  i_matsum-lgort,
                10 'Cnt:',15 i_matsum-cnt1,
                118 i_matsum-value1.
       ENDIF.
       IF NOT i_matsum-cnt2 IS INITIAL.
         WRITE:/2  i_matsum-lgort,
                10 'Cnt:',15 i_matsum-cnt2,
                154 i_matsum-value2.
       ENDIF.
       IF NOT i_matsum-cnt3 IS INITIAL.
         WRITE:/2  i_matsum-lgort,
                10 'Cnt:', 15 i_matsum-cnt3,
                186 i_matsum-value3.
       ENDIF.
       IF NOT i_matsum-cnt4 IS INITIAL.
         WRITE:/2  i_matsum-lgort,
                10 'Cnt:', 15 i_matsum-cnt4,
                222 i_matsum-value4.
       ENDIF.
      ENDLOOP.
    ENDFORM.                    " f_display_summary

  • Deleting data from a 2D array based on the id of the second column

    Hello
    I hope someone can help me. I have come across a hurdle in the programming of my application.
    1.
    I have a 2D array, the first column of this array contains my data and the second column contains an id, which is either 0 or 1.
    I have sorted this 2D array based on the id column so that the data corresponding to the 0’s is on top part of the array and the data corresponding to the 1’s follows it (on the bottom of the array).
    I want to delete that data (rows) of this sorted array that correspond to the 1’s and keep only the data (rows) that correspond to the 0’s.  
    So I would end up with a new 2D array that has only the data that I want on the first column and 0’s on the second column.
    I have hundreds of these 2D arrays resulting from my program (using a for loop) hence I want to automate this procedure. The length of the selected data arrays will vary.
    2.
    Once I can do this I will want to remove the id column (with the 0’s) from the 2D array and would like to build a new array with only the data from the first column (which may be of different length).
    So I want to end up with a 2D array with columns corresponding to the selected (1st column) data from the (original) 2D arrays. These data may be of different lengths so when building this new array I may need to do some padding. Will labview do this automatically?
    I hope that this is clear.
    Best wishes,

    Attached is a different approach - you don't need to do any sorting.
    The outer FOR loop assumes you have all the arrays available at once. If you are reading a file, modify it accordingly.
    You may or may not want the TRANSPOSE function on the final results, depending on what you want to do with it.
    Yes, when you assemble N-dimensional arrays into (N+1)-dimensional arrays, LabVIEW automatically pads for you.
    Enjoy.
    Steve Bird
    Culverson Software - Elegant software that is a pleasure to use.
    Culverson.com
    Blog for (mostly LabVIEW) programmers: Tips And Tricks
    Attachments:
    Extract Marked Data.vi ‏40 KB

  • How to fetch the data from the table COEP for WBS element,cost center,,,,,?

    Hi,
    I would like to retrive the data from the table COEP ,based on KOKRS,BELNR fields.
    I need the output for Cost centre, cost element, wbs element,net work ,activity.
    These values are storing OBJNR ,OBJNAR_1,OBJNR_2,OBJNR_N3.
    But here always these field are not giving the correct values.
    for example : for one record COST CENTRE vlaue is storing in OBJNR_1 field,
                        for one record COST CENTRE vlaue is storing in OBJNR_2 field,
                       for one record  COST CENTRE vlaue is storing in OBJNR_3 field.
    Here SAP has used a generic approach for this.
    How can I dispaly the values in this case ?
    Thanks and Regards
    Srinivas.N

    Hi,
    I am asking, how can we say OBJNR_1 value alwyas belongs to cost center ?
    USPOB is not filling always.

  • Fetch the data from the tables in the SQL 2005 server to sap R/3.

    Hi Experts,
    We need to fetch the data from the tables in the SQL 2005 server to sap R/3.
    Please explain which will be the best approach to fetch the same and how to do it. Sample program can greatly help.
    << Please do not offer points >>
    Regards,
    Shobana K
    Edited by: Rob Burbank on Sep 21, 2010 2:36 PM

    Hi,
    Try NATIVE SQL statements in your abap code otherwise you can try to establish jdbc connection from ABAP program.
    search in SDN for samples!
    Suresh

  • Featching Data From The Data Base Using DI API in Matrix

    Hi
       All of u i am shahid i faced a problem when i retrive
       the selected data from the data base using matrix plz.
       Healp me!.
       Thanks
       Mohd Shahid.
       SAP Techinical Consultent
      Option Strict Off
    Option Explicit On
    Friend Class UseMatrix
        '// This parameter will use us to manipulate the
        '// SAP Business One Application
        Private WithEvents SBO_Application As SAPbouiCOM.Application
        Private oForm As SAPbouiCOM.Form
        Private oMatrix As SAPbouiCOM.Matrix
        Private oColumns As SAPbouiCOM.Columns
        Private oColumn As SAPbouiCOM.Column
        '// declareing a DB data source for all the Data binded columns
        Private oDBDataSource As SAPbouiCOM.DBDataSource
        '// declaring a User data source for the "Remarks" Column
        Private oUserDataSource As SAPbouiCOM.UserDataSource
        ' This Function is called automatically when an instance
        ' of the class is created.
        ' Indise this function
        Public Sub New()
            MyBase.New()
            '// set SBO_Application with an initialized application object
            SetApplication()
            '// Create the UI
            CreateFormWithMatrix()
            '// Add Data Sources to the Form
            AddDataSourceToForm()
            '// Bind the Form's items with the desired data source
            BindDataToForm()
            '// Load date to matrix
            GetDataFromDataSource()
            '// Make the form visible
            oForm.Visible = True
        End Sub
        Private Sub SetApplication()
            '// Use an SboGuiApi object to establish connection
            '// with the SAP Business One application and return an
            '// initialized appliction object
            Dim SboGuiApi As SAPbouiCOM.SboGuiApi
            Dim sConnectionString As String
            SboGuiApi = New SAPbouiCOM.SboGuiApi
            '// by following the steps specified above, the following
            '// statment should be suficient for either development or run mode
            sConnectionString = Environment.GetCommandLineArgs.GetValue(1)
            '// connect to a running SBO Application
            Try ' If there's no active application the connection will fail
                SboGuiApi.Connect(sConnectionString)
            Catch ' Connection failed
                System.Windows.Forms.MessageBox.Show("No SAP Business One Application was found")
                End
            End Try
            '// get an initialized application object
            SBO_Application = SboGuiApi.GetApplication()
            'SBO_Application.MessageBox("Hello World")
        End Sub
        Private Sub SBO_Application_AppEvent(ByVal EventType As SAPbouiCOM.BoAppEventTypes) Handles SBO_Application.AppEvent
            Select Case EventType
                Case SAPbouiCOM.BoAppEventTypes.aet_ShutDown
                    SBO_Application.MessageBox("A Shut Down Event has been caught" & _
                        Environment.NewLine() & "Terminating 'Add Menu Item' Add On...")
                    '// terminating the Add On
                    System.Windows.Forms.Application.Exit()
            End Select
        End Sub
        Private Sub CreateFormWithMatrix()
            '// Don't Forget:
            '// it is much more efficient to load a form from xml.
            '// use code only to create your form.
            '// once you have created it save it as XML.
            '// see "WorkingWithXML" sample project
            '// we will use the following object to add items to our form
            Dim oItem As SAPbouiCOM.Item
            '// we will use the following objects to set
            '// the specific values of every item
            '// we add.
            '// this is the best way to do so
            Dim oButton As SAPbouiCOM.Button
            Dim oStaticText As SAPbouiCOM.StaticText
            Dim oEditText As SAPbouiCOM.EditText
            '// The following object is needed to create our form
            Dim creationPackage
            creationPackage = SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_FormCreationParams)
            creationPackage.UniqueID = "UidFrmMatrix14"
            creationPackage.FormType = "TypeFrmMatrix14"
            '// Add our form to the SBO application
            oForm = SBO_Application.Forms.AddEx(creationPackage)
            '// Set the form properties
            oForm.Title = "Quality Check"
            oForm.Left = 336
            oForm.ClientWidth = 620
            oForm.Top = 44
            oForm.ClientHeight = 200
            '// Adding Items to the form
            '// and setting their properties
            '// Adding an Ok button
            '// We get automatic event handling for
            '// the Ok and Cancel Buttons by setting
            '// their UIDs to 1 and 2 respectively
            oItem = oForm.Items.Add("1", SAPbouiCOM.BoFormItemTypes.it_BUTTON)
            oItem.Left = 5
            oItem.Width = 65
            oItem.Top = 170
            oItem.Height = 19
            oButton = oItem.Specific
            oButton.Caption = "Ok"
            '// Adding a Cancel button
            oItem = oForm.Items.Add("2", SAPbouiCOM.BoFormItemTypes.it_BUTTON)
            oItem.Left = 75
            oItem.Width = 65
            oItem.Top = 170
            oItem.Height = 19
            oButton = oItem.Specific
            oButton.Caption = "Cancel"
            '// Adding a Text Edit item
            'oItem = oForm.Items.Add("txtPhone", SAPbouiCOM.BoFormItemTypes.it_EDIT)
            ' oItem.Left = 265
            'oItem.Width = 163
            'oItem.Top = 172
            'oItem.Height = 14
            '// Adding an Add Phone prefix column button
            ' oItem = oForm.Items.Add("BtnPhone", SAPbouiCOM.BoFormItemTypes.it_BUTTON)
            ' oItem.Left = 160
            ' oItem.Width = 100
            ' oItem.Top = 170
            ' oItem.Height = 19
            ' oButton = oItem.Specific
            ' oButton.Caption = "Add Phone prefix"
            '// Add the matrix to the form
            AddMatrixToForm()
        End Sub
        Private Sub AddMatrixToForm()
            '// we will use the following object to add items to our form
            Dim oItem As SAPbouiCOM.Item
            '// we will use the following object to set a linked button
            Dim oLink As SAPbouiCOM.LinkedButton
            '// Adding a Matrix item
            oItem = oForm.Items.Add("Matrix1", SAPbouiCOM.BoFormItemTypes.it_MATRIX)
            oItem.Left = 5
            oItem.Width = 500
            oItem.Top = 5
            oItem.Height = 150
            oMatrix = oItem.Specific
            oColumns = oMatrix.Columns
            '// Adding Culomn items to the matrix
            oColumn = oColumns.Add("#", SAPbouiCOM.BoFormItemTypes.it_EDIT)
            oColumn.TitleObject.Caption = "#"
            oColumn.Width = 30
            oColumn.Editable = False
            '// Add a column for Item Code
            oColumn = oColumns.Add("DSItemCode", SAPbouiCOM.BoFormItemTypes.it_LINKED_BUTTON)
            oColumn.TitleObject.Caption = "Item Code"
            oColumn.Width = 40
            oColumn.Editable = True
            '// Link the column to the ITEM master data system form
            oLink = oColumn.ExtendedObject
            oLink.LinkedObject = SAPbouiCOM.BoLinkedObject.lf_Items
            oColumn = oColumns.Add("DSItemName", SAPbouiCOM.BoFormItemTypes.it_EDIT)
            oColumn.TitleObject.Caption = "Item Name"
            oColumn.Width = 80
            oColumn.Editable = True
            '// Add a column for BP Card Phone
            oColumn = oColumns.Add("DSWhs", SAPbouiCOM.BoFormItemTypes.it_EDIT)
            oColumn.TitleObject.Caption = "Ware House"
            oColumn.Width = 40
            oColumn.Editable = True
            '// Add a column for BP Card Phone
            oColumn = oColumns.Add("DSQuantity", SAPbouiCOM.BoFormItemTypes.it_EDIT)
            oColumn.TitleObject.Caption = "Quantity"
            oColumn.Width = 40
            oColumn.Editable = True
            '// Add a column for Combo Box
            oColumn = oColumns.Add("DSQuality", SAPbouiCOM.BoFormItemTypes.it_CHECK_BOX)
            oColumn.TitleObject.Caption = "Quality"
            ' oColumn.ValidValues.Add("OK", "")
            'oColumn.ValidValues.Add("NOT OK", "")
            oColumn.Width = 40
            oColumn.Editable = True
            oColumn = oColumns.Add("DSReport", SAPbouiCOM.BoFormItemTypes.it_EDIT)
            oColumn.TitleObject.Caption = "Remarks"
            ' oColumn.ValidValues.Add("OK", "")
            'oColumn.ValidValues.Add("NOT OK", "")
            oColumn.Width = 40
            oColumn.Editable = True
            '// Add a column for BP Card Phone
            ' oColumn = oColumns.Add("DSPhoneInt", SAPbouiCOM.BoFormItemTypes.it_EDIT)
            ' oColumn.TitleObject.Caption = "Int. Phone"
            'oColumn.Width = 40
            'oColumn.Editable = True
        End Sub
        Public Sub AddDataSourceToForm()
            '// every item must be binded to a Data Source
            '// prior of binding the data we must add Data sources to the form
            '// Add user data sources to the "International Phone" column in the matrix
            ' oUserDataSource = oForm.DataSources.UserDataSources.Add("IntPhone", SAPbouiCOM.BoDataType.dt_SHORT_TEXT, 20)
            '// Add DB data sources for the DB bound columns in the matrix
            oDBDataSource = oForm.DataSources.DBDataSources.Add("OITW")
        End Sub
        Public Sub BindDataToForm()
            '// getting the matrix column by the UID
            oColumn = oColumns.Item("DSItemCode")
            'oColumn.DataBind.SetBound(True, "", "DSCardCode")
            oColumn.DataBind.SetBound(True, "OITW", "ItemCode")
            'oColumn = oColumns.Item("DSItemName")
            'oColumn.DataBind.SetBound(True, "OITW", "ItemName")
            oColumn = oColumns.Item("DSWhs")
            oColumn.DataBind.SetBound(True, "OITW", "WhsCode")
            oColumn = oColumns.Item("DSQuantity")
            oColumn.DataBind.SetBound(True, "OITW", "U_QCStock")
            '// to Data Bind an item with a user Data source
            '// the table name value should be an empty string
            ' oColumn = oColumns.Item("DSPhoneInt")
            'oColumn.DataBind.SetBound(True, "", "IntPhone")
        End Sub
        Public Sub GetDataFromDataSource()
            '// Ready Matrix to populate data
            oMatrix.Clear()
            oMatrix.AutoResizeColumns()
            '// Querying the DB Data source
            oDBDataSource.Query()
            '// setting the user data source data
            'oUserDataSource.Value = "Phone with prefix"
            oMatrix.LoadFromDataSource()
        End Sub
        Private Sub SBO_Application_ItemEvent(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.ItemEvent
            If (pVal.FormUid = "UidFrmMatrix") Then
                If ((pVal.itemUID = "BtnPhone") And _
                    (pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED) And _
                    (pVal.Before_Action = False)) Then
                    AddPrefix()
                End If
                If ((pVal.EventType = SAPbouiCOM.BoEventTypes.et_FORM_UNLOAD) And _
                    (pVal.Before_Action = False)) Then
                    SBO_Application.MessageBox("Form Unloaded, Addon will terminate")
                    System.Windows.Forms.Application.Exit()
                End If
            End If
        End Sub
        Public Sub AddPrefix()
            Dim i As Integer
            Dim PhoneExtCol As SAPbouiCOM.Column
            Dim newPhone As String
            Dim oItem As SAPbouiCOM.Item
            Dim oEditTxt As SAPbouiCOM.EditText
            '// Get the prefix edit text item
            oItem = oForm.Items.Item("txtPhone")
            oEditTxt = oItem.Specific
            '// Flush user input into datasources
            oMatrix.FlushToDataSource()
            '// Get the DBdatasource we base the matrix on
            oDBDataSource = oForm.DataSources.DBDataSources.Item("OCRD")
            '// Iterate all the records and add a prefix to the phone
            For i = 0 To oDBDataSource.Size - 1
                newPhone = oDBDataSource.GetValue("phone1", i)
                newPhone = newPhone.Trim(" ")
                oDBDataSource.SetValue("phone1", i, oEditTxt.String + newPhone)
            Next
            '// Load data back to
            oMatrix.LoadFromDataSource()
        End Sub
    End Class

    Hi Shahid,
    I am not sure what your question is. The code you pasted looks like the MatrixAndDataSources example that comes with the SDK. What are you trying to do?
    Thanks,
    Adele

  • How to export some data from the tables of an owner with integrity?

    Hi to all,
    How to export some data from the tables of an owner with integrity?
    I want to bring some data from all tables in a single owner of the production database for development environment.
    My initial requirements are: seeking information on company code (emp), contract status (status) and / or effective date of contract settlement (dt_liq_efetiva) - a small amount of data to developers.
    These three fields are present in the main system table (the table of contracts). Then I thought about ...
    - create a temporary table from the query results table to contract;
    - and then use this temporary table as a reference to fetch the data in other tables of the owner while maintaining integrity. But how? I have not found the answer, because: what to do when not there is the possibility of a join between the contract and any other table?
    I am considering the possibility of consulting the names of tables, foreign keys and columns above, and create dynamic SQL. Conceptually, something like:
    select r.constraint_name "FK name",
    r.table_name "FK table",
    r.column_name "FK column",
    up.constraint_name "Referencing name",
    up.table_name "Referencing table",
    up.column_name "Referencing column"
    from all_cons_columns up
    join all_cons_columns r
    using (owner, position), (select r.owner,
    r.constraint_name fk,
    r.table_name table_fk,
    r.r_constraint_name r,
    up.table_name table_r
    from all_constraints up, all_constraints r
    where r.r_owner = up.owner
    and r.r_constraint_name = up.constraint_name
    and up.constraint_type in ('P', 'U')
    and r.constraint_type = 'R'
    and r.owner = 'OWNERNAME') aux
    where r.constraint_name = aux.fk
    and r.table_name = aux.table_fk
    and up.constraint_name = aux.r
    and up.table_name = aux.table_r;
    -- + Dynamic SQL
    If anyone has any suggestions and / or reuse code to me thank you very much!
    After resolving this standoff intend to mount the inserts in utl_file by a table and create another program to read and play in the development environment.
    Thinking...
    Let's Share!
    My thanks in advance,
    Philips

    Thanks, Peter.
    Well, I am working with release 9.2.0.8.0. But the planning is migrate to 10g this year. So my questions are:
    With Data Pump can export data just from tables owned for me (SCHEMAS = MYOWNER) parameterizing the volume of data (SAMPLE) and filters to table (QUERY), right? But parameterizing a contract table QUERY = "WHERE status NOT IN (2,6) ORDER BY contract ":
    1º- the Data Pump automatically searches for related data in other tables in the owner? ex. parcel table has X records related (fk) with Y contracts not in (2,6): X * SAMPLE records will be randomly exported?
    2º- for the tables without relation (fk) and which are within the owner (MYOWNER) the data is exported only based on the parameter SAMPLE?
    Once again, thank you,
    Philips
    Reading Oracle Docs...

  • Error while fetching data from Logical data base

    Hi All,
    I need to fetch the data from Logical data base DDF.First when i am trying demo code
    REPORT demo_program_read_tables_2.
    NODES: spfli, sflight.
    GET spfli FIELDS carrid connid cityfrom cityto.
      WRITE: / spfli-carrid,
               spfli-connid,
               spfli-cityfrom,
               spfli-cityto.
    GET sflight FIELDS fldate.
      WRITE: / sflight-fldate.
    I am getting error like ""spfli is not a node of the logical data base __S""
    Should i declare anything esle?
    Madhu

    REPORT demo_logical_database.
    DATA wa_spfli TYPE spfli.
    SELECT-OPTIONS s_carr FOR wa_spfli-carrid.
    DATA: callback TYPE TABLE OF ldbcb,
          callback_wa LIKE LINE OF callback.
    DATA: seltab TYPE TABLE OF rsparams,
          seltab_wa LIKE LINE OF seltab.
    callback_wa-ldbnode     = 'SPFLI'.
    callback_wa-get         = 'X'.
    callback_wa-get_late    = 'X'.
    callback_wa-cb_prog     = sy-repid.
    callback_wa-cb_form     = 'CALLBACK_SPFLI'.
    APPEND callback_wa TO callback.
    CLEAR callback_wa.
    callback_wa-ldbnode     = 'SFLIGHT'.
    callback_wa-get         = 'X'.
    callback_wa-cb_prog     = sy-repid.
    callback_wa-cb_form     = 'CALLBACK_SFLIGHT'.
    APPEND callback_wa TO callback.
    seltab_wa-kind = 'S'.
    seltab_wa-selname = 'CARRID'.
    LOOP AT s_carr.
      MOVE-CORRESPONDING s_carr TO seltab_wa.
      APPEND seltab_wa TO seltab.
    ENDLOOP.
    CALL FUNCTION 'LDB_PROCESS'
         EXPORTING
              ldbname                     = 'F1S'
              variant                     = ' '
         TABLES
              callback                    = callback
              selections                  = seltab
         EXCEPTIONS
              ldb_not_reentrant           = 1
              ldb_incorrect               = 2
              ldb_already_running         = 3
              ldb_error                   = 4
              ldb_selections_error        = 5
              ldb_selections_not_accepted = 6
              variant_not_existent        = 7
              variant_obsolete            = 8
              variant_error               = 9
              free_selections_error       = 10
              callback_no_event           = 11
              callback_node_duplicate     = 12
              OTHERS                      = 13.
    IF sy-subrc <> 0.
      WRITE: 'Exception with SY-SUBRC', sy-subrc.
    ENDIF.
    FORM callback_spfli USING name  TYPE ldbn-ldbnode
                              wa    TYPE spfli
                              evt   TYPE c
                              check TYPE c.
      CASE evt.
        WHEN 'G'.
          WRITE: / wa-carrid, wa-connid, wa-cityfrom, wa-cityto.
          ULINE.
        WHEN 'L'.
          ULINE.
      ENDCASE.
    ENDFORM.
    FORM callback_sflight USING name  TYPE ldbn-ldbnode
                                wa    TYPE sflight
                                evt   TYPE c
                                check TYPE c.
      WRITE: / wa-fldate, wa-seatsocc, wa-seatsmax.
    ENDFORM.

  • Crystal Add on Failed to retrieve data from the DB Vendor Code: 2812

    Hi everyone
    Im using Sap Business One Version 2007A SP00 PL49, SQL 2005 and Crystal Reports Basic for Sap Business One (Add on 2.0.0.7). Whenever i try to generate a report from SBO the system displays the following message "Failed to retrieve data from the database DETAILS: Database Vendor Code: 2812"
    The scenario is that, according to the Colombia's product local expert, Is not possible to create Stored Procedures, Views, Functions or anything in the customer productive database, in order to improve the performance of the query i created other DB where i created an stored procedure, after that, i called it from Crystal where it's working ok. But when i try to generate it from SBO it show the message promted.
    Someone knows what could be happening
    I'll be thankful

    Hi everyone
    My Stored Procedure contains the following code "annar.dbo.OIBT c", where Annar is the database name.
    When i execute the report in Crystal directly is working without Issues, There everything is ok, the Stored Procedure parameters, sorts, cross tab. When i try to executed it from SBO it shows the prompt error.
    The connection was OLE DB (ADO). I created an ODBC connection with the following settings
    - SQL autentication based on Id and password created by user, in this case sa
    -  "Use Identifiers between "" ANSI " and "Use Null, filled and ANSI warning " are ticked.
    - Execute character data conversion.
    Microsoft SQL Native Client Versión 09.00.1399
    Nombre del origen de datos: Bisynf
    Descripción del origen de datos: BisynfDW
    Servidor: BISYNFGER
    Usar seguridad integrada: No
    Base de datos: (Default)
    Idioma: (Default)
    Cifrado de datos: No
    Certificado de servidor de confianza: No
    Multiple Active Result Sets (MARS): No
    Realizar conversión de los datos de caracteres: Yes
    Registrar consultas de larga ejecución: No
    Estadísticas del controlador de registro: No
    Usar configuración regional: No
    Usar identificadores entrecomillados ANSI: Yes
    Usar nulos, rellenos y advertencias ANSI: Yes
    Right now with Those setting is running ok again in Crystal Reports  but when i try to execute from SBO the error has changed the error now is "connection could not be opened", Report Name in this case "Informe Stock Total" { 1D2DBDC5-41DE-43C0-A23C-391E7AEF2A37}.rpt
    Tks a lot

  • Retrieve data from the same table

    i have a table with following fields
    emp_no,name,salary,department,dept_prev,prev_emp_no.
    now i want retrieve emp_no,name,salary,department, from the data base for a perticular employeee number along with dept_prev
    but dept_prev is the prev_emp_no dept_prev
    now iam doing two query like this
    first query to retreive name,salary,department
    select name,salary,department from employee where emp_no = 10
    second to retrieve the dept_prev from the same table but this
    dept_prev must be based on prev_emp_no
    select dept_prev from employee where emp_no in(select prev_emp_no from employee where emp_no =10)
    can any one suggest to combine these two queries in a single sql statements, because all the fieldds are from the same table.
    Thanks

    Would this one solve it?
    SELECT emp.NAME, emp.salary, emp.department,
           prev_emp.dept_prev
      FROM employee emp,
           employee prev_emp
    WHERE emp.emp_no      = 10
       AND prev_emp.emp_no = emp.prev_emp_no;
    not tested
    C.

  • How do I pull just the year from a date?

    I'm trying to pull just the year from a date and cannot figure out how this can be done. I tried the SUBSTR fuction but its not acting how I would expect. What I'm wanting to do is write a condition that says Item Birth Year = Current Year minus 23 I have a calc that figures the age from the difference in the birthdate and current year but I'd really like to just write a condition based just one years. Can this be done?

    Hello
    SUBSTR will only work on a string. To extract portions of a date you need to use the TO_CHAR command.
    To get the year you would use this: TO_CHAR(the_date,'YYYY')
    TO_CHAR takes 2 switches, the date to be manipulated and the portion to be extracted, with the portion in single quotes.
    Once you get used to manipulating dates like this other common pieces are: DD - extracts the day of the month, MON extracts the 3 character code for the month.
    Thus you can use this: TO_CHAR(sysdate,'DD-MON-YYYY') and it will convert the current date, June 7th 2012 to 07-JUN-2012
    Hope this helps
    Best wishes
    Michael

  • DB Connect Load - "Unknow error while uploading data from the DB Table"

    Hi Experts,
    We have our BI7 system connected to Oracle DB based third party tool. The loads are performing quite well in DEV environment.
    I would like to know, how we transport DB Connect datasources to Quality systems? Any different process to be followed for DB Connect datasources?
    At present the connections between BI Quality and the third party quality systems are established. We transported the DataSource from BI DEV system to BI quality system, but on trigerring an infopackage we are not able to perform loads. It prompts - "Unknow error while uploading data from the DB Table".
    Also on comparing the DataSources in DEV system and Quality system there are no fields in "Proposal" tab of datasource in Quality system. Also I cannot change or activate Datasource in Quality system as we dont have change access in quality.
    Please advice.
    Thanks,
    Abhijit

    Hi,
    Sorry for bumping an old thread ....
    Did this issue get ever get resolved?
    I am facing the same one. The loads work successfully in Dev. The transport for DBConnect DS also moved in successfully.
    One strange this is that DB User for dev did not automatically change to db user from quality when I transported the DBConnect datasource. DBCon DS still shows me the DB User from Dev in Quality system
    I get "Unknown Error" whenever I trigger the data package.
    Advait

  • Unable to get the data from the stored procedure

    Hello Folks,
    I have this stored procedure and am trying to get the data from the table stage_bill but for some reason i am not sure its not pulling the data.Am a beginner in pl/sql Can any one please help to find out. I can give the code below.
    create or replace procedure Load_FADM_Staging_Area_TEST(p_data_load_date date) is
    -- local variables
    v_start_date                date;
    v_end_date                  date;
    -- cursor starting
      CURSOR c_get_data
      IS
      SELECT
       a.batch_id 
    ,a.beginning_service_date 
    ,a.bill_id 
    ,a.bill_method 
    ,a.bill_number 
    ,a.bill_received_date 
    ,a.bill_status 
    ,a.bill_type 
    ,a.change_oltp_by 
    ,a.change_oltp_date 
    ,a.client_datafeed_code 
    ,a.client_id 
    ,a.created_date 
    ,a.date_of_incident 
    ,a.date_paid 
    ,a.deleted_oltp_by 
    ,a.deleted_oltp_date 
    ,a.duplicate_bill 
    ,a.ending_service_date 
    ,a.event_case_id 
    ,a.event_id 
    ,a.from_oltp_by 
    ,a.oltp_bill_status 
    ,a.review_status 
    ,'HRI' schema_name
    , sysdate Load_date
    ,'ETLPROCESS001' Load_user
    ,v_start_date as Row_Effective_Date
    ,null Row_End_date
    from stage_bill a
    where
    --created_date >= to_date('20101031 235959', 'YYYYMMDD HH24MISS')
    created_date >= v_start_date
    and
    --created_date <= to_date('20101111 235959', 'YYYYMMDD HH24MISS')
      created_date <= v_end_date
    and not exists
    (select
    b.batch_id 
    ,b.beginning_service_date 
    ,b.bill_id 
    ,b.bill_method 
    ,b.bill_number 
    ,b.bill_received_date 
    ,b.bill_status 
    ,b.bill_type 
    ,b.change_oltp_by 
    ,b.change_oltp_date 
    ,b.client_datafeed_code 
    ,b.client_id 
    ,b.created_date 
    ,b.date_of_incident 
    ,b.date_paid 
    ,b.deleted_oltp_by 
    ,b.deleted_oltp_date 
    ,b.duplicate_bill 
    ,b.ending_service_date 
    ,b.event_case_id 
    ,b.event_id 
    ,b.from_oltp_by 
    ,b.oltp_bill_status 
    ,b.review_status,
    b.schema_name,
    b.Load_date,
    b.Load_user,
    b.Row_Effective_Date,
    b.Row_End_Date
    from STG_FADM_HRI_STAGE_BILL_TEST b)
      -- cursor o/p variables
    v_batch_id                  stage_bill.batch_id%TYPE;
    v_beginning_service_date    stage_bill.beginning_service_date%TYPE;
    v_bill_id                   stage_bill.bill_id%TYPE;
    v_bill_method               stage_bill.bill_method%TYPE;
    v_bill_number               stage_bill.bill_number%TYPE;
    v_bill_received_date        stage_bill.bill_received_date%TYPE;
    v_bill_status               stage_bill.bill_status%TYPE;
    v_bill_type                 stage_bill.bill_type%TYPE;
      v_change_oltp_by            stage_bill.change_oltp_by%TYPE;
      v_change_oltp_date          stage_bill.change_oltp_date%TYPE;
      v_client_datafeed_code      stage_bill.client_datafeed_code%TYPE;
      v_client_id               stage_bill.client_id%TYPE;
      v_created_date          stage_bill.created_date%TYPE;
      v_date_of_incident    stage_bill.date_of_incident%TYPE;
      v_date_paid         stage_bill.date_paid%TYPE;
      v_deleted_oltp_by     stage_bill.deleted_oltp_by%TYPE;
      v_deleted_oltp_date    stage_bill.deleted_oltp_date%TYPE;
      v_duplicate_bill     stage_bill.duplicate_bill%TYPE;
      v_ending_service_date   stage_bill.ending_service_date%TYPE;
      v_event_case_id        stage_bill.event_case_id%TYPE;
      v_event_id            stage_bill.event_id%TYPE;
      v_from_oltp_by         stage_bill.from_oltp_by%TYPE;
      v_oltp_bill_status   stage_bill.oltp_bill_status%TYPE;
      v_review_status     stage_bill.review_status%TYPE;   
      v_schema_name        varchar(50);
      v_Load_date          date;
      v_Load_user            varchar(50);
      v_Row_Effective_Date   date;
      v_Row_End_Date         date;     
    Begin
    if  p_data_load_date is null then
        select (sysdate - 7), (sysdate - 1) into v_start_date, v_end_date from dual;
      elsif p_data_load_date is not null then
       select (p_data_load_date - 7), (p_data_load_date - 1) into v_start_date, v_end_date from dual;
      else
        raise_application_error('-20042', 'Data control - GetDataControlAuditData : Date parameter must be a date of this or a previous week.');
      end if;
    -- cursor c_get_data loop begin
    OPEN c_get_data;
        LOOP                                                       -- cursor c_get_data loop begin
          FETCH c_get_data
           INTO
            v_batch_id,
      v_beginning_service_date,
      v_bill_id ,
      v_bill_method ,
      v_bill_number,
      v_bill_received_date,
      v_bill_status,
      v_bill_type,
      v_change_oltp_by,
      v_change_oltp_date,
      v_client_datafeed_code,
      v_client_id,
      v_created_date,
      v_date_of_incident,
      v_date_paid,
      v_deleted_oltp_by,
      v_deleted_oltp_date,
      v_duplicate_bill,
      v_ending_service_date ,
      v_event_case_id ,
      v_event_id,
      v_from_oltp_by,
      v_oltp_bill_status,
      v_review_status,   
      v_schema_name,
       v_Load_date,
       v_Load_user,
       V_Row_Effective_Date,   
       v_Row_End_Date;
        EXIT WHEN c_get_data%NOTFOUND;
    insert into STG_FADM_HRI_STAGE_BILL_TEST
    batch_id 
    ,beginning_service_date 
    ,bill_id 
    ,bill_method 
    ,bill_number 
    ,bill_received_date 
    ,bill_status 
    ,bill_type 
    ,change_oltp_by 
    ,change_oltp_date 
    ,client_datafeed_code 
    ,client_id 
    ,created_date 
    ,date_of_incident 
    ,date_paid 
    ,deleted_oltp_by 
    ,deleted_oltp_date 
    ,duplicate_bill 
    ,ending_service_date 
    ,event_case_id 
    ,event_id 
    ,from_oltp_by 
    ,oltp_bill_status 
    ,review_status 
    ,schema_name
    ,Load_date
    ,Load_user
    ,Row_Effective_Date
    ,Row_End_Date
    values(
           v_batch_id,
    v_beginning_service_date,
    v_bill_id ,
    v_bill_method ,
    v_bill_number,
    v_bill_received_date,
    v_bill_status,
    v_bill_type,
    v_change_oltp_by,
    v_change_oltp_date,
    v_client_datafeed_code,
    v_client_id,
    v_created_date,
    v_date_of_incident,
    v_date_paid,
    v_deleted_oltp_by,
    v_deleted_oltp_date,
    v_duplicate_bill,
    v_ending_service_date ,
    v_event_case_id ,
    v_event_id,
    v_from_oltp_by,
    v_oltp_bill_status,
    v_review_status,   
    v_schema_name,
    v_Load_date,
    v_Load_user,
    v_Row_Effective_Date,   
    v_Row_End_Date ) ;
      COMMIT;
        END LOOP;                                                 
        CLOSE c_get_data; 

    Maybe you need something else, like
    CREATE OR REPLACE PROCEDURE load_fadm_staging_area_test (
      p_data_load_date DATE
    ) IS
      v_start_date   DATE;
      v_end_date     DATE;
    BEGIN
      SELECT NVL (p_data_load_date, SYSDATE) - 7,
             NVL (p_data_load_date, SYSDATE) - 1
      INTO   v_start_date,
             v_end_date
      FROM   DUAL;
      MERGE INTO stg_fadm_hri_stage_bill_test b
      USING      (SELECT *
                  FROM   stage_bill
                  WHERE  created_date BETWEEN v_start_date AND v_end_date) a
      ON         (b.bill_id = a.billl_id)
      WHEN NOT MATCHED THEN
        INSERT     (batch_id,
                    beginning_service_date,
                    bill_id,
                    bill_method,
                    bill_number,
                    bill_received_date,
                    bill_status,
                    bill_type,
                    change_oltp_by,
                    change_oltp_date,
                    client_datafeed_code,
                    client_id,
                    created_date,
                    date_of_incident,
                    date_paid,
                    deleted_oltp_by,
                    deleted_oltp_date,
                    duplicate_bill,
                    ending_service_date,
                    event_case_id,
                    event_id,
                    from_oltp_by,
                    oltp_bill_status,
                    review_status,
                    schema_name,
                    load_date,
                    load_user,
                    row_effective_date,
                    row_end_date
        VALUES     (a.batch_id,
                    a.beginning_service_date,
                    a.bill_id,
                    a.bill_method,
                    a.bill_number,
                    a.bill_received_date,
                    a.bill_status,
                    a.bill_type,
                    a.change_oltp_by,
                    a.change_oltp_date,
                    a.client_datafeed_code,
                    a.client_id,
                    a.created_date,
                    a.date_of_incident,
                    a.date_paid,
                    a.deleted_oltp_by,
                    a.deleted_oltp_date,
                    a.duplicate_bill,
                    a.ending_service_date,
                    a.event_case_id,
                    a.event_id,
                    a.from_oltp_by,
                    a.oltp_bill_status,
                    a.review_status,
                    'HRI',
                    SYSDATE,
                    'ETLPROCESS001',
                    v_start_date,
                    NULL
    END load_fadm_staging_area_test;Whenever you code a cursor and a loop, ask yourself. Do I need that?
    Regards
    Peter

  • TcpListener not working on Azure: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host

    Hi Everybody,
    i'm playing a little bit with Windows Azure and I'm blocked with a really simple issue (or maybe not).
    I've created a Cloud Service containing one simple Worker Role. I've configured an EndPoint in the WorkerRole configuration, which allows Input connections via tcp on port 10100.
    Here the ServiceDefinition.csdef file content:
    <?xml version="1.0" encoding="utf-8"?>
    <ServiceDefinition name="EmacCloudService" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2014-01.2.3">
    <WorkerRole name="TcpListenerWorkerRole" vmsize="Small">
    <Imports>
    <Import moduleName="Diagnostics" />
    <Import moduleName="RemoteAccess" />
    <Import moduleName="RemoteForwarder" />
    </Imports>
    <Endpoints>
    <InputEndpoint name="Endpoint1" protocol="tcp" port="10100" />
    </Endpoints>
    </WorkerRole>
    </ServiceDefinition>
    This WorkerRole is just creating a TcpListener object listening to the configured port (using the RoleEnvironment instance) and waits for an incoming connection. It receives a message and returns a hardcoded message (see code snippet below).
    namespace TcpListenerWorkerRole
    using System;
    using System.Net;
    using Microsoft.WindowsAzure.ServiceRuntime;
    using System.Net.Sockets;
    using System.Text;
    using Roche.Emac.Infrastructure;
    using System.IO;
    using System.Threading.Tasks;
    using Microsoft.WindowsAzure.Diagnostics;
    using System.Linq;
    public class WorkerRole : RoleEntryPoint
    public override void Run()
    // This is a sample worker implementation. Replace with your logic.
    LoggingProvider.Logger.Info("TcpListenerWorkerRole entry point called");
    TcpListener listener = null;
    try
    listener = new TcpListener(RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["Endpoint1"].IPEndpoint);
    listener.ExclusiveAddressUse = false;
    listener.Start();
    LoggingProvider.Logger.Info(string.Format("TcpListener started at '{0}:{1}'", RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["Endpoint1"].IPEndpoint.Address, RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["Endpoint1"].IPEndpoint.Port));
    catch (SocketException ex)
    LoggingProvider.Logger.Exception("Unexpected exception while creating the TcpListener", ex);
    return;
    while (true)
    Task.Run(async () =>
    TcpClient client = await listener.AcceptTcpClientAsync();
    LoggingProvider.Logger.Info(string.Format("Client connected. Address='{0}'", client.Client.RemoteEndPoint.ToString()));
    NetworkStream networkStream = client.GetStream();
    StreamReader reader = new StreamReader(networkStream);
    StreamWriter writer = new StreamWriter(networkStream);
    writer.AutoFlush = true;
    string input = string.Empty;
    while (true)
    try
    char[] receivedChars = new char[client.ReceiveBufferSize];
    LoggingProvider.Logger.Info("Buffer size: " + client.ReceiveBufferSize);
    int readedChars = reader.Read(receivedChars, 0, client.ReceiveBufferSize);
    char[] validChars = new char[readedChars];
    Array.ConstrainedCopy(receivedChars, 0, validChars, 0, readedChars);
    input = new string(validChars);
    LoggingProvider.Logger.Info("This is what the host sent to you: " + input+". Readed chars=" + readedChars);
    try
    string orderResultFormat = Encoding.ASCII.GetString(Encoding.ASCII.GetBytes("\xB")) + @"MSH|^~\&|Instrument|Laboratory|LIS|LIS Facility|20120427123212+0100||ORL^O34^ORL_O34| 11|P|2.5.1||||||UNICODE UTF-8|||LAB-28^IHE" + Environment.NewLine + "MSA|AA|10" + Environment.NewLine + @"PID|||patientId||""""||19700101|M" + Environment.NewLine + "SPM|1|sampleId&ROCHE||ORH^^HL70487|||||||P^^HL70369" + Environment.NewLine + "SAC|||sampleId" + Environment.NewLine + "ORC|OK|orderId|||SC||||20120427123212" + Encoding.ASCII.GetString(Encoding.ASCII.GetBytes("\x1c\x0d"));
    writer.Write(orderResultFormat);
    catch (Exception e)
    LoggingProvider.Logger.Exception("Unexpected exception while writting the response", e);
    client.Close();
    break;
    catch (Exception ex)
    LoggingProvider.Logger.Exception("Unexpected exception while Reading the request", ex);
    client.Close();
    break;
    }).Wait();
    public override bool OnStart()
    // Set the maximum number of concurrent connections
    ServicePointManager.DefaultConnectionLimit = 12;
    DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString");
    RoleEnvironment.Changing += RoleEnvironment_Changing;
    return base.OnStart();
    private void RoleEnvironment_Changing(object sender, RoleEnvironmentChangingEventArgs e)
    // If a configuration setting is changing
    LoggingProvider.Logger.Info("RoleEnvironment is changing....");
    if (e.Changes.Any(change => change is RoleEnvironmentConfigurationSettingChange))
    // Set e.Cancel to true to restart this role instance
    e.Cancel = true;
    As you can see, nothing special is being done. I've used the RoleEnvironment.CurrentRoleInstance.InstanceEndpoints to retrieve the current IPEndpoint.
    Running the Cloud Service in the Windows Azure Compute Emulator everything works fine, but when I deploy it in Azure, then I receive the following Exception:
    2014-08-06 14:55:23,816 [Role Start Thread] INFO EMAC Log - TcpListenerWorkerRole entry point called
    2014-08-06 14:55:24,145 [Role Start Thread] INFO EMAC Log - TcpListener started at '100.74.10.55:10100'
    2014-08-06 15:06:19,375 [9] INFO EMAC Log - Client connected. Address='196.3.50.254:51934'
    2014-08-06 15:06:19,375 [9] INFO EMAC Log - Buffer size: 65536
    2014-08-06 15:06:45,491 [9] FATAL EMAC Log - Unexpected exception while Reading the request
    System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
    at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
    --- End of inner exception stack trace ---
    at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
    at System.IO.StreamReader.ReadBuffer(Char[] userBuffer, Int32 userOffset, Int32 desiredChars, Boolean& readToUserBuffer)
    at System.IO.StreamReader.Read(Char[] buffer, Int32 index, Int32 count)
    at TcpListenerWorkerRole.WorkerRole.<>c__DisplayClass0.<<Run>b__2>d__0.MoveNext() in C:\Work\Own projects\EMAC\AzureCloudEmac\TcpListenerWorkerRole\WorkerRole.cs:line 60
    I've already tried to configure an internal port in the ServiceDefinition.csdef file, but I get the same exception there.
    As you can see, the client can connect to the service (the log shows the message: Client connected with the address) but when it tries to read the bytes from the stream, it throws the exception.
    For me it seems like Azure is preventing the retrieval of the message. I've tried to disable the Firewall in the VM in Azure and the same continues happening.
    I'm using Windows Azure SDK 2.3
    Any help will be very very welcome!
    Thanks in advance!
    Javier
    En caso de que la respuesta te sirva, porfavor, márcala como válida
    Muchas gracias y suerte!
    Javier Jiménez Roda
    Blog: http://jimenezroda.wordpress.com

    hi Javier,
    I changed your code like this:
    private AutoResetEvent connectionWaitHandle = new AutoResetEvent(false);
    public override void Run()
    TcpListener listener = null;
    try
    listener = new TcpListener(
    RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["Endpoint"].IPEndpoint);
    listener.ExclusiveAddressUse = false;
    listener.Start();
    catch (SocketException se)
    return;
    while (true)
    IAsyncResult result = listener.BeginAcceptTcpClient(HandleAsyncConnection, listener);
    connectionWaitHandle.WaitOne();
    The HandleAsync method is your "While (true)" code:
    private void HandleAsyncConnection(IAsyncResult result)
    TcpListener listener = (TcpListener)result.AsyncState;
    TcpClient client = listener.EndAcceptTcpClient(result);
    connectionWaitHandle.Set();
    NetworkStream netStream = client.GetStream();
    StreamReader reader = new StreamReader(netStream);
    StreamWriter writer = new StreamWriter(netStream);
    writer.AutoFlush = true;
    string input = string.Empty;
    try
    char[] receivedChars = new char[client.ReceiveBufferSize];
    // LoggingProvider.Logger.Info("Buffer size: " + client.ReceiveBufferSize);
    int readedChars = reader.Read(receivedChars, 0, client.ReceiveBufferSize);
    char[] validChars = new char[readedChars];
    Array.ConstrainedCopy(receivedChars, 0, validChars, 0, readedChars);
    input = new string(validChars);
    // LoggingProvider.Logger.Info("This is what the host sent to you: " + input + ". Readed chars=" + readedChars);
    try
    string orderResultFormat = Encoding.ASCII.GetString(Encoding.ASCII.GetBytes("\xB")) + @"MSH|^~\&|Instrument|Laboratory|LIS|LIS Facility|20120427123212+0100||ORL^O34^ORL_O34| 11|P|2.5.1||||||UNICODE UTF-8|||LAB-28^IHE" + Environment.NewLine + "MSA|AA|10" + Environment.NewLine + @"PID|||patientId||""""||19700101|M" + Environment.NewLine + "SPM|1|sampleId&ROCHE||ORH^^HL70487|||||||P^^HL70369" + Environment.NewLine + "SAC|||sampleId" + Environment.NewLine + "ORC|OK|orderId|||SC||||20120427123212" + Encoding.ASCII.GetString(Encoding.ASCII.GetBytes("\x1c\x0d"));
    writer.Write(orderResultFormat);
    catch (Exception e)
    // LoggingProvider.Logger.Exception("Unexpected exception while writting the response", e);
    client.Close();
    catch (Exception ex)
    //LoggingProvider.Logger.Exception("Unexpected exception while Reading the request", ex);
    client.Close();
    Please try it. For this error message, I suggest you could refer to this thread (http://stackoverflow.com/questions/6173763/using-windows-azure-to-use-as-a-tcp-server
    ) and this post (http://stackoverflow.com/a/5420788).
    Regards,
    Will
    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.

Maybe you are looking for

  • Is there a way to create an index through Pages?

    I would like to create an index for a book using Pages where I have created the book.  Is there a tool in Pages that will set up an index automatically or more easily than using find and the page number?

  • ThinkPad OneLink Dock USB Probleme

    Hallo Forum, ich habe bei meinem OneLink Dock das Problem, dass ich an keinem der USB-Ports Drucker installieren kann... Ich habe das Gerät bereits einmal austauschen lassen; doch auch beim neuen Gerät leider kein Erfolg. Schließe ich den Drucker am

  • Discover: error: The file /a.out was linked by an older link step. Please use the latest compiler to do the link.

    Hi, I have installed Solaris studio and wanted to use the memory analyzer from there. I am trying it on a sample program, but it returns the above error and does not instrument the executable. Could you please help me tracing where am I going wrong.

  • SIGBUS with -Xincgx/-Xconcgc for JDK 1.5 on multi-CPU system

    Hi, I've been having trouble with random crashes using 1.5.0_03 up to _07 on Solaris and Linux (x86), especially on multi-CPU hosts. This is for a Web server (Tomcat 4.1.x), where CMS has been wonderful in avoiding the sometimes-horrible (multi-minut

  • Opening balnce

    Hii All             i am in a roll out project i want to know how upload all opening balnce with new g/l account. i knw normally we done through with the help of BDC  &  LSMW. i need to knw  how to frame this thing with lsmw.. Regards   Ajeesh.s