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_GOODSMVT_CREATE 301 with WBS Elements

Former Member
0 Likes
6,498

I have a development that must create a Goods Movement 301 to transfer stock between special stock 'Q' WBS Elements.

If you create the 301 manually by MIGO you can have a WBS supplier (goodsmvt_item-VAL_WBS_ELEM) and a WBS destiny (goodsmvt_item-WBS_ELEM) and MIGO creates the document perfect, in table MSEG you can see two records (one for the supplier and one for the destiny) the field TCODE = 'MIGO_TR', it´s the only value i see different

If you try to replicate this with BAPI BAPI_GOODSMVT_CREATE you dont have the value to create a MIGO_TR, instead you create  with TCODE 'MB1B' (value 04), yo specify goodsmvt_item-VAL_WBS_ELEM and goodsmvt_item-WBS_ELEM, if i activate the MIGO Badi the tables IT_MSEG and IS_MKPF are filled with my values but when it finishes to create the document WBS_ELEM and VAL_WBS_ELEM are equal, so there's no transfer at all.

This is my example:

DATA: ls_header TYPE bapi2017_gm_head_01,

       ls_code   TYPE bapi2017_gm_code,

       lt_items  TYPE TABLE OF bapi2017_gm_item_create,

       lt_ret2   TYPE bapiret2_t,

       lv_matdoc TYPE mblnr,

       lv_mjahr  TYPE mjahr,

       lt_extensiont TYPE TABLE OF bapiparex.

FIELD-SYMBOLS: <fs_item> LIKE LINE OF lt_items,

                <fs_ext>  LIKE LINE OF lt_extensiont.

BREAK-POINT.

ls_header-pstng_date = sy-datum.

ls_header-doc_date = sy-datum.

*ls_header-ref_doc_no = '1234567890123456'.

ls_header-pr_uname = sy-uname.

ls_header-header_txt = 'FOLIOLARGODESIFAYHENCABECERA'.

*ls_header-ref_doc_no_long = '12345678901234567890123456789012345'.

ls_code-gm_code = '04'.

APPEND INITIAL LINE TO lt_items ASSIGNING <fs_item>.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

   EXPORTING

     input  = '606830057'

   IMPORTING

     output = <fs_item>-material.

<fs_item>-plant = '1500'.

<fs_item>-stge_loc = '1100'.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

   EXPORTING

     input  = 'CURMM0109'

   IMPORTING

     output = <fs_item>-batch.

<fs_item>-move_type = '301'.

<fs_item>-spec_stock = 'Q'.

<fs_item>-entry_qnt = '5'.

<fs_item>-entry_uom = 'ST'.

CALL FUNCTION 'CONVERSION_EXIT_ABPSN_INPUT'

   EXPORTING

     input  = 'P/80000021-00000001'

   IMPORTING

     output = <fs_item>-wbs_elem.

<fs_item>-move_mat = <fs_item>-material."'000000000606830057'.

<fs_item>-move_plant = '1500'.

<fs_item>-move_stloc = '1300'.

<fs_item>-move_batch = <fs_item>-batch."'CURMM0209'.

CALL FUNCTION 'CONVERSION_EXIT_ABPSN_INPUT'

   EXPORTING

     input  = 'P/80000021-00000000'

   IMPORTING

     output = <fs_item>-val_wbs_elem.

APPEND INITIAL LINE TO lt_extensiont ASSIGNING <fs_ext>.

<fs_ext>-structure = 'SIAFYH'.

<fs_ext>-valuepart1 = 'WBS_DESTINO'.

<fs_ext>-valuepart2 = <fs_item>-wbs_elem.

CALL FUNCTION 'BAPI_GOODSMVT_CREATE'

   EXPORTING

     goodsmvt_header       = ls_header

     goodsmvt_code         = ls_code

*   testrun               = 'X'

*   GOODSMVT_REF_EWM      =

   IMPORTING

*   GOODSMVT_HEADRET      =

     materialdocument      = lv_matdoc

     matdocumentyear       = lv_mjahr

   TABLES

     goodsmvt_item         = lt_items

*   GOODSMVT_SERIALNUMBER =

     return                = lt_ret2

     extensionin           = lt_extensiont.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

   EXPORTING

     wait = abap_true.

How can i create a transfer with TCODE 'MIGO_TR', it's the only field that changes besides the WBS values (When manually create from MIGO WBS_ELM and VAL_WBS_ELEM are the ones defined, when i create this from the bapi it copies VAL_WBS_ELEM to WBS_ELEM).

Attached there's an image of the records in MSEG, document 4900000379 is created manually in MIGO, 4900000386 and 4900000387 are created from the BAPI.

5 REPLIES 5
Read only

Former Member
0 Likes
3,351

Hi Gabriel,

I suppose using 415 Q will solve your issue.

Refer

BAPI_GOODSMVT_CREATE for 415Q transfer posting | SCN

Regards

Read only

0 Likes
3,351

Hi Mohammed i tried passing VAL_WBS_ELEM(Source) and WBS_ELEM(Destination) but BAPI copies source in destination, i even activated MIGO BADI and it's filled with my values but later in some point it changes to the same value of source.

415 Q can't be done for different plants, the devlopment can have one transfer with different plants, different locations, different WBS_ELEM and via MIGO the MM functional can do a 301 with this specification, i can't do it with the bapi, don' know if i'm missing something or if i have to use another bapi to simulate that migo.

Read only

0 Likes
3,351

I'm trying now and i can see this:

If i do a 415 even if i pass PLANT and MOVE_PLANT it just makes the movement in the same plant (Copies source in both fields in MSEG)

If i do a 301 even if i pass WBS_ELEM and VAL_WBS_ELEM it creates a movement between different plants and storage locations but copies source WBS_ELEM in both field in MSEG (PS_PSP_PNR and MAT_PSPNR same value)

Maybe it's just an X in another field i need, but can't find it yet.

Thank you Mohammed for the suggestions but by now still can't solve this.

Read only

0 Likes
3,351

Hi Gabriel,

SAP has a note on how to use this FM but that is for generic case....

You can raise an OSS with SAP and they will suggest in most cases they correct the bug

I would suggest to try raising an OSS for the same.

Regards

Read only

Arifi
Discoverer
3,351

I faced the same problem with movement type 311 Q and I have just solved it.

You should set the flag XMIGO = 'X' before calling the BAPI

CALL FUNCTION 'MB_SET_BAPI_FLAG'
EXPORTING
ACTION = '3'