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

Inserting Batch Split Items in Delivery

Former Member
0 Likes
8,486

Hi Folks,

a very quick question. I was mining for info to get the batchsplit items inserted into an Outbound delivery thru the FM WS_DELIVERY_UPDATE sometime ago. Out of doubt and tight schedule I had to opt for BDC which is not that elegant and I would like to know if anyone of you gurus has managed to insert batch split items for a normal item in a delivery. A sample piece of code would be just what I am looking for, suggestions are invited

thanks a lot in advance.

ZAM

15 REPLIES 15
Read only

FredericGirod
Active Contributor
0 Likes
3,561

Hi ZAMUser,

I have played with batch-split Items, this is a little part of the code. In this code I try to update quantity of the delivery. Maybe that will help you

Regards

Frédéric

(comments are in french, and I play with special messages and text)

*   Livraison
    refresh wlt_btc.
    move : 'SAPMV50A'    to wlt_btc-program ,
           '4004'        to wlt_btc-dynpro ,
           'X'           to wlt_btc-dynbegin.
    append wlt_btc.
    clear  wlt_btc.
    move : 'BDC_OKCODE'  to wlt_btc-fnam ,
           '/00'         to wlt_btc-fval .
    append wlt_btc.
    clear  wlt_btc.
    move : 'LIKP-VBELN'    to wlt_btc-fnam ,
           wlt_badge-vbeln to wlt_btc-fval .
    append wlt_btc.
    clear  wlt_btc.

*   PoPo.
    move : 'SAPMV50A'    to wlt_btc-program ,
           '1000'        to wlt_btc-dynpro ,
           'X'           to wlt_btc-dynbegin.
    append wlt_btc.
    clear  wlt_btc.
    move : 'BDC_OKCODE'  to wlt_btc-fnam ,
           '=POPO_T'     to wlt_btc-fval .
    append wlt_btc.
    clear  wlt_btc.

*   Poste.
    if wlt_badge-uecha eq '00000000'.
      move wlt_badge-posnr to wlv_poste.
    else.
      move wlt_badge-uecha to wlv_poste.
    endif.
    move : 'SAPMV50A'    to wlt_btc-program ,
           '0111'        to wlt_btc-dynpro ,
           'X'           to wlt_btc-dynbegin.
    append wlt_btc.
    clear  wlt_btc.
    move : 'BDC_OKCODE'  to wlt_btc-fnam ,
           '=WEIT'       to wlt_btc-fval .
    append wlt_btc.
    clear  wlt_btc.
    move : 'RV50A-POSNR' to wlt_btc-fnam ,
           wlv_poste     to wlt_btc-fval .
    append wlt_btc.
    clear  wlt_btc.

*   Marque le poste
    move : 'SAPMV50A'    to wlt_btc-program ,
           '1000'        to wlt_btc-dynpro ,
           'X'           to wlt_btc-dynbegin.
    append wlt_btc.
    clear  wlt_btc.
    if wlt_badge-uecha ne '00000000'.
      move : 'BDC_OKCODE'  to wlt_btc-fnam ,
             '=CHSP_T'     to wlt_btc-fval .
    else.
      move : 'BDC_OKCODE'  to wlt_btc-fnam ,
             '=IDET_T'     to wlt_btc-fval .
    endif.
    append wlt_btc.
    clear  wlt_btc.
    move : 'BDC_CURSOR'     to wlt_btc-fnam ,
           'LIPS-POSNR(01)' to wlt_btc-fval .
    append wlt_btc.
    clear  wlt_btc.

    if wlt_badge-uecha ne '00000000'.
*     Recherche le sous poste.
      move : 'SAPMV50A'    to wlt_btc-program ,
             '3000'        to wlt_btc-dynpro ,
             'X'           to wlt_btc-dynbegin.
      append wlt_btc.
      clear  wlt_btc.
      move : 'BDC_OKCODE'  to wlt_btc-fnam ,
             '=POPO_T'     to wlt_btc-fval .
      append wlt_btc.
      clear  wlt_btc.

*     Sous Poste.
      move : 'SAPMV50A'    to wlt_btc-program ,
             '0111'        to wlt_btc-dynpro ,
             'X'           to wlt_btc-dynbegin.
      append wlt_btc.
      clear  wlt_btc.
      move : 'BDC_OKCODE'  to wlt_btc-fnam ,
             '=WEIT'       to wlt_btc-fval .
      append wlt_btc.
      clear  wlt_btc.
      move : 'RV50A-POSNR'   to wlt_btc-fnam ,
             wlt_badge-posnr to wlt_btc-fval .
      append wlt_btc.
      clear  wlt_btc.

*     Marque le sous poste
      move : 'SAPMV50A'    to wlt_btc-program ,
             '3000'        to wlt_btc-dynpro ,
             'X'           to wlt_btc-dynbegin.
      append wlt_btc.
      clear  wlt_btc.
      move : 'BDC_OKCODE'  to wlt_btc-fnam ,
             '=CDET_T'     to wlt_btc-fval .
      append wlt_btc.
      clear  wlt_btc.
      move : 'BDC_CURSOR'     to wlt_btc-fnam ,
             'LIPS-POSNR(01)' to wlt_btc-fval .
      append wlt_btc.
      clear  wlt_btc.
    endif.



*   Onglet Qtt
    move : 'SAPMV50A'    to wlt_btc-program ,
           '3000'        to wlt_btc-dynpro ,
           'X'           to wlt_btc-dynbegin.
    append wlt_btc.
    clear  wlt_btc.
    if wlt_badge-uecha ne '00000000'.
      move : 'BDC_OKCODE'  to wlt_btc-fnam ,
             '=T04'       to wlt_btc-fval .
    else.
      move : 'BDC_OKCODE'  to wlt_btc-fnam ,
             '=T05'       to wlt_btc-fval .
    endif.
    append wlt_btc.
    clear  wlt_btc.

*   Mise à jour Qtt livrée
    move : 'SAPMV50A'    to wlt_btc-program ,
           '3000'        to wlt_btc-dynpro ,
           'X'           to wlt_btc-dynbegin.
    append wlt_btc.
    clear  wlt_btc.
    move : 'BDC_OKCODE'  to wlt_btc-fnam ,
           '=SICH_T'     to wlt_btc-fval .
    append wlt_btc.
    clear  wlt_btc.
    move : 'LIPS-LFIMG'  to wlt_btc-fnam ,
           wlv_poids     to wlt_btc-fval .
    append wlt_btc.
    clear  wlt_btc.



*   Appels du call transaction.
    call transaction 'VL02N'  using wlt_btc
                              mode  'N'
                              update 'S'
                              messages into wlt_error.
    sort wlt_error by msgid msgnr.
*   Binary search
    read table wlt_error
         with key msgid = 'ZTPL'
                  msgnr = '011'
         binary search.
    if sy-subrc eq space.
      message i011(ztpl) with wlt_error-msgv1 wlt_error-msgv2.
    else.
      read table wlt_error
           with key msgid = 'ZTPL'
                    msgnr = '010'
           binary search.
      if sy-subrc eq space.
        message i010(ztpl) with wlt_error-msgv1 wlt_error-msgv2.
      else.
*       Pas de binary search pour la recherche d'erreur
        read table wlt_error
             transporting no fields
             with key msgtyp = 'E'.
        if sy-subrc eq space.
          message i398(00) with text-e01.
        else.
*         Mise à jours des masses dans les textes au niveau des postes
*         de livraison.
          concatenate wlt_lips-vbeln
                      wlt_lips-posnr
                      into wlv_tdname.
*         Masse net.
          move : 'VBBP'     to wls_thead-tdobject ,
                 wlv_tdname to wls_thead-tdname ,
                 'YP09'     to wls_thead-tdid ,
                 wlv_langu  to wls_thead-tdspras.
          move : wlt_bascule-poids to wls_tdline-tdline ,
                 '*'               to wls_tdline-tdformat .
          refresh wlt_tdline.
          append wls_tdline to wlt_tdline.
          call function 'SAVE_TEXT'
            exporting
              header                = wls_thead
              savemode_direct       = 'X'
            tables
              lines                 = wlt_tdline
            exceptions
              id                    = 1
              language              = 2
              name                  = 3
              object                = 4
              others                = 5.
*         Masse brut.
          move : 'YP07'            to wls_thead-tdid ,
                 wlt_bascule-poid2 to wls_tdline-tdline ,
                 '*'               to wls_tdline-tdformat.
          refresh wlt_tdline.
          append wls_tdline to wlt_tdline.
          call function 'SAVE_TEXT'
            exporting
              header                = wls_thead
              savemode_direct       = 'X'
            tables
              lines                 = wlt_tdline
            exceptions
              id                    = 1
              language              = 2
              name                  = 3
              object                = 4
              others                = 5.
*         Tare.
          move : 'YP08'            to wls_thead-tdid ,
                 wlt_bascule-poid3 to wls_tdline-tdline ,
                 '*'               to wls_tdline-tdformat.
          refresh wlt_tdline.
          append wls_tdline to wlt_tdline.
          call function 'SAVE_TEXT'
            exporting
              header                = wls_thead
              savemode_direct       = 'X'
            tables
              lines                 = wlt_tdline
            exceptions
              id                    = 1
              language              = 2
              name                  = 3
              object                = 4
              others                = 5.
        endif.
      endif.
    endif.

Read only

Former Member
0 Likes
3,561

thanks for the reply VJ, however i need a standard FM/BAPI to do the job. I am also looking at

WS_DELIVERY_UPDATE_2 which updates OUTBOUND DELIVERIES.

Let me know if you have anyother solution.

thanks

Raj

Read only

former_member378318
Contributor
0 Likes
3,561

Hi,

I had a similar requirement but was unable to find a FM or BAPI to perform multiple batch split on an outbound delivery. You can use WS_DELIVERY_UPDATE/2 to allocate a single batch number but it won't perform batch split.

I believe there is a BAPI available from 4.7 that allows you to perform multiple batch split called BAPI_OUTB_DELIVERY_CHANGE, I have not used it but from the documentation it looks possible.

The function VB_BATCH_DETERMINATION will tell you if need to allocate a single batch number or need to perform batch spilt.

In the end I used a combination of WS_DELIVERY_UPDATE2 and Batch Input. Using WS_DELIVERY_UPDATE2 when I needed to allocate a single batch number and batch input when batch split was needed.

Read only

0 Likes
3,561

Let me know if you find a way.

Read only

0 Likes
3,561

HI! I want to insert batch split items in delivery. How can this be done.

Can you let me know how did u resolve this issue using bapi with a sample piece of code

Read only

Former Member
0 Likes
3,561

I guess BAPI or WS_DELIVERY_UPDATE FM will not work.

Try with

VB_CREATE_BATCH - or

BAPI_BATCH_CREATE

Thanks

Seshu

Read only

0 Likes
3,561

Hi Seshu,

Thanks for the reply. I checked the bapi and function module that you gave me. Those function modules are for creation of Batches for material. This is done using transaction MSC1N.

But in my case batches has already been created. I want to insert batch split.

Say I have a delivery XXXX and item ITM1. It has a material MAT1 with quantity 5.

I want to change this to

delivery XXXX item ITM1 material MAT1 batch B1 quantity 3.

delivery XXXX item ITM1 material MAT1 batch B2 quantity 2.

I came to know that we can use BAPI_OUTB_DELIVERY_CHANGE for this. I am not able to find the right inputs. Can you check?

Regards, Senthil G

Read only

3,561

Hi

Use BAPI_OUTB_DELIVERY_CHANGE.

Fill Delivery number in HEADER_DATA and HEADER_CONTROL structures. Pass Delivery number in DELIVERY parameter.

Fill ITEM_DATA. first line in itab with regular delievery line and next lines with the batch items.

First line -

DELIV_NUMB -Pass Delivery number

DELIV_ITEM - Pass the delivry item number

MATERIAL - Pass Material Number

DLV_QTY - Pass the final balance quantity after the batch split

For the rest of the entries in the ITEM_DATA tables fill the following fields

DELIV_NUMB -Pass Delivery number

DELIV_ITEM - Pass the delivery batch item number (For eg, 900001)

MATERIAL - Pass Material Number

BATCH - Pass the batch number

HIERARITEM - Pass the delivery item number

DLV_QTY - Pass the quantity of the batch item

and other relevant fields

In ITEM_CONTROL itab

Pass delviery number, delivery item number and 'X' to CHG_DELQTY field.

This should split the line item after Commit.

Reward if found helpful.

Thanks

Prasad

Read only

0 Likes
3,561

Dear Prasad Ji

I have 1 sale order with multiple line items and different batches...i wanna design a z program to create partial deliveries of that sale order considering batches...

which bapi should i use???

Thanks

Read only

0 Likes
3,561

Hello Prasad,

After almost 8 years, greetings from Portugal Your post has been extremely useful to me.

Regards,

João

Read only

jainsaras18
Explorer
3,561

For someone still looking for an answer to this: here's the key to achieve Batch Split using BAPI_OUTB_DELIVERY_CHANGE

In ITEM_DATA, pass 1st line with main Delivery Line (e.g. 000010) with 0 Delivery Qty and pass 2nd line with Item = 900001, Batch & Qty.

In ITEM_CONTROL, pass 1st line with main Delivery Line (e.g. 000010) with Blank in CHG_DELQTY and pass 2nd line with Item = 900001 and X in CHG_DELQTY.

I achieved this after wasting one whole day.

Read only

0 Likes
3,561

I have been working that problem. I have been trying much test data. One of them was as you mentioned.

I have also read the SAP document. It made similiar comments.

In ITEM_DATA,

DELIV_NUMB = 80000093 DELIV_ITEM = 000010

DELIV_NUMB = 80000093 DELIV_ITEM=900001 MATERIAL=3000000090001 BATCH=1000000798 HIERARITEM=000010 USEHIERITM=1 DLV_QTY=4 DLV_QTY_IMUNIT=4

ITEM_CONTROL.


DELIV_NUMB=80000093 DELIV_ITEM=000010 CHG_DELQTY

DELIV_NUMB80000093 DELIV_ITEM900001 CHG_DELQTYX


Read only

0 Likes
3,561

I tried with same way...but it is not working ...it is not updating the delivery.

Please provide data with all fiedls that we need to fill in bapi.

thanks

Read only

0 Likes
3,561

I tried with same way...but it is not working ...it is not updating the delivery.

Please provide data with all fiedls that we need to fill in bapi.

thanks

Read only

former_member664245
Discoverer
3,561
When I did it this way, I couldn't run it.