Sunday, November 21, 2010

Quarter Validation when input is given date

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_accp   FOR  lv_buper  OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1.



ranges: r_faedn   FOR dfkkop-faedn.




DATA: lv_year(4) TYPE n.
  CLEAR r_faedn.
  r_faedn-sign = 'I'.
  r_faedn-option = 'EQ'.
  CASE s_accp-low+4(2).
    WHEN '01' OR '02' OR '03'.
*      lv_year = s_accp-low(4).
*      lv_year = lv_year - 1.
*      CONCATENATE lv_year '1001'
*      INTO r_faedn-low.
*      CONCATENATE lv_year '1231'
*      INTO r_faedn-high.
      CONCATENATE s_accp-low(4)  '0101'
      INTO r_faedn-low.
      CONCATENATE s_accp-low(4) '0331'
      INTO r_faedn-high.
      APPEND r_faedn.
      CLEAR : r_faedn-low,
              r_faedn-high.
    WHEN '04' OR '05' OR '06'.
      CONCATENATE s_accp-low(4) '0401'
      INTO r_faedn-low.
      CONCATENATE s_accp-low(4) '0630'
      INTO r_faedn-high.
      APPEND r_faedn.
      CLEAR : r_faedn-low,
              r_faedn-high.
    WHEN '07' OR '08' OR '09'.
      CONCATENATE s_accp-low(4) '0701'
      INTO r_faedn-low.
      CONCATENATE s_accp-low(4) '0930'
      INTO r_faedn-high.
      APPEND r_faedn.
      CLEAR : r_faedn-low,
              r_faedn-high.
    WHEN '10' OR '11' OR '12'.
      CONCATENATE s_accp-low(4) '1001'
      INTO r_faedn-low.
      CONCATENATE s_accp-low(4) '1231'
      INTO r_faedn-high.
      APPEND r_faedn.
      CLEAR : r_faedn-low,
              r_faedn-high.
  ENDCASE.
  CASE s_accp-high+4(2).
    WHEN '01' OR '03' OR '05' OR '07' OR
         '08' OR '10' OR '12'.
      CONCATENATE s_accp-high(6) '31'
              INTO gv_sett_dt.
    WHEN '04' OR '06' OR '09' OR '11'.
      CONCATENATE s_accp-high(6) '30'
              INTO gv_sett_dt.
    WHEN '02'.
      CONCATENATE s_accp-high(6) '28'
              INTO gv_sett_dt.
  ENDCASE.

Friday, November 19, 2010

Function Module gives the Quarter start date and end date.

 l_month = sy-datum+4(2).

* Set quarter
  ex_quarter-q = trunc( ( l_month - 1 ) / 3 ) + 1.
 ex_quarter-q = ex_quarter-q - 1
* Set year
  ex_quarter-year = sy-datum(4).

* the below Function Module gives you the Quarter start date and end date.
call function 'HR_99S_GET_DATES_QUARTER'
    exporting
      im_quarter       = ex_quarter-q
      im_year          = ex_quarter-year
    importing
      ex_begda         = ex_quarter-begda             " Quarter Start date
      ex_endda         = ex_quarter-endda.            " Quarter End date

FM: Quarter Validation based on given date

* Set quarter
  ex_quarter-q = trunc( ( l_month - 1 ) / 3 ) + 1.

* Set year
  ex_quarter-year = sy-datum(4).

* the below Function Module gives you the Quarter start date and end date.
call function 'HR_99S_GET_DATES_QUARTER'
    exporting
      im_quarter       = ex_quarter-q
      im_year          = ex_quarter-year
    importing
      ex_begda         = ex_quarter-begda             " Quarter Start date
      ex_endda         = ex_quarter-endda.            " Quarter End date

Wednesday, November 10, 2010

F4 help for select-options

************************************************************************
*                      TYPES DECLARATION
************************************************************************


Types: begin of ty_sercd,
         venture_cd type zri_series-venture_cd,
         series_cd  type zri_series-series_cd,       "RI: Series Code
       end of ty_sercd.
data : gt_sercd     type standard table of ty_sercd.  "Internal Table
         
         


SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

SELECT-OPTIONS: s_sercd  for  zri_series-series_cd,               
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN END OF BLOCK b1.


**---------------------------------------------------------------------*
**     AT SELECTION-SCREEN ON VALUE-REQUEST
**---------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_sercd-low.
  PERFORM f4_help_sercd.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_sercd-HIGH.
  PERFORM f4_help_sercd.

*&---------------------------------------------------------------------*
*&      Form  F4_HELP_SERCD
*&---------------------------------------------------------------------*
*       F4 Help for Series Code
*----------------------------------------------------------------------*

FORM f4_help_sercd .

  REFRESH : GT_SERCD.

  SELECT  venture_cd  series_cd
         FROM zri_series
         INTO CORRESPONDING FIELDS OF TABLE gt_sercd.

  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
      retfield    = 'SERIES_CD'
      dynpprog    = sy-repid
      dynpnr      = SY-DYNNR
      dynprofield = 'S_SERCD'
      value_org   = 'S'
    TABLES
      value_tab   = gt_sercd
    EXCEPTIONS
      OTHERS      = 0.

ENDFORM.