Application Development 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: 

GN_DELIVERY_CREATE

Former Member
0 Kudos

Hello All,

I need to create an outbound delivery with or without reference to a Sales order using GN_DELIVERY_CREATE.

This is very critical for us and need asap.

I saw some blogs where people have successfully used it but cant see the code anywhere.

If any have used it could you please atleast let me know the parameters passed in KOMDLGN.

Appreciate your help..

Thanks Much

1 ACCEPTED SOLUTION

Former Member
0 Kudos

S/M Naveed,

here it is

http://scn.sap.com/thread/1306671

Regards

8 REPLIES 8

Former Member
0 Kudos

S/M Naveed,

here it is

http://scn.sap.com/thread/1306671

Regards

venkateswaran_k
Active Contributor
0 Kudos

Hi Naveed,

There are couple of solutions to it..  However would like to know how do you want to implement.

1.  Is it there is a z-program where you accept range of Sales Order numbers and then create delivery documents?

2. Or Within any of your program, you are creating a deliveries based on so document.

Bassed on your answer, it will be useful for us to provide you right solution

Regards,

Venkat

0 Kudos

I just need to create 1 delivery for 1 sales order . Its not a Z program but I can fetch any sales order data needed in the user exit/enhancement point.

The current process creates a delivery for a STO but we need the same for a sales order.

When I pass the STO number and item no in xkomdlgn-VGBEL and xkomdlgn-VGPOS its fine but when I do the same putting the Sales order no and item it fails with all sorts of error messages.

I tried so many different ways of filling data in xkomdlgn but most of the time I get the error "Essential parameters are not transferred...."

Thanks Much !!

Former Member
0 Kudos

check this code

  CLEAR: it_xkomdlgn,

         it_xkomdlgn[].

  LOOP AT it_output INTO wa_output WHERE selection EQ 'X'.

*Create outbound delivery is in process...

     CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'

       EXPORTING

         percentage     = sy-index

         text           = text-t05.

      wa_vbsk_i-smart   = cn_smart. "gd_smart. "'F'.

      wa_vbsk_i-ernam   = sy-uname.

      wa_vbsk_i-erdat   = sy-datum.

      it_xkomdlgn-dlvtp = cn_dlvtype. "gd_dlvtype. "'OD'.

      it_xkomdlgn-vstel = p_vstel. "gd_ship_point.

      it_xkomdlgn-vkorg = p_vkorg. "gd_salesorg.

      it_xkomdlgn-vtweg = p_vtweg. "gd_distr_chan.

      it_xkomdlgn-spart = p_spart. "gd_division.

      it_xkomdlgn-lfart = p_dtype. "gd_dlv_type.

      it_xkomdlgn-kunwe = gd_ship_to.

      it_xkomdlgn-matnr = wa_output-matnr.

      it_xkomdlgn-werks = wa_output-werks.

      it_xkomdlgn-wadat = sy-datum.

      it_xkomdlgn-lgort = wa_output-lgort.

      READ TABLE it_mat_sel WITH KEY matnr = wa_output-matnr.

      IF sy-subrc EQ 0.

        it_xkomdlgn-lfimg = it_mat_sel-qty.

      ENDIF. "IF sy-subrc EQ 0.

      it_xkomdlgn-vrkme = wa_output-meins.

      APPEND it_xkomdlgn.

      CLEAR  it_xkomdlgn.

  ENDLOOP. "LOOP AT it_output INTO wa_output WHERE selection EQ 'X'.

CALL FUNCTION 'GN_DELIVERY_CREATE'

    EXPORTING

      vbsk_i                     = wa_vbsk_i

*     no_commit                  = 'X'

      if_synchron                = 'X'

*     vbls_pos_rueck             = 'X'

*     IF_CREATE_DEC              = ' '

      if_no_deque                = 'X'

*     IT_HANDLING_UNITS          =

*     IF_QUAN_NO_CHECK           =

      if_mass_read_mat_sw        = 'X'

*     IS_DELIVERY_EXTEND         =

*     is_control                 = wa_control

*     IS_BORGR_CONTROL           =

*     IF_NO_INIT                 = ' '

      if_no_partner_dialog       = 'X'

*     IF_CHECK_UOM               = ' '

*     IMPORTING

*     VBSK_E                     =

*     ET_SPLITPROT               =

*     ET_VBADR                   =

*     ET_VBPA                    =

    TABLES

      xkomdlgn                   = it_xkomdlgn

      xvbfs                      = it_xvbfs

      xvbls                      = it_xvbls

      xxlips                     = it_xxlips

*     XVERKO                     =

*     XVERPO                     =

*     IT_GN_PARTNER              =

*     IT_GN_LIPSPO               =

*     IT_GN_LIPSRF               =

*     IT_GN_TEXTH                =

*     IT_GN_TEXTL                =

*     IT_GN_HUSERNR              =

*     IT_GN_SERNR                =

*     it_tmstmp                  = it_tmstmp

*     et_spe_vbfs                = it_et_spe_vbfs.

.

  READ TABLE it_xvbfs WITH KEY msgty = 'E'.

    IF sy-subrc EQ 0.

      CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

     MESSAGE ID it_xvbfs-msgid TYPE it_xvbfs-msgty NUMBER it_xvbfs-msgno

       WITH it_xvbfs-msgv1 it_xvbfs-msgv2 it_xvbfs-msgv3 it_xvbfs-msgv4.

    ELSE.

       CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

        EXPORTING

          wait = 'X'.

        READ TABLE it_xvbls INDEX 1.

          IF sy-subrc EQ 0.

            gd_delivery = it_xvbls-vbeln_lif.

            MESSAGE s311(vl) WITH text-t14 gd_delivery.

*           & & has been saved

*           MESSAGE s013 WITH gd_delivery .

*           Delivery w/o Ref. & has been saved

          ENDIF. "IF sy-subrc EQ 0.

* Update Post Good Issue.

        IF NOT gd_delivery IS INITIAL.

          PERFORM update_pgi.

        ENDIF. "IF NOT gd_delivery IS INITIAL.

        LOOP AT it_output INTO wa_output WHERE selection EQ 'X'.

          wa_output-delno = gd_delivery.

          MODIFY it_output FROM wa_output INDEX sy-tabix.

        ENDLOOP. "LOOP AT it_output INTO wa_ouput WHERE selectin EQ 'X'.

    ENDIF. "IF sy-subrc EQ 0.

Former Member
0 Kudos

Hello All,

I am still unsuccessful on this.  Does any one have a better idea on how to create a Delivery with reference to a Sales order using GN_DELIVERY_CREATE. I dont have option of using any other FM/BAPI.

Any help is appreciated and Points will be rewarded.

Thanks!!

0 Kudos

Dear Naveed,

In the FM - there is a table called VBLS.

In your user exit,  You need to read the sales order and item details and append them to this table.

TABLES

      XKOMDLGN STRUCTURE  KOMDLGN

      XVBFS STRUCTURE  VBFS

      XVBLS STRUCTURE  VBLS

Construct the VBLS table and pass it to the function and let me know how it works.

Regards,

Venkat

0 Kudos

Hello Venkat,

I tried filling the VBLS but still getting errors. Looks like either am missing some fields or populating incorrect flags in KOMDLGN/VBLS. There are so many flags that SAP code is looking at and I see code where it tries fill the data from VBAP to LIPS. But am not getting to the point where it fills vbak/vbap tables in the std code. they are blank when I see in Debugging

0 Kudos

Dear Naveed,

Just to confirm things.

GN_DELIVERY_CREATE is used to create inbound deliveries,

RV_DELIVERY_CREATE is used to create outbound deliveries.

In your case, since you are referring to Sales Order with GN_DELIVERY_CREATE , then you must be creating the RETURNS..

Kindly confirm

Regards,

Venkat