ABAP-年月期间搜索帮助详解编程语言

selection-screen begin of block block1 with frame title text-001. 
 
parameters:p_mon1 like s031-spmon, 
 
           p_mon2 like s031-spmon. 
 
selection-screen end of block block1. 
 
  
 
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_mon1. 
 
  PERFORM MONAT_F4. 
 
  
 
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_mon2. 
 
  PERFORM MONAT_F4. 
 
  
 
FORM MONAT_F4 . 
 
  DATA: BEGIN OF MF_DYNPFIELDS OCCURS 1. 
 
          INCLUDE STRUCTURE DYNPREAD. 
 
  DATA: END   OF MF_DYNPFIELDS. 
 
  DATA: MF_RETURNCODE   LIKE SY-SUBRC, 
 
        MF_MONAT        LIKE ISELLIST-MONTH, 
 
        MF_HLP_REPID    LIKE SY-REPID. 
 
  FIELD-SYMBOLS: <MF_FELD>. 
 
  
 
* Wert von Dynpro lesen 
 
  GET CURSOR FIELD MF_DYNPFIELDS-FIELDNAME. 
 
  APPEND MF_DYNPFIELDS. 
 
  MF_HLP_REPID = SY-REPID. 
 
  DO 2 TIMES. 
 
    CALL FUNCTION 'DYNP_VALUES_READ' 
 
      EXPORTING 
 
        DYNAME               = MF_HLP_REPID 
 
        DYNUMB               = SY-DYNNR 
 
      TABLES 
 
        DYNPFIELDS           = MF_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. 
 
*     Aktuelles Dynpro ist Wertemengenbild 
 
      MF_HLP_REPID = 'SAPLALDB'. 
 
    ELSE. 
 
      READ TABLE MF_DYNPFIELDS INDEX 1. 
 
*     Unterstriche durch Blanks ersetzen 
 
      TRANSLATE MF_DYNPFIELDS-FIELDVALUE USING '_ '. 
 
      EXIT. 
 
    ENDIF. 
 
  ENDDO. 
 
  IF SY-SUBRC = 0. 
 
*   Konvertierung ins interne Format 
 
    CALL FUNCTION 'CONVERSION_EXIT_PERI_INPUT' 
 
      EXPORTING 
 
        INPUT         = MF_DYNPFIELDS-FIELDVALUE 
 
      IMPORTING 
 
        OUTPUT        = MF_MONAT 
 
      EXCEPTIONS 
 
        ERROR_MESSAGE = 1. 
 
    IF MF_MONAT IS INITIAL. 
 
*     Monat ist initial => Vorschlagswert aus akt. Datum ableiten 
 
      MF_MONAT = SY-DATLO(6). 
 
    ENDIF. 
 
    CALL FUNCTION 'POPUP_TO_SELECT_MONTH' 
 
      EXPORTING 
 
        ACTUAL_MONTH               = MF_MONAT 
 
      IMPORTING 
 
        SELECTED_MONTH             = MF_MONAT 
 
        RETURN_CODE                = MF_RETURNCODE 
 
      EXCEPTIONS 
 
        FACTORY_CALENDAR_NOT_FOUND = 01 
 
        HOLIDAY_CALENDAR_NOT_FOUND = 02 
 
        MONTH_NOT_FOUND            = 03. 
 
    IF SY-SUBRC = 0 AND MF_RETURNCODE = 0. 
 
      CALL FUNCTION 'CONVERSION_EXIT_PERI_OUTPUT' 
 
        EXPORTING 
 
          INPUT  = MF_MONAT 
 
        IMPORTING 
 
          OUTPUT = MF_DYNPFIELDS-FIELDVALUE. 
 
      COLLECT MF_DYNPFIELDS. 
 
      CALL FUNCTION 'DYNP_VALUES_UPDATE' 
 
        EXPORTING 
 
          DYNAME               = MF_HLP_REPID 
 
          DYNUMB               = SY-DYNNR 
 
        TABLES 
 
          DYNPFIELDS           = MF_DYNPFIELDS 
 
        EXCEPTIONS 
 
          INVALID_ABAPWORKAREA = 01 
 
          INVALID_DYNPROFIELD  = 02 
 
          INVALID_DYNPRONAME   = 03 
 
          INVALID_DYNPRONUMMER = 04 
 
          INVALID_REQUEST      = 05 
 
          NO_FIELDDESCRIPTION  = 06 
 
          UNDEFIND_ERROR       = 07.           "<<== note 148804 
 
    ENDIF. 
 
  ENDIF. 
 
ENDFORM.                                                    " MONAT_F4

*************************************************************************************

"前一个月 
 
data:datum type sy-datum. 
 
CALL FUNCTION 'BKK_ADD_MONTH_TO_DATE' 
 
  EXPORTING 
 
    MONTHS        = -1 
 
    OLDDATE       = sy-datum 
 
  IMPORTING 
 
    NEWDATE       = datum 
 
          . 
 
  
 
  p_mon1 = datum+0(6). 
 
  p_mon2 = sy-datum+0(6).

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/17961.html

(0)
上一篇 2021年7月19日 20:41
下一篇 2021年7月19日 20:41

相关推荐

发表回复

登录后才能评论