Write code in ad hoc query

hello All,
I have a reqmnt, My client has an existing ad hoc query and I need to add two fields to it, both of the fields are not direct and needs some coding, cud anyone please explain how can i go bout it?
thanks,
RS

Its quite straight forward, so just have a play around, but the steps are something like:
1.     SQ01/environment/info sets/query areas/standard
2.     Choose the info set you wish to change
3.     Choose the filed group you wish to add a field to
4.     Right click the infoset you want to add a field to
5.     Add the new field to the field group for that infoset
6.     Then use the extras button to add code to that field
I tend to use the initialization, and record processing event blocks for adding my code.  USe the eblow link for the SAP documentation.
http://saphelp.user.ad.glasgow.gov.uk:8000/saphelp/helpdata/EN/d2/cb3efb455611d189710000e8322d00/frameset.htm
And here is some sample code i've used for one particaulr field, just to give you an idea of how easy it is.
rp_provide_from_last p0000 space pn-begda pn-endda.
* Get last Ity2001 record
IF p0000-massn = '16'.
  SELECT SINGLE pernr max( endda )
         FROM pa2001
         INTO (p2001-pernr, p2001-endda)
              WHERE pernr = pernr-pernr
              GROUP BY pernr.
ELSE.
  rp_provide_from_last p2001 space pn-begda pn-endda.
ENDIF.
SELECT SINGLE UMSKD
       INTO WA_UMSKD
       FROM Y0PT_AMMSUBS
            WHERE PERNR = p2001-pernr
            AND   ENDDA = p2001-endda.
wa_OCCHC  = wa_UMSKD(2).
occhealth = wa_OCCHC.
<a href="http://saphelp.user.ad.glasgow.gov.uk:8000/saphelp/helpdata/EN/d2/cb3efb455611d189710000e8322d00/frameset.htm">http://saphelp.user.ad.glasgow.gov.uk:8000/saphelp/helpdata/EN/d2/cb3efb455611d189710000e8322d00/frameset.htm</a>

Similar Messages

  • Transaction Code to AD Hoc Query

    I have created an Ad Hoc Query and Given it a name and saved it.
    Next Time when I wanted to execute that query I go to S_PH0_48000510 - Ad Hoc Query , select that query and press on Output to get the result. In between I have selected the setting "Start via selection screen" in Extras>Settings.
    Hence I get into the selection screen and while I execute, I go to the output result.
    What I am looking for is how to assign a transaction code to this query that I have created, so that I execute that transaction code I am directly into the selection screen. By means of this I can skip some of the steps like going to S_PH0_48000510 - Ad Hoc Query and then selecting the query and then the other steps.

    Both the ad-hoc and the SQ01 queries create a program that can be assigned to a transaction.  However, the program name that is generated contains a 2 digit code that is specific to the client you are working on.  This makes it hard to run the same transaction in DEV, QAS, and PRD.  Instead, create a parameter transaction that runs the START_REPORT transaction with parameters set that run the D_SREPOVARI-REPORTTYPE=AQ, D_SREPOVARI-EXTDREPORT=<sap query name in SQ01>, D_SREPOVARI-REPORT=<user groups belonging to the query>

  • Validation of EEO code using ad hoc query

    Hi,
    I just want to ask for a help or any ideas with regards to the case below.
    The EEO job categories have been revised and I've already map the existing job codes to the correct EEO job category in table T5U13. But when I try to run a query for a specific job to check and verify if the mapping of the new EEO job category to the existing job code is correct, the EEO code field is left blank. Meaning that there is no EEO job category attached to the job code. But I've maintain the mapping already and when I double check table T5U13, the job code is map to the new EEO job category. I just want to ask for help that if I run the query, the EEO code field would have an entry based on the mapping I've done.
    Thanks in advance for your help!

    Hi Sanghmitra,
    I have got a query  in AD-HOC query.
    After creating the Adhoc query using the join table functionality the resulting adhoc query does not results any out put.
    What I have done is :
    1.Created a user group through SQ03
    2.Attched user to My user group
    3.Created an infoset using join table functionality(SQ02).
    4.Saved and generated the infoset
    5.Added the user group to the infoset and than run the ADHOC query.
    The table I have used to join is all PA table (For test pupose)
    Though the purpose of the custom infoset is to join PA,OM and E rec infotypes, for testing purpose I have joined only PA infotypes.
    Result:The adhoc query does not gives any out put instead it says no data could be read.
    Could you please tell what else I need to do so that the custom infosets gives an out put.
    Will greatly appreciate your help.
    Thanks and best regards
    Rajeev

  • Custom code in HR Ad Hoc query

    Hi Friends  ,
    I am facing one issue where the custom ad hoc query is giving incorrect results so I have to overwrite the values in available  internal tables with my own logic , But I am unable to write the code at right point through Extras>create>code  path in SQ02   the values are populate after the point where i can right code . Request you to kindly help me .
    Thanks & Regards
    Gaurav Deep

    Hi,
    Write the coding in End-of-selection(before list) event. Your internal table would not be changed after this point.
    Regards,
    Srini.

  • 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

  • How to get List Item attachments name without write any custom code or any database query?

    Hi,
    How to get List Items attachments name without write any custom code or any database query?

    You can get it from Rest,
    There are 2 options,
    1) create a 'Result Source' which has a search query for that List which has attachments 
     - Use rest query to get the 'Filename' , it will have the attachment file name 
    For example, if the result source id is : 73e6b573-abf8-4407-9e5f-8a85a4a95159 , then the query will be 
    http://[site URL]/_api/search/query?querytext='*'&selectproperties='Title,Path,FileExtension,SecondaryFileExtension,Filename'&sourceid='73e6b573-abf8-4407-9e5f-8a85a4a95159'&startrow=0&rowLimit=100
    You can refine the query, be giving proper 'querytext'
    2) Use the List rest api
    For example if your list guid is :38d524a1-e95c-439f-befd-9ede6ecd242e
    You can get he attachments for 1st item using this 
    http://[Site URL]/_api/lists(guid'38d524a1-e95c-439f-befd-9ede6ecd242e')/items(1)/AttachmentFiles
    get2pallav
    Please click "Propose As Answer" if this post solves your problem or "Vote As Helpful" if this post has been useful to you.

  • Is it possible to write an abap code be SAP SQL query.(ECC 6)

    hello guys,
    Is it possible to write an abap code be SAP SQL query.
    Scenario : table A has a field say f1 of length 10 and table B has a field say s1 of lenght 20. in sap sql i am able to link all the other tables but i am not able to link
    table Af1 --->Table Bs1. as the length doesnot match. so is it possibel that using abap code I can pick 10 characters from table A field f1 adjust it to 20 characters using abap and map it to field s1 of table B.
    Please let me know how to accomplish this if possible.
    thanks in advance!!

    Herm,
    Adding code is done in the infoset.
    Please do following:
    > Goto SQ02
    > Type in the infoset that the basis for your query, <change>
    > Press <code> OR <shift><f8>
    > Tou'll see 4 tabs: Extras, Selections, Code, Enhancements.
    > GoTo tab Code
    > Choose the coding section (<f4> gives you an overview)
    > Enter the code.
    You may set a breakpoint to see what the query in SQ01 will do with it.
    Succes!
    Frank

  • AD HOC query (coding)

    Hi,
    I have Ad hoc query and in the selection screen I have  field(select option) for language , what I am trying to do is to make a login language  as default value for language field ,I tried throw SQ01 the only thing I could do is to add fixed value (for example 'EN') but need it to be login language.
    Its seems to be the only way is to write code But I donu2019t know how?
    PLEASE HELP.

    Defining ad hoc query you can select personnel number as output field by right clicking on "Personnel number" in "Key fields" group. In the context menu you can find "Output" and three possibilities:
    1. Only text - which is default and means an employee's name,
    2. Only value - which means personnel number,
    3. Value and text - in this case two columns are displayed: personnel number  and the employee's name.
    Regards,
    Renata

  • Questions in Ad Hoc Query & How to Configure the EEO standard reports

    Hi all,
      I have a  question in Ad hoc query report in HR.
    <b>How to:</b> Get a list of the total number of employees included in a particular report at the end of the report. Ex: If i create and run a report for salaried employees, sorted out by company codes, how can i get a sub-total and total no. of employees listed in the report.
    I tried Ranked format, but when you print the report it doesn't retain the report name on the top.
    -->I have a question regarding the Standard reports for EEO and AAP
    <b> How do I</b>
    1. Start configuring these report
    2. What are the things i should have before configuring it in IMG
    If anyone can provide me with some documentation regarding the EEO and AAP report configuration that would be great.
    Thanks in advance.....
    Harish

    This can be done using the security for the Infoprovider,  provide the users access to create queries only for that Infoprovider.

  • How to make a custom field as text as well as value fied in ad hoc query

    hi,
      i have created a custom infotype 9004 in which the custom field contain the code values, and the text of this code values are maintained in another ztable.
    when i am viewing this infotype in Ad hoc query i am able to see this fields as only value fields and hence i am unable to get text for this field i.e when we right click on this field only the value option is enabled and the text option is disabled, both these options are enabled in some other standard fields like pernr(personnel no), persg(employee group),persk(employee subgroup).
       can anybody suggest me how to enable both these options for custom fields.

    Assign you table of text as a table text to the data element/domain of your custom field or thru external key on your infotype.
    Query is able to analyse these links.
    Regards.

  • Addition of new fields and sub dields in ad hoc query

    hey all,
    hey friends i would like to know how to add additional fields and the sub fields in ad- hoc query.
    i had tried sq02 and went on creating new field but it is nt adng there and no options of sub fields are visible.
    note: i am entirely new to sap hr.. so plz try and help me out in a laymans language.

    At the Date Field, there is 1 node call the Additional fields.
    Then Right click the Additional field and choose create >> additional field.
    Then enter the field name, description, Data type and length.
    After that right click the newly created field name and choose code
    Then enter some simple code.
    E.g.
    For IT2006 the table does not provide the quota balance. If order to display the quota balance we can create an additional field call ZBalance. Then at code section enter the code ZBalance = p2006-anzhl - p2006-kverb.

  • Ad-hoc query

    Hello,
    Our business users would like to use ad-hoc query for the reports they would want to generate on the as need basis. Can anyone please elaborate on how to use ad-hoc reports in HR.
    I tried with the t-code S_PHO_48000516 for running ad-hoc reports, but its only for PA. We would want to run queries both on PA and OM data simultaneously. Also I could not pull the custom infotypes data in there.
    Please elaborate on how to use Ad-hoc and Infoset queries.
    Thanks in advance.

    Hi,
    U can use Infoset Query for report in HR. T-Codes are SQ03, SQ02 AND SQ01. By SQ03 create user group. then SQ02 -infoset and by SQ01 create reports.
    try this. it works.
    Regards
    Nas

  • Ad hoc query without personnel no

    hi,
        In Ad hoc query t.code S_PH0_48000510 ,infoset(/SAPQUERY/HR_ADM) when I select personnel no & issue output, system is displaying personnel name instead of personnel no. Is there any changes need to be done or is it a system bug ECC6.
    Regards,
    Karthik.k

    Defining ad hoc query you can select personnel number as output field by right clicking on "Personnel number" in "Key fields" group. In the context menu you can find "Output" and three possibilities:
    1. Only text - which is default and means an employee's name,
    2. Only value - which means personnel number,
    3. Value and text - in this case two columns are displayed: personnel number  and the employee's name.
    Regards,
    Renata

  • Ad hoc query for  om

    Dear gurus,
    could you please tell me that ad hoc query is written by Sap functional people.like sao hr people ,or this is standard one.
    actually my DOJ and Relationship is not showing in that Ad Hoc Query report for OM.
    Pls suggest me what i need to do ,so that it will update,
    Could u pls tell me how to write this Ad hoc Query ?
    regards
    S
    Edited by: smrutipuspa on Sep 23, 2010 1:09 PM
    Edited by: smrutipuspa on Sep 23, 2010 2:03 PM

    Hi S,
    TCD SQ01,SQ02,SQ03
    for this you would have to create usergroup and infoset
    as we know LDB's are special abap program that  combines data from related tables and makes it avilable for query and programs
    Logical Database
    TCD -SE36
    PCH(Personnel Planning),PNP(HR Master Data),PNPCE(HR Master Data (Incl. Concurrent Employment)),PAP (applicant matsre data) are some LDB's(logical databses)
    Infoset are special views of LDB's and determine which tables and/or fields within a table, queries may reference
    http://www.dmgfederal.com/Resources/Articles/Article_SAPR3Infosets.asp
    usergroup are user gruped using the same application aera
    you could also try TCD SQVI-sap query viewer
    http://auditware.cyb.co.uk/downloads/SAPQuery_step_thru.pdf
    http://www.sap-img.com/abap/step-for-using-query-sq01-sq02-sq03.htm
    http://www.insightcp.com/res_15.html
    hope it helps
    No Worries
    KG
    Edited by: SAPenjoy:) on Sep 24, 2010 8:09 AM

  • Ad-Hoc Query Field using HR_99S_INTERVAL_BETWEEN_DATES function module

    I have created an additional field in Sq02 to calculate years between two dates and am using function module HR_99S_INTERVAL_BETWEEN_DATES.
    There are no syntax erros but when I run a query in Sq01 and output the field it doesn't calculate instead gives "00000" output.
    The field Code in the additional field
    Clear ZHR_SERVICEYRS.
    DATA: V_MONTHS TYPE  i.
    DATA: V_YEARS TYPE  i.
    DATA: V_MONTHS1 TYPE  char20.
    DATA: V_YEARS1 TYPE  char20.
    CALL FUNCTION 'HR_99S_INTERVAL_BETWEEN_DATES'
      EXPORTING
       BEGDA           = P0002-GBDAT
       ENDDA           = Sy-Datum
      TAB_MODE        = ' '
    IMPORTING
      DAYS            =
      C_WEEKS         =
       C_MONTHS        = V_MONTHS
       C_YEARS         = V_YEARS
      WEEKS           =
      MONTHS          =
      YEARS           =
      D_MONTHS        =
      MONTH_TAB       =
    V_MONTHS1 = V_MONTHS.
    V_YEARS1 =  V_YEARS.
    CONCATENATE V_YEARS1  '.'  V_MONTHS1 INTO ZHR_SERVICEYRS.
    condense ZHR_SERVICEYRS.
    has anybody had similar problems! Help Appreciated!

    Hi Anuj,
    Yes, you use Transaction Code SQ02.  Find your infoset on the list - if you want to create a new infoset you can do so.  If it is an existing infoset, select it and Change.  On the next screen you will see all the infotypes in that infoset on the left.  The fields available for Ad Hoc are on the right.  Open the infotype table on the left and the field group on the right.  If the field is not included in the field group all you have to do is drag and drop from the list on the left to the correct field group.  If the infotype is not already in your infoset, select Edit --> Change Infotype Selection from the top menu bar.  Place a check in the new infotype and then return and do the drag and drop if necessary.  You will find the basic fields already moved to the field group. 
    You say you want information from IT0008-Basic Pay and IT1005-Planned Compensation.  Problem is that if you use the standard HR logical data base, there is no link directly between a person and IT1005.  IT1005 is assigned to a Position or a Job.  If it is assigned to a Position, you can select the "Change Infotype Selection" action and ago to the bottom of the list to Related Objects.  Here select Position and open that to find the IT1005.  If the IT1005 is tied to the Job, there is no direct link. Thus, if it does not already exist, you will need to create an infoset based on the PCH logical database and object Position.  Now you can link that Position to "Holder"-Person and "Described by"-Job.  Again, select the infotypes and fields you want and you will be able to obtain your information via Ad Hoc Query based on that infoset.
    Paul

Maybe you are looking for

  • Trouble out of no where

    when trying to sync my ipod i get the error message: iTunes has detected an Ipod that appears to be corrupted. You may need to restore this Ipod before it can be used with iTunes. You may also try disconnecting an reconnecting the Ipod. and when i cl

  • Unable to start subscription service for Adobe Photoshop CS5

    Hi there. I'm trying to install Adobe Photoshop CS5 on my laptop and every time, after installing the product and entering the serial number, the process fails and tells me 'We are unable to start your subscription for Adobe Photoshop CS5 Subscriptio

  • Correct way to compress 16X9 file for the web

    Hello: Shot an HDV project. After importing converted files to DVCProHD. 1280X1080 16X9. Edited 5 min. piece. Exported QT with current settings. Need to upload to You Tube. Please tell me...what's the best choice in Compressor? I tried H.264 Streamin

  • Ole, attaching a word document in forms6i

    Hi everyone, I am planning to attach a word document using an ole container in a blob database item in oracle 6i forms environment. I was able to do it but when a word document is opened i was not able to restrict few users from editing the word.(All

  • Adf security login system

    Hi I would ask you for advice. I have a case: 1.     On the weblogic are specified users: 2.     I must make login system which will verified is user exist on weblogic. I have seen Franks tutorial http://download.oracle.com/otn_hosted_doc/jdeveloper/