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

Update SLOC in Delivery using BAPI / BDC

Former Member
4,638

Hi Gurus,

My requirement is to update the storage location in an existing delivery. I tried to achieve this using BAPI " BAPI_OUTB_DELIVERY_CHANGE" and BDC of "VL02" t-code. the results are quite ambigious.

In both the approaches, Sometimes it update sloc and sometimes it doesn't.

In case of error while using BAPI, the error code is VL412.

In case of BDC, no error message is coming but in few cases sloc is not getting updated..

Request your help.

Regards,

Pankaj

18 REPLIES 18
Read only

Former Member
0 Likes
3,586

Hi,

Before using the material in delivery check whether that material is assigned with storage location in material master. This can be checked in table MARD-LGORT.

If storage location is not existing then not possible to update in delivery also. In that case you skip updating and write it to error log.

Read only

0 Likes
3,586

Hi Karun,

Thanks for the reply..

in Mard table it is there.. and apart from this i checked in SPRO tcode also... slocs are maintained correctly..

Regards,

Pankaj

Read only

Lakshmipathi
SAP Champion
SAP Champion
0 Likes
3,586

Check the following note:-

  • Note 511194 - VL02: Termination of batch input processing in background

G. Lakshmipathi

Read only

0 Likes
3,586

Hi,

Thanks a lot for the prompt reply.

Yes i checked this note and the issue exactly matches to my requirement.

Please tell how to apply this SNOTE. I tried by using SNOTE t-code, but unsuccessful..

Regards,

Pankaj

Read only

0 Likes
3,586

Hi, In order to implement it go to SNOTE in the menu options goto->download SAP note.

Provide the sap note there and download it if it is relevant for your system.

Once the note is downloaded it shall be available under sapnotes->new. Expand the hierarchy and find your note and click on execute button.

Read the note thoroughly before execution in order to take into consideration the manual steps to be performed or if there are any pre-requisites.

Thanks and Regards,

Sriranjani Chimakurthy.

Read only

0 Likes
3,586

Hi Sriranjani,

Thanks for the reply..

I agree... I tried the steps you are mentioning but this Note is different.

Can you please look into this and tell me..

Version of SAP we are using is ECC6.0

SAP_APPL Stack level is 0020

I am unable to download this snote using SNOTE t-code..

Regards,

Pankaj

Read only

0 Likes
3,586

Hi,

I tried this but this SNOTE cannot be implemented for ECC6.0 .

It is valid for 4.6C version only..

Now what shall i do..? any suggestion..

Regards,

Pankaj

Read only

0 Likes
3,586

Any take on this...

Read only

0 Likes
3,586

Has BAPI commit been given

Read only

0 Likes
3,586

Yes..

Read only

Former Member
0 Likes
3,586

Hi,

Can you clarify the below.

Is the storage location is not updated from sales order?

Are you trying to add the storage location f in delivery to complete the PGI as this mandatory field to complete the PGI ?

If YES  for the above then there are two ways to update storage location in delivery.

1. There is a configuration to update the storage location when creation delivery which may be missing in your system. For this you can contact your function team (Let me know if you need the config screen, then I will try to get it from my function team)

2. You cad add the storage location using coding in sales order user exit program MV45AFZZ.

For name is userexit_move_field_to_vbap.

You can write the coding something like the below.

   form userexit_move_field_to_vbap.

data:
    lv_lgort type lgort_d.

      clear lv_lgort.
      select single lgort into lv_lgort from mard
              where matnr = vbap-matnr
                and werks = vbap-werks.
      if sy-subrc eq 0.
        vbap-lgort = lv_lgort.
        clear lv_lgort.
      endif.

   endform.

Read only

0 Likes
3,586

Hi Karun,

Thanks for the reply..

Below is the complete scenario:

1. First i am creating a stock transport order using BAPI ' BAPI_PO_CREATE1' .

This step is working fine.

2. After this I am creating a delivery  using BAPI ' BAPI_OUTB_DELIVERY_CREATE_STO'. This is alos working fine. Delivery is getting created.

3. Thereafter In the newly created delivery, I am passing the required SLOC using BAPI 'BAPI_OUTB_DELIVERY_CHANGE'.

At this stage, issue is coming.

Regards,

Pankaj

Read only

0 Likes
3,586

Hi,

Can you paste your piece of code where you populating data to BAPI?

Read only

0 Likes
3,586

Hi,

select vbeln kunnr from likp into table it_likpn where vbeln = gv_delivery.

     select vbeln

        posnr

        vgbel

        vgpos

        matnr

        charg

        werks

        lfimg

        meins

        vrkme

        umvkz

        umvkn

        into table it_lipsn from lips

        where vbeln = gv_delivery.

     sort it_lipsn by vbeln.

     loop at it_lipsn into wa_lipsn.

     lw_item_data-deliv_numb       = wa_lipsn-vbeln.

     lw_item_data-deliv_item       = wa_lipsn-posnr.

     lw_item_data-material         = wa_lipsn-matnr.

     lw_item_data-batch            = wa_lipsn-charg.

     lw_item_data-dlv_qty          = wa_lipsn-lfimg.

     lw_item_data-dlv_qty_imunit   = wa_lipsn-lfimg.

     lw_item_data-sales_unit       = wa_lipsn-vrkme.

     lw_item_data-sales_unit_iso   = wa_lipsn-vrkme.

     lw_item_data-base_uom         = wa_lipsn-meins.

     lw_item_data-base_uom_iso     = wa_lipsn-meins.

     lw_item_data-fact_unit_nom    = wa_lipsn-umvkz.

     lw_item_data-fact_unit_denom  = wa_lipsn-umvkn.

     append lw_item_data to gi_item_data.

     lw_item_control-deliv_numb = wa_lipsn-vbeln.

     lw_item_control-deliv_item = wa_lipsn-posnr.

     lw_item_control-chg_delqty = 'X'.

     append lw_item_control to gi_item_control.

     iw_sloc-DELIV_NUMB = wa_lipsn-vbeln.

     iw_sloc-DELIV_ITEM = wa_lipsn-posnr.

     read table it_likpn into wa_likpn with key vbeln = gv_delivery.

     if sy-subrc = 0.

     call function 'CONVERSION_EXIT_ALPHA_OUTPUT'

       exporting

         input         = wa_likpn-kunnr

      IMPORTING

         OUTPUT        = clgort.

    iw_sloc-stge_loc   = clgort.

     endif.

     append iw_sloc to it_sloc.

     clear : iw_sloc.

     gw_bapiobdlvhdrchg-deliv_numb = wa_lipsn-vbeln.

     gw_bapiobdlvhdrctrlchg-deliv_numb = wa_lipsn-vbeln.

     gw_bapiobdlvhdrchg-dlv_prio = '06'.

     gw_bapiobdlvhdrctrlchg-dlv_prio_flg = 'X'.

    at end of vbeln.

     call function 'BAPI_OUTB_DELIVERY_CHANGE'

       exporting

         header_data                   = gw_bapiobdlvhdrchg

         header_control                = gw_bapiobdlvhdrctrlchg

         delivery                      = wa_lipsn-vbeln

       tables

         ITEM_DATA                     = gi_item_data

         ITEM_CONTROL                  = gi_item_control

         return                        = gi_return

         ITEM_DATA_SPL                 = it_sloc .

     call function 'BAPI_TRANSACTION_COMMIT'

       exporting

         wait = 'X'.

     clear: lw_item_data, lw_item_control,gw_bapiobdlvhdrchg,gw_bapiobdlvhdrctrlchg .

     refresh : gi_item_control,gi_item_data,gi_item_control.

     perform log_error.          .

     endat.

     endloop.

Regards,

Pankaj

Read only

0 Likes
3,586

Hi,

Are you missing conversion of material?

Can you try replace the line "lw_item_data-material         = wa_lipsn-matnr."

from your code with below conversion exit for material?


CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
  EXPORTING
    input              wa_lipsn-matnr
IMPORTING
   OUTPUT             lw_item_data-material        
EXCEPTIONS
   LENGTH_ERROR       = 1
          .

Also check all places to find if you missing any conversions.

Read only

0 Likes
3,586

Hi Karun,

I checked this in debugging mode. On fetching data from LIPS, Matnr is coming in internal format and i am passing that matnr to BAPI. So It's not an issue. I have checked for other fields also and it is fine. Moreover one important point is sometimes it is updating SLOC and simetimes it is not..

Regards,

Pankaj

Read only

0 Likes
3,586

Introduce wait upto 2 seconds statement for each commit and try.

Read only

Former Member
0 Likes
3,586

Hi Pankaj,

BAPI_TRANSACTION_COMMIT Itself has a wait command.

So try testing this BAPI explicitely from SE37 & check if the data provided is correct or not. and if the Stoarage location is getting updated or not.

Also, in this conversion exit, input field is KUNNR(Customer No. ), so in this KUNNR(10 char field) getting truncated in CLGORT(4 char Field), so may be the kunnr is getting truncated in  first 4 characters in SLOC.


     call function 'CONVERSION_EXIT_ALPHA_OUTPUT'

       exporting

         input         = wa_likpn-kunnr

      IMPORTING

         OUTPUT        = clgort.

check if this helps you.

Regards,

Ashish