SAP Query: MSEG - MATNR

hello friends,
i'm trying to create an SAP query that should output the Material Number of some purchase orders.
i'm choosing Direct Read of Table (MSEG) as my data source for my infoset.
however, inspite of choosing MSEG-MATNR (selection and output) as one of my data field, i could only output the Material Description, and not the Material Number itself.
i believe i am missing out on something. could someone help me?
thanks in advance.
best regards,
albert

Dear,
Did you try MB51 report with Movement restriction 101.
1. You are preparing query to get PO number and Material document number. That means Purchase orders which have material documents - usually means goods receipts.
If it is true, then try MB51. In this report you will get PO. Nu. / Mat. Nu /  Mat. Desc / Batch / Mat. Doc. Nu. / Amount in LC and Currency.
All display you required you will get.. Try this. I hope this will solve your requirement.
Regards,
Syed Hussain.
Edited by: Syed Hussain on Aug 31, 2009 12:32 PM

Similar Messages

  • Creation of SAP Query in SQ02 with Single Table With Condition

    Hi All,
    I want to Create SAP Query in SQ02 using single Table MCHA.
    ii) I dont want all entries of MCHA Table I mean , I have to apply some Condition on this Table.
    i.e  Suppose I am having actual data in MCHA table is like this for Material M1.
    Plant    Material   Batch   BatchCreationdate
    P1          M1         B1       20.06.2007
    P2          M1         B1       04.05.2009
    P3          M1         B1       04.05.2009
    But I want the Output of SAP Query is like this:
       Material   Batch   BatchCreationdate
          M1         B1       20.06.2007
    That is irrespective of Plant if Material & Batch are equal ---> 1st record with Lowest date shoud get at the output.
    Please help me How write the code on single table in the SAP Query.
    Thanks,
    Kiran Manyam

    Hi,
    Your query should be like this:
    Select MATNR CHARG HSDAT
    from MCHA
    into table t_mcha
    where matnr = Materlal number from selection screen.
    The structure of t_mcha should contain the fields that you select.
    Then sort the table by date ascending
    Sort t_mcha by HSDAT.
    Hope this solves your problem.
    Thanks,
    Sowmya

  • SAP Query - Additional field that collects information from table RESB

    Hello gurus. I have a question.
    I want to create a SAP Query that shows me the stock level of a list of materials, and also show me the total quantity of order reservations in an additional field.
    I created an InfoSet with table MARD, which is the one that holds the Stock information in a plant. Then I created an additional field which would read information from table RESB, the table that holds order reservations per material.
    So I wrote this piece of code:
    SELECT * FROM RESB
    WHERE MATNR EQ MARD-MATNR and
           WERKS EQ MARD-WERKS.
    ENDSELECT.
    if ( sy-dbcnt NE '0').
          MOVE RESB-BDMNG to ZQTY.
    ELSE.
          MOVE '' to ZQTY.
    ENDIF.
    This works fine. However, this is currently just catching the first record in table RESB that matches my condition.
    What I would like is to collect every instance of RESB-BDMNG and add them to field "ZQTY", have it loop in RESB until it finishes finding every record that match the MATNR and WERKS. With this I could get the total number of order reservations that this material has in that table.
    Could someone share some coding that would help me achieve this?

    Yes! That did it. That's what I needed to do. Thank you so much.
    While I'm at it, let me ask you a related question.
    When I execute the query, in the first records of the query where there's no value from RESB to transfer, the value of field ZQTY appears empty. Once it finds the first record in RESB and it populates ZQTY with a value, then the rest of the records with no hit get the proper value of 0.
    Do you know why the first records in the query appear empty and not with a 0? Is there anything I should add to the coding to fix this?

  • Sap query and additional fields.

    Hello guys.
    ABAP it's not my strong skill, but i need to develop some report.
    What i need:
    input: material, SLED, plant
    output: material, SLED, plant, values from characteristic field.
    I have created sap query with additional field type c.
    Below my code:
    TYPES: BEGIN OF charast,
            ATNAM(50)    TYPE c,
            ATWTB(8)     TYPE n,
            X(50)        TYPE n,
            C(50)        TYPE n,
            ATINN(50)    TYPE n,
            END OF charast.
    DATA: char TYPE TABLE OF charast WITH HEADER LINE.
    CALL FUNCTION 'VB_BATCH_GET_DETAIL'
       EXPORTING
         MATNR              = MCH1-MATNR
         CHARG              = MCH1-CHARG
         GET_CLASSIFICATION = 'X'
       TABLES
         CHAR_OF_BATCH      = char.
    LOOP AT char into TEST (This is an additional field type C.
       ENDLOOP.
    Questions:
    1. How i can return internal table into standard abap type, because i can create additional field only with standart types.
    2. Need i fetch exporting parameters before calling FM? Or sap query do it automatically, based on given values on selection screen of the report?
    3. How i can return only needed field from FM output? Now, when i'm executing FM via SE37 it's show desired result, but when i'm getting it from code i see strange values.
    4. If i don't know exactly return by an FM values, how i can fill structure dynamically?
    5. How i can return result of a program not only to additional field but to layout?
    Sorry for noob questions and thank you in advance guys!

    Well, seems like it work fine for me.
    Below my crappy, but working code:
    DATA: material TYPE MCHB-MATNR,
           batch    TYPE MCHB-CHARG,
           plant    TYPE MCHB-WERKS,
           sloc     TYPE MCHB-LGORT,
           gtdt     TYPE STANDARD TABLE OF clbatch,
           gtdit    TYPE clbatch.
    SELECT MATNR INTO material FROM MCHB
       WHERE MATNR = MCHB-MATNR.
    ENDSELECT.
    SELECT CHARG INTO batch FROM MCHB
       WHERE CHARG = MCHB-CHARG.
    ENDSELECT.
    SELECT WERKS INTO plant FROM MCHB
       WHERE WERKS = MCHB-WERKS.
    ENDSELECT.
    SELECT LGORT INTO sloc FROM MCHB
       WHERE LGORT = MCHB-LGORT.
    ENDSELECT.
    CALL FUNCTION 'VB_BATCH_GET_DETAIL'
       EXPORTING
         MATNR = material
         CHARG = batch
         WERKS = plant
         GET_CLASSIFICATION = 'X'
        TABLES
          CHAR_OF_BATCH = gtdt.
    READ TABLE gtdt INTO gtdit
       WITH KEY atnam = 'BATCH_SHELF_LIFE_EXPIRY_DATE'.
    GTD = gtdit-ATWTB.

  • Sap query sq02

    Dear all,
    since TWO days Iam working on this .... SAP Query without succes. Now I wanted to ask you here.
    I want to make a select-option in the SAP Query. Ok, this is easy! now the customer want to have F4-Help. Iam now in SQ02 where the data coming IN. I  crated a Z-Structur. In this Structur I have my field KLART. This field has a domain. In SQ02 I can say take the value from references. This mean  its takes the data from TCLA-KLART. But I see in the reference field. It takes data from TCLAT-ARTXT. So my question are:
    1) Why does it take the field from TCLAT-ARTXT?
    2) I dont see any information in the screen. This mean I dont get an option for this field KLART
    Thank u very much

    Hi,
    1)Data Source is  direct read of  table Mara
    2)
    you've to place the follow. code in
    SQ02-Goto-Code-Record processing:
    select count( * ) from mchb into sy-dbcnt
                     where matnr = mara-matnr.
    check sy-dbcnt = 0.
    regards Andreas

  • SAP Query join statements

    Hello,
    I am working on SAP Query in infoset I want to link the MVKE-MATNR to DRAD-OBJKY,
    but the length of the two fields are different. So the Query is not allowing the join. Hw can I over come the issue.
    Note. One material will have multiple docments.
    Thanks,
    Ravi.

    Hi,
    Define the final internal table with the fileds of the both internal table it1 and it2.
    the programming logic is like as following.
    Loop at it1 with every line item.
    move line item of it1(work area) into it_final.
    read table it2 with key wa_key (the same primary key field in any table it1 and it2).
    move line item of it2(work area) into it_final.
    endloop.
    try this to fill the it_final like this.
    regards,
    Pulak.

  • Display only the last record per material in SAP query

    Hi,
    I have created a SAP Query using the quickviewer that is a join between 2 tables (MSEG and MKPF) that consist of material document information and date of posting.
    The results are fine however I would like only the last record per material to be displayed.
    Can anyone tell what do I need to add so for only the last record per material be displayed in the output.
    Thanks,
    Mark

    Hi Mark,
    May be if you use Control Level processing .........I think you will be able to get the result you want. Try displaying as Below,
    LOOP AT XXXXX.
    AT FIRST material.
    ENDAT.
    AT LAST material.
    *...Display what ever you want here. It will display at end of every material.
    ENDAT.
    ENDLOOP.
    Before using sort the table with key material in ascending.
    Hope what I had to say is helpful to you.
    Cheers,
    Raga Suman.

  • Issue with Infoset of sap query

    Hi All,
    There is an existing 'z' Sap query and the inofet is created using  the data source 'Data retreival by program'(Data structure:BAPIEXPLOSIONLIST).
    I got the requirement to add onemore radiobutton(for Costing Run) to the selection screen of exsiting query and when the radio button is clicked on, it should display two more fields (Costing Run name and Costing Run date).So,I have added the below lines in the existing Infoset.
    1.Under the extras button and in data read program tab,I have added the below code for radio button and the two fields for selection.
    PARAMETERS p_cstrun LIKE jest-inact RADIOBUTTON GROUP cost.
    SELECT-OPTIONS sp_kaid FOR keko-kalaid  MODIF ID s1.
    SELECT-OPTIONS sp_kadt FOR keko-kaladat MODIF ID s1.
    2.Under the extras button and in code tab and in at seletion-screen output,I have added the below logic to enable those fields dynamically.
    LOOP AT SCREEN.
        IF p_CSTRUN EQ 'X' AND SCREEN-GROUP1 EQ 'S1'.
          screen-invisible = 0.
          screen-active = 1.
          MODIFY SCREEN.
          elseif p_CSTRUN NE 'X' AND SCREEN-GROUP1 EQ 'S1' .
          screen-invisible = 1.
          screen-active = 0.
          MODIFY SCREEN.
        ENDIF.
      ENDLOOP.
    After adding this,the existing selection-screen format has been changed.Please look at the below changes.
    ->Actually,there are two blocks in the existing screen with block titles.Now they are replaced with some different text
    ->And one more block for output format and under that the layout field selection was there in previous selection screen.Now this layout field text is changed to 'Sap Listviewer' and some butto has also come additionaly in the output format.
    How to retreive the old selection-screen with previous texts and formats.
    Can any one suggest to resolve the issue?
    Thanks in advance!!
    Best Regards,
    Mounika

    This is the complete code of selection-screen
    SELECTION-SCREEN BEGIN OF BLOCK issel
                              WITH FRAME TITLE text-S01.
    SELECTION-SCREEN SKIP.
    PARAMETERS p_cstcur LIKE jest-inact USER-COMMAND ex DEFAULT 'X'  RADIOBUTTON GROUP cost .
    PARAMETERS p_cstfut LIKE jest-inact RADIOBUTTON GROUP cost.
    PARAMETERS p_cstprv LIKE jest-inact RADIOBUTTON GROUP cost.
    *Begin of Insert CBDK972000
    PARAMETERS p_cstrun LIKE jest-inact RADIOBUTTON GROUP cost.
    SELECT-OPTIONS sp_kaid FOR keko-kalaid  MODIF ID s1.
    SELECT-OPTIONS sp_kadt FOR keko-kaladat MODIF ID s1.
    *End of Insert CBDK97200
    SELECTION-SCREEN SKIP.
    PARAMETERS p_niv_g LIKE jest-inact DEFAULT 'X'.
    PARAMETERS p_niv_a LIKE jest-inact DEFAULT  ''.
    PARAMETERS p_niv_f LIKE jest-inact DEFAULT  ''.
    SELECT-OPTIONS sp_disgr FOR marc-disgr MEMORY ID lev NO-DISPLAY.
    SELECTION-SCREEN SKIP.
    PARAMETERS p_newfil LIKE jest-inact DEFAULT  ''.
    SELECTION-SCREEN END OF BLOCK issel.
    SELECTION-SCREEN BEGIN OF BLOCK csel
                              WITH FRAME TITLE text-s02.
    SELECT-OPTIONS sp_mtart FOR mara-mtart OBLIGATORY
      NO INTERVALS NO-EXTENSION MEMORY ID mta.
    SELECT-OPTIONS sp_werks FOR mbew-bwkey OBLIGATORY
      NO INTERVALS NO-EXTENSION MEMORY ID bwk.
    SELECT-OPTIONS sp_matnr FOR mara-matnr MEMORY ID mat.
    SELECTION-SCREEN END OF BLOCK csel.

  • SAP Query Creation

    Hi All,
    I am creating a SAP query in the system using the tables KONP,MBEW & A018 i could join tables KONP & MBEW but i am not able to add the table A018 and a error message is displayed
    Error Message:
    Table A018 cannot be used in a join
    Message no. AQ501
    Diagnosis
    1. You cannot read the selected table with SELECT statements (because, for example, it is a structure without a database table). Therefore, this table cannot be read within a table join either.
    2. The chosen table is a pool or cluster table. These tables may not be used in a table join.
    Can anyone tell me a alternative to join this table to MBEW & KONP.
    I want this Join Conditions:
    MBEW-MATNR = A018-MATNR
    A018-KAPPL = KONP-KAPPL     
    A018-KSCHL = KONP-KSCHL     
    A018-KNUMH = KONP-KNUMH
    Thanks & Regards
    Andrew
    Edited by: Andrew J on Dec 18, 2008 2:49 PM

    hi,
    use  FOR ALL ENTRIES
    EXAMPLE:
    Exporting all flight data for a specified departure city. The relevant airlines and flight numbers are first put in an internal table entry_tab, which is evaluated in the WHERE condition of the subsquent SELECT statement.
    PARAMETERS p_city TYPE spfli-cityfrom.
    TYPES: BEGIN OF entry_tab_type,
             carrid TYPE spfli-carrid,
             connid TYPE spfli-connid,
           END OF entry_tab_type.
    DATA: entry_tab   TYPE TABLE OF entry_tab_type,
          sflight_tab TYPE SORTED TABLE OF sflight
                           WITH UNIQUE KEY carrid connid fldate.
    SELECT carrid connid
           FROM spfli
           INTO CORRESPONDING FIELDS OF TABLE entry_tab
           WHERE cityfrom = p_city.
    SELECT carrid connid fldate
           FROM sflight
           INTO CORRESPONDING FIELDS OF TABLE sflight_tab
           FOR ALL ENTRIES IN entry_tab
           WHERE carrid = entry_tab-carrid AND
                 connid = entry_tab-connid.
    REGARDS
    RAHUL

  • Sap query AND sapnwrfc

    Hi all,
    I have a working "sap query" (sq01).
    This query prints the list of our material catalog (module MM).
    My problem is to write an external program that displays the same output.
    To this purpose I installed "sapnrfc".
    All works correctly: I can connect to SAP, read a table (for example MARAV) and output the content.
    In SAPGui (sq01), I selected "InfoSet Query" and then "Display field information".
    I see (for example) that the "Material Number" is stored in the table MARAV (field MATNR).
    The problem is that in my "sap query" there are a couple of fields that I do not know where they come from.
    Selecting "Display field information" for these fileds I only see:
    TXT_ITA (Additional field)
    TXT_TET (Additional filed)
    Where is this information stored ?
    Perhaps there is a view ... or a better method.
    Thanks for any help.
    Miche

    Dear Sathya,
    SAP does not allow you to rename SAP Query & Info set at a same time.
    Note:
    The system has to lock the following objects before you are able to use the Rename SAP Info set function:
    User group catalog
    Info Set catalog
    Query catalogs for user groups to which the Info Set that you are renaming is assigned,
    Queries using this Info Set
    Once all these locks have been set, the system can carry out the function.
    Renaming an Info Set can, however, be very time-consuming. These locks may also prevent other users from working in the system for as long as it takes to rename the Info Set.
    Thanks & Regards
    Dinu

  • Abap coding in SAP query (SQ01)

    Hi,
    By using the a table like for MSEG if i want to retrieve data for the movement type 101 (receipts from vendor), i can build a query using this table and retrieve data - my problem starts when the system shows individual line items instead of cumulated result as mentioned in the following example.
    Example :-
    for the date 01.07.2007 - i have 10 entries (101 movement) of quantity 1,2,3,4,5,6,7,8,9,10 against a vendor V1. - the query lists all the 10 entries.
    But what is required is the cumulated entry against the vendor like shown below
    vendor    receipt
    V1         55.
    What abap coding should be written (provide the sample code) and the where should it be written in the query transaction SQ01
    Regards,
    M.M

    Hi Magesh,
    If you do not wish to see the detail lines, then you do not need to create them.  Just create the Statistics portion only.
    If you wish to see 'summarized Vendor quantity by day', then you might sort on Vendor first, then posting date second.  Or, vice versa, depending on your business requirement.  I would think that you might also wish to include Material in the sort, since each Material is probably valued differently.
    For more info on creating statistics in SAP Query, refer to
    http://help.sap.com/erp2005_ehp_02/helpdata/en/d2/cb4256455611d189710000e8322d00/frameset.htm
       Regards,
       Bruce

  • SAP Query :  Excel sheet  download problem

    Hi,
    While executing a Z SAP query in SQ01 and data is displaying  fine in the ALV format. But when we export the data to excel sheet, every column is appearing twice (repeating only the header,  with empty items)
    something like this......
    Excel sheet...
    Header MATNR  MATNR  MATKX MATKX   LIFNR  LIFNR  KUNNR   KUNNR
    Item     10                       Test                   ABC                ABC
                  20                       Test2                 XYZ                 XYZ
                  30                       Test3                 MNO               MNO
    What can be possible cause of this ? What can be the corrective step to the issue?
    Thanks,
    Jai

    Hi ,
    Please follow the below step .
    In SQ01 --> In the List Display screen --> click on Export --> Local file --> Spread Sheet --> Give the File name and click on generate .
    It s working file . and i can be able to download all the records to excel without any repeatation .
    Thanks
    Pavendhan

  • Field selection in SAP query

    Hello Team,
    I have a query on SAP query. I have the field MSEG-KZEAR and RESB_KZEAR. Now the MSEG field is visible in sq01 and is selected as output but the table has no entries for this field. Also the entries are maintained in RESB field. But RESB table is not visible for selection in sq01; however I can see the table in sq02 but unable to select the said field as output.
    I want to select the RESB-KZEAR field for output but i am unable to do so in SQ01.
    SQ01
    SQ02
    Please help to do so.
    Thanks again for your time,
    Beryl

    Hi Beryl,
    Please move your RESB-KZEAR field into Group fields using drag and drop in SQ02.
    and activate your SAP Infoset aafter that you can use  infoset in Query.
    Then value will be moving from RESB table.
    Regards,
    Prasenjit Mishra

  • Question on SAP query

    i am working on sap query,
    my requirement is:
    there is already a sap query, where MARA tabel and MARC are mapped and are working fine.
    i need to drag in one more table AEOI for the purpose of finding latest revision level.
    in ususal report program we can find the revision level by sending matnr as OBJKT, objtyp as 41,
    and out of the list we get, we sort in descending order of date to get the latest levesion level.
    can some one suggest me how to do this in SAP query.
    is there a place where i can simply put in my code to call the AEOI table and sort the out put.
    please help.

    Hi Sanjana,
    Its better not to touch the standard sap generated program for the query, better choice would be copy the program to Z program and then make the changes what ever you require.
    Then create the tcode for that zreport and execute it and you can transport it to other environments.
    you can directly give the tcode to the process folks.

  • SAP query

    Hello ABAP Guru
    I need a help here. trying to create SAP query joining three table VBAK VBAP KONV since KONV being cluster table I am not able to do that
    thpough I am suceesfully establishe dthe link
    VBAK-VBELN=VBAP-VBELN
    VBAK-KNUMV=KONV-KNUMV & VBAP-POSNR=KONV-KPOSN
    OSS msg says we have to write routine in sap query
    but I never used that option
    anyone has any clue on how to use cluster table in SAP query?
    Thx
    Praveen

    Hi,
         Inner Join can't be  used for cluster tables.
         Write a routine in SAP query as follows.
          do inner join on vbak,vbap into internal table  
          itab.
           select for konv for all entries itab .           
    Regards
    Amole

Maybe you are looking for