Thursday, 15 February 2024

Change Info record using BAPI_ALM_ORDER_MAINTAIN

 









 Data g_refnum(6TYPE N.

  REFRESH lt_methods,lt_component,lt_component_up..
  CLEAR ls_methods.
  CLEAR ls_component.
  CLEAR ls_component_up.

*Get Reservation N
  LOOP AT IT_DAT4 INTO WA_DAT4.
    Select single rsnum rspos
           into (wa_dat4-rsnum,wa_dat4-rspos)
           from RESB
           Where Aufnr EQ G_AUFNR
             And Matnr EQ wa_dat4-col_10

    Modify it_dat4 from wa_dat4.
  Endloop.

  g_refnum 1.
  LOOP AT IT_DAT4 INTO WA_DAT4 WHERE col_12 EQ SPACE.
*-- Component Mapping
    ls_methods-refnumber =  g_refnum .
    ls_methods-objecttype 'COMPONENT'.
    ls_methods-method     'CHANGE'.
    ls_methods-objectkey  =  G_AUFNR.
    Append ls_methods to lt_methods.

    ls_component-reserv_no =  wa_dat4-rsnum.
    ls_component-res_item  =  wa_dat4-rspos.
    ls_component-material  =  wa_dat4-col_10.
    ls_component-item_number =  wa_dat4-col_21.
    ls_component-activity '0010'.
    ls_component-info_rec ''.
    ls_component-pur_group wa_dat4-col_06.

    ls_component_up-material 'X'.
    ls_component_up-item_number 'X'.
    ls_component_up-info_rec 'X'.
    ls_component_up-pur_group 'X'.
    APPEND ls_component TO lt_component.
    APPEND ls_component_up TO lt_component_up.
    CLEAR ls_methods.

    ls_methods-method 'SAVE'.
    APPEND ls_methods TO lt_methods.
    g_refnum g_refnum + 1.
  ENDLOOP.

  call function 'BAPI_ALM_ORDER_MAINTAIN'
    TABLES
      it_methods      lt_methods
      it_component    lt_component
      it_component_up lt_component_up
      return          lt_return
      et_numbers      lt_numbers.

  Call function 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
      wait 'X'.

No comments:

Post a Comment

Visitor

Code Syntax Try...Endtry

  Code : Report Try. Parameters  NUMBER  type  I . data  RESULT  type  P  decimals  2 . data  OREF  type  ref  to  CX_ROOT . data  TEXT  typ...