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

Reading DB records

Former Member
0 Likes
583

Hello All,

I have a scenario.

I read a DB table MARA, i will get few records .

now i have to query a Z* table, based on the mara entries, what i got earlier.

but in Z* table contains the material, with two extra characters than mara-matnr.

for eg: if mara-matnr = 12345

Z*-matnr can be 1234500 or/and 12345AB like this.......

I know i can loop through mara entries and select Z* for each of mara entry using like statement.

is there any other better way.

I cant use 'for all entries' with 'like' it is giving a sytax error saying this combination cant be used.

Thanks in advance.

Best Regards

Amrender Reddy B

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
557

Hi,

First select the Material from MARA table into itab then,

Build the range..

LOOP AT ITAB.

Concatenate itab-matnr *' into l_matnr.

R_matnr-SIGn = 'I'.

R_matnr-option ='CP'.

R_matnr = l_matnr.

append r_matnr.

Clear r_matnr.

ENDLOOP.

Use the range R_MATNR on the Z* table to select the data

Hello All,

I have a scenario.

I read a DB table MARA, i will get few records .

now i have to query a Z* table, based on the mara entries, what i got earlier.

but in Z* table contains the material, with two extra characters than mara-matnr.

for eg: if mara-matnr = 12345

Z*-matnr can be 1234500 or/and 12345AB like this.......

I know i can loop through mara entries and select Z* for each of mara entry using like statement.

is there any other better way.

I cant use 'for all entries' with 'like' it is giving a sytax error saying this combination cant be used.

Thanks in advance.

Best Regards

Amrender Reddy B

3 REPLIES 3
Read only

Sandeep_Panghal
Product and Topic Expert
Product and Topic Expert
0 Likes
557

If you already know that your Z table will contain few entries , you can still live with this approach

Read only

Former Member
0 Likes
558

Hi,

First select the Material from MARA table into itab then,

Build the range..

LOOP AT ITAB.

Concatenate itab-matnr *' into l_matnr.

R_matnr-SIGn = 'I'.

R_matnr-option ='CP'.

R_matnr = l_matnr.

append r_matnr.

Clear r_matnr.

ENDLOOP.

Use the range R_MATNR on the Z* table to select the data

Read only

Former Member
0 Likes
557

Hi,

If you can apply any other conditions in Where cause other than MATNR apply that and take all entries of Z table into an internal table and after that you can put the check of mara-matnr* and delete the not required entries,this will reduce hitting DB for every LOOP pass.

Regards,

Neha