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

please explain me the code

Former Member
0 Likes
851

SELECT lifnr

matnr

kbetr

INTO CORRESPONDING FIELDS OF TABLE t_data

FROM zitdata

WHERE lifnr = p_lifnr.

LOOP AT t_data .

r_matnr-sign = 'I' .

r_matnr-option = 'EQ' .

r_matnr-low = t_data-matnr .

APPEND r_matnr .

ENDLOOP.

SELECT mblnr

matnr

menge

INTO TABLE data_menge

FROM mseg

FOR ALL ENTRIES IN lt_data

WHERE mblnr = lt_data-mblnr

AND matnr IN r_matnr

.

1 ACCEPTED SOLUTION
Read only

marcelo_ramos1
SAP Mentor
SAP Mentor
0 Likes
813

Hi,

All Material code selected from table zitdata is alocate in Range r_matnr. Thus, we can control value interval.

Exemple:

Select material code equal 100.

r_matnr-sign = 'I' .

r_matnr-option = 'EQ' .

r_matnr-low = 100.

Select material code betwen 200 and 300.

r_matnr-sign = 'I' .

r_matnr-option = 'BT' .

r_matnr-low = 200.

r_matnr-hight = 300.

Select material code less them 010.

r_matnr-sign = 'I' .

r_matnr-option = 'LT' .

r_matnr-low = 010.

Regards.

Marcelo Ramos

6 REPLIES 6
Read only

Former Member
0 Likes
813

Basically you are getting material document line items from MSEG for all materials that are listed for a particular vendor in your custom table ZITDATA.

Read only

Former Member
0 Likes
813

you are selecting lifnr, matnr, kbetr from the database table zitab into the internal table t_data based on the lifnr given in the selection scree.

you are intialising the values of r_matnr-sign, r_matnr, option, r_matnr-low.

then you are selecting mblnr, matnr, menge for all entries in lt_data into data_menge depending on the values of mblnr in the internal table lt_data and the values of matnr in r_matnr.

<b>if u giv the entire code explanation can be more specific.</b>

regards,

srinivas

<b>*reward for useful answers*</b>

Read only

0 Likes
813

Thanks Srinivas for ur reply , please tell me the use of ranges in this . if u want i can send u the entire code to ur mail

Read only

marcelo_ramos1
SAP Mentor
SAP Mentor
0 Likes
814

Hi,

All Material code selected from table zitdata is alocate in Range r_matnr. Thus, we can control value interval.

Exemple:

Select material code equal 100.

r_matnr-sign = 'I' .

r_matnr-option = 'EQ' .

r_matnr-low = 100.

Select material code betwen 200 and 300.

r_matnr-sign = 'I' .

r_matnr-option = 'BT' .

r_matnr-low = 200.

r_matnr-hight = 300.

Select material code less them 010.

r_matnr-sign = 'I' .

r_matnr-option = 'LT' .

r_matnr-low = 010.

Regards.

Marcelo Ramos

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
813

first the data fetch is made into an itab.

then the matnr from that itab is stored into ranges.

you can use this ranges in any select queries with in statement where ever u need to fetch data based on that matnr.

this avoids looping at t_data and passing each matnr.

in the second select it will only take the mblnr for the matnr in the ranges and the occurence of mblnr in lt_data.

this wiil improve the performance while fetching data from mseg because its a huge table.

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
813

you can declare ranges in two three ways.

ranges: r_matnr for marc-matnr,

r_dat for mkpf-budat.

r_matnr-option = 'EQ'.

r_matnr-sign = 'I'.

r_dat-option = 'BT',

r_dat-sign = 'I'.

while appending data to r_dat.u can appen it to low and high and specify "in" in select statements......it will take all the values between low and high.

earlier one is as the same...hope so u got the difference