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: 

Packing delivery

Former Member
0 Kudos

We try to create packing for a delivery using functions module

(BAPI_HU_CREATE, WS_DELIVERY_UPDATE, etc..). We are not able to do it, is there anaybody who have made that kind of think before. If you can show us some example.

Regards,

5 REPLIES 5

Former Member
0 Kudos

Are you creating packing from SO or PO ?

Former Member
0 Kudos

It is for SO, outbound delivery.

Regards.

0 Kudos

Hi!

I am having a problem to do the packing for an outbound delivery as well. Did you solve your problems?

Did any of the Bapis worked?

Thanks in advance!

Nisha

Former Member
0 Kudos

Hi,

Yes it work, look at this code:

METHOD emballer_pieces.

TYPES: BEGIN OF ty_vekp,

venum TYPE vekp-venum,

exidv TYPE vekp-exidv,

END OF ty_vekp.

DATA: lta_verko TYPE STANDARD TABLE OF verko,

lta_verpo TYPE STANDARD TABLE OF verpo,

lta_prott TYPE STANDARD TABLE OF prott,

lts_vekp TYPE SORTED TABLE OF ty_vekp

WITH UNIQUE KEY venum.

DATA: lst_zcs005 TYPE zcs005s,

lst_vbkok TYPE vbkok,

lst_verko TYPE verko,

lst_verpo TYPE verpo,

lst_bal_s_msg TYPE bal_s_msg,

lst_vekpvb TYPE vekpvb,

lst_vekp TYPE ty_vekp.

DATA: lwa_tdlnr TYPE j_3o_v07-tdlnr,

lwa_venum TYPE vepo-venum,

lwa_tabix TYPE sy-tabix.

DATA: ltpb_valide TYPE boolean,

ltpb_retrait TYPE boolean,

ltpn_bloque TYPE i.

tps_etape = text-005.

LOOP AT ta_zcs005 INTO lst_zcs005 WHERE NOT selec IS INITIAL.

IF NOT lst_zcs005-tmeng IS INITIAL.

IF lst_vbkok IS INITIAL.

lst_vbkok-vbeln_vl = st_zcs004-vbeln. "delivery number

lst_vbkok-vbtyp_vl = co_livraison. "delivery number

lst_vbkok-vbeln = st_zcs004-vbeln. "delivery number

lst_verko-exidv = '$'. "HU a creer

lst_verko-exida = 'C'.

lst_verko-vstel = st_zcs004-vstel.

lst_verko-vhilm = wa_emballage.

lst_verko-ntgew = st_zcs004-brgew.

lst_verko-laeng = st_zcs004-laeng.

lst_verko-breit = st_zcs004-breit.

lst_verko-hoehe = st_zcs004-hoehe.

lst_verko-btvol = lst_verko-laeng * lst_verko-breit * lst_verko-hoehe.

lst_verko-voleh_max = co_volume.

IF NOT lst_verko-voleh_max IS INITIAL.

CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT'

EXPORTING

input = lst_verko-voleh_max

IMPORTING

output = lst_verko-voleh_max.

ENDIF.

IF NOT st_zcs004-meabm IS INITIAL.

CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT'

EXPORTING

input = st_zcs004-meabm

IMPORTING

output = lst_verko-meabm.

ENDIF.

lst_verko-brgew = st_zcs004-brgew.

IF NOT st_zcs004-gewei IS INITIAL.

CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT'

EXPORTING

input = st_zcs004-gewei

IMPORTING

output = lst_verko-gewei.

ENDIF.

lst_verko-gewei_max = lst_verko-gewei.

APPEND lst_verko TO lta_verko.

ENDIF.

ELSE.

ltpb_retrait = 1.

ENDIF.

CLEAR lst_verpo.

lst_verpo-exidv_ob = '$'.

lst_verpo-velin = '1'. " 1 to pack a material in a HU

lst_verpo-vbeln = st_zcs004-vbeln.

lst_verpo-posnr = lst_zcs005-posnr.

lst_verpo-tmeng = lst_zcs005-tmeng.

lst_verpo-vrkme = lst_zcs005-vrkme.

lst_verpo-werks = lst_zcs005-werks.

lst_verpo-lgort = lst_zcs005-lgort.

CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'

EXPORTING

input = lst_zcs005-zpcsnr

IMPORTING

output = lst_verpo-matnr.

APPEND lst_verpo TO lta_verpo.

ENDLOOP.

IF NOT lst_vbkok IS INITIAL.

IF NOT st_zcs004-tknum IS INITIAL.

CALL METHOD lcl_gerer_service=>dequeue_trsp_avis

EXPORTING

i_tknum = st_zcs004-tknum

i_qmnum = ''.

ENDIF.

CALL METHOD lcl_gerer_service=>sauve_modification

EXPORTING

i_retrait = ltpb_retrait

IMPORTING

e_valide = ltpb_valide.

IF NOT ltpb_valide IS INITIAL.

IF NOT st_zcs004-laeng IS INITIAL AND

NOT st_zcs004-breit IS INITIAL AND

NOT st_zcs004-hoehe IS INITIAL AND

NOT st_zcs004-meabm IS INITIAL AND

NOT st_zcs004-brgew IS INITIAL AND

NOT st_zcs004-gewei IS INITIAL.

REFRESH ta_vekpvb.

CALL FUNCTION 'WS_DELIVERY_UPDATE'

EXPORTING

vbkok_wa = lst_vbkok

synchron = co_select

commit = co_select

delivery = st_zcs004-vbeln

nicht_sperren = space

TABLES

prot = lta_prott

verko_tab = lta_verko

verpo_tab = lta_verpo

et_created_hus = ta_vekpvb.

IF lta_prott IS INITIAL.

SELECT venum exidv INTO TABLE lts_vekp

FROM vekp

WHERE vpobj = '01'

AND vpobjkey = st_zcs004-vbeln.

LOOP AT ta_vekpvb INTO lst_vekpvb.

lwa_tabix = sy-tabix.

READ TABLE lts_vekp WITH KEY venum = lst_vekpvb-venum

TRANSPORTING NO FIELDS.

IF sy-subrc <> 0.

DELETE ta_vekpvb INDEX lwa_tabix.

ENDIF.

ENDLOOP.

READ TABLE lts_vekp INTO lst_vekp INDEX 1.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = st_zcs004-tdlnr

IMPORTING

output = lwa_tdlnr.

SELECT SINGLE tdlnr INTO lwa_tdlnr

FROM j_3o_v07

WHERE tdlnr = lwa_tdlnr

AND matnr = wa_emballage

AND spras = sy-langu.

IF sy-subrc = 0.

CALL METHOD lcl_gerer_service=>imprimer_etiquette

IMPORTING

e_valide = ltpb_valide.

ENDIF.

IF NOT ltpb_valide IS INITIAL.

*Impression bon de livraison

CALL METHOD lcl_gerer_service=>imprime_bon_livraison

EXPORTING

i_venum = lst_vekp-venum.

ENDIF.

CALL METHOD lcl_gerer_service=>valide_saisie_transport

EXPORTING

i_mode = co_select.

IF ta_zcs005 IS INITIAL AND st_zcs004-sttrg <> co_load_end.

CALL METHOD lcl_gerer_service=>modifie_statut_transport.

CALL METHOD lcl_gerer_service=>valide_saisie_transport

EXPORTING

i_mode = co_select.

ENDIF.

ELSE.

CLEAR lst_bal_s_msg.

lst_bal_s_msg-msgno = '062'.

lst_bal_s_msg-msgid = 'ZCS_GENERALE'.

CALL METHOD lcl_gerer_service=>ajout_message_erreur

EXPORTING

i_msgno = lst_bal_s_msg-msgno

i_msgid = lst_bal_s_msg-msgid

i_etape = tps_etape.

ENDIF.

REFRESH ta_vekpvb.

ELSE.

CLEAR lst_bal_s_msg.

lst_bal_s_msg-msgno = '062'.

lst_bal_s_msg-msgid = 'ZCS_GENERALE'.

CALL METHOD lcl_gerer_service=>ajout_message_erreur

EXPORTING

i_msgno = lst_bal_s_msg-msgno

i_msgid = lst_bal_s_msg-msgid

i_etape = tps_etape.

ENDIF.

ENDIF.

IF NOT st_zcs004-tknum IS INITIAL.

CALL METHOD lcl_gerer_service=>enqueue_trsp_avis

EXPORTING

i_tknum = st_zcs004-tknum

i_qmnum = ''

i_mess = ''

i_repete = 6

IMPORTING

e_verouille = ltpn_bloque.

IF NOT ltpn_bloque IS INITIAL.

MESSAGE a072(zcs_generale) WITH st_zcs004-tknum sy-msgv1.

ENDIF.

ENDIF.

ELSE.

CLEAR lst_bal_s_msg.

lst_bal_s_msg-msgno = '061'.

lst_bal_s_msg-msgid = 'ZCS_GENERALE'.

CALL METHOD lcl_gerer_service=>ajout_message_erreur

EXPORTING

i_msgno = lst_bal_s_msg-msgno

i_msgid = lst_bal_s_msg-msgid

i_etape = tps_etape.

ENDIF.

IF NOT wa_balloghndl IS INITIAL.

CALL METHOD lcl_gerer_service=>affiche_protocole.

ENDIF.

ENDMETHOD. "emballer_pieces

Regards,

Daniel Cantin

Former Member
0 Kudos

Hi Daniel/Nisha,

Here is the simple method way of doing,

DATA: ls_mm_data TYPE hum_plant_stloc,

ls_hdr_main TYPE huhdr_proposal,

ls_ref_obj TYPE hum_object,

ls_hu_items TYPE huitm_proposal,

ls_vekpvb TYPE vekpvb,

ls_lips TYPE lips.

DATA: lt_hu_items TYPE huitm_prop,

lt_lips TYPE STANDARD TABLE OF lips,

et_vekpvb TYPE STANDARD TABLE OF vekpvb.

CLEAR: ls_hdr_main, ls_ref_obj, ls_lips, ls_mm_data, ls_vekpvb.

REFRESH: lt_lips[], lt_hu_items[], et_vekpvb[].

ls_hdr_main-exidv = '$'.

ls_ref_obj-object = '01'.

ls_ref_obj-objkey = v_vbeln " Delivery number.

SELECT * FROM lips INTO TABLE lt_lips

WHERE vbeln = v_vbeln.

LOOP AT lt_lips INTO ls_lips.

CLEAR ls_hu_items.

ls_hu_items-exidv = '$'.

ls_hu_items-velin = '1'.

ls_hu_items-belnr = ls_lips-vbeln.

ls_hu_items-posnr = ls_lips-posnr.

ls_hu_items-quantity = ls_lips-lifmg.

ls_hu_items-meins = ls_lips-meins.

ls_hu_items-matnr = ls_lips-matnr.

ls_hu_items-werks = ls_lips-werks.

ls_hu_items-lgort = ls_lips-lgort.

APPEND ls_hu_items TO lt_hu_items.

ENDLOOP.

ls_mm_data-plant = ls_lips-werks.

ls_mm_data-stge_loc = ls_lips-lgort.

CALL FUNCTION 'PROCESS_HU_INBOUND_DLVRY'

EXPORTING

i_packing_activity = 'PACK'

i_pack_type = 'MAT'

i_hu_id = ' '

i_new_hu = 'X'

i_create_hu = 'X'

i_reference_object = ls_ref_obj

i_mm_data = ls_mm_data

i_hu_header_main = ls_hdr_main

i_hu_items = lt_hu_items[]

i_save_step = 'ITEM'

i_pack_activity = 'MAT'

i_delivery_type = 'J'

TABLES

et_created_hus = et_vekpvb

EXCEPTIONS

input_missing = 1

not_possible = 2

header_error = 3

item_error = 4

serial_nr_error = 5

fatal_error = 6

operation_failed = 7

delivery_update_error = 8

OTHERS = 9.

IF sy-subrc EQ 0.

ENDIF.

Thanks,

Meg