on 05-28-2015 3:15 PM
Hello Experts,
i need to execute a goods receipt for a hu of an inbound delivery.
This can be done via transaction /scwm/prdi:
I need to do this via abap-code and a HU-Ident and the delivery number are provided.
Does anyone know how to implement this and what classes / function modules need to be used? I already have read SAP-Note 1414179 about delivery service providers, but i do not find a way for a hu-goods-receipt.
Thanks in advance,
Matthias
I found out on my own how to do this. If someone is interested, this the solution:
DATA lo_sp_prd_in TYPE REF TO /scdl/cl_sp_prd_inb.
DATA lo_message_box TYPE REF TO /scdl/cl_sp_message_box.
DATA lt_sp_a_head TYPE /scdl/t_sp_a_head.
DATA ls_sp_a_head TYPE /scdl/s_sp_a_head.
DATA ls_sp_k_head TYPE /scdl/s_sp_k_head.
DATA lt_sp_k_head TYPE /scdl/t_sp_k_head.
DATA ls_sp_a_hu TYPE /scdl/s_sp_a_hu.
DATA lt_sp_a_hu TYPE /scdl/t_sp_a_hu.
DATA lv_rejected TYPE boolean.
DATA lt_return_codes TYPE /scdl/t_sp_return_code.
DATA ls_sp_a_hu_scwm TYPE /scwm/s_sp_a_hu.
DATA lt_sp_a_hu_scwm TYPE /scwm/t_sp_a_hu.
DATA ls_sp_a_myhu_scwm TYPE /scwm/s_sp_a_hu.
DATA ls_sp_k_hu_scwm TYPE /scwm/s_sp_k_hu.
DATA lt_sp_k_hu_scwm TYPE /scwm/t_sp_k_hu.
"Create service provider for inbound delivery
CREATE OBJECT lo_sp_prd_in
EXPORTING
io_message_box = lo_message_box. " Service Provider Nachrichtenverwaltung
ls_sp_k_head-docid = is_proch-docid.
APPEND ls_sp_k_head TO lt_sp_k_head.
"select delivery head data
CALL METHOD lo_sp_prd_in->/scdl/if_sp1_aspect~select
EXPORTING
inkeys = lt_sp_k_head
aspect = /scdl/if_sp_c=>sc_asp_head
IMPORTING
outrecords = lt_sp_a_head
rejected = lv_rejected
return_codes = lt_return_codes.
"Lock delivery
CALL METHOD lo_sp_prd_in->/scdl/if_sp1_locking~lock
EXPORTING
inkeys = lt_sp_k_head
aspect = /scdl/if_sp_c=>sc_asp_head
lockmode = 'E'
IMPORTING
rejected = lv_rejected
return_codes = lt_return_codes.
"If lock has been successful
IF lv_rejected = abap_false.
"select hu data from delivery
CALL METHOD lo_sp_prd_in->/scdl/if_sp1_aspect~select_by_relation
EXPORTING
" relation = /scdl/if_sp_c=>sc_rel_head_to_hu
relation = /scwm/if_sp_c=>sc_rel_head_to_hu
inrecords = lt_sp_k_head
aspect = /scdl/if_sp_c=>sc_asp_head
* options =
IMPORTING
outrecords = lt_sp_a_hu_scwm
rejected = lv_rejected
return_codes = lt_return_codes.
LOOP AT lt_sp_a_hu_scwm INTO ls_sp_a_hu_scwm.
"determine hu data which has to be moved.
IF ls_sp_a_hu_scwm-huno = /scwm/huhdr-huident.
ls_sp_a_myhu_scwm = ls_sp_a_hu_scwm.
MOVE-CORRESPONDING ls_sp_a_hu_scwm TO ls_sp_k_hu_scwm.
APPEND ls_sp_k_hu_scwm TO lt_sp_k_hu_scwm.
EXIT.
ENDIF.
ENDLOOP.
CLEAR lt_sp_a_hu_scwm.
CLEAR lt_sp_a_head.
"execute action hu goods movement
CALL METHOD lo_sp_prd_in->/scdl/if_sp1_action~execute
EXPORTING
aspect = /scwm/if_sp_c=>sc_asp_hu " Aspect Name
inkeys = lt_sp_k_hu_scwm " Objects to Act On
* inparam = " Parameters
action = /scwm/if_sp_c=>sc_act_hu_post_gm " Name of Action
relation_inkey = ls_sp_k_head " Key for Target Aspect
relation = /scwm/if_sp_c=>sc_rel_head_to_hu " Name of Relation
IMPORTING
outrecords = lt_sp_a_hu_scwm " Changed Aspect Objects
rejected = lv_rejected " Error on Back End
return_codes = lt_return_codes " Table of Return Codes
relation_outrecord = lt_sp_a_head. " Changed Target Aspect Line
"Save changes
CALL METHOD lo_sp_prd_in->/scdl/if_sp1_transaction~save
EXPORTING
synchronously = abap_false
IMPORTING
rejected = lv_rejected.
"remove lock
CALL METHOD lo_sp_prd_in->/scdl/if_sp1_transaction~cleanup
EXPORTING
reason = 'END'.
ENDIF.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks a lot Matthias..These code snippets are useful and helpful.
Hi former member
I am getting dump from this method CALL METHOD lo_sp_prd_in->/scdl/if_sp1_aspect~select_by_relation
Category ABAP programming error
Runtime Errors OBJECTS_OBJREF_NOT_ASSIGNED_NO
Except. CX_SY_REF_IS_INITIAL
ABAP Program /SCWM/CL_IM_SP_EX_ASPECT======CP
Application Component SCM-EWM-DLP
At below line
lo_bo = mo_bom->get_bo_by_id( iv_docid = ls_head_keys-docid ).
lv_handle = lo_bo->get_archive_handle( ).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
15 | |
4 | |
3 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.