Year Validation?

I've used Spry Validation text boxes throughout a project and now need to enter a year in YYYY format,
The problem is all the existing date formats include the day and month too (which I don''t need)
I'd still like to use spry to validate so the error messages match my other fields,
So how do I validate on just the year?
p.s. at the moment I just validate on > 1900 or < 2010 which is a bit of compromise.
Thanks
Adam.

Try the following
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>test spry</title> 
<link  href="SpryAssets/SpryValidationTextField.css" rel="stylesheet"  type="text/css" />
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<script>
var correctYear = function(value, options){
    var theDate=new Date();
    var theYear=theDate.getFullYear();
    if (value < 1900 || value > theYear)
        return false;
    return true;
</script>
</head>
<body>
<span id="sprytextfield1">
<label>
  <input type="text" name="text1" id="text1" />
</label>
<span class="textfieldRequiredMsg">A value is required.</span></span>
<script>
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "custom", {validation: correctYear, validateOn:["change", "blur"]});
</script>
</body>
</html>
I hope this helps.
Ben

Similar Messages

  • From & To Year Validation

    Hi Experts,
    I have two year variables Year1 and Year2 for input in the BEx report. Year2 should be always greater than Year1. I want to display error message if Year1 <= Year2. How can I achieve this validation.
    Thank you,
    Ramana.

    can u xplain how are u using year1 and year2
    frm wat i understand year1 = from year value
    year2 =  to year value
    so for e.g. if you want to see the Price for From Year1 to To year2
    is this how u r intending to use year1 and year2
    if yes then in Price Selection if you create Interval variable , first value as year1 and second as year2 then this way it will automatically detect the year1 as smaller value and year2 of greater value.
    i will like to understand wat exactly is ur scenario
    how r u using year1 and year2
    And if above is the case than u can create only 1 variable and create it as interval option....
    And if this is not the case
    Then as a work around try following thing :
    Lets say u have price1 and price2
    Price1 has time variable year1
    price 2 has time variable year2
    now you can restrict the price1 in its own selection by bringing fiscal year and year1 as variable
    when u intend to do similar for price2 follow below thing.
    Bring price2 from keyfigure section to columns
    hit price2 right click and select edit
    in selection screen bring fiscal year from dimension to right screen
    hit fiscal year and hit restrict
    in restrict screen you can select year2 from variable tab and bring in right dialog box.
    this is not done yet
    you hit Value ranges tab and then u will see options such as between, greater smaller etc.
    Choose Greater than option
    Choose year 1 and hit transfer
    so now for price2 u restricted fiscal year with year2 and value > year1
    this will help u showing error messge to user when they try to enter different values, and it will bring in NO DATA.

  • Is the SAP note (old, 2001 year) valid?

    Hi!
    I am trying to create source system in BW  to connect from BW-system  to SAP source system.  I can connect to SAP system but when I click on use (RFC connection) I get message "Error during insert in port table". I found SAP note with number 110849 but it is was released in 2001 year. I work with Netweaver 7.0. Can I use this note to correct error?
    Thanks,
    Olga

    Olga,
    There is another alternative solution here which does not require transaction SNOTE usage - go to SAP Service Marketplace, open the required SAP Note and check section "Affected Releases", where you will be able to find out information on software components' release versions which are affected. Just find out if the one which you use is in the list - if not, then the SAP Note is not applicable for your system. The second step in case the first one is passed and you found your release version in the list of affected releases is to verify Support Package level: ensure that Support Package which delivers the correction for this software component hasn't yet been implemented in your system (if it or higher Support Packages are implemented, then you should already have the correction applied in your system).
    My regards,
    Vadim

  • Month and Year Validation

    Hi All !
    I want to check whether a given date in my form is less than or greater than sysdate..
    I used the coding
    if trim(:empaply.fromdate)<trim(sysdate) then
         message('Check the from date you have given !');This condition checks only the date and not the month and year ..
    So, how can i check the month and year is less than the current sysdate in sql?
    pls help me with a solution..
    Thanks and Regards
    user 10685325

    Hi in sql when you do the comparision it check the whole date I believe not just the date part.
    you can see it for yourself
    SQL> select * from emp where HIREDATE<to_date('01-jun-2009','dd-mon-rrrr');
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7839 KING       PRESIDENT            17-NOV-81       5000                    10
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
          7369 SMITH      CLERK           7902 17-DEC-80        800                    20
          7788 SCOTT      ANALYST         7566 09-DEC-82       3000                    20
          7876 ADAMS      CLERK           7788 12-JAN-83       1100                    20
          7934 MILLER     CLERK           7782 23-JAN-82       1300                    10
    14 rows selected.the hiredate of first employee in 17-NOV-81 and compare it with '01-jun-2009' so it has checked whole date part not just 17 and 01 do not use TRIM

  • CoCd validation in controlling area

    Hi Gurus,
    I want to activate CoCd validation checkbox in the controlling area using OKKP.
    This controlling area I want to change is active for some years.
    When i try to do it, I get a critical warning message although it's possible (because the co.area is active).
    I have also the option to do it as of date, and open a new record from 2010 year with this indicator.
    What option is preferred?
    Can you see any problem with any of these options?
    Thanks
    Ofer

    HI Eugene,
    Thanks
    This is the messege I get:
    Critical transport: Control indicator in controlling area
    Message no. KT364
    Diagnosis
    You want to transport the control indicators in controlling area . These indicators include All currencies. Transporting this indicator can result in serious data inconsistencies in the target system, if:
    As a result of the transport, the indicator is changed in the target system and
    In the target system, you already planned or made account assignments to CO objects (cost centers or orders for example).
    Procedure
    If the target system already contains transaction data for CO objects from the controlling area, you should carry out the transport only if this does not change the indicator in the target system.
    You can check the indicator in the Implementation Guide under:
    Controlling -> General Controlling -> Production Start-Up Preparation -> Set "Update All Currencies" Indicator.
    Choose Display indicator.
    Note
    Not that the entries displayed are the fiscal years as of which the indicator is active or inactive. This status holds until a new entry is made.
    Examples
    The target system already contains control indicators for 1994, 1997 and 2003. The following validity periods then exist:
    Control indicator for year Validity period All currencies
    1994 1994 - 1996 X
    1997 1997 - 2002 X
    2003 2003 - 9999 X
    If the source system also contains an entry for the fiscal year 2000, for which the indicator is inactive, transporting the indicator would lead to the following:
    1994 1994 - 1996 X
    1997 1997 - 1999 X
    2000 2000 - 2002
    2003 2003 - 9999 X
    In other words, for the period 2000 - 2002, the indicator would not be active in the target system.
    Procedure for System Administration
    Thanks
    Ofer

  • Sick Quota validity/ded. issue

    Hello,
    Can you guys please help me with this issue..
    we have only one sick quota and , and its validity periods are set as year to year (validity beginning of year and deduction as end of year)..
    but, we have 2 rules for new hires... for one group.. they should get quota on hire date valid thru end of year.. and for other group the quota should start after 3 months of service to end of the year. all other people with more than 1.5 yrs of service will have the quota validity and deduction dates from beginning of the year.
    so how to have different validity/ded periods of one quota type..
    Annmarie.

    here
    we can divide it into three parts
    for nornal hireing period if u want to generate the quota
    >u can check the Pro rata option in the accural period
    for the second one
    Run the Programme RPTQTA00 once only when he comepletes the 3 months of service
    for the last one also we can do same as manually
    if this is not possible thru standrad the only option is to change the code of RPTQTA00
    but check above options once

  • How to do date validation in Web Dynpro java

    Hi
    We have one requirement that One input field with date type is there.When we take Date type input field then in web dynpro Date navigater is appearing by default.Our requirement is if user enters the date manually in the input filed instead of chossing the date from the Date navigator then how we will do the following date validations manually:
    a. If user is entering the date in any format then it should convert it to dd.mm.yy format.
    b. How to do leap year validation?Suppose user is entering   29.02.20007 then it should display Invalid date.
    c. How to do the follwing date validation:
        Let's say that current running hours(Text Vie
    w) on a given engine is 100, entered on 10-Jun-2008(Running hour date-Text view)).
    -On 15-Jun-2008(New Running Hour Date-input field), I try to enter a value of 300 hours(New running hour-input field).
    -This is impossible, because only 5x24=120 hrs has passed from the previous update.
    -Hence, in this case the maximum value I can enter is 100+120=220.
    Can anybody help me in solving the above 3 date validation?

    Hi Susmita,
    For your 3 rd requirement...
    Initially you will be storing the first date entered by the user right???
    Say that date is D1. and user entered hours is H1.
    now after some days at day D2 user again trying to enter some hours say H2. Now you have to restrict user from entering hours which are
    greater than 24*D2-D1....
    so now you have to get D2-D1....
    For this....
    long l1=youdate1.getTime();   // This will convert your Date D1 into long...
    then,
    Date d=new Date(System.currentTimeMillis());
    long l2=d.getTime();  //which is a long value of current date...
    So Now l2-l1 will give you number of days between past date and today's date...
    So On Save you check for
    if((l2-l1)*24<(H2-H1))
    message("Please enter valied number of hours");
    Hope this will help you....
    Regards,
    Srinivas.

  • Increase Subordinate CA validity

    Hy,
    I want to build a Subordinate CA but using a different validity period. As you know the default it's 5 years (SubCA template), and I want to make it 10 years.
    So before I installed the Subordinate Certification Authority on the second server I created a capolicy.inf file and put put this in:
       [Version]
       Signature="$Windows NT$"
       [RequestAttributes]
       CertificateTemplate = MySubCA
    On the Root CA I duplicated the defaut certificate and name this MySubCA with a period of 10 years, then publish this certificate on the certificate templates. Now I install my Subordinate CA and save the request file, went to Root CA and issue the certificate,
    but the new certificate period it's two years. I oppened the certificate an looked at details and the certificate template that issue this one it's ok is the one I created earlier. I can't make this work until a issue the command on the  Root CA:
    certutil -setreg CA\ValidityPeriodUnits 10
    But now all my certificate will have 10 years validity. So my question as you can asume is:
    How can I make this work using capolicy.inf file and the new template, without modifying the registry
    Thanks

    In
         enterprise CA environment , Subordinate CA Validation Period was limited
         as 5 years in the SubCA template by default. All template store here:
              "CN=Certificate Templates ,CN=Public Key
         Services,CN=Services,CN=Configuration,DC=ForestRoot,DC=com"
              To modify them, login your DC ,
              launch "Active Directory Sites and
         Services". On the View menu, click "Show Services
         Node".
              goto "CN=Certificate Templates ,CN=Public Key
         Services,CN=Services,CN=Configuration,DC=ForestRoot,DC=com"
              Find out template "SubCA" , Right click it , click
         Properties
              Switch to "Properties Editor " Tab, edit
         pKIExpirationPeriod, modify the value, For
         example, hexadecimal number 00803c48d1cbf4ff = decimal number
         10
              Save it and restart certsvc.
              you will see Validation Period of SubCA template is 10 years, Now!

  • Service contract with multiple validity period

    Hi,
    I am having a requirement where i need to create service contracts with multiple validities.
    some contracts may have 1 year validity, some six months.
    I already have a transaction type for contract which is having 1 year validity period assigned in its date profile.
    can i use the same transaction to create contracts for 6 months???
    Regards,
    PePe

    Hi,
      Yes you can use the same transaction type for the other validity period. What you can do is when you create a service contract, it will automatically pick up the 1 year duration since you have defined that way. But you can write some enhancement in ORDER_SAVE Badi.
    First you create a Z table and maintain the different durations (say based on your item) in a Z table.
    For example,
    item    duration(months)
    100       6
    200       12
    300       18
    400       24
    So at the time of saving the contract, your Badi implementation will be triggered and there you can pick up relevant duration (say 6 months) based on the item entered in your contract. And once you get the duration, you can change the Contract End date accordingly and then it will be saved. This way you can get the Contract duration as per your requirement.
    Hope it HELPS...
    Regards,
    Shailesh Jadhav

  • Total Text Display at the end of the ALV

    Hi,
    I want to display the text 'TOTAL' in my ALV at the end of my report.I am pasting my code, So please any one help me in this issue.
    *& Report  ZFIR0011_O2C_TAX_GL_SUMMARY
    REPORT  zfir0011_o2c_tax_gl_summary.
    TYPE-POOLS slis.
    TABLES: faglflexa.
    Column positions to pass to field catalog
    CONSTANTS :  c_pos_1      TYPE sy-cucol       VALUE '1',   " position of the columns
                 c_pos_2      TYPE sy-cucol       VALUE '2',
                 c_pos_3      TYPE sy-cucol       VALUE '3',
                 c_pos_4      TYPE sy-cucol       VALUE '4',
                 c_pos_5      TYPE sy-cucol       VALUE '5'.
    *Field names for Field Catalog
    CONSTANTS : c_h           TYPE c              VALUE 'H',
                c_s           TYPE c              VALUE 'S',
                c_slash       TYPE c              VALUE '/',
                c_colon       TYPE c              VALUE ':',
                c_top_of_page TYPE slis_formname  VALUE 'TOP_OF_PAGE',
                c_top_of_page_split TYPE slis_formname  VALUE 'TOP_OF_PAGE_SPLIT',
                c_txjcd       TYPE slis_fieldname VALUE 'TXJCD',     "Tax Jurisdiction
                c_region      TYPE slis_fieldname VALUE 'STATE',     "State
                c_currb       TYPE slis_fieldname VALUE 'CURR_BAL',  "Current Balance
                c_perch       TYPE slis_fieldname VALUE 'PER_CHNG',  "Period Change
                c_prbal       TYPE slis_fieldname VALUE 'PRI_BALA',  "Prior Balance
                c_total       TYPE slis_fieldname VALUE 'TOTAL'.     "Total
    CONSTANTS : c_table_name  TYPE slis_tabname   VALUE 'IT_FINAL', "For Field Catalog
                c_spras       TYPE spras          VALUE 'E',        "Language
                c_buzei       TYPE c              VALUE '1',
                c_zp          TYPE bset-mwskz     VALUE 'ZP',
                c_zr          TYPE bset-mwskz     VALUE 'ZR'.
    Types Declaration.
    TYPES: BEGIN OF ty_faglflexa,
           ryear TYPE gjahr,
           bukrs TYPE bukrs,
           belnr TYPE belnr_d,                  "Document Number
           poper TYPE poper,                    "Posting Period
           budat TYPE budat,                    "Posting Date
           buzei TYPE buzei,                    "Document line item
           racct TYPE racct,                    "G/L Account no.
           END   OF ty_faglflexa,
           ty_t_faglflexa TYPE STANDARD TABLE OF ty_faglflexa.
    TYPES: BEGIN OF ty_bset,
           belnr TYPE belnr_d,
           buzei TYPE buzei,
           mwskz TYPE mwskz,                    "Tax code
          hkont TYPE hkont,
           shkzg TYPE shkzg,                    "Debit/Credit Indicator
           txjcd TYPE txjcd,                    "Tax Jurisdiction
           h2ste TYPE h2ste,                    "Tax Amount
           h2bas TYPE h2bas_bses,               "Tax Amount
           END   OF ty_bset,
           ty_t_bset TYPE STANDARD TABLE OF ty_bset.
    TYPES: BEGIN OF ty_skat,
           spras TYPE spras,
           ktopl TYPE ktopl,
           saknr TYPE saknr,
           text  TYPE txt20_skat,
           END   OF ty_skat,
           ty_t_skat TYPE STANDARD TABLE OF ty_skat.
    TYPES: BEGIN OF ty_custom,
           geo_state    TYPE char2,
           geo_county   TYPE char3,
           country      TYPE char2,
           description  TYPE char40,
           END   OF ty_custom,
           ty_t_custom TYPE STANDARD TABLE OF ty_custom.
    TYPES : BEGIN OF ty_budat,
             sign     TYPE char_01,
             option   TYPE char2,
             low      TYPE budat,
             high     TYPE budat,
            END OF ty_budat,
            ty_t_budat TYPE STANDARD TABLE OF ty_budat.
    TYPES: BEGIN OF ty_txjcd,
           geo_state  TYPE char2,
           geo_county TYPE char3,
           END   OF ty_txjcd,
           ty_t_txjcd TYPE STANDARD TABLE OF ty_txjcd.
    TYPES: BEGIN OF ty_inter,
           ryear TYPE gjahr,
           bukrs TYPE bukrs,
           txjcd TYPE txjcd,                    "Tax Jurisdiction
           racct TYPE racct,                    "G/L Account no.
           h2ste TYPE h2ste,                    "Tax Amount
           poper TYPE poper,                    "Posting Period
           belnr TYPE belnr_d,                  "Document Number
           shkzg TYPE shkzg,                    "Debit/Credit Indicator
           END   OF ty_inter,
           ty_t_inter TYPE STANDARD TABLE OF ty_inter.
    TYPES: BEGIN OF ty_final,
           txjcd    TYPE bset-txjcd,                     "Tax Jurisdiction
           state    TYPE char40,                         "State
           curr_bal TYPE bset-h2ste,                     "Current Balance
           per_chng TYPE bset-h2ste,                     "Period Change
           pri_bala TYPE bset-h2ste,                     "Prior Balance
           END   OF ty_final,
           ty_t_final TYPE STANDARD TABLE OF ty_final.
    Internal Tables Declaration.
    DATA : it_faglflexa        TYPE ty_t_faglflexa,
           it_bset             TYPE ty_t_bset,
           it_skat             TYPE ty_t_skat,
           it_custom           TYPE ty_t_custom,
           it_txjcd            TYPE ty_t_txjcd,
           it_inter            TYPE ty_t_inter.                 "Intermediate table for storing data
    DATA : it_final            TYPE ty_t_final.                 "#EC NEEDED
    *Fieldcatalogue Internal Table Declaration
    DATA : it_fieldcat         TYPE slis_t_fieldcat_alv,
           wa_fieldcat         TYPE slis_fieldcat_alv,
           it_alv_top_of_page  TYPE slis_t_listheader,
           gs_line             TYPE slis_listheader.
    *Field-symbols and Work Area Declarations
    FIELD-SYMBOLS : <fs_faglflexa>      TYPE ty_faglflexa,
                    <fs_bset>           TYPE ty_bset,
                    <fs_inter>          TYPE ty_inter.
    DATA : wa_faglflexa     TYPE ty_faglflexa,                  "#EC NEEDED
           wa_bset          TYPE ty_bset,
           wa_skat          TYPE ty_skat,
           wa_custom        TYPE ty_custom,
           wa_txjcd         TYPE ty_txjcd,
           wa_inter         TYPE ty_inter,
           wa_final         TYPE ty_final.                      " #EC NEEDED
    Variables Declaration.
    DATA : v_current_year TYPE i,
           v_poper        TYPE poper,
           v_saknr        TYPE saknr,                           "#EC NEEDED
           v_ktopl        TYPE ktopl,
           v_konts        TYPE saknr,
           v_bukrs        TYPE bukrs,
           v_buzei(2)     TYPE n VALUE '0',
           v_sum_val      TYPE h2ste,
           v_sum_val1     TYPE h2ste,
           v_sum_val2     TYPE h2ste,
           v_h2ste        TYPE string,
           v_desc         TYPE char40,
           v_title        TYPE char40,
           v_start_date   TYPE char10.             "Temp Added
    SELECTION-SCREEN
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    PARAMETERS:     p_bukrs TYPE faglflexa-rbukrs OBLIGATORY,              " Company Code
                    p_gjahr TYPE faglflexa-gjahr  OBLIGATORY.              " Fiscal Year
    SELECT-OPTIONS: s_budat FOR  faglflexa-budat  OBLIGATORY
                                                  NO-EXTENSION
                                                  NO INTERVALS.
    PARAMETERS:     p_racct TYPE faglflexa-racct  OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK b1.
    SELECTION-SCREEN VALIDATIONS.
    *Company Code Validation.
    AT SELECTION-SCREEN ON p_bukrs.
      SELECT SINGLE bukrs INTO v_bukrs
      FROM t001
      WHERE bukrs = p_bukrs.
      IF sy-subrc NE 0.
        MESSAGE text-002 TYPE 'E'.
      ENDIF.
    Fiscal Year Validation. It should not be more than Current.
    AT SELECTION-SCREEN ON p_gjahr.
      v_current_year = sy-datum+0(4).
      IF p_gjahr > v_current_year.
        MESSAGE text-003 TYPE 'E'.
      ENDIF.
    *G/L Account Validation.
    AT SELECTION-SCREEN ON p_racct.
      SELECT SINGLE saknr INTO v_saknr
      FROM skb1
      WHERE saknr EQ p_racct
      AND   bukrs EQ p_bukrs.
      IF sy-subrc EQ 0.
        SELECT SINGLE ktopl FROM t001
        INTO v_ktopl
        WHERE bukrs = p_bukrs.
        SELECT SINGLE konts FROM t030k
        INTO v_konts
        WHERE ktopl = v_ktopl
        AND   konts = v_saknr.
        IF sy-subrc NE 0.
          MESSAGE text-004 TYPE 'E'.
        ENDIF.
      ELSE.
        MESSAGE text-004 TYPE 'E'.
      ENDIF.
    START-OF-SELECTION.
      PERFORM get_data USING p_bukrs
                             p_gjahr
                             s_budat[]
                             p_racct  CHANGING it_final.
    *Display report in ALV grid
      IF it_final IS NOT INITIAL.
    *Build Top of the page table.
        PERFORM comment_build USING it_skat CHANGING it_alv_top_of_page.
    *Build Field catalog table for ALV
        PERFORM build_field_catalog CHANGING it_fieldcat.
    *Display report
        PERFORM display_alv USING it_final.
      ELSE.
    *No data found for the selection criteria/period.
        MESSAGE text-018 TYPE 'I'.
      ENDIF.
    *&      Form  GET_DATA
          text
         -->P_P_BUKRS  text
         -->P_P_GJAHR  text
         -->P_P_BUDAT  text
         -->P_P_RACCT  text
         <--P_IT_FINAL  text
    FORM get_data  USING    fp_bukrs     TYPE bukrs
                            fp_gjahr     TYPE gjahr
                            fp_budat     TYPE ty_t_budat
                            fp_racct     TYPE racct
                   CHANGING fp_it_final  TYPE ty_t_final.
      DATA : v_date(2)  TYPE c VALUE '01',
             v_month(2) TYPE c VALUE '01',
             v_start_date TYPE datum.
    *concatenate p_gjahr v_month v_date into v_start_date.  " separated by c_slash.
      SELECT ryear
             rbukrs
             belnr                                "Document Number
             poper                                "Posting Period
             budat                                "Posting Date
             buzei                                "Document line item
             racct                                "G/L Account no.
             INTO TABLE it_faglflexa
             FROM faglflexa
             WHERE rbukrs EQ p_bukrs
             AND   gjahr  EQ p_gjahr
             AND   budat  LE s_budat
             AND   racct  EQ p_racct.
    *selecting the Tax Jurisdiction, Tax amount from BSET
      IF it_faglflexa IS NOT INITIAL.
        SELECT belnr
               buzei
               mwskz
               "hkont
               shkzg                                "Debit/Credit Indicator
               txjcd                                "Tax Jurisdicaiton
               h2ste                                "Tax Amount
               h2bas                                "Tax Amount1
               INTO TABLE it_bset
               FROM bset
               FOR ALL ENTRIES IN it_faglflexa
               WHERE belnr EQ it_faglflexa-belnr
               AND   gjahr EQ p_gjahr               "it_faglflexa-ryear
               AND   buzei EQ c_buzei.              "Line item
      ENDIF.
      IF sy-subrc EQ 0.
        SORT it_bset BY txjcd ASCENDING.
      ENDIF.
    *Selecting the G/L Account Long Text from SKAT
      IF it_faglflexa IS NOT INITIAL.
        SELECT  spras                            " Language key
                ktopl                            " Chart of Accounts
                saknr                            " G/L Account Number
                txt20                            " G/L Account Long Text
             INTO TABLE it_skat
             FROM skat
             FOR ALL ENTRIES IN it_faglflexa
             WHERE spras =  c_spras
             AND   saknr =  it_faglflexa-racct.
      ENDIF.
    *Selecting the Description from Custom table
      LOOP AT it_bset ASSIGNING <fs_bset>.
        wa_txjcd-geo_state  = <fs_bset>-txjcd+0(2).
        wa_txjcd-geo_county = <fs_bset>-txjcd+2(3).
        APPEND wa_txjcd TO it_txjcd.
        CLEAR wa_txjcd.
      ENDLOOP.
      IF it_txjcd IS NOT INITIAL.
        SELECT geo_state
               geo_county
               country
               description
        INTO TABLE it_custom
        FROM ztfi_tgl_summary
        FOR ALL ENTRIES IN it_txjcd
        WHERE geo_state  = it_txjcd-geo_state
        AND   geo_county = it_txjcd-geo_county.
      ENDIF.
      LOOP AT it_faglflexa ASSIGNING <fs_faglflexa>.
        MOVE-CORRESPONDING <fs_faglflexa> TO wa_inter.          "#EC ENHOK
    *Read Tax Jurisdiction and Tax Amount from BSET Table.
        READ TABLE it_bset INTO wa_bset WITH KEY belnr =  <fs_faglflexa>-belnr.
        IF sy-subrc EQ 0.
          wa_inter-shkzg = wa_bset-shkzg.
          wa_inter-txjcd = wa_bset-txjcd.
        ENDIF.
    *If BSET-MWSKZ = ZP or ZR then pick H2BAS as Tax Amount.
        IF wa_bset-mwskz = c_zp.
          wa_inter-h2ste = wa_bset-h2bas.
        ELSEIF wa_bset-mwskz = c_zr.
          wa_inter-h2ste = wa_bset-h2bas.
        ELSE.
          wa_inter-h2ste = wa_bset-h2ste.
        ENDIF.
    *Check it is credit entry or debit entry ('H' or 'S').
        IF wa_inter-shkzg EQ 'H'.
          wa_inter-h2ste = wa_inter-h2ste * -1.
        ENDIF.
        APPEND wa_inter TO it_inter.
        CLEAR: wa_inter, wa_bset.
      ENDLOOP.
      IF sy-subrc EQ 0.
        SORT it_inter BY bukrs ryear txjcd ASCENDING.
        DELETE it_inter WHERE txjcd EQ space.
      ENDIF.
      v_poper = s_budat-low+4(2).
      LOOP AT it_inter INTO wa_inter.
    *Read the Text maintained in the custom table based on the GEO_STATE = First two digits of TXJCD
    *and GEO_COUNTY = Next three digits of TXJCD. If this is blank pick based on First two digits of TXJCD.
        READ TABLE it_custom INTO wa_custom WITH KEY geo_state  = wa_bset-txjcd+0(2)
                                                     geo_county = wa_bset-txjcd+2(3).
        IF sy-subrc NE 0.
          READ TABLE it_custom INTO wa_custom WITH KEY geo_state  = wa_bset-txjcd+0(2).
        ENDIF.
        IF sy-subrc = 0.
          wa_final-state = wa_custom-description.
        ENDIF.
        AT NEW txjcd.
          CLEAR: v_sum_val, v_sum_val1, v_sum_val2.
        ENDAT.
      Period Change
        IF wa_inter-poper EQ v_poper.
          v_sum_val1 = v_sum_val1 + wa_inter-h2ste.
        ENDIF.
      Prior Balance
        IF wa_inter-poper LT v_poper.
          v_sum_val2 = v_sum_val2 + wa_inter-h2ste.
        ENDIF.
        AT END OF txjcd.
          wa_final-txjcd    = wa_inter-txjcd.
          wa_final-per_chng = v_sum_val1.                                     "Period change
          wa_final-pri_bala = v_sum_val2.                                     "Prior Balance
          wa_final-curr_bal = v_sum_val1 + v_sum_val2.                        "Current Balance
          APPEND wa_final TO it_final.
          CLEAR wa_final.
        ENDAT.
      ENDLOOP.
    ENDFORM.                    " GET_DATA
    *&      Form  COMMENT_BUILD
          text
         -->P_IT_SKAT  text
         <--P_IT_ALV_TOP_OF_PAGE  text
    FORM comment_build  USING    fp_it_skat            TYPE ty_t_skat
                        CHANGING fp_it_alv_top_of_page TYPE slis_t_listheader.
      DATA: v_budat_low  TYPE c LENGTH 10,
            v_budat_high TYPE c LENGTH 10,
            v_butxt      TYPE butxt.
      CLEAR gs_line.
    *Report Title
      CONCATENATE text-005 p_bukrs INTO v_title SEPARATED BY space.
      gs_line-typ = c_h.
      gs_line-key = ' '.
      gs_line-info = v_title.
      APPEND gs_line TO fp_it_alv_top_of_page.
      CLEAR gs_line.
    *Account Number
      gs_line-typ = c_s.
      gs_line-key = text-006.
      gs_line-info = p_racct.
      APPEND gs_line TO fp_it_alv_top_of_page.
      CLEAR gs_line.
    *G/L Account Description
      READ TABLE it_skat INTO wa_skat WITH KEY ktopl = v_ktopl.
      IF sy-subrc EQ 0.
        v_desc = wa_skat-text.
      ENDIF.
      gs_line-typ = c_s.
      gs_line-key = text-007.
      gs_line-info = v_desc.
      APPEND gs_line TO fp_it_alv_top_of_page.
      CLEAR gs_line.
    *Fiscal Year from selection
      IF NOT p_gjahr IS INITIAL.
        gs_line-info = p_gjahr.
        gs_line-typ   = c_s.
        gs_line-key  = text-008.                                              "Fiscal Year
        APPEND gs_line TO fp_it_alv_top_of_page.
        CLEAR gs_line.
      ENDIF.
    *Posting Date
      CONCATENATE s_budat-low4(2) s_budat-low6(2) s_budat-low+0(4) INTO gs_line-info SEPARATED BY c_slash.
      gs_line-typ   = c_s.
      gs_line-key  = text-009.                                               "Posting Date
      APPEND gs_line TO fp_it_alv_top_of_page.
      CLEAR gs_line.
    *Company Code Description from selection
      IF NOT p_bukrs IS INITIAL.
        SELECT SINGLE butxt FROM t001
        INTO v_butxt WHERE bukrs EQ p_bukrs.
        gs_line-info = v_butxt.
        gs_line-typ  = c_s.
        gs_line-key  = text-010.                                              "Company Code Description
        APPEND gs_line TO fp_it_alv_top_of_page.
        CLEAR gs_line.
      ENDIF.
    Printed Date
      gs_line-typ = c_s.
      gs_line-key = text-011.                                                 "Printed Date
      CONCATENATE  sy-datum+4(2)
                   sy-datum+6(2)
                   sy-datum(4) INTO gs_line-info SEPARATED BY c_slash.        "todays date
      APPEND gs_line TO fp_it_alv_top_of_page.
      CLEAR: gs_line.
    Printing Time
      gs_line-typ = c_s.
      gs_line-key = text-012.                                                 "Printing Time
      gs_line-info = sy-uzeit.
      CONCATENATE  sy-uzeit(2)
                   sy-uzeit+2(2)
                   sy-uzeit+4(2) INTO gs_line-info SEPARATED BY c_colon.      "current time
      APPEND gs_line TO fp_it_alv_top_of_page.
      CLEAR: gs_line.
    ENDFORM.                    " COMMENT_BUILD
    *&      Form  BUILD_FIELD_CATALOG
          text
         <--P_IT_FIELDCAT  text
    FORM build_field_catalog  CHANGING fp_it_fieldcat TYPE slis_t_fieldcat_alv.
    TAX JURISDICTION
      wa_fieldcat-col_pos      = c_pos_1.
      wa_fieldcat-reptext_ddic = text-013.                                    "TAX JURISDICTION
      wa_fieldcat-fieldname    = c_txjcd.
      wa_fieldcat-tabname      = c_table_name.
      wa_fieldcat-outputlen    = '15'.
      APPEND  wa_fieldcat TO fp_it_fieldcat.
      CLEAR : wa_fieldcat.
    STATE
      wa_fieldcat-col_pos      = c_pos_2.
      wa_fieldcat-reptext_ddic = text-014.                                    "STATE
      wa_fieldcat-fieldname    = c_region.
      wa_fieldcat-tabname      = c_table_name.
      wa_fieldcat-outputlen    = '40'.
      APPEND  wa_fieldcat TO fp_it_fieldcat.
      CLEAR : wa_fieldcat.
    CURRENT BALANCE
      wa_fieldcat-col_pos      = c_pos_3.
      wa_fieldcat-reptext_ddic = text-015.                                    "CURRENT BALANCE
      wa_fieldcat-fieldname    = c_currb.
      wa_fieldcat-tabname      = c_table_name.
      wa_fieldcat-do_sum       = 'X'.
      wa_fieldcat-datatype     = 'CURR'.
      wa_fieldcat-outputlen    = '17'.
      APPEND  wa_fieldcat TO fp_it_fieldcat.
      CLEAR : wa_fieldcat.
    PERIOD CHANGE
      wa_fieldcat-col_pos      = c_pos_4.
      wa_fieldcat-reptext_ddic = text-016.                                    "PERIOD CHANGE
      wa_fieldcat-fieldname    = c_perch.
      wa_fieldcat-tabname      = c_table_name.
      wa_fieldcat-do_sum       = 'X'.
      wa_fieldcat-datatype     = 'CURR'.
      wa_fieldcat-outputlen    = '17'.
      APPEND  wa_fieldcat TO fp_it_fieldcat.
      CLEAR : wa_fieldcat.
    PRIOR BALANCE
      wa_fieldcat-col_pos      = c_pos_5.
      wa_fieldcat-reptext_ddic = text-017.                                    "PRIOR BALANCE
      wa_fieldcat-fieldname    = c_prbal.
      wa_fieldcat-tabname      = c_table_name.
      wa_fieldcat-do_sum       = 'X'.
      wa_fieldcat-datatype     = 'CURR'.
      wa_fieldcat-outputlen    = '17'.
      APPEND  wa_fieldcat TO fp_it_fieldcat.
      CLEAR : wa_fieldcat.
    ENDFORM.                    " BUILD_FIELD_CATALOG
    *&      Form  DISPLAY_ALV
          text
         -->P_IT_FINAL  text
    FORM display_alv  USING    fp_it_final TYPE ty_t_final.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
         i_callback_program                = sy-repid
      I_CALLBACK_PF_STATUS_SET          = ' '
      I_CALLBACK_USER_COMMAND           = ' '
      i_callback_top_of_page            = c_top_of_page
       i_callback_html_top_of_page       = c_top_of_page_split
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
      I_GRID_TITLE                      =
      I_GRID_SETTINGS                   =
      IS_LAYOUT                         =
         it_fieldcat                       = it_fieldcat
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         = 'X'
         i_save                            = 'A'
      IS_VARIANT                        =
      IT_EVENTS                         =
      IT_EVENT_EXIT                     =
      IS_PRINT                          =
      IS_REPREP_ID                      =
      I_SCREEN_START_COLUMN             = 0
      I_SCREEN_START_LINE               = 0
      I_SCREEN_END_COLUMN               = 0
      I_SCREEN_END_LINE                 = 0
      I_HTML_HEIGHT_TOP                 = 0
      I_HTML_HEIGHT_END                 = 0
      IT_ALV_GRAPHICS                   =
      IT_HYPERLINK                      =
      IT_ADD_FIELDCAT                   =
      IT_EXCEPT_QINFO                   =
      IR_SALV_FULLSCREEN_ADAPTER        =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
        TABLES
          t_outtab                          = fp_it_final
    EXCEPTIONS
      PROGRAM_ERROR                     = 1
      OTHERS                            = 2
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " DISPLAY_ALV
    *&      Form  top_of_page
          Top of the page for ALV
    FORM top_of_page.                                           "#EC CALLED
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary       = it_alv_top_of_page
      I_LOGO                   =
      I_END_OF_LIST_GRID       =
      I_ALV_FORM               =
    ENDFORM. "top_of_page
    *&      Form  top_of_page_split
          text
    FORM top_of_page_split USING r_top TYPE REF TO cl_dd_document."#EC *
      TYPES: BEGIN  OF ty_text,
             text   TYPE sdydo_text_element,
             END    OF ty_text.
      TYPES: BEGIN  OF ty_text1,                        "AAAAAAAA
             text1  TYPE sdydo_text_element,
             END    OF ty_text1.
      DATA: s_tab          TYPE sdydo_text_table,
            c_area         TYPE REF TO cl_dd_area,
            text           TYPE sdydo_text_element,
            c_area1        TYPE REF TO cl_dd_area,             "AAAAAAA
            text1          TYPE sdydo_text_element,
            s_tab1         TYPE sdydo_text_table.
      DATA: it_text        TYPE TABLE OF ty_text,
            wa_text        TYPE ty_text.
      DATA: it_text1       TYPE TABLE OF ty_text1,
            wa_text1       TYPE ty_text1.
      DATA: v_title        TYPE string,
            v_accts_desc   TYPE string,
            v_year         TYPE string,
            v_comp_code    TYPE string,
            v_desc         TYPE char40,
            v_budat        TYPE char10,
            v_budat1       TYPE char10,
            v_butxt        TYPE butxt,
            v_time         TYPE char10,
            v_comma        TYPE c VALUE ','.
      CALL METHOD r_top->initialize_document.
      CALL METHOD r_top->vertical_split
        EXPORTING
          split_area  = r_top
          split_width = '31%'
        IMPORTING
          right_area  = c_area.
      IF sy-subrc EQ 0.
    *MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *G/L Account Description
      READ TABLE it_skat INTO wa_skat WITH KEY ktopl = v_ktopl.
      IF sy-subrc EQ 0.
        v_desc = wa_skat-text.
      ENDIF.
    *Company code Description
      IF NOT p_bukrs IS INITIAL.
        SELECT SINGLE butxt FROM t001
        INTO v_butxt WHERE bukrs EQ p_bukrs.
      ENDIF.
      CONCATENATE text-005 p_bukrs INTO v_title SEPARATED BY space.
      wa_text1-text1 = v_title.
      APPEND wa_text1 TO it_text1.
      s_tab1 = it_text1.
      CALL METHOD c_area->add_text
        EXPORTING
          text_table   = s_tab1
          fix_lines    = 'X'
          sap_fontsize = cl_dd_document=>large
          sap_emphasis = cl_dd_document=>strong.                           "AAAAAA
      CONCATENATE text-006 p_racct v_comma text-007 v_desc INTO v_accts_desc SEPARATED BY space.
      CONCATENATE s_budat-low4(2) s_budat-low6(2) s_budat-low+0(4) INTO v_budat SEPARATED BY c_slash.
      CONCATENATE text-008 p_gjahr v_comma text-009 v_budat INTO v_year SEPARATED BY space.
      CONCATENATE text-010 v_butxt INTO v_comp_code SEPARATED BY space.
    wa_text-text = v_title.
    APPEND wa_text TO it_text.
      wa_text-text = v_accts_desc.
      APPEND wa_text TO it_text.
      wa_text-text = v_year.
      APPEND wa_text TO it_text.
      wa_text-text = v_comp_code.
      APPEND wa_text TO it_text.
      s_tab = it_text.
      CALL METHOD c_area->add_text
        EXPORTING
          text_table   = s_tab
          fix_lines    = 'X'
          sap_fontsize = cl_dd_document=>medium
          sap_emphasis = cl_dd_document=>medium.
      CALL METHOD r_top->new_line.
      CALL METHOD r_top->new_line.
      CALL METHOD r_top->new_line.
      CALL METHOD r_top->add_gap
        EXPORTING
          width = 0.
      CONCATENATE sy-datum4(2) sy-datum6(2) sy-datum+0(4) INTO v_budat1 SEPARATED BY c_slash.
      CALL METHOD r_top->add_text
        EXPORTING
          text         = text-011
          sap_emphasis = 'STRONG'.
      CALL METHOD r_top->add_gap
        EXPORTING
          width = 1.
      text = v_budat1.
      CALL METHOD r_top->add_text
        EXPORTING
          text = text.
         sap_style = 'KEY'.
      CALL METHOD r_top->new_line.
      CALL METHOD r_top->add_text
        EXPORTING
          text         = text-012
          sap_emphasis = 'STRONG'.
      CALL METHOD r_top->add_gap
        EXPORTING
          width = 1.
      CONCATENATE  sy-uzeit(2)
                   sy-uzeit+2(2)
                   sy-uzeit+4(2) INTO v_time SEPARATED BY c_colon.   "current time
      text = v_time.
      CALL METHOD r_top->add_text
        EXPORTING
          text = text.
         sap_style = 'KEY'.
    ENDFORM.                    "top_of_page_split
    Thanks & Regards,
    Ramana

    Hi,
    try to declare alv layout and in that
    FORM t_layout  USING    i_layout TYPE slis_layout_alv.
    i_layout-colwidth_optimize = 'X'.
      i_layout-zebra  = 'X'.
    p_i_layout-totals_text = 'GRAND TOTAL ='.
    p_i_layout-subtotals_text = 'Sub Total'.
    p_i_layout-DEF_STATUS  = ' '.
    p_i_layout-info_fieldname = 'LINE_COLOR'.
    ENDFORM.                    " T_LAYOUT
    hope this helps you.
    Thanks & Regards,
    Y.R.Prem Kumar

  • Error message was displaying when comes back from the final output display

    Hi Experts,
    I have developed one program and it works fine. But when i press F3 or BACK button from the final display one Error  wa coming in a pop-up saying "Selection criterion "Posting Date" contains several selection lines".
    I cant understand where the problem was. Can any one suggest where would be the problem. I am sending the code.
    REPORT  zfir0011_o2c_tax_gl_summary.
    TYPE-POOLS slis.
    TABLES: faglflexa.
    Types Declaration.
    TYPES: BEGIN OF x_faglflexa,
           ryear TYPE gjahr,
           bukrs TYPE bukrs,
           belnr TYPE belnr_d,                  "Document Number
           poper TYPE poper,                    "Posting Period
           budat TYPE budat,                    "Posting Date
           buzei TYPE buzei,                    "Document line item
           racct TYPE racct,                    "G/L Account no.
           END   OF x_faglflexa,
           ty_t_faglflexa TYPE STANDARD TABLE OF x_faglflexa.
    TYPES: BEGIN OF x_bset,
           belnr TYPE belnr_d,
           buzei TYPE buzei,
           mwskz TYPE mwskz,                    "Tax code
          hkont TYPE hkont,
           shkzg TYPE shkzg,                    "Debit/Credit Indicator
           txjcd TYPE txjcd,                    "Tax Jurisdiction
           h2ste TYPE h2ste,                    "Tax Amount
           h2bas TYPE h2bas_bses,               "Tax Amount
           END   OF x_bset,
           ty_t_bset TYPE STANDARD TABLE OF x_bset.
    TYPES: BEGIN OF x_skat,
           spras TYPE spras,
           ktopl TYPE ktopl,
           saknr TYPE saknr,
           text  TYPE txt20_skat,
           END   OF x_skat,
           ty_t_skat TYPE STANDARD TABLE OF x_skat.
    TYPES: BEGIN OF x_custom,
           geo_state    TYPE char2,
           geo_county   TYPE char3,
           country      TYPE char2,
           description  TYPE char40,
           END   OF x_custom,
           ty_t_custom TYPE STANDARD TABLE OF x_custom.
    TYPES: BEGIN OF x_budat,
           sign     TYPE char_01,
           option   TYPE char2,
           low      TYPE budat,
           high     TYPE budat,
           END OF x_budat,
           ty_t_budat TYPE STANDARD TABLE OF x_budat.
    TYPES: BEGIN OF x_txjcd,
           geo_state  TYPE char2,
           geo_county TYPE char3,
           END   OF x_txjcd,
           ty_t_txjcd TYPE STANDARD TABLE OF x_txjcd.
    TYPES: BEGIN OF x_inter,
           ryear TYPE gjahr,
           bukrs TYPE bukrs,
           txjcd TYPE txjcd,                    "Tax Jurisdiction
           racct TYPE racct,                    "G/L Account no.
           h2ste TYPE h2ste,                    "Tax Amount
           poper TYPE poper,                    "Posting Period
           belnr TYPE belnr_d,                  "Document Number
           shkzg TYPE shkzg,                    "Debit/Credit Indicator
           END   OF x_inter,
           ty_t_inter TYPE STANDARD TABLE OF x_inter.
    TYPES: BEGIN OF x_final,
           txjcd    TYPE bset-txjcd,                     "Tax Jurisdiction
           state    TYPE char40,                         "State
           curr_bal TYPE bset-h2ste,                     "Current Balance
           per_chng TYPE bset-h2ste,                     "Period Change
           pri_bala TYPE bset-h2ste,                     "Prior Balance
           END   OF x_final,
           ty_t_final TYPE STANDARD TABLE OF x_final.
    Column positions to pass to field catalog
    CONSTANTS : c_pos_1      TYPE sy-cucol       VALUE '1',   " position of the columns
                c_pos_2      TYPE sy-cucol       VALUE '2',
                c_pos_3      TYPE sy-cucol       VALUE '3',
                c_pos_4      TYPE sy-cucol       VALUE '4',
                c_pos_5      TYPE sy-cucol       VALUE '5'.
    *Field names for Field Catalog
    CONSTANTS : c_h           TYPE c              VALUE 'H',                         "Header
                c_s           TYPE c              VALUE 'S',                         "Sub heading
                c_slash       TYPE c              VALUE '/',                         "Slash
                c_colon       TYPE c              VALUE ':',                         "Column
                c_top_of_page TYPE slis_formname  VALUE 'TOP_OF_PAGE',"#EC NEEDED          "Top-of-page
                c_top_of_page_split TYPE slis_formname  VALUE 'TOP_OF_PAGE_SPLIT',   "Top-of-page centered
                c_txjcd       TYPE slis_fieldname VALUE 'TXJCD',                     "Tax Jurisdiction
                c_region      TYPE slis_fieldname VALUE 'STATE',                     "State
                c_currb       TYPE slis_fieldname VALUE 'CURR_BAL',                  "Current Balance
                c_perch       TYPE slis_fieldname VALUE 'PER_CHNG',                  "Period Change
                c_prbal       TYPE slis_fieldname VALUE 'PRI_BALA'.                  "Prior Balance
    CONSTANTS : c_table_name  TYPE slis_tabname   VALUE 'IT_FINAL', "For Field Catalog
                c_spras       TYPE spras          VALUE 'E',        "Language
                c_buzei       TYPE c              VALUE '1',        "Line item in BSET
                c_one(2)      TYPE c              VALUE '01',
                c_zp          TYPE bset-mwskz     VALUE 'ZP',       "Sales Tax Code
                c_zr          TYPE bset-mwskz     VALUE 'ZR'.       "Sales Tax Code
    Variables Declaration.
    DATA : v_current_year TYPE i,                                   "Current year
           v_poper        TYPE poper,                               "Posting period
           v_saknr        TYPE saknr,                               "Account no.    "#EC NEEDED
           v_ktopl        TYPE ktopl,                               "Chart of Accounts
           v_konts        TYPE saknr,                               "G/L Account Number
           v_bukrs        TYPE bukrs,                               "Company Code
           v_sum_val      TYPE h2ste,           "#EC NEEDED     "Tax Amount
           v_sum_val1     TYPE h2ste,                               "Tax Amount
           v_sum_val2     TYPE h2ste,                               "Tax Amount
           v_sum_debit    TYPE h2ste,
           v_sum_credit   TYPE h2ste,
           v_sum_debit1   TYPE h2ste,
           v_sum_credit1  TYPE h2ste,
           v_h2ste        TYPE string,                          "#EC NEEDED
           v_desc         TYPE char40,                              "G/L Acct. Description
           v_title        TYPE char40.                              "Title
    Internal Tables Declaration.
    DATA : it_faglflexa        TYPE ty_t_faglflexa,             "Internal table for G/L Line Items.
           it_bset             TYPE ty_t_bset,                  "Internal table for Tax Data Document Segment.
           it_skat             TYPE ty_t_skat,                  "Internal table for Chart of Accounts: Desc.
           it_custom           TYPE ty_t_custom,                "Custom table for storing STATE Description.
           it_txjcd            TYPE ty_t_txjcd,                 "For storing Tax Jurisdiction codes.
           it_inter            TYPE ty_t_inter.                 "Intermediate table for storing data & Performing Calculations.
    DATA : it_final            TYPE ty_t_final.                 "#EC NEEDED
    *Fieldcatalogue Internal Table Declaration
    DATA : it_fieldcat         TYPE slis_t_fieldcat_alv,
           wa_fieldcat         TYPE slis_fieldcat_alv,
           it_alv_top_of_page  TYPE slis_t_listheader,
           wa_line             TYPE slis_listheader.
    *Field-symbols and Work Area Declarations
    FIELD-SYMBOLS : <fs_faglflexa>      TYPE x_faglflexa,
                    <fs_bset>           TYPE x_bset.
    DATA : wa_faglflexa     TYPE x_faglflexa,                   "#EC NEEDED
           wa_bset          TYPE x_bset,
           wa_skat          TYPE x_skat,
           wa_custom        TYPE x_custom,
           wa_txjcd         TYPE x_txjcd,
           wa_inter         TYPE x_inter,
           wa_final         TYPE x_final.                      " #EC NEEDED
    SELECTION-SCREEN
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    PARAMETERS:     p_bukrs TYPE faglflexa-rbukrs OBLIGATORY,              " Company Code
                    p_gjahr TYPE faglflexa-gjahr  OBLIGATORY.              " Fiscal Year
    SELECT-OPTIONS: s_budat FOR  faglflexa-budat  OBLIGATORY               " Posting Date
                                                  NO-EXTENSION
                                                  NO INTERVALS.
    PARAMETERS:     p_racct TYPE faglflexa-racct  OBLIGATORY.              " G/L Accounts
    SELECTION-SCREEN END OF BLOCK b1.
    SELECTION-SCREEN VALIDATIONS.
    *Company Code Validation.
    AT SELECTION-SCREEN ON p_bukrs.
      SELECT SINGLE bukrs INTO v_bukrs
      FROM t001
      WHERE bukrs = p_bukrs.
      IF sy-subrc NE 0.
        MESSAGE e071(zfinprjt).
      ENDIF.
    Fiscal Year Validation. It should not be more than Current.
    AT SELECTION-SCREEN ON p_gjahr.
      v_current_year = sy-datum+0(4).
      IF p_gjahr > v_current_year.
        MESSAGE e072(zfinprjt).
      ENDIF.
    *G/L Account Validation.
    AT SELECTION-SCREEN ON p_racct.
      SELECT SINGLE saknr INTO v_saknr
      FROM skb1
      WHERE saknr EQ p_racct
      AND   bukrs EQ p_bukrs.
      IF sy-subrc EQ 0.
    *Check the Chart of Accounts for that Company Code.
        SELECT SINGLE ktopl FROM t001
        INTO v_ktopl
        WHERE bukrs = p_bukrs.
    *Check that it is a Tax G/L Account for that Company Code and G/L Account.
        SELECT SINGLE konts FROM t030k                          "#EC *
        INTO v_konts
        WHERE ktopl = v_ktopl
        AND   konts = v_saknr.
        IF sy-subrc NE 0.
          MESSAGE e073(zfinprjt).
        ENDIF.
      ELSE.
        MESSAGE e073(zfinprjt).
      ENDIF.
    AT SELECTION-SCREEN ON s_budat.
      DATA : v_year(4)  TYPE c,
             v_month(2) TYPE c,
             v_date(2)  TYPE c.                                 "#EC NEEDED
    *if date ne 01 converting date to '01'
    READ TABLE s_budat.
      IF s_budat-low+6(2) NE c_one.
        v_year  = s_budat-low.
        v_month = s_budat-low+4(2).
        v_date  = s_budat-low+6(2).
        s_budat-high = s_budat-low.
        CLEAR s_budat-low.
        CONCATENATE v_year c_one c_one INTO s_budat-low.
        s_budat-sign = 'I'.
        s_budat-option = 'BT'.
        APPEND s_budat.
      ENDIF.
    START-OF-SELECTION.
      PERFORM get_data USING p_bukrs                            "#EC *
                             p_gjahr                            "#EC *
                             s_budat[]                          "#EC *
                             p_racct  CHANGING it_final.        "#EC *
    *Display report in ALV grid
      IF it_final IS NOT INITIAL.
    *Build Top of the page table.
       PERFORM comment_build USING it_skat CHANGING it_alv_top_of_page.
    *Build Field catalog table for ALV
        PERFORM build_field_catalog CHANGING it_fieldcat.
    *Display report
        PERFORM display_alv USING it_final.
      ELSE.
    *No data found for the selection criteria/period.
        MESSAGE i022(zfinprjt).
        exit.
      ENDIF.
    *&      Form  GET_DATA
          Retrieve data from Database tables
         -->P_P_BUKRS  text
         -->P_P_GJAHR  text
         -->P_P_BUDAT  text
         -->P_P_RACCT  text
         <--P_IT_FINAL  text
    FORM get_data  USING    fp_bukrs     TYPE bukrs             "#EC *
                            fp_gjahr     TYPE gjahr             "#EC *
                            fp_budat     TYPE ty_t_budat        "#EC *
                            fp_racct     TYPE racct             "#EC *
                   CHANGING fp_it_final  TYPE ty_t_final.
    *selecting the Required data from FAGLFLEXA
      SELECT ryear                                "Fiscal Year
             rbukrs                               "Company Code
             belnr                                "Document Number
             poper                                "Posting Period
             budat                                "Posting Date
             buzei                                "Document line item
             racct                                "G/L Account no.
             INTO TABLE it_faglflexa
             FROM faglflexa
             WHERE rbukrs EQ p_bukrs                            "#EC *
             AND   gjahr  EQ p_gjahr                            "#EC *
            AND   budat  LE s_budat                            "#EC *
             AND   budat  IN s_budat                            "#EC *
             AND   racct  EQ p_racct.                           "#EC *
      IF sy-subrc EQ 0.
        SORT it_faglflexa.
      ENDIF.
    *selecting the Tax Jurisdiction, Tax amount from BSET
      IF it_faglflexa IS NOT INITIAL.
        SELECT belnr
               buzei
               mwskz
               "hkont
               shkzg                                "Debit/Credit Indicator
               txjcd                                "Tax Jurisdicaiton
               h2ste                                "Tax Amount
               h2bas                                "Tax Amount1
               INTO TABLE it_bset
               FROM bset
               FOR ALL ENTRIES IN it_faglflexa
               WHERE belnr EQ it_faglflexa-belnr
               AND   gjahr EQ p_gjahr               "it_faglflexa-ryear
               AND   buzei EQ c_buzei.              "Line item
      ENDIF.
      IF sy-subrc EQ 0.
       SORT it_bset BY txjcd ASCENDING.
        SORT it_bset BY belnr ASCENDING.
      ENDIF.
    *Selecting the G/L Account Long Text from SKAT
      IF it_faglflexa IS NOT INITIAL.
        SELECT  spras                            " Language key
                ktopl                            " Chart of Accounts
                saknr                            " G/L Account Number
                txt20                            " G/L Account Long Text
             INTO TABLE it_skat
             FROM skat
             FOR ALL ENTRIES IN it_faglflexa
             WHERE spras =  c_spras
             AND   saknr =  it_faglflexa-racct.
      ENDIF.
      IF sy-subrc EQ 0.
        SORT it_skat.
      ENDIF.
      LOOP AT it_bset ASSIGNING <fs_bset>.
        wa_txjcd-geo_state  = <fs_bset>-txjcd+0(2).
        wa_txjcd-geo_county = <fs_bset>-txjcd+2(3).
        APPEND wa_txjcd TO it_txjcd.
        CLEAR wa_txjcd.
      ENDLOOP.
      IF sy-subrc EQ 0.
        SORT it_txjcd BY geo_state.
        DELETE ADJACENT DUPLICATES FROM it_txjcd COMPARING geo_state geo_county.
      ENDIF.
    *Selecting the Description from Custom table
      IF it_txjcd IS NOT INITIAL.
        SELECT geo_state
               geo_county
               country
               description
        INTO TABLE it_custom
        FROM ztfi_tgl_summary
        FOR ALL ENTRIES IN it_txjcd
        WHERE geo_state  = it_txjcd-geo_state
        AND   geo_county = it_txjcd-geo_county.
      ENDIF.
      IF sy-subrc EQ 0.
        SORT it_custom.
      ENDIF.
      LOOP AT it_faglflexa ASSIGNING <fs_faglflexa>.
        MOVE-CORRESPONDING <fs_faglflexa> TO wa_inter.          "#EC ENHOK
    *Read Tax Jurisdiction and Tax Amount from BSET Table.
        READ TABLE it_bset INTO wa_bset WITH KEY belnr =  <fs_faglflexa>-belnr
                                                 BINARY SEARCH.
        IF sy-subrc EQ 0.
          wa_inter-shkzg = wa_bset-shkzg.
          wa_inter-txjcd = wa_bset-txjcd.
        ENDIF.
    *If BSET-MWSKZ = ZP or ZR then pick H2BAS as Tax Amount.
        IF wa_bset-mwskz = c_zp.
          wa_inter-h2ste = wa_bset-h2bas.
        ELSEIF wa_bset-mwskz = c_zr.
          wa_inter-h2ste = wa_bset-h2bas.
        ELSE.
          wa_inter-h2ste = wa_bset-h2ste.
        ENDIF.
    *Check it is credit entry or debit entry ('H' or 'S').
        IF wa_inter-shkzg EQ 'H'.
          wa_inter-h2ste = wa_inter-h2ste * -1.
        ENDIF.
        APPEND wa_inter TO it_inter.
        CLEAR: wa_inter, wa_bset.
      ENDLOOP.
      IF sy-subrc EQ 0.
        SORT it_inter BY bukrs ryear txjcd ASCENDING.
        DELETE it_inter WHERE txjcd EQ space.
        DELETE ADJACENT DUPLICATES FROM it_inter COMPARING belnr.
      ENDIF.
      v_poper = s_budat-high+4(2).
      LOOP AT it_inter INTO wa_inter.
    *Read the Text maintained in the custom table based on the GEO_STATE = First two digits of TXJCD
    *and GEO_COUNTY = Next three digits of TXJCD. If this is blank pick based on First two digits of TXJCD.
        READ TABLE it_custom INTO wa_custom WITH KEY geo_state  = wa_inter-txjcd+0(2)
                                                     geo_county = wa_inter-txjcd+2(3)
                                                     BINARY SEARCH.
        IF sy-subrc NE 0.
          READ TABLE it_custom INTO wa_custom WITH KEY geo_state  = wa_bset-txjcd+0(2)
                                                       BINARY SEARCH.
        ENDIF.
        IF sy-subrc = 0.
          wa_final-state = wa_custom-description.
        ENDIF.
        AT NEW txjcd.
          CLEAR: v_sum_val, v_sum_val1, v_sum_val2.
        ENDAT.
      Period Change, if v_poper equal to present period(v_poper).
        IF wa_inter-poper EQ v_poper.
          IF wa_inter-shkzg EQ 'H'.
            v_sum_debit     = v_sum_debit + wa_inter-h2ste.
          ELSE.
            v_sum_credit    = v_sum_credit + wa_inter-h2ste.
          ENDIF.
      Prior Balance, if v_poper is less than present period(v_poper).
        ELSEIF wa_inter-poper LT v_poper.
          IF wa_inter-shkzg EQ 'H'.
            v_sum_debit1    = v_sum_debit1 + wa_inter-h2ste.
          ELSE.
            v_sum_credit1   = v_sum_credit1 + wa_inter-h2ste.
          ENDIF.
        ENDIF.
        AT END OF txjcd.
          wa_final-txjcd    = wa_inter-txjcd.
          IF sy-subrc EQ 0.
            v_sum_val1      = v_sum_credit - v_sum_debit.                     "Temp Commented
          ENDIF.
          wa_final-per_chng = v_sum_val1.                                     "Period change
          IF sy-subrc EQ 0.
            v_sum_val2      = v_sum_credit1 - v_sum_debit1.                   "Temp commented
          ENDIF.
          wa_final-pri_bala = v_sum_val2.                                     "Prior Balance
          wa_final-curr_bal = v_sum_val1 + v_sum_val2.                        "Current Balance
          APPEND wa_final TO it_final.                          "#EC *
          CLEAR: wa_inter,
                 wa_final,
                 v_sum_credit,
                 v_sum_credit1,
                 v_sum_debit,
                 v_sum_debit1.
        ENDAT.
      ENDLOOP.
    ENDFORM.                    " GET_DATA
    *&      Form  COMMENT_BUILD
          ALV Top of Page
         -->P_IT_SKAT  text
         <--P_IT_ALV_TOP_OF_PAGE  text
    FORM comment_build  USING    fp_it_skat            TYPE ty_t_skat"#EC NEEDED
                        CHANGING fp_it_alv_top_of_page TYPE slis_t_listheader.
      DATA: v_budat_low  TYPE c LENGTH 10,                      "#EC NEEDED
            v_budat_high TYPE c LENGTH 10,                      "#EC NEEDED
            v_butxt      TYPE butxt.
      CLEAR wa_line.
    *Report Title
      CONCATENATE text-005 p_bukrs INTO v_title SEPARATED BY space.
      wa_line-typ = c_h.
      wa_line-key = ' '.
      wa_line-info = v_title.
      APPEND wa_line TO fp_it_alv_top_of_page.
      CLEAR  wa_line.
    *Account Number
      wa_line-typ = c_s.
      wa_line-key = text-006.
      wa_line-info = p_racct.
      APPEND wa_line TO fp_it_alv_top_of_page.
      CLEAR  wa_line.
    *G/L Account Description
      READ TABLE it_skat INTO wa_skat WITH KEY ktopl = v_ktopl BINARY SEARCH."#EC *
      IF sy-subrc EQ 0.
        v_desc = wa_skat-text.
      ENDIF.
      wa_line-typ = c_s.
      wa_line-key = text-007.
      wa_line-info = v_desc.
      APPEND wa_line TO fp_it_alv_top_of_page.
      CLEAR  wa_line.
    *Fiscal Year from selection
      IF NOT p_gjahr IS INITIAL.
        wa_line-info = p_gjahr.
        wa_line-typ   = c_s.
        wa_line-key  = text-008.                                              "Fiscal Year
        APPEND wa_line TO fp_it_alv_top_of_page.
        CLEAR  wa_line.
      ENDIF.
    *Posting Date
      CONCATENATE s_budat-high4(2) s_budat-high6(2) s_budat-high+0(4) INTO wa_line-info SEPARATED BY c_slash.
      wa_line-typ   = c_s.
      wa_line-key  = text-009.                                               "Posting Date
      APPEND wa_line TO fp_it_alv_top_of_page.
      CLEAR  wa_line.
    *Company Code Description from selection
      IF NOT p_bukrs IS INITIAL.
        SELECT SINGLE butxt FROM t001
        INTO v_butxt WHERE bukrs EQ p_bukrs.
        IF sy-subrc EQ 0.
          wa_line-info = v_butxt.
          wa_line-typ  = c_s.
          wa_line-key  = text-010.                                              "Company Code Description
          APPEND wa_line TO fp_it_alv_top_of_page.
          CLEAR  wa_line.
        ENDIF.
      ENDIF.
    Printed Date
      wa_line-typ = c_s.
      wa_line-key = text-011.                                                 "Printed Date
      CONCATENATE  sy-datum+4(2)
                   sy-datum+6(2)
                   sy-datum(4) INTO wa_line-info SEPARATED BY c_slash.        "todays date
      APPEND wa_line TO fp_it_alv_top_of_page.
      CLEAR: wa_line.
    Printing Time
      wa_line-typ = c_s.
      wa_line-key = text-012.                                                 "Printing Time
      wa_line-info = sy-uzeit.
      CONCATENATE  sy-uzeit(2)
                   sy-uzeit+2(2)
                   sy-uzeit+4(2) INTO wa_line-info SEPARATED BY c_colon.      "current time
      APPEND wa_line TO fp_it_alv_top_of_page.
      CLEAR: wa_line.
    ENDFORM.                    " COMMENT_BUILD
    *&      Form  BUILD_FIELD_CATALOG
          Fieldcatalogue
         <--P_IT_FIELDCAT  text
    FORM build_field_catalog  CHANGING fp_it_fieldcat TYPE slis_t_fieldcat_alv.
    TAX JURISDICTION
      wa_fieldcat-col_pos      = c_pos_1.
      wa_fieldcat-reptext_ddic = text-013.                                    "TAX JURISDICTION
      wa_fieldcat-fieldname    = c_txjcd.
      wa_fieldcat-tabname      = c_table_name.
      wa_fieldcat-outputlen    = '15'.
      APPEND  wa_fieldcat TO fp_it_fieldcat.
      CLEAR : wa_fieldcat.
    STATE
      wa_fieldcat-col_pos      = c_pos_2.
      wa_fieldcat-reptext_ddic = text-014.                                    "STATE
      wa_fieldcat-fieldname    = c_region.
      wa_fieldcat-tabname      = c_table_name.
      wa_fieldcat-outputlen    = '40'.
      APPEND  wa_fieldcat TO fp_it_fieldcat.
      CLEAR : wa_fieldcat.
    CURRENT BALANCE
      wa_fieldcat-col_pos      = c_pos_3.
      wa_fieldcat-reptext_ddic = text-015.                                    "CURRENT BALANCE
      wa_fieldcat-fieldname    = c_currb.
      wa_fieldcat-tabname      = c_table_name.
      wa_fieldcat-do_sum       = 'X'.
      wa_fieldcat-datatype     = 'CURR'.
      wa_fieldcat-outputlen    = '17'.
      APPEND  wa_fieldcat TO fp_it_fieldcat.
      CLEAR : wa_fieldcat.
    PERIOD CHANGE
      wa_fieldcat-col_pos      = c_pos_4.
      wa_fieldcat-reptext_ddic = text-016.                                    "PERIOD CHANGE
      wa_fieldcat-fieldname    = c_perch.
      wa_fieldcat-tabname      = c_table_name.
      wa_fieldcat-do_sum       = 'X'.
      wa_fieldcat-datatype     = 'CURR'.
      wa_fieldcat-outputlen    = '17'.
      APPEND  wa_fieldcat TO fp_it_fieldcat.
      CLEAR : wa_fieldcat.
    PRIOR BALANCE
      wa_fieldcat-col_pos      = c_pos_5.
      wa_fieldcat-reptext_ddic = text-017.                                    "PRIOR BALANCE
      wa_fieldcat-fieldname    = c_prbal.
      wa_fieldcat-tabname      = c_table_name.
      wa_fieldcat-do_sum       = 'X'.
      wa_fieldcat-datatype     = 'CURR'.
      wa_fieldcat-outputlen    = '17'.
      APPEND  wa_fieldcat TO fp_it_fieldcat.
      CLEAR : wa_fieldcat.
    ENDFORM.                    " BUILD_FIELD_CATALOG
    *&      Form  DISPLAY_ALV
          ALV Grid Display
         -->P_IT_FINAL  text
    FORM display_alv  USING    fp_it_final TYPE ty_t_final.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
         i_callback_program                = sy-repid
      I_CALLBACK_PF_STATUS_SET          = ' '
      I_CALLBACK_USER_COMMAND           = ' '
      i_callback_top_of_page            = c_top_of_page
       i_callback_html_top_of_page       = c_top_of_page_split
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
      I_GRID_TITLE                      =
      I_GRID_SETTINGS                   =
      IS_LAYOUT                         =
         it_fieldcat                       = it_fieldcat
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         = 'X'
         i_save                            = 'A'
      IS_VARIANT                        =
      IT_EVENTS                         =
      IT_EVENT_EXIT                     =
      IS_PRINT                          =
      IS_REPREP_ID                      =
      I_SCREEN_START_COLUMN             = 0
      I_SCREEN_START_LINE               = 0
      I_SCREEN_END_COLUMN               = 0
      I_SCREEN_END_LINE                 = 0
      I_HTML_HEIGHT_TOP                 = 0
      I_HTML_HEIGHT_END                 = 0
      IT_ALV_GRAPHICS                   =
      IT_HYPERLINK                      =
      IT_ADD_FIELDCAT                   =
      IT_EXCEPT_QINFO                   =
      IR_SALV_FULLSCREEN_ADAPTER        =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
        TABLES
          t_outtab                          = fp_it_final
    EXCEPTIONS
      PROGRAM_ERROR                     = 1
      OTHERS                            = 2
      IF sy-subrc EQ 0.                                         "#EC *
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " DISPLAY_ALV
    *&      Form  top_of_page_split
          Top of page for displaying the Text in Center
    FORM top_of_page_split USING fp_top TYPE REF TO cl_dd_document."#EC *
      TYPES: BEGIN  OF ty_text,
             text   TYPE sdydo_text_element,
             END    OF ty_text.
      TYPES: BEGIN  OF ty_text1,                        "AAAAAAAA
             text1  TYPE sdydo_text_element,
             END    OF ty_text1.
      DATA: v_tab          TYPE sdydo_text_table,
            v_area         TYPE REF TO cl_dd_area,
            v_text         TYPE sdydo_text_element,
            v_text1        TYPE sdydo_text_element,             "#EC NEEDED
            v_tab1         TYPE sdydo_text_table.
      DATA: it_text        TYPE TABLE OF ty_text,
            wa_text        TYPE ty_text,
            it_text1       TYPE TABLE OF ty_text1,
            wa_text1       TYPE ty_text1.
      DATA: v_title        TYPE string,
            v_accts_desc   TYPE string,
            v_year         TYPE string,
            v_comp_code    TYPE string,
            v_desc         TYPE char40,
            v_budat        TYPE char10,
            v_budat1       TYPE char10,
            v_butxt        TYPE butxt,
            v_time         TYPE char10,
            v_comma        TYPE c VALUE ','.
      CALL METHOD fp_top->initialize_document.
      CHECK sy-subrc EQ 0.
      CALL METHOD fp_top->vertical_split
        EXPORTING
          split_area  = fp_top
          split_width = '31%'
        IMPORTING
          right_area  = v_area.
      IF sy-subrc EQ 0.                                         "#EC NEEDED
    *MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *G/L Account Description
      READ TABLE it_skat INTO wa_skat WITH KEY ktopl = v_ktopl BINARY SEARCH.
      IF sy-subrc EQ 0.
        v_desc = wa_skat-text.
      ENDIF.
    *Company code Description
      IF NOT p_bukrs IS INITIAL.
        SELECT SINGLE butxt FROM t001
        INTO v_butxt WHERE bukrs EQ p_bukrs.
      ENDIF.
      CONCATENATE text-005 p_bukrs INTO v_title SEPARATED BY space.
      wa_text1-text1 = v_title.
      APPEND wa_text1 TO it_text1.
      v_tab1 = it_text1.
      CALL METHOD v_area->add_text
        EXPORTING
          text_table   = v_tab1
          fix_lines    = 'X'
          sap_fontsize = cl_dd_document=>large
          sap_emphasis = cl_dd_document=>strong.                           "AAAAAA
      CHECK sy-subrc EQ 0.
      CONCATENATE text-006 p_racct v_comma text-007 v_desc INTO v_accts_desc SEPARATED BY space.
      CONCATENATE s_budat-high4(2) s_budat-high6(2) s_budat-high+0(4) INTO v_budat SEPARATED BY c_slash.
      CONCATENATE text-008 p_gjahr v_comma text-009 v_budat INTO v_year SEPARATED BY space.
      CONCATENATE text-010 v_butxt INTO v_comp_code SEPARATED BY space.
    wa_text-text = v_title.
    APPEND wa_text TO it_text.
      wa_text-text = v_accts_desc.
      APPEND wa_text TO it_text.
      wa_text-text = v_year.
      APPEND wa_text TO it_text.
      wa_text-text = v_comp_code.
      APPEND wa_text TO it_text.
      v_tab = it_text.
      CALL METHOD v_area->add_text
        EXPORTING
          text_table   = v_tab
          fix_lines    = 'X'
          sap_fontsize = cl_dd_document=>medium
          sap_emphasis = cl_dd_document=>medium.
      CHECK sy-subrc EQ 0.
      CALL METHOD fp_top->new_line.
      CHECK sy-subrc EQ 0.
      CALL METHOD fp_top->new_line.
      CHECK sy-subrc EQ 0.
      CALL METHOD fp_top->new_line.
      CHECK sy-subrc EQ 0.
      CALL METHOD fp_top->add_gap
        EXPORTING
          width = 0.
      CHECK sy-subrc EQ 0.
      CONCATENATE sy-datum4(2) sy-datum6(2) sy-datum+0(4) INTO v_budat1 SEPARATED BY c_slash.
      CALL METHOD fp_top->add_text
        EXPORTING
          text         = text-011
          sap_emphasis = 'STRONG'.
      CHECK sy-subrc EQ 0.
      CALL METHOD fp_top->add_gap
        EXPORTING
          width = 1.
      CHECK sy-subrc EQ 0.
      v_text = v_budat1.
      CALL METHOD fp_top->add_text
        EXPORTING
          text = v_text.
         sap_style = 'KEY'.
      CHECK sy-subrc EQ 0.
      CALL METHOD fp_top->new_line.
      CHECK sy-subrc EQ 0.
      CALL METHOD fp_top->add_text
        EXPORTING
          text         = text-012
          sap_emphasis = 'STRONG'.
      CHECK sy-subrc EQ 0.
      CALL METHOD fp_top->add_gap
        EXPORTING
          width = 1.
      CHECK sy-subrc EQ 0.
      CONCATENATE  sy-uzeit(2)
                   sy-uzeit+2(2)
                   sy-uzeit+4(2) INTO v_time SEPARATED BY c_colon.   "current time
      v_text = v_time.
      CALL METHOD fp_top->add_text
        EXPORTING
          text = v_text.
         sap_style = 'KEY'.
      CHECK sy-subrc EQ 0.
    ENDFORM.                    "top_of_page_split
    Thanks in Advance.
    Regards,
    Ramana

    Problem is with ur selection screen definition for s_budat
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    PARAMETERS: p_bukrs TYPE faglflexa-rbukrs OBLIGATORY, " Company Code
    p_gjahr TYPE faglflexa-gjahr OBLIGATORY. " Fiscal Year
    SELECT-OPTIONS: s_budat FOR faglflexa-budat OBLIGATORY " Posting Date
    NO-EXTENSION
    NO INTERVALS.
    PARAMETERS: p_racct TYPE faglflexa-racct OBLIGATORY. " G/L Accounts
    SELECTION-SCREEN END OF BLOCK b1.
    Here u r defining  s_budat like parameter with NO-EXTENSION
    NO INTERVALS. additions.
    So that means it should contain only one record in it. As s_budat is nothing but a range table with headerline so this entry should be contained in the body as well as in the header.
    But in AT SELECTION-SCREEN ON s_budat. u r again entering a 2nd record if date is not 01.
    AT SELECTION-SCREEN ON s_budat.
    DATA : v_year(4) TYPE c,
    v_month(2) TYPE c,
    v_date(2) TYPE c. "#EC NEEDED
    *if date ne 01 converting date to '01'
    READ TABLE s_budat.
    IF s_budat-low+6(2) NE c_one. << Here u r checking the header not the body
    v_year = s_budat-low.
    v_month = s_budat-low+4(2).
    v_date = s_budat-low+6(2).
    s_budat-high = s_budat-low.
    CLEAR s_budat-low.
    CONCATENATE v_year c_one c_one INTO s_budat-low.
    s_budat-sign = 'I'.
    s_budat-option = 'BT'.
    APPEND s_budat.
    ENDIF.
    Due to these 2 records it is giving u error. So to avoid the problem u should read the body of the table and then modify the record.
    Read table s_budat index 1.
    IF s_budat-low+6(2) NE c_one.* << Here u r checking the header not the body
    v_year = s_budat-low.
    v_month = s_budat-low+4(2).
    v_date = s_budat-low+6(2).
    s_budat-high = s_budat-low.
    CLEAR s_budat-low.
    CONCATENATE v_year c_one c_one INTO s_budat-low.
    s_budat-sign = 'I'.
    s_budat-option = 'BT'.
    modify s_budat index sy-tabix.
    Regards,
    Joy.

  • Error in authentication with ldap server with certificate

    Hi,
    i have a problem in authentication with ldap server with certificate.
    here i am using java API to authenticate.
    Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: timestamp check failed.
    I issued the new certificate which is having the up to 5 years valid time.
    is java will authenticate up to one year only?
    Can any body help on this issue...
    Regards
    Ranga

    sorry i am gettting ythe same error
    javax.naming.CommunicationException: simple bind failed: servername:636 exception is javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: timestamp check failed]
    here when i am using the old certificate and changing the system date means i can get the authentication.
    can you tell where we can concentrate and solve the issue..
    where is the issue
    1. need to check with the ldap server only
    2. problem in java code only.
    thanks in advance

  • Reg: Field Names in GUI_DOWNLOAD

    Hi Sapers,
    I want to keep the Field Headings in XLS file.Here I am using the FM GUI_DOWNLOAD, and passing the Tables parameter(i.e, fieldnames) .But my heading is truncated to 10 char.
    as the way the FM does.
    How can I satisfy my client.Plz help me out.
    regards,
    sri...

    yah, sure.
    here is my code, from type-pools....
    *---- TYPE-POOLS DECLARATION -*
    TYPE-POOLS:truxs.
    *---- SELECTION SCREEN BLOCK -*
    SELECTION-SCREEN BEGIN OF BLOCK sri. " WITH FRAME TITLE INPUT'.
    PARAMETERS   p_bukrs TYPE t001-bukrs OBLIGATORY VALUE CHECK.
    PARAMETERS : pperiod(2) TYPE c,
                 pyear(4)   TYPE c,
                 p_file TYPE rlgrap-filename OBLIGATORY default 'C:\Documents and Settings\srikanth\Desktop\rep1.xls'.
    PARAMETERS : csvfile  RADIOBUTTON GROUP rg1,     "factfile RADIOBUTTON GROUP rg1,
                 excel    RADIOBUTTON GROUP rg1 default 'X',
                 text     RADIOBUTTON GROUP rg1.
    SELECTION-SCREEN END OF BLOCK sri.
    *---- TYPES DECLARATION -*
    TYPES : BEGIN OF ty_faglflext,
              tslvt TYPE faglflext-tslvt,
              tsl01 TYPE faglflext-tsl01,
              tsl02 TYPE faglflext-tsl02,
              tsl03 TYPE faglflext-tsl03,
              tsl04 TYPE faglflext-tsl04,
              tsl05 TYPE faglflext-tsl05,
              tsl06 TYPE faglflext-tsl06,
              tsl07 TYPE faglflext-tsl07,
              tsl08 TYPE faglflext-tsl08,
              tsl09 TYPE faglflext-tsl09,
              tsl10 TYPE faglflext-tsl10,
              tsl11 TYPE faglflext-tsl11,
              tsl12 TYPE faglflext-tsl12,
              zzetbrnum TYPE zetbrmap-zzetbrnum,
            END OF ty_faglflext.
    TYPES :BEGIN OF ty_bukrs,
              bukrs TYPE bukrs,
           END OF ty_bukrs.
    TYPES :BEGIN OF ty_etbrtot,
              zzetbrnum TYPE zetbrmap-zzetbrnum,
              totamt TYPE tslxx12,
           END OF ty_etbrtot.
    TYPES :BEGIN OF ty_currtostr,
             dfld(1) type c,
              zzetbrnum LIKE zetbrmap-zzetbrnum,
              totamt(26) TYPE c,
           END OF ty_currtostr.
    TYPES : BEGIN OF ty_csv,
              comma(80) TYPE c,
            END OF ty_csv.
    TYPES : BEGIN OF ty_txt,
              hfld(1) TYPE c,
              dfld(1) TYPE c,
              zzetbrnum LIKE zetbrmap-zzetbrnum,
              totamt(26) TYPE c,
              tfld(1) TYPE c,
            END OF ty_txt.
    TYPES : BEGIN OF header_record,
              hfld(1) TYPE c,
              filler1(13) TYPE c,
              loc(5) TYPE c,
              filler2(10) TYPE c,
              ppyy(4) TYPE c,
              filler3(47) TYPE c,
            END OF header_record.
    TYPES : BEGIN OF detail_record,
              dfld(1) TYPE c,
              gl(4) TYPE c,
              subbacc(5) TYPE c,
              bal(18) TYPE n,
              sign(1) TYPE c,
              filler(4) TYPE c,
              code(2) TYPE c,
              filler1(45) TYPE c,
            END OF detail_record.
    TYPES : BEGIN OF trailer_record,
              tfld(1) TYPE c,
              filler(79) TYPE c,
            END OF trailer_record.
    *---- DATA DECLARATION -*
    *---- Work Area Declaration -*
    DATA : wa_infaglflext TYPE ty_faglflext,
           wa_inetbrtot TYPE ty_etbrtot,
           wa_currtostr TYPE ty_currtostr,
           wa_csv TYPE ty_csv,
           wa_txt TYPE ty_txt,
           wa_header_record TYPE header_record,
           wa_detail_record TYPE detail_record,
           wa_trailer_record TYPE trailer_record.
          wa_xls type ty_xls.
    *---- Internal Tables Declaration -*
    DATA : infaglflext TYPE STANDARD TABLE OF ty_faglflext,
           inetbrtot TYPE STANDARD TABLE OF ty_etbrtot,
           i_currtostr TYPE TABLE OF ty_currtostr,
           i_csv TYPE STANDARD TABLE OF ty_csv,
           i_txt TYPE STANDARD TABLE OF ty_txt.
          i_xls type table of ty_xls.
    DATA: BEGIN OF dlpivot OCCURS 1.
              INCLUDE STRUCTURE excelpivot.
    DATA: END OF dlpivot.
    DATA : t_bukrs TYPE STANDARD TABLE OF ty_bukrs WITH HEADER LINE.
    DATA : BEGIN OF infieldnames OCCURS 1,   " Internal Table to Hold Headings in file.
            text(50),
           END OF infieldnames.
    *---- Variables -*
    DATA : v_temp TYPE tslxx12,
           v_amt TYPE tslxx12.
    DATA : v_mon(2) TYPE c,
           v_year(4) TYPE c,
           v_yr(4) TYPE c.
    DATA : v_pfile TYPE string.
          p_filetyp type string.
    DATA : v_len TYPE i,
           v_ext(4),
           v_exts(4),
           v_fpath TYPE string.
    *---- INITIALIZING PARAMETERS -*
    INITIALIZATION.
      v_mon   = sy-datum+4(2).
      v_year  = sy-datum+0(4).
      pperiod = v_mon.
      pyear   = v_year.
    *---- VALIDATIONS -*
    *---- COMPANY CODE VALIDATION -*
    AT SELECTION-SCREEN ON p_bukrs.
      SELECT bukrs FROM t001 INTO TABLE t_bukrs WHERE bukrs = p_bukrs. " COMP CODE
      IF sy-subrc NE 0.
        MESSAGE 'enter valid company code' TYPE 'E'.
      ENDIF.
    *---- MONTH VALIDATION -*
    AT SELECTION-SCREEN ON pperiod.
      IF ( pperiod LT 1 OR pperiod GT 12 ).
        MESSAGE 'Enter valid month ' TYPE 'E'.
      ENDIF.
    *---- YEAR VALIDATION -*
    AT SELECTION-SCREEN ON pyear.
      v_yr = v_year - 2.
      IF ( pyear GT v_year OR pyear LT  v_yr ).
        MESSAGE 'Enter valid Year(Not less than current minus 2 or Greater than current) ' TYPE 'E'.
      ENDIF.
    *---- File Extension Validation -*
    AT SELECTION-SCREEN.
      PERFORM get_ext.
      IF ( ( NOT ( excel EQ 'X' AND v_ext EQ '.xls' ) ) and
      ( NOT ( csvfile EQ 'X' AND v_ext EQ '.csv' ) ) and
      ( NOT ( text EQ 'X' AND v_ext EQ '.txt' ) ) ).
        MESSAGE e001(zgmam_msg).   "'choose the correct file format' TYPE 'E'.
      ENDIF.
    *---- F4 FUNCTIONALITY FOR FILE PATH -*
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      CALL FUNCTION 'F4_FILENAME'
        EXPORTING
          program_name  = syst-cprog
          dynpro_number = syst-dynnr
          field_name    = 'P_FILE'
        IMPORTING
          file_name     = p_file.
    *---- START-OF-SELECTION -*
    START-OF-SELECTION.
      SELECT a~tslvt
             a~tsl01
             a~tsl02
             a~tsl03
             a~tsl04
             a~tsl05
             a~tsl06
             a~tsl07
             a~tsl08
             a~tsl09
             a~tsl10
             a~tsl11
             a~tsl12
             b~zzetbrnum
         INTO TABLE infaglflext
         FROM faglflext AS a
           INNER JOIN zetbrmap AS b
             ON arbukrs = bbukrs  AND
                aracct  = bhkont
         WHERE a~ryear   = pyear.
      IF sy-subrc EQ 0.
        LOOP AT infaglflext INTO wa_infaglflext.
         CLEAR v_amt.
          v_amt = v_amt + wa_infaglflext-tslvt.
          DO pperiod TIMES
            VARYING v_temp
            FROM   wa_infaglflext-tsl01
              NEXT wa_infaglflext-tsl02.
            v_amt = v_amt + v_temp.
          ENDDO.
          wa_inetbrtot-zzetbrnum = wa_infaglflext-zzetbrnum.
          wa_inetbrtot-totamt    = v_amt .
          APPEND wa_inetbrtot TO inetbrtot.
          CLEAR : wa_inetbrtot,
                  wa_infaglflext,
                  v_amt.
        ENDLOOP.
        PERFORM header.
        IF ( excel EQ 'X' AND v_ext EQ '.xls' ).
          PERFORM download_to_xls.
        ELSE.
          IF ( csvfile EQ 'X' AND v_ext EQ '.csv' ).
            PERFORM download_to_csv.
          ELSE.
            IF ( text EQ 'X' AND v_ext EQ '.txt' ).
              PERFORM download_to_text.
            ENDIF.
          ENDIF.
        ENDIF.
      ELSE.
        WRITE :/ 'NO RECORDS FOUND'.
      ENDIF.
    -------------------SUBROUTINES----------------------------------**
    *&      Form  download_to_xls
          text
    FORM download_to_xls.
    *wa_xls-head1 = 'GENERAL LEDGER'.
    *wa_xls-head2 = 'AMOUNT'.
    *APPEND WA_XLS TO I_CSV.
    *CLEAR WA_XLS.
    *loop at inetbrtot into wa_inetbrtot.
    wa_xls-zzetbrnum = wa_inetbrtot-zzetbrnum.
    wa_xls-totamt    = wa_inetbrtot-totamt.
    append wa_xls to i_CSV.
    clear wa_xls.
    *endloop.
    CALL FUNCTION 'EXCEL_OLE_STANDARD_DAT'
      EXPORTING
        file_name                       = p_file
      CREATE_PIVOT                    = 0
       DATA_SHEET_NAME                 = 'EXCEL'
      PIVOT_SHEET_NAME                = ' '
      PASSWORD                        = ' '
      PASSWORD_OPTION                 = 0
    TABLES
       PIVOT_FIELD_TAB                 = dlpivot
       DATA_TAB                        = inetbrtot
       FIELDNAMES                      = infieldnames
    EXCEPTIONS
       FILE_NOT_EXIST                  = 1
       FILENAME_EXPECTED               = 2
       COMMUNICATION_ERROR             = 3
       OLE_OBJECT_METHOD_ERROR         = 4
       OLE_OBJECT_PROPERTY_ERROR       = 5
       INVALID_PIVOT_FIELDS            = 6
       DOWNLOAD_PROBLEM                = 7
       OTHERS                          = 8
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    CALL FUNCTION 'GUI_DOWNLOAD'
       EXPORTING
         filename                      = v_pfile
         filetype                      = 'DBF'
         WK1_N_SIZE                    = 15
         WK1_T_SIZE                    = 15
         append                       = 'X'
      CONFIRM_OVERWRITE               = 'X'
       TABLES
         data_tab                      = inetbrtot
         fieldnames                    = infieldnames.
    ENDFORM.                    "download_to_xls
    *&      Form  download_to_csv
          text
    FORM download_to_csv.
      DATA : v_data TYPE string.
      CLEAR wa_inetbrtot.
      LOOP AT inetbrtot INTO wa_inetbrtot.
        v_data = wa_inetbrtot-totamt.
        CONDENSE  v_data NO-GAPS.
        CALL FUNCTION 'HRCM_AMOUNT_TO_STRING_CONVERT'
          EXPORTING
            betrg                         = v_data
        WAERS                         = ' '
        NEW_DECIMAL_SEPARATOR         =
        NEW_THOUSANDS_SEPARATOR       =
         IMPORTING
           string                        = wa_currtostr-totamt
        wa_currtostr-zzetbrnum = wa_inetbrtot.
        APPEND wa_currtostr TO i_currtostr.
        CLEAR wa_currtostr.
      ENDLOOP.
      LOOP AT i_currtostr INTO wa_currtostr.
        CONCATENATE wa_currtostr-zzetbrnum
                    wa_currtostr-totamt
                    INTO wa_csv-comma
                    SEPARATED BY ','.
        APPEND wa_csv TO i_csv.
        CLEAR wa_csv.
      ENDLOOP.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename                      = v_pfile
       filetype                         = 'ASC'
      WRITE_FIELD_SEPARATOR           = 'X'
        TABLES
          data_tab                      = i_csv
         fieldnames                   = infieldnames.
    ENDFORM.                    "download_to_csv
    *&      Form  DOWNLOAD_TO_TEXT
          text
    -->  p1        text
    <--  p2        text
    FORM download_to_text. " using p_filetyp type string.
      DATA : BEGIN OF head OCCURS 1,                             " Internal Table to Hold Headings in file.
              text(1) VALUE 'H',
             END OF head.
      DATA : v_data TYPE string.
      CLEAR wa_inetbrtot.
      CLEAR wa_header_record.
      wa_header_record = space.
      wa_header_record-hfld = 'H'.
    wa_txt-hfld = 'H'.
      wa_header_record-ppyy+0(2) = pperiod.
      wa_header_record-ppyy2(2) = pyear2(2).
      APPEND wa_header_record TO i_csv.
      APPEND wa_txt TO i_txt.
      CLEAR wa_txt.
      LOOP AT inetbrtot INTO wa_inetbrtot.
        CLEAR wa_detail_record.
        wa_detail_record = space.
        wa_detail_record-dfld = 'D'.
       wa_txt-dfld         = 'D'.
       wa_txt-zzetbrnum    = wa_inetbrtot-zzetbrnum.
        wa_detail_record-bal = '0000000000000000000000'.
       wa_detail_record-bal = wa_
        v_data              = wa_inetbrtot-totamt.
        wa_detail_record-gl = wa_inetbrtot-zzetbrnum.
        CONDENSE  v_data NO-GAPS.
        CALL FUNCTION 'HRCM_AMOUNT_TO_STRING_CONVERT'           "CONVERT ITAB-DATA TO STRING, AS THE ITAB CONTAINS A CURRENCY FIELD.
          EXPORTING
            betrg                         = v_data
        WAERS                           = ' '
        NEW_DECIMAL_SEPARATOR           =
        NEW_THOUSANDS_SEPARATOR         =
         IMPORTING
           string                         = wa_txt-totamt
        wa_detail_record-bal = wa_txt-totamt.
        IF ( wa_inetbrtot-totamt LT 0 ).
          wa_detail_record-sign = '-'.
        ELSE.
          wa_detail_record-sign = ' '.
        ENDIF.
        APPEND wa_detail_record TO i_csv.
        APPEND wa_txt TO i_txt.
        CLEAR wa_txt.
      ENDLOOP.
      wa_trailer_record-tfld = 'T'.
      APPEND wa_trailer_record TO i_csv.
      CLEAR wa_txt.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
      BIN_FILESIZE                      =
         filename                         = v_pfile
         filetype                         = 'DAT'
        append                          = 'X'
         header                         = 'abcd'
         replacement                    = '#'
      WRITE_FIELD_SEPARATOR             = ','
      CONFIRM_OVERWRITE                 = 'X'
        TABLES
          data_tab                        = i_csv
        fieldnames                      = HEAD.
    ENDFORM.                    " DOWNLOAD_TO_FILE
    *&      Form  header
          text
    -->  p1        text
    <--  p2        text
    FORM header .
      infieldnames-text = 'GeneralLedger Account'.
      APPEND infieldnames.
      CLEAR infieldnames.
      infieldnames-text = 'Amount'.
      APPEND infieldnames.
      CLEAR infieldnames.
    ENDFORM.                    "header
    *&      Form  get_ext
          text
    FORM get_ext.
      v_pfile = p_file.
      v_len   = STRLEN( v_pfile ).
      v_len   = v_len - 4.
      v_ext   = v_pfile+v_len(4).
    ENDFORM.                    "get_ext
    Message was edited by:
            srikanth vadlamani

  • DateFormat parse method usage

    Hi all,
    I am using the following code to parse the date String object to Date Object -
    ======================================================================
    if(dateString == null || dateString.trim().equals(""))
    return null;
    DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.SHORT,
    Locale.getDefault());
    Date d = null;
    try
    dateFormatter.setLenient(false);
    d = dateFormatter.parse(dateString);
    catch(ParseException pe)
    e.printStackTrace();
    =================================================================
    This code works perfectly for all formats of String objects I give except for the format - "12/12/12/1" in which case it converts to following date object -
    "Wed Dec 12 00:00:00 IST 2012" although its an invalid date String.
    Please let me know how I could have correct validation done in such cases or if this is the right behavior for DateFormat class.
    Thanks in advance!!

    I'm not going to comment on how exactly the parse method does its business, but I can suggest you use a regex pattern to validate the input you will send the parse method.
    Here is some info from the CodeProject website on date validation(Note that this is aimed at .NET - but regex works the same in Java as it does in .NET [i think]):
    Dates: As with numbers, we need two validators: a key-press validator, and a completion validator. The key-press validator can be pretty simple, if we limit how our user enters the date. Let’s say that we want to validate for the U.S. date format mm/dd/yyyy. Here is a validator that will do that:
    ^([0-9]|/)*$
    The regex reads: “Match any string that contains a sequence of zero or more characters, where each character is either a digit or a slash.” This validator will give the user immediate feedback if they enter an invalid character, such as an ‘a’.
    Copy that regex to Regex Tester and give it a try. Note that the validation fails if the user enters dashes, instead of slashes, between the parts of the date. How could we increase the flexibility of our regex to accommodate dashes? Think about the question for a minute before moving on.
    All we need to do is add a dash to the alternates group:
    ^([0-9]|/|-)*$
    We could add other alternates to make the regex as flexible as it needs to be.
    The completion validator does a final check to determine whether the input matches a complete date pattern:
    ^[0-2]?[1-9](/|-)[0-3]?[0-9](/|-)[1-2][0-9][0-9][0-9]$
    The regex reads as follows: "Match any string that conforms to this pattern: The first character can be a 0, 1, or 2, and it may be omitted. The second character can be any number and is required. The next character can be a slash or a dash, and is required…” And so on. This regex differs from the ones we used before in that it specifies each character of the pattern—the pattern is more of a template than a formula.
    Note the first character of the regex: ‘[0-2]’. This character points out that we can limit allowable digits to less than the full set. We can also expand them; for example, ‘[0-9A-F]’ would allow any hexadecimal digit. In fact, we can use this structure, known as a character class, to specify any set of characters we want. For example, the character class ‘[A-Z]’ allows capital letters, and ‘[A-Za-z]’ allows upper or lower-case letters.
    Our date regex also points out some of the limitations of regex validation. Paste the date regex shown into Regex Tester and try out some dates. The regex does a pretty good job with run-of-the-mill dates, but it allows some patently invalid ones, such as ‘29/29/2006’, or ‘12/39/2006'. The regex is clearly not ‘bulletproof’.
    We could beef up the regular expression with additional features to catch these invalid dates, but it may be simpler to simply use a bit of .NET in the completion validator:
    bool isValid = DateTime.TryParse(dateString, out dummy);
    We gain the additional benefit that .NET will check the date for leap year validity, and so on. As always, the choice comes down to: What is simpler? What is faster? What is more easily understood? In my shop, we use a regex for the key-press validator, and DateTime.TryParse() for the completion validator.
    Oh - and there is another regex validator:
    ^[0-9]{4}-(((0[13578]|(10|12))-(0[1-9]|[1-2][0-9]|3[0-1]))|(02-(0[1-9]|[1-2][0-9]))|((0[469]|11)-(0[1-9]|[1-2][0-9]|30)))$
    which matches the yyyy-mm-dd date format and also validates month and number of days in a month. Could be improved as currently all leap year dates (yyyy-02-29) will validate.
    Sorry if I couldn't be of more help...
    Edited by: JoKiLlSyA on Oct 9, 2008 11:22 PM

  • SimpleDateFormat Question

    Hiii...
    I am using SimpleDateFormat to do date validation and parsing. The problem that I am having is that I am setting the pattern of SimpleDateFormat to "MMddyyyy". Now, because of some implicit year validation, dates such as "121203" are taken as valid dates. I need to force the user to enter dates in (mmddyyyy) format.
    Is their any function which would force the SimpleDateFormat function to throw a parse exception for the above type (mmddyyyy) of dates.
    sanjay.

    hii..
    setLenient doesn't solve the problem. For instance the below code block doesn't throw any exception..
    java.text.SimpleDateFormat dft = new java.text.SimpleDateFormat();
    dft.applyPattern("MMddyyyy");
    dft.setLenient(false);
    java.util.Date dtObj = dft.parse("080103");
    System.out.println(dtObj.toString());
    Also, from what I have read..if setLenient is true then dates like 02302003(feb. 30th) is interpreted as Mar'2nd 2003. but by setting it to false feb.30th throws a parseException BUT it doesn't solve my problem of strict formatting.
    sanjay.

Maybe you are looking for

  • Is it possible to use single quotes in a String

    Can we use single quotes and comma in side a string variable... Eg: String s=" a ' , ' b "; why am i asking was...... when this variable is sent to database, the table automatically recognizes the beginning single quotes and end single quotes to retr

  • Transferring ebooks from Mavericks to iOS device?

    In the past I would move my ebooks from iTunes to my iOS devices just by dragging and dropping them onto the device, yet now with the introduction of iBooks for Mac that is no longer possible. How do I transfer my books from the Mac to my iOS device

  • SAPGUI 7.20 PL4: Input history is not working

    Hello, we're on the way to roll out SAPGUI 7.20 PL4. Now I discoverd a serious bug: Local input history isn't working anymore. I switched on tracing on SAPGUI to see whats wrong, an the cause is simple: SAPGUI uses comma (,) instead of dot (.) in the

  • Problem encoding video project

    I am trying to export a project that I have created but keep having problems encoding it. I can start the queue fine but it keeps failing with the following warning: - Source File: D:\DOCUME~1\PR\LOCALS~1\Temp\Exit Festival 2009_2.prproj - Output Fil

  • Airplay Mirroring still not working with OSX 10.9.3

    I upgraded yesterday, but the mirroring is still NOT working. I hear the sound, but don´t see the image. The option "DELL 2001FP spiegeln" is not selectable. What am I to do?