2018 Sep 26 9:58 AM
Hi experts,
I need to update shipment's stages, in tab Execution End date and time.
For this issue I'm using bapi BAPI_SHIPMENT_CHANGE like this:
gv_shp_hdr-shipment_num = l_vttk-tknum.
gv_hdract-shipment_num = 'X'.
gv_hdract-status_shpmnt_end = 'C'.
gv_shp_hdr-status_shpmnt_end = 'X'.
SELECT *
FROM vttp
INTO TABLE li_vttp
WHERE tknum = p_tknum
AND vbeln = p_vbeln.
* Searching shipment's stages (
REFRESH: li_vtts.
SELECT *
FROM vtts
INTO TABLE li_vtts
WHERE tknum = p_tknum.
LOOP AT li_vttp.
SELECT *
FROM vtsp
APPENDING TABLE li_vtsp
WHERE tknum = p_tknum
AND tpnum = li_vttp-tpnum.
LOOP AT li_vtsp.
l_st_dline-stage_seq = li_vtsp-tsnum.
l_st_dline-time_type = 'STLENADT'.
l_st_dline-time_stamp_utc = l_time_utc..
l_st_dline-time_zone = sy-zonlo.
APPEND l_st_dline TO it_stagedeadline.
l_st_act-stage_seq = 'C'.
l_st_act-time_type = 'C'.
l_st_act-time_stamp_utc = 'C'.
l_st_act-time_zone = 'C'.
APPEND l_st_act TO it_stagedeadlineaction.
READ TABLE li_vtts WITH KEY tsnum = li_vtsp-tsnum.
IF sy-subrc = 0.
l_st_data-stage_cat = li_vtts-tstyp.
l_st_data-org_addr = li_vtts-adrna.
l_st_data-org_point = li_vtts-knota.
l_st_data-org_shipp_dpmnt = li_vtts-vstel.
l_st_data-org_plant = li_vtts-werka.
l_st_data-org_cust = li_vtts-kunna.
l_st_data-org_suppl = li_vtts-lifna.
ENDIF.
l_st_data-stage_seq = li_vtsp-tsnum.
APPEND l_st_data TO it_stagedata.
l_st_data_act-stage_cat = 'C'.
l_st_data_act-stage_seq = 'X'.
APPEND l_st_data_act TO it_stagedataaction.
ENDLOOP.
ENDLOOP.
[....]
CALL FUNCTION 'BAPI_SHIPMENT_CHANGE'
EXPORTING
headerdata = gv_shp_hdr
headerdataaction = gv_hdract
TABLES
* headerdeadline = it_shp_hdr_dline
* headerdeadlineaction = it_hdr_dline_action
* ITEMDATA =
* ITEMDATAACTION =
stagedata = it_stagedata
stagedataaction = it_stagedataaction
stagedeadline = it_stagedeadline
stagedeadlineaction = it_stagedeadlineaction
return = it_logfile.
I have a dump in include LV56I_BAPIF03, form FILL_STG_DATA_CHANGE at this point:
LOOP AT it_stg_dline_action INTO ls_stg_dline_action
WHERE stage_seq = is_stg-stage_seq
AND time_type = gc_chg_delete.
At this moment IT_STG_DLINE_ACTION is like this:
but SAP is triing to find something within this internal table with IS_STG-STAGE_SEG = '0001' (field which is Numc4).
So I get this dump:
Unable to interpret "C" as a number.
I know C is not a number, but IT_STG_DLINE_ACTION-STAGE_SEQ type allows only A/C/D.
I don't know how to solve this problem. Any suggestion?
Thanks in advance!
Maria
2018 Sep 26 10:53 AM
Hi Maria,
yes, the error is correct: how do you link Stage data with Stage Action?
Via Stage_seq, which identify the stage item (value vtsp-tsnum): you pass 'C'
l_st_act-stage_seq = 'C'. "<<<<<<<< WRONG LINE
l_st_act-time_type = 'C'.
l_st_act-time_stamp_utc = 'C'.
l_st_act-time_zone = 'C'.
APPEND l_st_act TO it_stagedeadlineaction.
Replace the wrong line with
l_st_act-stage_seq = li_vtsp-tsnum.
2018 Sep 26 11:07 AM
Thanks Simone !! I'll try it.
Now I'm triing fm RV_SHIPMENT_UPDATE instead of BAPI_SHIPMENT_CHANGE as it seems easier to use...
2018 Sep 26 1:24 PM
No, i would avoid it.
BAPIs are the way to update standard objects and we should do the effort to use them 🙂
Let me know if my suggestion works.
2018 Sep 26 2:00 PM
yes and no. BAPI's are intended to be called from trusted sources outside SAP. That involves most often a conversion from English-named fields into internal fields and the building of logs usable from outside. It can be more efficient to call the internal function when you call it from inside SAP. The COMMIT can be also better/easier controlled.
2018 Sep 26 2:40 PM
Yes and no.
BAPIs can also perform checks on input data that FMs do not do.
So they are more secure than FMs per design (single cases can be exceptions 🙂 )
2018 Sep 26 3:40 PM
Yes it depends on the case.
The BAPI we are talking about is calling function SD_SHIPMENT_PROCESS_EXT_CHANGE.
Here is the header of this one 🙂
2018 Sep 26 4:11 PM
as I was wasting a lot of time with the bapi, I decided to try the fm. It worked, so for now, even if it's not the best solution, I'll leave it like that and review it later as Simone told me (and update this thread in case it works).
Thanks a lot for your answers!
2018 Sep 26 4:38 PM
Simone gave you the right answer, in a BAPI call there is always a structure (or table) for the data and a structure (or table) for the flags that indicate that the data should be updated. This allows for updating with empty values when needed. So you have to put the data in the first one and a flag 'X' in the second one.
After working a while with BAPI's, that will be a reflex and you won't search anymore 😉
2024 Apr 16 3:38 AM
I have the same error in STAGE_SEQ = C I can't run the bapi since it asks for a data type number something like this 1 and then wants to compare in the code with pure letters C.
Will I have to implement any SAP notes?