Skip to Content
author's profile photo Former Member
Former Member

problem in select statement....

Hi all,

Here i have problem, i.e i ve 2 internal tables. with data, in 2 int tables i ve date field, here one field is char type and other is DATS type, i want to compare these two dates,

like Tab1 date < min( tab2 date) and store into 3rd table. here am not able to comparing the dates.

here my code is:

REPORT ZEXCHANGE_RETES .

TABLES : tcurr, " Exchange Rates

/msg/rabr. " Account (Posting Headers)

DATA : l_date type datum.

TYPES : begin of t_tcurr,

kurst like tcurr-kurst, " Exchange Rate type

fcurr like tcurr-fcurr, " From Currrency

gdatu like tcurr-gdatu, " Date as of which

end of t_tcurr.

TYPES : begin of t_rabr,

abrnr like /msg/rabr-abrnr,

VTGNR like /msg/rabr-VTGNR,

BESTNR like /msg/rabr-BESTNR,

OW_WHGNR like /msg/rabr-OW_WHGNR,

bil_dat like /msg/rabr-bil_dat,

end of t_rabr.

TYPES : begin of t_output,

kurst like tcurr-kurst,

fcurr like tcurr-fcurr,

gdatu like tcurr-gdatu,

abrnr like /msg/rabr-abrnr,

VTGNR like /msg/rabr-VTGNR,

BESTNR like /msg/rabr-BESTNR,

OW_WHGNR like /msg/rabr-OW_WHGNR,

bil_dat like /msg/rabr-bil_dat,

end of t_output.

DATA : it_output TYPE STANDARD TABLE OF t_output WITH HEADER LINE,

wa_output TYPE t_output.

DATA : it_rabr TYPE STANDARD TABLE OF t_rabr WITH HEADER LINE,

wa_rabr TYPE t_rabr.

DATA : it_tcurr TYPE STANDARD TABLE OF t_tcurr WITH HEADER LINE,

wa_tcurr TYPE t_tcurr.

data : it_rabr1 type STANDARD TABLE OF /msg/rabr.

data : wa_rabr1 type /msg/rabr.

SELECT kurst fcurr gdatu

from tcurr into table it_tcurr

where kurst EQ 'M'.

SORT it_tcurr by fcurr GDATU DESCENDING.

delete adjacent duplicates from it_tcurr comparing fcurr.

LOOP AT it_tcurr.

MOVE it_tcurr-gdatu TO l_date.

READ TABLE it_rabr with key OW_WHGNR = it_tcurr-fcurr.

IF SY-SUBRC EQ 0.

SELECT * FROM /msg/rabr into CORRESPONDING FIELDS OF TABLE it_rabr

WHERE OW_WHGNR EQ it_tcurr-fcurr AND

WHERE abrnr BETWEEN '00000000000000800251' AND '00000000000000800300'

AND bil_dat LT l_date.

SORT it_rabr BY OW_WHGNR bil_dat abrnr.

IF SY-SUBRC EQ 0.

MOVE it_tcurr-kurst TO it_output-kurst.

MOVE it_tcurr-fcurr TO it_output-fcurr.

MOVE it_tcurr-gdatu TO it_output-gdatu.

MOVE it_rabr-VTGNR TO it_output-VTGNR.

MOVE it_rabr-BESTNR TO it_output-BESTNR.

MOVE it_rabr-OW_WHGNR TO it_output-OW_WHGNR.

MOVE it_rabr-abrnr TO it_output-abrnr.

MOVE it_rabr-bil_dat TO it_output-bil_dat.

APPEND it_output.

ENDIF.

ENDLOOP.

here am looping it_tcurr , then inside that am selecting data from /msg/rabr table, into it_rabr but here am not getting data into it_rabr table.

Whats wrong i ve gone plz help.

Thanks in Advance,

sudharsan.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Nov 21, 2007 at 08:22 AM

    Hi SUDHARSAN,

    For comparing two date fields where one field (of ITAB1)is in CHAR type and the other field (of ITAB2) in DATS.

    1. First of all you should declare a variable of type SY-DATUM.

    2. Assign the field of character type to this variable.

    3. If the representation of DATE is '23.03.2007' convert that into '20070323' format using function module 'CONVERSION_EXIT_PDATE_INPUT' or 'CONVERT_DATE_TO_INTERNAL'.

    Otherwise,

    make format '20070323' to '23032007' so that we can compare easily.

    4. Please Check these programs out.

    REPORT ZTEST.

    DATA : V_DATE1 LIKE SY-DATUM,

    V_DATE2 LIKE SY-DATUM..

    V_DATE1 = '01022006'.

    V_DATE2 = '01012007'.

    IF V_DATE1 LE V_DATE2.

    WRITE : 'yes'.

    ELSE.

    WRITE : 'no'.

    ENDIF.

    Output : No.

    REPORT ZTEST.

    DATA : V_DATE1 LIKE SY-DATUM,

    V_DATE2 LIKE SY-DATUM..

    V_DATE1 = '20060201'.

    V_DATE2 = '20070101'.

    IF V_DATE1 LE V_DATE2.

    WRITE : 'yes'.

    ELSE.

    WRITE : 'no'.

    ENDIF.

    Output : Yes

    Hope this works.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 21, 2007 at 08:42 AM

    Hi Sudharshan,

    move the date of dats type to a variable of type 'C' and then compare this wid

    ur date of character type.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.