‎2008 Feb 26 7:18 AM
Hello ,
I have the data from database tables to Internal Tables with some selection conditions..
and i processed the data to main table by using for all entries
while displaying the data i am unable to get one entire column if i give any wrong input but other colomns are ok,
what should i do to get whole data......
or
if the condition is false i should not get any data...!
SELECT MATNR WERKS FROM MARC
INTO TABLE ITAB_MARC WHERE WERKS = P_WERKS.
IF SY-SUBRC = 0.
SORT ITAB_MARC BY MATNR.
ENDIF.
SELECT MATNR BWKEY BWTAR LFGJA LFMON
LBKUM SALK3 VPRSV PEINH VERPR
STPRS BKLAS FROM MBEW
INTO CORRESPONDING FIELDS OF
TABLE ITAB_MBEWH FOR ALL ENTRIES IN ITAB_MARC
WHERE MATNR = ITAB_MARC-MATNR
AND BWTAR IN S_BWTAR
AND LFGJA IN S_LFGJA
AND LFMON IN S_LFMON.
SELECT MATNR BWKEY BWTAR LFGJA LFMON
LBKUM SALK3 VPRSV PEINH VERPR
STPRS BKLAS FROM MBEWH
APPENDING CORRESPONDING FIELDS OF TABLE ITAB_MBEWH
FOR ALL ENTRIES IN ITAB_MARC
WHERE MATNR = ITAB_MARC-MATNR
AND BWTAR IN S_BWTAR
AND LFGJA IN S_LFGJA
AND LFMON IN S_LFMON.
SELECT KTOPL KTOSL BKLAS KONTS FROM T030
INTO CORRESPONDING FIELDS OF
TABLE ITAB_T030
FOR ALL ENTRIES IN ITAB_MBEWH
WHERE BKLAS = ITAB_MBEWH-BKLAS
AND KONTS IN S_KONTS
AND KTOPL = W_KTOPL.
" AND KTOSL = 'BSX'.
SELECT MATNR MAKTX FROM MAKT INTO TABLE ITAB_MAKT
FOR ALL ENTRIES IN ITAB_MARC
WHERE MATNR = ITAB_MARC-MATNR .
ENDFORM. " GET_DATA
*&----
**& FORM PROCESS_DATA
*&----
FORM PROCESS_DATA .
LOOP AT ITAB_MBEWH.
ITAB_FINAL-MATNR = ITAB_MBEWH-MATNR.
ITAB_FINAL-BWTAR = ITAB_MBEWH-BWTAR.
ITAB_FINAL-LFGJA = ITAB_MBEWH-LFGJA.
ITAB_FINAL-LFMON = ITAB_MBEWH-LFMON.
ITAB_FINAL-LBKUM = ITAB_MBEWH-LBKUM.
ITAB_FINAL-SALK3 = ITAB_MBEWH-SALK3.
ITAB_FINAL-PRICE = ITAB_MBEWH-PRICE.
READ TABLE ITAB_MARC WITH KEY MATNR = ITAB_MBEWH-MATNR.
IF SY-SUBRC = 0.
ITAB_FINAL-WERKS = ITAB_MARC-WERKS.
READ TABLE ITAB_MAKT WITH KEY MATNR = ITAB_MARC-MATNR BINARY SEARCH.
IF SY-SUBRC = 0.
ITAB_FINAL-MAKTX = ITAB_MAKT-MAKTX.
READ TABLE ITAB_T030 WITH KEY BKLAS = ITAB_MBEWH-BKLAS
KTOPL = W_KTOPL BINARY SEARCH.
IF SY-SUBRC = 0.
ITAB_FINAL-KONTS = ITAB_T030-KONTS.
ENDIF.
ENDIF.
ENDIF.
APPEND ITAB_FINAL.
CLEAR ITAB_FINAL.
ENDLOOP.
DELETE ITAB_FINAL WHERE MATNR IS INITIAL.
SORT ITAB_FINAL BY LFGJA LFMON .
DELETE ADJACENT DUPLICATES FROM ITAB_FINAL COMPARING ALL FIELDS .
here the problem is I am not getting the data for T030 table for whole entire column...if its wrong it should not come.
if i give the proper condition its working fine....
‎2008 Feb 26 7:28 AM
Hi Aeda,
One very important rule of using BINARY SEARCH in readnig internal tables is you MUST SORT the internal table using the fields used in the WITH KEY clause in the READ on the internal table.
This might be interfering with the same.
Please SORT and check.
Cheers.