cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI_SHIPMENT_CHANGE - Update Staus

bzakaria
Participant
0 Kudos

Hi,

I want to change a shipment via the bapi: 'BAPI_SHIPMENT_CHANGE'. I change without any problem the different information as aaa but when I try to change the status it shows me an error message.

when I have to change the STATUS_SHPMNT_START. it displays this error message:

Status cannot be set because status "planned" has not been set 
shipment xxxxxx could not be changed by the BAPI

it shows me this message even if my goal is to activate the status planned.

when I have to change the STATUS_LOAD_END.it displays this error message:

Use Transaction ZSAPMSSY4

the code to change the STATUS_SHPMNT_START:

DATA: ls_header TYPE bapishipmentheader,
 ls_headera TYPE bapishipmentheaderaction,
 lt_return TYPE bapiret2_t.
ls_header-SHIPMENT_NUM = '0004000142'.

ls_header-STATUS_SHPMNT_START = 'X'.
ls_headera-STATUS_SHPMNT_START = 'C'.

CALL FUNCTION 'BAPI_SHIPMENT_CHANGE'

EXPORTING
 headerdata = ls_header
 headerdataaction = ls_headera

TABLES

return = lt_return.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = abap_true.

PERFORM display_messages tables lt_return.

the code to change the STATUS_LOAD_END:

DATA: ls_header TYPE bapishipmentheader,
 ls_headera TYPE bapishipmentheaderaction,
 lt_return TYPE bapiret2_t.
ls_header-SHIPMENT_NUM = '0004000142'.
ls_header-STATUS_LOAD_END = 'X'.
ls_headera-STATUS_LOAD_END = 'C'.

CALL FUNCTION 'BAPI_SHIPMENT_CHANGE'

EXPORTING
 headerdata = ls_header
 headerdataaction = ls_headera

TABLES

return = lt_return.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = abap_true.

PERFORM display_messages tables lt_return.

Best regards,

Accepted Solutions (0)

Answers (7)

Answers (7)

bzakaria
Participant
0 Kudos

simone.milesi it's good I managed to solve the problem. I can not start the modfication via se38. but after activating the program the update goes on without any problem.

Thanks for your help 🙂

bzakaria
Participant
0 Kudos

simone.milesi, I am very sorry I did not pay attention to your request.

when I click on '?' he shows me this screen (Message no IEQ127):

and when I do a breakpoint at message in debug. of the program, I find the condition that displays the error message (in the program : ZXREPU01 )

here are the values of the variables :

the problem comes from the execution of the update via SE38. but when I execute via an ALV transaction containing the shipment change code, it works very well without problem.

But I want to make the change via a program that runs after receiving an IDOC.and not via a transaction.

So how to make the change via program (non-transactional) possible ?

SimoneMilesi
Active Contributor
0 Kudos

And we end up with the first suggestion we gave you: check if there is any user exit, customer function or badi under the hood.

The answer is.. yes, since you found the include ZXREPU01 which sound so bad a customer function.

Check the calls stack in debug so you can identify the customer function and see if you can fix it with some kind of workaround (or ask to the one who developed it why it has been done).

bzakaria
Participant
0 Kudos

I managed to solve the first problem. I still have the second problem that gives me the error message "Use Transaction ZSAPMSSY4" when I try to update one of these three : Loading end (STATUS_LOAD_END) , shpmt completion (STATUS_COMPL) , shipment start (STATUS_SHPMNT_START).

raymond_giuseppi
Active Contributor
0 Kudos
  • As already written, Did you already look for any customer validation (BAdI, Enh, etc.) that could rise the pop-up?
  • Did you check for current Shipment status, so did you try to set STATUS_PLAN with the BAPI first ?
  • Did you get any Information/Warning message with a transaction such as VT02N ?
  • Did you set a break-point at start of form CHECK_SHIPMENT_IS_PLANNED of function group V56F ? (could be easily found with a where-used seach on message VW 562) - And test both BAPI and Transaction
bzakaria
Participant
0 Kudos

I managed to solve the first problem. I still have the second problem that gives me the error message "Use Transaction ZSAPMSSY4" when I try to update one of these three : Loading end (STATUS_LOAD_END) , shpmt completion (STATUS_COMPL) , shipment start (STATUS_SHPMNT_START).

raymond_giuseppi
Active Contributor
0 Kudos

As SAPMSSY4 is a central-basis system program, danger Will Robinson... You should ask your local basis for this popup (is that a transaction created to execute a local update task and not in background?)

Do you see any error in SM13?

SimoneMilesi
Active Contributor
0 Kudos

The popup is for ZSAPMSSY4 so there is some kind of custom there

bzakaria
Participant
0 Kudos

raymond.giuseppi No error displayed in SM13.

simone.milesi I do not know where the problem comes from. I searched on google without getting to find the source of the problem.

Thank you in advance for your answers.

SimoneMilesi
Active Contributor
0 Kudos

bzakaria did you try to go in SE38, put ZSAPMSSY4 and choose display?
You can also set a breakpoint on statement "MESSAGE" and see when it's called.

bzakaria
Participant
0 Kudos

simone.milesi , when I put 'ZSAPMSSY4' in SE38 he shows me the error message 'Program ZSAPMSSY4 does not exist'. because it's a transaction.

but when I put 'SAPMSSY4' (the program of this transaction) he shows me this program :

* -------------------------------------------------------------------
*                  S A P M S S Y 4
*         system routines for ABAP processing
*
*                    - Update Task -
* -------------------------------------------------------------------
program sapmssy4 message-id 02.
include tskhincl.
include <sys000>.
tables: vbparam, tfdir.

data: %_vb_calls type %_vb_calls occurs 50 with header line.    "#EC *

parameters: vbkey_id       type %_vbkey     no-display,
            enqkey         type eqeusrvb    no-display,
            enqdone        type c           no-display.

perform local_update_task.

form local_update_task.
  data: l_enqkey   type eqeusrvb,
        l_vbkey    type %_vbkey,
        l_enqdone  type c length 1.
  system-call state_limit set.

*
*   get direct update task orders from memory and do the job
*
  free %_vb_calls.                                              "#EC *
  import %_vb_calls from memory id vbkey_id.                    "#EC *
  if sy-subrc eq 0.
*   new imode: switch direct update task "on" again
    set update task local.
*   switch direct update task to "active"
    call 'SET_SWITCH_UTASK_OFF' id 'STATE' field 'Y'.
    perform %_updates_no_utask.
    free %_vb_calls.                                            "#EC *
    free memory id vbkey_id.
    commit work.
*   switch direct update task to "inactive"
    call 'SET_SWITCH_UTASK_OFF' id 'STATE' field 'N'.
*   get enqueue key of local update task imode
    call 'ThVBCall' id 'OPCODE' field get_vb_key
                    id 'VBKEY'   field l_vbkey-vbkey            "#EC *
                    id 'ENQKEY'  field l_enqkey
                    id 'ENQDONE' field l_enqdone.
*   release the locally acquired SAP locks
    if l_enqdone is not initial.
      call 'C_ENQUEUE'
        id 'USER' field l_enqkey
        id 'OPCODE' field '3'
        id 'SYNCHRON' field 'X'.
    endif.
*   SAP locks inherited from dialog imode are released when
*   returning to SAPMSSY0 by a following call to
*   'ThVBCall' id 'OPCODE' field reset_vb_enq_key
*              id 'SYNC_DEQUEUE' field 'X'.
*   Therefore there is no need to release them here.
  endif.

  system-call state_limit reset.
endform.

************************************************************************
* A R F C _ D E Q U E U E _ I N _ L O C A L _ U T A S K                *
*                                                                      *
************************************************************************
form arfc_dequeue_in_local_utask.
  data: %_direct_utask_active type c.                           "#EC *
  data: %_loc_enqkey  type eqeusrvb,                            "#EC *
        %_loc_enqdone type c,                                   "#EC *
        %_vbkey       type vbdata-vbkey.                        "#EC *

* release "inherited" locks if in local update task
  if enqdone = 'X'.
    call 'GET_SWITCH_UTASK' id 'MODE'  field 'A'
                            id 'STATE' field %_direct_utask_active.
    if %_direct_utask_active = 'Y'.
      call 'C_ENQUEUE'
        id 'USER' field enqkey
        id 'OPCODE' field '3'.
      enqdone = ' '.
    endif.
  endif.
* release local locks if in local update task
  call 'ThVBCall' id 'OPCODE'  field get_vb_key
                  id 'VBKEY'   field %_vbkey
                  id 'ENQKEY'  field %_loc_enqkey
                  id 'ENQDONE' field %_loc_enqdone.
  if %_loc_enqdone = 'X'.
    call 'GET_SWITCH_UTASK' id 'MODE'  field 'A'
                            id 'STATE' field %_direct_utask_active.
    if %_direct_utask_active = 'Y'.
      call 'C_ENQUEUE'
        id 'USER' field %_loc_enqkey
        id 'OPCODE' field '3'.
      %_loc_enqdone = ' '.                                      "#EC *
    endif.
  endif.
endform.

************************************************************************
* % _ U P D A T E S _ N O _ U T A S K                                  *
*                                                                      *
************************************************************************
form %_updates_no_utask.                                        "#EC *
  data: l_oncom like sy-oncom.
  loop at %_vb_calls.
    select single * from tfdir where funcname = %_vb_calls-func_name.
    if sy-subrc eq 0.
      l_oncom = sy-oncom.
      sy-oncom = 'V'.                                           "#EC *
      perform (%_vb_calls-func_name) in program (tfdir-pname) using
               %_vb_calls-daten_id.
      sy-oncom = l_oncom.                                       "#EC *
      free memory id %_vb_calls-daten_id.
    else.
      message a400 with %_vb_calls-func_name.
    endif.
  endloop.
endform.
************************************************************************
* % _ U P D A T E _ T A S K                                            *
*                                                                      *
************************************************************************
form %_update_task.                                             "#EC *
  data: begin of vbkey,
          timestamp like vbparam-vbkey,
          id        like vbdata-vbmodcnt,
        end of vbkey.

  vbkey-timestamp = vbparam-vbkey.
  vbkey-id        = vbparam-vbmodcnt.
  tfdir-funcname = vbparam-vbfunc.
  read table tfdir.
  perform (vbparam-vbfunc) in program (tfdir-pname) using vbkey.
endform.

************************************************************************
* G E T _ U P D A T E _ K E Y                                          *
*                                                                      *
* deliver update key (called from CL_SYSTEM_TRANSACTION_STATE)         *
************************************************************************
form get_update_key changing update_key like vbhdr-vbkey. "#EC CALLED
  update_key = vbkey_id-vbkey.
endform.

And when I click on F8 to execute it, it will show me this error message : "Use transaction ZSAPMSSY4".

SimoneMilesi
Active Contributor
0 Kudos

bzakaria and TCODE (SE93) ZSAPMSSY4 exists? Which report it refers to?

Did you try to see where that message is raised?

bzakaria
Participant
0 Kudos

simone.milesi , Yes, it exists.

And when I execute the transaction by putting its code in the input box nothing happens.

SimoneMilesi
Active Contributor
0 Kudos

bzakaria i really hate to repeat myself, but... did you tried to debug and check where that message (which is quite custom, try to press on the ? on it to see which is the message) is raised?

SimoneMilesi
Active Contributor
0 Kudos

Well, the message is self explaining: you are setting the Loading End status but you cannot since you didn't set the planned one.

i do not remember if it's a standard behavior, something you can set by customizing or a total custom control ( iftah.peretz refers to the last popup which clearly speaks about a Z.. development so it's quite possible you have a BADI activated and implemented performing some controls).

You should check those things, the Z stuff as first step

bzakaria
Participant
0 Kudos

the problem is that the error message appears when i try to update the first status (STATUS_SHPMNT_START), it tells me that status "planned" has not been set.

for the STATUS_LOAD_END I tried to modify it after manually activating the staus that are before him.

bzakaria
Participant
0 Kudos

simone.milesi , could you please see this problem ?

iftah_peretz
Active Contributor
0 Kudos

Hey,

Could it be that you have some custom code that intervenes in the status flow (for more information go here)?

bzakaria
Participant
0 Kudos

I did not understand. could you give me an example, because this is my first use of bapi.

NB : I only have this code that comes in. when i change the status manually via vt02n i change them without problem.