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: 

Create an inbound delivery for a purchase order ( Similar to Vl31N )

nishanthbhandar
Contributor
0 Kudos

Hi All,

Is there a BAPI using which we can create an inbound delivery for a purchase order similar to the way that we manually create the same using VL31N.

Cheers

Nishanth

1 ACCEPTED SOLUTION

Former Member
0 Kudos

search in SE37 with string BAPIINBOUND

and also see the documention of that BAPI's.

All,

Kindly do not post the answers for the sake of getting points.<b>---->nowhere i asked for ur POINTS? keep in mind ,i am here not get points, just help peoples? ur points is just like a **** for me. Customer satisfaction is IMP for me</b>

Please answer if you have a genuine answer as i have already tried sufficiently like <b>---->DONT use words like that , i dont have SAP systesm to give DUMP of BAPIs , that is the way to search.How will i know u already searched for it ?</b>

If u are that much Intelligent , cannt u find out the BAPI ?

<b>dont u know , we cannt do mass changes by using any kind of FM BAPI's.</b>

Regards

prabhu

8 REPLIES 8

Former Member
0 Kudos

search in SE37 with string BAPIINBOUND

and also see the documention of that BAPI's.

All,

Kindly do not post the answers for the sake of getting points.<b>---->nowhere i asked for ur POINTS? keep in mind ,i am here not get points, just help peoples? ur points is just like a **** for me. Customer satisfaction is IMP for me</b>

Please answer if you have a genuine answer as i have already tried sufficiently like <b>---->DONT use words like that , i dont have SAP systesm to give DUMP of BAPIs , that is the way to search.How will i know u already searched for it ?</b>

If u are that much Intelligent , cannt u find out the BAPI ?

<b>dont u know , we cannt do mass changes by using any kind of FM BAPI's.</b>

Regards

prabhu

Former Member
0 Kudos

Hi

Delivery related BAPI's are:

BAPI_DELIVERYPROCESSING_EXEC

BAPI_INB_DELIVERY_CHANGE

BAPI_INB_DELIVERY_CONFIRM_DEC

BAPI_INB_DELIVERY_SAVEREPLICA

BAPI_OUTB_DELIVERY_CHANGE

BAPI_OUTB_DELIVERY_CONFIRM_DEC

BAPI_OUTB_DELIVERY_SAVEREPLICA

BAPI_OUTB_DELIVERY_SPLIT_DEC

Fun modules

SHP_VL10_DELIVERY_CREATE

SHP_VL10_DELIVERY_CREATE_PARA

GN_DELIVERY_CREATE

GN_DELIVERY_CREATE_FD_POST

GN_DELIVERY_CREATE_FOR_DIALOG

RV_DELIVERY_CREATE

RV_DELIVERY_CREATE_SINGLE

RV_DELIVERY_CREATE_SINGLE_POST

Check them

Reward if useful

regards,

Anji

Message was edited by:

Anji Reddy Vangala

nishanthbhandar
Contributor
0 Kudos

All,

Kindly do not post the answers for the sake of getting points.Please answer if you have a <b>genuine answer</b> as i have already tried sufficiently like

Matching pattern search in SE37

Exploring BAPI's,IDOC's,FM's

I have also debugged the transactions VL10G and VL34 which perform mass creation of deliveries.

Cheers

Nishanth

nishanthbhandar
Contributor
0 Kudos

Mr Prabhu Peram,

Why are you getting so jumpy about my request ? Your language is not very encouraging .. Please do not post such rude replies ..

I would not have posted the question if i was intelligent enough to solve the same.Anyway thanks for your answer.

Nishanth

0 Kudos

SORRY now onwards , <b>I</b> will try to give/post <b>GENUINE</b> answers only.

So <b>I</b> can also get <b>points.</b>

Regards

prabhu

nishanthbhandar
Contributor

I finally found the solution to creating the inbound delivery for a PO.We have to use the FM GN_DELIVERY_CREATE exactly the same way as it is called in the program RM06EANL.( This is the program for VL34 transaction ).

Cheers

Nishanth

The sample function module which i created for the same is pasted below : Hope this helps all future users:

FUNCTION zinbound_delivery_create_po.

*"----


""Local interface:

*" IMPORTING

*" REFERENCE(FI_PURCHASE_ORDER) TYPE EBELN

*" REFERENCE(FI_DELIVERY_DATE) TYPE SY-DATLO DEFAULT SY-DATLO

*" EXPORTING

*" REFERENCE(FE_INBOUND_DELIVERY) TYPE LIKP-VBELN

*" EXCEPTIONS

*" INVALID_PURCHASE_ORDER

*" NO_ITEMS_IN_PURCHASE_ORDER

*" PURCHASE_ORDER_LOCKED

*" OPEN_QUANTITY_NOT_FOUND

*" NUMBER_RANGE_NOT_DETERMINED

*"----


TYPE-POOLS v50s .

*C-- Internal tables

DATA : tl_ekpo TYPE STANDARD TABLE OF ekpo WITH HEADER LINE,

tl_xeket TYPE STANDARD TABLE OF eket WITH HEADER LINE,

tl_eket TYPE STANDARD TABLE OF beket WITH HEADER LINE,

tl_xkomdlgn TYPE STANDARD TABLE OF komdlgn WITH HEADER LINE,

tl_xvbfs TYPE STANDARD TABLE OF vbfs WITH HEADER LINE,

tl_xvbls TYPE STANDARD TABLE OF vbls WITH HEADER LINE,

tl_xlips TYPE STANDARD TABLE OF lips WITH HEADER LINE,

tl_xekkn TYPE STANDARD TABLE OF ekkn WITH HEADER LINE,

tl_sernr TYPE v50s_sern_t WITH HEADER LINE.

*C-- Work areas

DATA : wa_ekko TYPE ekko,

wa_vbsk TYPE vbsk,

wa_tvsa TYPE tvsa,

wa_lfm1 TYPE lfm1.

STATICS: l_grkor LIKE lips-grkor,

l_bsmng LIKE ekpo-menge.

CALL FUNCTION 'MESSAGES_INITIALIZE'.

CLEAR tl_xkomdlgn.

*C-- Read the purchase order header details

CLEAR wa_ekko.

SELECT SINGLE *

FROM ekko

INTO wa_ekko

WHERE ebeln = fi_purchase_order.

IF sy-subrc NE 0.

RAISE invalid_purchase_order.

ELSE.

*C-- Lock the purchase order for processing

CALL FUNCTION 'ENQUEUE_EMEKKOS'

EXPORTING

ebeln = fi_purchase_order

EXCEPTIONS

foreign_lock = 2

system_failure = 3.

IF sy-subrc EQ 0.

CALL FUNCTION 'ENQUEUE_EMEKPOE'

EXPORTING

ebeln = fi_purchase_order

EXCEPTIONS

foreign_lock = 2

system_failure = 3.

IF sy-subrc NE 0.

RAISE purchase_order_locked.

ENDIF.

ELSE.

RAISE purchase_order_locked.

ENDIF.

*C-- Read the item details of the purchase order

CLEAR : tl_ekpo,

tl_ekpo[].

SELECT *

FROM ekpo

INTO TABLE tl_ekpo

WHERE ebeln EQ fi_purchase_order.

IF sy-subrc NE 0.

PERFORM release_order USING fi_purchase_order.

RAISE no_items_in_purchase_order.

ELSE.

LOOP AT tl_ekpo.

SELECT *

FROM eket

INTO TABLE tl_xeket

WHERE ebeln EQ tl_ekpo-ebeln

AND ebelp EQ tl_ekpo-ebelp.

*C-- Obtain the open quantity in the purchase order items

IF sy-subrc EQ 0.

LOOP AT tl_xeket WHERE eindt LE fi_delivery_date.

IF tl_xeket-menge GT tl_xeket-dabmg.

tl_eket-ebeln = tl_ekpo-ebeln.

tl_eket-ebelp = tl_ekpo-ebelp.

tl_eket-etenr = tl_xeket-etenr.

tl_eket-lpein = tl_xeket-lpein.

tl_eket-uzeit = tl_xeket-uzeit.

tl_eket-eindt = tl_xeket-eindt.

tl_eket-charg = tl_xeket-charg.

tl_eket-licha = tl_xeket-licha.

IF tl_xeket-dabmg GT tl_xeket-wemng.

tl_eket-menge = tl_xeket-menge - tl_xeket-dabmg.

ELSE.

tl_eket-menge = tl_xeket-menge - tl_xeket-wemng.

ENDIF.

IF tl_eket-menge GT 0.

APPEND tl_eket.

ENDIF.

ENDIF.

ENDLOOP.

IF tl_eket-menge IS INITIAL.

PERFORM release_order USING fi_purchase_order.

RAISE open_quantity_not_found.

ENDIF.

*C-- Fill the FM input parameters

CLEAR wa_vbsk.

wa_vbsk-mandt = sy-mandt.

wa_vbsk-ernam = sy-uname.

wa_vbsk-erdat = sy-datum.

wa_vbsk-uzeit = sy-uzeit.

wa_vbsk-smart = 'L'.

SELECT SINGLE *

FROM tvsa

INTO wa_tvsa

WHERE smart EQ wa_vbsk-smart.

IF sy-subrc EQ 0.

CALL FUNCTION 'NUMBER_GET_NEXT'

EXPORTING

nr_range_nr = wa_tvsa-numki

object = 'RV_SAMMG'

IMPORTING

number = wa_vbsk-sammg

EXCEPTIONS

OTHERS = 01.

IF sy-subrc NE 0.

PERFORM release_order USING fi_purchase_order.

RAISE number_range_not_determined.

ENDIF.

ELSE.

PERFORM release_order USING fi_purchase_order.

RAISE number_range_not_determined.

ENDIF.

LOOP AT tl_eket.

IF NOT wa_ekko-lifnr IS INITIAL.

CALL FUNCTION 'VENDOR_MASTER_DATA_SELECT_12'

EXPORTING

pi_lifnr = wa_ekko-lifnr

pi_ekorg = wa_ekko-ekorg

IMPORTING

pe_lfm1 = wa_lfm1

EXCEPTIONS

no_entry_found = 1

OTHERS = 2.

tl_xkomdlgn-vsbed = wa_lfm1-vsbed.

ELSE.

CLEAR tl_xkomdlgn-vsbed.

ENDIF.

tl_xkomdlgn-adrnr_li = wa_ekko-adrnr.

tl_xkomdlgn-lifnr = wa_ekko-lifnr.

tl_xkomdlgn-inco1 = wa_ekko-inco1.

tl_xkomdlgn-inco2 = wa_ekko-inco2.

tl_xkomdlgn-exnum = wa_ekko-exnum.

tl_xkomdlgn-bukrs_best = wa_ekko-bukrs.

tl_xkomdlgn-matnr = tl_ekpo-matnr.

tl_xkomdlgn-werks = tl_ekpo-werks.

tl_xkomdlgn-lgort = tl_ekpo-lgort.

tl_xkomdlgn-vrkme = tl_ekpo-meins.

tl_xkomdlgn-meins = tl_ekpo-lmein.

tl_xkomdlgn-umvkz = tl_ekpo-umrez.

tl_xkomdlgn-umvkn = tl_ekpo-umren.

IF tl_ekpo-matnr EQ space.

tl_xkomdlgn-meins = tl_ekpo-meins.

tl_xkomdlgn-umvkz = 1.

tl_xkomdlgn-umvkn = 1.

ENDIF.

tl_xkomdlgn-insmk = tl_ekpo-insmk.

tl_xkomdlgn-kzfme = tl_ekpo-kzfme.

tl_xkomdlgn-kzvbr = tl_ekpo-kzvbr.

tl_xkomdlgn-lfimg = tl_eket-menge.

tl_xkomdlgn-lfdat = tl_eket-eindt.

tl_xkomdlgn-lfuhr = tl_eket-uzeit.

tl_xkomdlgn-vgbel = tl_ekpo-ebeln.

tl_xkomdlgn-vgpos = tl_ekpo-ebelp.

tl_xkomdlgn-lfart = 'EL'.

tl_xkomdlgn-vgtyp = 'V'.

tl_xkomdlgn-kzazu = 'X'.

tl_xkomdlgn-knttp = tl_ekpo-knttp.

tl_xkomdlgn-sobkz = tl_ekpo-sobkz.

IF tl_ekpo-matnr IS INITIAL OR tl_ekpo = '6'.

tl_xkomdlgn-posar = 'B'.

ENDIF.

tl_xkomdlgn-ematn = tl_ekpo-ematn.

tl_xkomdlgn-mfrnr = tl_ekpo-mfrnr.

tl_xkomdlgn-mfrpn = tl_ekpo-mfrpn.

tl_xkomdlgn-emnfr = tl_ekpo-emnfr.

tl_xkomdlgn-cuobj = tl_ekpo-cuobj.

tl_xkomdlgn-uebto = tl_ekpo-uebto.

tl_xkomdlgn-untto = tl_ekpo-untto.

tl_xkomdlgn-uebtk = tl_ekpo-uebtk.

tl_xkomdlgn-lichn = tl_eket-licha.

tl_xkomdlgn-charg = tl_eket-charg.

tl_xkomdlgn-bwtar = tl_ekpo-bwtar.

tl_xkomdlgn-kdmat = tl_ekpo-idnlf.

tl_xkomdlgn-arktx = tl_ekpo-txz01.

tl_xkomdlgn-mfrgr = tl_ekpo-mfrgr.

tl_xkomdlgn-gewei = tl_ekpo-gewei.

tl_xkomdlgn-voleh = tl_ekpo-voleh.

tl_xkomdlgn-ntgew = tl_ekpo-ntgew * tl_xkomdlgn-lfimg.

tl_xkomdlgn-brgew = tl_ekpo-brgew * tl_xkomdlgn-lfimg.

tl_xkomdlgn-volum = tl_ekpo-volum * tl_xkomdlgn-lfimg.

tl_xkomdlgn-ean11 = tl_ekpo-ean11.

tl_xkomdlgn-aktnr = tl_ekpo-aktnr.

tl_xkomdlgn-abeln = tl_ekpo-abeln.

tl_xkomdlgn-abelp = tl_ekpo-abelp.

tl_xkomdlgn-aurel = tl_ekpo-aurel.

tl_xkomdlgn-idnlf = tl_ekpo-idnlf.

tl_xkomdlgn-matkl = tl_ekpo-matkl.

CLEAR tl_xkomdlgn-grkor.

CLEAR tl_xkomdlgn-kmpmg.

CLEAR tl_xkomdlgn-uepos.

CLEAR tl_xkomdlgn-uepvw.

IF tl_ekpo-upvor CA '3X'.

l_grkor = l_grkor + 1.

tl_xkomdlgn-grkor = l_grkor.

l_bsmng = tl_ekpo-menge.

ENDIF.

IF NOT tl_ekpo-uebpo IS INITIAL AND

tl_ekpo-uptyp CA '3X'.

tl_xkomdlgn-uepvw = 'G'.

tl_xkomdlgn-uepos = tl_ekpo-uebpo.

tl_xkomdlgn-grkor = l_grkor.

IF l_bsmng NE 0.

tl_xkomdlgn-kmpmg = tl_ekpo-menge / l_bsmng.

ENDIF.

ENDIF.

IF tl_ekpo-pstyp EQ '2'.

tl_xkomdlgn-sobkz = 'K'.

ENDIF.

IF tl_ekpo-sobkz EQ 'E' OR tl_ekpo-sobkz EQ 'Q'.

CALL FUNCTION 'MMPUR_EKKN_READ_EBELN_EBELP'

EXPORTING

pi_ebeln = tl_ekpo-ebeln

pi_ebelp = tl_ekpo-ebelp

TABLES

pto_ekkn_po = tl_xekkn

EXCEPTIONS

no_records_requested = 1

OTHERS = 2.

IF sy-subrc EQ 0.

READ TABLE tl_xekkn INDEX 1.

tl_xkomdlgn-ps_psp_pnr = tl_xekkn-ps_psp_pnr.

tl_xkomdlgn-vbelv = tl_xekkn-vbeln.

tl_xkomdlgn-posnv = tl_xekkn-vbelp.

ENDIF.

ENDIF.

*C-- Fill in serial numbers

DO tl_eket-menge TIMES.

tl_sernr-rfbel = tl_xkomdlgn-rfbel.

tl_sernr-rfpos = tl_xkomdlgn-rfpos.

tl_sernr-sernr = tl_sernr-sernr + 1.

APPEND tl_sernr.

ENDDO.

APPEND tl_xkomdlgn.

ENDLOOP.

*C-- Call the delivery FM

CALL FUNCTION 'GN_DELIVERY_CREATE'

EXPORTING

vbsk_i = wa_vbsk

TABLES

xkomdlgn = tl_xkomdlgn

xvbfs = tl_xvbfs

xvbls = tl_xvbls

xxlips = tl_xlips

it_gn_sernr = tl_sernr.

CALL FUNCTION 'BORGR_DELIVERY_CREATE_AUTOGR'.

COMMIT WORK.

READ TABLE tl_xlips INDEX 1.

IF sy-subrc EQ 0.

fe_inbound_delivery = tl_xlips-vbeln.

ENDIF.

ELSE.

PERFORM release_order USING fi_purchase_order.

RAISE open_quantity_not_found.

ENDIF.

ENDLOOP.

ENDIF.

ENDIF.

CLEAR : tl_ekpo,

tl_xeket,

tl_eket,

tl_xkomdlgn,

tl_xvbfs,

tl_xvbls,

tl_xlips,

tl_xekkn,

tl_sernr.

REFRESH : tl_ekpo,

tl_eket,

tl_xkomdlgn,

tl_xvbfs,

tl_xvbls,

tl_xlips,

tl_xekkn,

tl_sernr.

CLEAR : wa_ekko,

wa_vbsk,

wa_tvsa,

wa_lfm1.

CLEAR: l_grkor,

l_bsmng.

ENDFUNCTION.

&----


*& Form release_order

&----


  • Release the lock on the purchase order in process

----


form release_order using fp_ebeln.

*C-- Release the purchase order.

CALL FUNCTION 'DEQUEUE_EMEKKOS'

EXPORTING

ebeln = fp_ebeln.

endform. " release_order

0 Kudos

thx:

for the note for "EXNUM", had two days research to copy custom data from PO to delivery, easy solution to use the exnum of the PO in lt_komdlgn-exnum for CALL FUNCTION 'GN_DELIVERY_CREATE'.

Former Member
0 Kudos

Excellent work Nishanth. This will be very useful for the interfaces related tot he third party shipments.

good job.