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: 

Delete handling unit

Former Member
0 Kudos

Hello All,

I am working on a dev in which i have to delete handling unit from delivery doc ...

If handling unit is not empty then it should unpack and then delete the handling unit from the delivery doc.

I need a function module or a BAPI to delete a handling unit from delivery doc.

Also if there is a function module to NEST handling unit...

Please let me know.

This is a very critical requirement.

Thanks,

Prasad.

27 REPLIES 27

Former Member
0 Kudos

Apart from removing the handling unit from the delivery, do you want to delete the handling unit itself?

Look at function modules with the pattern HU_. The ones that will be particular interest to you will be HU_UNPACK, HU_DELETE* and HU_DELIV.

I will give you the exact ones once I get to the system.

Srinivas

0 Kudos

Hello Srinivas,

All the function modules which SAP has given are without Object referance that is a SAD part i have done enough reserch on this.

Please let me know If you find anything.

Prasad.

0 Kudos

Hi Prasad

Did you manage to do what you wanted?

I have the same requirement.

I have looked at several function modules, including those mentioned by Srinivas, but none seem to work.

WS_DELIVERY_UPDATE_2 does not work, as it asks for a target HU to pack the items into.

The HU* function modules that Srinivas mentions does not work on delivery related HUs, similarly the BAPIs in FUGR HU_BASIC_BAPIS.

I have debugged VL02n and copied some of the code, but obviously not enough, as the HU is deleted, but the items are not returned to the delivery, and the document flow still references the HU.

Vince

0 Kudos

Hi all

I have the same problem. I need to delete HUs from a delivery via FM. Did anybody knows if FM WS_DELIVERY_UPDATE works for that? Has anybody had an example?

Thanks and regards

0 Kudos

1. To first unpack

select single exidv into <VAR1>-unpack_exid from vekp

where venum = <HU-venum>.

call function 'BAPI_HU_UNPACK'

exporting

hukey = <HU> (type exidv)

itemunpack = <VAR1>

tables

return = return.

2. to Delete

call function 'HU_DELETE_HU'

exporting

if_with_lower = 'X'

if_venum = venum

exceptions

not_found = 1

not_possible = 2

snr_problem = 3

fatal_error = 4

others = 5.

if sy-subrc = 0.

call function 'HU_POST'

exporting

if_no_rename = 'X'

if_no_messages = 'X'

  • if_commit = 'X'

is_object = object "just a variable

importing

et_messages = message.

0 Kudos

Hi

I regret to tell you that the solution given by Srinivas does not work. After calling function HU_DELETE_HU, sy-subrc is equal to 1, so it could not found the handling unit. I had a problem like this last week using functions BAPI_HU_CREATE and BAPI_HU_CHANGE_HEADER. Last one returns the same error when I tried assigning a HU to a delivery. I posted a note to SAP and the reply was changing these two FM by WS_DELIVERY_CREATE for creating HUs and assinginig them to a delivery. So I still have the same problem, how can i unassign a HU and delete it?

Thanks and best regards

0 Kudos

Hi Munoz,

Is there a possibility of using a BDC Call transaction instead of BAPIS/Function Modules?

Ravi

0 Kudos

Hi

It's a possibility we want to avoid. We want to use BAPIS/FM for this.

Thanks

0 Kudos

Just to give everyone an update...

I had suspected that Srinivas's suggestions would not work, as I had tried those function modules with all sorts of parameters, prior to my original posting.

BDC is no good for me either, as we are trying to do this in a cancel tranfer order transaction user exit.

Munoz mentioned using WS_DELIVERY_UPDATE, however, this is essentially WS_DELIVERY_UPDATE_2 (look at the code - I suspect SAP has updated the code and just called the new code from the old FM to avoid problems in code where the old FM is used), and the problems I had with that is already documented.

Logged a call to SAP; it will be interesting to see if I get the same response as Munoz.

0 Kudos

If you have any good (or bad) notice from SAP for this topic, please don´t forget to post it. I have posted another call to SAP and I´m waiting for response. If I have something new, I will post it here.

About using WS_DELIVERY_UPDATE/WS_DELIVERY_UPDATE_2 I have achieved to delete all HUS assigned to a delivery, but I only want to delete one of them. I am not able to make that using those FM,

Of course BDC is the last last option for us.

Thanks and regards

0 Kudos

Hi Munoz

Thanks for your reply.

SAP replied to my message and said it was consulting, as I think they have misunderstood what we wanted. I have since rephrased the message, so hopefully they will progress it further.

How did you manage to delete all HUs with WS_DELIVERY_UPDATE?

When I tried it, it asks for a target HU to pack the items into. The quantities I tried with were negative values as I read somewhere that the quantities you post with are an adjustment to what is already on the HU.

Sample working code would be much appreciated as we are not concerned with selectively deleting HUs.

TIA

Regards

Vincent

0 Kudos

Hi Vincent

SAP replied the same to me. I post the complete resonse:

Dear Customer,

The nature of your request indicates that this is a consulting issue

rather than a software error. Customer Support's charter, under the SAP

maintenance agreement, is to handle software or system defects in the

standard delivered R/3 product. The function you are trying to acheive

is not released in the standard system and therefore will require a

system modification. Please see note 109533.

If you need assitance from SAP to modify the system to meet your businesrequirement you can contact our remote consulting service and they will

be able to advise you further. (See note 83020

for further details of that process)

Sorry for this answer and for the inconveniences.

Thanks for your cooperation.

It seems it is not posible to do what we want.

I write down sample code I have tested for deleting all HUs assigned to a delivery. I think maybe could be a problem, I don't pack the items into the HU, I only assign the HU to the delivery. If you pack the materials into the HU, this might not work properly. Try it and then tell me if works in your case.

vbkok_wa-vbeln = '0187000063'.

vbkok_wa-vbeln_vl = '0187000063'.

vbkok_wa-vbtyp_vl = 'J'.

i_verko-object = '01'.

i_verko-objkey = '0187000063'.

APPEND i_verko.

CLEAR i_hus.

REFRESH i_hus.

CALL FUNCTION 'WS_DELIVERY_UPDATE'

EXPORTING

vbkok_wa = vbkok_wa

synchron = 'X'

  • NO_MESSAGES_UPDATE = ' '

commit = 'X'

delivery = '0187000063'

  • UPDATE_PICKING = ' '

nicht_sperren = ' '

IF_CONFIRM_CENTRAL = 'X'

  • IF_WMPP = ' '

  • IF_GET_DELIVERY_BUFFERED = ' '

  • IF_NO_GENERIC_SYSTEM_SERVICE = ' '

  • IF_DATABASE_UPDATE = '1'

  • IF_NO_INIT = ' '

  • IF_NO_READ = ' '

  • IF_ERROR_MESSAGES_SEND_0 = 'X'

  • IF_NO_BUFFER_REFRESH = ' '

  • IF_NO_MES_UPD_PACK = ' '

  • IMPORTING

  • EF_ERROR_ANY_0 =

  • EF_ERROR_IN_ITEM_DELETION_0 =

  • EF_ERROR_IN_POD_UPDATE_0 =

  • EF_ERROR_IN_INTERFACE_0 =

  • EF_ERROR_IN_GOODS_ISSUE_0 =

  • EF_ERROR_IN_FINAL_CHECK_0 =

TABLES

  • VBPOK_TAB =

  • prot = i_prott

verko_tab = i_verko

  • VERPO_TAB =

  • VBSUPCON_TAB =

  • IT_VERPO_SERNR =

  • IT_PACKING =

  • IT_PACKING_SERNR =

  • IT_REPACK =

  • IT_HANDLING_UNITS =

et_created_hus = i_hus.

Regards

0 Kudos

Hi Munoz

That worked! Thank you very much for that.

Sorry for not replying earlier; I am only at this customer once a week.

Where I was going wrong was trying to unpack the handling units by adjusting the amounts and flagging them for deletion:

<ProgramExtractBegin>

tables: ltak,

vekp,

vepo.

data: l_vbkok like vbkok,

lt_verko like verko occurs 0 with header line,

lt_verpo like verpo occurs 0 with header line,

lt_et_created_hus

like vekpvb occurs 0 with header line.

parameters: p_vbeln like likp-vbeln memory id vl.

l_vbkok-vbeln_vl = p_vbeln.

select * from vekp

where vpobj = '01'

and vpobjkey = p_vbeln.

move-corresponding vekp to: lt_verko,

lt_ET_CREATED_HUS.

lt_verko-status = lt_et_created_hus-status = '0060'.

append: lt_verko,

lt_ET_CREATED_HUS.

select * from vepo

where venum = vekp-venum.

move-corresponding vepo to lt_verpo.

lt_verpo-tmeng = vepo-vemng * -1.

append lt_verpo.

endselect.

endselect.

call function 'WS_DELIVERY_UPDATE_2'

exporting

vbkok_wa = l_vbkok

SYNCHRON = 'X'

  • NO_MESSAGES_UPDATE_1 = ' '

  • COMMIT = ' '

delivery = p_vbeln

  • UPDATE_PICKING = ' '

  • NICHT_SPERREN_1 = ' '

  • IF_CONFIRM_CENTRAL = ' '

  • IF_WMPP = ' '

  • IF_GET_DELIVERY_BUFFERED = ' '

  • IF_NO_GENERIC_SYSTEM_SERVICE = ' '

  • IF_DATABASE_UPDATE_1 = '1'

  • IF_NO_INIT_1 = ' '

  • IF_NO_READ_1 = ' '

  • IF_ERROR_MESSAGES_SEND = 'X'

  • IF_NO_BUFFER_REFRESH = ' '

  • IT_PARTNER_UPDATE =

  • IT_SERNR_UPDATE =

  • IF_NO_REMOTE_CHG_1 = ' '

  • IF_NO_MES_UPD_PACK = ' '

  • IMPORTING

  • EF_ERROR_ANY =

  • EF_ERROR_IN_ITEM_DELETION =

  • EF_ERROR_IN_POD_UPDATE =

  • EF_ERROR_IN_INTERFACE =

  • EF_ERROR_IN_GOODS_ISSUE =

  • EF_ERROR_IN_FINAL_CHECK =

  • EF_ERROR_PARTNER_UPDATE =

  • EF_ERROR_SERNR_UPDATE =

tables

  • VBPOK_TAB =

  • PROT =

verko_tab = lt_verko

verpo_tab = lt_verpo

  • VBSUPCON_TAB_1 =

  • IT_VERPO_SERNR =

  • IT_PACKING =

  • IT_PACKING_SERNR =

  • IT_REPACK =

  • IT_HANDLING_UNITS_1 =

  • IT_OBJECTS =

ET_CREATED_HUS = lt_ET_CREATED_HUS

  • TVPOD_TAB =

.

<ProgramExtractEnd>

When I run this it complains about a target HU to pack them into.

I guess the main difference was that you passed empty itabs for both VERPO_TAB and ET_CREATED_HUS, whereas I didn't.

Given the above experience, I think I now understand how this FM works. If you want to selectively delete HUs, you need to supply the HUs you wish to keep on the delivery in itab ET_CREATED_HUS, in the manner I have coded above. You will not have to pass VERPO_TAB, as you have nothing packed into the HUs.

I have tried it and it works!

So the code should now look something like this:

.

.

if HU wanted. "psuedo code - your condition

move-corresponding vekp to: lt_verko,

lt_ET_CREATED_HUS.

append: lt_verko,

lt_ET_CREATED_HUS.

endif.

.

.

Regards

Vincent

0 Kudos

Hi Vincent

Thanks for your reply.

I regret to tell you that your solution does not work in my case. I have tested your example but it doesn't work. I have made some changes in it but in every test i have made, the HU is not deleted.

I have understood that I have to supply HUs that I DON'T want to delete in itab ET_CREATED_HUS and the HUs that I need to erase doesn't have to be supplied in any itab isn't it? I have one more doubt, what must i supply in itab lt_verko? All HUs assigned to the delivery? Nothing?

Example: Delivery 187000063 have assigned 3 HUs:

1000000851

1000000852

1000000853

And I want to delete 1000000851.

I think content of itab ET_CREATED_HUS will be something like that:

MANDT VENUM EXIDV EXIDA VSTEL LSTEL ......

600 |0000000607|1000000852|E |PE01 | |......

600 |0000000608|1000000852|E |PE01 | |......

Is that correct? What will be content on itab lt_verko?

Maybe I didn't understand your explanation properly.

Can you help me?

Thanks a lot

Regards

Message was edited by: Munoz Carrasco

0 Kudos

Hi Munoz

The code definitely works, as I have tested it removing one HU of two.

You have understood me correctly in that you have to supply the HUs that must NOT BE DELETED in itab ET_CREATED_HUS; the ones you want to delete should just be missing from the itab.

In VERKO_TAB (LT_VERKO being the actual parameter in my example), you also need to list the HUs you wish to keep.

I do not know what the contents will be, as I am not at that customer today; you need to look at my previous code. I had set up ET_CREATED_HUS with a move-corresponding from VEKP; do the same for VERKO_TAB.

So my previous example code, slightly expanded further, and with your example data:

select * from vekp

where vpobj = '01'

and vpobjkey = '187000063'.

if vekp-exidv in ('1000000852', '1000000852').

move-corresponding vekp

to: lt_verko, lt_ET_CREATED_HUS.

append: lt_verko, lt_ET_CREATED_HUS.

endif.

endselect.

As your HUs are not packed, you do not have to set up VERPO_TAB.

Incidentally, SAP replied to our message, saying what we wanted could not be done:

<Quote>

I have consulted with my colleagues who specialise in HUM and shipping functionality. There is categorically no other way of unpacking and deleting a HU other than using the standard VL02n transaction.

You can create your own functionality to do this if you wish, but the functionality is not available in the standard code and I have been informed that this will not be available in any future releases.

<snip>

<EndQuote>

0 Kudos

Hi Vincent

I'm sure i have copied your example correctly, but it doesn't work. Simply, it does not delete anything. This is the complete code I have tested, can you check it please?

This code is only a test, so I put a manual check for the HUs that I want to keep. I'm using always the same delivery (187000063) which have assigned 4 HUs:

1000000855, 1000000856, 1000000857 and 1000000858. So in the code, i want to delete 1000000858.

<ProgramExtractBegin>

TABLES: ltak,

vekp,

vepo.

DATA: l_vbkok LIKE vbkok,

lt_verko LIKE verko OCCURS 0 WITH HEADER LINE,

lt_verpo LIKE verpo OCCURS 0 WITH HEADER LINE,

lt_et_created_hus LIKE vekpvb OCCURS 0 WITH HEADER LINE.

PARAMETERS: p_vbeln LIKE likp-vbeln MEMORY ID vl.

l_vbkok-vbeln_vl = p_vbeln.

SELECT * FROM vekp

WHERE vpobj EQ '01'

AND vpobjkey EQ p_vbeln.

IF vekp-exidv EQ '00000000001000000855' OR

vekp-exidv EQ '00000000001000000856' OR

vekp-exidv EQ '00000000001000000857'.

MOVE-CORRESPONDING vekp TO: lt_verko,

lt_et_created_hus.

lt_verko-status = lt_et_created_hus-status = '0060'.

APPEND: lt_verko,

lt_et_created_hus.

ENDIF.

ENDSELECT.

CALL FUNCTION 'WS_DELIVERY_UPDATE_2'

EXPORTING

vbkok_wa = l_vbkok

synchron = 'X'

  • NO_MESSAGES_UPDATE_1 = ' '

  • COMMIT = ' '

delivery = p_vbeln

  • UPDATE_PICKING = ' '

  • NICHT_SPERREN_1 = ' '

  • IF_CONFIRM_CENTRAL = ' '

  • IF_WMPP = ' '

  • IF_GET_DELIVERY_BUFFERED = ' '

  • IF_NO_GENERIC_SYSTEM_SERVICE = ' '

  • IF_DATABASE_UPDATE_1 = '1'

  • IF_NO_INIT_1 = ' '

  • IF_NO_READ_1 = ' '

  • IF_ERROR_MESSAGES_SEND = 'X'

  • IF_NO_BUFFER_REFRESH = ' '

  • IT_PARTNER_UPDATE =

  • IT_SERNR_UPDATE =

  • IF_NO_REMOTE_CHG_1 = ' '

  • IF_NO_MES_UPD_PACK = ' '

  • IMPORTING

  • EF_ERROR_ANY =

  • EF_ERROR_IN_ITEM_DELETION =

  • EF_ERROR_IN_POD_UPDATE =

  • EF_ERROR_IN_INTERFACE =

  • EF_ERROR_IN_GOODS_ISSUE =

  • EF_ERROR_IN_FINAL_CHECK =

  • EF_ERROR_PARTNER_UPDATE =

  • EF_ERROR_SERNR_UPDATE =

TABLES

  • VBPOK_TAB =

  • PROT =

verko_tab = lt_verko

  • verpo_tab =

  • VBSUPCON_TAB_1 =

  • IT_VERPO_SERNR =

  • IT_PACKING =

  • IT_PACKING_SERNR =

  • IT_REPACK =

  • IT_HANDLING_UNITS_1 =

  • IT_OBJECTS =

et_created_hus = lt_et_created_hus

  • TVPOD_TAB =

<ProgramExtractEnds>

Maybe we are using diferent SAP Releases. I'm working with a release 4.6C. Or maybe we have not the same level of support packages. I don't know why this code didn't work for me.

I apologize for the problems that I might causing to you.

Thanks and regards

0 Kudos

Hi Munoz

Sorry for not replying earlier as I have been very busy at another client and this is only the first opportunity I have been back at the client in question.

To answer your question:

SAP 4.7 patch level SAPKB62038

Remove the line of code:

lt_verko-status = lt_et_created_hus-status = '0060'.

this was my INITIAL attempt at marking the HUs as deleted and it does not work!

I also notice that l_vbkok is not set up the same way as I have done, nor are some flags on the FM call...

so using and changing your code:

<ProgramExtractBegin>

TABLES: ltak,

vekp,

vepo.

DATA: l_vbkok LIKE vbkok,

lt_verko LIKE verko OCCURS 0 WITH HEADER LINE,

lt_verpo LIKE verpo OCCURS 0 WITH HEADER LINE,

lt_et_created_hus LIKE vekpvb OCCURS 0 WITH HEADER LINE.

PARAMETERS: p_vbeln LIKE likp-vbeln MEMORY ID vl.

l_vbkok-vbtyp_vl = 'J'.

l_vbkok-vbeln = l_vbkok-vbeln_vl = p_vbeln.

SELECT * FROM vekp

WHERE vpobj EQ '01'

AND vpobjkey EQ p_vbeln.

IF vekp-exidv EQ '00000000001000000855' OR

vekp-exidv EQ '00000000001000000856' OR

vekp-exidv EQ '00000000001000000857'.

MOVE-CORRESPONDING vekp TO: lt_verko,

lt_et_created_hus.

APPEND: lt_verko,

lt_et_created_hus.

ENDIF.

ENDSELECT.

CALL FUNCTION 'WS_DELIVERY_UPDATE_2'

EXPORTING

vbkok_wa = l_vbkok

synchron = 'X'

  • NO_MESSAGES_UPDATE_1 = ' '

COMMIT = 'X'

delivery = p_vbeln

  • UPDATE_PICKING = ' '

  • NICHT_SPERREN_1 = ' '

IF_CONFIRM_CENTRAL = 'X'

  • IF_WMPP = ' '

  • IF_GET_DELIVERY_BUFFERED = ' '

  • IF_NO_GENERIC_SYSTEM_SERVICE = ' '

  • IF_DATABASE_UPDATE_1 = '1'

  • IF_NO_INIT_1 = ' '

  • IF_NO_READ_1 = ' '

  • IF_ERROR_MESSAGES_SEND = 'X'

  • IF_NO_BUFFER_REFRESH = ' '

  • IT_PARTNER_UPDATE =

  • IT_SERNR_UPDATE =

  • IF_NO_REMOTE_CHG_1 = ' '

  • IF_NO_MES_UPD_PACK = ' '

  • IMPORTING

  • EF_ERROR_ANY =

  • EF_ERROR_IN_ITEM_DELETION =

  • EF_ERROR_IN_POD_UPDATE =

  • EF_ERROR_IN_INTERFACE =

  • EF_ERROR_IN_GOODS_ISSUE =

  • EF_ERROR_IN_FINAL_CHECK =

  • EF_ERROR_PARTNER_UPDATE =

  • EF_ERROR_SERNR_UPDATE =

TABLES

  • VBPOK_TAB =

  • PROT =

verko_tab = lt_verko

  • verpo_tab =

  • VBSUPCON_TAB_1 =

  • IT_VERPO_SERNR =

  • IT_PACKING =

  • IT_PACKING_SERNR =

  • IT_REPACK =

  • IT_HANDLING_UNITS_1 =

  • IT_OBJECTS =

et_created_hus = lt_et_created_hus

  • TVPOD_TAB =

<ProgramExtractEnds>

You may need to change the arguments on the FM call.

For example, I used the code in the middle of another transaction, so for that I set...

COMMIT = ' '

NICHT_SPERREN_1 = 'X'

as we do not want a commit in the middle of a transaction, nor do we wish to lock objects which have already been locked by the transaction.

Give that a go, good luck, and let us know how you get on!

regards

Vince

0 Kudos

Hi Vincent

I've been on holidays and today is my first day after them. Now I'm working with another topic, but the first I have time for check your last code, i'll try it and tell everybody if at last I'm able to delete HUs from a delivery.

Thanks a lot for all your time!!!

Best Regards and Merry Christmas!!!

0 Kudos

That code works!!!!

Thank you very much, Vincent

Regards

0 Kudos

No problems Munoz

Glad to be of help!

In any case, it was your sample code which provided the break-through for me, so in a way you helped yourself!

Regards

Vincent

0 Kudos

Hello All,

I am glad i initiated this subject ....To be very frank..

i thought i am the only one who is facing this problem..

I have gone through all your replies and all the post related to this topic...

The solution given by Vince to all of us..

WS_DELIVERY_UPDATE2...seems to be working ...BUT...

when you use IF_CONFIRM_CENTRAL = 'X' SAP littary refreshes all the packing data....

though you can see all the EXIDVS are intact in packing screen....

But all the VENUMS are changed....in VEKP it is as good

as reassigning everything...

and this will definately affect all the labels and forms which are dependent on handling unit..

I don't know if anybody has observed this...

Please let me know if we can avoid this.

Thanks,

Prasad.

0 Kudos

Prasad,

I'm having the same problem as you. Vince's code works but only if you use IF_CONFIRM_CENTRAL option which refreshes all HU assignments.

Has anyone solved this issue?

Regards,

Adam

Former Member
0 Kudos

This appears to work(please confirm)

    
    CALL FUNCTION 'HU_PACKING_REFRESH'.

    CALL FUNCTION 'HU_GET_HUS'
        EXPORTING
           if_lock_hus = 'X'
           it_venum    = it_venum.     "it_venum contains l_venum

    CALL FUNCTION 'V51F_DELETE_HU'
        EXPORTING
           if_venum    = l_venum.

    CALL FUNCTION 'HU_POST'.

0 Kudos

Hi,

I am facing same kind of problem.

When i create a handling unit and using the fm ws_delivery_update_2, it is updating the output type twice.

Let me elaborate the scenario.

For that particular delivery already handling units are there. When i create a handling unit, the output type will be assigned to that particular hu. but in my case it is doing that as well as it is appending the same output type to the existing hu's.

I don't know how it is getting updated.

Do we have any solution to this??

Regards,

Arun.

Former Member
0 Kudos

Hi there,

why you not using BDC to delete handling units?I did that using BDC and it works fine

0 Kudos

to BrightSide

BDC works fine, but blocks the docflow

I have same problem

0 Kudos

BAPI_HU_DELETE_FROM_DEL can be used to delete HU from delivery.