Simple abap query doubt

Hello all,
   i have one simple doubt plz help.
data:begin of itab1 occurs 0,
     psnfh like plfh-psnfh,
     end of itab1.
select  psnfh  into table itab1
from plfh
                 where plnty = 'N'
                 AND plnNR = group_number
                 AND plnfl  = W_PRT_ASSIGN-SEQUENCE_NO
                 and loekz ne 'X'
                and plnkn = t_plnkn.
this query is working fine.
        now i have 3 psnfh entires(0010 0020 0030) ..my requirement is that i have choose maximum of these that is 0030 and wanna add 0010 to it everytime.....and may be it will be better if i can save it in a variable.......
     plz help in this syntax......i know we can use MAX function but it will be better if u can give that exact 2-3 lines of code.

Hi Abhijeet,
Do you always want to add "0010" to the maximum value from that internal table?
If yes, then you can follow the steps mentioned below.
1. Declare temporary internal table and transfer al values from your main internal table to the temporary.
ITAB_TEMP[] = ITAB[].
2. Now Sort the temp table as follows.
SORT ITAB_TEMP BY fieldname DESCENDING.
3. Now if you READ this temp table with INDEX 1, you wil get the maximum value to which you can add the value.
READ TABLE ITAB_TEMP INTO W_ITAB INDEX 1.
IF SY-SUBRC EQ 0.
  V_MAX = W_ITAB-field + 0010.
ENDIF.
Best Regards,
Ram.

Similar Messages

  • ABAP Query Doubt

    Hi All,
           I am using the ABAP query using the infoset Logical database PNPCE.
    When i select the fields for the output i am getting it. But i need to make some of the fields as mandatory in the selection screen.
    How can i make it.
    Regards,
    Yogesh

    Hello,
    Go to the info set of the query.
    SQ02 -> Enter the infoset name  -> click on 'Change'
    Go to the 'Selections' tab.
    There you will find all the selction screen parameters. Double click on the selection parameter which you want to make it a mandatory field.
    It will pop-up a dialog screen. On  this dialog screen on the input field 'Extras'
    enter the key word OBLIGATORY. Than don't forget to regenarate the infosets again.
    This will solve your problem.
    Regards,
    A.Singh

  • Need ABAP Query Builder Like Ms-SQLQuery Builder for Critical ABAP-Query

    Dear ABAP Friends,
    I Need ABAP Query Builder which is as flexible as Ms-SQLQuery Builder for building Critical ABAP-Queries e.g. "I have 4 master tables , Each master table having self-join with some condition and these 4 Result-Sets have Innser-Join+Left Outer Join " Please Help.

    I have seen TCODE SQ01, But I found that this TCODE may be used to build simple ABAP Query with Selection-screen which can be used for generating simple report. But i think for critical query ??????????
    I have build my Query in MS-SQL and got the right output, Now how do I write this in ABAP Using Join statement. Please Help.....................
    My SQL Query as below(Remember this is a single Query and verified correct in SQL):
    SELECT     P1.PERNR, P1.ENAME, P1.BEGDA AS P1BEGDA, P1.ENDDA AS P1ENDDA, P1.AEDTM AS P1AEDTM, P1.UNAME AS P1UNAME, P1.PERSG, P1.PERSK,
                          P1.PLANS,
           P2.ENDDA AS P2ENDDA, P2.BEGDA AS P2BEGDA, P2.AEDTM AS P2AEDTM, P2.UNAME AS P2UNAME, P2.GESCH, P2.FAMST,
                       P21.ENDDA AS P21ENDDA, P21.BEGDA AS P21BEDDA, P21.AEDTM AS P21AEDTM, P21.UNAME AS P21UNAME, P21.FAMSA, P21.FAVOR, P21.FANAM,
                          P21.FGBDT, P21.FASEX,
                       P0.ENDDA AS P0ENDDA, P0.BEGDA AS P0BEDDA, P0.AEDTM AS P0AEDTM, P0.UNAME AS P0UNAME, P0.MASSN,
                          P0.MASSG
    FROM         (SELECT     TOP (100) PERCENT PA0001_2.PERNR, PA0001_2.ENDDA, PA0001_2.BEGDA, PA0001_2.AEDTM, PA0001_2.UNAME, PA0001_2.PERSG,
                                                  PA0001_2.PERSK, PA0001_2.PLANS, PA0001_2.ENAME
                           FROM          PA0001 AS PA0001_2 INNER JOIN
                                                      (SELECT     PERNR, MAX(ENDDA) AS ENDDA
                                                        FROM          PA0001 AS PA0001_1
                                                        GROUP BY PERNR) AS Pi1
    ON PA0001_2.PERNR = Pi1.PERNR
    AND PA0001_2.ENDDA = Pi1.ENDDA
                                               ORDER BY PA0001_2.PERNR) AS P1 LEFT OUTER JOIN
                              (SELECT     TOP (100) PERCENT PA0000.PERNR, PA0000.ENDDA, PA0000.BEGDA, PA0000.AEDTM, PA0000.UNAME, PA0000.MASSN,
                                                       PA0000.MASSG
                                FROM          PA0000 INNER JOIN
                                                           (SELECT     PERNR, MAX(AEDTM) AS Pi0AEDTM
                                                             FROM          PA0000 AS PA0000_1
                                                             GROUP BY PERNR) AS Pi0 ON PA0000.PERNR = Pi0.PERNR AND PA0000.AEDTM = Pi0.Pi0AEDTM
                                ORDER BY PA0000.PERNR) AS P0 ON P1.PERNR = P0.PERNR LEFT OUTER JOIN
                              (SELECT     TOP (100) PERCENT PA0021.PERNR, PA0021.ENDDA, PA0021.BEGDA, PA0021.AEDTM, PA0021.UNAME, PA0021.FAMSA, PA0021.FAVOR,
                                                       PA0021.FANAM, PA0021.FGBDT, PA0021.FASEX
                                FROM          PA0021 INNER JOIN
                                                           (SELECT     PERNR, MAX(AEDTM) AS Pi21AEDTM
                                                             FROM          PA0021 AS PA0021_1
                                                             GROUP BY PERNR) AS Pi21 ON PA0021.PERNR = Pi21.PERNR AND PA0021.AEDTM = Pi21.Pi21AEDTM
                                ORDER BY PA0021.PERNR) AS P21 ON P1.PERNR = P21.PERNR LEFT OUTER JOIN
                              (SELECT     TOP (100) PERCENT PA0002.PERNR, PA0002.ENDDA, PA0002.BEGDA, PA0002.AEDTM, PA0002.UNAME, PA0002.GESCH,
                                                       PA0002.FAMST
                                FROM          PA0002 INNER JOIN
                                                           (SELECT     PERNR, MAX(ENDDA) AS Pi2ENDDA
                                                             FROM          PA0002 AS PA0002_1
                                                             GROUP BY PERNR) AS Pi2 ON PA0002.PERNR = Pi2.PERNR AND PA0002.ENDDA = Pi2.Pi2ENDDA
                                ORDER BY PA0002.PERNR) AS P2 ON P1.PERNR = P2.PERNR
    xxxxx----
    Edited by: Goutam Roy on May 5, 2009 1:11 PM

  • Issue in ABAP query

    Hi
      I have a doubt regarding ABAP queries . I need to pass the output of an ABAP query to another program . For this i want to know if the output of an ABAP query is stored in some kind of internal table or some other logic is used in that .
    Is it possible to send the ABAP query output to a memory structure.
    Helpful answers will be suitably rewarded.
    Thanks.

    Hi,
    program 1:
    from select query get the output to internal table
    so that with export and import u can attain this
    EXPORT t_sflight1 TO MEMORY ID 'SFLI'.
    SUBMIT pgm2 AND RETURN.
    program2:
    IMPORT t_sflight1 FROM MEMORY ID 'SFLI'.
    LOOP AT t_sflight1 INTO fs_string1.
    where in use the same internal table in both reports
    Reward Points If helpful.
    Regards,
    priya.

  • Hide/Delete lines from ABAP Query output when Quantity is 0

    Hi all,
    I'm changing an existing abap query. My requirement is to delete the rows from the report output where qantity = 0.
    I tried the following ways.
    1. In SQ01, select the quantity field and check the checkbox for "Display only field <> 0", but this didnt worked as it will 
         supress the zero from display.
    2. I tried to write code in the Infoset SQ02->Edit->Code. I wrote the following code "CHECK vbep-wmeng IS NOT INITIAL".
        Here  the problem is, the code is not executing in the test client. When I open the Infoset in test(i mean development test) 
        client the code is there, but when i execute the program its not working. I tried using "BREAK-POINT", program executions
        does not stop at the break point. There is existing code in the event "START-OF-SELECTION", this code I'm able to see in the
        query program opened through SE38. I edited the existing code and kept a break point in between, and now checked in the
        program in SE38, but the changes are not reflected. I'm able to see old code only(even after save n generate).
    3. Gave search in SCN, google etc.
    Please note.
    1. I'm not using any Logical Database in the Infoset. Its a simple join of 4 tables.
    2. Query is created in the Global Area (cross client) not client specific.
    Can anybody tell me what could be the problem and how can Over the above issues and achive the requirement.
    Thanks in advance.
    Edited by: Mr A on Feb 25, 2010 1:39 AM

    Dear Mr A,
    Can i know how did u solve the issue even i'm facing the same problem.
    Regards,
    Karan Bhasin

  • ABAP Query error

    Hello! can anyone help pls?
    I am in the process of constructing an ABAP query and I'm getting an error message which is quite puzzling.  Here's the details:
    I'm creating the query using an infoset constructed from logical database VAV.  When I try to add field VBUP-GBSTA to my basic list design, I get the following error:
    "You placed fields from different parallel branches of the hierarchical data source in the same line. . This makes no sense. The list will not be displayed as you desire. . List is only displayed in simple format for correction purposes. .  Please check the sequence. Button  allows you to color list fields according to the hierarchy. "
    I don't know why this is the case, and I really need to report on that field. Any ideas would be most appreciated!
    Thanks in advance!

    Hello Elizabeth,
    I hope you have selected VBUP also in the hierarchy in the infoset. If this is selected and the field which you are looking for (GBSTA) is assigned to a field group, then u should be able to select this in the basic list.
    Hope this helps
    Abhijit

  • What is the use of abap query?

    hi sap gurus,
    good morning to all,
    what is the actual relecance of abap query ?
    i know that we can generate simple reports
    but
    what kind of reports ?
    give some examples plz.
    regards,
    balaji.t
    09990019711

    Hi Balaji,
    Here is the details of ABAP Query
    ABAP Query
    An ABAP Workbench tool that enables users without knowledge of the ABAP programming language to define and execute their own reports.
    In ABAP Query, you enter texts and select fields and options to determine the structure of the reports. Fields are selected from functional areas and can be assigned a sequence by numbering.
    ABAP Query offers the following types of reports:
    Basic lists
    Statistics
    Ranked lists
    I hope it will clear for you,
    Regards,
    Murali.

  • Transport of Abap Query

    Hi,
    Can anybody tel me how to transport Abap Query.

    Hi,
    ABAP/4 Query is a powerful tool to generate simple reports without any coding. ABAP/4 Query can generate the following 3 simple reports: Basic List: It is the simple reports. Statistics: Reports with statistical functions like Average, Percentages. Ranked Lists: For analytical reports. - For creating a ABAP/4 Query, programmer has to create user group and a functional group. Functional group can be created using with or without logical database table. Finally, assign user group to functional group. Finally, create a query on the functional group generated.
    You can transport queries between systems in SQ02 (hit the lorry button) or run program RSAQR3TR. 
    You download the infosets, queries etc into a file and load them into whichever system you wish.
    regards,
    vineela.

  • Abap query table link

    Experts Im doing an abap query then I just link the tables adr2 , adr3 , adr6 and lfa1 and lfb1 in infosets "join button"..then show the fields that I need in sq01.But I was wondering why my data becomes times 4..it repeatedly display my data in FOUR times..
    What do you think is the cause of that?

    dear,
    it depends on which table you selected first (Table join using basis table) and how do you insert next tables.
    i am talking about the info-set creation step.
    let's do a simple query.
    run SQ02. type new infoset name and hit Create.
    type name and type MARA for "Table join using basis table" radio button. Hit Continue.
    now insert (add) tables: MARC, MCHA, CABN, CAWN
    think about Inner Join or Left Outer Join !!'
    say, if you need to display all materials (even if not exist on plant) set Left Outer Join. if you're after materials existing on plant keep default Inner Join.
    friend, my example above is only the example.
    make sure you undertsand how to build a sap query in general.
    never set many tables at once. insert 2-3 tables, return to your query (SQ01) or create it, adjust it and test. step by step - table by table. add the new table in infoset, add the fields, generate it and come back to your query. adjust it and test.
    good luck!

  • ABAP Query transport request

    Hi All,
    We created an ABAP Query report for Transfer order address and it is system generated report. When I am trying to find the version management but is it showing no version found. Even I have created TR manunally and imported to quality system, But this program is not moved.
    I have a doubt here this is system generated program that we cant import to other system or can we import?
    Can you please let us know how can we transport ABAP query report?
    Regards,
    Jyothi CH.

    Hi Jyothi,
    Copy this report in another prog, save with package. that time it will be asking request. make request for this copy prog
    so this way you can able to find transport request.
    Regards,
    Kunjan

  • ABAP query vs ABAP report

    Hi Experts,
       I have a question regarding ABAP query  and report.
      what is the difference between ABAP query and ABAP report  ?
      will the query be more efficient than abap report ?
      Is there a standard SAP report that could replace a query?
    Thanks in advance,
    Manoj

    Hi,
    A report is a piece of logic that you write in (this case) in a programming language (ABAP). It uses the syntax of the normal commands of the PL.
    ABAP Query is a higher level tool, that reduces or eliminates the need to "program" in the PL, and rather uses more intuitive, graphic tools, to basically get the same results.
    Generally speaking, if the reporting needs are simple and standard, it is easy and feasible to use the query. The more complex the logic gets, the more you'll probably need to use programming.
    Regards,
    Mario

  • Creating t.code for ABAP query and Transport  it TO Production and run it .

    Hi Friends
    Thanks for ur reply ,
    The requirement is that i want to create tcode for abap query and that query can be regenearted ,
    in case of regeneration programe name i got answer programame name will be change, i created and modified query but i saw the same programe name ,,, may be it changed when it is trasnported if so then what ??
    and also pls give me solution for asiging tcode for query which is going to be regenerated.
    thanks and regards
    farukh

    Dear Farukh,
    As we know,
    Query is created in Production server and a corresponding program is generated by System.
    What we have to do is just to assign the program to the desired transaction code in Development server and transport it.
    If you have any doubts please let me know.
    Kindly assign points if you find this info usefull.
    Regards,
    Lijo Joseph

  • ABAP QUERY STEPS

    Hi Friends,
    can i send me Creation of ABAP QUERY...
    REGARDS,

    What Is SAP Queries
    Many times a need arises for SAP Users and Functional Consultants to generate quick reports without getting any ABAP coding done – time taken to complete the coding in development, transport and test it in QA system and then transport to production – is sometimes too long. In such cases, ABAP/4 query is a tool provided by SAP for generating these kind of reports.
    Type of Report Desired:
    Before starting to write an ABAP query, its advisable to decide the type of report that the user wants. ABAP query provides the following type of reports:
    Basic List Simple report
    Statistics Report containing statistical functions like Average &Percentage
    Ranked List Report written for analytical purpose
    The output is always seen in the order of Basic List, then Statistics and then Ranked List if any. One ABAP query can have one basic list, maximum of 9 statistics and maximum of 9 ranked lists.
    In a nutshell, an ABAP/4 query can be designed in four steps
    - Creation of a user group
    - Creation of functional area
    - Assignment of user group to functional area
    - Creation of the query based on functional area
    The various objects that form an ABAP query can be created in the following 2 ways:
    - Tools => ABAP/4 Workbench => Utilities => ABAP/4 Query
    OR
    - By executing the transaction codes mentioned below:
    SQ01 ABAP/4 Query
    SQ02 Functional Area
    SQ03 User group
    Step I - Create Functional Area
    In the functional area section, the user indicates from which part of the SAP database the data is going to be retrieved and how the data is to be retrieved by the query. One functional area can be assigned to many user groups. A functional area can be created with or without a logical database. To create a functional area with a logical database, one has to mention the name of the database and then select the fields from the tables that form the logical database.
    ABAP Query Authorizations: To use an ABAP query, the user must have appropriate authorizations. Two ways of providing authorizations to the users are as follows:
    - User groups
    The user should be a part of at least one user group to run the corresponding ABAP query. This automatically restricts the access of the user to specific functional areas, and thus the corresponding underlying logical databases.
    - Authorizations
    The authorization object S_QUERY should be used to give proper authorizations to the user for a query. This authorization object has a field named ACTVT which can take values 02 for Change, 23 for Maintain and 67 for Translate.
    This value determines whether the user can create and modify the query. The possible authorizations in the object are as follows:
    S_QUERY_ALL Change, maintain and translate query
    S_QUERY_UPD Change and Translate
    Though the general concept of an ABAP query is moderately difficult, the results and the long term use of the ABAP query is worth the effort.
    Creating the ABAP Query
    To create the query use the menu path Environment => Queries
    · Give a name to the query and click on the Create button
    · Give the description of the query in the next screen. Specify the output length and select the processing option from the Further Processing Options box. The data can be displayed in various formats such as table, download to a file, and display in Word etc.
    · Click on the Next screen icon. Select the functional group screen. All the functional groups created in the functional area are displayed. Select the groups that you desire – fields from only these groups will be displayed in the output. Click on the respective check boxes and click on the Next Screen icon.
    · The Select Field screen gets displayed. Select all the fields from the user group that you need to display on the output of the query. If required, specify the short names for the fields using the menu path Edit => Short Names => Switch On/Off or you can also change the selection text contains in the order you want to appear on the selection screen. You can also maintain column headers for the fields by using the menu path Edit => Column Header => Maintain. 
    ·         Click on the Next Screen icon to get the Selections Screen. Here you can check against the fields that you require to be shown on the selection screen.
    ·         Now we need to specify the output type for the query as Basic List, Statistics or Ranked List. Choose the option Basic List.
    ·         On the Basic List line structure screen the following things can be done
    o        Specify the report layout in detail – lines on which the fields will appear.
    o        Order in which the fields will appear in the output
    o        Sort order for the fields – this is optional.
    o        For the numeric fields you can check against the fields for which you require totals in the output.
    o        Beautify the output according to the options provided.
    ·         Click on the next screen icon, to specify the control levels as mentioned below
    o        Specify the sort order. The default sort order is ascending and can be changed to descending if required.
    o        Totals for each field selected for sorting can be displayed
    o        To display the output of a field in a box click on the check box against box. To display a line after the output of a field, click on the check box against BlnkLn
    o        To display the output of a field on a new page click on the check box against New Page
    ·         Click on the next screen icon to get the List Line options Screen. Here you can specify the background color for displaying the output.
    ·         Click on the next screen icon to get the Field Output Option screen. In this you can specify the following:
    o        Change the output length or the display positions of the fields
    o        Specify the display position of the unit for quantity or currency fields. Click left radio button to display it before the figure, middle radio button to display it after the figure while last radio button to hide the unit altogether.
    o        Specify color for the column of every field under the Format option.
    o        Specify the label against the output of sort fields.
    ·         Click on the Next screen option to go to the Basic List Header screen. Here you can specify
    o        Give page header and page footer for the output
    o        Include user name and date by specifying &N and &D respectively.
    After providing all the above options you can save the query and execute it by clicking the Execute button twice
    Regards,
    Maha

  • ABAP Query - ALV Grid Calculation

    Can anybody tell me whether in ABAP Query when you execute the Query in SQ01 its shows the report in ALV Grid format. In ALV Grid format there are some standard calculation are available like
    TOtal
    Mean value
    Minmum
    Maximum
    Count
    The above calculation can be done for each column.
    My Query is it possible to put our own simple calculation
    through some coding for overall summation fields instead of this std. calculation.
    Example : Unrestricted moved Qty Summation divided by INspection lot qty summation * 100
    The output of this calculation is called First pass yield.
    This calculation i done for each line item by creating a Additional field with ABAP coding.The overall meanvalue calcualtion of this addtional fields column is not suits the customer expectation.They want the calculation to be done by the system like what i had explained in the example.

    Hi,
    Here is a code for a single grid.
    In the screen layout,make a custom container (Icon with C ) and name it in Capital letters as CONTAINER.The code below in bold letters is what exactly you want.I ve given a small example on how to use ALV:
    REPORT SAMPLE.
    DATA: alv type ref to cl_gui_alv_GRID,
    cont type ref to cl_gui_custom_container,
    itab_spfli type table of spfli.
    START-OF-SELECTION.
    select * from spfli into table itab_spfli.
    call screen 100.
    END-OF-SELECTION.
    *& Module STATUS_0100 OUTPUT
    text
    MODULE STATUS_0100 OUTPUT.
    seT PF-STATUS 'GUI'.
    SET TITLEBAR 'xxx'.
    if cont is initial.
    CREATE OBJECT cont
    EXPORTING
    CONTAINER_NAME = 'CONTAINER'.
    CREATE OBJECT ALV
    EXPORTING
    I_PARENT = CONT.
    CALL METHOD ALV->SET_TABLE_FOR_FIRST_DISPLAY
    EXPORTING
    I_STRUCTURE_NAME = 'SPFLI'
    CHANGING
    IT_OUTTAB = itab_spfli
    Now for your requirement,you can create two custom containers in the screen layout and two different alv grid instances.ie:
    DATA: alv1 type ref to cl_gui_alv_GRID,
    cont1 type ref to cl_gui_custom_container
    alv2 type ref to cl_gui_alv_GRID,
    cont2 type ref to cl_gui_custom_container.
    To select data from first grid,you can use events on double_click and fetch information and then display it in the second grid.
    <b>SOME MATERIAL REGARDING ALV:</b>
    www.abap4.it/download/ALV.pdf <b>(very useful)</b>
    http://www.sapdevelopment.co.uk/reporting/alvhome.htm
    <b>-->download the PDF from following link.</b>
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVALV/BCSRVALV.pdf
    http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_color.htm
    <b>SAMPLE PROGRAMS IN ALV:</b>http://www.geocities.com/victorav15/sapr3/abap_ood.html#d_grid
    <b>DEMO PROGRAMS IN ALV:</b>BCALV*
    Regards,
    Beejal
    **Reward if this helps

  • ABAP Query and Translation

    Hi Experts,
    I have a Tcode and it looks like it is generated through ABAP Query. I know the Report name also, so how i can find the Query and Infoset Name. Please suggest me some ideas.
    I have another doubt when i am Trying to Translate the text elements, After giving the target language it shows 'Empty object list'. What it exactly means.
    Thanks,
    Mohanraj.N

    If it a ABAP query then u will get a name like:
    AQZZZ_SLO=======Z_SLO_AUDIT_IM
    Here Z_SLO is ur user group and Z_SLO_AUDIT_IM is ur query name.
    If u display the query from SQ01 then in the initial screen u will get an ALV report where it will show the infoset name of that query.
    Regards,
    Joy.

Maybe you are looking for

  • Proper screen resolution for optimum work with SD

    A couple of questions. I've just set up a 27" IMAC with FC. What's surprised me is the poor quality of the SD image I'm getting in the Viewer and Canvas. Two years ago I edited another SD project on a system using two 24" Apple monitors, and at that

  • Lion 10.7.4 and wi fi connection loss

    I have seen others are suffering the same problem that I am since upgrade to Lion 10.7.4 that my internet connection via wifi will keep dropping every 5-10 mins. The only way to get it back is to keep switching teh router on and off which is driving

  • Can't create a default document in iis for an mvc application

    I know!  This post doesn't belong here, but resetting a password in asp.net or iis.net requires a much more brilliant person than myself.  Long story there, just trust me... I'm hoping some kind (and smart) soul will have had experience with this, an

  • Exchange issue

    My FIM deployment is having problem with exchanging emails and I get this the following error logged in the event logs. Microsoft.ResourceManagement.Service: System.ArgumentException: Invalid or NULL email address    at Microsoft.ResourceManagement.M

  • 2010 11.6" MBA, connects to wifi, full signal strength, barely works

    I'm staying in a hotel with unencrypted wifi. I know the wifi works fine because my iPhone connects to it and it's great--very snappy, great download speeds, etc. My MacBook Air finds the wifi router instantly, connects to it without any problems, sh