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?

Similar Messages

  • Sap Query Additional Fields using  Abap Code

    Hi Experts,
    I am relatively new to the world of SAP query (Log Database PNPCE), I have written a number of additional fields to retrieve previous info-type data using the select statement E.G
    prev_endda = p0008-begda - 1.
    SELECT  single bsgrd
          INTO FTE1
          FROM
            pa0008
          WHERE pernr EQ  P0008-pernr
          AND   endda EQ prev_endda
    Although I can retrieve the previous info-type data , I was wondering if there was a easy way where I could take this a step further and show the Previous , Previous record. I.E
    Pernr     FTE Current    FTE1      FTE2
    101              60%          30%       75%
    I guess what I am asking is , is there a way to loop through the HR info-type records, does anybody know if there is a standard function or macro I can use to achieve this.
    Your help is much appreciated.

    Hi ,
    Thanks for our reply.
    I have pasted some example code into my additional field which I have created in SAP Query But im not sure how the loop bit works and how I can populate the additional fields that I have created , could you please explain this
    CALL FUNCTION 'HR_READ_INFOTYPE'
      EXPORTING
        pernr                 = '000000019'
        infty                 = '01'
        BEGDA                 = '18000101'
        ENDDA                 = '99991231'
      tables
        infty_tab             = p0008
      EXCEPTIONS
        INFTY_NOT_FOUND       = 1
        OTHERS                = 2
        LOOP AT p0008.
    NOT SURE WHAT TO PUT IN THIS SECTION *****
      ENDLOOP.
    I have created 3 additional Fields in the infoset Current FTE ,FTE1 FTE2 , and I want to loop through the records and populate the relevant Additional field with the employees FTE  (I only want to populate  where there is a change)
    Sample Data
    Begda              Endda             FTE        Salary
    1/1/2010         31/12/999       60%         19K          (Current  FTE)
    01/08/2009     31/12/2009     100%       27k           (FTE1)
    01/07/2008     31/7/2009         50%       17K          (FTE2)
    Thanks in anticipation
    DM

  • SQ01 Sap Query - additional fields doesn't appear

    Hi everybody,
    i've created a SAP Query with transaction SQ01 but one of my additional fields doesn't appear when i execute my Query.
    My query shows the G/L account number and the field status Group (table SKB1)
    I just need to display equally the text field of "field status Group" but it doesn't work.
    When i look at the parameters i can see that it makes the link between the table T004G and SKB1 in order to find the textfield but the field stay blank.
    For information T004g is a Pooled table.
    Is someone could help me?
    Thank you

    Hi,
    First you need to create a structure in Data Dictionary - SE11. This structure will contain all the fields that you want to display in the query output.
    Example - Name the Strucutre as zz_infoset01
    fields of the structure( for your requirement )
    BUKRS
    SAKNR
    FSTAG
    FSTTX
    Go to T-code SQ02
    1) Enter the Infoset name - zinfoset01 press create
    2) Enter a Short Description - G/L Infoset - 01
    3) select radio button - "Data retrieval by program"
                   and in "data structure" enter   zz_infoset01
    4) select "Integrated program" radio button
    5) In the next screen click on the "Data reading program" push button(on the application toolbar)
    6) An Editor will open with the following code
    REPORT  rsaqdvp_template .
      declarations
      (insert your declarations in this section)
    DATA:
      zz_infoset01                          TYPE zz_infoset01                          ,
      it_data TYPE STANDARD TABLE OF zz_infoset01 WITH HEADER LINE.
      selection screen statements
      (define your selection-screen here)
    !! the following comment MUST NOT BE CHANGED !!
    *<QUERY_HEAD>
      read data into IT_DATA
    (select your data here into internal table IT_DATA)
      output of the data
      (this section can be left unchanged)
    LOOP AT it_data.
      zq01  = it_data.                        .
    !! the following comment MUST NOT BE CHANGED !!
    *<QUERY_BODY>
    ENDLOOP.     
    7) when you insert your code in the sections it will look like this
    REPORT  rsaqdvp_template .
      declarations
      (insert your declarations in this section)
    Tables:SKB1,
              t004g.          
    DATA:
      zz_infoset01                          TYPE zz_infoset01 ,
      it_data TYPE STANDARD TABLE OF zz_infoset01 WITH HEADER LINE.
      selection screen statements
      (define your selection-screen here)
    !! the following comment MUST NOT BE CHANGED !!
    *<QUERY_HEAD>
    *These will be the input parameters for the query
    parameters: sp_bukrs like skb1-bukrs,
             sp_saknr like skb1-saknr.     
      read data into IT_DATA
    (select your data here into internal table IT_DATA)
    *get all the G/L for com code and G/L in selection screen
    SELECT bukrs saknr fstag
                INTO TABLE it_data
                FROM skb1
                WHERE bukrs = sp_bukrs
                AND   saknr = sp_saknr.
      output of the data
      (this section can be left unchanged)
    *for every G/L get the status text from t004g for lang 'EN'
    LOOP AT it_data.
    SELECT SINGLE fsttx
                    FROM t004g
                    INTO it_data-fsttx
                    WHERE spras = 'EN' "Language
                    AND   bukrs = it_data-bukrs
                    AND   fstag = it_data-fstag.
      zz_infoset01  = it_data.                        .
    !! the following comment MUST NOT BE CHANGED !!
    *<QUERY_BODY>
    ENDLOOP.     
    8) Save and generate the Infoset.By clicking on the generate button.
    9) Now assign the Infoset to the query in SQ01 and select the output list fields.
    let me know if you need more info. Also award points if helpful.
    Regards,
    Santosh

  • How to make SAP Query additional field as one of the selection field ?

    Hi experts,
    I'm working on a AdHoc query. I added some Additional fields to the infoset. I put Abap code to populate this additional fields as output fields but I want to make these fields as selection fields also.
    How can I accomplish this ?
    I'd appreciate any answer or suggestion.
    Thanks in advance.

    See Extended / Quick Search capability with attributes in the following SAP notes.
    [482338 - Using Extended Search in ISA B2B, ver. 30|https://service.sap.com/sap/support/notes/482338]
    [792556 - Quick search using several attributes|https://service.sap.com/sap/support/notes/792556]
    [888528 - ISA R/3 4.0: Extended catalog search not consistent|https://service.sap.com/sap/support/notes/888258]

  • SAP Query : additional field

    Hi,
    in my HR query i need to add a new field in infotype specific 9016 to be calculated by ABAP code.
    I perform the following steps :
    - transaction SQ02, i modify my info-set, in the node of my infotype i add a new field, i give a new name and a LIKE reference, and i generate the info-set, it's ok.
    - transaction SQ01 : i add my new field in my request, i check it and it's ok but when i run it, i have a dump : Function module "RPAQ_GET_AF_9016" not found.
    Can you explain to me how can i resolve this problem ?
    Cheers
    Edited by: CECG on Aug 25, 2009 11:08 AM

    Hi,
    What is the field you have referred to using LIKE statement? If this is infotype 9016, there  would be the corresponding table which holds the data for 9016 infotype(PA table...PA9016(i hope so and not sure of HR tables))....
    If so please refer to a dataelement for the field and then try to regenrate your query in SQ01 after adjusting the infotype in SQ02.
    Hope this helps
    Regards
    Shiva

  • SAP query text field

    Hi,
    I created a new customised field in infotype 9000 that has the same domain (but not the same component type) as p0001-stell(job).
    During sap query, i notice that this field only contain values and does not contain the text field. Please advise how i can add in the text field for this.

    Hi Lanwu,
    For the Custom field, let its domain be the same as the Sap standard field P0001-STELL ( JOB) . Do Not Change the Domain.
    Instead Create a Custom Data Element on this standard sap domain STELL and use ur naming convection for the text.
    Use this Customised or Z Data Element into ur Customised Field.
    Now wherever u use this field, the text specified in the data element would pop up.
    Thus u wont be touching the standard SAP Fields.
    Hope this helps.
    Jay Gandhi

  • I have trouble buying my account says that the information from my bank is wrong, I fixed, but goes on to say the same

    I have trouble buying my account says that the information from my bank is wrong, theCorrigo but goes on to say the same

    iTunes Store: My credit card's security code or zip code does not match my bank's records

  • SAP QUERY(SQ03/02/02) - how to join tables

    Hi MM Wizards,
    I would like to know how to join tables EINE & A017 through SAP Query?
    Thanks,
    Kaveri

    Hi Kaveri,
    A017 is a pooled table.  SAP Query does not support joins against Pooled tables.  You should stick to transparent tables if you want to use Query.
    You can do a direct read of A017, but you will just end up with a glorified SE16 display.
    You could have a programmer write some ABAP and place it into the 'extras' section in SQ02 to grab the additional data that you want, but once you have decided to enlist the aid of an ABAPer, it is better just to write a custom Z program from scratch.
    Regards,
    DB49

  • Can I create a Stored Procedure That access data from tables of another servers?

    I'm developing a procedure and within it I'm trying to access another server and make a select into a table that belongs to this another server. When I compile this procedure I have this error message: " PLS-00904: insufficient privilege to access object BC.CADPAP", where BC.CADPAP is the problematic table.
    How can I use more than one connection into an Oracle Stored Procedure?
    How I can access tables of a server from a Stored Procedure since the moment I'm already connected with another server?
    Can I create a Stored Procedure That access data from tables of another servers?

    You need to have a Database Link between two servers. Then you could do execute that statement without any problem. Try to create a database link with the help of
    CREATE DATABASE LINK command. Refer Document for further details

  • Query with collective information from MD04 in detail

    Hello gurus. I have a question about Infosets.
    Iu2019ve being asked to create a query that shows the information from transaction MD04, but for multiple materials. It should be a list that essentially lists every MD04 record for material in our plant, one after the other.
    I found a Function called MD_STOCK_REQUIREMENTS_LIST_API which contains this information. The problem is, this function exports the detailed data to a structure called MDEZ and the header data to a separate one called MDKP.
    I created an Infoset using u201CData Retrieval by programu201D and I typed MDEZ as the structure. I then coded the retrieval of data under the u201CData Reading Programu201D tab.
    The problem is, the MDEZ structure inside Function MD_STOCK_REQUIREMENTS_LIST_API doesnu2019t have the material number; this is exported to a separate one called E_MDKP.
    My question is; how can I also have the contents of MDKP added to this Infoset? When I create it, it only lets me use one single structure, I cannot also add MDKP.
    I tried creating an additional field just for the MATNR, but those extra fields cannot read what I coded under the u201CData Reading Programu201D tab. I tried to use a second internal table to drop the values of E_MDKP, and then loop it to fetch the MATNR, but I canu2019t add it to the additional field nor can I add it to a second structure.
    I made a query and it shows the MDEZ data correctly; I get one line per item found in MD04 for the materials I imported from our Plant, but I donu2019t know which material is which because that info is in the other structure MDKP.

    Thanks for your reply. if you don't mind me asking, how can I create my own structure to add it to the Infoset?
    When I create the infoset, I can either make from a Table Join, a Logical Database or data Retrieval. In the Table Join I cannot use structures, and under Data Retrieval, I can only use one of them.
    Is there a way to create a temporary (or permanent) structure that would contain MDEZ and the extra field MATNR that I need?
    Please advise.

  • Additional Field require to flow from SAP Delivery Line to DTR Line to Freight Unit

    Dear All,
    My scenario is Delivery line Item = DTR Line Item = Freight Unit.
    For this my requirement is I have added Additional field in ECC Delivery Line Item Table (LIPS) to record BAR Code Number.
    Now I want this BAR Code Number to flow in DTR Line Item and also in Freight Unit probably in Z Field as I do not found any standard field which I can use to map Bar code Number.
    Please suggest the necessary steps to achieve the same and also the Table/ Structures that need to be modified to flow additional field from Delivery (ECC) to PI and from PI to DTR (TM) and from DTR to Freight Unit.
    Regards,
    Vibhu Gupta

    Hi,
    First the inbound PI service needs to be enhanced with the addtional field on item level and in TRQ item node, this field also needs to be enahnced;
    For this field, do you want to save it in FU header or item level?
    In the implementation class of the inbound service, this field should be mapped to DTR item instance;
    If you enhance the field in FU item level with same field name, then the field value saved in DTR item will automatically flow to FU item.
    Hope this help.
    BR, Dawson

  • Sap Query custom field assigned to wrong field group (in extract)

    Hello,
    I want to add an extra field to InfoSet /SAPQUERY/MEBANF at EBAN level. I added a field in a normal way:
    I fill it with a constant value. I adapted Sap Query:
    In result, I got the value in new column but only for certain rows:
    The value is there only for EBAN rows which have EBKN entries related.
    I checked the program, and my new field is added to field group %fg07 with some other fields from table EBKN (not EBAN):
    Fields from field group %fg07 are inserted to extract only in event get EBKN, so if there is no entries in EBKN, my field will not be inserted into extract:
    I tried a lot of things (assigning my field to new field group in InfoSource, adding a field on EBKN level). I can say that every extra field created by me was assigned to field group &fg07.
    Am I doing something wrong?
    The target is to add new field in the document overview panel in ME2xN transaction. I know that there is user-exit EXIT_SAPLMEQUERY_002 where I can specify a Z* query. But this solution requires a copy of InfoSet and query to Z*. Adding a new field to standard Sap query is the fastest way.
    Message was edited by: Rafal Matuszewski
    Now I tried to append EBAN table with my Z* field. I regenerated InfoSet and query but the result is still wrong:
    insert EBAN-GSFRG into %fg06.
    insert EBAN-ZUGBA into %fg06.
    insert EBKN-VBELN into %fg07.
    insert EBKN-AUFNR into %fg07.
    insert EBKN-KOSTL into %fg07.
    insert EBAN-ZZDELIV_DATE_MRP into %fg07.   <-- here again the Z* field is assigned to field group related to EBKN table

    Thanks Sandra

  • Creating custom fields for manual entry and fields that gather data from Active Directory

    So I am no SQL developer but I am being asked to do this.. I've spent the last few days researching but cannot find anything related to my particular situation.
    I have made a copy of the following report to add or modify a few columns:
     Hardware 01A - Summary of computers in a specific collection
    So I have 2 questions:
    How do I create a field that will search the "Managed By" tab in the Computer Properties window in Active Directory.
    How do I create a field that can be manually updated for example: "Date Deployed" or "Deployed By: Analyst"
    I understand I need edit this in SQL report builder and think I know how to create the columns. I believe all I am really asking is.. What are the SQL statements I need to write in order to get this to work?
    I'm sure it's not as cut and dry as I hope it to be so I will be standing by to try to answer any further information that you will want to know.
    thanks!

    Before you can accomplish this you need:
    "Managed by" -attribute has to be added to your Active Directory System Discovery, more on this here: http://technet.microsoft.com/en-us/library/bb693618.aspx
    For "Date Deployed", I'd use a custom Tattoo script in your task sequence to "Tattoo" the installation info in the registry, after that I'd configure the Hardware Inventory to pick that from the registry, more on this here: http://ccmexec.com/2012/08/script-to-tattoo-the-client-registry-during-osd/
    and here: http://www.petervanderwoude.nl/post/reporting-about-the-all-the-different-os-deployment-versions-with-configmgr-2012/
    After those prerequisites, you can start working with SQL reports. More info here: http://myitforum.com/myitforumwp/2012/10/29/sccm-2012-reporting-for-dummies-creating-your-own-ssrs-reports/

  • Ad Hoc query Addition Field code

    Dear Experts,
    I need amend Ad hoc query to be able to report on Expected End MPP Q0088-EEMPP, It is not a standard field in the infotype for SE16 or SAP Query/Ad Hoc. We need to be able to query off this field. Can someone please point me in the right direction about how to get the calculated value from this field added to queries, or what code is needed.
    I have created an additional field in SQ02, i probably need code to make it fetch the data
    thanks
    haji

    Hi,
    Please take a look at standard function module HR_GBSMP_MPP_DATES. It returns the expected end date.
    Hope this helps.
    Donnie

  • Additional fields not getting copied from change req to change doc

    Hi,
    I created some addtional customer fields which I added both in change req and change doc.But the entries given to those fields are not getting copied from change req to the change doc as like standard SAP fields are getting copied.
    Please let me know if someone worked on the similar issue.
    Regards,
    M.R

    Hi,
    We have done a similar requirement of adding additional fields in Quotation doc type  at header and item level .
    Also we have got the Reference data of the order being created to flow in to Additional Data B .
    This is purely Abaper's Coding .when you add Additional Fields there is screen logic also to be coded for these screens .
    to get the Reference order data logic has to be written in PBO of the screen which u have added additional fields .
    the reference data will be validated with "VGBEL" field in VBAK table .If VGBEL is not initial then Query the VBAK table for this data in VGBEL into Internal table or work area and update the screen fields in additional data with these fields .
    I have done the same and it is Working Wonderful .
    Try this and Let me know Further. All the Best.
    Thanks,
    DevendraP.

Maybe you are looking for