Skip to Content
avatar image
Former Member

Program to update the reason of rejection (VBAP-ABGRU) field.

Hi,

I need to write a program which will change rejection reason of selected sales order line items from "UP" to "99". Please let me know the best way of doing this.

Thanks,

Sandeep

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Aug 16, 2007 at 02:23 PM

    Hi!

    We were using BDC for a task like this in VA02...

    Just create a recording in SM35 for it.

    Regards

    Tamá

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      The problem is that I have more than 8400 entries and many of the sales orders have more than one line items which has the ABGRU field value as 99. I think it would be a very complicated logic to perform this task using BDC.

  • avatar image
    Former Member
    Aug 16, 2007 at 02:27 PM

    BAPI is the Best Option.

    BAPI_SALESORDER_CHANGE

    and see the documentation of it.

    Regards

    Peram

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 16, 2007 at 02:32 PM

    I Wrote a sample program for you, please let me know if you are successfull.

    You can use the following bapi ...!

    REPORT ZTEST_REASONREJ.

    parameters : vbeln like vbak-vbeln.

    DATA IT_ITEM TYPE STANDARD TABLE OF BAPISDITM.

    DATA W_ITEM TYPE BAPISDITM.

    DATA IT_ITEMX TYPE STANDARD TABLE OF BAPISDITMX.

    DATA W_ITEMX TYPE BAPISDITM.

    DATA IT_RETURN TYPE STANDARD TABLE OF BAPIRET2.

    w_ordhinx-updateflag = 'U'.

    W_ITEM-ITMNUMBER = '0010'.

    W_ITEM-ITEMCATEG = 'ZTAN'.

    W_ITEM-REASON_REJ = 'Z1'.

    APPEND W_ITEM TO IT_ITEM.

    W_ITEMX-ITMNUMBER = 'X'.

    W_ITEMX-ITEMCATEG = 'X'.

    W_ITEMX-REASON_REJ = 'X'.

    APPEND W_ITEMX TO IT_ITEMX.

    CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

    EXPORTING

    salesdocument = vbeln

    order_header_inx = w_ordhinx

    tables

    return = it_return

    ORDER_ITEM_IN = it_item

    ORDER_ITEM_INX = it_itemx

    .

    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' .

    Reward Points if usefull.

    Thanks and regards,

    Veerendranath Maddula.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      You should always reward points for all the replies, even if it is very helpfull, or helpfull this will encourage the people who will try to solve your problem.

      Following is the code, just try it , this should work.

      DATA: BEGIN OF IT_VBAP OCCURS 0,

      VBELN type VBAP-VBELN,

      POSNR TYPE VBAP-POSNR,

      MATNR TYPE VBAP-MATNR,

      ABGRU TYPE VBAP-ABGRU,

      PSTYV TYPE VBAP-PSTYV,

      END OF IT_VBAP.

      DATA WA_VBAP like IT_VBAP.

      DATA IT_ITEM TYPE STANDARD TABLE OF BAPISDITM.

      DATA W_ITEM TYPE BAPISDITM.

      DATA IT_ITEMX TYPE STANDARD TABLE OF BAPISDITMX.

      DATA W_ITEMX TYPE BAPISDITMX.

      DATA IT_RETURN TYPE STANDARD TABLE OF BAPIRET2.

      DATA w_ordhinx type BAPISDH1X.

      w_ordhinx-updateflag = 'U'.

      W_ITEM-ITM_NUMBER = WA_VBAP-POSNR.

      w_order_item_in-material = wa_vbap-matnr.

      W_ITEM-ITEM_CATEG = WA_VBAP-PSTYV.

      W_ITEM-REASON_REJ = '99'.

      APPEND W_ITEM TO IT_ITEM.

      w_order_item_inx-updateflag = 'X'.

      W_ITEMX-ITM_NUMBER = 'X'.

      w_order_item_inx-material = 'X'.

      W_ITEMX-ITEM_CATEG = 'X'.

      W_ITEMX-REASON_REJ = 'X'.

      APPEND W_ITEMX TO IT_ITEMX.

      CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

      EXPORTING

      salesdocument = wa_VBAP-VBELN

      order_header_inx = w_ordhinx

      tables

      return = it_return

      ORDER_ITEM_IN = it_item

      ORDER_ITEM_INX = it_itemx .

      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' .

      Reward points if usefull.

      Thanks,

      Veerendranath.