Search help exit

SAP/ABAP 개발 2010. 11. 17. 09:50 Posted by KindKay





  function zpp_wooden_f4_help_exit.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  TABLES
*"      SHLP_TAB TYPE  SHLP_DESCT
*"      RECORD_TAB STRUCTURE  SEAHLPRES
*"  CHANGING
*"     REFERENCE(SHLP) TYPE  SHLP_DESCR
*"     REFERENCE(CALLCONTROL) TYPE  DDSHF4CTRL
*"----------------------------------------------------------------------

  data: lv_matnr  type matnr,
        lv_aufnr  type aufnr,
        lv_maktx  type maktx,
        lv_inch   like ztpp1140-inch01,
        lv_width  like ztpp1140-width01,
        lv_height like ztpp1140-height01,
        lv_char.

  clear: lv_matnr, lv_maktx, lv_aufnr.

  case sy-tcode.
    when 'CO01' or 'CO01' or 'CO01'.
      get parameter id 'MAT' field lv_matnr.
      get parameter id 'ANR' field lv_aufnr.

    when others.
      clear: lv_matnr, lv_maktx, lv_aufnr.
  endcase.

  if callcontrol-step = 'PRESEL1'.
    clear: g_check_first.
    return.
  endif.

  check lv_matnr is not initial or lv_aufnr is not initial.

  if lv_matnr is initial.
    select single matnr
      into lv_matnr
      from afpo
     where aufnr eq lv_aufnr.
  endif.

  select single maktx
    into lv_maktx
    from makt
   where matnr eq lv_matnr
     and spras eq sy-langu.

  if lv_maktx cs 'RTC'.
    clear: lv_char.
    call function 'ZPP_GETCHAR_SHIFT_LEFT'
      exporting
        i_matnr       = lv_matnr
        i_left        = 5
      importing
        e_char        = lv_char.

    if lv_char ne 'E'.
      clear: record_tab[].
      return.
    endif.
  else.
    clear: record_tab[].
    return.
  endif.

  call function 'F4UT_OPTIMIZE_COLWIDTH'
    tables
      shlp_tab = shlp_tab
      record_tab = record_tab
    changing
      shlp = shlp
      callcontrol = callcontrol.

  data: lt_ztpp1130   like table of ztpp1130 with header line,
        ls_record_tab like seahlpres.

  data: lt_ddshselops type table of ddshselopt.

  if callcontrol-step = 'SELECT'.
    perform get_characteristic using lv_matnr
                            changing lv_inch
                                     lv_width
                                     lv_height.

    clear: lt_ddshselops[].
    lt_ddshselops[] = shlp-selopt[].

    if lt_ddshselops[] is initial and g_check_first is initial.
      if lv_inch is not initial.
        perform append_model_selopt  tables lt_ddshselops
                                      using 'INCH01' lv_inch.

        perform append_model_selopt  tables lt_ddshselops
                                      using 'WIDTH01' lv_width.

        perform append_model_selopt  tables lt_ddshselops
                                      using 'HEIGHT01' lv_height.
      endif.

      shlp-selopt[] = lt_ddshselops[].
      g_check_first = 'X'.
    endif.

  endif.

endfunction.