‎2009 May 13 7:04 AM
Hi,
select ekko~ebeln ekko~bedat ekpo~ebelp ekpo~matnr ekpo~werks
ekpo~netpr from ekko inner join ekpo
on ekko~ebeln = ekpo~ebeln into
corresponding fields of table it_ekko
where matnr in s_matnr and werks in s_werks
and bedat in s_bedat.
l_low_mon = s_bedat-low+04(02).
l_high_mon = s_bedat-high+04(02).
l_low_yr = s_bedat-low+00(04).
l_high_yr = s_bedat-high+00(04).if l_low_mon = '01'.
move '10' to l_low_mon.
l_low_yr = l_low_yr - 1.
endif.
if l_low_mon = '02'.
move '11' to l_low_mon.
l_low_yr = l_low_yr - 1.
endif.
if l_low_mon = '03'.
move '12' to l_low_mon.
l_low_yr = l_low_yr - 1.
endif.if l_low_mon = '04'.
move '01' to l_low_mon.
l_low_yr = l_low_yr.
endif.Similarly I am moving '02' for the month of May.Like that every month it has to be incremented.
For l_low_month ( 04 to 12 ) ie,from Apr to Dec l_low_yr is same.But for ( 01 to 03 ) ie, Jan to Mar
l_low_year = l_low_yr - 1.( because of Fiscal yr)
Condition is similar for l_high_mon and l_high_yr.
Now I need l_low_mon and l_high_mon has to be appended in a single field
and l_low_yr and l_high_yr in a single field.
select * from mbewh into corresponding fields of table it_mbewh
for all entries in it_ekko where matnr = it_ekko-matnr
and bwkey = it_ekko-werks and
lfmon = ?
and lfgja = ?.Because in lfmon I have two fields (l_low_mon,l_high_mon) and lfgja also (l_low_yr,l_high_yr)
For fetching these two variables has to be appended in on variable
Suggest some ideas.
Regards,
Bathri.
Edited by: Bathrinath Sankaranarayanan on May 13, 2009 8:05 AM
Edited by: Bathrinath Sankaranarayanan on May 13, 2009 8:07 AM
Edited by: Bathrinath Sankaranarayanan on May 13, 2009 8:07 AM
Edited by: Bathrinath Sankaranarayanan on May 13, 2009 8:08 AM
Edited by: Bathrinath Sankaranarayanan on May 13, 2009 8:12 AM
‎2009 May 13 7:13 AM
Hi,
The best solution that I can see here is to have 2 internal tables for both month and year and use this code for the retrieval.
select * from mbewh into corresponding fields of table it_mbewh
for all entries in it_ekko where matnr = it_ekko-matnr
and bwkey = it_ekko-werks
and ( lfmon IN it_mon1
and lfgja IN it_year1 )
OR ( lfmon IN it_mon2
AND lfgja IN it_year2 ).
Here, it_mon1 contains the months for current year -1 and it_year1 contains current year -1 while it_mon2 contains the months for the current year and it_year2 contain the current year.
regards,
Peter
‎2009 May 13 7:13 AM
Hi,
Use CONCATENATE command to combine two fields and store value in single field.
Syntax: CONCATENATE str1 str2 into str3.
by
Prasad gvk.
‎2009 May 13 7:14 AM
hi,
u can simply do like this
data : l_mon(4) type char.
concatenate l_low_mon l_high_mon into l_mon .
same for yr also.
‎2009 May 13 7:17 AM
Hello,
concatenate l_low_mon and l_high_mon into a range l_month.
similarly concatenate l_low_yr and l_high_yr into another range l_year.
Pass these ranges l_month and l_year to lfmon and lfgja of table mbewh.
Hope this helps.
Thanks,
Sowmya Arni
‎2009 May 13 7:33 AM
Hi Bathrinath,
1.Define Range table like below for lfmon
2. Append your l_low_mon and l_high_mon to range table r_lfmon
TABLES:mbewh.
RANGES:r_lfmon FOR mbewh-lfmon.
3. Now put that range table in where condition. Do same way for lfgja as well.
r_lfmon-low = l_low_mon.
r_lfmon-high = space.
r_lfmon-sign = 'I'.
r_lfmon-option = 'EQ'.
APPEND r_lfmon.
CLEAR r_lfmon.
r_lfmon-low = l_high_mon.
r_lfmon-high = space.
r_lfmon-sign = 'I'.
r_lfmon-option = 'EQ'.
APPEND r_lfmon.
CLEAR r_lfmon.
I hope that it solves your problem.
Thanks
Venkat.O
select * from mbewh into corresponding fields of table it_mbewh
for all entries in it_ekko where matnr = it_ekko-matnr
and bwkey = it_ekko-werks and
lfmon in r_lfmon
and lfgja in r_lfgja.
‎2009 May 13 7:35 AM
Hi Bathrinath,
I am not clear with your requirement, if you want the data from MBEWH betw your high and low date then in where clause you can go for :
WHERE lfmon BETWEEN l_low_mon and l_high_mon
AND lfgja BETWEEN l_low_yr and l_high_yr.With luck,
Pritam.