03-07-2014 9:28 AM
Hello Experts,
I require your guidance regarding one select query.
The selection screen contains a date field only. That date is based on VBRK-AEDAT(Last Changed date). So the output is displayed based on AEDAT field. The condition is that if AEDAT field is blank in VBRK Table, then the output should be displayed based on FKDAT(Billing Date) field in VBRK Table.
The code snippet which I have written is:
types: begin of st_date,
l_date like sy-datum,
aedat like vbrk-aedat,
fkdat like vbrk-fkdat,
date type datum,
end of st_date.
data : it_date type table of st_date,
wa_date type st_date.
selection-screen : begin of block blk with frame title text-001.
select-options : date for aedat.
selection-screen : end of block blk.
at selection-screen on date.
select aedat
from vbrk
into corresponding fields of table it_date
where aedat in date.
if sy-subrc ne 0.
select fkdat
from vbrk
into corresponding fields of table it_date
where fkdat in date.
endif.
So when AEDAT is blank, it is not fetching data based on FKDAT.
Kindly suggest some changes in the SELECT query.
Thanks and Regards,
Satvik
03-07-2014 9:35 AM
Hi Satvik,
In above code if date field is empty it will fetch all the records from vbrk based on fkdat.
Try with this code.
at selection-screen on date.
if date is not initial.
select aedat
from vbrk
into corresponding fields of table it_date
where aedat in date.
else.
select fkdat
from vbrk
into corresponding fields of table it_date
where fkdat in date.
endif.
03-07-2014 9:36 AM
Hi Satvik,
check the date which you are giving that is there in the table vbrk and remove at selection -screen on date.
Regards,
Raman
03-07-2014 9:56 AM
Hi Satvik,
The Code you written is correct as per your logic, Check with your VBRK table , whether it will have your Input date for the filed fkdat.
TABLES : VBRK.
types: begin of st_date,
l_date like sy-datum,
aedat like vbrk-aedat,
fkdat like vbrk-fkdat,
date type datum,
end of st_date.
data : it_date type table of st_date,
wa_date type st_date.
selection-screen : begin of block blk with frame title text-001.
select-options : date for VBRK-aedat.
selection-screen : end of block blk.
at selection-screen .
select aedat
from
vbrk
into corresponding fields of table it_date
where aedat in date.
BREAK-POINT.
if it_date is initial.
refresh it_date[].
select fkdat
from vbrk
into corresponding fields of table it_date
where fkdat in date.
endif.
Regards,
Vijay
03-07-2014 9:57 AM
03-07-2014 10:00 AM
03-07-2014 10:05 AM
hi,
If the date AEDAT is blank and FKDAT which is will not have the input date means???
Rgds,
Vijay SR
03-07-2014 10:15 AM
IF AEDAT is blank in the VBRK Table, then the data should be fetched based on FKDAT.
03-07-2014 10:08 AM
Hi,
Your logic is acting as a validation on the select-option date . As per the code if the Select on the VBRK for AEDAT fails i.e when no values are found for the provided date input, then it needs to select the FKDAT from VBRK for the same date input.
1. Check whether data is maintained in VBRK for the provided date under FKDAT.
2. Check whether the input date provided is valid or in proper format.
Regards,
Mayur Priyan. S
03-07-2014 10:11 AM
03-07-2014 10:27 AM
Please let us know the remaining fields.
if VBLEN is also one field in that table, fetch the data from VBRK based on AEDAT and FKDAT into two different tables.
loop AEDAT table and check AEDAT is empty or not. if it is not empty pass AEDAT value to DATE field
else read FKDAT table based on VBELN and pass FKDAT value to DATE field.
i think it works. 🙂
03-07-2014 10:26 AM
Hi,
Try this.
If you need not have to validate, you can place the code after start of selection.
types: begin of st_date,
vbeln type vbrk-vbeln,
aedat like vbrk-aedat,
fkdat like vbrk-fkdat,
end of st_date.
select vblen aedat fkdat
from vbrk
into corresponding fields of table it_date
where aedat in date.
Then check it_date and inside loop, output the date based on the available date.
loop at it_date ....
if it_date-aedat is not initial.
move this field to output.
else.
moved it_date-fkdat to output.
endif.
03-07-2014 10:35 AM
Hi Satvik,
You can do following steps
1. Select from VBRK based on AEDAT IN date INTO ITAB1. In this query, you wont get any entries where AEDAT = space.
2. Select from VBRK based on FKDAT IN date INTO ITAB2.
3. Append ITAB1 to ITAB3.
4. Append ITAB2 to ITAB3 where AEDAT IS INITIAL.
Hope this will solve your problem.
Regards,
Peri