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: 

Function module/BAPI to delete assignments as VL02n

Former Member
0 Kudos
2,669

In my program I have a requirement to delete assignment which is done through VL02n

Following are the steps followed:

1. Enter the outbound delivery no. in VL02n

2. Click on Pack button

3. In Pack Material tab, select all Handling Units and click Delete assignment button.

I want this functionality to be written in my program. I debugged and found the FM V51P_DELETE_RELATIONSHIP.

Following is my code:

   CALL FUNCTION 'V51P_DELETE_RELATIONSHIP'
    EXPORTING
      if_control  = 'X'
      it_hus      = lt_venum      "table which contains all the Internal HU number associated with the delivery
    IMPORTING
      et_new_hus  = lt_hus
      et_messages = lt_messages
    EXCEPTIONS
      fatal_error = 1
      OTHERS      = 2.

But this doesn't help. Is there any other steps that are supposed to be followed after this or should I use a different FM?

Please give inputs on this...

9 REPLIES 9

former_member196490
Active Participant
0 Kudos
758

Please try the BAPI 'BAPI_HU_DELETE_FROM_DEL'

0 Kudos
758

Thanks for the quick reply. BAPI_HU_DELETE_FROM_DEL will delete the Handling Units, but to my requirement Handling units need to be only deassigned from the delivery.

Former Member
0 Kudos
758

Hi Rajan,

CALL FUNCTION 'V51P_DELETE_RELATIONSHIP'

    EXPORTING

      if_control  = 'X'

      it_hus      = lt_venum      "table which contains all the Internal HU number associated with the delivery

    IMPORTING

      et_new_hus  = lt_hus

      et_messages = lt_messages

    EXCEPTIONS

      fatal_error = 1

      OTHERS      = 2.

Is the above code giving some error? If not then maybe changes would be happening but not getting written to DB, so try calling BAPI_TRANSACTION_COMMIT after this FM.

BR.

0 Kudos
758

The code populates lt_messages with message "Handling unit  is packed - only entire HUs can be reassigned" for all the HUs (but sy-subrc = 0).The same error I get while doing manually through VL02n also, but I can still go back and save the changes which results in all the handling units getting deassigned from the delivery.

I have BAPI_TRANSACTION_COMMIT too after this, but no effect.

0 Kudos
758

Hi Raja,

I am afraid that you cannot achieve this requirement with BAPI because BAPIs simulate the transaction behavior and if you cannot do directly via transaction then BAPIs would also fail to do so. May be you need to check some configuration which might be preventing you deassigning. This is just a guess.

BR.

0 Kudos
758

Thanks Ankit for the suggestion. Let me check the configuration and see if that is the issue.

0 Kudos
758

Hi Raja,

Did you ever solve this issue?

I have the same requirement and have the same error: Handling unit &1 is packed - only entire HUs can be reassigned in FM.

This is the same error that comes in VL02N but in the standard it shows the error and then REMOVES the assignments.

Please share your solution!

Regards,

Fernanda

former_member41806
Discoverer
0 Kudos
758

Hi, check this thread.

It works fine for me.

Function Modules to Unassign HU from a Outbound... | SCN

kirill_smirnov
Explorer
0 Kudos
758

Hi RajaRajan,

Did you try to use 'BAPI_HU_CHANGE_HEADER'? I used this function module to assign HU to delivery, so I'm pretty sure that it should work for unassignment as well (try to clear PACK_MAT_OBJ and PACK_MAT_OBJ_KEY in HUCHANGED structure).

Cheers,

Kirill