Skip to Content
0
Former Member
Nov 02, 2005 at 09:48 AM

Inventory

48 Views

Hi All,

I wanted to enhance my DS with 5 fields( key figures) , shall I write routines at Update rules instead of CMOD. (In Inventory)

1 Previous Code: which I want to drop:

*Get the dmbtr and menge values from mseg

SELECT SINGLE DMBTR MENGE

INTO (LT_DMBTR , LT_MENGE)

FROM MSEG

WHERE MBLNR = L_T_2LIS_BF-MBLNR

AND MJAHR = L_T_2LIS_BF-MJAHR

AND ZEILE = L_T_2LIS_BF-ZEILE.

  • Modify the dmbtr value if it is zero in work area and not in mseg

IF ( SY-SUBRC = C_ZERO ).

IF ( L_T_2LIS_BF-DMBTR = C_ZERO ) AND ( LT_DMBTR NE C_ZERO ).

L_T_2LIS_BF-DMBTR = LT_DMBTR.

ENDIF.

IF ( L_T_2LIS_BF-MENGE = C_ZERO ) AND ( LT_MENGE NE C_ZERO ).

L_T_2LIS_BF-MENGE = LT_MENGE.

ENDIF.

ENDIF.

*Get the Amount in Local Currency into zzdmbtr

L_T_2LIS_BF-ZZDMBTR = L_T_2LIS_BF-DMBTR.

L_T_2LIS_BF-ZZMENGED = L_T_2LIS_BF-MENGE.

*Get the Debit/Credit Value

SELECT SINGLE SHKZG

INTO LT_LCL_SHKZG

FROM MSEG

WHERE MBLNR = L_T_2LIS_BF-MBLNR

AND MJAHR = L_T_2LIS_BF-MJAHR

AND ZEILE = L_T_2LIS_BF-ZEILE.

*Comment start to correct zzdmbtr and zmenge values

IF ( SY-SUBRC = C_ZERO AND LT_LCL_SHKZG = C_H )

OR ( L_T_2LIS_BF-SHKZG = C_H ).

L_T_2LIS_BF-ZZDMBTR = C_ZERO - L_T_2LIS_BF-ZZDMBTR.

L_T_2LIS_BF-ZZMENGED = C_ZERO - L_T_2LIS_BF-ZZMENGED.

IF ( LT_LCL_SHKZG = C_H ) AND ( L_T_2LIS_BF-SHKZG NE C_H ) .

L_T_2LIS_BF-ZZDMBTR = C_ZERO - L_T_2LIS_BF-ZZDMBTR.

L_T_2LIS_BF-ZZMENGED = C_ZERO .

ENDIF.

IF ( LT_LCL_SHKZG NE C_H ) AND ( L_T_2LIS_BF-SHKZG = C_H ) .

L_T_2LIS_BF-ZZMENGED = C_ZERO .

ENDIF.

ENDIF.

*Comment Ends

*Comment start for selecting SGTXT value from MSEG

SELECT SINGLE SGTXT INTO L_T_2LIS_BF-ZZSGTXT FROM MSEG

WHERE MBLNR = L_T_2LIS_BF-MBLNR

AND MJAHR = L_T_2LIS_BF-MJAHR

AND ZEILE = L_T_2LIS_BF-ZEILE.

*Comment Ends

2 New code in Update Rules which i want to write to get amount and qty:

Please see the code and correct if I am wrong:

Use this update rule as a template to calculate the key figure value. You must adjust the source field from the InfoSource correspondingly (XXXXXXX).

IF ( COMM_STRUCTURE-processkey EQ '100' Other Issues

OR COMM_STRUCTURE-processkey EQ '101' "Returns / Vendor

OR COMM_STRUCTURE-processkey EQ '104' "Material transfer

OR COMM_STRUCTURE-processkey EQ '105' "Stock Adjustment InvD

OR COMM_STRUCTURE-processkey EQ '106' "Stock Adjustment Other

OR COMM_STRUCTURE-processkey EQ '110' ) "Issues from Stock

"Transfers

AND COMM_STRUCTURE-bwapplnm EQ 'MM'

  • only movements which are relevant for stock control

AND COMM_STRUCTURE-XXXXXXX <> 0.

  • result value of the routine

RESULT = -1 * COMM_STRUCTURE-XXXXXXX.

  • if the returncode is zero, the result will be updated

RETURNCODE = 0.

ELSEIF ( COMM_STRUCTURE-processkey EQ '000' "Other Receipts

OR COMM_STRUCTURE-processkey EQ '001' "Goods Receipt / Vendor

OR COMM_STRUCTURE-processkey EQ '004' "Material Transfer /

"Receipt

OR COMM_STRUCTURE-processkey EQ '005' "Stock Adjustment InvD

OR COMM_STRUCTURE-processkey EQ '006' "Stock Adjustment Other

OR COMM_STRUCTURE-processkey EQ '010' ) "Receipt from Stock

"Transfer

  • only movements which are relevant for stock control

AND COMM_STRUCTURE-XXXXXXX <> 0.

  • result value of the routine

RESULT = COMM_STRUCTURE-XXXXXXX.

  • if the returncode is zero, the result will be updated

RETURNCODE = 0.

ELSE.

  • if the returncode is not equal zero, the result will not be updated

RETURNCODE = 4.

ENDIF.

  • if abort is not equal zero, the updates process will be canceled

ABORT = 0.

I wanted to comment pevious code to get Amount and Qty and I want to write a

new code in Update Rules:

Let me advise :

1. what is process key?

2. shall i stop my previous code(CMOD) and start new one(Update Rules)?

Regards,

Siri.