0
Former Member
Jan 24, 2008 at 12:41 PM

# How to Optimize

17 Views

Friends,

How to optimize the following Code?

FORM ORDERINVOICE.

SELECT SINGLE * FROM KNC1 WHERE BUKRS EQ COMPANY AND KUNNR EQ

XKNB1-KUNNR AND GJAHR EQ SY-DATUM+0(4).

IF SY-SUBRC = 0.

DEBITS = KNC1-UM01S + KNC1-UM02S + KNC1-UM03S + KNC1-UM04S + KNC1-UM05S

+ KNC1-UM06S + KNC1-UM07S + KNC1-UM08S + KNC1-UM09S + KNC1-UM10S +

KNC1-UM11S + KNC1-UM12S + KNC1-UM13S + KNC1-UM14S + KNC1-UM15S +

KNC1-UM16S.

CREDITS = KNC1-UM01H + KNC1-UM02H + KNC1-UM03H + KNC1-UM04H + KNC1-UM05H

+ KNC1-UM06H + KNC1-UM07H + KNC1-UM08H + KNC1-UM09H + KNC1-UM10H +

KNC1-UM11H + KNC1-UM12H + KNC1-UM13H + KNC1-UM14H + KNC1-UM15H +

KNC1-UM16H.

ZNORMAL = DEBITS - CREDITS + KNC1-UMSAV.

ELSE.

ZNORMAL = 0.

ENDIF.

SELECT SINGLE * FROM KNC3 WHERE KUNNR EQ XKNB1-KUNNR AND

BUKRS = COMPANY AND SHBKZ = 'W' AND GJAHR = SY-DATUM+0(4).

IF SY-SUBRC = 0.

ZPDC = KNC3-SALDV + KNC3-SOLLL - KNC3-HABNL.

ELSE.

ZPDC = 0.

ENDIF.

ZVARA = LIMIT - ( ZNORMAL + ZPDC ).

ENDFORM. " ORDERINVOICE

Thanks & Regds.

Vijay