Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Comparison b/w two char field

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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 ).

9 REPLIES 9

Former Member
0 Kudos

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

Former Member
0 Kudos

Actually gdatu is in inverted date format.

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

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

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

0 Kudos

thanx 2 all

for quick response, but this wont solve my problem i know ican convert the type of one feild into another but the problem is logical comparision is not portable with char field type.

so is there anything else can u all will suggest me

0 Kudos

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.

Former Member
0 Kudos

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 ).

0 Kudos

thanx sanjay

ur solution had really help me alot

thanx alot.