Skip to Content
0
Former Member
Nov 20, 2008 at 11:21 PM

Help with Read statement

28 Views

Hi All,

I have the following code and I am not getting data properly with the Read statement.

This report has thousands of lines of output data. If I have the read stmt with binary search it is not able to find some records from IKONv and I am getting KBETR and KWERT values as 0.00 in the output.

READ TABLE ikonv WITH KEY knumv = iORD-knumv

KPOSN = IORD-POSNR. " binary search.

If I give the Read stmt with out binary search it is finding all the data properly but taking long time(approx 7min) for execution.

Can someone please guide me to resolve this problem.

Thanks,

Veni.

FORM get_data.

SELECT AVBELN AERDAT AAUART AKNUMV ABSTNK AKUNNR

BPOSNR BMATNR BARKTX BNETWR B~NETPR

CVBELN CERDAT C~RFMNG

INTO TABLE IORD

FROM VBAK AS A

INNER JOIN VBAP AS B

ON AVBELN = BVBELN

INNER JOIN VBFA AS C

ON Bvbeln = Cvbelv

AND BPOSNR = CPOSNV

WHERE A~ERDAT IN S_ERDAT

AND A~AUART IN S_AUART

AND A~KUNNR IN S_KUNNR

AND C~VBTYP_N NE 'J'

AND C~VBTYP_N NE 'R'.

IF sy-subrc = 0.

SELECT knumv kposn KBETR kschl kwert

FROM konv

INTO TABLE ikonv

FOR ALL ENTRIES IN iORD

WHERE knumv = iORD-knumv

AND kschl = 'PR00'.

ENDIF.

ENDFORM. " get_data

&----


*& Form process_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM process_data.

DATA: lv_name1 LIKE kna1-name1.

loop at iORD.

  • if sy-subrc = 0.

MOVE IORD-vbeln TO iout-vbeln.

MOVE IORD-ERDAT TO iout-ERDAT.

MOVE IORD-AUART TO iout-AUART.

MOVE IORD-NETWR TO iout-NETWR.

MOVE IORD-BSTNK TO iout-BSTNK.

MOVE IORD-KUNNR TO iout-KUNNR.

MOVE IORD-POSNR TO iout-POSNR.

MOVE IORD-MATNR TO iout-MATNR.

MOVE IORD-ARKTX TO IOUT-ARKTX.

  • MOVE IORD-ZMENG TO IOUT-ZMENG.

MOVE IORD-NETPR TO iout-NETPR.

MOVE IORD-INVNO TO iout-INVNO.

MOVE IORD-INVDT TO IOUT-INVDT.

MOVE IORD-RFMNG TO iout-RFMNG.

SELECT SINGLE name1

FROM kna1 INTO lv_name1 WHERE kunnr = iORD-kunnr.

IF sy-subrc = 0.

MOVE lv_name1 TO iout-name1.

ENDIF.

READ TABLE ikonv WITH KEY knumv = iORD-knumv

KPOSN = IORD-POSNR. " binary search.

IF sy-subrc = 0.

MOVE IKONV-KBETR TO IOUT-KBETR.

Move IKONV-KWERT to iout-kwert.

ENDIF.

  • endif.

APPEND IOUT.

CLEAR iout.

ENDLOOP.

CLEAR iORD.

clear ikonv.

CLEAR lv_name1.

ENDFORM. " process_data