Retrieving spatial and non spatial data in one query

Hello. I am having slight difficulties using JDBC to retrieve both spatial and non spatial data in the same query. The following is code from a sample program of mine that retrives spatial data from spatial tables.
(In spatialquery geom is a geometry column and city is simply the name of the city):
try
Geometry geom = null;
String database = "jdbc:oracle:thin:@" + m_host + ":" + m_port + ":" + m_sid;
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
con = (OracleConnection)DriverManager.getConnection(database, sUsername, sPassword);
GeometryAdapter sdoAdapter =
OraSpatialManager.getGeometryAdapter("SDO", "8.1.7", STRUCT.class, null, null, con);
String spatialquery = "SELECT a1.geom, a1.city \n" +
"FROM cities a1";
Statement stmt = con.createStatement();
OracleResultSet rs = (OracleResultSet) stmt.executeQuery(spatialquery);
int i = 0;
int noOfFeatures = 2;
while (rs.next())
for(i = 1; i <= noOfFeatures; i++)
STRUCT dbObject = (STRUCT)rs.getObject(i);
try
geom = sdoAdapter.importGeometry(dbObject);
catch(GeometryInputTypeNotSupportedException e)
System.out.println("Input Type not supported");
catch(InvalidGeometryException e)
System.out.println("Invalid geometry");
System.out.println(geom);
}//end while loop
This retrieves the sptial data fine, however when I attempt to retreive the non-spatial data I keep getting a "ClassCastException" error. I understand it is something to do with "STRUCT dbObject = (STRUCT)rs.getObject(i);" line. Can anyone tell me how to retrieve both spatial and non-spatial data in the one query using JDBC. I have tried nearly everything at this stage. Cheers joe

Theresa A Radke
Posts: 20
OTN Member Since: Jul, 2001
retrieving spatial and non spatial in same query. May 23, 2003 12:02 AM
retrieving spatial and non spatial in same query.

Similar Messages

  • Grouped and non-grouped SELECT in one query: help!

    look first at: Wrong result when I use CASE on this forum. Here I wanted to get the user who created and the user who solved a problem (Lets call it Validation Error from now on (VE)).
    The thing is: I already have a query who returns me lots of information about a VE.
    The query in the previous thread returned me additional info about that VE (that is the creating_user and the solving_user). The 1st query is no group select, but the second is! Still, I need to combine those two in one query.
    1st query:
    select ve.seq,
         max((case vah.action when 'C' then vah.ur_code else null end)) created,
         max((case vah.action when 'S' then vah.ur_code else null end)) solved
    from validation_errors ve
    left outer join ver_action_histories vah
    on (ve.seq = vah.ver_seq AND ve.log_date = vah.ver_log_date)
    where ve.seq = 12860687
    group by ve.seq;Result:
    seq       | created | solved
    12860687    Bob       Bobdont mind the "where"-clause, it is just to make the query go faster
    what I do is: I join the VE with the ver_action_histories table which contains the users and what action they performed on a VE.
    Now I just want to add that information to the results of an other query which also returns lots of information about a VE.
    2nd query:
    select ve.seq "VE seq", mh.seq "Counter seq",
              ve.log_date, ve.solve_date, ve.solved Status, ve.failure_code, ve.mde_code,
              mh.meter_type,
              iv.mr_type, iv.mr_reason,
              ih.mmr_seq
    from validation_errors ve
    inner join meter_histories mh
    on (ve.mhy_seq = mh.seq)
    left outer join index_values iv
    on (ve.mhy_seq = iv.mhy_seq AND ve.log_date =iv.timestamp)
    left outer join index_histories ih
    on (ve.mhy_seq = ih.ive_mhy_seq)
    where ve.seq = 8653936
    and sysdate >= mh.start_date
    and sysdate < mh.end_date;dont mind the "where" and "and"-clauses ... I hope the result of this query will simplify things ...
    Result:
    seq        |   counter seq | log_date | solved_date | status    | failure_code | ...
    12860687       4568          1-jan-06   2-jan-06      Solved      ABCNow the actual question: Is it possible to combine those queries in one query? I just want the results of the first query (creating_user and solving_user) to be added as columns to the second result. Performance is very important. Please tell me that its possible?
    Wanted Result:
    seq        |   counter seq | log_date | solved_date | status    | failure_code | created  | solved  | ...
    12860687       4568          1-jan-06   2-jan-06      Solved      ABC            Bob        BobIf anything I explained is unclear, please tell so I can try to explain it in an easier way.

    Try an in line view:
    select *
    from
    ( <your first query goes here > ) a
    , ( <your second query goes here > ) b
    where a.seq = b.seq

  • Is it possible to add value item and non stock item in one billing?

    Is it possible to add value item and non stock item in one billing?

    Hi,
    Yes,it is possible .Take example of service scenario,where material used in servicing and service charges(labour) can be billed in single invoice.
    Billing document type,Customer and other header data should be same.
    Reward points if useful
    Regards,
    Amrish Purohit

  • SAP and Non-SAP data to Xcelsius

    Hi Experts,
    I m new to Xcelsius and i a m currently working on Xcelsius project, i need help on approach to bring both SAP and Non-SAP data to Xcelsius. Here the scenario goes on....
    Total 6 plants are there, out of 6, 4 plants are on SAP and other 2 plants are on Non-SAP (Excel)
    The requirement is to develop a dashboard to see all the plants details (both SAP and Non-SAP)
    The approach i suggested for SAP: ECC --> BW --> InfoProvider --> Query --> QaaWS --> Xcelsius
    For non-sap, data is available in excel, so we can bring that data directly to xcelsius, but problem is how to make it dynamaic because data in excel changes daily.
    So my doubt is, if i  develop a universe on excel files, then how to combine both SAP and Non-SAP universes. Is Data Federator is required for this or is there any approach to bring both SAP and Non-SAP data to Xcelsius.
    Can any one help me on this
    Thanks & Regards
    Ramakrishna Kamurthy

    hi
    Another approach which i have used in the past is to have data in XML format, placed on a web server.  When my data changes daily, i just export my data from excel or whatever source into the XML format..
    Use the XML data connector to bring into xcelsius.
    thanks.. hope this helps
    regards
    Jeff.

  • Migrate PY and TM cluster data from One SAP System to another

    Hi Experts,
    Could you please suggest me some options to migrate PY and TM cluster data from One SAP System to another? My requirement is to move all the cluster data (Active and Inactive ees).
    I see that PU12 is an option. Anybody used that to migrate between SAP systems. Please provide some details
    Points guaranteed
    I see that using PU12 you can export only PCL2 Clutsers. Are there any ways to move the other clusters like PCL4 ?

    Hi,
    As far as data transfer, If have all normal configuration settings in your targeted system you can use LSMW (Use T.code AS91 in LSMW for recording)  to transfer your data in your both cases.
    Hope it resolves your both the issues.
    Regards,
    Murali

  • Filter Data with Merged and non merged columns in one

    Hi there,
    I have an excel spreadsheet that has got merged and non merged columns. What I want to be able to do is, filter a row that has got merged column and non merged columns. But when I filter it only takes the first line, rather than the merged and non merged
    columns.
    With this data I have one merged column which spans 6 rows, and then in the same row I have 6 rows with different points in, and what I want to do is filter my list, but be able to see the merged coloum aswell as the 6 points.
    Any ideas are much appriciated.
    Cheers
    SAN

    You cannot filter across a row - so I have assumed that what you mean is that some cells in columns are merged to serve as the headers, and the data is in the came columns but in the row(s) below the header. If this is incorrect, ignore this post.
    For this example, I have assumed E to J are the column of data and merged cells, column K is free, and the first merged header is in row 1:
    In K1, enter
    =E1
    in K2, enter
    =IF(COUNTA(E2:J2)=1,E2,K1)
    and copy down. Then filter based on column K, and it will show the headers and the data for the selected header value.
    HTH, Bernie

  • JAX-RPC and non-primitive data types

    Hello all!
    I am using JWSDP v1.3 and i have a problem using non-primitive data types as return types for my operations.
    Consider the helloservice example of the JWSDP1.3 tutorial. Now suppose that instead of having the simple operation sayHello() that returns a String, we execute a query on a database, get some ResultSetMetaData and we want these Metadata to be the return type of our operation. I.e. have the operation
    public ResultSetMetaData sayHello()
    instead of the
    public String sayHello()
    of the tutorial.
    When trying to build the service i get the following error which is normal, because ResultSetMetaData is not a supported JAX-RPC type.
    run-wscompile: [echo] Running wscompile: [echo] C:\jwsdp\apache-ant\../jaxrpc/bin/wscompile.bat -define -d build - nd build -classpath build config-interface.xml -model build/model. gz [exec] error: invalid type for JAX-RPC structure: java.sql.ResultSetMetaData [exec] Result: 1
    Is there any way to define an operation like this? Can i specify somehow ResultSetMetaData as a supported-type?
    I hope someone can give me some advice on it, because i have lost one evening trying to figure it out myself :)
    Regards,
    Kostas

    Courtesy links to crossposts so people don't waste their time answering a question which has already been answered
    http://forum.java.sun.com/thread.jsp?thread=482875&forum=59&message=2253704
    http://forum.java.sun.com/thread.jsp?thread=482873&forum=331&message=2253699

  • Numeric and Non Numeric Data

    Hi,
    I have to check the data in Varchar2 field idtr and if it is numeric some actions are to be done on the data and if it is numeric some other different action is to be done.
    So I used some logic for finding whether the data is numeric or non numeric which I got it from the net.
    Now my problem is all decimal numbers are to be treated as numeric but this logic is treating decimals as non numeric and I am not able to proceed further.
    Can some one help me out in this issue.
    Below is the Logic and actions I am doing
    select      pol_id,lpad(substr(trunc(to_number(idtr),0),1,10),10,0),idtr
    from           pl_insrd
    where      length(idtr) - length(translate(idtr,chr(1)||translate(idtr,CHR(1)||'1234567890',CHR(1) ),CHR(1) ) ) = 0
    and           length(idtr) > 9
    UNION
    select      pol_id,lpad(trunc(idtr,0),10,0),idtr
    from           pl_insrd
    where      length(idtr) - length(translate(idtr,chr(1)||translate(idtr,CHR(1)||'1234567890',CHR(1) ),CHR(1) ) ) = 0
    and           length(idtr) < 10
    UNION
    select      pol_id,substr(idtr,1,10),idtr
    from           pl_insrd
    where      length(idtr) - Length(TRANSLATE(idtr,CHR(1)||TRANSLATE(idtr,CHR(1)||'1234567890', CHR(1) ), CHR(1) ) ) > 0
    and           length(idtr) > 9
    UNION
    select      pol_id,lpad(idtr,10,0),idtr
    from      pl_insrd
    where      length(idtr) - Length(TRANSLATE(idtr,CHR(1)||TRANSLATE(idtr,CHR(1)||'1234567890', CHR(1) ), CHR(1) ) ) > 0
    and           length(idtr) < 10

    <quote>One I provided was I found at asktom.oracle.com</quote>
    So? ... If you'd provided a link then one could see the entire context for that particular snippet of code and decide if it is indeed appropriate. As shown by Angus it is not always appropriate ... add to that, NULL is not a number as that function reports.
    <quote>It's using replace and transalate functions which are less expensive then To_Number function.</quote>
    Proof?
    <quote>I agree with you [John], that's the best function you can use to validate data for numeric.<quote>
    I don't agree to_number() is [always] the best way ... the easiest way? ... maybe.
    My personal view is that there is no universal way to determine if a string, in all circumstances, can be translated into a number. One has to have knowledge of the source data domain ... only you know if, in your particular circumstance, '1e4' is or is not a NUMBER represented as a string.
    flip@FLOP> select to_number('1e3') from dual;
    TO_NUMBER('1E3')
    1000

  • Unicode and Non-Unicode Instances in one Transport Landscape

    We have a 4.7 landscape that includes a shared global development system supporting two regional landscapes.  The shared global development system is used for all ABAP/Workbench activity and for global customization used by both regional production systems.  The two regional landscapes include primarily three instances - Regional Configuration, Quality Assurance, and Production.  The transport landscape includes all systems with transport routes for global and regional.
    A conversion to unicode is also being planned for the global development and one regional landscape.  It is possible that we will not convert the other regional landscape due to pending discussions on consolidation.  This means one of the regional landscapes will be receiving global transports from a unicode-based system.  
    All information I've located implies no actual technical constraints.  Make sure you have the right R3trans versions, don't use non-Latin_1 languages, etc.  Basic caveats for a heterogenous environment ....
    Is anyone currently supporting a complete, productive landscape that includes unicode and non-unicode systems?   If so, any issues or problems encountered with transports across the systems?  (insignificant or significant)
    Information on actual experiences will be greatly appreciated ....
    Many thanks in advance.

    Hi Laura,
    Although i do not have the live / practical experience, but this is what i can share.
    I have been working on a Non-Unicode to Unicode conversion project. While we were in the discussion phase there was one such possibility of a scenario that part of the landscapes would remain non-unicode. So based on the research i did by reading and directly interacting with some excellent SPA consultants, i came to know there are absolutely no issues in transporting ABAP programs from a Unicode system to non-unicode system. In a Unicode system the ABAP code has already been checked and rectified for higher syntax checks and these are downward compatible with the ABAP code on lower ABAP versions and non-unicode systems. Hence i beleive there should not be any issues, however as i mentioned this is not from practical experience.
    Thanks.
    Chetan

  • Can we have xl and non-xl card in one chassis?

    Hello,
    In cisco document it is mentioned that to work as XL, all card in chassis must be XL (apart from scalable license requirement). Is it a chassis or vdc specific requirement?
    In below case we have create two vdcs in one n7k switch and installed the scalable license. Vdc 2 have both mixed ( XL and non-XL) module interfaces whereas VDC 3 have only XL module interfaces
    VDC 2-
    xl + non xl M-series module interfaces
    vdc 3 -
    only XL M-series module interfaces
    Can anyone please confirm if my below understanding is correct ?
    1. VDC 2 will work in Non-mode
    2. VDC 3 will work in XL mode.

    Hi babu,
    You can do this in one view it self.
    create a one attribute of type wdy_boolean.. in view context.
    Bind these attribute to read only property of table.. and  initially set the value to abap_true in wddoinit method.
    Then create one button say "EDIT" in view and create action for edit button.. in that action set the above attribute value to
    abap_false.
    so now, initially table will be in display mode, when you click on edit mode...it will become editable mode...
    Hope you got some idea.
    Regards
    Srinvias

  • Re: Segregate leading and non-leadingledger data in BI Cube

    Hello,
    I would like to share the following Scenario with you all:
    I want to extract leading ledger and non-leading ledger data into a BI cube. Sure, the answer is yes.
    Would it be possible to segregate both leading and non-leading ledger data within a BI cube? Or the only possibility is to load leading and non-leading ledger data into two different cubes?
    Please advise.
    Thanks
    RJ

    Hi RJ,
    Depending on what datasource you are using, it will provide a field that indicates the ledger. The new general ledger datasources provide the field RLDNR for this purpose, and you'll need to make sure to carry through this value to the BW DSO or Cube that you are using - [http://help.sap.com/saphelp_bic706sp01/helpdata/en/45/757140723d990ae10000000a155106/frameset.htm]
    Cheers,
    Ethan

  • OO4O to Retrieve Spatial Data (SDO_GEOMETRY)

    Does anyone have any sample code in VB or C++ to retrieve data from the SDO_GEOMETRY object? Any code or suggestions would be much appreciated.

    oracle spatial has built-in functions that can do this job,I think you can find in the spatial reference book,here is an example that find the nearest 5 outlet beside a warehouse
    REM Finds the 5 closest customers to warehouse_id = 3
    REM who reside in NY state, and return the distance in miles,
    REM and order the results by distance
    REM
    REM CUSTOMERS and WAREHOUSES
    REM
    set lines 132
    set pages 1000
    select /*+ordered*/
    c.customer_id,
    c.cust_address.state_province state,
    sdo_nn_distance(1) distance_in_miles
    from warehouses w,
    customers c
    where w.warehouse_id = 3
    and sdo_nn (c.cust_geo_location, w.wh_geo_location,
    'sdo_batch_size =5 unit=mile', 1) = 'TRUE'
    and c.cust_address.state_province = 'NY'
    and rownum < 6
    order by distance_in_miles;

  • How to retrieve spatial data in VC?

    I have tried many ways ,but i can't do it
    did someone do it before??

    The Visual SDO demo works with ORACLE 8.1.7. The problem is a small BUG in the source code.
    You have to make 2 small changes in the "sdogeomcursor.cpp" file (see changes below). After that the demo works with
    the "cola_markets" and the "counties" demo-table at least...
    Cheers,
    Johannes
    Look for function:
    BOOL SDOGeomCursor::SDOMirrorToClient(CSDOMirrorGeom* mirrorGeom,
    CSDOMirrorGeomInd* mgIndicator,
    CSDODimArray* dimArray,
    CSDOGeometry* geom)
    // Process elements one by one
    for (elemCount = 0, thisIndex = 0; thisIndex < nEIUnits;
    elemCount++, thisIndex++)
    CSDOElement elem;
    // Get the element info structure
    startOffset = mirrorGeom->sdo_elem_info[thisIndex*3];
    elem.m_nElemType = mirrorGeom->sdo_elem_info[thisIndex*3+1];
    elem.m_nElemItpr = mirrorGeom->sdo_elem_info[thisIndex*3+2];
    elem.m_nElemType = elem.m_nElemType % 1000; //<------------------------------Add this line (Change 1)
    if (elem.m_nElemType == 4 || elem.m_nElemType == 5)
    nSegs = elem.m_nElemItpr;
    else
    nSegs = 0;
    nextIndex = thisIndex + nSegs + 1;
    // GTYPE support:
    // 0 -- Unsupported type, ignore all elements
    // 1 -- Points only, ignore all string and polygon elements
    // 2 -- Strings only, ignore all point and polygon elements
    // 3 -- Polygons only, ignore all point and string elements
    // 4 -- Mixed, load all elements
    // 5 -- Point collection, same as GTYPE 1
    // 6 -- String collection, same as GTYPE 2
    // 7 -- Polygon collection, same as GTYPE 3
    BOOL ignoreElement = FALSE;
    switch (geom->m_nGeomType % 1000) //<------------------------------Change line to this (Change 2)
    case 0: // ignore all

  • Performing ORM and non-ORM transactions in one request.

    During the processing of a request, we need to perform an ORM statement and a non-ORM cftransaction on 2 different data sources.
    Example:
    # Note, 'someObject' is a persistent CFC with a datasource attribute of 'DSN1'.
    <cftransaction>
         <cfset myObjects = EntityLoad('someObject') />
    </cftransaction>
    <cftransaction>
         <cfquery name="test" datasource="DSN2">
               INSERT INTO ...
         </cfquery>
    </cftransaction>
    Whenever we hit the 2nd cftranaction block, we get the following error:
    Message=A transaction cannot be started on more than one datasource.
    This works in CF 9.0.1, but fails on CF 9.0.1 HF3, CF 9.0.2, and on CF 10.

    javax.servlet.ServletRequest method isSecure() - "Returns a boolean indicating
    whether this request was made using a secure channel, such as HTTPS."
    Chris Scott wrote:
    >
    What's the best way to separate SSL andnon-SSL transactions in a single web app?Ie when the user logs in, the login formis submitted over an SSL connection, butfrom then on only certain pages/forms useSSL. If there's one JVM with the sessioninfo, how can we be sure what needs to besecured goes thru the SSL server?

  • Download the KTOPL  field data and GLT0 table data into one Internal table

    Hi,
    I have downloaded GLT0 table fields  data to PC file . But i need to download KTOPL(Chart Of Accounts) data also. in GLT0 table there is no KTOPL field.
    But in SKA1 table have KTOPL field. Then what is the issue is GLT0 data & KTOPL field data needs to download into one Internal Table.
    anybody could you please solve this problem. immediately need to solve this.
    Below is the code.
    REPORT ZFXXEABL_1 NO STANDARD PAGE HEADING
                    LINE-SIZE 200.
    Tables Declaration
    TABLES : GLT0.
    Data Declaration
    DATA :   FP(8)           TYPE C,
             YEAR           LIKE GLT0-RYEAR,
             PERIOD(3)       TYPE C,
             DBALANCE         LIKE VBAP-NETWR VALUE 0 ,
             CBALANCE         LIKE VBAP-NETWR VALUE 0.
    *Internal table for for final data..
    DATA : BEGIN OF REC1 OCCURS 0,
           BAL             LIKE GLT0-TSLVT value 0,
           COAREA          LIKE GLT0-RBUSA,
          CA(4)           TYPE C,
           KTOPL           LIKE ska1-ktopl, 
           CCODE           LIKE GLT0-BUKRS,
           CREDIT          LIKE  VBAP-NETWR,
           CURRENCY        LIKE GLT0-RTCUR,
           CURTYPE(2)      TYPE N,
           DEBIT           LIKE VBAP-NETWR,
           YEAR(8)         TYPE C,
           FY(2)           TYPE C,
           ACCOUNT         LIKE GLT0-RACCT,
           VER             LIKE GLT0-RVERS,
           VTYPE(2)        TYPE N,
           CLNT            LIKE SY-MANDT,
           S_SYS(3)        TYPE C,
           INDICATOR      LIKE GLT0-DRCRK,
           END OF REC1.
    DATA : C(2) TYPE N,
           D(2) TYPE N.
    DATA REC1_H LIKE REC1.
    Variable declarations
    DATA :
           W_FILES(4) TYPE N,
           W_DEBIT LIKE GLT0-TSLVT,
           W_CREDIT LIKE GLT0-TSLVT,
           W_PCFILE LIKE RLGRAP-FILENAME ,
           W_UNIXFILE LIKE RLGRAP-FILENAME,
           W_PCFILE1 LIKE RLGRAP-FILENAME,
           W_UNIXFIL1 LIKE RLGRAP-FILENAME,
           W_EXT(3) TYPE C,
           W_UEXT(3) TYPE C,
           W_PATH LIKE RLGRAP-FILENAME,
           W_UPATH LIKE RLGRAP-FILENAME,
           W_FIRST(1) TYPE C VALUE 'Y',
           W_CFIRST(1) TYPE C VALUE 'Y',
           W_PCFIL LIKE RLGRAP-FILENAME.
    DATA: "REC LIKE GLT0 OCCURS 0 WITH HEADER LINE,
          T_TEMP LIKE GLT0 OCCURS 0 WITH HEADER LINE.
    DATA: BEGIN OF REC3 OCCURS 0.
          INCLUDE STRUCTURE GLT0.
    DATA: KTOPL LIKE SKA1-KTOPL,
          END OF REC3.
    DATA: BEGIN OF T_KTOPL OCCURS 0,
          KTOPL LIKE SKA1-KTOPL,
          SAKNR LIKE SKA1-SAKNR,
          END OF T_KTOPL.
    Download data.
    DATA: BEGIN OF I_REC2 OCCURS 0,
           BAL(17),        "             like GLT0-TSLVT value 0,
           COAREA(4),      "          like glt0-rbusa,
           CA(4),          "  chart of accounts
           CCODE(4),       "           like glt0-bukrs,
           CREDIT(17),     "          like  vbap-netwr,
           CURRENCY(5),    "       like glt0-rtcur,
           CURTYPE(2),     "      type n,
           DEBIT(17),      "           like vbap-netwr,
           YEAR(8),        "  type c,
           FY(2),          " type c, fiscal yr variant
           ACCOUNT(10),    " like glt0-racct,
           VER(3),         "    like glt0-rvers,
           VTYPE(3),       " type n,
           CLNT(3),        "like sy-mandt,
           S_SYS(3),       "like sy-sysid,
           INDICATOR(1),   "   like glt0-drcrk,
          END OF I_REC2.
    Selection screen.                                                    *
    SELECTION-SCREEN BEGIN OF BLOCK BL1  WITH FRAME TITLE TEXT-BL1.
    SELECT-OPTIONS : COMPCODE FOR GLT0-BUKRS,
                      GLACC FOR GLT0-RACCT,
                      FISYEAR   FOR GLT0-RYEAR,
                    no intervals no-extension,      "- BG6661-070212
                       FISCPER FOR GLT0-RPMAX,
                     busarea   for glt0-rbusa,
                      CURRENCY  FOR GLT0-RTCUR.
    SELECTION-SCREEN END   OF BLOCK BL1.
    SELECTION-SCREEN BEGIN OF BLOCK BL2  WITH FRAME TITLE TEXT-BL2.
    PARAMETERS:
      P_UNIX AS CHECKBOX,                  "Check box for Unix Option
      P_UNFIL LIKE RLGRAP-FILENAME,        " Unix file Dnload file name
       default '/var/opt/arch/extract/GLT0.ASC',  "- BG6661-070212
      P_PCFILE AS CHECKBOX,                "Check box for Local PC download.
      P_PCFIL LIKE RLGRAP-FILENAME         " PC file Dnload file name
                 default 'C:\GLT0.ASC'.           "- BG6661-070212
          DEFAULT 'C:\glt0_gl_balance_all.asc'.     "+ BG6661-070212
    SELECTION-SCREEN END   OF BLOCK BL2.
    *eject
    Initialization.                                                     *
    INITIALIZATION.
    Try to default download filename
    p_pcfil = c_pcfile.
    p_unfil = c_unixfile.
    if sy-sysid eq c_n01.
       p_unfil =   c_unixfile.
    endif.
    if sy-sysid eq c_g21.
       p_unfil =   c_g21_unixfile.
    endif.
    if sy-sysid eq c_g9d.
       p_unfil =   c_g9d_unixfile.
    endif.
    Default for download filename
    *{ Begin of BG6661-070212
      CONCATENATE C_UNIXFILE
                  SY-SYSID C_FSLASH C_CHRON C_FILENAME INTO P_UNFIL.
    *} End of BG6661-070212
    AT SELECTION-SCREEN OUTPUT.
    loop at screen.
       if screen-name = 'P_PCFIL'.        "PC FILE
         screen-input = '0'.
         modify screen.
       endif.
       if screen-name = 'P_UNFIL'.        "UN FILE
         screen-input = '0'.
         modify screen.
       endif.
    endloop.
      if w_first = 'Y'.
        perform path_file.
        w_first = 'N'.
      endif.
    if w_cfirst = 'Y'.
       perform cpath_file.
       w_cfirst = 'N'.
    endif.
    Start-of-Selection.                                                 *
    START-OF-SELECTION.
    *COLLECT DATA
      PERFORM COLLECT_DATA.
    *BUILD FILENAMES
      PERFORM BUILD_FILES.
    *LOCAL
      IF P_PCFILE = C_YES.
       PERFORM LOCAL_DOWNLOAD.
      ENDIF.
    *UNIX
      IF P_UNIX = C_YES.
        PERFORM UNIX_DOWNLOAD.
      ENDIF.
      IF P_PCFILE IS INITIAL AND P_UNIX IS INITIAL.
        MESSAGE I000(ZL) WITH 'Down load flags both are unchecked'.
      ENDIF.
    END-OF-SELECTION.
    IF P_PCFILE = C_YES.
    WRITE :/ 'PC File'  , C_UNDER, P_PCFIL.
    ENDIF.
    *&      Form  DOWNLOAD
          Download                                                       *
    FORM DOWNLOAD.
      P_PCFIL =  W_PATH.
      DATA LIN TYPE I.
      DESCRIBE TABLE I_REC2 LINES LIN.
      WRITE:/ 'No of Records downloaded = ',LIN.
      CALL FUNCTION 'WS_DOWNLOAD'
           EXPORTING
               FILENAME            =  P_PCFIL
               FILETYPE            =  C_ASC   "c_dat   "dat
           TABLES
                DATA_TAB            = I_REC2  " t_str
               fieldnames          = t_strhd
           EXCEPTIONS
                FILE_OPEN_ERROR     = 1
                FILE_WRITE_ERROR    = 2
                INVALID_FILESIZE    = 3
                INVALID_TABLE_WIDTH = 4
                INVALID_TYPE        = 5
                NO_BATCH            = 6
                UNKNOWN_ERROR       = 7
                OTHERS              = 8.
      IF SY-SUBRC EQ 0.
      ENDIF.
    ENDFORM.
    *&      Form  WRITE_TO_SERVER
          text                                                           *
    -->  p1        text
    <--  p2        text
    FORM WRITE_TO_SERVER.
      DATA : L_MSG(100) TYPE C,
             L_LINE(5000) TYPE C.
      P_UNFIL =  W_UPATH.
      DATA LIN TYPE I.                           
      DESCRIBE TABLE I_REC2 LINES LIN.           
      WRITE:/ 'No of Records downloaded = ',LIN. 
      OPEN DATASET P_UNFIL FOR OUTPUT IN TEXT MODE.        " message l_msg.
      IF SY-SUBRC <> 0.
        WRITE: / L_MSG.
      ENDIF.
    perform header_text1.
      LOOP AT I_REC2.
        TRANSFER I_REC2 TO P_UNFIL.
      ENDLOOP.
      CLOSE DATASET P_UNFIL.
      WRITE : / C_TEXT , W_UPATH.
      SPLIT W_UNIXFILE AT C_DOT INTO W_UNIXFIL1 W_UEXT.
      CLEAR W_UPATH.
      IF NOT W_UEXT IS INITIAL.
        CONCATENATE W_UNIXFIL1  C_DOT W_UEXT INTO W_UPATH.
      ELSE.
        W_UEXT = C_ASC. " c_csv.
        CONCATENATE W_UNIXFIL1 C_DOT W_UEXT INTO W_UPATH.
      ENDIF.
    ENDFORM.                               " WRITE_TO_SERVER
    *&      Form  BUILD_FILES
    FORM BUILD_FILES.
      IF P_PCFILE = C_YES.
        W_PCFILE = P_PCFIL.
    ***Split path at dot**
        SPLIT W_PCFILE AT C_DOT INTO W_PCFILE1 W_EXT.
        IF NOT W_EXT IS INITIAL.
          CONCATENATE W_PCFILE1 C_DOT W_EXT INTO W_PATH.
        ELSE.
          W_PATH = W_PCFILE1.
        ENDIF.
      ENDIF.
      IF P_UNIX = C_YES.
        W_UNIXFILE = P_UNFIL.
        SPLIT W_UNIXFILE AT C_DOT INTO W_UNIXFIL1 W_UEXT.
        IF NOT W_UEXT IS INITIAL.
          CONCATENATE W_UNIXFIL1  C_DOT W_UEXT INTO W_UPATH.
        ELSE.
          W_UPATH = W_UNIXFIL1.
        ENDIF.
      ENDIF.
    ENDFORM.
    FORM CPATH_FILE.
    CLEAR P_PCFIL.
       CONCATENATE C_PCFILE
                   C_COMFILE SY-SYSID C_UNDER SY-DATUM SY-UZEIT
                   C_DOT C_ASC INTO  P_PCFIL.
    ENDFORM.                    " CPATH_FILE
    FORM PATH_FILE.
    CLEAR P_UNFIL.
      if sy-sysid eq c_n01.
       CONCATENATE C_UNIXFILE
                   C_COMFILE SY-SYSID C_UNDER SY-DATUM SY-UZEIT
                    C_DOT C_ASC INTO  P_UNFIL.
      endif.
      if sy-sysid eq c_g21.
      concatenate c_g21_unixfile
                  c_comfile sy-sysid c_under sy-datum sy-uzeit
                   c_dot c_asc into  p_unfil.
      endif.
      if sy-sysid eq c_g9d.
      concatenate c_g9d_unixfile
                  c_comfile sy-sysid c_under sy-datum sy-uzeit
                   c_dot c_asc into  p_unfil.
      endif.
    ENDFORM.                    " PATH_FILE
    Local_Download                                                       *
          Local                                                          *
    FORM LOCAL_DOWNLOAD.
    perform header_text.
    LOOP AT REC1.
    REC1-CLNT = SY-MANDT.
    REC1-S_SYS = SY-SYSID.
    MOVE:  REC1-BAL TO I_REC2-BAL,
            REC1-COAREA TO I_REC2-COAREA,
           REC1-CA TO I_REC2-CA,         
            REC1-KTOPL TO I_REC2-CA,       
            REC1-CCODE TO I_REC2-CCODE,
            REC1-CREDIT TO I_REC2-CREDIT,
            REC1-CURRENCY TO I_REC2-CURRENCY,
            REC1-CURTYPE TO I_REC2-CURTYPE,
            REC1-DEBIT TO I_REC2-DEBIT,
            REC1-YEAR TO I_REC2-YEAR,
            REC1-FY TO I_REC2-FY,
            REC1-ACCOUNT TO I_REC2-ACCOUNT,
            REC1-VER TO I_REC2-VER,
            REC1-VTYPE TO I_REC2-VTYPE,
            REC1-CLNT TO I_REC2-CLNT,
            REC1-S_SYS TO I_REC2-S_SYS,
            REC1-INDICATOR TO I_REC2-INDICATOR.
    APPEND I_REC2.
    CLEAR  I_REC2.
    ENDLOOP.
      IF NOT I_REC2[] IS INITIAL.
        PERFORM DOWNLOAD .
        CLEAR I_REC2.
        REFRESH I_REC2.
       ELSE.
       WRITE : / ' no record exist due to unavailability of data'.
      ENDIF.
    ENDFORM.                               " LOCAL_DOWNLOAD
    *&      Form  UNIX_DOWNLOAD
    FORM UNIX_DOWNLOAD.
    LOOP AT REC1.
    REC1-CLNT = SY-MANDT.
    REC1-S_SYS = SY-SYSID.
    MOVE:  REC1-BAL TO I_REC2-BAL,
            REC1-COAREA TO I_REC2-COAREA,
          REC1-CA TO I_REC2-CA,         
            REC1-KTOPL TO I_REC2-CA,       
            REC1-CCODE TO I_REC2-CCODE,
            REC1-CREDIT TO I_REC2-CREDIT,
            REC1-CURRENCY TO I_REC2-CURRENCY,
            REC1-CURTYPE TO I_REC2-CURTYPE,
            REC1-DEBIT TO I_REC2-DEBIT,
            REC1-YEAR TO I_REC2-YEAR,
            REC1-FY TO I_REC2-FY,
            REC1-ACCOUNT TO I_REC2-ACCOUNT,
            REC1-VER TO I_REC2-VER,
            REC1-VTYPE TO I_REC2-VTYPE,
            SY-MANDT TO I_REC2-CLNT,
            SY-SYSID TO I_REC2-S_SYS,
            REC1-INDICATOR TO I_REC2-INDICATOR.
    APPEND I_REC2.
    CLEAR  I_REC2.
    ENDLOOP.
      IF NOT I_REC2[] IS INITIAL.
        PERFORM WRITE_TO_SERVER.
        CLEAR I_REC2.
        REFRESH I_REC2.
      ELSE.
       WRITE : / ' no record exist due to unavailability of data'.
      ENDIF.
    ENDFORM.                               " UNIX_DOWNLOAD
    *&      Form  HEADER_TEXT
          text                                                           *
    -->  p1        text
    <--  p2        text
    *form header_text.
      concatenate c_bal c_ba c_ca c_cc  c_credit c_currency c_curtype
         c_debit c_fisyear c_fisvar c_acct c_ver c_vtype c_indicator
               into t_strhd
               separated by c_comma.
      append t_strhd.
    *endform.                               " HEADER_TEXT
    *&      Form  HEADER_TEXT1
          text                                                           *
    *form header_text1.
      concatenate c_bal c_ba c_ca c_cc  c_credit c_currency c_curtype
        c_debit c_fisyear c_fisvar c_acct c_ver c_vtype c_indicator
               into t_strhd1
               separated by c_comma.
      append t_strhd1.
      transfer t_strhd1 to p_unfil.
    *endform.                    " HEADER_TEXT1
    *&      Form  COLLECT_DATA
          Collect Data                                                   *
    FORM COLLECT_DATA.
    SELECT * FROM GLT0 INTO  TABLE REC3
                        WHERE   BUKRS IN COMPCODE
                        AND     RYEAR IN FISYEAR
                        AND     RPMAX IN FISCPER
                        AND     RACCT IN GLACC
                        AND     RTCUR IN  CURRENCY.
    SELECT KTOPL FROM SKA1
                 INTO TABLE T_KTOPL
                 FOR ALL ENTRIES IN REC3
                 WHERE SAKNR = REC3-RACCT.
    LOOP AT REC3 .
       select *
       from glt0
       into table t_temp
       where rldnr = rec-rldnr
         and rrcty  = rec-rrcty
          and rvers  = rec-rvers
         and bukrs = rec-bukrs
         and ryear = rec-ryear
          and racct  = rec-racct
           and rbusa  = rec-rbusa
           and rtcur <> 'ZAR'
         and rpmax  = rec-rpmax.
    if sy-subrc = 0.
            rec1-bal = '0.00'.
    else.
      rec1-bal = rec-hslvt.
      endif.
    *READ TABLE T_KTOPL WITH KEY SAKNR = REC-RACCT BINARY SEARCH.
    MOVE T_KTOPL-KTOPL TO REC3-KTOPL.
    CLEAR:  CBALANCE, DBALANCE.
    REC1-BAL = REC3-HSLVT.
    IF REC3-DRCRK = 'S'.
    IF REC3-HSLVT NE C_ZERO.
           YEAR   = REC-RYEAR.
           PERIOD = '000'.
           CONCATENATE PERIOD C_DOT YEAR INTO FP.
           REC1-INDICATOR = REC-DRCRK.
           REC1-DEBIT = C_ZERO.
           REC1-CREDIT = C_ZERO.
           REC1-CCODE = REC-BUKRS.
           REC1-YEAR  = FP.
           REC1-CURRENCY = REC-RTCUR.
           REC1-ACCOUNT  = REC-RACCT.
           rec1-bal      = rec-hslvt.
           dbalance = rec1-bal.
           REC1-CURTYPE = C_CTYPE.
           REC1-FY      = C_FY.
           REC1-COAREA   = REC-RBUSA.
           REC1-VER     = REC-RVERS.
           REC1-VTYPE   = C_CTYPE.
           REC1-CA      = C_CHART.
           APPEND REC1.
            C = 0.
          PERFORM D.
    ENDIF.
    IF REC3-HSL01 NE C_ZERO.
            YEAR   = REC3-RYEAR.
            PERIOD = '001'.
            CONCATENATE PERIOD C_DOT YEAR INTO FP.
            REC1-INDICATOR = REC3-DRCRK.
            REC1-DEBIT = REC3-HSL01 .
            REC1-CCODE = REC3-BUKRS.
            REC1-YEAR  = FP.
            REC1-CURRENCY = REC3-RTCUR.
            REC1-ACCOUNT  = REC3-RACCT.
           rec1-bal      = REC3-hsl01 + dbalance.
           dbalance = rec1-bal.
            REC1-CURTYPE = C_CTYPE.
            REC1-FY      = C_FY.
            REC1-COAREA   = REC3-RBUSA.
            REC1-VER     = REC3-RVERS.
            REC1-VTYPE   = C_CTYPE.
          REC1-CA      = C_CHART. 
            REC1-KTOPL = REC3-KTOPL. 
            APPEND REC1.
            C = 1.
         PERFORM D.
    ENDIF.
    IF  REC3-HSL02 NE C_ZERO.
          REC1-DEBIT = REC3-HSL02.
       YEAR   = REC3-RYEAR.
       PERIOD = '002'.
      CONCATENATE PERIOD C_DOT YEAR INTO FP.
         REC1-INDICATOR = REC3-DRCRK.
       REC1-DEBIT = REC3-HSL02.
       REC1-CCODE = REC3-BUKRS.
       REC1-YEAR  = FP.
       REC1-CURRENCY = REC3-RTCUR.
       REC1-ACCOUNT  = REC3-RACCT.
      rec1-bal      = REC3-hsl02 + dbalance.
      dbalance = rec1-bal.
            REC1-CURTYPE = C_CTYPE.
            REC1-FY      = C_FY.
            REC1-COAREA   = REC3-RBUSA.
            REC1-VER     = REC3-RVERS.
            REC1-VTYPE   = C_CTYPE.
          REC1-CA      = C_CHART. "-BF7957-070503
            REC1-KTOPL = REC3-KTOPL.  "+BF7957-070503
       APPEND REC1.
       C = 2.
    PERFORM D.
    ENDIF.
    IF  REC3-HSL03 NE C_ZERO.
            YEAR   = REC3-RYEAR.
            PERIOD = '003'.
            CONCATENATE PERIOD C_DOT YEAR INTO FP.
               REC1-INDICATOR = REC3-DRCRK.
            REC1-DEBIT = REC3-HSL03.
            REC1-CCODE = REC3-BUKRS.
            REC1-YEAR  = FP.
            REC1-CURRENCY = REC3-RTCUR.
            REC1-ACCOUNT  = REC3-RACCT.
           rec1-bal      = REC3-hsl03 + dbalance .
           dbalance =  rec1-bal.
            REC1-CURTYPE = C_CTYPE.
            REC1-FY      = C_FY.
            REC1-COAREA   = REC3-RBUSA.
            REC1-VER     = REC3-RVERS.
            REC1-VTYPE   = C_CTYPE.
           REC1-CA      = C_CHART. "-BF7957-070503
             REC1-KTOPL = REC3-KTOPL. "+BF7957-070503
            APPEND REC1.
          C = 3.
    PERFORM D.
    ENDIF.
    IF  REC3-HSL04 NE C_ZERO.
           REC1-DEBIT = REC3-HSL04.
              YEAR   = REC3-RYEAR.
              PERIOD = '004'.
             CONCATENATE PERIOD C_DOT YEAR INTO FP.
                REC1-INDICATOR = REC3-DRCRK.
             REC1-DEBIT = REC3-HSL04.
              REC1-CCODE = REC3-BUKRS.
              REC1-YEAR  = FP.
              REC1-CURRENCY = REC3-RTCUR.
              REC1-ACCOUNT  = REC3-RACCT.
             rec1-bal      = REC3-hsl04 + dbalance .
            REC1-CURTYPE = C_CTYPE.
            REC1-FY      = C_FY.
            REC1-COAREA   = REC3-RBUSA.
            REC1-VER     = REC3-RVERS.
            REC1-VTYPE   = C_CTYPE.
          REC1-CA      = C_CHART.  "-BF7957-070503
            REC1-KTOPL = REC3-KTOPL.  "+BF7957-070503
            APPEND REC1.
             dbalance = rec1-bal.
              C = 4.
              PERFORM D.
    ENDIF.
    Thanks and Regards,
    Ram

    use logical database SDF, nodes ska1 and  skc1c
    A.

Maybe you are looking for

  • How can I call AM from another page

    Hi, I have come across a situation which I am not sure how to solve it. Here is the issue. I have a custom requirement to add another page to an already existing custom page. The first page used to hold the data and commit buttons however because of

  • One Display at a Time?

    Apologies if this is a repeat - I couldn't find anything in the archives. I have a MacBookPro running Leopard and a 17" Apple Display. All is working beautifully but I have an OCD problem. Can I somehow turn off the display on my laptop while working

  • DVD Player in Lion

    In DVD Player in Snow Leopard, I used to be able to create video clips (that is, short sections of DVDs to play for my students in school).  DVD Player in Lion does not seem to offer that feature.  Bookmarks are not good enough for my purposes, becau

  • Hello T5i cr2 will not read in cs5 or lightroom 3 ?

    Recently I purchased a Canon T5i and now I find my mac book pro , lightroom 3 and cs5 will not read the cr2 files from the T5i . They read cr2's from my T1i . How dow I fix this or is my camera not supported by any of these things ? Thanks , PS my ma

  • Selecting InDesign version in VB script

    I am having some difficulty with selecting the proper version of InDesign in my VB scripts. Usually I use the connection string: CreateObject("InDesign.Application"), which will launch in whatever version is installed. Now, one of my customers has in