Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

problem with status-button in item view of ME21/22/23N

Former Member
0 Kudos

Hello ABAP,

i have to check for some conditions when a PO is saved, and due to those checks either save it or well, not.

This is working fine so far.

when you click check, or save, conditions get checked and window with errors pops up.

I´m using the normal error message procession used in SAPLMEGUI which i have to fill with thos three makros.

I just have one problem, my status button in item line doesnt get updated. i tried with a lot of metafields by now but it seems trial and error is not the way to go here.

any tips?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi

You can not issue error messages by normal processing. You need to use MMPUR macro to issue the error message.

OSS-Note 310154 may be helpful.

6 REPLIES 6

Former Member
0 Kudos

Hi

You can not issue error messages by normal processing. You need to use MMPUR macro to issue the error message.

OSS-Note 310154 may be helpful.

0 Kudos

arrrgh ok i was speaking a bit complicated. what i meant is that i use this MMPUR thingie, but like it seems not a 100% correct

anyway i will go and scan this SAP-NOTE now thx.

0 Kudos

ok, this SAP-note was very interesting and now i kinda understand what i already did.

I´m adding my coding here now, since nothing what i do really helps.


LOOP AT lt_items INTO lr_item.
  ls_item = lr_item-item->get_data( ).  "EKPO

  "select liquidations/annulations orders for supplier material nr.
  SELECT *
  FROM   ysdch_vbap_idnlf
  INTO   TABLE lt_ytab
  WHERE  /fis/idnlf = ls_item-idnlf.

  LOOP AT lt_ytab INTO ls_ytab.
    "now lets see which of those orders has order stock
    SELECT SINGLE kalab kaspe
    FROM   mska
    INTO   CORRESPONDING FIELDS OF ls_mska
    WHERE  vbeln = ls_ytab-vbeln
    AND    posnr = ls_ytab-posnr.

    IF ls_mska-kalab GT 0 OR ls_mska-kaspe GT 0.
      ls_data-vbeln       = ls_ytab-vbeln.
      ls_data-posnr       = ls_ytab-posnr.
      ls_data-/fis/idnlf  = ls_item-idnlf.
      ls_data-kalab       = ls_mska-kalab.
      ls_data-kaspe       = ls_mska-kaspe.
      ls_data-meins       = ls_item-meins.
      ls_data-ebelp       = ls_item-ebelp.
      APPEND ls_data TO lt_data.
    ELSE.
      CONTINUE.
    ENDIF.
  ENDLOOP.
ENDLOOP. " lt_item


IF NOT lt_data IS INITIAL.
  "we got annulation/liquidation orders with order stock for this material
  "so popup a error message
  READ TABLE lt_data
  INTO  ls_data
  INDEX 1.

  LOOP AT lt_data INTO ls_data.
    lv_item-ebeln = ls_data-vbeln.
    lv_item-ebelp = ls_data-posnr.
    IF NOT ls_data-vbeln IS INITIAL AND NOT ls_data-posnr IS INITIAL.
      mmpur_business_obj_it lv_item-ebeln lv_item-ebelp.
    ENDIF.
    mmpur_metafield mmmfd_item_number.
    mmpur_message  'E' 'YMMCH' '110' ls_data-vbeln ls_data-posnr ls_data-ebelp ' '.
  ENDLOOP.
  ch_failed = 'X'.
ENDIF.

i suspect, that most of it is correct but i´m just missing something small to get this status button in item line to do (show) something.

/edit: BTW i´m using the old-school classical BADI to implement this coding. i´m in the CHECK routine.

Edited by: Florian Kemmer on Sep 7, 2010 10:24 AM

Edited by: Florian Kemmer on Sep 7, 2010 10:25 AM

0 Kudos

Hi Florian,

Have you tried using macro mmpur_message_forced instead of mmpur_message?

Regards,

Ana Luisa.

0 Kudos

yeah i had done that first before i had read the sap note from above. after reading this i tried it without forced since it may be i´m the last one processing a message.

anyway, didnt work for both implementations...

0 Kudos

requirement resolved.

solution follows:


DATA: lt_ytab             TYPE TABLE OF ysdch_vbap_idnlf,
      lt_data             TYPE TABLE OF ymmch_check_idnlf_out, "added ID (TYPE INT4) Field to structure
      lt_out              TYPE TABLE OF char80.

DATA: ls_ytab             TYPE ysdch_vbap_idnlf,
      ls_mska             TYPE mska,
      ls_data             TYPE ymmch_check_idnlf_out,
      ls_out              TYPE char80,
      lv_row_end          TYPE i VALUE 10.

CONSTANTS:  lc_col_start        TYPE i VALUE 10,
            lc_col_end          TYPE i VALUE 40,
            lc_row_start        TYPE i VALUE 10,
            lc_title            TYPE char80 VALUE
            'Fehler, noch Bestand zu Liquidations/Annulationsaufträgen vorhanden'.

*~~~Get header data
ls_head = im_header->get_data( ).
*~~~Get item data
lt_items = im_header->get_items( ).
LOOP AT lt_items INTO lr_item.
  ls_item = lr_item-item->get_data( ).  "EKPO

  "select liquidations/annulations orders for supplier material nr.
  SELECT *
  FROM   ysdch_vbap_idnlf
  INTO   TABLE lt_ytab
  WHERE  /fis/idnlf = ls_item-idnlf.

  LOOP AT lt_ytab INTO ls_ytab.
    "now lets see which of those orders has order stock
    SELECT SINGLE kalab kaspe
    FROM   mska
    INTO   CORRESPONDING FIELDS OF ls_mska
    WHERE  vbeln = ls_ytab-vbeln
    AND    posnr = ls_ytab-posnr.

    IF ls_mska-kalab GT 0 OR ls_mska-kaspe GT 0.
      ls_data-vbeln       = ls_ytab-vbeln.
      ls_data-posnr       = ls_ytab-posnr.
      ls_data-/fis/idnlf  = ls_item-idnlf.
      ls_data-kalab       = ls_mska-kalab.
      ls_data-kaspe       = ls_mska-kaspe.
      ls_data-meins       = ls_item-meins.
      ls_data-ebelp       = ls_item-ebelp.
      ls_data-id          = ls_item-id. "saved ID for later processing
      APPEND ls_data TO lt_data.
    ELSE.
      CONTINUE.
    ENDIF.
  ENDLOOP.
ENDLOOP. " lt_item


IF NOT lt_data IS INITIAL.
  "we got annulation/liquidation orders with order stock for this material
  "so popup a error message

  LOOP AT lt_data INTO ls_data.
    IF NOT ls_data-vbeln IS INITIAL AND NOT ls_data-posnr IS INITIAL.
      mmpur_business_obj_id ls_data-id. "using other makro now and making use of ID
      "using mmpur_business_obj_id instead of mmpur_business_obj_it
    ENDIF.
    mmpur_metafield mmmfd_item_number.
    mmpur_message  'W' 'YMMCH' '110' ls_data-vbeln ls_data-posnr ls_data-ebelp ' '.
  ENDLOOP.
  ch_failed = 'X'.
ENDIF.

Edited by: Florian Kemmer on Sep 7, 2010 3:22 PM