登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

原来为了你

我的人生就是要一次次的超越

 
 
 

日志

 
 
 
 

some functions for F4 at selection screen  

2011-01-27 15:08:07|  分类: ABAP屏幕操作 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

report  ztest_sc_3   no standard page heading.

*Include
include: rmcs0f0m.

*Types & data: For dropdownlist
parameter:
  p_file     type rlgrap-filename,  "file parameter
  p_monat    type spmon default sy-datum+0(6),
  p_week     type scal-week,
  p_carrid   type spfli-carrid default '%',
  p_car2     type spfli-carrid default '%'.


*1. Value help for p_file
at selection-screen on value-request for  p_file.
*1-1. call File FM
  call function 'KD_GET_FILENAME_ON_F4'
    exporting
      program_name  = syst-repid
      dynpro_number = syst-dynnr
      static        = 'X'     "field_name = 'c:\'
      mask          = '*.*'
    changing
      file_name     = p_file
    exceptions
      mask_too_long = 1
      others        = 2.

  if sy-subrc <> 0.
    "value-help error
    message 'value-help error' type 'E'.
  endif.



*2. Value help for p_monat

at selection-screen on value-request for  p_monat.
*2-1. call standard F4-help FM for MONAT
  perform monat_f4. "from the include



*3. Value help for p_week
at selection-screen on value-request for  p_week.
*3-1. call standard F4-help FM for p_week
  perform f4_for_week.

*4. Value help for  p_connid,call F4 Help using Internal table
at selection-screen on value-request for   p_carrid.

  data:
     ls_dyn_field   type  dynpread,   "very important
     lt_dyn_field   type  table of dynpread,
     lt_spfli       type  table of  spfli.

  ls_dyn_field-fieldname = 'P_CARRID'.
  append ls_dyn_field to lt_dyn_field.  " carrid

*4-1. get the values in the dynpro
  call function 'DYNP_VALUES_READ'
    exporting
      dyname               = sy-repid
      dynumb               = sy-dynnr
    tables
      dynpfields           = lt_dyn_field
    exceptions
      invalid_abapworkarea = 1
      invalid_dynprofield  = 2
      invalid_dynproname   = 3
      invalid_dynpronummer = 4
      invalid_request      = 5
      no_fielddescription  = 6
      invalid_parameter    = 7
      undefind_error       = 8
      double_conversion    = 9
      stepl_not_found      = 10
      others               = 11.

  if sy-subrc <> 0.
    write:/ 'error occurs in read_value.'.
    leave list-processing.
  endif.

  read table lt_dyn_field into ls_dyn_field with key fieldname = 'P_CARRID'.



*4-2. get the table-value from BD

  select * from spfli into table  lt_spfli
    where carrid like ls_dyn_field-fieldvalue.

*4-3. form the F4Help
  call function 'F4IF_INT_TABLE_VALUE_REQUEST'
    exporting
      retfield               = 'CARRID'
      dynpprog               = sy-repid
      dynpnr                 = sy-dynnr
      dynprofield            = 'P_CARRID'
      value_org              = 'S' "s:structure;default(c):cell by cell
    tables
      value_tab              = lt_spfli
   exceptions
     parameter_error        = 1
     no_values_found        = 2
     others                 = 3.

*5. Value help for  p_connid,call F4 Help using Internal table
at selection-screen on value-request for  p_car2.
  data:
     ls_dyn_field   type  dynpread,   "very important
     lt_dyn_field   type  table of dynpread.

  data:
     ls_fields  type help_value,
     lt_fields  type table of help_value.

  types:
     begin of typ_value,
       carrid  type  spfli-carrid,
       connid  type  spfli-connid,
     end of typ_value.

  data:
     ls_value  type typ_value,
     lt_value  type table of typ_value.

*5-1. For the fields and value
  ls_fields-tabname = 'SPFLI'.
  ls_fields-fieldname = 'CARRID'.
  ls_fields-selectflag = 'X'.

  append ls_fields to lt_fields.



*5-2. Dynpro

  ls_dyn_field-fieldname = 'P_CAR2'.
  append ls_dyn_field to lt_dyn_field.  " carrid

*5-3. get the values in the dynpro
  call function 'DYNP_VALUES_READ'
    exporting
      dyname               = sy-repid
      dynumb               = sy-dynnr
    tables
      dynpfields           = lt_dyn_field
    exceptions
      invalid_abapworkarea = 1
      invalid_dynprofield  = 2
      invalid_dynproname   = 3
      invalid_dynpronummer = 4
      invalid_request      = 5
      no_fielddescription  = 6
      invalid_parameter    = 7
      undefind_error       = 8
      double_conversion    = 9
      stepl_not_found      = 10
      others               = 11.

  if sy-subrc <> 0.
    write:/ 'error occurs in read_value.'.
    leave list-processing.
  endif.

  read table lt_dyn_field into ls_dyn_field with key fieldname = 'P_CAR2'.

*5-4. get the table-value from BD
  select carrid connid from spfli into table  lt_value
    where carrid like ls_dyn_field-fieldvalue.

*5-5. form the F4Help

  call function 'HELP_VALUES_GET_WITH_TABLE'
    exporting
      title_in_values_list      = 'carrid-selection'
      titel                     = 'carrid-selection-internal'
    importing
      select_value              = p_car2
    tables
      fields                    = lt_fields
      valuetab                  = lt_value
    exceptions
      field_not_in_ddic         = 1
      more_then_one_selectfield = 2
      no_selectfield            = 3
      others                    = 4.

  if sy-subrc <> 0.
    "do nothing
  endif.

*&———————————————————————*

*&      Form  F4_FOR_WEEK

*&———————————————————————*

*       call standard F4-help FM for p_week

*———————————————————————-*

form f4_for_week .

  data:
    lv_date  type d.
*6-1. Get the date

  call function 'F4_DATE'
   exporting
     date_for_first_month               = sy-datum
   importing
     select_date                        = lv_date
   exceptions
     calendar_buffer_not_loadable       = 1
     date_after_range                   = 2
     date_before_range                  = 3
     date_invalid                       = 4
     factory_calendar_not_found         = 5
     holiday_calendar_not_found         = 6
     parameter_conflict                 = 7
     others                             = 8.
  if sy-subrc <> 0.
    "do nothing
  endif.

*6-2. Get the week 
返回值是一年中的第几周
  call function 'DATE_GET_WEEK'" f4_for_week
    exporting
      date         = lv_date
    importing
      week         = p_week
    exceptions
      date_invalid = 1
      others       = 2.
  if sy-subrc <> 0.
    "do nothing
  endif.
endform.                    "F4_FOR_WEEK

  评论这张
 
阅读(557)| 评论(0)

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018