Application Development and Automation 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: 
Read only

BADI - ME_REQ_POSTED

Former Member
0 Likes
4,357

Hello experts

i need to implement BADI - ME_REQ_POSTED to change some fields in purchase request when save,

But i have some problem to change structure IM_EBAN.

this is the code

data: l_IM_EBAN2 like line of IM_EBAN.

loop at IM_EBAN into l_im_eban2.

clear l_im_eban2-afnam.

modify im_eban from l_im_eban2.

endloop.

But i have msg:The field "IM_EBAN" cannot be changed. -

How can i change this field?

Thanks in advice

B.

5 REPLIES 5
Read only

Former Member
0 Likes
2,155

Hi,

ME too getting same problem, Please suggest me.

Thanks&Regards,

Gopi .M

Read only

Former Member
0 Likes
2,155

Hello Boris,

If you want to change the values while saving PR, its better to implement ME_PROCESS_REQ_CUST rather than ME_REQ_POSTED coz in POST method, I think you can validate but changing the values is not possible in either of the BADI's.

Check the sample following code  to change values before SAVE :

Its a sample code, in this Im changing the Quantity of the PR as per the Material Characteristics

  DATA : ls_citem TYPE mereq_item,
         ls_pitem TYPE mereq_item,
         ls_client TYPE bapi_mara_ga,
         lt_units TYPE TABLE OF bapi_marm_ga,
         ls_units TYPE bapi_marm_ga,
         lv_answer TYPE c,
         lv_menge TYPE bamng,
         lv_ques TYPE string,
         lv_temp1 TYPE string,
         lv_temp2 TYPE string,
         lt_message TYPE bssp_t_message.


** Multily Quantity with Base Quantity for Materials of type Z123
  CHECK im_count EQ 1.  " This need to be checked bcoz the same method will call multiple times
  CALL METHOD im_item->get_data
    RECEIVING
      re_data = ls_citem.
  CALL METHOD im_item->get_previous_data
    RECEIVING
      re_data = ls_pitem.
  IF ls_citem-menge IS NOT INITIAL AND ls_citem-menge <> ls_pitem-menge.
    CLEAR ls_client.
    REFRESH lt_units.
    CALL FUNCTION 'BAPI_MATERIAL_GET_ALL'
      EXPORTING
        material       = ls_citem-matnr
        comp_code      = ls_citem-werks
      IMPORTING
        clientdata     = ls_client
      TABLES
        unitsofmeasure = lt_units.
    IF ls_client-matl_type EQ 'Z123'.
      READ TABLE lt_units INTO ls_units WITH KEY alt_unit = ls_client-po_unit.
      IF sy-subrc EQ '0'.
        CLEAR : lv_menge, lv_ques, lv_temp1, lv_temp2.
        lv_menge = ls_citem-menge * ls_units-numerator.
        MOVE ls_citem-menge TO lv_temp1.
        MOVE lv_menge TO lv_temp2.
        CONCATENATE 'Quantity' lv_temp1 'will be converted to' lv_temp2 'as per Material Chrst.' INTO lv_ques SEPARATED BY space.
        CALL FUNCTION 'KLPOPUP_TO_DISPLAY_TEXT'
          EXPORTING
            titel     = 'Note'
            textline1 = lv_ques.
        ls_citem-menge = lv_menge.
        CALL METHOD im_item->set_data
          EXPORTING
            im_data = ls_citem.
      ENDIF.
    ENDIF.
  ENDIF.

Hopefully it helps!!!

Rgrds,

Sravan

Read only

0 Likes
2,155

Hi Sravan,

   

  Is it useful to change Purchase req. quantity which are currently creating PR.

  And  i'm using Badi MD_PURREQ_POST.

Kindly suggest me.

Thanks&Regards,

Gopi

Read only

Former Member
0 Likes
2,155

Hi Boris,

ME_REQ_POSTEDhas only Post method.

Use BADI ME_PROCESS_REQ -  PROCESS_ITEM method from the method parameters u wcan go to another inteface there we will have SET_DATA for a item.

Hope this helps.

Let me knw if additional info is required.

Thanks,

Tooshar Bendale

Read only

0 Likes
2,155

Hi Boris,

 

Thank you for reply. In BADI ME_PROCESS_REQ may have to implement new method .

Please confirm and explain the process.

Thanks&Regards,

Gopi.