‎2008 Aug 07 2:06 PM
hi experts,
Please tell me how to write ABAP coding which will hit database ..for ex..
REPORT ZRUNTIME.
TABLES : BSEG.
DATA : BEGIN OF FINAL OCCURS 0,
BELNR LIKE BSEG-BELNR,
WRBTR LIKE BSEG-WRBTR,
AUGDT LIKE BSEG-AUGDT,
END OF FINAL.
SELECT-OPTIONS: DATE1 FOR BSEG-AUGDT.
SELECT BELNR WRBTR AUGDT FROM BSEG INTO CORRESPONDING FIELDS OF TABLE FINAL WHERE AUGDT IN DATE1.
LOOP AT FINAL.
WRITE:/ FINAL-BELNR,FINAL-WRBTR,FINAL-AUGDT.
ENDLOOP.
this is a simple progarm which affects database 100% in runtime analysis.how shall i re write the code in another way ..???
regards,
mani
‎2008 Aug 07 2:08 PM
REPORT ZRUNTIME.
TABLES : BSEG.
types : BEGIN OF ty_FINAL ,
BELNR LIKE BSEG-BELNR,
WRBTR LIKE BSEG-WRBTR,
AUGDT LIKE BSEG-AUGDT,
END OF ty_FINAL.
data: itab type standard table of itab with header line.
SELECT-OPTIONS: DATE1 FOR BSEG-AUGDT.
SELECT BELNR WRBTR AUGDT
FROM BSEG
INTO TABLE itab
WHERE AUGDT IN DATE1.
LOOP AT itab.
WRITE:/ FINAL-BELNR,FINAL-WRBTR,FINAL-AUGDT.
ENDLOOP.
‎2008 Aug 07 2:12 PM
‎2008 Aug 07 2:18 PM
hi.
try to code like this:
TYPES : BEGIN OF S_FINAL ,
BELNR LIKE BSEG-BELNR,
WRBTR LIKE BSEG-WRBTR,
AUGDT LIKE BSEG-AUGDT,
END OF S_FINAL.
data: final type standard table of s_final,
wa_final type s_final.
data: l_date type 'data element of field Augdt'.
SELECT-OPTIONS: DATE1 FOR l_date.
try to avoid corresponding keyword by writing fields in internal table in the same order that the fields in dtabase table
SELECT BELNR WRBTR AUGDT FROM BSEG INTO CORRESPONDING FIELDS OF TABLE FINAL WHERE AUGDT IN l_date.
LOOP AT FINAL into wa_final.
WRITE:/ wa_FINAL-BELNR,wa_FINAL-WRBTR,wa_FINAL-AUGDT.
ENDLOOP.
hope this will help u.
‎2008 Aug 07 2:48 PM
If you don't want to affect the database, then don't select any data! It doesn't matter what you do, if you write a program where most of the processing is involved in getting the data, it will spend most of its time getting the data.
If you really want to get that 100% down, I suggest you add this at the end.
DATA: l_x TYPE f,
l_y TYPE f,
l_z TYPE f.
l_x = '-0.5'.
l_y = '0.5'.
DO 10000000 TIMES.
l_z = l_x.
l_x = ( l_x * l_x ) - ( l_y * l_y ).
l_y = 2 * l_z * l_y + l_z + l_y.
ENDDO.The program will take a lot longer, but you'll get the percentage of time in the database down.
matt
‎2008 Aug 07 3:11 PM
Hi Matthew,
this looks a little bit like a mandelbrot computation. Do you have a graphical output as well?
‎2008 Aug 07 3:23 PM
That would probably add to the ABAP percentage, so we'd have to introduce another huge SELECT to maintain the 50/50 balance.
In the end we should have a nice and fully emancipated little program.
Thomas
‎2008 Aug 07 4:11 PM
DATA : BEGIN OF FINAL OCCURS 0,
BELNR LIKE BSEG-BELNR,
WRBTR LIKE BSEG-WRBTR,
AUGDT LIKE BSEG-AUGDT,
END OF FINAL.
field-symbols : <fs_final> like line of final.
data: final_1 like table of final with header line.
select BELNR
WRBTR
AUGDT
into final from <tablename>
where AUGDT IN DATE1.
loop at final assigning <fs_final>.
final_1-belnr = <fs_final>-belnr.
final_1-wrbtr = <fs_final>-wrbtr.
final_1-augdt = <fs_final>-augdt.
append <fs_final> to final_1.
endloop.
hope this helps