FM status untuk equipment

STATUS_READ
digunakan untuk membaca status yang ada pada equipment

PARAMETERS: p_equnr LIKE equi-equnr.

DATA: d_objnr       LIKE viqmel-objnr.
DATA: t_status TYPE TABLE OF jstat WITH HEADER LINE.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  EXPORTING
    input  = p_equnr
  IMPORTING
    output = p_equnr.

CONCATENATE 'IE' p_equnr INTO d_objnr.
CONDENSE d_objnr.

CALL FUNCTION 'STATUS_READ'
  EXPORTING
    objnr            = d_objnr
    only_active      = 'X'
  TABLES
    status           = t_status
  EXCEPTIONS
    object_not_found = 1
    OTHERS           = 2.

IMAS_CHANGE_STATUS_SINGLE
digunakan untuk mengubah status equipment.
value parameter i_activity bisa dilihap pada table TJ01.

TYPE-POOLS: imas.

DATA: gs_error_rec  TYPE imas_objnr_act_error_rec,
      gs_msg_rec    TYPE imas_objnr_act_msg_rec,
      d_objnr       LIKE viqmel-objnr,
      d_message(255).

PARAMETERS: p_equnr LIKE equi-equnr.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  EXPORTING
    input  = p_equnr
  IMPORTING
    output = p_equnr.

CONCATENATE 'IE' p_equnr INTO d_objnr.
CONDENSE d_objnr.

CALL FUNCTION 'IMAS_CHANGE_STATUS_SINGLE'
  EXPORTING
    i_objnr     = d_objnr
    i_activity  = 'INAZ'
  IMPORTING
    e_error_rec = gs_error_rec
    e_msg_rec   = gs_msg_rec.

IF gs_msg_rec IS INITIAL.
  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
      wait = 'X'.
  WRITE: p_equnr, 'was activated'.
ELSE.
  CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
  CALL FUNCTION 'FORMAT_MESSAGE'
    EXPORTING
      id        = gs_msg_rec-id
      lang      = 'E'
      no        = gs_msg_rec-no
      v1        = gs_msg_rec-v1
      v2        = gs_msg_rec-v2
      v3        = gs_msg_rec-v3
      v4        = gs_msg_rec-v4
    IMPORTING
      msg       = d_message
    EXCEPTIONS
      not_found = 1
      OTHERS    = 2.
  WRITE d_message.
ENDIF.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s