Pushbutton && scrren && submit

*&---------------------------------------------------------------------*
*& Report  Y_TEST_INTERFACE2
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

report  y_test_interface2.

type-pools : slis,vrm.

tables: t030, skat, sscrfields,afko,afpo,zatpp008.

data: g_save( 1)        type  c.
data: g_exit( 1)        type  c.


data: name   type vrm_id,
      list   type vrm_values,
       value  like  line  of list.

data: is_variant   like disvariant.          "ALV 儲存配置
data: is_layout    type slis_layout_alv.     "ALV 格式設定 *
data: is_layout_lvc   type lvc_s_layo.       "ALV 格式設定 *

data: sel_tab  type  table  of rsparams,
      sel_tab_wa  like  line  of sel_tab.

data:g_f4vari( 1type  c.

* 作業選取  &  ALV 儲存配置選取 ---------------------------------------
selection- screen  begin  of  block blk01  with  frame  title  text- 001.
parameters: lb_key  as listbox visible length  40 user-command upd.

selection- screenbegin  of  line.
selection- screen  comment  1( 31text- 110  for  field p_vari .
parameters: p_vari  type slis_vari.
selection- screen: end  of  line.
selection- screen  end  of   block blk01.


*條件選取 -----------------------------------------------------
selection- screen  begin  of  block blk02  with  frame  title  text- 002.

parameters : p_werks  like afpo-pwerk obligatory .
select-options :  s_aufnr  for zatpp008-aufnr. "工单号码a
parameters : p_dept   like zatpp008-dept obligatory.
select-options :  s_matnr  for zatpp008-matnr .  "工單生產料號
select-options :  s_idnrk  for zatpp008-matnr.   "下階料

selection- screen  end  of  block blk02.

selection- screen  begin  of  block block1  with  frame  title  text- 102.

selection- screen  comment /01( 78text- 401.
selection- screen  skip  1.

selection- screen  begin  of  line.
selection- screen pushbutton  10( 20text- 230 user-command but2230.
selection- screen pushbutton  40( 20text- 231 user-command but2231.
selection- screen  end  of  line.

selection- screen  skip  1.

selection- screen  begin  of  line.
selection- screen pushbutton  10( 20text- 234 user-command but2234.
selection- screen pushbutton  40( 30text- 236 user-command but2236.
selection- screen  end  of  line.
selection- screen  end  of  block block1.


initialization .


*由 T-CODE -> SU01 取得使用者帳號,頁簽 -參數,針對參數設定值        *
   get  parameter  id  'WRK'  field p_werks.

   perform set_listbox.

   "取得初始作業 其 ALV 儲存配置預設值
  g_save =  'A'.
   "ALV ABAP 程式名稱命名規則 ->程式名稱 加 -流水號                    *
   perform get_default_variant  using  'ZAPP02R2230-1'.




at selection- screen  output.
   case lb_key.
     when  'A'.
     when  'B'.
     when  'T'.
     when  'U'.
     when  'P'.
     when  'S'.
   endcase..

at selection- screen  on lb_key.


at selection- screen.
   "檢查權限,因畫面工廠只能輸入單一值,故在此檢查,若可輸入多工廠,
   "請在資料處理迴路中進行檢查
   perform check_authority.



   "若畫面欄位  -> ALV 儲存配置 未按 F4 進行選取,
   "則以畫面欄位-> 作業選取 ,所選定作業取得其預設 ALV儲存配置
   if g_f4vari  is  initial .
     case lb_key.  "作業選取
       when  'A'.                                              "1 工單-表頭
         "ALV ABAP 程式名稱命名規則 ->程式名稱 加 -流水號            *
         perform get_default_variant  using  'ZAPP02R2230-1'.
       when  'B'.                                              "2 工單-下階料
         "ALV ABAP 程式名稱命名規則 ->程式名稱 加 -流水號            *
         perform get_default_variant  using  'ZAPP02R2230-2'.
     endcase.
   endif.

   "若畫面欄位  -> ALV 儲存配置 有按 F4 進行選取, 在此將旗標清除
   clear:g_f4vari.
   "點擊 Pushbutton 鏈接
   perform select_screen.


at selection- screen  on  value-request  for p_vari. "ALV 儲存配置 按 F4 查詢
   case lb_key.   "作業選取
     when  'A'.
       perform f4_alv_variant  using  'ZAPP02R2230-1'.
     when  'B'.
       perform f4_alv_variant  using  'ZAPP02R2230-2'.
   endcase.
   "將旗標設成 'X', 表示有按 F4 查詢  ,
   "此旗標在 AT SELECTION-SCREEN  會有判定處理
   move  'X'  to g_f4vari.






start- of-selection.

"執行  轉向 TCODE
   perform post_tcode.

*&---------------------------------------------------------------------*
*&      Form  f4_alv_variant
*&---------------------------------------------------------------------*
*       ALV 儲存配置 按 F4 查詢
*----------------------------------------------------------------------*
form f4_alv_variant  using u_prgm.
   data: is_variantx   like disvariant.          "ALV 儲存配置
  is_variantx- report = u_prgm.
   call  function  'REUSE_ALV_VARIANT_F4'
     exporting
      is_variant    = is_variant
      i_save        = g_save
     importing
      e_exit        = g_exit
      es_variant    = is_variantx
     exceptions
      not_found     =  1
      program_error =  2.

   if sy-subrc =  2.
     message  id sy-msgid  type  's'       number sy-msgno
             with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
   else.
     if g_exit = space.
      p_vari = is_variantx-variant.   "將選取值傳回畫面欄位
     endif.
   endif.

endform.
*&---------------------------------------------------------------------*
*&      Form  check_authority
*&---------------------------------------------------------------------*
*       檢查權限
*----------------------------------------------------------------------*
form check_authority.

   "必須有查詢 工單權限
  authority- check object  'C_AFKO_AWA'
            id  'ACTVT'   field  '03'
            id  'AUFART'  field  '*'
            id  'AUTYP'   field  '10'
            id  'WERKS'   field   p_werks.
   if sy-subrc <>  0.
*    MESSAGE s009(zapp01) WITH p_dwerk .
*    message s009 with p_werks .
*    stop.
   endif.
endform.                     "check_authority
*&---------------------------------------------------------------------*
*&      Form  Post_tcode
*&---------------------------------------------------------------------*
*       執行轉向 TCODE
*----------------------------------------------------------------------*
form post_tcode.
   perform post_data.
   case lb_key.
     when  'A'.
       submit yapp02r2230  with selection- table sel_tab  and  return.
     when  'B'.
       submit yapp02r2230  with selection- table sel_tab  and  return.
     when  'T'.
       submit zapp02r2231  with selection- table sel_tab  and  return.
     when  'U'.
       submit zapp02r2231  with selection- table sel_tab  and  return.
     when  'X'.
       submit zapp02r2234  with selection- table sel_tab  and  return.
     when  'P'.
       submit zapp02r2236  with selection- table sel_tab  and  return.
   endcase.

endform.                     "Post_tcode
*&---------------------------------------------------------------------*
*&      Form  post_data
*&---------------------------------------------------------------------*
*       組合 選擇數據 進行傳遞
*----------------------------------------------------------------------*
form post_data.

   clear:sel_tab,sel_tab[].

  sel_tab_wa-selname =  'LB_KEY'.
  sel_tab_wa- sign    =  'I'.
  sel_tab_wa-option  =  'EQ'.
  sel_tab_wa-low     = lb_key.
   append sel_tab_wa  to sel_tab.

  sel_tab_wa-selname =  'P_VARI'.
  sel_tab_wa- sign    =  'I'.
  sel_tab_wa-option  =  'EQ'.
  sel_tab_wa-low     = p_vari.
   append sel_tab_wa  to sel_tab.

  sel_tab_wa-selname =  'P_WERKS'.
  sel_tab_wa- sign    =  'I'.
  sel_tab_wa-option  =  'EQ'.
  sel_tab_wa-low     = p_werks.
   append sel_tab_wa  to sel_tab.

   loop  at s_aufnr.
    sel_tab_wa-selname =  'S_AUFNR'.
    sel_tab_wa- sign    = s_aufnr- sign.
    sel_tab_wa-option  = s_aufnr-option.
    sel_tab_wa-low     = s_aufnr-low.
    sel_tab_wa-high    = s_aufnr-high.
     append sel_tab_wa  to sel_tab.
   endloop.


  sel_tab_wa-selname =  'P_DEPT'.
  sel_tab_wa- sign    =  'I'.
  sel_tab_wa-option  =  'EQ'.
  sel_tab_wa-low     = p_dept.
   append sel_tab_wa  to sel_tab.

   loop  at s_matnr.
    sel_tab_wa-selname =  'S_MATNR'.
    sel_tab_wa- sign    = s_matnr- sign.
    sel_tab_wa-option  = s_matnr-option.
    sel_tab_wa-low     = s_matnr-low.
    sel_tab_wa-high    = s_matnr-high.
     append sel_tab_wa  to sel_tab.
   endloop.

   loop  at s_idnrk.
    sel_tab_wa-selname =  'S_IDNRK'.
    sel_tab_wa- sign    = s_idnrk- sign.
    sel_tab_wa-option  = s_idnrk-option.
    sel_tab_wa-low     = s_idnrk-low.
    sel_tab_wa-high    = s_idnrk-high.
     append sel_tab_wa  to sel_tab.
   endloop.


endform.                     "post_data
*&---------------------------------------------------------------------*
*&      Form  set_listbox
*&---------------------------------------------------------------------*
*       初始化 領料單類型 KEY值
*----------------------------------------------------------------------*
form set_listbox.
   clear: list[].
  name   =  'LB_KEY'.
  lb_key =  'A'.

   value- key =  'A'.   value- text =  text- 501.
   append  value  to list.

   value- key =  'B'.   value- text =  text- 502.
   append  value  to list.

   value- key =  'T'.   value- text =  text- 503.
   append  value  to list.

   value- key =  'U'.   value- text =  text- 504.
   append  value  to list.

   value- key =  'X'.   value- text =  text- 505.
   append  value  to list.

   value- key =  'P'.   value- text =  text- 506.
   append  value  to list.


   call  function  'VRM_SET_VALUES'
     exporting
       id     = name
      values = list.
endform.                     "set_listbox
*&---------------------------------------------------------------------*
*&      Form  get_default_variant
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->U_PRGM     text
*----------------------------------------------------------------------*
form get_default_variant  using u_prgm.
   clear is_variant.

  is_variant- report = u_prgm.
   call  function  'REUSE_ALV_VARIANT_DEFAULT_GET'
     exporting
      i_save        = g_save
       " A,U --> 先取使用者設定預設,若無再取 Global 設定預設
       " X   --> 僅取 Global 設定預設
     changing
      cs_variant    = is_variant
     exceptions
      wrong_input   =  1
      not_found     =  2
      program_error =  3.

   if sy-subrc =  0.
    p_vari = is_variant-variant.   "將選取值傳回畫面欄位
   endif.

endform.                     "get_default_variant
*&---------------------------------------------------------------------*
*&      Form  select_screen
*&---------------------------------------------------------------------*
*       點擊 畫面 Pushbutton 鏈接TCODE
*----------------------------------------------------------------------*
form select_screen.
   if sscrfields-ucomm =  'BUT2230'.
     perform post_data.
     submit yapp02r2230  with selection- table sel_tab  and  return.
   endif.
   if sscrfields-ucomm =  'BUT2231'.
     perform post_data.
     submit zapp02r2231  with selection- table sel_tab  and  return.
   endif.

   if sscrfields-ucomm =  'BUT2234'.
     perform post_data.
     submit zapp02r2234  with selection- table sel_tab  and  return.
   endif.

   if sscrfields-ucomm =  'BUT2236'.
     perform post_data.
     submit zapp02r2236  with selection- table sel_tab  and  return.
   endif.

endform.                     "select_screen
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值