Application Development and Automation 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: 
Read only

Logic on date

Former Member
0 Likes
942

I have my internal table structure as below -

From Date | To Date | Margin

________________________

20180725 |20181116 | 2.50

20181117 |99991231 | 3.00

Based on PO creation date it should pick the margin value.

For example my PO creation date is 20180726. It should pick 2.50 as margin.

I have the code as below. But its picking 3.00 as margin. Please help.

 DATA(zyear)  = i_ekko-aedat+0(4).
 DATA(zmonth) = i_ekko-aedat+4(2).
 DATA(zdate)  = i_ekko-aedat+6(2).
 CONCATENATE zyear zmonth zdate INTO lv_podate.
 SELECT SINGLE zmargin
       FROM zsa_po_margin
       INTO @DATA(lv_po_margin)
       WHERE  zfrom_date >= @lv_podate AND
              zto_date   <= @lv_podate .
<br>
2 REPLIES 2
Read only

RaymondGiuseppi
Active Contributor
811

Your code look for a record where from date is greater than a date and to date lower, some kind of reversed logic or a typo?

Read only

DoanManhQuynh
Active Contributor
811

lv_podate much be between zfrom_date and zto_date but your sql conditions is not correct. and why you have to concatenate the date, just lets it asis.

 SELECT SINGLE zmargin
 FROM zsa_po_margin
 INTO @DATA(lv_po_margin)
 WHERE zfrom_date <= @i_ekko-aedat AND
         zto_date >= @i_ekko-aedat .