SAP/ABAP

BAPI/FM to get equipment / funct. location task list

그녀는애교쟁이 2013. 1. 24. 07:56
반응형
Note to the coding
- create a structure with whatever fields you need from EAPL/TAPL for es_tasklist
- create a structure with whatever fields you need from PLPO for et_task
* convert to internal format
  call function 'CONVERSION_EXIT_ALPHA_INPUT'
    exporting
      input  = iv_equnr
    importing
      output = lv_equnr.

* get takslist "header" - EAPL or TAPL *********************************
 if lv_equnr is not initial.
    select single * from eapl
           into corresponding fields of es_tasklist
           where equnr = lv_equnr.
* in case no tasklist was found, set error with 'equipment'
    lv_errtext  = text-013. 
    lv_errvalue = iv_equnr.
  elseif iv_tplnr is not initial.
    select single * from tapl
           into corresponding fields of es_tasklist
           where tplnr = iv_tplnr.
* in case no tasklist was found, set error with 'funct. location'
    lv_errtext  = text-014. 
    lv_errvalue = iv_tplnr.
  endif.

* check if an tasklist exists
  if es_tasklist is initial.
    ls_return-type = 'E'.
    concatenate text-012 lv_errtext lv_errvalue text-050
      into ls_return-message
      separated by space.
    append ls_return to et_return.
    exit.
  endif.

* get text of tasklist group - PLKO ************************************
  select single ktext from plko
         into es_tasklist-ktext
         where plnty = es_tasklist-plnty
         and   plnnr = es_tasklist-plnnr
         and   txtsp = sy-langu.
  " if no text was found with sy-langu...
  if sy-subrc <> 0.
    "...try without
    select single ktext from plko
           into es_tasklist-ktext
           where plnty = es_tasklist-plnty
           and   plnnr = es_tasklist-plnnr.
  endif.

* get tasks of tasklist - PLPO *****************************************
  select * from plpo
         into corresponding fields of table et_tasks
         where plnty = es_tasklist-plnty
         and   plnnr = es_tasklist-plnnr
         order by vornr.

* get production group for each task
  loop at et_tasks assigning <lf_task>.
    call function 'CR_WORKSTATION_READ'
      exporting
        id        = <lf_task>-arbid
      importing
        arbpl     = <lf_task>-arbpl
      exceptions
        not_found = 1
        others    = 2.
  endloop.

반응형