‎2009 Apr 08 10:49 PM
Hello All!
Perhaps this is a simple question, and I will slap myself in the forehead when I can figure out the answer, but here it goes...
One of the methods of a class I am building simply populates an internal table of the class. I originally had this section of code working (Labeled Original Below); the requirements have changed and I need to select the data slightly differently (Labeled New Below). Now the SELECT Statement is returning NO DATA.
I have verified that at least one record exists that should meet the requirements.
Original Code
- This code will select the fields listed for Shipments that fall with in the bTKNUM and eTKNUM fields and have an appointment date between bDPLBG and eDPLBG, only if the shipment had a carrier assigned (Inner Join LFA1 ON VTTKTDLNR = LFA1LIFNR). This was working!
METHOD GetHeadInfo .
" --> bTKNUM
" --> eTKNUM
" --> bDPLBG
" --> eDPLBG
SELECT DISTINCT VTTK~TKNUM VTTK~DPLBG VTTK~UPLBG VTTK~TDLNR
LFA1~NAME1 LFA1~TELFX
INTO CORRESPONDING FIELDS OF TABLE itHeader
FROM VTTK
INNER JOIN LFA1
ON VTTK~TDLNR = LFA1~LIFNR
WHERE VTTK~TKNUM BETWEEN bTKNUM AND eTKNUM
AND VTTK~DPLBG BETWEEN bDPLBG AND eDPLBG .
ENDMETHOD .
New Code
The code had to be changed however. The requirements changed to Shipments that have a carrier and do not have an appointment date set.
METHOD GetHeadInfo .
" --> bTKNUM
" --> eTKNUM
SELECT DISTINCT VTTK~TKNUM VTTK~DPLBG VTTK~UPLBG VTTK~TDLNR LFA1~NAME1 LFA1~TELFX
INTO CORRESPONDING FIELDS OF TABLE itHeader
FROM VTTK
INNER JOIN LFA1
ON VTTK~TDLNR = LFA1~LIFNR
WHERE VTTK~DPLBG IS NULL
AND VTTK~TKNUM BETWEEN bTKNUM AND eTKNUM .
* AND VTTK~DPLBG BETWEEN bDPLBG AND eDPLBG .
ENDMETHOD .
As you can see, I simply added a test for NULL Appointment Dates and removed the BETWEEN section for appointment dates. In addition, the UI was modified to not allow entrance of Appointment Date values.
This code is not working, everything else about the application seems to work, but this section of code.
I have an idea that it is due to the BETWEEN statement with a TYPE TKNUM field. TKNUM is TYPE N, and I am basically asking for records that are between two Numeric Character fields and it doesn't know how to compare them.
This is currently in a MODULE-POOL, so the screens have been built with Screen Painter. Perhaps I need to learn to implement SELECT-OPTIONS in Screen Painter build screen.
Any other ideas on why the new code would fail while the old code worked?
Thank you in Advance!
‎2009 Apr 09 4:33 AM
Hi Steve,
Change line 'WHERE VTTKDPLBG IS NULL' to 'WHERE VTTKDPLBG = 00000000'. Ur code will work.
Ur code:
SELECT DISTINCT VTTKTKNUM VTTKDPLBG VTTKUPLBG VTTKTDLNR LFA1NAME1 LFA1TELFX
INTO CORRESPONDING FIELDS OF TABLE itHeader
FROM VTTK
INNER JOIN LFA1
ON VTTKTDLNR = LFA1LIFNR
WHERE VTTKDPLBG IS NULL <----- Change this line to WHERE VTTKDPLBG = 00000000
AND VTTK~TKNUM BETWEEN bTKNUM AND eTKNUM .
AND VTTK~DPLBG BETWEEN bDPLBG AND eDPLBG .
Thanks.
‎2009 Apr 09 4:33 AM
Hi Steve,
Change line 'WHERE VTTKDPLBG IS NULL' to 'WHERE VTTKDPLBG = 00000000'. Ur code will work.
Ur code:
SELECT DISTINCT VTTKTKNUM VTTKDPLBG VTTKUPLBG VTTKTDLNR LFA1NAME1 LFA1TELFX
INTO CORRESPONDING FIELDS OF TABLE itHeader
FROM VTTK
INNER JOIN LFA1
ON VTTKTDLNR = LFA1LIFNR
WHERE VTTKDPLBG IS NULL <----- Change this line to WHERE VTTKDPLBG = 00000000
AND VTTK~TKNUM BETWEEN bTKNUM AND eTKNUM .
AND VTTK~DPLBG BETWEEN bDPLBG AND eDPLBG .
Thanks.
‎2009 Apr 09 4:56 AM
Hi Steven,
DPLBG-Planned date for start of loading is a date field, For a date field if you use NULL operator it will not work,
I mean there is a difference b/n NULL & INITIAL.
Thats it,
Perhaps I need to learn to implement SELECT-OPTIONS in Screen Painter build screen.
And for what you said, Once a long back when I was a Begginer in ABAP I tried & failed,
Thanks for remembering me, Now I will solve my known backlog...
Thanks & regards,
Dileep .C
‎2009 Apr 09 6:15 AM
‎2009 Apr 09 6:19 AM
Hi!
in this select clause u used the date field can not be null but '00000000' and hence if u change this
WHERE VTTK~DPLBG IS NULL
(to)
WHERE VTTK~DPLBG = '00000000'
this will work..........
and u will get ur one record selected.......
SELECT DISTINCT VTTK~TKNUM VTTK~DPLBG VTTK~UPLBG VTTK~TDLNR LFA1~NAME1 LFA1~TELFX
INTO CORRESPONDING FIELDS OF TABLE itHeader
FROM VTTK
INNER JOIN LFA1
ON VTTK~TDLNR = LFA1~LIFNR
WHERE VTTK~DPLBG eq '00000000'
AND VTTK~TKNUM BETWEEN bTKNUM AND eTKNUM .
AND VTTK~DPLBG BETWEEN bDPLBG AND eDPLBG .
Edited by: Richa Tripathi on Apr 9, 2009 7:20 AM
‎2009 Apr 09 2:19 PM