Mathematical calculations in ABAP Query
Dear gurus
Can I perform mathematical calculations in ABAP Query?
Kingly guide
MK
Hi
You would need tables - AFPO, AUFM, MSEG, MAKTX (if you need mtl description).
Use AFPO table to pass your FERT material number, then read the order numbers for this order.
Now in AUFM there is an Index on AUFNR field, so you can pass all the order nos. of the FERT to this field.
If you want to limit for a certain period, then use AUFM-BUDAT which is the posting date.
Now add all the 261 movements for which there is no 262 movement, you can check for reversals in MSEG table. This you can do per component & display the data as per your need.
Regards,
Vivek
Added
You can get this info in COOIS report as well, by selecting List option as Documented Goods Movement & by using suitable filter options.
Similar Messages
-
How to use mathematical calculations in abap
Hi!
In my program,
I declared one variable as w_h(2) type n.
i am doing calculation as,
w_h = 100 /60.
its giving the o/p as 2(1.66...). but in 1.6 i want that 1 alone as my o/p.normally math function floor() is there to bring the o/p as 1. in abap how to use this floor function. or any other possible is there to get the o/p as 1.could anybody plz help me.define w_h as i.
data: w_h type i.
Edited by: mayank jain on Sep 8, 2009 9:42 AM -
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 -
Creation of local field in ABAP Query
Hi
Please let me know how to create a local field in ABAP query. I am finding the option inactive in SQ01.
Regards
Priyadarshinihi priya,
*__Adding u201CLocal Fieldu201D (user defined field) in SAP Query_ :
There is also facility to add the user defined fields in SAP query output. Also we can provide calculation formula for calculating values for this user defined field.
Calculation formula consists of standard fields from standard SAP tables. So the values fetched for particular standard SAP fields from standard SAP tables get calculated as per the calculation formula defined for the user defined field and displays the value accordingly.
To do this first go to change mode for Query which automatically takes you to screen shown below and click on icon , as below :
Then further screen will appears. So select the Field group and again click on the same icon button .
Then switch on the Short names for the fields and give the short names to fields which we need to use in Calculation formula.
Give the short names and then created u201CLocal Fieldu201D, as shown in below screen shot. Also Short names are given to fields, which can be used further for calculation.
Defining Local Field u201CREM_QTYu201D along with its field type and Calculation formula.
In this case we have
defined field type for new
field as similar to
ORD_QTY and
Calculation formula is
defined.
Also its possible to have Conditional logic for Local field by putting Condition in u201CConditionu201D line.
Now activate this newly added Local field for coming it in output screen. To do the same again go to u201CBasic Listu201D and activate the Local Field as shown below :
i think this will help u
regards,
sindhu. -
Problem in Currency field in Abap Query
hi.
I have created an additional field for storing the currency type.
Based on some calculations i want to store the currency type into this additonal field.But the problem is that the currency field is not getting displayed in the report though i am getting the currency type in the additional field when i check it while debugging. Can anyone help me out...Vimal,
Is it ABAP Query problem(SQ01).If yes, then
In tcode SQ02(Infotype)>press extras button(F5)>In right side you will find 4 tabstrip buttons.Press on Extras--> create variable with same type of currency.
goto Field group button--> add this field to field groups.
In record processing event after your calculations assign your value of cuurncy to this new variable.
In tcode SQ01-->enter query name >F6>F6>F6>select your new varaible
>Press on basic list button(shift+F4)>left side you will find additional fields Node From there select your new field-->Save come back and execute the query.Now you will find your variable.
Don't forget ot reward if useful.... -
Tricky dynamic date variant in ABAP query
Hello All,
In an abap query there is a date field in the selection screen with from & to values.
I am trying to create a dynamic variant that will fill the following data into those fields:
From date: will be left blank
To date: will show today's date - 90 days
For example, if today's date is 01/12/2006 the variant should fill the following data into the fields:
From date: <blank>
To date: 01/09/2006
I have tried all the methods I know with dynamic dates calculation in the variant definition but did not manage to create such variant.
Any help will be very appreciated and points would be rewarded generously !
Thank you very much,
RonenIf the "from" date is meant to be left blank (beginning of time) and the "to" date is some date plus or minus number of days from today, you use the "current +/- days" dynamic date calculation format as was mentioned earlier. Likewise if the "from" date is some date plus or minus today's date, and the "to" date is infinity -- you only need the one Dynamic Date calculation.
To do this, first don't think about this as a date range, think of your Dynamic Date calculation as if this were a single parameter and not a select-option. You are really saying "my date is anything LT/LE this date" or "my date is anything GT/GE this date" -- not a range
In the Save Variant screen, find the desired date select-option and:
1. Choose in column "Selection Variable", a "D" (Dynamic date calculation)
2. Use F4 in the "Name of Variable" column
3. Find "Current date +/- ??? days" or "Current date +/- ??? work days" in the popup, as appropriate
4. For "I/E" (include/exclude) column select as appropriate
5. For "Option" column, choose "LE", "LT", "GE", "GT", "NE" as appropriate
6. After clicking green check mark, enter your plus or minus days (and factory calendar if using work days).
7. Finish saving your variant.
8. You may not see your changes in your variant until you back all the way out of the variant and then redisplay it. You'll see a greyed out date along with the symbol matching your choice (LT, LE, etc.)
Unfortunately if you don't have infinity on either end of the date you are limited to 999 days differences as far as I am aware. If that is the case you can populate TVARVC table with parameter or selection variables, maintain them with STVARV transaction by hand, or use an ABAP program in batch to regularly calculate the values. Then you can reference the TVARVC values in your variant instead of the Dynamic Date calculation.
If someone knows a way to bypass the use of TVARVC for date ranges that are more than 999 days apart please let me know. TVARVC works well but it is extra effort whereas Dynamic Date calculation would be much easier to maintain if the date range could be made larger than 999 days. -
Excess Inventory/Scheduled Receipts Report using ABAP Query.
Hi All,
I want to create a ABAP query for Excess inventory & Scheduled receipts in a single report. I have identified tables, fields and some extra calculated fields in the report. Here are the following tables and fields.
EKPO-MATNR ( Material number)
EKPO-WERKS ( Plant)
MAKT-MAKTX (Material Discription)
MARC-MAABC ( ABC indicator)
LFA1-NAME1 ( Supplier name)
MBEW-STPRS (Total value)
EKET-EINDT ( Item delivery date)
RIBOF-AMOUNT
S939-SPWOC or S032-SPWOC
Calculation fields : Value execess this week.extend value, over or under this week, onhand inventory for last week and this week.
Here my question is, when i was creating a infoset, how do i maintain relationship or joins from one table to another table...Is there any sequence for the above tables? Pl suggest. When i was adding all the tables in a infoset and try join the tables...it says illegal join...
Pl suggest me.
Thanks for your help
PRadeep
Edited by: Venkata Pr Papulugari on Jul 18, 2008 1:37 AMHi Gordon,
What i need to display is the remainder of the transaction that was received... if it is zero (0), i don't want to display it.
i.e.
transact # 100 inqty = 5
transact # 200 outqty =1
I'd like to display
transact # 100 qty on hand = 4
right know the transaction # that i am displaying is transact # 200.
And also, it needs to be warehouse oriented. because i can have multiple warehose transactions.... and i am getting that wrong too.
Regards,
Manuel Roman -
SAP HR : ABAP Query / Infotype enhancement / Field in Q0168 & not in P0168
Hi all,
There is a field in the structure Q0168-CSTDT, the field can be seen in the PA20/30 screen under the costs tab.
This field is not there in the P0168 structure.
The requirement is to add this to the ABAP Query.
What steps should be taken ? Do we need ABAP coding ?
Thanks
RahulHi,
Use Fm : HR_BEN_GET_KEY_DATE to get the Benefit Cost Calculation Date ..
Look at include MP016840 for the same.
Look for F1 on the field in pa20/pa30 , you'll get an idea on how this field is calculated.
Regards,
Srini. -
ABAP QUERY - Adding a new field in the output
Hello ,
I am creating a ABAP query in which i need to do a calculation and display it in the output.
How do i do it?
I have added the field PLAF-GSMNG and PLAF-AVMNG in the infoset.
The calculation that i have to do is CALCULATEFIELDS = PLAF-GSMNG - PLAF-AVMNG.
I have to display the CALCULATEFILEDS in the output. How do i add this field and where do i do the calculation for this.
Regards
AshishHi Kanagaraj,
Thanks a lot for your help.
Actually those steps dint work but i created a new infocube and copied the structure from old infocube and then just created a Transformation and DTP.It worked fine.Did not generate a export datasource.
But for my previous question
3 characteristics and 3 keyfugures.
Want to add a new field based on the department ID
Tthe values have to be populated for the new field.
It is not a constant value.So what should i choose in the conditons.
Regards,
Harish -
how we create abap query can any1 tell me?
Reporting tool :Standard reports
Purpose :Provide solutions for your most frequent reporting requirements
Advantages :Can be used immediately
No developments required
Limitations :Limited flexibility
Output fields cannot be selected as required
HIS
Purpose :Hierarchies are displayed as graphics
Reports are executed using selected structures or substructures, that is, using preselected sets of objects
Advantages :User-friendly method of displaying hierarchical structures
Integration with InfoSet Query and standard reports
No need to switch from one HR application to another if you want to execute reports from different applications
Little training required
Limitations : Limited flexibility
Tool is used to execute standard reports and customer reports
It cannot be used to create reports
InfoSet Query
Purpose :Intuitive, general SAP reporting tool used to create customer reports
Enables you to create reports for all areas of HR
When InfoSet Query is accessed from Human Resources (HR), the Query area and User group parameters already contain values and you can only perform ad hoc reporting. If InfoSet Query is accessed this way, it is called Ad Hoc Query in HR (see HR in InfoSet Query).
Advantages :User-friendly interface
Very easy to use
No programming required
If integrated with SAP Query, you can continue processing queries using SAP Query
Set operations enable you to create sets of objects as required for which data must be output
Can be included in roles using a suitable InfoSet
Limitations :InfoSets and user groups must be defined in SAP Query before you can use InfoSet Query
Multiline lists cannot be displayed
SAP Query
Purpose :General SAP reporting tool used to create customer reports
Individual definition of user groups, InfoSets, and queries
Advantages :Extremely flexible
No programming required
Queries can be provided in the SAP Easy Access menu
Includes numerous options for aggregating data, performing calculations, and displaying graphics
Enables you to display multiline lists
Enables you to define one basic list and several statistics and ranked lists for each query
Limitations :Restricted to data from the R/3 System
Each HR query can process data from just one HR logical database:
PNP: Administration, Time Management, and Payroll
PCH: Generally for all areas, but particularly suitable for reporting on data from Personnel Planning
PAP: Recruitment
Requires much more training than other options
Limitations:Data is extracted from OLTP systems, that is, real-time data is not accessed
Business Information Warehouse
Purpose :Analytical reporting tool used for information and decision-making purposes
Advantages : Extremely flexible
Facilitates complex calculations (calculation of averages, time series comparisons)
Enables you to access non-SAP data
Easy to use
Uses OLAP technology
Includes detailed Business Content (HR extractors, InfoCubes, key figures, and standard queries
i think it is adhoc query not abap query -
How to create an ABAP Query with OR logical expression in the select-where
Hi,
In trying to create an ABAP query with parameters. So it will select data where fields are equal to the parameters entered. The default logical expression is SELECT.. WHERE... AND.. However I want to have an OR logical expression instead of AND.. how can I attain this??
Please help me on this.. Points will be rewarded.
Thanks a lot.
Regards,
Question ManHi Bhupal, Shanthi, and Saipriya,
Thanks for your replies. But that didn't answer my question.
Bhupal,
You cannot just replace AND with OR in an ABAP QUERY. ABAP QUERY is a self generated SAP code. You'll just declare the tables, input parameters and output fields to be displayed and it will create a SAP standard code. If you'll try to change the code and replace the AND with OR in the SAP standard code, the system will require you to enter access key/object key for that particular query.
Shanthi,
Yes, that is exactly what need to have. I need to retireve DATA whenever one of the conditions was satisfied.
Saipriya,
Like what I have said, this is a standard SAP code so we can't do your suggestion.
I have already tried to insert a code in the ABAP query (there's a part there wherein you can have extra code) but that didn't work. Can anybody help me on this.
Thanks a lot.
Points will be rewarded.
Regards,
Question Man -
Logical database of ABAP query
Hi,
Can anybody please let me know what is the Logical database for ETXDCI, ETXDCH & ETXDCJ (Tax tables) with any sales document tables? I need to develop one ABAP query for the users.
I am a Functional person so I would like to know Can anybody please let me know how I can find out the Logical database?
Your time and help will be really appreciate.
Thanks & Regards,
Niki Shah.Try the BRF logical database.
I found it by searching in which programs the tables were used.
It show program SAPDBBRF which is the program for logical database BRF.
Kind regards,
Arthur Parisius -
hi.
i need to create an ABAP/sap query. when i created the InfoSet i used logical db-pnp.
if i want to get only the employees which entered my organization during the last month where should i add the ABAP code, under which section => extras -> code. i have there several options - data, initialization, at selection-screen output etc, what to choose??????????
thanks,
AmiHi
Welcome to SDN forum
query has got some limitatins compared to Reports which we write using SE38
these queries are user specific and client specific and can't be transportable and you can't write your own code as you wish like reports
see the doc
http://help.sap.com/saphelp_46c/helpdata/en/35/26b413afab52b9e10000009b38f974/content.htm
http://www.thespot4sap.com/Articles/SAP_ABAP_Queries_Introduction.asp
Step-by-step guide for creating ABAP query
http://www.sappoint.com/abap/ab4query.pdf
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
Anji -
Wrong sequence in selection screen generated by ABAP Query
Hi,
I am developing a query to display the data in the view.
My query has 8 selection fields totally.
As part of my requirement I have added selection parameter in the
selections tab of the infoset and maintained the sequence as 9.
Inspite of maintaining the sequence number as 9 in the infoset, It is
appearing first in the selection screen of the query.
I tried putting different numbers in the sequence number, but even it
is appearing first in the selection screen.
Can you please let me know how to display the selections declared in
the infoset as per the sequence required.
Thanks,
Madhuri.Actually what happen when you declare your own fields in ABAP query . you have to care about the sequence . As an example if youre selecting lets say state name , you have two variables
<b>1-state
2- land</b>
for state you have to select land first , if your state is first and land is 2nd it gave you the error of sequence .
Because you have to get data in land first in order to get state specific to the land .
it should be
1-Land
2-State
Just see the your fields , Im sure youre missing that .
<b>You can also see the NO ( field ) in Query ( Sq03 ) . where you can define the seqence on selection.</b>
hope thisll help you .
Pl...Award the points .
Thanks
Saquib<b></b>
Message was edited by: Saquib Khan -
Performance tuning for ABAP Query (created from t-cd SQ01)
Hello all,
We created ABAP Query report from transaction SQ01.
But the generated report has an appropriate SQL statement which causes performance problem.
To solve this issue, I guess the easiest way is;
0. Give up to use it.
1. Copy it to another object in the customer namespace.
2. Ajust SQL statement.
But I'm wondering if there're appropriate ways to adjust SQL statement of Query.
Could anybody give me any better idea?
Thank you
YukoYou can try this: Create 2 ranges, for objnr and cdtcode and fill like:
ra_objnr-sign = 'I'.
ra_objnr-option = 'CP'.
ra_objnr-low = 'OR*'.
append ra_objnr.
ra_code-sign = 'I'.
ra_code-option = 'CP'.
ra_code-low = 'CO*'.
append ra_code.
SELECT objnr udate utime
FROM jcds
INTO TABLE it_jcds
WHERE objnr IN ra_objnr
AND stat = l_tj02t
AND cdtcode IN ra_code
AND inact = space
Regards,
John.
Maybe you are looking for
-
How can I set up the printer for a custom size A7 OR 10X7 FOLDED GREETING CARD SIZE?
My new HP 7610 wide format printer does not have a "custom" paper size selection area. A 5x7 folded (open:10x7) greeting card is surely the most popular greeting card size but is NOT included in the printers size selection area- so - what to do?
-
Display PDF in Popup / How to do this?
Hi folks, I'm trying to establish a popup in one of my WD4As which I want to display a PDF which is stored on the application server. Here is what I do: 1. Collect Data from User Input / Runtime Output of WD4A 2. Send it to a XSLT Transformation and
-
I changed some settings on my ipad and now my calendar is blank on both my ipad and iphone. Can i restore my calendar on my phone?
-
0REPORT_TEMPLATE_BROADCASTING variable reset issue
I am broadcasting a formatted report (created in report designer) as a pdf. The broadcast runs fine but the result is always fixed to a specific time period. The variables are not resetting. I checked the default template 0REPORT_TEMPLATE_BROADCASTIN
-
Reminders after changing Date and Time
Hello, Recently i changed my date to 1 month later, when i do that all the reminders till that day poped up and i needed to quit all of them or i pressed the power button once and kinda ignored them. But when i came back to todays date, reminders sto