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

Multiple records not displaying

Former Member
0 Likes
1,318

Hi Experts,

I am doing a report on material tracking and as per my requirment I am taking matnr , tarcking no

(BEDNR) and purchase requisition no: (BANFN) from eban now I want the corresponding

ebeln and po quantity from ekpo. If one matnr have multiple ebeln how do I get it?

as I am getting only single ebeln.

I have copied my coding 4 ur reference.

SELECT EBAN~MATNR EBAN~WERKS EBAN~BANFN EBAN~BNFPO  EBAN~EBELN MARA~MTART EBAN~BEDNR FROM EBAN INNER JOIN MARA ON EBAN~MATNR EQ MARA~MATNR INTO CORRESPONDING FIELDS OF TABLE IT_EBAN
 WHERE MARA~MTART IN MTART AND EBAN~MATNR IN MATNR AND EBAN~WERKS IN WERKS
 AND EBAN~BEDNR IN BEDNR.

LOOP AT IT_EBAN INTO WA_EBAN.
    MOVE-CORRESPONDING WA_EBAN TO WA_FINAL.
    APPEND WA_FINAL TO IT_FINAL.
    CLEAR: WA_EBAN.
  ENDLOOP.

IF IT_FINAL[] IS NOT INITIAL.
SELECT EBELN EBELP MATNR BUKRS WERKS BEDNR FROM EKPO INTO TABLE IT_EKPO
 FOR ALL ENTRIES IN IT_FINAL  WHERE MATNR EQ IT_FINAL-MATNR AND WERKS EQ IT_FINAL-WERKS  AND BEDNR EQ IT_FINAL-BEDNR.
 AND BEDNR EQ IT_FINAL-BEDNR.
  ENDIF.

LOOP AT IT_FINAL INTO WA_FINAL.
    READ TABLE IT_EKPO INTO WA_EKPO WITH KEY MATNR = WA_FINAL-MATNR
                                             WERKS = WA_FINAL-WERKS
                                             BEDNR = WA_FINAL-BEDNR
                                             BINARY SEARCH.
    IF SY-SUBRC = 0.
      MOVE WA_EKPO-EBELN TO WA_FINAL-EBELN.
    ENDIF.
    MODIFY IT_FINAL FROM WA_FINAL.
    CLEAR: WA_EKPO.
  ENDLOOP.

Please advice

Karthik

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,229

Hi,

SELECT EBANMATNR EBANWERKS EBANBANFN EBANBNFPO EBANEBELN MARAMTART EBANBEDNR FROM EBAN INNER JOIN MARA ON EBANMATNR EQ MARA~MATNR INTO CORRESPONDING FIELDS OF TABLE IT_EBAN

WHERE MARAMTART IN MTART AND EBANMATNR IN MATNR AND EBAN~WERKS IN WERKS

AND EBAN~BEDNR IN BEDNR.

SORT it_eban BY matnr werks bendr.

IF IT_eban[] IS NOT INITIAL.

SELECT EBELN EBELP MATNR BUKRS WERKS BEDNR FROM EKPO INTO TABLE IT_EKPO

FOR ALL ENTRIES IN IT_eban WHERE MATNR EQ IT_eban-MATNR AND WERKS EQ IT_eban-WERKS AND BEDNR EQ IT_eban-BEDNR.

AND BEDNR EQ IT_FINAL-BEDNR.

ENDIF.

SORT it_final by matnr werks bendr.

LOOP AT IT_final INTO WA_final.

READ TABLE IT_eban INTO WA_eban WITH KEY MATNR = WA_FINAL-MATNR

WERKS = WA_eban-WERKS

BEDNR = WA_eban-BEDNR

BINARY SEARCH.

IF SY-SUBRC = 0.

MOVE-corresponding WA_eban TO WA_FINAL.

ENDIF.

MODIFY IT_FINAL FROM WA_FINAL.

CLEAR: WA_EKPO.

ENDLOOP.

do like above!!

Hope it works!!

Regards,

Pavan

11 REPLIES 11
Read only

Former Member
0 Likes
1,229

You have to loop IT_EKPO table also. It is not a good practice. Use Do and End do instead of loop.

Read only

Former Member
0 Likes
1,229

Hi,

Change the code in this manner

DATA : W_TABIX TYPE I.
LOOP AT IT_FINAL INTO WA_FINAL.
  W_TABIX = 1.
  while sy-subrc = 0.
    READ TABLE IT_EKPO INTO WA_EKPO 
                           FROM W_TABIX
                           WITH KEY MATNR = WA_FINAL-MATNR
                                             WERKS = WA_FINAL-WERKS
                                             BEDNR = WA_FINAL-BEDNR
                                             BINARY SEARCH.
    IF SY-SUBRC = 0.
      W_TABIX = SY-TABIX.
      MOVE WA_EKPO-EBELN TO WA_FINAL-EBELN.
      
    MODIFY IT_FINAL FROM WA_FINAL.
    CLEAR: WA_EKPO.
    ENDIF.
  endwhile.
ENDLOOP.

Regards,

Siddarth

Read only

0 Likes
1,229

Hi Sidharth,

I tried ur logic but i am getting error message in read statement used that unable to interpret with

READ TABLE IT_EKPO INTO WA_EKPO
                             FROM W_TABIX
                             WITH KEY MATNR = WA_FINAL-MATNR
                                               WERKS = WA_FINAL-WERKS
                                               BEDNR = WA_FINAL-BEDNR
                                               BINARY SEARCH

.

Please advice

Karthik

Edited by: Karthik R on Mar 30, 2009 2:45 PM

Read only

Former Member
0 Likes
1,230

Hi,

SELECT EBANMATNR EBANWERKS EBANBANFN EBANBNFPO EBANEBELN MARAMTART EBANBEDNR FROM EBAN INNER JOIN MARA ON EBANMATNR EQ MARA~MATNR INTO CORRESPONDING FIELDS OF TABLE IT_EBAN

WHERE MARAMTART IN MTART AND EBANMATNR IN MATNR AND EBAN~WERKS IN WERKS

AND EBAN~BEDNR IN BEDNR.

SORT it_eban BY matnr werks bendr.

IF IT_eban[] IS NOT INITIAL.

SELECT EBELN EBELP MATNR BUKRS WERKS BEDNR FROM EKPO INTO TABLE IT_EKPO

FOR ALL ENTRIES IN IT_eban WHERE MATNR EQ IT_eban-MATNR AND WERKS EQ IT_eban-WERKS AND BEDNR EQ IT_eban-BEDNR.

AND BEDNR EQ IT_FINAL-BEDNR.

ENDIF.

SORT it_final by matnr werks bendr.

LOOP AT IT_final INTO WA_final.

READ TABLE IT_eban INTO WA_eban WITH KEY MATNR = WA_FINAL-MATNR

WERKS = WA_eban-WERKS

BEDNR = WA_eban-BEDNR

BINARY SEARCH.

IF SY-SUBRC = 0.

MOVE-corresponding WA_eban TO WA_FINAL.

ENDIF.

MODIFY IT_FINAL FROM WA_FINAL.

CLEAR: WA_EKPO.

ENDLOOP.

do like above!!

Hope it works!!

Regards,

Pavan

Read only

0 Likes
1,229

hI,

APOLOGIZE DID NOT CHECK THE SYNTAX....

USE THIS CODE

LOOP AT IT_FINAL INTO WA_FINAL.

LOOP AT IT_EKPO INTO WA_EKPO WHERE MATNR = WA_FINAL-MATNR
AND                                             WERKS = WA_FINAL-WERKS
       AND                                      BEDNR = WA_FINAL-BEDNR.
      W_TABIX = SY-TABIX.
      MOVE WA_EKPO-EBELN TO WA_FINAL-EBELN.
      
    MODIFY IT_FINAL FROM WA_FINAL.
    CLEAR: WA_EKPO.
ENDLOOP.
ENDLOOP.

Regards,

Siddarth

Read only

0 Likes
1,229

Hi Sidharth,

Its not working, please advice if my method is wrong as my requirement is I need to get the

tracking no:, matnr from eban and its corresponding po and po quantity from ekpo.

Thanks

Karthik.

Read only

0 Likes
1,229

Hi,

Try with this select query...

IF IT_FINAL[] IS NOT INITIAL.
SELECT EBELN EBELP MATNR BUKRS WERKS BEDNR FROM EKPO INTO TABLE IT_EKPO
FOR ALL ENTRIES IN IT_FINAL  WHERE MATNR EQ IT_FINAL-MATNR AND BEDNR EQ IT_FINAL-BEDNR.
ENDIF.

clear it_final  
then write the loop with it_ekpo and read from it_eban with the code given by me earlier with small modifications and append the records in it_final... this will contain all your records...

Regards,

Siddarth

Read only

0 Likes
1,229

Hi Sidhu,

Yeh !! its working....thanks a lot Sidharth.....

Karthik

Read only

Former Member
0 Likes
1,229

LOOP AT IT_FINAL INTO WA_FINAL.

READ TABLE IT_EKPO INTO WA_EKPO WITH KEY MATNR = WA_FINAL-MATNR

WERKS = WA_FINAL-WERKS

BEDNR = WA_FINAL-BEDNR

BINARY SEARCH.

IF SY-SUBRC = 0.

while sy-subrc eq 0.

READ TABLE IT_EKPO INTO WA_EKPO INDEX lv_index.

if sy-subrc eq 0.

MOVE WA_EKPO-EBELN TO WA_FINAL-EBELN.

MODIFY IT_FINAL FROM WA_FINAL.

CLEAR: WA_EKPO.

ENDIF.

lv_index = lv_index + 1.

READ TABLE IT_EKPO INTO WA_EKPO INDEX lv_index.

endwhile.

ENDIF.

ENDLOOP.

Read only

Former Member
0 Likes
1,229

Hello,

You need to LOOP at IT_EKPO and then READ IT_FINAL with the key MATNR, instead of looping at it_final and then reading from it_ekpo as it is EKPO which has multiple ebeln.

Then check for SY_SUBRC

Then MOVE .

And then APPEND the data to IT_FINAL.

I believe this will resolve your problem.

Regards

Richa

Read only

0 Likes
1,229

Hi,

Thank you !! my problem has been solved !!

Karthik.