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

append two variables in single variable

Former Member
0 Likes
803

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

6 REPLIES 6
Read only

peter_ruiz2
Active Contributor
0 Likes
771

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

Read only

Former Member
0 Likes
771

Hi,

Use CONCATENATE command to combine two fields and store value in single field.

Syntax: CONCATENATE str1 str2 into str3.

by

Prasad gvk.

Read only

Former Member
0 Likes
771

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.

Read only

Former Member
0 Likes
771

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

Read only

venkat_o
Active Contributor
0 Likes
771

Hi Bathrinath, 1.Define Range table like below for lfmon


TABLES:mbewh.
RANGES:r_lfmon FOR mbewh-lfmon.
2. Append your l_low_mon and l_high_mon to range table r_lfmon

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.
3. Now put that range table in where condition. Do same way for lfgja as well.

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.
I hope that it solves your problem. Thanks Venkat.O

Read only

Former Member
0 Likes
771

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.