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

BAPI order confirmation creation

Former Member
0 Likes
1,927

Hello,

I created a test program that uses BAPI_PRODORDCONF_CREATE_HDR to create order confirmation. When i run the program i get an error on the Goods Issue that is generated for my backflushed component.

I'm not sure why it's giving this error since the data that i have in the program is as far as i can tell correct...

The error is below, i will post the code of test program in subsequent post since i loose the formatting otherwise....

Thanks for your help.

ERROR:

Content of order 100003269: 4048 transferred to interface (IMSEG): 20002952

Message no. M7 349

Diagnosis

When calling the function module MB_CREATE_GOODS_MOVEMENT or the BAPI GoodsMovement.CreateFromData (BAPI_GOODSMVT_CREATE) to post a goods receipt for a production order, there are differences between the interface data and the order data.

Example: The order was created for plant 0001, but plant 0002 is passed on in the interface.

The system checks this for the material and the order item.

System Response

Due to this difference, the system cannot post the goods receipt.

Procedure

Check the data in the interface (IMSEG-WERKS, IMSEG-AUFNR). If necessary, correct the plant or the order number in the interface.

End of ERROR.

4 REPLIES 4
Read only

Former Member
0 Likes
1,234

DATA: POST_WRONG_ENTRIES LIKE BAPI_CORU_PARAM-INS_ERR,
      TESTRUN            LIKE BAPI_CORU_PARAM-TESTRUN,
      RETURN             LIKE BAPIRET1 occurs 10 with HEADER LINE,
      ATHDRLEVELS        LIKE BAPI_PP_HDRLEVEL OCCURS 10 WITH HEADER
                                                               LINE,
      GOODSMOVEMENTS     LIKE BAPI2017_GM_ITEM_CREATE OCCURS 10 WITH
                                                         HEADER LINE,
      LINK_CONF_GOODSMOV LIKE BAPI_LINK_CONF_GOODSMOV OCCURS 10 WITH
                                                         HEADER LINE,
      DETAIL_RETURN      TYPE BAPI_CORU_RETURN OCCURS 10 WITH HEADER
                                                             LINE.


ATHDRLEVELS-orderid = '000100003269'.
ATHDRLEVELS-postg_date = SY-DATUM.
ATHDRLEVELS-conf_quan_unit = 'CAS'.
ATHDRLEVELS-yield         = '1'.
ATHDRLEVELS-conf_text = 'TEST11/09'.
APPEND ATHDRLEVELS.

GOODSMOVEMENTS-material = '000000000000004048'.
GOODSMOVEMENTS-plant    = '1042'.
GOODSMOVEMENTS-stge_loc = '1000'.
GOODSMOVEMENTS-batch    = 'QWERTY'.
GOODSMOVEMENTS-move_type = '101'.
GOODSMOVEMENTS-entry_qnt = '1'.
GOODSMOVEMENTS-entry_uom = 'CAS'.
GOODSMOVEMENTS-orderid   = '000100003269'.
GOODSMOVEMENTS-mvt_ind   = 'F'.
GOODSMOVEMENTS-prod_date = SY-DATUM.
APPEND GOODSMOVEMENTS.

GOODSMOVEMENTS-material = '000000000020002952'.
GOODSMOVEMENTS-plant    = '1042'.
GOODSMOVEMENTS-stge_loc = '1000'.
GOODSMOVEMENTS-move_type = '261'.
GOODSMOVEMENTS-batch    = 'TEST'.
GOODSMOVEMENTS-orderid   = '000100003269'.
GOODSMOVEMENTS-mvt_ind   = 'F'.
GOODSMOVEMENTS-prod_date = SY-DATUM.
APPEND GOODSMOVEMENTS.

LINK_CONF_GOODSMOV-Index_Confirm = '1'.
LINK_CONF_GOODSMOV-Index_Goodsmov = '1'.
APPEND LINK_CONF_GOODSMOV.
LINK_CONF_GOODSMOV-Index_Confirm = '1'.
LINK_CONF_GOODSMOV-Index_Goodsmov = '2'.
APPEND LINK_CONF_GOODSMOV.


CALL FUNCTION 'BAPI_PRODORDCONF_CREATE_HDR'
       exporting
         POST_WRONG_ENTRIES = POST_WRONG_ENTRIES
         TESTRUN = TESTRUN
       importing
         RETURN = RETURN
       tables
         ATHDRLEVELS = ATHDRLEVELS
         GOODSMOVEMENTS = GOODSMOVEMENTS
         LINK_CONF_GOODSMOV = LINK_CONF_GOODSMOV
         DETAIL_RETURN = DETAIL_RETURN.

IF SY-SUBRC = 0.
  COMMIT WORK.
  MESSAGE s888(sabapdocu) WITH detail_return-message.
ELSE.
  MESSAGE e888(sabapdocu) WITH detail_return-message.
ENDIF.
Read only

Former Member
0 Likes
1,234

Did you verify if the order and your confirmation have the same plant as suggested in the error message? Also, with BAPIs, you should look at the RETURN structure to determine if there is an error not SY-SUBRC.

Read only

0 Likes
1,234

Thansk for the quick reply.

Where do you check what plant is in the confirmation?

When i go to CO14 and enter the confirmation, i don't see any plant field in the main screen. I have to do a "shift-6" or click on "Goods Movements" to see the GR/GI entries and in there i can see the plant. In here the plant is the same as the one in the PO in both the GR line and the GI line.

Thanks for tip, I do check the ret structure when calling bapi's but not in test programs because i usually run them in debug.

Thanks for your help.

Read only

0 Likes
1,234

Hello,

I switched the program to use BAPI_PRODORDCONF_GET_HDR_PROP to get proposed values, i then call BAPI_PRODORDCONF_CREATE_HDR using the proposed values.

In this manner, a confirmation is created along with the corresponding GR and GI for backflushed components. The problem that i'm facing now is that the default values that are proposed are based on the total quantity of the PO.

I would like to do partial confirmations, i'm able to overwrite the default values with the quantity that i want to confirm and the corresponding uom (UOM on confirmation can defer from the UOM in the PO) but the problem is that i don't know how to calculate the required quantity in a GI for a backflushed components so that i can overwrite it.

is there a FM or BAPI that does this calculation? If not, what is the formula that should be implemented.

I tried to do the following logic:

- Convert the given qty/uom to the PO uom using CO_RU_UNIT_CONVERSION.

- Divide total PO qty by the converted qty i get from above FM, this is my factor.

- I then divide the total amount proposed in the GI by the factor to get the right qty but it does not seem to work...

I'm not sure what i'm missing.....

Thanks for your help.