Hello,

Sign up to join our community!

Welcome Back,

Please sign in to your account!

Forgot Password,

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

You must login to ask a question.

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

ABAP

ABAP Programming

Share
Followers
7 Answers
127 Questions
  1. How to Do Pallet Packing in SAP ECC (Nesting an Outer Box HU into a Pallet HU) Question I need to pack an already-built outer box (a lower-level Handling Unit) onto a pallet HU in SAP ECC using standard function modules. What's the correct sequence, and how do I build the packing request so the boxRead more

    How to Do Pallet Packing in SAP ECC (Nesting an Outer Box HU into a Pallet HU)

    Question

    I need to pack an already-built outer box (a lower-level Handling Unit) onto a pallet HU in SAP ECC using standard function modules. What’s the correct sequence, and how do I build the packing request so the box gets nested inside the pallet? Below is the approach I used.

    Answer

    The concept here is HU nesting — like Russian nesting dolls: the product sits in a box, and that box (the outer box HU) sits on a pallet (the pallet HU). This routine performs one nesting step: placing the outer box into the pallet.

    The key is to follow the standard sequence in order — Refresh → Get/Lock HUs → Pack → Post. Skipping any step (especially the refresh or the lock) is the usual cause of packing that “works once then silently fails.”

    Building the packing request (ls_pack_req):

    • venum / exidv → the target pallet HU (what you pack into)
    • sub_hu_venum / sub_hu_exidv → the content outer box HU (what gets packed)
    • pagewweight, veanz = 1 → one unit, velin = 3 → item category for HU-in-HU (packing a whole HU, not loose material)

    The four SAP standard function modules used:

    Function ModulePurpose
    HU_PACKING_REFRESHClears the HU work buffer for a clean start
    HU_GET_HUSReads and locks both HUs for exclusive access
    HU_PACKING_AND_UNPACKINGPerforms the actual packing in the buffer
    HU_POST (if_commit = 'X')Saves and commits the result to the database

    After each call, sy-subrc is checked. On failure, the SAP message is captured into the status field and the routine exits; on success, the record is stamped with status, date, time, and user.

    Code

    ls_pack_req-venum = ls_vekp_pal-venum.
    ls_pack_req-exidv = ls_vekp_pal-exidv.

    *–Fill Outerbox as lower level HU
    ls_pack_req-sub_hu_venum = ls_vekp_out-venum.
    ls_pack_req-sub_hu_exidv = ls_vekp_out-exidv.

    *–Fill quantity
    ls_pack_req-pagew = ls_pallet-pallet_wt.
    ls_pack_req-veanz = ‘1’.
    ls_pack_req-velin = ‘3’.

    ls_venom-venum = ls_vekp_out-venum.
    append ls_venom to lt_venom.
    clear ls_venom.
    ls_venom-venum = ls_vekp_pal-venum. “gs_pallet-venum.
    append ls_venom to lt_venom.
    clear ls_venom.
    *–Refresh
    call function ‘HU_PACKING_REFRESH’.
    *–Get HU headers
    call function ‘HU_GET_HUS’
    exporting
    if_object = ’04’
    if_lock_hus = ‘X’
    it_venum = lt_venom
    importing
    et_header = lt_header
    exceptions
    hus_locked = 1
    no_hu_found = 2
    fatal_error = 3
    others = 4.
    *–Do the packing
    if sy-subrc eq 0.
    call function ‘HU_PACKING_AND_UNPACKING’
    exporting
    is_packing_request = ls_pack_req
    exceptions
    missing_data = 1
    hu_not_changeable = 2
    not_possible = 3
    customizing = 4
    weight = 5
    volume = 6
    serial_nr = 7
    fatal_error = 8
    others = 9.

    if sy-subrc = 0.
    call function ‘HU_POST’
    exporting
    if_synchron = ‘X’
    if_commit = ‘X’.

    <lfs_data>-status = text-020.
    <lfs_data>-error_msg = text-s01.
    <lfs_data>-idate = sy-datum.
    <lfs_data>-itime = sy-uzeit.
    <lfs_data>-iuser = sy-uname.
    else.
    <lfs_data>-status = text-019.
    message id sy-msgid
    type sy-msgty
    number sy-msgno
    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
    into <lfs_data>-error_msg.
    lv_error = abap_true.
    lv_msg = <lfs_data>-error_msg.
    exit.
    endif.
    else.
    <lfs_data>-idate = sy-datum.
    <lfs_data>-itime = sy-uzeit.
    <lfs_data>-iuser = sy-uname.
    <lfs_data>-status = text-019.
    message id sy-msgid
    type sy-msgty
    number sy-msgno
    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
    into <lfs_data>-error_msg.
    lv_error = abap_true.
    lv_msg = <lfs_data>-error_msg.
    exit.
    endif.

    See less
  2. Hi Marianne, You can get it. follow these steps. Get DOCID from /SCDL/PROCH_I or /SCDL/PROCH_O table by passing document number Pass DOCID in /SCWM/ORDIM_O and /SCWM/ORDIM_C table and get all open/confirmed tasks. let me know if you need further help on this.

    Hi Marianne,

    You can get it. follow these steps.

    Get DOCID from /SCDL/PROCH_I or /SCDL/PROCH_O table by passing document number

    Pass DOCID in /SCWM/ORDIM_O and /SCWM/ORDIM_C table and get all open/confirmed tasks.

    let me know if you need further help on this.

    See less
  3. DATA: lo_spfd TYPE REF TO /scdl/cl_sp_fd_out. DATA: lt_key TYPE /scdl/t_sp_k_head. DATA: lt_key_itm TYPE /scdl/t_sp_k_item. DATA: lv_aspect TYPE /scmb/sp_aspect VALUE '/SCDL/S_SP_A_HEAD'. DATA: lv_aspect_itm TYPE /scmb/sp_aspect VALUE '/SCDL/S_SP_A_ITEM'. DATA: lv_rejected TYPE abap_bool. DATA: lt_rRead more

    DATA: lo_spfd TYPE REF TO /scdl/cl_sp_fd_out.

    DATA: lt_key TYPE /scdl/t_sp_k_head.

    DATA: lt_key_itm TYPE /scdl/t_sp_k_item.

    DATA: lv_aspect TYPE /scmb/sp_aspect VALUE ‘/SCDL/S_SP_A_HEAD’.

    DATA: lv_aspect_itm TYPE /scmb/sp_aspect VALUE ‘/SCDL/S_SP_A_ITEM’.

    DATA: lv_rejected TYPE abap_bool.

    DATA: lt_ret TYPE /scdl/t_sp_return_code.

    DATA: lt_return TYPE bapiret2_t.

    DATA: lv_msg TYPE msgtx.

    DATA: lt_outrec TYPE /scdl/t_sp_a_head.

    DATA: lt_outrec_itm TYPE /scdl/t_sp_a_item.

    DATA: lt_docid TYPE /scwm/dlv_docid_item_tab.

    DATA: lt_key_docid TYPE /scdl/t_sp_k_head.

    DATA: lo_sp TYPE REF TO /scdl/cl_sp_prd_out.

    DATA: lo_dlv TYPE REF TO /scwm/cl_dlv_management_prd.

    DATA: lt_sp_k_head TYPE /scdl/t_sp_k_head.

    DATA: lt_sp_k_item TYPE /scdl/t_sp_k_item.

    DATA: lt_a_head_eew TYPE /scdl/t_sp_a_head_eew_prd.

    *–Append messaage for queue start

    MESSAGE s171 INTO lv_msg.

    PERFORM add_message TABLES lt_return

    USING lv_msg.

    CREATE OBJECT lo_spfd.

    *–Get OD

    SELECT docid,

    itemid

    FROM /scdl/db_dlvi_o

    INTO TABLE @lt_key_itm

    FOR ALL ENTRIES IN @it_docid

    WHERE refdocid = @it_docid-docid.

    IF sy-subrc = 0.

    lt_key = CORRESPONDING #( lt_key_itm MAPPING

    docid = docid ).

    *–Fetch corresponding FDO Details

    SELECT docid,

    itemid,

    doccat

    INTO TABLE @lt_docid

    FROM /scdl/db_dlvi_o

    FOR ALL ENTRIES IN @it_docid

    WHERE refdocid = @it_docid-docid.

    IF lt_docid[] IS NOT INITIAL.

    lt_key_docid = CORRESPONDING #( lt_docid MAPPING

    docid = docid ).

    ENDIF.

    DO 5 TIMES.

    SELECT *

    INTO TABLE @DATA(lt_msl)

    FROM /scwm/messagelog

    FOR ALL ENTRIES IN @lt_key

    WHERE docid EQ @lt_key-docid

    AND doccat = ‘FDO’.

    IF sy-subrc EQ 0 AND lt_msl IS NOT INITIAL.

    READ TABLE lt_msl INTO DATA(ls_msl)

    WITH KEY message = /scwm/if_mapping_constants=>sc_m_obdlv_change_revgi.

    IF sy-subrc NE 0.

    WAIT UP TO 2 SECONDS.

    CONTINUE.

    ELSE.

    LOOP AT lt_msl ASSIGNING FIELD-SYMBOL().

    IF -message = /scwm/if_mapping_constants=>sc_m_obdlv_change_revgi.
    -status = ‘X’.

    ELSEIF -message = /scwm/if_mapping_constants=>sc_m_obdlv_confirm_dec.
    -status = ‘X’.

    ENDIF.

    ENDLOOP.

    MODIFY /scwm/messagelog FROM TABLE lt_msl.

    COMMIT WORK AND WAIT.

    MESSAGE s167 INTO lv_msg.

    PERFORM add_message TABLES lt_return

    USING lv_msg.

    ENDIF.

    ENDIF.

    ENDDO.

    *–Check for errors

    IF VALUE #( lt_return[ type = ‘E’ ]-type OPTIONAL ) NE ‘E’.

    *–create service provider

    DATA(lo_message_box) = NEW /scdl/cl_sp_message_box( ).

    *–Create object to instantiate

    CREATE OBJECT lo_sp

    EXPORTING

    io_message_box = lo_message_box

    iv_doccat = /scdl/if_dl_doc_c=>sc_doccat_out_fd “sc_doccat_out_prd

    iv_mode = /scdl/cl_sp=>sc_mode_classic.

    *–Get real warehouse

    /scwm/cl_tm=>set_lgnum( iv_lgnum ).

    *–Lock dlv

    lo_sp->lock(

    EXPORTING

    inkeys = lt_key

    aspect = /scdl/if_sp_c=>sc_asp_head

    lockmode = /scdl/if_sp1_locking=>sc_exclusive_lock

    IMPORTING

    rejected = lv_rejected

    return_codes = DATA(lt_return_codes) ).

    *–read item details into buffer

    lo_sp->select(

    EXPORTING

    inkeys = lt_key_itm

    aspect = /scdl/if_sp_c=>sc_asp_item

    IMPORTING

    outrecords = lt_outrec_itm

    rejected = lv_rejected

    return_codes = lt_ret ).

    *–read header details into buffer

    lo_sp->select(

    EXPORTING

    inkeys = lt_key

    aspect = /scdl/if_sp_c=>sc_asp_head

    IMPORTING

    outrecords = lt_outrec

    rejected = lv_rejected

    return_codes = lt_ret ).

    *–Delete the FDO

    lo_sp->delete(

    EXPORTING

    inkeys = lt_key

    aspect = /scdl/if_sp_c=>sc_asp_head

    IMPORTING

    rejected = lv_rejected

    return_codes = lt_ret

    ).

    *–Check if any error occurred

    IF line_exists( lt_return_codes[ failed = abap_true ] ) OR lv_rejected EQ abap_true.

    *–Error to fail queue

    ELSE.

    lo_sp->save(

    IMPORTING

    rejected = lv_rejected ).

    *–Commit / rollback based on errors

    IF lv_rejected IS INITIAL.

    CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT’

    EXPORTING

    wait = abap_true.

    CALL METHOD lo_sp->(‘CLEANUP’)

    EXPORTING

    reason = /scmb/if_sp_transaction=>sc_cleanup_commit.

    *–Clear buffers and release locks

    /scwm/cl_tm=>cleanup( ).

    ELSE.

    CALL FUNCTION ‘BAPI_TRANSACTION_ROLLBACK’.

    *–Clear buffers and release locks

    /scwm/cl_tm=>cleanup( ).

    ENDIF.

    ENDIF.

    See less
  4. I think this is not how PARAMETER ID is intended to be used. For transfering values from and to memory you should use MEMORY ID (EXPORT TO or IMPORT FROM).

    I think this is not how PARAMETER ID is intended to be used. For transfering values from and to memory you should use MEMORY ID (EXPORT TO or IMPORT FROM).

    See less