Skip to Content
author's profile photo
Former Member

Comparison b/w two char field

hi all

Here in following select query field gdatu is char field it storing date as in char format and i hv to compare it with date.Which is not possible in dis way.

can anyone suggest me any solution for dis problem.

here lv_pool_val_dt is date type field.

SELECT fcurr ukurs

INTO TABLE lt_tcurr

FROM tcurr

WHERE gdatu GE lv_pool_val_dt.

regards

sunanda

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

6 Answers

  • Best Answer
    author's profile photo
    Former Member
    Oct 05, 2005 at 06:19 AM

    Hi Sunanda,

    You have to convert your date field before the select statement. Try this -

    <b>data : begin of lt_tcurr occurs 0,

    fcurr like tcurr-fcurr,

    ukurs like tcurr-ukurs,

    end of lt_tcurr.

    data lv_pool_val_dt like sy-datum.

    data wa_date(10).

    data wa_gdatu like tcurr-gdatu.

    lv_pool_val_dt = sy-datum.

    write lv_pool_val_dt to wa_date.

    CALL FUNCTION 'CONVERSION_EXIT_INVDT_INPUT'

    EXPORTING

    INPUT = wa_date

    IMPORTING

    OUTPUT = wa_gdatu

    .

    SELECT fcurr ukurs

    INTO TABLE lt_tcurr

    FROM tcurr

    WHERE gdatu GE wa_gdatu.

    loop at lt_tcurr.

    write :/ lt_tcurr-fcurr, lt_tcurr-ukurs.

    endloop.</b>

    Cheers.

    ( dont forget to reward if answers were helpful ).

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Oct 05, 2005 at 05:10 AM

    you should be able to change the declaration of lv_pool_val_dt to type char so long as the contents of the field is in format YYYYMMDD. This way you can simple perform your sql statement as is. One assumption (without looking at TCURR) is that gdatu is also inthe format of YYYYMMDD

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Oct 05, 2005 at 05:13 AM

    Actually gdatu is in inverted date format.

    So use FM CONVERSION_EXIT_INVDT_INPUT to convert your date into the format of tcurr-gdatu.

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 05, 2005 at 05:16 AM

    Welcome to SDN forum.

    Try like this,

    DATA: lv_pool_val_dt type date,
          lv_date(8) type c.
    
    After u get the value in this variable do as:
    <b>WRITE: lv_pool_val_dt TO lv_date.</b>
    SELECT fcurr ukurs
    INTO TABLE lt_tcurr
    FROM tcurr 
    WHERE gdatu GE lv_date.

    Hope this helps.

    Kindly reward points and close this thraed if ur problem got solved or get back.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Oct 05, 2005 at 05:27 AM

    Hi,

    I hope the info given by Judith will help you.

    You can also use <b>MOVE</b> instraed of <b>WRITE</b>.

    Please reward points if this explanation is useful.

    Regards,

    Siva

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Oct 05, 2005 at 05:30 AM

    do as following

    suppose gdatu is '05.31.2005'.

    char: mm(2), dd(2), yy(4).

    split gdatu at '.' into mm dd yy.

    concatenate yy mm dd into gdatu.

    now u can do the select query.

    hope ur problem is solved.

    Reward points if ur problem is solved.

    Cheers,

    Ateeq

    Message was edited by: Ateeq K

    Add comment
    10|10000 characters needed characters exceeded

    • Hi,

      U can try this code its working fine

      DATA: lv_pool_val_dt LIKE eabl-adat,
            lv_date(8) type c,
            lv_outdat(8) TYPE c.
      
      lv_pool_val_dt =  '20040101'.
      
      WRITE: lv_pool_val_dt TO lv_date.
      
      lv_outdat = '79949595'.
      
      IF lv_outdat GE lv_date .
       write: / 'HI'.
      endif.

      Hope this helps.