Skip to Content
0
Jun 21, 2018 at 10:21 PM

IF_EX_ME_PROCESS_REQ_CUST~OPEN method creating lines grays out entry

1507 Views

I have a requirement to create an ALV report. From there the user wants to select a few rows of data with information like part#, text, price etc. They then want me to call ME51N with the selected data and prepopulate the detail grid with the selected information. Then they would be able to finish doing the data entry in ME51N before eventually saving and creating the req.

I am using the OPEN method of BAdI ME_PROCESS_REQ_CUST. By adding some items using IM_HEADER->CREATE_ITEM from some data stored in memory by the caller and then using SET_DATA method to default fields at the open time of ME51N. I thought I had the solution, but unfortunately, the rows that are created are actually grayed out.

The user has to hit the check button and get the error message popup. They get this because I am not populating the quantity or date fields. After hitting the green arrow on the pop-up, the rows are then opened for data entry. This is the desired result. I will include my code here in case someone know what I am missing that will allow the rows to be opened for entry at the beginning of the screen without the extra manual steps.

METHOD if_ex_me_process_req_cust~open.

DATA: i_mereq_item TYPE mereq_item,
      i_mereq_head TYPE mereq_header.

DATA: ld_im_item TYPE REF TO if_purchase_requisition_item,
      ld_re_item TYPE REF TO if_purchase_requisition_item.

DATA: t_me51n TYPE STANDARD TABLE OF zmmprprice_me51n_wa,
      x_me51n TYPE zmmprprice_me51n_wa,
      v_bnfpo TYPE bnfpo.

REFRESH t_me51n.
IMPORT t_me51n TO t_me51n FROM MEMORY ID 'ZMMPRICE_ME51N'.
CHECK t_me51n[] IS NOT INITIAL.

CLEAR i_mereq_head.
i_mereq_head-bsart = 'ID'.
im_header->set_data( EXPORTING im_data = i_mereq_head ).

CLEAR v_bnfpo.
LOOP AT t_me51n INTO x_me51n.
  CALL METHOD im_header->create_item(
    EXPORTING
       im_item = ld_im_item
    RECEIVING
       re_item = ld_re_item ).

  CLEAR i_mereq_item.
  v_bnfpo = v_bnfpo + 10.
  i_mereq_item-bnfpo = v_bnfpo.
  i_mereq_item-bsart = 'ID'.
  i_mereq_item-lifnr = x_me51n-lifnr.
  i_mereq_item-txz01 = x_me51n-indmatcod.
  i_mereq_item-ekgrp = x_me51n-ekgrp.
  i_mereq_item-preis = x_me51n-netpr.
  i_mereq_item-waers = x_me51n-waers.
  i_mereq_item-werks = x_me51n-werks.

  ld_re_item->set_data( EXPORTING im_data = i_mereq_item ).
ENDLOOP.

ENDMETHOD.