Query with information from SD tables

Dears,
I have two questions concerning the creation of a Query which reports information of sales orders and information related to these (tables VBAK, VBAP, KNA1, VBKD).
1. I want to include for example the ship-to-party, but I only find the field in structures, so it would not be able to include... or is there another way to acces this field?
2. I want to include the field KONWA (rate unit). It should appear showing the rate unit depending on the condition type PR00 on item level... Is this possible?
If anybody could help me out on this topics, I would appreciate it a lot!
Thanks in advance,
Dominik Ley
Chile

Hi,
The answer for the first question is If you want to include ship to party at
a)Header level:Simply pass the order number in to VBPA  table and fetch for PARVW="WE" having POSNR=000000.By default header details will appear in this table.Take "ADRNR" field contents and pass to ADRC table to fetch the address.
b)Item level:If you want ship to party address at the item level Simply pass the order number in to VBPA  table and fetch for PARVW="WE" having POSNR=000010 or 000020 like that what ever is your line item number.If it recognises any change in change at the line item then only the entry will appear in the table.otherwise you cannot find any entry in the table.Take "ADRNR" field contents for the corresponding line item and pass to ADRC table to fetch the address.
Regards,
Mohan.

Similar Messages

  • Creating a Query with Data from 4 Tables.

    Hey guys. I'm having a small problem figuring out the best way for me to handle this query.
    I'm trying to make a query which outputs the amount of appointments a GP has furfilled, and the total amount allowed.
    I have 4 tables, for each I'm just gonna list the relevent columns:
    Appointment: ID, Patient_ID.
    Patient: ID, GP_ID.
    GP: ID, Trust_ID.
    Trust: ID, Quota.
    Appointment table has 400 entries (2 per patient atm).
    Patient table has 200 entries.
    GP Table has 30 entries (GP's can be assigned to more than one person) .
    Trust table has 6 entries.
    What I need to do is, look at the appointment table and get the number of times each patient has an appointment.
    Go through the patient table, and find out which GP the patient in the appointment belongs to.
    Add each occurance to the correct GP.
    Find out which Trust each GP belongs to, and add the total for each GP to the correct Trust.
    Check the quota in the Trust table, to see if the total is more than the allowed.
    I can't seem to think of an easy or simple way for me to do this. Can anyone help please? Many thanks.

    Hi,
    That sounds like a job for JOIN.
    To check the quotas against the total, use the SUM function; either the aggregate SUM or the analytic SUM, depending on your requirements.
    Sorry this answer is so vague, but that's the bes I can do with the information provided so far.
    Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) from all tables involved. In this case, between 2 and 10 rows of data per table should be enough to show what you need to do.
    Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
    Always say which version of Oracle you're using.

  • Change search results tile with information from just client table...

    Hello all,
    I am quite new in MSA development area. Could you please answer one specific question?
    I would like to enchance search results tile. I want to add two additional columns, but with information from ONLYclient table. For exapmle table Zclient. I would like to store this table only in IDES DB on laptop and not transfer it to CRM server.
    This table Zclient will have relation to other information which is now in search result tile.
    Is it possible to create BDoc with combination of data...from server and only from client DB?
    And could you please provide me some cookbook for enchacing Mobile application?
    Thanks a lot!!
    Best regards,
    Vera

    Hi Vera,
    What you want to accomplish is possible. Santosh is correct, you have to create your Zclient (CDB table) and query Z_BDOC on CRM server. Then, generate this Zlcient table and new Z_BDOC with a Client Console on the laptop, and that will create CDB table in your ides db and update tps file with new Z_BDOC.
    Then, in MAS, create a Business Query, with relation to new Z_BDOC. Generate that BQuery. Model your tile, so that it's using your new Business Query. You may need to do some coding as well.
    P.S. Cince data from this table won't be replicated to CRM, you still need to initially populate that table on every client ( sql query ? ).
    Let me know if you have any questions or need help.
    Regards,
    Vadim.

  • Work with data from a table of another SAP R/3 system

    Hi,
    I want to work with data from a table of another system. I know there's a function called 'RFC_READ_TABLE' but I don't know really how it works. What I want to do is to get data from that system and pass it to the one where I'm working in order I can continue working with this data in the report.
    Besides, I'd like to select only the records that have some conditions.
    I'd appreciate if someone could tell how to do it, whether with FM 'RFC_READ_TABLE' or in another way.
    Thanks in advance,
    Gerard
    P.S: The systems are already connected in SM59

    Yes, you can use RFC_read_table .You can pass the number of columns but I recommend you to  bring all results in your internal table after that you can filter the records. Most of the time I have notice when you make RFC call with this FM to another system it works but it may also happen that other system controlling authorization and then it might give you nothing. As I face this problem on my last Project.
    Hope this’ll give you idea!!
    <b>P.S award the points.</b>
    Good luck
    Thanks
    Saquib Khan
    "Some are wise and some are otherwise"

  • Create a procedure which requires displaying information from two tables

    What if we want to create a procedure which requires displaying information from two tables. In this situation,
    I need to display all the details of an employee from an 'emp' table based on the deptno. and also their salary information which is
    stored in "Salgrade" Table. Is the use of "And" the correct way of using it?
    Do I need to declare all the attributes before begin or I can just access them directly? Thanks
    Create Procedure findDept
    ( I_deptno IN number
    ) As
    Begin
    Select Ename, Job, MGR, Hiredate, Sal, Comm, Dept_no from emp and exp, grade , location from salgrade where dept_no
    = I_Deptno;
    Exception
    When NO_Data_Found then
    DBMS_Output.Put_Line(' Department not found"|| I_deptno);
    End findDept;

    Hi,
    Besides Qwerty's remark, you've also got a quoting error:
    Change
    DBMS_Output.Put_Line(' Department not found"|| I_deptno);
    {code}
    into
    {code}
    dbms_output.put_line(' Department not found: '|| i_deptno);
    {code}
    Which leads to the question:
    What do you want to do when a record is found?
    Display it?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Left join query with join of three tables

    I'm trying to build a query which has me stumped. Most of the query is fairly straightforward but I've run into an issue I'm not sure how to solve.
    Background:
    We have actions stored in i_action.
    We have the available attributes for each type of action. The available attributes for each action are described in shared_action_attribute. Each type of action may have up to three attributes or none at all.
    We have the values stored for the attributes in i_attribute_value.
    A written example:
    We have a transfer action (action_code B4). The entry of the B4 action into i_action records the fact that the transfer occurred and the date on which it occurred. The available attributes for a transfer action are the receiving function code, the receiving unit number, and the transfer reason code. These available attribute types and their order are stored in shared_action_attribute. The actual values of the attributes for a specific transfer action are stored in i_attribute_value.
    Now i_action and i_attribute_value can be directly linked through action_seq in i_action and ia_action_seq in i_attribute_value. A left join built between these two tables provides results for all actions (including actions which have no attributes) and attribute values (see query 1 below).
    There are two issues. First, I only want the first two attributes. In order to specify the first two attributes, I also have to link i_attribute_value to shared_action_attribute (which is where the order is stored). I can build a simple query (without the left join) linking the three tables but then actions with no attributes would be excluded from my result set (see query 2 below).
    The second issue is that I would actually like one row returned for each action with first_attribute and second_attribute as columns instead of two rows.
    The final query will be used to create a materialized view.
    Here are the tables and examples of what's stored in them:
    TABLE i_action
    Name Type
    ACTION_SEQ NUMBER(10)
    ACTION_DATE DATE
    ACTION_CODE VARCHAR2(3)
    DELETED VARCHAR2(1)
    EXAMPLE ROWS
    ACTION_SEQ ACTION_DATE ACTION_CODE DELETED
    45765668 09-OCT-09 B2 A
    45765670 09-OCT-09 BA A
    45765672 09-OCT-09 B6 A
    45765673 09-OCT-09 B4 A
    45765674 09-OCT-09 G1 A
    45765675 09-OCT-09 M3 A
    TABLE i_attribute_value
    Name Type
    IA_ACTION_SEQ NUMBER(10)
    SACTATT_SACT_CODE VARCHAR2(3)
    SACTATT_SAT_TYPE VARCHAR2(3)
    VALUE VARCHAR2(50)
    EXAMPLE ROWS
    IA_ACTION_SEQ SACTATT_SACT_CODE SACTATT_SAT_TYPE VALUE
    45765668 B2 ACO 37B
    45765670 BA ROA D
    45765670 BA ROR P
    45765672 B6 CAT C
    45765673 B4 RFC E
    45765673 B4 TRC P
    45765673 B4 RUN 7
    45765674 G1 SS 23567
    45765674 G1 ASG W
    TABLE shared_action_attribute
    Name Type
    SACT_CODE VARCHAR2(3)
    SAT_TYPE VARCHAR2(3)
    ORDER NUMBER(2)
    TITLE VARCHAR2(60)
    EXAMPLE ROWS
    SACT_CODE SAT_TYPE ORDER TITLE
    B2 ACO 1 Office code
    BA ROR 1 Reason for reopen
    BA ROA 2 Reopen authority
    B6 CAT 1 Category
    B4 RFC 1 Receiving function code
    B4 RUN 2 Receiving unit code
    B4 TRC 3 Transfer reason code
    G1 SS 1 Staff sequence
    G1 ASG 2 Assignment reason
    QUERY 1:
    This is my current query along with its results. Most of it is straightforward select but one column is populated using the last_value analytical function (thanks to you guys). The last column in the below view stores the attribute value. What I want is to replace that single column with two columns named first_attribute and second_attribute and to eliminate any other attributes.
    SELECT ia.action_seq, ia.action_date, ia.action_code cod,
    NVL
    (LAST_VALUE (CASE
    WHEN ia.action_code = 'G1'
    AND iav.sactatt_sat_type = 'SS'
    THEN VALUE
    WHEN ia.action_code IN ('A0', 'A1')
    THEN '67089'
    END IGNORE NULLS
    ) OVER (PARTITION BY ia.ici_charge_inquiry_seq ORDER BY ia.action_date,
    ia.serial_number, ia.action_seq),
    '67089'
    ) staff_seq,
    value
    FROM i_action ia LEFT JOIN i_attribute_value iav
    ON iav.ia_action_seq = ia.action_seq
    WHERE ia.deleted = 'A';
    ACTION_SEQ ACTION_DA COD STAFF_SEQ VALUE
    45765668 09-OCT-09 B2 67089 37B
    45765670 09-OCT-09 BA 67089 D
    45765670 09-OCT-09 BA 67089 P
    45765672 09-OCT-09 B6 67089 C
    45765673 09-OCT-09 B4 67089 E
    45765673 09-OCT-09 B4 67089 P
    45765673 09-OCT-09 B4 67089 7
    45765674 09-OCT-09 G1 23567 23567
    45765674 09-OCT-09 G1 23567 W
    45765675 09-OCT-09 M3 23567
    QUERY 2:
    This query limits to the first two attributes but it also drops actions which have no attributes and it still creates multiple rows for each action instead of a single row with two columns for the attributes.
    SELECT ia.action_seq, ia.action_date, ia.action_code cod,
    NVL
    (LAST_VALUE (CASE
    WHEN ia.action_code = 'G1'
    AND iav.sactatt_sat_type = 'SS'
    THEN VALUE
    WHEN ia.action_code IN ('A0', 'A1')
    THEN '67089'
    END IGNORE NULLS
    ) OVER (PARTITION BY ia.ici_charge_inquiry_seq ORDER BY ia.action_date,
    ia.serial_number, ia.action_seq),
    '67089'
    ) staff_seq,
    value
    FROM shared_action_attribute saa, ims_action ia, ims_attribute_value iav
    WHERE iav.ia_action_seq = ia.action_seq
    AND iav.sactatt_sact_code = saa.sact_code
    AND iav.sactatt_sat_type = saa.sat_type
    AND saa.display_order IN ('1','2')
    AND ia.deleted = 'A';
    ACTION_SEQ ACTION_DA COD VALUE
    45765668 09-OCT-09 B2 67089 37B
    45765670 09-OCT-09 BA 67089 D
    45765670 09-OCT-09 BA 67089 P
    45765672 09-OCT-09 B6 67089 C
    45765673 09-OCT-09 B4 67089 E
    45765673 09-OCT-09 B4 67089 7
    45765674 09-OCT-09 G1 23567 23567
    45765674 09-OCT-09 G1 23567 W
    I found this pretty complex to try to write out - I hope I've been clear.
    Thanks so much!

    Ok, here's more information with a simplified question. I figured out the syntax for building my query with the three tables. My final query returns multiple rows (multiple attributes per action). Instead of multiple rows, I'd like two columns (first_attribute, and second_attribute) in a single row (I only need the first two attributes).
    Here's the action table:
    CREATE TABLE I_ACTION
      ACTION_SEQ               NUMBER(10)           NOT NULL,
      ACTION_DATE              DATE,
      ACTION_CODE              VARCHAR2(3 BYTE)     NOT NULL,
      DELETED                  VARCHAR2(1 BYTE),
    );With the following rows added:
    Insert into I_ACTION (ACTION_SEQ, ACTION_DATE, ACTION_CODE, DELETED)
                  Values (45765668, '09-oct-2009', 'B2', 'A');
    Insert into I_ACTION (ACTION_SEQ, ACTION_DATE, ACTION_CODE, DELETED)
                  Values (45765670, '09-oct-2009', 'BA', 'A');
    Insert into I_ACTION (ACTION_SEQ, ACTION_DATE, ACTION_CODE, DELETED)
                  Values (45765672, '09-oct-2009', 'B6', 'A');
    Insert into I_ACTION (ACTION_SEQ, ACTION_DATE, ACTION_CODE, DELETED)
                  Values (45765673, '09-oct-2009', 'B4', 'A');
    Insert into I_ACTION (ACTION_SEQ, ACTION_DATE, ACTION_CODE, DELETED)
                  Values (45765674, '09-oct-2009', 'G1', 'A');
    Insert into I_ACTION (ACTION_SEQ, ACTION_DATE, ACTION_CODE, DELETED)
                  Values (45765675, '09-oct-2009', 'M3', 'A');
    COMMIT;The attribute table is:
    CREATE TABLE I_ATTRIBUTE_VALUE
      IA_ACTION_SEQ          NUMBER(10)             NOT NULL,
      SACTATT_SACT_CODE      VARCHAR2(3 BYTE)       NOT NULL,
      SACTATT_SAT_TYPE       VARCHAR2(3 BYTE)       NOT NULL,
      VALUE                  VARCHAR2(50 BYTE),
    );With the following rows:
    Insert into I_ATTRIBUTE_VALUE (IA_ACTION_SEQ, SACTATT_SACT_CODE, SACTATT_SAT_TYPE, VALUE)
                           Values (45765668, 'B2', 'ACO', '37B');
    Insert into I_ATTRIBUTE_VALUE (IA_ACTION_SEQ, SACTATT_SACT_CODE, SACTATT_SAT_TYPE, VALUE)
                           Values (45765670, 'BA', 'ROR', 'P');
    Insert into I_ATTRIBUTE_VALUE (IA_ACTION_SEQ, SACTATT_SACT_CODE, SACTATT_SAT_TYPE, VALUE)
                           Values (45765670, 'BA', 'ROA', 'D');
    Insert into I_ATTRIBUTE_VALUE (IA_ACTION_SEQ, SACTATT_SACT_CODE, SACTATT_SAT_TYPE, VALUE)
                           Values (45765672, 'B6', 'CAT', 'C');
    Insert into I_ATTRIBUTE_VALUE (IA_ACTION_SEQ, SACTATT_SACT_CODE, SACTATT_SAT_TYPE, VALUE)
                           Values (45765673, 'B4', 'RFC', 'E');
    Insert into I_ATTRIBUTE_VALUE (IA_ACTION_SEQ, SACTATT_SACT_CODE, SACTATT_SAT_TYPE, VALUE)
                           Values (45765673, 'B4', 'RUN', '7');
    Insert into I_ATTRIBUTE_VALUE (IA_ACTION_SEQ, SACTATT_SACT_CODE, SACTATT_SAT_TYPE, VALUE)
                           Values (45765673, 'B4', 'TRC', 'P');
    Insert into I_ATTRIBUTE_VALUE (IA_ACTION_SEQ, SACTATT_SACT_CODE, SACTATT_SAT_TYPE, VALUE)
                           Values (45765674, 'G1', 'SS', '23567');
    Insert into I_ATTRIBUTE_VALUE (IA_ACTION_SEQ, SACTATT_SACT_CODE, SACTATT_SAT_TYPE, VALUE)
                           Values (45765674, 'G1', 'ASG', 'W');
    COMMIT;And finally, the shared table:
    CREATE TABLE SHARED_ACTION_ATTRIBUTE
      SACT_CODE      VARCHAR2(3 BYTE)               NOT NULL,
      SAT_TYPE       VARCHAR2(3 BYTE)               NOT NULL,
      TITLE          VARCHAR2(25 BYTE)              NOT NULL,
      DISPLAY_ORDER  NUMBER(2)                      NOT NULL
    );With the following rows:
    Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
                                 Values ('B4', 'RFC', 'Y', 'Rcv. Function Code', 1);
    Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
                                 Values ('B6', 'CAT', 'Y', 'Category', 1);
    Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
                                 Values ('G1', 'SS', 'Y', 'Staff Name', 1);
    Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
                                 Values ('B2', 'ACO', 'Y', '"Other" Office Code', 1);
    Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
                                 Values ('B4', 'RUN', 'Y', 'Receiving Unit Number', 2);
    Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
                                 Values ('B6', 'LEP', 'N', 'LEP Issue/Sub Category', 2);
    Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
                                 Values ('B4', 'TRC', 'Y', 'Transfer Reason Code', 3);
    Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
                                 Values ('B6', 'NEP', 'N', 'NEP Issue', 3);
    Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
                                 Values ('G1', 'ASG', 'Y', 'Assignment Reason', 2);
    Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
                                 Values ('B2', 'MSN', 'S', 'Machine Serial Number', 3);
    Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
                                 Values ('BA', 'ROR', 'Y', 'Reopen Reason', 1);
    Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
                                 Values ('BA', 'ROA', 'Y', 'Reopen Authority', 2);
    COMMIT;Now, this is my current query (it's changed from my first post):
    SELECT ia.action_seq, ia.ici_charge_inquiry_seq, ia.action_date,
           ia.serial_number, ia.reporting_office, ia.reporting_function,
           ia.reporting_unit, ia.action_code, ia.machine_serial_number,
           NVL
              (LAST_VALUE (CASE
                              WHEN ia.action_code = 'G1'
                                 THEN VALUE
                              WHEN ia.action_code IN ('A0', 'A1')
                                 THEN '67089'
                           END IGNORE NULLS
                          ) OVER (PARTITION BY ia.ici_charge_inquiry_seq ORDER BY ia.action_date,
                ia.serial_number, ia.action_seq),
               '67089'
              ) staff_seq,
           (CASE
              WHEN display_order = '1'
              THEN VALUE
           END) first_attribute,
           (CASE
              WHEN display_order = '2'
              THEN VALUE
           END) second_attribute
      FROM ims_action ia
      LEFT JOIN ims_attribute_value iav
           ON iav.ia_action_seq = ia.action_seq
      LEFT JOIN shared_action_attribute
           ON sactatt_sact_code = sact_code
         AND sactatt_sat_type = sat_type
    WHERE ia.deleted = 'A';Which gives me the following results:
    ACTION_SEQ ACTION_DA ACT STAFF_SEQ FIRST_ATTRIBUTE SECOND_ATTRIBUTE   
      45765668 09-OCT-09 B2  67089     37B                                
      45765670 09-OCT-09 BA  67089                     D                  
      45765670 09-OCT-09 BA  67089     P                                  
      45765672 09-OCT-09 B6  67089     C                                  
      45765673 09-OCT-09 B4  67089     E                                  
      45765673 09-OCT-09 B4  67089                     7                  
      45765673 09-OCT-09 B4  67089                                        
      45765674 09-OCT-09 G1  23567                     W                  
      45765674 09-OCT-09 G1  23567     23567                              
      45765675 09-OCT-09 M3  23567                                       The result I WANT is similar but I want the two separate attribute columns on one row as such:
    ACTION_SEQ ACTION_DA ACT STAFF_SEQ FIRST_ATTRIBUTE SECOND_ATTRIBUTE   
      45765668 09-OCT-09 B2  67089     37B                                
      45765670 09-OCT-09 BA  67089     P               D                  
      45765672 09-OCT-09 B6  67089     C                                  
      45765673 09-OCT-09 B4  67089     E               7                  
      45765674 09-OCT-09 G1  23567     23567           W                  
      45765675 09-OCT-09 M3  23567                          Thanks so much!

  • Extracting information from a table based on different criteria

    Post Author: shineysideup
    CA Forum: Formula
    Hi Folks
    I have a bit of a strange one here.
    I need to extract information from a single table based on different critera.
    Sounds simple enough but here's the tricky part.
    This table is a table that contains the build of a product. All the parts that are used to make the product and also the sub-parts that are used to make the primary product parts.
    Example:
    I have a part that is in the product and the part no is 1111. This part is actually part of another part that is part no 1112
    What I need to do is display part no 1111 with all of its details but then also show that it is also part of part no 1112.
    The way the table holds this information is as follows.
    Seq_No      Parent_Seq_No     Part_No
    The seq_no is item no that is given to the part number. If the part is a member of another part then there is also a parent_seq_no.
    Everything needs to tie back to the seq_no and the parent_seq no as the part itself can be used in a parent or it can be used on its own. This way you can actually have the same part appearing in the list several times but the seq_no will be different for each one. If the part can be used in two different sub-builds (with each part being used twice in each sub-build) and also on its own once then you would have 5 different seq_nos two parent_seq_nos.
    What I need to do is to list all of the parts but then also when a part is part of a parent_seq_no I need to be able to display the parent seqno but also the part_no for that as the parent would also be listed as an individual item in the part list.
    At the moment listing the part_no, seq_no and parent_seq_no is easy but when I try to list the part_no for the parent I jsut keep getting the original sub part again. I can do this with a sub-report but with what I need to do with the data after listing the parts a sub-report is not an option for me.
    This make sense?
    Thanks

    Post Author: Charliy
    CA Forum: Formula
    As long as the chain only goes one link deep, you should be able to Alias the table and link it (left outer)  from the child part to the parent part.  Then build a Detail B (or Group Footer if that's where you're printing) and conditionally suppress is if there is no "Parent Part".

  • Problem creating a datablock with columns from 2 tables...

    Hello guys, i have a problem in creating a datablock with columns from 2 different tables. I try to create the datalock manually and in the Query Data Source Type Property i choose FROM clause query, and in the query data source name property i type my sql statement with the columns i want to display.After that i place the items that the datablock will contain , manually from the painter. However , when i run the application, the datablock doesn't display the items from the database. Am i doing something wrong?
    Thanx in advance,
    Regards,
    Bill.

    Never mind Peter, I found the error. I forgot to make execute_query for the datablock, so this was the reason why the items weren't displayed to me.
    Thanx anyway a lot for your advices and your time you spent !

  • Simple Query Failure? from 2 tables: pull First [DATE] Where [OIL] 0

    I am a novice Access 2010 user, and I do not know how to write VBA code.  I have written many queries, some built upon others and packaged them into macros, but that's about the extent of my experience, to date. 
    My problem.  I built a query from 2 tables: [AC_PROPERTY] and [AC_PRODUCT]
    I have linked the tables by PROPNUM.  Designed the query to give me every PROPNUM in the db, then give me the 'First' [DATE] 'Where' [OIL] is >0.
    When I run the query with 1 PROPNUM qualified, it works brilliant.  Every case I check is working, on a one-PROPNUM-at-a-time basis.  As soon as I remove the PROPNUM from criteria, so it will pull all PROPNUMs in the db, it appear to work -- that
    is, until you check the data.
    For some reason, it's not consistently picking the correct First date where Oil >0.  I cannot figure out why it's working on some and not on others.  I thought it was a date format problem, but haven't been able to determine or solve the issue.
    I have always (historically) figured out my query problems, but this one has me stumped!  Help!?
    thank you :-)

    I have linked the tables by PROPNUM.  Designed the query to give me every PROPNUM in the db, then give me the 'First' [DATE] 'Where' [OIL] is >0.
    The problem is that FIRST will not always give you the oldest date. Access uses FIRST to get the first record it finds, not the earliest date.
    Use MIN to find oldest date.
    Build a little, test a little

  • Select query for fetching from 3 tables.

    Can we have a single Select query for fetching same fields (kappl,kschl,vkorg,vtweg,spart,kunwe,datbi,knuma,datab,knumh)
    from 3 tables >> KOTE707,KOTE708 and KOTE709 into an internal table for a particular KUNNR?
    Regards,
    Shashank.

    Hi,
    If you have kunnr field in all the 3 tables then it is possible. use inner join as below
    PARAMETERS: p_cityfr TYPE spfli-cityfrom,
                p_cityto TYPE spfli-cityto.
    DATA: BEGIN OF wa,
             fldate TYPE sflight-fldate,
             carrname TYPE scarr-carrname,
             connid   TYPE spfli-connid,
           END OF wa.
    DATA itab LIKE SORTED TABLE OF wa
                   WITH UNIQUE KEY fldate carrname connid.
    SELECT c~carrname p~connid f~fldate
           INTO CORRESPONDING FIELDS OF TABLE itab
           FROM ( ( scarr AS c
             INNER JOIN spfli AS p ON p~carrid   = c~carrid
                                  AND p~cityfrom = p_cityfr
                                  AND p~cityto   = p_cityto )
             INNER JOIN sflight AS f ON f~carrid = p~carrid
                                    AND f~connid = p~connid ).
    LOOP AT itab INTO wa.
      WRITE: / wa-fldate, wa-carrname, wa-connid.
    ENDLOOP.
    <b>Reward Points if this helps,</b>
    Satish

  • Query with variant from ABAP

    Hello!
    I need to execute a BW-query from an Abap-report.
    I tried it already with function module 'RRW3_GET_QUERY_VIEW_DATA' and with classes / objects 'CL_RSR_REQUEST' resp. 'CL_RSR_DATA', but:
    I want to use the query with a variant, which could be found in table RSRPARAMETRIZA.
    (Btw: even with a variant in table RSRVARIANTDIR  I don't get the results wanted...)
    Is there a direct way to call a BW-query with a variant from Abap?
    Alternatively: How do I get the variant-contents? Is there a 'universal' way to work with both kinds of variants? (RSRVARIANTDIR / RSRPARAMETRIZA) 
    Thanks in advance.

    Thanks for the link.
    Well, I already read that document and I followed the links to the former blogs on this subject.
    But this solution doesn't work for me: CL_RSR_QUERY_VARIABLES is unknown.
    I read the pdf and the function-module-code, but I still don't have an idea how to work with query- variants . The example-coding includes a line
    DATA: wf_variant TYPE variant .
    but that's not used, or is it?
    (I don't have a set of variables and conditions, but just a variant-name. The variant will be created by other people, who would start my report.)
    Greetings

  • Colleting related information from related tables

    Hi,
    I have a requirement that i have to collected all related information from all related tables and store into text file.
    Table_A - Table_B,Table_B - Table_C, Table_B - Table_D
    if this is the relation
    for each record in Table_A i have to collected the details from Table_B and from all the related tables. The structure is not definded and it can varry.
    present approach is
    we have designed a table with parent,child,reference and the relation we are mentioning it in the table and using this we are trying to represent in tree structure.
    we have also writen recursive procedure to traverse through the nodes and flushing the record to the file.
    Is that there is any better way to do?

    Thanks a lot for your interest
    the table structure is like this
    case
    |----act_entry
    |....|--------gbst_elm
    |....|--------participant
    |....|--------user
    |----close_case
    .....|------act_entry
    .................|----- gbst_elm
    .................|----- participant
    .................|----- user
    so i want to collect the related records of a particular
    case ( let it be 100) in all act_entry (let it be 200,300) and then i have to go to gbst_elm and collect all records of gbst_elm(let it be 400,500) related to fetched act_entry based on the case.
    so the result in the text file shoule be like this
    100, , , , ,
    200, , , , ,
    300, , , , ,
    400, , , , ,
    500, , , , ,
    then for next case
    relation of the table structured in a table
    case_table_rel
    parent........child............relation
    case........act_entry.....case2act_entry
    act_entry...gbst_elm......act_entry2gbst_elm
    act_entry...participant...act_entry2participant
    act_entry...user..........act_entry2user
    case........close_case....case2close_case
    close_case..act_entry.....close_case2act_entry
    act_entry...gbst_elm......act_entry2gbst_elm
    act_entry...participant...act_entry2participant
    act_entry...user..........act_entry2user
    Hope now it would be clear if not kindly reply.
    Thanks     

  • BEx query with variant from ABAP

    Hello,
    I'm looking for possibility to start BEx query with variant (variant is created with tx RSRT) from ABAP. There are some funktion modules, which start queries (launch excel), for example RSAH_LAUNCH_EXCEL or RSSEM_QUERY_LAUNCH, but they are ending with short dump, when there are variables in the query. Is there any standard FM, which starts the query with variant or accepts parameters?
    regards,
    Krzysztof

    Hi,
    the short dump was my fault, I've passed query name instead of genuniid to the RSAH_LAUNCH_EXCEL.
    What I'm trying to do is to I'll start BEx query with parameters (I don't want to get selection-screen from the query, I need to fill it from ABAP).
    Here is my example, which is not working.
    DATA:
      lv_query(30) TYPE c,
      lv_genuniid  TYPE rsrrepdir-genuniid,
      ls_var       TYPE rrx_var,
      lt_var       TYPE TABLE OF rrx_var.
    lv_query = 'YB_MAKLER_DETAIL'.
    CALL FUNCTION 'CONVERSION_EXIT_GENID_INPUT'
      EXPORTING
        input  = lv_query
      IMPORTING
        output = lv_genuniid.
    IF lv_genuniid = ''.
      WRITE: / 'There is no Query', lv_query.
    ELSE.
      ls_var-vnam = 'YS_MKLE'.
      ls_var-sign = 'I'.
      ls_var-opt  = 'EQ'.
      ls_var-low  = '0000005100'.
      APPEND ls_var TO lt_var.
      ls_var-vnam = 'YS_VTGJ'.
      ls_var-sign = 'I'.
      ls_var-opt  = 'EQ'.
      ls_var-low  = '1999'.
      APPEND ls_var TO lt_var.
      CALL FUNCTION 'RSAH_LAUNCH_EXCEL'
        EXPORTING
          i_genuniid                       = lv_genuniid
          I_OBJVERS                        = 'A'
          i_hide_sapgui                    = 'X'
        TABLES
          I_T_VAR                          = lt_var.
    ENDIF.
    If parameter 'i_hide_sapgui' is empty, I'm getting empty selection-screen,
    If parameter 'i_hide_sapgui' equals 'X' I'm getting selection-screen filled with values, which were used last time manualy, not with values from the internal table 'lt_var'.
    Do you have any idea how to pass parameters to the query with this function module?
    Regards,
    Krzysztof

  • Query with 'different from' clause in Sqlite

    My question is very simple:
    How can I submit a query with a 'different from' clause into a table.
    In AIR, I would like to query :
    "select * from myTable where myField <> 'value' ";
    but it does'nt work !
    Nor
    "select * from myTable where myField != 'value' ";
    nor
    "select * from myTable where myField is not 'value' ";
    is it impossible to query with a 'different from' clause in Sqlite wih Adobe Air

    Hello,
    SQLite in AIR does support 'different from' and '<>' is the correct operator. Take the following emp table for example:
    id
    name
    age
    1
    A
    26
    2
    B
    30
    3
    C
    28
    If you want to query the records whose name isn't A. The following SQL is correct:
    select * from emp where name <> 'A'
    Thanks,
    Yang

  • Update table with select from another table

    Hallo,
    I'd like to update table b with codes from a mapping table a.
    a has:
    town_id, town_code, town_name
    b has town_code, town_id, town_population, town_zip_code,...
    Table a has all the details - town_id, town_code and town_name and acts as the mapping between town_id and town_code
    In table b, town_code is null. I want to update the column b.town_code with town_code from table a where a.town_id = b.town_id.
    How will the update query look like?
    I tried
    UPDATE B SET town_code = (SELECT A.town_code FROM A,B WHERE A.town_id=B.town_id)
    and I get the error 'single-row subquery returns more than one row'
    Will appreciate your assistance

    This is what I did.
    First, I created and populated the TOWN_INFO table:
    CREATE TABLE "TOWN_INFO"
    (     "TOWN_ID" NUMBER,
         "TOWN_CODE" NUMBER,
         "E_MAIL" CHAR(15 BYTE)
    Table Created.
    insert all
    into TOWN_INFO (TOWN_ID, E_MAIL) values (3024,'[email protected]')
    into TOWN_INFO (TOWN_ID, E_MAIL) values (3040,'[email protected]')
    into TOWN_INFO (TOWN_ID, E_MAIL) values (3052,'[email protected]')
    into TOWN_INFO (TOWN_ID, E_MAIL) values (3065,'[email protected]')
    into TOWN_INFO (TOWN_ID, E_MAIL) values (3066,'[email protected]')
    select * from dual
    5 rows created.
    The following creates and populates the mapping table:
    CREATE TABLE "TOWN_MAPP"
    (     "TOWN_CODE" NUMBER,
         "TOWN_ID" VARCHAR2(255 BYTE),
         "TOWN_NAME" CHAR(6 BYTE)
    insert all
    into TOWN_MAPP (TOWN_ID,TOWN_CODE, TOWN_NAME) values (3024,'1001','TOWN_1')
    into TOWN_MAPP (TOWN_ID,TOWN_CODE, TOWN_NAME) values (3040,'1003','TOWN_3')
    into TOWN_MAPP (TOWN_ID,TOWN_CODE, TOWN_NAME) values (3052,'1002','TOWN_2')
    into TOWN_MAPP (TOWN_ID,TOWN_CODE, TOWN_NAME) values (3065,'1004','TOWN_4')
    into TOWN_MAPP (TOWN_ID,TOWN_CODE, TOWN_NAME) values (3066,'1006','TOWN_6')
    into TOWN_MAPP (TOWN_ID,TOWN_CODE, TOWN_NAME) values (3088,'1007','TOWN_7')
    into TOWN_MAPP (TOWN_ID,TOWN_CODE, TOWN_NAME) values (3020,'1009','TOWN_9')
    select * from dual
    7 rows created.
    And now the update query:
    UPDATE TOWN_INFO
    SET TOWN_CODE=(SELECT B.TOWN_CODE FROM TOWN_MAPP B, TOWN_INFO C
    WHERE B.TOWN_ID=B.TOWN_ID)
    SET TOWN_CODE=(SELECT B.TOWN_CODE FROM TOWN_MAPP B, TOWN_INFO C
    ERROR at line 2:
    ORA-01427: single-row subquery returns more than one row
    Thanx in advance
    Edited by: user9954260 on Apr 13, 2010 7:40 AM
    Edited by: user9954260 on Apr 13, 2010 7:44 AM

Maybe you are looking for