Application Development 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: 

All entries and read statement not working

Former Member
0 Kudos

Hi Experts,

I am doing a report on material history,

First I get the entire matnr from mara then I go to eket and mard to take some details and then to ekpo to take open Po's (ebeln) for the particular matnr .....

I am displaying my o/p like : for a single matnr there will be many ebeln.

But I am facing problem in displaying eban~banfn for the particular matnr ...can any one

please advice me how to display it such that other details which I have already displayed should not get affected.

I tried ALL ENTRIES FROM EBAN connecting only MATNR and WERKS then used READ its just reading the first record.

Please advice if there is any other logic.

Thanks

Karthik

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Kartik,

Plz try as given below;

LOOP AT IT_FIRST.

LOOP AT IT_EBAN WHERE MATNR = IT_FIRST-MATNR

AND WERKS = IT_FIRST-WERKS.

my_tabix = sy-tabix.

MOVE IT_EBAN-BANFN TO IT_FIRST-BANFN.

MODIFY IT_FIRST INDEX my_tabix TRANSPORTING banfn.

clear : IT_EBAN, my_tabix.

ENDLOOP.

clear IT_FIRST.

ENDLOOP.

15 REPLIES 15

Sandeep_Kumar
Product and Topic Expert
Product and Topic Expert
0 Kudos

Can you paste the selection logic here so that it gives a better idea what issue you are facing?

0 Kudos

Here,

SELECT MARA~MATNR MARA~MTART MARD~WERKS MARD~LABST MARD~INSME MARD~SPEME    FROM MARA INNER JOIN MARD ON MARA~MATNR EQ MARD~MATNR
  INTO CORRESPONDING FIELDS OF TABLE IT_MARA 
 WHERE MARA~MATNR IN MATNR   
AND MARD~WERKS IN   WERKS                                                                                
.
  LOOP AT IT_MARA.
    MOVE IT_MARA-MATNR TO IT_TAB-MATNR.
    MOVE IT_MARA-WERKS TO IT_TAB-WERKS.
    MOVE IT_MARA-LABST TO IT_TAB-LABST.
    MOVE IT_MARA-INSME TO IT_TAB-INSME.
    MOVE IT_MARA-SPEME TO IT_TAB-SPEME.
    COLLECT IT_TAB.
  ENDLOOP.

IF NOT IT_TAB IS INITIAL.
    SELECT * FROM EKPO INTO CORRESPONDING FIELDS OF TABLE IT_EKPO
       FOR ALL ENTRIES IN IT_TAB WHERE MATNR EQ IT_TAB-MATNR
       AND WERKS EQ IT_TAB-WERKS AND PSTYP EQ '0' AND BSTYP EQ 'F'
       AND ELIKZ EQ ' '.
  ENDIF.

LOOP AT IT_TAB.
    MOVE-CORRESPONDING IT_TAB TO IT_FIRST.
    LOOP AT IT_EKPO WHERE MATNR EQ IT_TAB-MATNR
                      AND WERKS EQ IT_TAB-WERKS.
      MOVE IT_EKPO-EBELN TO IT_FIRST-EBELN.
      MOVE IT_EKPO-EBELP TO IT_FIRST-EBELP.
      APPEND IT_FIRST.
      CLEAR IT_FIRST."-LABST.
    ENDLOOP.
  ENDLOOP.

And now I am facing problem in the below querry

SELECT * FROM EBAN INTO CORRESPONDING FIELDS OF TABLE IT_EBAN FOR ALL
  ENTRIES IN IT_FIRST WHERE MATNR = IT_FIRST-MATNR
  AND WERKS = IT_FIRST-WERKS AND STATU IN ('N','A').

LOOP AT IT_FIRST.
    READ TABLE IT_EBAN WITH KEY MATNR = IT_FIRST-MATNR
                                WERKS = IT_FIRST-WERKS.
    MOVE IT_EBAN-BANFN TO IT_FIRST-BANFN.
    MODIFY IT_FIRST.
*    CLEAR IT_EBAN.
  ENDLOOP.

Please advice

Karthik

Former Member
0 Kudos

Hi, U can try this...

SELECT MATNR

MTART

.....

from MARA

into table T_MATNRwhere matnr eq T_MATNR-MATNR.

then

SELECT MATNR

MTART

.....

from MARA

appending table T_MATNR

for all entries in T_MATNR

where matnr eq T_MATNR-MATNR.

In this way u can do.

Former Member
0 Kudos

Hi,

Don't do this :

READ TABLE IT_EBAN WITH KEY MATNR = IT_FIRST-MATNR

WERKS = IT_FIRST-WERKS.

MOVE IT_EBAN-BANFN TO IT_FIRST-BANFN.

MODIFY IT_FIRST.

  • CLEAR IT_EBAN.

But this instead :

LOOP AT IT_EBAN WHERE MATNR = IT_FIRST-MATNR

AND WERKS = IT_FIRST-WERKS.

MOVE IT_EBAN-BANFN TO IT_FIRST-BANFN.

MODIFY IT_FIRST.

  • CLEAR IT_EBAN.

ENDLOOP

Edited by: Issa SY on Apr 15, 2009 9:56 AM

0 Kudos

Hi Issa,

Its not working !!

Please advice

Karthik

0 Kudos

Sorry,

If you want to gets all items of IT_EBAN you should also change your MODIFY statement into APPEND In the second loop after the first line-item. Try this.

LOOP AT IT_FIRST.

LOOP AT IT_EBAN WHERE MATNR = IT_FIRST-MATNR

AND WERKS = IT_FIRST-WERKS.

MOVE IT_EBAN-BANFN TO IT_FIRST-BANFN.

IF sy-tabix = 1.

MODIFY It_FIRST.

ELSE.

APPEND IT_FIRST.

ENDIF.

  • CLEAR IT_EBAN.

ENDLOOP

ENDLOOP.

The result should be the same as a LEFT OUTER JOIN.

Issa

Edited by: Issa SY on Apr 15, 2009 11:16 AM

0 Kudos

Hi Issa,

I am getting short dump 4 ur logic ..

Please advice

Karthik

0 Kudos

hi Karthik,



before using the for all entries,

sort the above internal table with Matnr and werks..
and delete the repeated matnr and werks combination or push into another internal table ir create range for matnr and werks.

it will work..

because if matnr and werks combination repeats it will skip not only duplicates it will delete the orginal also.



Regards,

Prabhuads

0 Kudos

It may be an idex problem.

Try this.

LOOP AT IT_FIRST.

w_tabix = sy-tabix.

LOOP AT IT_EBAN WHERE MATNR = IT_FIRST-MATNR

AND WERKS = IT_FIRST-WERKS.

MOVE IT_EBAN-BANFN TO IT_FIRST-BANFN.

IF sy-tabix = 1.

MODIFY It_FIRST INDEX w_tabix.

ELSE.

APPEND IT_FIRST.

ENDIF.

  • CLEAR IT_EBAN.

ENDLOOP

ENDLOOP.

Issa

Former Member
0 Kudos

Hi Kartik,

Plz try as given below;

LOOP AT IT_FIRST.

LOOP AT IT_EBAN WHERE MATNR = IT_FIRST-MATNR

AND WERKS = IT_FIRST-WERKS.

my_tabix = sy-tabix.

MOVE IT_EBAN-BANFN TO IT_FIRST-BANFN.

MODIFY IT_FIRST INDEX my_tabix TRANSPORTING banfn.

clear : IT_EBAN, my_tabix.

ENDLOOP.

clear IT_FIRST.

ENDLOOP.

0 Kudos

Hi Arnab,

Thank you , ur logic is working ..but now I am facing another problem..as eban~banfn is getting messed up ( not displaying to the correct werks wise matnr).

For Eg-.

Now my O/P is...

material no: Purchase order Plant PR no: (eban~banfn)

raw mat1 4500047821 Unit1 10015436

raw mat1 4500008143 Unit1 10000848

raw mat1 4500019180 Unit1 10001795

raw mat1 4500021372 Unit1 10003959

raw mat1 4500040300 Unit2

raw mat1 4500005484 Unit2

But I want my O/P to be

material no: Purchase order Plant PR no: (eban~banfn)

raw mat1 4500047821 Unit1 10015436

raw mat1 4500008143 Unit1 10000848

raw mat1 4500019180 Unit1

raw mat1 4500021372 Unit1

raw mat1 4500040300 Unit2 10001795

raw mat1 4500005484 Unit2 10003959

Please advice

Karthik

Edited by: Karthik R on Apr 15, 2009 4:29 PM

Edited by: Karthik R on Apr 15, 2009 4:30 PM

0 Kudos

The problem is modifying it_first with the index of second loop !!!!!!!!!!!!!!!!!!!!!

0 Kudos

Hi Srinivas,

I have posted another question regadarding this subjected: Problem with interactive.

Please have a look on it and advice me.

Thanks

Karthik

0 Kudos

Hi Karthik,

Sorry for the dump, this may work better.

Define IT_FINAL like IT_FIRST.

LOOP AT IT_FIRST.

LOOP AT IT_EBAN WHERE MATNR = IT_FIRST-MATNR

AND WERKS = IT_FIRST-WERKS.

MOVE IT_EBAN-BANFN TO IT_FIRST-BANFN.

APPEND IT_FIRST TO IT_FINAL.

  • CLEAR IT_EBAN.

ENDLOOP.

IF SY-SUBRC NE 0.

APPEND IT_FIRST TO IT_FINAL.

ENDIF.

ENDLOOP.

Then use IT_FINAL instead of IT_FIRST.

Issa

kesavadas_thekkillath
Active Contributor
0 Kudos

first check the relation of records for both itabs ex: 1 to many , many to 1 etc .

Place some data of both itabs.