Skip to Content
0
Former Member
Aug 02, 2008 at 10:26 AM

werks annd matnr

696 Views

Hi all,

I am creating report to count valuation stock on plants. I wont to display how many together materials are in plant

bp01 and bp02 ( quantity of e.g.. matnr 13325s...).

here is report but not working correct, please guide me.

TABLES : mard.

DATA : lt_mard TYPE TABLE OF mard,

ls_mard TYPE mard,

ls_mard2 TYPE mard,

ls_mard3 TYPE mard,

lt_mard2 TYPE TABLE OF mard,

lt_mard3 TYPE TABLE OF mard.

DATA: m TYPE i,

n TYPE i,

k TYPE i.

SELECT-OPTIONS: p_mat FOR mard-matnr.

START-OF-SELECTION.

SELECT * FROM mard APPENDING TABLE lt_mard

WHERE matnr IN p_mat

AND werks = 'BP01'.

SELECT * FROM mard APPENDING TABLE lt_mard2

WHERE matnr IN p_mat

AND werks = 'BP02'.

m = 0.

WRITE : 'werks bp01'.

LOOP AT lt_mard INTO ls_mard WHERE

werks = 'BP01'.

m = m + 1.

WRITE: / ls_mard-matnr,

22 ls_mard-labst .

ENDLOOP.

ULINE.

n = 0.

WRITE : 'werks bp02'.

LOOP AT lt_mard2 INTO ls_mard2 WHERE

werks = 'BP02'.

n = n + 1.

WRITE: / ls_mard2-matnr,

22 ls_mard2-labst .

ENDLOOP.

ULINE.

WRITE : 'together in plants '.

LOOP AT lt_mard2 INTO ls_mard2.

READ TABLE lt_mard2 INTO ls_mard WITH KEY matnr = ls_mard2-matnr.

IF sy-subrc = 0.

ls_mard-labst = ls_mard-labst + ls_mard2-labst.

APPEND ls_mard TO lt_mard3.

ENDIF.

ENDLOOP.

CLEAR ls_mard.

LOOP AT lt_mard3 INTO ls_mard.

WRITE: / ls_mard-matnr,

22 ls_mard-labst .

ENDLOOP.

ULINE.