‎2005 Apr 01 8:20 AM
Hi,
I have worked quite a lot on Oracle Database Programming. I am tring to do some programming in ABAP , but its failing to do so. What is the normal way of calculating the fields in the ABAP.
Take for Eg below table structure.
Table Name: YSALESTAB. (Sales Table)
Field: ORDERNO (Order Number)
PRODNO (Product Number)
UNITPR (Unit Price)
QTYORD (Qty Ordered)
Question A): I am executing the following select.
SELECT ORDERNO UNITPR QTYORD, <b>UNITPR*QTYORD</b> from YSALESTAB.
WRITE .......
ENDSELECT.
But it is not allowing me to select calculated field. Is there any way in the select statement to use calculated field or I will have to go with other workaround like defining local variable and doing calculation on that variable?
Question B): Is there any way to write out calculated fields in write statement.
eg data : int1 type i value 3, int2 type i value 4.
write 😕 'Values are ', int1 * int2.
Regards
Mitesh
‎2005 Apr 01 8:35 AM
Hi Mitesh,
Unfotunately there is no possibility to use calcualted fields in an ABAP Open SQL query. Also ABAP has a rudimentary syntax concerning expressions: you cannot use calculated expressions almost anywhere except the right side of an assignment statement. In your question 2 you have to use some intermediate variable.
‎2005 Apr 01 8:35 AM
Hi Mitesh,
Unfotunately there is no possibility to use calcualted fields in an ABAP Open SQL query. Also ABAP has a rudimentary syntax concerning expressions: you cannot use calculated expressions almost anywhere except the right side of an assignment statement. In your question 2 you have to use some intermediate variable.
‎2005 Apr 04 9:00 AM
‎2005 Apr 04 11:09 AM
Hi ,
try this
types : begin of ty_mara,
matnr type mara-matnr,
quan type n,
end of ty_mara.
DATA: BEGIN OF WA,
matnr type mara-matnr,
quan type n,
END OF WA.
data v_matnr type mara-matnr.
v_matnr = '000000000000000033'.
EXEC SQL.
select matnr, ntgew*3 into :wa from
mara where matnr = :v_matnr
ENDEXEC.
write 😕 wa-matnr, wa-quan.
Hope this help.