ABAP 年月F4

Posted 想发财的小夏

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ABAP 年月F4相关的知识,希望对你有一定的参考价值。

ABAP年月F4搜索帮助,实现效果如下:

代码如下:

PARAMETERS: p_spmon TYPE mcs1-spmon DEFAULT sy-datum+0(6) OBLIGATORY.           " 导入年月

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_spmon.
  PERFORM frm_spmon_f4.

FORM frm_spmon_f4.

  DATA: BEGIN OF ls_dynpfields.
          INCLUDE STRUCTURE dynpread.
  DATA: END   OF ls_dynpfields,
  lt_dynpfields LIKE TABLE OF ls_dynpfields.

  DATA: lv_returncode LIKE sy-subrc,
        lv_monat      LIKE isellist-month,
        lv_hlp_repid  LIKE sy-repid.

  GET CURSOR FIELD ls_dynpfields-fieldname.
  APPEND ls_dynpfields TO lt_dynpfields.
  lv_hlp_repid = sy-repid.

  DO 2 TIMES.
    CALL FUNCTION 'DYNP_VALUES_READ'
      EXPORTING
        dyname               = lv_hlp_repid
        dynumb               = sy-dynnr
      TABLES
        dynpfields           = lt_dynpfields
      EXCEPTIONS
        invalid_abapworkarea = 01
        invalid_dynprofield  = 02
        invalid_dynproname   = 03
        invalid_dynpronummer = 04
        invalid_request      = 05
        no_fielddescription  = 06
        undefind_error       = 07.
    IF sy-subrc = 3.
      lv_hlp_repid = 'SAPLALDB'.
    ELSE.
      READ TABLE lt_dynpfields INTO ls_dynpfields INDEX 1.
      TRANSLATE ls_dynpfields-fieldvalue USING '_ '.
      EXIT.
    ENDIF.
  ENDDO.

  IF sy-subrc = 0.

    CALL FUNCTION 'CONVERSION_EXIT_PERI_INPUT'
      EXPORTING
        input         = ls_dynpfields-fieldvalue
      IMPORTING
        output        = lv_monat
      EXCEPTIONS
        error_message = 1.

    IF lv_monat IS INITIAL.
      lv_monat = sy-datlo(6).
    ENDIF.

    CALL FUNCTION 'POPUP_TO_SELECT_MONTH'
      EXPORTING
        actual_month               = lv_monat
      IMPORTING
        selected_month             = lv_monat
        return_code                = lv_returncode
      EXCEPTIONS
        factory_calendar_not_found = 01
        holiday_calendar_not_found = 02
        month_not_found            = 03.
    IF sy-subrc = 0 AND lv_returncode = 0.
      CALL FUNCTION 'CONVERSION_EXIT_PERI_OUTPUT'
        EXPORTING
          input  = lv_monat
        IMPORTING
          output = ls_dynpfields-fieldvalue.
      COLLECT ls_dynpfields INTO lt_dynpfields.
      CALL FUNCTION 'DYNP_VALUES_UPDATE'
        EXPORTING
          dyname               = lv_hlp_repid
          dynumb               = sy-dynnr
        TABLES
          dynpfields           = lt_dynpfields
        EXCEPTIONS
          invalid_abapworkarea = 01
          invalid_dynprofield  = 02
          invalid_dynproname   = 03
          invalid_dynpronummer = 04
          invalid_request      = 05
          no_fielddescription  = 06
          undefind_error       = 07.

    ENDIF.

  ENDIF.

ENDFORM.

以上是关于ABAP 年月F4的主要内容,如果未能解决你的问题,请参考以下文章

ABAP 年月F4

ABAP f4帮助输入多个值

ABAP 实现内表自定义的F4功能

ABAP ALV F4帮助

ABAP DIALOG POV F4搜索帮助

abap中怎么快速的查找一个结构中的字段,有没啥通用的方法?