‎2007 Nov 14 9:48 AM
hi,
I have to select data from tables bkpf , bkdf , bseg and anla and club them into a final internal table and the selection criteria is
1) company code - select-option - Mandatory .
2) cost center -select-option - if not entered should work for all cost
centers ( taken from csks table)
3) vendor number - select-option - if not entered should work for all vendors
( taken from lfa1 table)
Kindly suggest how should i select data.
‎2007 Nov 14 9:52 AM
Hi,
Select data bkpf then using FOR ALL ENTRIES slect data from remaing tables based on selection screen then using read statement collect all data into one internal table and display it.
Regards,
Prashant
‎2007 Nov 14 9:54 AM
‎2007 Nov 16 8:55 AM
hi riches,
I wrote select query using for all entries.See if it is usful.
i have declared one inetrnal table ,wa and temp table for all given tables and also one final table.
SELECT BUKRS
BELNR
GJAHR
BLART
FROM BKPF
INTO TABLE I_BKPF
WHERE BUKRS IN S_BUKRS
AND BELNR IN S_BELNR.
IF SY-SUBRC EQ 0.
SORT I_BKPF BY BELNR.
ENDIF.
IF NOT I_BKPF[] IS INITIAL.
TEMP_BKPF[] = I_BKPF[].
DELETE ADJACENT DUPLICATES FROM TEMP_BKPF[].
ENDIF.
SELECT BUKRS
BELNR
GJAHR
FROM BKDF
INTO TABLE I_BKDF
FOR ALL ENTRIES IN TEMP_BKPF
WHERE BELNR = TEMP_BKPF-BELNR
AND BUKRS = TEMP_BKPF-BUKRS.
IF SY-SUBRC EQ 0.
SORT I_BKDF BY BELNR.
ENDIF.
IF NOT I_BKDF[] IS INITIAL.
TEMP_BKDF[] = I_BKDF[].
DELETE ADJACENT DUPLICATES FROM TEMP_BKDF[].
ENDIF.
SELECT BUKRS
BELNR
GJAHR
BUZEI
KOART
AUGDT
FROM BSEG
INTO TABLE I_BSEG
FOR ALL ENTRIES IN TEMP_BKDF
WHERE BUKRS = TEMP_BKDF-BUKRS.
IF SY-SUBRC EQ 0.
SORT I_BSEG BY BELNR.
ENDIF.
IF NOT I_BSEG[] IS INITIAL.
TEMP_BSEG[] = I_BSEG[].
DELETE ADJACENT DUPLICATES FROM TEMP_BSEG[].
ENDIF.
SELECT BUKRS
ANLN1
ANLN2
FROM ANLA
INTO TABLE I_ANLA
FOR ALL ENTRIES IN TEMP_BSEG
WHERE BUKRS = TEMP_BSEG-BUKRS.
IF SY-SUBRC = 0.
IF NOT I_ANLA[] IS INITIAL.
TEMP_ANLA[] = I_ANLA[].
DELETE ADJACENT DUPLICATES FROM TEMP_ANLA[].
ENDIF.
ENDIF.
after that we need to start process.
Reward if it usful.
Thanks ,
Srikanth.
‎2007 Nov 19 9:39 AM