Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

optimization of the code

hi,

plz can suggest to optimize the below code

LOOP AT ibkpf.

DATA v_rate LIKE bset-hwste.

MOVE ibkpf-belnr TO lt_output-belnr.

MOVE ibkpf-awkey TO lt_output-awkey.

MOVE ibkpf-budat TO lt_output-budat.

MOVE ibkpf-blart TO lt_output-blart.

IF ibkpf-blart NE 'EP'.

SELECT SINGLE kschl

INTO (bset-kschl )

FROM bset

WHERE bukrs = ibkpf-bukrs

AND belnr = ibkpf-belnr

AND gjahr = gjahr

AND ( kschl IN zlst OR

kschl IN zcst ).

CHECK sy-subrc = 0.

COMPUTE v_rate = ( bset-hwste / bset-hwbas ) * 100.

IF sy-subrc NE 0.

CLEAR v_rate.

ENDIF.

ENDIF.

SELECT SINGLE vbeln erdat knumv kunag

INTO (vbrk-vbeln,vbrk-erdat,lt_output-knumv,

lt_output-kunag)

FROM vbrk

WHERE vbeln = ibkpf-awkey

AND kunag IN s_kunnr

AND rfbsk = 'C'.

CHECK sy-subrc = 0.

IF sy-subrc <> 0.

CLEAR: lt_output-knumv,lt_output-kunag.

ELSE.

SELECT * FROM vbrp WHERE vbeln = vbrk-vbeln

AND werks = p_werks

AND erdat = vbrk-erdat

AND gsber = p_gsber

AND mvgr3 IN s_mvgr3.

IF sy-subrc EQ 0.

MOVE-CORRESPONDING vbrp TO lt_output.

CONCATENATE lt_output-matnr lt_output-arktx INTO lt_output-fmatnr

SEPARATED BY ' - '.

APPEND lt_output.

MOVE lt_output-knumv TO ttab-knumv.

MOVE vbrk-vbeln TO ttab-vbeln .

MOVE vbrp-mvgr3 TO ttab-mvgr3.

COLLECT ttab.

CLEAR ttab.

ENDIF.

ENDSELECT.

CLEAR lt_output.

ENDIF.

ENDLOOP.

Former Member
Not what you were looking for? View more on this topic or Ask a question