Skip to Content

VL02N - USER EXIT AFTER LENDING DOCUMENT CREATED

HI,

I'M LOOKING FOR USER EXIT OR BADI WHICH I CAN USE FOR CALL BAPI_GOODSMVT_CREATE. THIS MUST BE DONE AFTER LENDING DOCUMENT WAS CREATED. MM CONSULTANT SAD THAT LENDING DOCUMENT NUMBER RELATED WITH SOURCE DOCUMENT IS STORED IN MSEG. BUT MSEG IN FORM MV50AFZ1 PROGRAM MV50AFZ1 IS EMPTY.

CAN YOU HELP ME?

THX

LECHOO

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    Posted on Dec 11, 2013 at 03:31 PM

    Solution is:

    DATA: lv_aufnr TYPE aufnr,

    lv_mblnr TYPE mblnr,

    lv_mjahr TYPE mjahr,

    ls_goodsmvt_header TYPE bapi2017_gm_head_01,
    ls_goodsmvt_code TYPE bapi2017_gm_code,
    ls_goodsmvt_headret TYPE bapi2017_gm_head_ret,

    lt_goodsmvt_item TYPE STANDARD TABLE OF bapi2017_gm_item_create,
    ls_goodsmvt_item LIKE LINE OF lt_goodsmvt_item,

    lt_return TYPE STANDARD TABLE OF bapiret2,
    ls_return LIKE LINE OF lt_return.

    IF lips-bwart = '631' AND sy-ucomm = 'WABU_T'. " WABU_T - Post Goods Issue button

    **********************************************************************
    *** MvT Code
    * 01 - MB01 - Goods Receipts FOR Purchase ORDER
    *
    * 02 - MB31 - Goods Receipts FOR Prod ORDER
    *
    * 03 - MB1A - Goods Issue
    *
    * 04 - MB1B - TRANSFER Posting
    *
    * 05 - MB1C - Enter Other Goods Receipt
    *
    * 06 - MB11
    **********************************************************************
    *** Movement Indicator
    * space - Goods movement w/o REFERENCE
    *
    * B - Goods movement FOR purchase ORDER
    *
    * F - Goods movement FOR production ORDER
    *
    * L - Goods movement FOR delivery note
    *
    * K - Goods movement FOR kanban requirement (WM - internal only)
    *
    * O - Subsequent adjustment OF "material-provided" consumption
    *
    * W - Subsequent adjustment OF proportion/product UNIT material
    **********************************************************************

    ls_goodsmvt_code = '03'.

    **********************************************************************
    *** HEADER
    ls_goodsmvt_header-pstng_date = likp-wadat_ist.
    ls_goodsmvt_header-doc_date = likp-bldat.
    ls_goodsmvt_header-ref_doc_no = likp-vbeln.
    ls_goodsmvt_header-bill_of_lading = likp-bolnr.
    ls_goodsmvt_header-pr_uname = sy-uname.
    **********************************************************************

    **********************************************************************
    *** ITEM
    CLEAR: lv_aufnr.

    SELECT SINGLE aufnr FROM vbak INTO lv_aufnr
    WHERE vbeln = lips-vgbel.

    ls_goodsmvt_item-ORDERID = lv_aufnr.
    ls_goodsmvt_item-material = lips-matnr .
    ls_goodsmvt_item-plant = lips-werks.
    ls_goodsmvt_item-stge_loc = lips-lgort.
    ls_goodsmvt_item-move_type = '261'.
    ls_goodsmvt_item-entry_qnt = lips-lfimg.
    ls_goodsmvt_item-entry_uom = lips-vrkme.

    APPEND ls_goodsmvt_item TO lt_goodsmvt_item.
    **********************************************************************

    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
    wait = 'X'.

    CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
    EXPORTING
    goodsmvt_header = ls_goodsmvt_header
    goodsmvt_code = ls_goodsmvt_code
    IMPORTING
    goodsmvt_headret = ls_goodsmvt_headret
    materialdocument = lv_mblnr
    matdocumentyear = lv_mjahr
    TABLES
    goodsmvt_item = lt_goodsmvt_item
    return = lt_return.

    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
    wait = 'X'.
    ENDIF.


    You can add this code to MV50AFZ1 / USEREXIT_SAVE_DOCUMEN.


    If you like this, please give me CORRECT AND HELPFUL ANSWER and rate my answer by many star.


    thx.

    Lechoo

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 06, 2013 at 10:23 AM

    Hi,

    please don't use upper case

    did you try this one : SHP_BADI_GOODS_MOVEMENT ?

    regards

    Fred

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 06, 2013 at 11:56 AM

    In VL02n you will find many exit. Search it. You can then CALL BAPI_GOODSMVT_CREATE in background task for the same.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 06, 2013 at 12:13 PM

    Hi,

    can you explain in detail whats your requirement is ... once delivery happens through vl01n after that we post goods issue.

    on post goods issue (PGI) inventory is reduced , only making delivery does not guarantee a reduction in stock. and once PGI is made a delivery document no is created which gets saved in MSEG & MKPF table.

    explain your requirement , what you need to do and why you want to use BAPI inside the VL01N/VL02N exit???

    Add a comment
    10|10000 characters needed characters exceeded

    • The first materiál document is created via the posting delivery:

      • T-code VL02N – change delivery, button Post Goods Issue.

      After that you find in Document flow some documents:

      Last of them is materiál document with Movement type 631. (this action moves the materiál from stock to the special stock W – consignment)

      This is full automatic process.


      What business needs – automatically create (after button Post Goods Issue was pressed) the second material document with Movement type 261, which moves the material from the special stock W to the consumption of the CS order (customer service order).


      How to create the second material document manually?

      1. Transaction MB1A
      2. Selection parameters:
        • Document Date: (date of GI booking of delivery)
        • Posting Date: (date of GI booking of delivery)
        • Movement Type: 261
        • Plant: 2891
        • Storage location: 2321
        • Special Stock: W
      3. Enter (go to the next screen)
      4. Next screen:
        • Order: customer service order (from document flow in delivery)

        • Customer: ship-to-party (from delivery)

        • Material: from delivery

        • Quantity: from delivery

      5. Save document.


      Verifiaction:

      • Transaction for material documents checking: MB51
      • Result:
        If you are successful you find 2 documents:
        • MvT 631 to delivery document (in field Reference)
        • MvT 261 to CS order (in field Order)

      So how can I create second document with MvT 261?

      Can You help me?

      Thank You.

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

      I trying to resolve this problem by call FM BAPI_GOODSMVT_CREATE and set MvT to 261. But I've error message "Account 51110049 requires an assignment to a CO object".

      When we post document manually by MB1A we don't have this error message and document is posted OK.

      Any ideas?

      Thank You.

      Message was edited by: Lech Dzierzawski

      STEP 01.png (6.6 kB)
      STEP 02.png (9.8 kB)
      STEP 03.PNG (137.9 kB)
      STEP 04.PNG (14.0 kB)
      STEP 05.PNG (21.3 kB)
      STEP 06.PNG (16.7 kB)

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.