10-04-2008 12:16 PM
hi all,
I want to compare 2 date fields in from internal table using loop how is this possible . I tried lot.
Plz help me.
10-04-2008 12:19 PM
suppose u have two internal tables ITAB1,ITAB2 and work areas WA!,WA2 respectively,suppose MATNR is the field u want to compare for ur condition.
if WA1-MATNR = WA2-MATNR .
write:/sy-subrc.
endif.
If you send your coding we will give u the exact solution.
10-04-2008 12:17 PM
Hi,
If both are date fields then u can compare using relational operation.
Thanks
Piyush
10-04-2008 12:18 PM
Hi piyush ,
If i m using '> ' condition then it gives wrong answer.
Plz help me..
10-04-2008 12:19 PM
suppose u have two internal tables ITAB1,ITAB2 and work areas WA!,WA2 respectively,suppose MATNR is the field u want to compare for ur condition.
if WA1-MATNR = WA2-MATNR .
write:/sy-subrc.
endif.
If you send your coding we will give u the exact solution.
10-04-2008 12:23 PM
SELECT BELNR BUDAT GJAHR BLDAT
INTO (ITAB-BELNR,ITAB-BUDAT,ITAB-GJAHR,ITAB-BLDAT)
FROM BKPF
WHERE BLDAT <= BUDAT
AND BUKRS = 'ABCB'
AND BLART = 'RV'.
SELECT KUNNR SHKZG WRBTR ZFBDT BSCHL VBELN AUGBL ZBD1T ZTERM AUGDT
BELNR
INTO (ITAB-KUNNR,ITAB-SHKZG,ITAB-WRBTR,ITAB-ZFBDT,ITAB-BSCHL,
ITAB-VBELN,ITAB-AUGBL,ITAB-ZBD1T,ITAB-ZTERM,ITAB-AUGDT,ITAB-BELNR1)
FROM BSEG
WHERE BELNR = ITAB-BELNR
AND BUKRS = 'ABCB'
AND KUNNR IN KUNNR
AND KOART = 'D'
AND GJAHR = ITAB-GJAHR.
APPEND ITAB.
ENDSELECT.
ENDSELECT.
LOOP AT ITAB.
ITAB-NET_DUE_DT = ITAB-ZBD1T + ITAB-ZFBDT.
MODIFY ITAB.
ENDLOOP.
in this coding i want to compare
ITAB-NET_DUE-DT < = ITAB-AUGDT.
PLZ. HELP ME.
10-04-2008 12:39 PM
10-04-2008 12:49 PM
Please let us know in what dates your conditions are failing.
Below code is working fine for me.
DAT1 = '20071231'.
DAT2 = '20070131'.
IF DAT1 <= DAT2.
BREAK-POINT.
ENDIF.
Piyush
10-04-2008 12:50 PM
Hi,
ITAB-NET_DUE-DT < = ITAB-AUGDT.
First check Is your ITAB having working OR not,otherwise declare work area explicitely.
10-04-2008 12:51 PM
what do u want to check?
if u want to compare dates?
wa_date1(2) > wa_date2(2).
date1 = 28102002
this will compare the first two numbers of ur work area..i.e first two numbers are 28..28 is the date.
10-04-2008 12:55 PM
I think it is ITAB-NET_DUE_DT < = ITAB-AUGDT not ITAB-NET_DUE-DT < = ITAB-AUGDT.
10-04-2008 12:56 PM
hi
anil..
its date like '20040111'.
both date are in same formate.
Plz help me...
10-04-2008 12:57 PM
What are the dates, in which ur condition is fails.
Give one example.
10-04-2008 1:00 PM
hi..
if i m using such condition then
1 date compares with another dates of second column.
i want to compare 1 date with only 1 date of another column.
10-04-2008 1:28 PM
then u can write
write loop it into wa...endloop.
inside loop -
endloop
wa1_date6(2) > wa2_date6(2).
then u can compare dates.
10-04-2008 1:40 PM
HI Ankita,
Did u solved u problem otherwise give me ur total code I'll try to help u
10-04-2008 1:54 PM
> SELECT BELNR BUDAT GJAHR BLDAT
> INTO (ITAB-BELNR,ITAB-BUDAT,ITAB-GJAHR,ITAB-BLDAT)
> FROM BKPF
> WHERE BLDAT <= ITAB-BUDAT
> AND BUKRS = 'ABCB'
> AND BLART = 'RV'.
>
Use ITAB-BUDAT in where condittion, as shown above.