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.

Similar Messages

  • SAP Query and runtime error CREATE_OBJECT_CLASS_NOT_FOUND

    Dear ABAP gurous,
    I have created a query connected to an infoset. It worked fine. When I made a minor change to the infoset (checked, saved and generated afterwards) I couldn't run the query. Now, the problem is, when I run the query, the ABAP runtime error occurs:
    Runtime Errors         CREATE_OBJECT_CLASS_NOT_FOUND
    Except.                CX_SY_CREATE_OBJECT_ERROR
    Can somebody tell me what causes the problem? Did I miss to do something after introducing this minor change to the infoset?
    Thank you in advance and regards
    Rafal Kosinski

    In the infoset I had tables join (FEBKO+T001) and additional field group. For the field group I defined a field for which a code was created (a function module call). It worked for this setup.
    Then, I just made a change in the code: in the function module call, I changed
    sy-datum to febko-azdat for parameter DATE of the function module.

  • Diff between sap query and abap query

    diff between sap query and abap query

    Hi,
    ABAP query is mostly used by functional consultants.
    SAP Query :
    Purpose
    The SAP Query application is used to create lists not already contained in the SAP standard system. It has been designed for users with little or no knowledge of the SAP programming language ABAP. SAP Query offers users a broad range of ways to define reporting programs and create different types of reports such as basic lists, statistics, and ranked lists.
    Features
    SAP Query's range of functions corresponds to the classical reporting functions available in the system. Requirements in this area such as list, statistic, or ranked list creation can be met using queries.
    All the data required by users for their lists can be selected from any SAP table created by the customer.
    To define a report, you first have to enter individual texts, such as titles, and select the fields and options which determine the report layout. Then you can edit list display in WYSIWYG mode whenever you want using drag and drop and the other toolbox functions available.
    ABAP Query,:
    As far as I Believe, is the use of select statements in the ABAP Programming. This needs a knowledge of Open SQL commands like Select,UPdtae, Modify etc. This has to be done only by someone who has a little bit of ABAP experience.
    To sum up, SAP queries are readymade programs given by SAP, which the user can use making slight modification like the slection texts, the tables from which the data is to be retrieved and the format in which the data is to be displayed.ABAP queries become imperative when there is no such SAP query existing and also when there is a lot of customizing involved to use a SAP Query directly
    use either SQ02 ans SQ01
    or SQVI tr code
    for more information please go thru this url:
    http://www.thespot4sap.com/Articles/SAP_ABAP_Queries_Create_The_Query.asp
    http://goldenink.com/abap/sap_query.html
    Please check this PDF document (starting page 352) perhaps it will help u.
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVQUE/BCSRVQUE.pdf
    check the below link will be helpful for u
    Tutorial on SQVI
    once you create query system generates a report starting with AQZZ/SAPQUERY/ABAGENCY2======= assing this report to tr code for the same
    regards,
    vasavi.
    reward if it is helpful.

  • Difference between sap query and sap ad hoc query

    Hello Experts-
    Is there any difference between sap query and sap ad hoc query. If yes, I will appreciate if you can provide some input.
    Thanks,

    Hi,
    SAP Query
    Purpose
    The SAP Query application is used to create reports not already contained in the default. It has been designed for users with little or no knowledge of the SAP programming language ABAP.
    SAP Query offers users a broad range of ways to define reports and create different types of reports such as basic lists, statistics, and ranked lists.
    Features
    The SAP Query comprises five components: Queries, InfoSet Query, InfoSets, User Groups and Translation/Query.
    Classic reporting- the creation of lists, statistics and ranked lists- are covered by the InfoSet Query and Queries components. Other components’ range of functions cover the maintenance of InfoSets, the administration of user groups and also the translation of texts created in the SAP Query.
    All data required by a user for a report can be read from various tables.
    To define a report, you first have to enter individual texts, such as titles, and select the fields and options which determine the report layout. In the WYSIWYG mode, you can edit the lists using Drag & Drop and various toolbars.
    AD Hoc Query
    Definition
    A Web item that enables you to create and change queries in a Web application on an ad-hoc basis.
    Use
    You can use the  Ad-hoc Query Designer Web item in the Web Application Designer to structure Web applications in which you create or change queries. The Web item is as a tool for designing ad-hoc queries in a Web environment.
    In particular it enables you to:
    ·        Create queries by assigning characteristics from an InfoProvider to rows, columns, filters, and free characteristics, and including key figures from the InfoProvider in the key figure structure of the query.
    ·        Restrict or filter key figures and characteristics
    ·        Use predefined key figure structures and restricted or calculated key figures in the query
    ·        Set or change query properties and key figure/characteristic properties in the query
    ·        Create or change conditions and exceptions
    When compared with the BEx Query Designer, the Ad-hoc Query Designer Web item has the following restrictions when creating or changing queries:
    ·        You cannot integrate variables into the query directly.
    However, you can use variables in reusable structures, or restricted or calculate key figures, which are used in the Ad-hoc Query Designer
    ·        The query can contain only one structure. This structure has to be the key figure structure and be in the rows or columns of the query.
    -        You cannot use key figures or key figure structures in the filter.
    -        You cannot define exception cells, since this requires two structures.
    You cannot create the following objects using the Ad-hoc Query Designer Web item:
    -         Reusable structures
    -         Reusable restricted key figures
    -         Reusable calculated key figures
    -        Local calculated key figures
    You can create local, restricted key figures using the Ad-hoc Query Designer Web item.
    You can edit existing queries in the Ad-hoc Query Designer Web item, if the queries adhere to the restrictions laid out above The Ad-hoc Query Designer checks these requirements when loading a query. If the query is too complex, the query can be loaded into the Ad-hoc Query Designer but you cannot change it there. You then receive the appropriate message. You can still check and execute the query.
    "Ad Hoc" is a Latin phrase which means "for this purpose" and in today's parlance generally means "on the fly," or "spontaneously."
    An ad hoc query is a query that is run at the spur of the moment, and generally is never saved to run again. These queries are run using a SQL statement created by a tool or an administrator. So therefore, such a query is one that might suit a situation which is only there for the moment and later on will become irrelevant.
    As queries become more complex, it can be difficult to write them correctly ad-hoc. To help with this, one can instead write the knowledge needed for queries as business rules in English, and then use a system called "Internet Business Logic" to automatically generate and run the SQL queries. One can then get explanations of the results, in English, at the business level.
    Check these links....
    http://help.sap.com/saphelp_nw04/helpdata/en/1f/03223c5f00612be10000000a11402f/content.htm
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/80bf2f79-021d-2a10-5082-dadc79aaa92c
    http://www50.sap.com/businessmaps/27FEEF3A12444F89A8524CCACAF4F5BF.htm
    http://help.sap.com/saphelp_nw70/helpdata/en/15/00a042b443c56ae10000000a155106/content.htm
    Reward points if useful....
    Regards
    AK

  • Autorization issue with SAP Query and RPTQTA10

    Dear all,
    I am having some difficulties with autorisations in SAP Query and Report RPTQTA10.
    in IT2006 I have a subtype 03 which should not be accessible for a group of users.
    Also I have created a test employee with a sybtype of IT2006 which is allowd and one which is not allowed.
    When I run some reports with that user I get a nice result with PT50. Only the allowed subtypes are being displayed.
    When I try to run A SAP Query or report PRTQTA10, the employee is not visible and seems to end op in an error list.
    Can someone shed some light on this issue?
    Kind regards,
    Patrick

    Hallo,
    Follow like this...
    Role 1:-
    authorization level: R, W  (You should not give W, R. You should give either W or M, R, Any way it will not create any problem)
    Infotype: 2006 -Ok
    Pers area: * -Ok
    Emp group: * -Ok
    Emp sub group: * -Ok
    profile: ALL*, ZBHR_OS etc etc -Ok
    Subtype: 01, 02 - Keep only sub type 01, 02
    fuction group: * -Ok
    Role 2:-
    authorization level: R, W  (You should not give W, R. You should give either W or M, R, Any way it will not create any problem)
    Infotype: 2006 -Ok
    Pers area: * -Ok
    Emp group: * -Ok
    Emp sub group: * -Ok
    profile: ALL*, ZBHR_OS etc etc -Ok
    Subtype: 03 - Keep only sub type 03
    fuction group: * -Ok
    Then user who want only sub type 01 & 02 then assign role 1 and he will not have access to sub type 03
    User who want only sub type 03 access, then assign role 2 only so that he will not have access to sub type 01 & 01
    User who want sub type 01, 02 & 03 access, gibe Role 1 & Role 2
    Hope it clarifies.
    Regards,
    Purnima

  • SAP Query and infoset rename

    HI
    Is it possible to rename sap query and infoset at a same time instead of changing one by one.?
    Thanks
    reg
    cns

    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

  • SAP Query and selection screen fields

    Hi,
    I am currently modifying a Query. I have added a new selection field. The fieldname for this selection field has been autogenerated within the query and I have pasted a bit in here:
    SELECT-OPTIONS SP$00015 FOR ZERROR_FLG LOWER CASE.
    SELECT-OPTIONS SP$00022 FOR KNA1-ERDAT.
    SELECT-OPTIONS SP$00023 FOR KNA1-ERNAM.
    SELECT-OPTIONS SP$00027 FOR ZLOEVM LOWER CASE.
    SELECT-OPTIONS SP$00030 FOR ZPARTNERNO
    NO INTERVALS NO-EXTENSION.
    I relation to this select -option, I want to execute a few lines of code that only is executed if the user has filled in a value in teh ZPARTNERNO field. However, no matter if I use the field name ZPARTNERNO or SP$00030 it has no effect.
    Any good ideas ?

    HI,
    In the AT SELECTIOn-SCREEN event, you can write the code
    IF not <b>SP$00030[]</b> is initial.
    write the code which you want to execute before the output
    ENDIF.
    if you want in START-OF-SELECTION>
    IF not <b>SP$00030[]</b> is initial.
    write the code which you want to execute before the output
    ENDIF
    Regards
    Sudheer

  • SAP Query - Adding new fields to SAP query

    Hi experts,
    I got an issue to work on SAP query.
    I have Transaction code and need to know the infoset to add additional two fields to the existing output.
    Please let me know how to find infoset/ Query for the specfic transaction and how to add fields.
    Regards,
    Venkata

    first check the transaction code given to you.. if it is report transaction (check using SE93), then get the report name for example AQFKTES_SGS_IV==MMIV0003======, then after aQFK,TES_SGS_IV woulbe be your user group and MMIV0003 would be your query. Now go to SQ03 with the user group (you need to check the query areas also which would be Environment---> query areas) because some can be client depended some can be just cross client. and then go to sq01 from user group. It will direct you to the queries of the user group you mentioned in SQ03. Now you should be able to find the query you are looking for. The infoset will also be displayed linked to the query. The infoset can be displayed via SQ02 transaction.
    If it is parameter transaction code, you need to check the parameter values to find the query details. Rest of the approach is same as mentioned above.

  • 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

  • SQ02 - Ad Hoc Query - Custom additional fields

    HI experts
    I am working additional fields in SQ02 .
    I added a new additional field for an info type in SQ02.
    Issue is when I right click on my additional field I can see options 'Only value' but for other fields I can see ' only value ' , 'only text' and ' value and text' .
    When creating the new field in SQ02, the check box "Determine LIKE reference using text field" is disabled.
    Is there is configuration somewhere or any other way, where I can also get the text for the custom additional field?
    I can see that this question has been asked earlier, but there are no responses.
    Also on SAP documentation, this field is shown as enabled.
    But I cant get the text for a additional field working. Please coyu post your suggestions?
    Thanks,
    Vaishali

    Hello Srini,
    Thank you for your time.
    Consider the additional field SYHR_A_P0001_AF_PL_CTRY (country) in Infotype 0001 in the infoset.
    This field does not populate any country code or text for us, so I need to create a custom additional field that will have the same functionality.
    I have created two new additional fields - Z_Country_Code and Z_country_text in additional fields section of IT0001.
    One field fetches country code and other fetches the text corresponding to this code.
    What I want to achieve is the standard functionality that is available for standard fields - P0001-WERKS for example.
    In the query output, you could select to display text/code/ text and code.
    For the additional field "Country", I have to select two separate fields - Z_Country_Code and Z_country_text  to achieve the same  functionality.
    How can I achieve this?
    When we define a custom additional field, in the field definition section, there is a check-box "Determine LIKE reference using TEXT FIELD" , but this is disabled when I create the additional fields. Perhaps, if this is enabled, then I can define the text table.
    Any ideas how to enable this text box?
    Vaishali

  • Adhoc query -sq02- Additional fields

    HI experts
    I am working additional fields in SQ02 .
    I added a additional field for an infotype in SQ02  .Issue when I go to Tcode PQAH and run the query .I Could not able to see the selections check box for my additional fields which is useful to select as input field .
    And when I right click on my additional field I could see  options 'Only value'  but for other fields I could see ' only value ' , 'only text' and ' value and text' .
    If any one worked on these kind of issues .Please give pointers .and requirement is specific.

    Hi Kamesh,
    I have the same issue - did you resolve this issue, and please could you share how?
    Thanks,
    Vaishali

  • SAP Query: Display Selection Fields in the header page of Basic list

    Hello,
    I have to display the selection fields in the header page of the basic list and statistics
    in a SAP Query.
    I know the usage of short names for fields in the header page, but this doesn't work
    for the selection fields.
    How can I display the selection fields in header pages?
    Kind regards
    Thomas

    Try using:
    DATA: wa_lstab TYPE line
    READ LINE sy-index line value INTO wa_lstab
    Thanks,
    SKJ

  • Query and selection fields

    Hi,
    I'm creating a query with trx SQ01.
    I want to modify the name of a field in the selection screen of the query.
    How can I do this ?
    Regards

    Hi,
    In SQ01 select query and choose icon "change".
    In the change query screen choose from top menu "goto", followed by "field selection" and "selections". In column "No" you can set sequence, in columns "selection text" you can amend the descriptions.
    Hope it will solve ur problem

  • Cfoutput query and form field names

    I have a form that have two field inputs. I would like to repeat the form fields as part of a cfoutput query. The first field of the form automatically populates the different person's name (via cfoutput query) and this form field is called "tenant". The next field of the form is called "sales". The sales field is left open for user imput. The entire form is in between the cfoutput query tags. When the cfoutput query is executed, Both form fields of the form is displayed with each tenant name listed in each of the first form fields of each row. The problem I'm running into is that even though the form elements appear to display correctly, I would like the name of each of my form elements in the cfoutput query, of each row to have a different form field name like, tenant2, sales2, tenant3, sales3 etc. is that possible?
    Here's what my code look like.
    <cfform action= "addsales.cfm" method="post">
    <cfoutput query="tenantsales"><Input name="tenant" type="text" value="#office.tenant#" size="32" />
    <select name="sales"><option>$5</option><option>$10</option><option>$12</option></br></cfoutput>
    <input name="submit" type="submit" />
    </cfform>

    I cannot imagine why you would want to show a list of pre-populated input fields. What makes sense to me is a select-box. If that is indeed what you want, then you could do something like this:
    <cfform action= "addsales.cfm" method="post">
    <cfselect name="tenant">
        <option value="">Tenant</option>
    <cfoutput query="tenantsales">
        <option value="#tenantsales.tenantID#">#tenantsales.tenantName#</option>
    </cfoutput>
    </cfselect></br>
    <cfselect name="sales">
    <option value="">Sales</option>
    <option value="5">$5</option>
    <option value="10">$10</option>
    <option value="12">$12</option>
    </cfselect></br>
    <cfinput name="submit" type="submit" value="Submit" />
    </cfform>
    Like Dan, I have assumed your database table has a column for tenant ID.

  • SAPbouiCOM.DBDataSource.Query and Date fields

    When I try to add a Condition that uses an Alias for a database field of type datetime, the Query method crashes.
    Is there a specific Date format that I am supposed to use?
    I am currently using the SAP date format and I also tried the database date format. Both crashed the Query method.

    My customer's date format is mm/dd/yy and that is the format I was using. Here is what my code looks like for debugging this problem which is still crashing on the Query method:
    conditions = new SAPbouiCOM.Conditions();
    condition = conditions.Add();
    condition.Alias = "U_PLS_PkgD";     
    condition.Operation = SAPbouiCOM.BoConditionOperation.co_GRATER_EQUAL;
    condition.CondVal = "03/11/2004";
    dbDataSource.Query(conditions);
    I have also tried the following date formats:
    condition.CondVal = "11/03/2004";
    condition.CondVal = "03-11-2004";
    condition.CondVal = "2004-11-01";
    "U_PLS_PkgD" is a field in my user table that is of type datetime in the database. I can Query with varchar and int database fields. Just not datetime fields.
    Please advise. Thank-you.

Maybe you are looking for

  • Can I change the background color of a caption?

    I would like to tone down the background color of a caption, and was wondering if and how I could do this. I found the caption image in the gallery, but it has an accompanying .fcm file which am not familiar with. Any help would be appreciated. Thank

  • Three invisible volumes eating up disk space

    I used Carbon Copy Cloner to load up a new external drive with the contents of my MBP. After it finished my Users folder it began copying "Volumes / LaCie 500GB." It wouldn't show up in Finder, so I presumed it was an invisible file, as best I unders

  • Changing to NTFS in Lion

    I want to change the format of an external hdd to ntfs file system in lion. How do i do that?

  • Problems Partitioning extra internal HD in MacBook Pro

    So here is the skinny, I bought a Mac Book Pro late 2011 2.3 i7 750gb 8gb ram moved the 750 to the optical bay then replaced it with a mushkin 240gb SSD, I love it. except I started using time machine on my 750gb internal drive and have run out of sp

  • Self approving travel expense on ESS/MSS

    Hi , I am implementing travel expense module. We are also implementing ESS and MSS for TE. Workflows are being used to send aprovel request to managers. I want to know if some one has implemented a check for self approval. i.e do any one know how to