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

Goods Mvt using BAPI_PROCORDCONF_CREATE_TT

Former Member
0 Likes
5,817

Hi Guys,

I am trying to post process order confirmation using BAPI_PROCORDCONF_CREATE_TT.

Confirmation is getting posted successfully but not goods movement.  Material Document against the confirmation number is blank.

I intend to capture the material document (GI & GR) against the confirmation posted for the Process Order.

In order to achieve that, I have also tried following tricks -

1. Using BAPI_PROCORDCONF_GET_HDR_PROP

2.  Using Goods Movement Indicator = 'F' for GR (Header Material)

3.  Calling BAPI_TRANSACTION_COMMIT after the confirmation BAPI

4. Using Control Key with "Aut. Goods Receipt" indicator set

Kindly guide me on how to post GR & GI automatically using BAPI_PROCORDCONF_CREATE_TT.?

Also, how to populate input data for BAPI to achieve the result?

Thanks in advance,

Rajen

Hi Guys,

I am trying to post process order confirmation using BAPI_PROCORDCONF_CREATE_TT.

Confirmation is getting posted successfully but not goods movement.  Material Document against the confirmation number is blank.

I intend to capture the material document (GI & GR) against the confirmation posted for the Process Order.

In order to achieve that, I have also tried following tricks -

1. Using BAPI_PROCORDCONF_GET_HDR_PROP

2.  Using Goods Movement Indicator = 'F' for GR (Header Material)

3.  Calling BAPI_TRANSACTION_COMMIT after the confirmation BAPI

4. Using Control Key with "Aut. Goods Receipt" indicator set

Kindly guide me on how to post GR & GI automatically using BAPI_PROCORDCONF_CREATE_TT.?

Also, how to populate input data for BAPI to achieve the result?

Thanks in advance,

Rajen

12 REPLIES 12
Read only

yogendra_bhaskar
Contributor
0 Likes
4,350

Hi Rajen ,

You need to populate data in tables :

         goodsmovements    

         link_conf_goodsmov

Moreover , if you are getting any error ,please look into the table

         detail_return

Regards

Yogendra Bhaskar

Read only

0 Likes
4,350

Hi Yogender,

Thanks for replying. I did populated both these tables while calling BAPI. But no material document posted although RETURN table gives a message saying "Confirmation saved for Process Order ".

Please suggest if i am missing something.

Thanks,

Rajen

Read only

0 Likes
4,350

Hi Rajen ,

Can you paste the code , so that i can review it once.

Regards

Yogendra Bhaskar

Read only

0 Likes
4,350

Hi Yogendra,


Please find the code below.

Here, I am populating GI & GR data in table goodsmovements and corresponding entries in table link_conf_goodsmov.


I have also tried posting only GR (Mvt. Type 101) for the header material but couldn't able to generate material document although confirmation is done successfully.





**********************************************************************

***Get Order Details

   READ TABLE it_prod INTO wa_prod INDEX 1.

   CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

     EXPORTING

       input  = wa_prod-order

     IMPORTING

       output = lv_aufnr.

   SELECT SINGLE vornr

   FROM afko AS k INNER JOIN afvc AS v

   ON k~aufpl EQ v~aufpl

   INTO lv_phase

   WHERE aufnr EQ lv_aufnr

     AND phflg EQ 'X'.

   ls_objects-header = 'X'.

   ls_objects-components = 'X'.

   CALL FUNCTION 'BAPI_PROCORD_GET_DETAIL'

     EXPORTING

       number        = lv_aufnr

       order_objects = ls_objects

     IMPORTING

       return        = ls_bapiret2

     TABLES

       header        = lt_hdr

       component     = lt_comp.

   IF sy-subrc EQ 0.

     READ TABLE lt_hdr INTO lw_hdr INDEX 1.

   ENDIF.

**********************************************************************

***Populate Time Ticket data for Order

   CLEAR: lw_tt, lv_qty.

   lw_tt-orderid = wa_prod-order.

   lw_tt-phase = lv_phase.

   lw_tt-fin_conf = 'X'.

   CONCATENATE wa_prod-prod_date+6(4)

               wa_prod-prod_date+3(2)

               wa_prod-prod_date+0(2)

          INTO lw_tt-postg_date.

   lw_tt-plant = lw_hdr-production_plant.

   lw_tt-conf_quan_unit = lw_hdr-unit.

   lw_tt-yield = wa_prod-qty.

   CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'

     EXPORTING

       i_matnr              = lw_hdr-material

       i_in_me              = 'KG'

       i_out_me             = lw_hdr-unit

       i_menge              = lw_tt-yield

     IMPORTING

       e_menge              = lv_qty

     EXCEPTIONS

       error_in_application = 1

       error                = 2

       OTHERS               = 3.

   lw_tt-yield = lv_qty.

   APPEND lw_tt TO lt_tt.

   lv_cnf_ind = lv_cnf_ind + 1.

**********************************************************************

***Get Proposed Goods Movement for Header

   CLEAR: ls_bapiret, lw_hdrlvl.

   lw_hdrlvl-orderid = lv_aufnr.

   APPEND lw_hdrlvl TO lt_hdrlvl.

   CALL FUNCTION 'BAPI_PROCORDCONF_GET_HDR_PROP'

     EXPORTING

       prop_gmov          = 'X'

     IMPORTING

       return             = ls_bapiret

     TABLES

       athdrlevels        = lt_hdrlvl

       goodsmovements     = lt_gm

       link_conf_goodsmov = lt_link

       detail_return      = lt_return.

   READ TABLE lt_return INTO lw_return WITH KEY type = 'E'.

   IF sy-subrc NE 0 AND ls_bapiret-type NE 'E' AND ls_bapiret-type NE 'A'.

     LOOP AT lt_gm INTO lw_gm.

       lw_gm-entry_qnt = lw_tt-yield.

       lw_gm-prod_date  = lw_tt-postg_date.

       lw_gm-activity  = lv_phase.

       lw_gm-line_id   = '1'.

       lw_gm-parent_id = '1'.

       lw_gm-mvt_ind = 'F'.

       APPEND lw_gm TO lt_gm_upd.

       lv_gm_ind = lv_gm_ind + 1.

     ENDLOOP.

   ENDIF.

   IF lv_cnf_ind IS NOT INITIAL AND lv_gm_ind IS NOT INITIAL.

     CLEAR lw_link.

     lw_link-index_confirm  = lv_cnf_ind.

     lw_link-index_goodsmov = lv_gm_ind.

     APPEND lw_link TO lt_link_upd.

   ENDIF.

**********************************************************************

***Get Proposed Goods Movement for Material List Items

   lv_line_id = '1'.

   LOOP AT lt_comp INTO lw_comp.

     lv_line_id = lv_line_id + 1.

     lv_gm_ind  = lv_gm_ind + 1.

*    lv_cnf_ind = lv_cnf_ind + 1.

     CLEAR: lw_gm, wa_cons, lv_qty.

     CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'

       EXPORTING

         input  = lw_comp-material

       IMPORTING

         output = lw_comp-material.

     lv_matnr = lw_comp-material+0(10).

     CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

       EXPORTING

         input  = lv_matnr

       IMPORTING

         output = lv_matnr.

     CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

       EXPORTING

         input  = lw_comp-material

       IMPORTING

         output = lw_comp-material.

     READ TABLE it_cons INTO wa_cons WITH KEY pcode = lv_matnr.

     IF sy-subrc EQ 0.

       lw_gm-entry_qnt = wa_cons-qty.

     ELSE.

       lw_gm-entry_qnt = lw_comp-req_quan.

     ENDIF.

     CONCATENATE wa_cons-cons_date+6(4)

                 wa_cons-cons_date+3(2)

                 wa_cons-cons_date+0(2)

            INTO lw_gm-prod_date.

     CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'

       EXPORTING

         i_matnr              = lw_comp-material

         i_in_me              = 'KG'

         i_out_me             = lw_comp-base_uom

         i_menge              = lw_gm-entry_qnt

       IMPORTING

         e_menge              = lv_qty

       EXCEPTIONS

         error_in_application = 1

         error                = 2

         OTHERS               = 3.

     IF sy-subrc EQ 0.

       lw_gm-entry_qnt = lv_qty.

     ENDIF.

     lw_gm-orderid   = lv_aufnr.

     lw_gm-activity  = lv_phase.

     lw_gm-material  = lw_comp-material.

     lw_gm-plant     = lw_comp-prod_plant.

     lw_gm-stge_loc  = lw_comp-storage_location.

     lw_gm-batch     = lw_comp-batch.

     lw_gm-move_type = lw_comp-movement_type.

     lw_gm-mvt_ind   = lw_comp-special_stock.

     lw_gm-entry_uom = lw_comp-base_uom.

     lw_gm-reserv_no = lw_comp-reservation_number.

     lw_gm-res_item  = lw_comp-reservation_item.

     lw_gm-parent_id = '1'.

     lw_gm-line_id   = lv_line_id.

     APPEND lw_gm TO lt_gm_upd.

     IF lv_cnf_ind IS NOT INITIAL AND lv_gm_ind IS NOT INITIAL.

       CLEAR lw_link.

       lw_link-index_confirm  = lv_cnf_ind.

       lw_link-index_goodsmov = lv_gm_ind.

       APPEND lw_link TO lt_link_upd.

     ENDIF.

   ENDLOOP.

**********************************************************************

***Post Confirmation for Order & Items with Goods Movement

   CLEAR: lt_return[], ls_bapiret.

   CALL FUNCTION 'BAPI_PROCORDCONF_CREATE_TT'

     EXPORTING

       post_wrong_entries = lv_err

       testrun            = lv_testrun

     IMPORTING

       return             = ls_bapiret

     TABLES

       timetickets        = lt_tt

       goodsmovements     = lt_gm_upd

       link_conf_goodsmov = lt_link_upd

       detail_return      = lt_return.






Thanks,

Rajen

Read only

0 Likes
4,350

Hi Rajen ,

Are you using  BAPI_TRANSACTION_COMMIT FM in the last ?

Regards

Yogendra Bhaskar

Read only

0 Likes
4,350

Hi Yogendra,

I have used BAPI_TRANSACTION_COMMIT in the last after calling BAPI_PROCORDCONF_CREATE_TT..

Please suggest to resolve this issue.

Thanks,

Rajen

Read only

0 Likes
4,350

Hi Rajen ,

Go through the t-code COGI ( Are you capturing the error ? )

Regards

Yogendra Bhaskar

Read only

0 Likes
4,350

Hi Yogendra,

COGI Error log shows only stock deficit & posting period errors which I took care and then tried again.

Now, when the confirmation BAPI is called, no error logs are there in transaction COGI and confirmation is saved with no material documents posted.

Thanks,

Rajen

Read only

VenkatRamesh_V
Active Contributor
0 Likes
4,350

Hi Rajen,

For Goods Movement try FM BAPI_GOODSMVT_CREATE.

Hope it helpful,

Regards,

Venkat.

Read only

0 Likes
4,350

Hi Venkat,

Thanks for replying.

So, should i post both GI & GR using BAPI_GOODSMVT_CREATE ?

Is there any way to link the posted material documents with Confirmation Number for Process Order generated?

Appreciate your quick response.

Thanks,

Rajen

Read only

Ashokv
Explorer
0 Likes
4,350

Try calling BAPI_PROCORDCONF_GET_TT_PROP and appropriate parameters in PROPOSE.

Read only

former_member711377
Discoverer
0 Likes
4,350

HI,Former Member,are u resolve the problem, I have the same problem,can u help me ,BAPI_PROCORDCONF_GET_TT ,What's your solution to let us learning.