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

RE: Code is not fetching correct recors

former_member182343
Active Contributor
0 Likes
674

HI Experts,

I am into SAP BI. I have done datasource enhancement to get Delivery costs(DMBTR) from EKBZ table to EKPO table structure.

In EKPO having 3 items - data is like this -

EBELN--- EBELLP POQTY

415150901--10 --- 30

415150901---20 --- 40

415150901---30 --- 40

In EKBZ data is like this

EBELN- EBELLPGR qty--Delivery cost(DMBTR)

415150901---10 -- 40--10

415150901--10 -- 40---20

415150901---20 - 205

After writing code in CMOD - code is

WHEN '2LIS_02_ITM'.

DATA :C_T_DATA1 type table of MC02M_0ITM,

WA_MC02M_0ITM LIKE MC02M_0ITM.

LOOP AT C_T_DATA INTO WA_MC02M_0ITM.

IF WA_MC02M_0ITM-ALIEF = '0'.

DELETE C_T_DATA index sy-tabix .

ENDIF.

ENDLOOP.

c_t_data1[] = c_t_data[].

sort C_T_DATA1 by ebeln ebelp.

LOOP AT C_T_DATA1 INTO WA_MC02M_0ITM.

SELECT DMBTR FROM EKBZ INTO WA_MC02M_0ITM-ZZDMBTR

WHERE EBELN = WA_MC02M_0ITM-EBELN

AND EBELP = WA_MC02M_0ITM-EBELP

AND MENGE = WA_MC02M_0ITM-AKTWE.

MODIFY C_T_DATA1 FROM WA_MC02M_0ITM index sy-tabix transporting zzdmbtr .

endselect.

After executing code the result is not coming properly. The result is like this -

EBELN-EBELLPPO qty GR qty- Delivery cost(DMBTR)

415150901---10 -30 40--10

415150901--20 - 40-20---5

415150901---30 -- 40-20-0

I am missing one item document i.e.

415150901---10 -- 40----20

Can any one help on this issue.

Regards,

rvc

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
639

Hi RVC,

Try using

GJAHR

BELNR

BUZEI

Fields in ur selection criteria if possible. Sometimes SAP misses out the records if few fields are duplicate to avoid this we should add as many primary keys as possible in select query .

Thanks,

MN

HI Experts,

I am into SAP BI. I have done datasource enhancement to get Delivery costs(DMBTR) from EKBZ table to EKPO table structure.

In EKPO having 3 items - data is like this -

EBELN--- EBELLP POQTY

415150901--10 --- 30

415150901---20 --- 40

415150901---30 --- 40

In EKBZ data is like this

EBELN- EBELLPGR qty--Delivery cost(DMBTR)

415150901---10 -- 40--10

415150901--10 -- 40---20

415150901---20 - 205

After writing code in CMOD - code is

WHEN '2LIS_02_ITM'.

DATA :C_T_DATA1 type table of MC02M_0ITM,

WA_MC02M_0ITM LIKE MC02M_0ITM.

LOOP AT C_T_DATA INTO WA_MC02M_0ITM.

IF WA_MC02M_0ITM-ALIEF = '0'.

DELETE C_T_DATA index sy-tabix .

ENDIF.

ENDLOOP.

c_t_data1[] = c_t_data[].

sort C_T_DATA1 by ebeln ebelp.

LOOP AT C_T_DATA1 INTO WA_MC02M_0ITM.

SELECT DMBTR FROM EKBZ INTO WA_MC02M_0ITM-ZZDMBTR

WHERE EBELN = WA_MC02M_0ITM-EBELN

AND EBELP = WA_MC02M_0ITM-EBELP

AND MENGE = WA_MC02M_0ITM-AKTWE.

MODIFY C_T_DATA1 FROM WA_MC02M_0ITM index sy-tabix transporting zzdmbtr .

endselect.

After executing code the result is not coming properly. The result is like this -

EBELN-EBELLPPO qty GR qty- Delivery cost(DMBTR)

415150901---10 -30 40--10

415150901--20 - 40-20---5

415150901---30 -- 40-20-0

I am missing one item document i.e.

415150901---10 -- 40----20

Can any one help on this issue.

Regards,

rvc

3 REPLIES 3
Read only

Former Member
0 Likes
640

Hi RVC,

Try using

GJAHR

BELNR

BUZEI

Fields in ur selection criteria if possible. Sometimes SAP misses out the records if few fields are duplicate to avoid this we should add as many primary keys as possible in select query .

Thanks,

MN

Read only

0 Likes
639

MN,

I feel it is not possible, because these feilds are not keys in EKPO table.

need some other valuable inputs.

Read only

0 Likes
639

Hi RVC ,

Better u have to collect the quantity from EKBZ using EBELN & EBELP. like itab2.

Now u r having the the single record in ITAB2.

come to the previous U have internal table with the data's of EKPO. LIKE ITAB1.

now loop through the internal table ITAB1.

read itab2 with ebeln & ebelp.

if sy-subrc = 0.

itab1-quantity = itab2-quantity.

endif.

modify itab1.

endloop.

Above code is working perfect.

Regards,

S.C.K