06-30-2011 1:29 PM
Hi,
I have a requirement to display error message by comparing the LIPS table and a ZBOX table. Currently I am summing up the box table. Looping on LIPS and then reading the box table by sales_order sales_item and matnr.IF no of lines in lips> thank the box, throw the error ... the the error message is correct, but the sales_item is coming wrong.
LIPS
VBELN | POSNR | MATNR | LFIMG
002743747 | 000010 | MATNR1 | 2
BOX
BOXNUM | SALES_ORDER | SALES_ITEM | MATNR | QUANT
00001 | 002743747 | 000010 | MATNR1| 1
00002 | 002743747 | 000010 | MATNR1| 1
00003 | 002743747 | 000020 | MATNR2| 1
Error message should be Sales Order 002743747 Sale item 000020 are boxed.....
but I am getting...Sales Order 002743747 Sale item 000010 are boxed.....
Compare lt_lips & lt_final
LOOP AT lt_lips INTO lw_lips.
READ TABLE lt_final INTO lw_final WITH KEY
sales_order = lw_lips-vgbel sales_item = lw_lips-vgpos matnr = lw_lips-matnr quant = lw_lips-lfimg.
IF sy-subrc <> 0.
MESSAGE e002 WITH lw_final-matnr lw_final-sales_order lw_final-sales_item lw_final-quantity.
EXIT.
ELSE.
READ TABLE lt_final INTO lw_final WITH KEY
sales_order = lw_lips-vgbel sales_item = lw_lips-vgpos.
IF sy-subrc = 0.
DESCRIBE TABLE lt_lips LINES lf_lips_lines.
DESCRIBE TABLE lt_final LINES lf_final_lines.
IF lf_final_lines > lf_lips_lines.
READ TABLE lt_zbox INTO lw_zbox WITH KEY
sales_order = lw_lips-vgbel sales_item = lw_lips-vgpos matnr = lw_lips-matnr." quant = lw_lips-lfimg.
IF sy-subrc = 0.
clear lf_box_num.
Move lw_box-box_num to lf_box_num.
MESSAGE e003 WITH lw_final-sales_order lw_final-sales_item lf_box_num.
EXIT.
ELSE.
MESSAGE e005 WITH lw_final-sales_order lw_final-sales_item.
EXIT.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
06-30-2011 2:12 PM
Hi!
Try this:
LOOP AT lt_lips INTO lw_lips.
READ TABLE lt_final INTO lw_final
WITH KEY sales_order = lw_lips-vgbel
sales_item = lw_lips-vgpos
matnr = lw_lips-matnr
quant = lw_lips-lfimg.
IF sy-subrc 0.
MESSAGE e002 WITH lw_final-matnr
lw_final-sales_order
lw_final-sales_item
lw_final-quantity.
EXIT.
ELSE.
READ TABLE lt_final INTO lw_final
WITH KEY sales_order = lw_lips-vgbel
sales_item = lw_lips-vgpos.
IF sy-subrc = 0.
DESCRIBE TABLE lt_lips LINES lf_lips_lines.
DESCRIBE TABLE lt_final LINES lf_final_lines.
IF lf_final_lines gt lf_lips_lines.
loop at lt_zbox INTO lw_zbox
where sales_order = lw_lips-vgbel
and matnr = lw_lips-matnr.
if lw_zbox-sales_item ne lw_lips-vgpos.
clear lf_box_num.
Move lw_box-box_num to lf_box_num.
MESSAGE e003 WITH lw_final-sales_order
lw_zbox-vgpos
lf_box_num.
EXIT.
endif.
endloop.
MESSAGE e005 WITH lw_final-sales_order
lw_final-sales_item.
EXIT.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
Regards,
Robson Pereira
Edited by: Robson Pereira on Jun 30, 2011 3:13 PM
Edited by: Robson Pereira on Jun 30, 2011 3:14 PM
Edited by: Robson Pereira on Jun 30, 2011 3:14 PM
Edited by: Robson Pereira on Jun 30, 2011 3:15 PM
06-30-2011 2:27 PM
Hi SB
For the parameters of your message in this case you should be use the position of lw_zbox.
READ TABLE lt_zbox INTO lw_zbox WITH KEY
sales_order = lw_lips-vgbel sales_item = lw_lips-vgpos matnr = lw_lips-matnr." quant = lw_lips-lfimg.
IF sy-subrc = 0.
clear lf_box_num.
Move lw_box-box_num to lf_box_num.
MESSAGE e003 WITH lw_zbox-sales_order lw_zbox-sales_item lf_box_num.
EXIT.
Regards,
Filippo