Help required on 'FOR ALL ENTRIES IN'
I am using this query:
SELECT vguid qausp
INTO TABLE tb_qualif
FROM vlcadddata
FOR ALL ENTRIES IN tb_distmode1
WHERE vguid = tb_distmode1-vguid
AND aqual = 'ASPT'.
Now if the internal table contains no data tb_distmode1 then the query is giving wrong result. In fact it is ignoring the part 'FOR ALL ENTRIES IN tb_distmode1'.
Ideally my requirement is not to fetch any data if the table is empty. So can anyone suggest any suitable way so that I can get the desired result without using IF...ENDIF.
This is because when the table which is used in for all entries is empty, all the database records are selected.
Solution :
Before the select query check if the table tb_distmode1 has any entries . Only then make the select query to execute.
describe table tb_distmode1 lines sy-tfill.
if sy-tfill GE 1.
SELECT vguid qausp
INTO TABLE tb_qualif
FROM vlcadddata
FOR ALL ENTRIES IN tb_distmode1
WHERE vguid = tb_distmode1-vguid
AND aqual = 'ASPT'.
endif.
I dont think there is any other way to achive your requirement.
regards,
Advait.
Edited by: Advait Gode on Oct 8, 2008 3:17 PM
Similar Messages
-
Plz help me out with for all entries
hi to all experts,
This is my sample code plz tell me how to output the data.plz help me out.im very much beginner in ABAP and i dont want to use loop and endloop is there any way
REPORT Z_FORALLENTERIES .
types : begin of ty_lfa1,
lifnr type lfa1-lifnr,
name1 type lfa1-name1,
land1 type lfa1-land1,
end of ty_lfa1.
types : begin of ty_lfb1 ,
lifnr type lfb1-lifnr,
bukrs type lfb1-bukrs,
pernr type lfb1-pernr,
end of ty_lfb1.
types : begin of ty_lfc1 ,
lifnr type lfc1-lifnr,
gjahr type lfc1-gjahr,
usnam type lfc1-usnam,
end of ty_lfc1.
types : begin of ty_lfbk ,
lifnr type lfbk-lifnr,
banks type lfbk-banks,
bankl type lfbk-bankl,
bankn type lfbk-bankn,
end of ty_lfbk.
types : begin of ty_final,
lifnr type lfa1-lifnr,
name1 type lfa1-name1,
land1 type lfa1-land1,
bukrs type lfb1-bukrs,
pernr type lfb1-pernr,
gjahr type lfc1-gjahr,
usnam type lfc1-usnam,
banks type lfbk-banks,
bankl type lfbk-bankl,
bankn type lfbk-bankn,
end of ty_final.
data : it_lfa1 type standard table of ty_lfa1 initial size 0 with header line.
data : it_lfb1 type standard table of ty_lfb1 initial size 0 with header line.
data : it_lfc1 type standard table of ty_lfc1 initial size 0 with header line.
*--internal for outputting data--
data : it_lfbk type standard table of ty_lfbk initial size 0 with header line.
data : it_final type standard table of ty_final initial size 0,
wa_final like line of it_final.
select lifnr name1 land1
into table it_lfa1[]
from lfa1 up to 10 rows.
if it_lfa1[] is not initial.
select lifnr bukrs pernr
into table it_lfb1[]
from lfb1
for all entries in it_lfa1[]
where lifnr eq it_lfa1-lifnr.
endif.
if it_lfb1[] is not initial.
select lifnr gjahr usnam
into table it_lfc1[]
from lfc1
for all entries in it_lfb1[]
where lifnr eq it_lfb1-lifnr.
endif.
if it_lfc1[] is not initial.
select lifnr banks bankl bankn
into table it_lfbk[]
from lfbk
for all entries in it_lfc1[]
where lifnr eq it_lfc1-lifnr.
endif.Hi
see this program almost same req
**************DATA TYPES DECLARATION **********************
TABLES: HRP1001, HRP1026, HRP1000,PCHDY.
TYPE-POOLS SLIS.
TYPES :BEGIN OF ST_OUTPUT,
COUNT TYPE STRING,
OBJID TYPE HRP1001-OBJID,
STEXT TYPE HRP1000-STEXT,
BEGDA TYPE HRP1000-BEGDA,
ENDDA TYPE HRP1000-ENDDA,
CANCRT TYPE T77CRT-CANCRT,
AEDTM TYPE HRP1026-AEDTM,
UNAME TYPE HRP1026-UNAME,
LSTEXT TYPE HRP1000-STEXT,
RINVT TYPE T777V-RINVT,
END OF ST_OUTPUT.
TYPES: BEGIN OF ST_HRP1000,
OBJID TYPE HRP1001-OBJID,
STEXT TYPE HRP1000-STEXT,
END OF ST_HRP1000.
TYPES : BEGIN OF ST_HRP1001,
OTYPE TYPE HRP1001-OTYPE,
OBJID TYPE HRP1001-OBJID,
RELAT type hrp1001-RELAT,
BEGDA TYPE HRP1001-BEGDA,
ENDDA TYPE HRP1001-ENDDA,
SCLAS TYPE HRP1001-SCLAS,
SOBID TYPE HRP1001-SOBID,
END OF ST_HRP1001.
TYPES : BEGIN OF ST_HRP1026,
OTYPE TYPE HRP1026-OTYPE,
OBJID TYPE HRP1001-OBJID,
AEDTM TYPE HRP1026-AEDTM,
UNAME TYPE HRP1026-UNAME,
DELET TYPE HRP1026-DELET,
CANCR TYPE HRP1026-CANCR,
END OF ST_HRP1026.
TYPES : BEGIN OF ST_REASON,
CANCR TYPE HRP1026-CANCR,
CANCRT TYPE T77CRT-CANCRT,
END OF ST_REASON.
TYPES : BEGIN OF ST_SOBID,
OTYPE TYPE HRP1001-OTYPE,
OBJID TYPE HRP1001-OBJID,
RELAT type hrp1001-OBJID,
BEGDA TYPE HRP1001-BEGDA,
ENDDA TYPE HRP1001-ENDDA,
SCLAS TYPE HRP1001-SCLAS,
SOBID TYPE HRP1001-OBJID,
END OF ST_SOBID.
TYPES : BEGIN OF ST_OBJID,
OBJID TYPE HRP1001-OBJID,
END OF ST_OBJID.
TYPES : BEGIN OF ST_LOCATION,
OTYPE TYPE HRP1001-OTYPE,
OBJID TYPE HRP1001-OBJID,
RSIGN TYPE HRP1001-RSIGN,
RELAT TYPE HRP1001-RELAT,
SCLAS TYPE HRP1001-SCLAS,
SOBID TYPE HRP1001-SOBID,
END OF ST_LOCATION.
TYPES : BEGIN OF ST_LOCATION1,
OTYPE TYPE HRP1001-OTYPE,
OBJID TYPE HRP1001-OBJID,
RSIGN TYPE HRP1001-RSIGN,
RELAT TYPE HRP1001-RELAT,
SCLAS TYPE HRP1001-SCLAS,
SOBID TYPE HRP1001-OBJID,
END OF ST_LOCATION1.
TYPES : BEGIN OF ST_LSTEXT,
OTYPE TYPE HRP1000-OTYPE,
OBJID TYPE HRP1000-OBJID,
LSTEXT TYPE HRP1000-STEXT,
END OF ST_LSTEXT.
TYPES : BEGIN OF ST_OBJID_SH,
OTYPE TYPE HRP1000-OTYPE,
OBJID TYPE HRP1000-OBJID,
END OF ST_OBJID_SH.
DATA : IT_OBJID_SH TYPE STANDARD TABLE OF ST_OBJID_SH.
DATA : WA_OBJID_SH TYPE ST_OBJID_SH.
DATA : IT_LSTEXT TYPE STANDARD TABLE OF ST_LSTEXT. "TOS STORE THE TEXT OF COURCE LOCATION
DATA : WA_LSTEXT TYPE ST_LSTEXT.
DATA : IT_LOCATION TYPE STANDARD TABLE OF ST_LOCATION. " TO STORE THE LOCATION OF COURCE
DATA : WA_LOCATION TYPE ST_LOCATION.
DATA : IT_LOCATION1 TYPE STANDARD TABLE OF ST_LOCATION1. " TO CONVERT SOBID INTO OBJID FOR COURCE LOCATION
DATA : WA_LOCATION1 TYPE ST_LOCATION1.
DATA : IT_SOBID TYPE STANDARD TABLE OF ST_SOBID. " TO CHANGE THE SOBID OF HRP1001 TO OBJID OF HRP1026
DATA : WA_SOBID TYPE ST_SOBID. " BY USING FOR ALL ENTRIES
DATA : IT_REASON TYPE STANDARD TABLE OF ST_REASON. "TO STORE T HE REASON FOR CANCELL TEXT
DATA : WA_REASON TYPE ST_REASON.
DATA : IT_OUTPUT TYPE STANDARD TABLE OF ST_OUTPUT. "OUTPUT FEILDS OF REPORT.
DATA : WA_OUTPUT TYPE ST_OUTPUT.
DATA : IT_OUTPUT_1 TYPE STANDARD TABLE OF ST_OUTPUT. " TEMP OUTPUT FEILDS OF REPORT.
DATA : WA_OUTPUT_1 TYPE ST_OUTPUT.
DATA : IT_HRP1000 TYPE STANDARD TABLE OF ST_HRP1000. "DATA FROM HRP1000 TABLE
DATA : WA_HRP1000 TYPE ST_HRP1000.
DATA : IT_HRP1001 TYPE STANDARD TABLE OF ST_HRP1001. "DATA FROM HRP1001 TABLE
DATA : WA_HRP1001 TYPE ST_HRP1001.
DATA : IT_HRP1026 TYPE STANDARD TABLE OF ST_HRP1026. "DATA FROM HRP1026 TABLE
DATA : WA_HRP1026 TYPE ST_HRP1026.
DATA : IT_OBJID TYPE STANDARD TABLE OF ST_OBJID. " TO STORE THE OBJID OF HRP1001
DATA : WA_OBJID TYPE ST_OBJID.
DATA: WS_FCAT TYPE SLIS_FIELDCAT_ALV . " FEILDCATALOG FOR ALV REPORT
DATA: IN_FCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA: W_LAYOUT TYPE SLIS_LAYOUT_ALV.
DATA : LV_COUNT TYPE I. "FEILD FOR SERIAL NUMBER
***************************END OF DATA DECLARATION******************************************
***********SELECTION SCREEN DESIGN***********************
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
*SELECT-OPTIONS : S_OTYPE FOR HRP1001-OTYPE NO INTERVALS .
SELECT-OPTIONS : S_OBJID FOR HRP1001-OBJID NO INTERVALS .
SELECT-OPTIONS : DATE FOR SY-DATUM NO-EXTENSION OBLIGATORY.
SELECTION-SCREEN END OF BLOCK B1.
**********END OF SELECTION SCREEN DESIGN*****************
*****INITIALIZATION VENT TO ASIGN DEFAULT VALUES TO OTYPE
*INITIALIZATION.
S_OTYPE-LOW = 'D'.
S_OTYPE-SIGN = 'I'.
S_OTYPE-OPTION = 'EQ'.
APPEND S_OTYPE.
CLEAR S_OTYPE.
*************END OF EVENT INITIALIZATION*****************
*********VALIDATION FOR SCREEN FIELDS********************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_OBJID-LOW.
IF S_OBJID IS NOT INITIAL.
SELECT OTYPE OBJID FROM HRP1000
INTO TABLE IT_OBJID_SH
WHERE OTYPE = 'D'.
IF SY-SUBRC EQ 0.
SEARCH HELP FOR QUALIFICATION.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
DDIC_STRUCTURE = ' '
RETFIELD = 'OBJID'
PVALKEY = ' '
DYNPPROG = SY-REPID
DYNPNR = SY-DYNNR
DYNPROFIELD = 'S_OBJID'
STEPL = 0
WINDOW_TITLE =
VALUE = ' '
VALUE_ORG = 'S'
MULTIPLE_CHOICE = ' '
DISPLAY = ' '
CALLBACK_PROGRAM = ' '
CALLBACK_FORM = ' '
MARK_TAB =
IMPORTING
USER_RESET =
TABLES
VALUE_TAB = IT_OBJID_SH
FIELD_TAB =
RETURN_TAB = RETURN_TAB
DYNPFLD_MAPPING =
EXCEPTIONS
PARAMETER_ERROR = 1
NO_VALUES_FOUND = 2
OTHERS = 3
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
IF SY-SUBRC NE 0.
MESSAGE 'NO RECORD FOUND FOR THE GIVEN SELECTION CRITERIA.' TYPE 'E'.
ENDIF.
ENDIF.
REFRESH IT_OBJID.
***************VALIDATION OF SCREEN FIELDS ENDS***********
*****************START OF SELECTION ************************
START-OF-SELECTION.
SELECT OTYPE
OBJID
RELAT
BEGDA
ENDDA
SCLAS
SOBID FROM HRP1001 INTO TABLE IT_HRP1001
WHERE OTYPE = 'D'
AND OBJID IN S_OBJID
AND BEGDA GE DATE-LOW
AND ENDDA LE DATE-HIGH
AND ( SCLAS = 'E' OR SCLAS = 'ET' ).
IF SY-SUBRC NE 0.
MESSAGE 'NO RECORD FOUND FOR THE GIVEN SELECTION CRITERIA ' TYPE 'E'.
ENDIF.
LOOP AT IT_HRP1001 INTO WA_HRP1001.
WA_SOBID-OTYPE = WA_HRP1001-OTYPE.
WA_SOBID-OBJID = WA_HRP1001-OBJID.
WA_SOBID-RELAT = WA_HRP1001-RELAT.
WA_SOBID-BEGDA = WA_HRP1001-BEGDA.
WA_SOBID-ENDDA = WA_HRP1001-ENDDA.
WA_SOBID-SCLAS = WA_HRP1001-SCLAS.
WA_SOBID-SOBID = WA_HRP1001-SOBID.
APPEND WA_SOBID TO IT_SOBID.
ENDLOOP.
SELECT OTYPE
OBJID
AEDTM
UNAME
DELET
CANCR
NCONT
FROM HRP1026
INTO TABLE IT_HRP1026
FOR ALL ENTRIES IN IT_SOBID
WHERE OBJID = IT_SOBID-SOBID
AND ( OTYPE = 'E' OR OTYPE = 'ET' )
AND DELET = 'X' AND
BEGDA GE DATE-LOW AND
ENDDA LE DATE-HIGH.
IF SY-SUBRC EQ 0.
SELECT OBJID
STEXT
FROM HRP1000
INTO TABLE IT_HRP1000
FOR ALL ENTRIES IN IT_SOBID
WHERE OBJID = IT_SOBID-SOBID AND
BEGDA GE DATE-LOW AND
ENDDA LE DATE-HIGH.
SELECT CANCR
CANCRT
FROM T77CRT
INTO TABLE IT_REASON
FOR ALL ENTRIES IN IT_HRP1026
WHERE CANCR = IT_HRP1026-CANCR
AND LANGU = 'E' .
********PERFORM FOR GETTING T HE LOCATION OF THE COURCE**
PERFORM GET_LOCATION.
**************END OF LOCATION OF COURCE ******************
ELSE.
MESSAGE 'NO RECORD FOUND FOR THE GIVEN SELECTION CRITERIA ' TYPE 'E'.
ENDIF.
*****PERFORM FOR GETTING DATA INTO THE FINAL INTERNAL TABLE IT_OUTPUT**
PERFORM GET_DATA.
*********************************END OF PERFORM ET DATA ***************
***********LOGIC FOR PRONTING NUMBER OF RECORDS ***********************
LV_COUNT = 0.
LOOP AT IT_OUTPUT INTO WA_OUTPUT.
LV_COUNT = LV_COUNT + 1.
WA_OUTPUT-COUNT = LV_COUNT.
APPEND WA_OUTPUT TO IT_OUTPUT_1.
ENDLOOP.
REFRESH IT_OUTPUT.
IT_OUTPUT = IT_OUTPUT_1.
********************END OF LOGIC FOR NUMBER OF RECORDS ***************
****************DISPLAYING OUTPUT BY USEING GRID DISPLAY**********
PERFORM ALV_DISPLAY.
****************************END OF PERFORM FOR DISPLAYING **********
*& Form PERFORM_ALV
DISPLAY THE RECORDS IN ALV GRID FORMAT.
FORM ALV_DISPLAY.
PERFORM FIELD_CATALOG USING 'COUNT' 'Sr. No.'.
PERFORM FIELD_CATALOG USING 'OBJID' 'COURCE ID.'.
PERFORM FIELD_CATALOG USING 'STEXT' 'COURCE NAME'.
PERFORM FIELD_CATALOG USING 'LSTEXT' 'COURCE LOATION'.
PERFORM FIELD_CATALOG USING 'BEGDA' 'BEGIN DATE '.
PERFORM FIELD_CATALOG USING 'ENDDA' 'END DATE '.
PERFORM FIELD_CATALOG USING 'CANCRT' 'REASON'.
PERFORM FIELD_CATALOG USING 'AEDTM' 'DATE Of CANCEL'.
PERFORM FIELD_CATALOG USING 'NCONT' 'NUMBER OF BOOKINGS'.
PERFORM FIELD_CATALOG USING 'LOCTX' 'COURCE LOCATION'.
PERFORM FIELD_CATALOG USING 'UNAME' 'WHO CANCELLED'.
PERFORM FIELD_CATALOG USING 'LSTEXT' 'COURCE LOATION'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_STRUCTURE_NAME = 'IT_OUTPUT'
I_GRID_TITLE = ' Cancelled courses with reason '
IT_FIELDCAT = IN_FCAT
TABLES
T_OUTTAB = IT_OUTPUT.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. "PERFORM_ALV
*& Form FIELD_CATALOG
text
-->FIELD_NAME text
-->DIS_TEXT text
FORM FIELD_CATALOG USING FIELD_NAME DIS_TEXT.
CLEAR WS_FCAT.
WS_FCAT-TABNAME = 'IT_OUTPUT'.
WS_FCAT-FIELDNAME = FIELD_NAME.
WS_FCAT-SELTEXT_M = DIS_TEXT.
APPEND WS_FCAT TO IN_FCAT .
ENDFORM. "FIELD_CATALOG
*& Form GET_DATA
text
--> p1 text
<-- p2 text
FORM GET_DATA .
*sort it_sobid by objid.
LOOP AT IT_SOBID INTO WA_SOBID." where otype eq s_otype and objid eq s_objid.
READ TABLE IT_HRP1026 WITH KEY OBJID = WA_SOBID-SOBID OTYPE = WA_SOBID-SCLAS INTO WA_HRP1026.
IF SY-SUBRC EQ 0.
READ TABLE IT_HRP1000 WITH KEY OBJID = WA_SOBID-SOBID INTO WA_HRP1000.
READ TABLE IT_REASON WITH KEY CANCR = WA_HRP1026-CANCR INTO WA_REASON.
WA_OUTPUT-OBJID = WA_HRP1026-OBJID.
WA_OUTPUT-BEGDA = WA_SOBID-BEGDA.
WA_OUTPUT-ENDDA = WA_SOBID-ENDDA.
WA_OUTPUT-AEDTM = WA_HRP1026-AEDTM.
WA_OUTPUT-UNAME = WA_HRP1026-UNAME.
WA_OUTPUT-NCONT = WA_HRP1026-NCONT.
READ TABLE IT_HRP1000 WITH KEY OBJID = WA_SOBID-SOBID INTO WA_HRP1000.
WA_OUTPUT-STEXT = WA_HRP1000-STEXT.
READ TABLE IT_REASON WITH KEY CANCR = WA_HRP1026-CANCR INTO WA_REASON.
WA_OUTPUT-CANCRT = WA_REASON-CANCRT.
CLEAR WA_REASON-CANCRT.
READ TABLE IT_LOCATION1 WITH KEY OBJID = WA_HRP1026-OBJID INTO WA_LOCATION1..
READ TABLE IT_LSTEXT WITH KEY OBJID = WA_LOCATION1-SOBID OTYPE = 'F' INTO WA_LSTEXT.
WA_OUTPUT-LSTEXT = WA_LSTEXT-LSTEXT.
CLEAR WA_LSTEXT-LSTEXT.
APPEND WA_OUTPUT TO IT_OUTPUT.
CLEAR WA_OUTPUT.
CLEAR WA_OUTPUT-CANCRT.
ENDIF.
ENDLOOP.
ENDFORM. " GET_DATA
*& Form GET_LOCATION
text
--> p1 text
<-- p2 text
FORM GET_LOCATION .
SELECT OTYPE
OBJID
RSIGN
RELAT
SCLAS
SOBID
FROM HRP1001
INTO TABLE IT_LOCATION
FOR ALL ENTRIES IN IT_HRP1026
WHERE OTYPE = 'E' AND OBJID = IT_HRP1026-OBJID
AND RSIGN = 'A' AND RELAT = '024' AND SCLAS = 'F'
AND BEGDA GE DATE-LOW AND ENDDA LE DATE-HIGH.
IF SY-SUBRC NE 0.
MESSAGE 'NO RECORD FOUND FOR THE GIVEN SELECTION CRITERIA ' TYPE 'E'.
ENDIF.
LOOP AT IT_LOCATION INTO WA_LOCATION.
WA_LOCATION1-OTYPE = WA_LOCATION-OTYPE.
WA_LOCATION1-OBJID = WA_LOCATION-OBJID.
WA_LOCATION1-RSIGN = WA_LOCATION-RSIGN.
WA_LOCATION1-RELAT = WA_LOCATION-RELAT.
WA_LOCATION1-SCLAS = WA_LOCATION-SCLAS.
WA_LOCATION1-SOBID = WA_LOCATION-SOBID.
APPEND WA_LOCATION1 TO IT_LOCATION1.
CLEAR WA_LOCATION1.
ENDLOOP.
SELECT OTYPE
OBJID
STEXT
FROM HRP1000
INTO TABLE IT_LSTEXT
FOR ALL ENTRIES IN IT_LOCATION1
WHERE OBJID = IT_LOCATION1-SOBID
AND OTYPE = 'F'.
AND BEGDA GE DATE-LOW
AND ENDDA LE DATE-HIGH.
ENDFORM. " GET_LOCATION
<b>Reward if usefull</b> -
For all entries.. with agregate functions....help
Hi ppl,
I want to put this select query outside loop using for all entries but it doesnt support group by neither aggregate funstions like sum.
its not giving correct results if i use collect or sum even using control break statements .
plz help..
LOOP AT T_UNITS.
V_TABIX = SY-TABIX.
get GLPCA postings
SELECT AWTYP AWORG RACCT REFDOCNR SUM( HSL ) FROM GLPCA "1062
INTO TABLE T_GLPCA
WHERE RPRCTR = T_UNITS-UNIT
AND RACCT IN S_HKONT
AND KOKRS = V_KOKRS
AND RYEAR = P_GJAHR
AND POPER <= P_MONAT
GROUP BY AWTYP AWORG RACCT REFDOCNR. "GK_166118
SORT T_GLPCA BY AWTYP AWORG REFDOCNR. "1062
process GLPCA postings
LOOP AT T_GLPCA.
endloop.
some code
endloop.
thanks
Archana... FOR ALL ENTRIES IN itab WHERE cond
Effect
Only selects the records that meet the logical condition cond when each replacement symbol itab-f is replaced with the value of component f of the internal table itab for at least one line of the table. SELECT ... FOR ALL ENTRIES IN itab WHERE cond returns the union of the solution sets of all SELECT statements that would result if you wrote a separate statement for each line of the internal table replacing the symbol itab-f with the corresponding value of component f in the WHERE condition.Duplicates are discarded from the result set. If the internal table itab does not contain any entries, the system treats the statement as though there were no WHERE cond condition, and selects all records (in the current client).
Example
Displaying the occupancy of flights on 28.02.2001:
TYPES: BEGIN OF ftab_type,
carrid TYPE sflight-carrid,
connid TYPE sflight-connid,
END OF ftab_type.
DATA: ftab TYPE STANDARD TABLE OF ftab_type WITH
NON-UNIQUE DEFAULT KEY INITIAL SIZE 10,
free TYPE I,
wa_sflight TYPE sflight.
Suppose FTAB is filled as follows:
CARRID CONNID
LH 2415
SQ 0026
LH 0400
SELECT * FROM sflight INTO wa_sflight
FOR ALL ENTRIES IN ftab
WHERE CARRID = ftab-carrid AND
CONNID = ftab-connid AND
fldate = '20010228'.
free = wa_sflight-seatsocc - wa_sflight-seatsmax.
WRITE: / wa_sflight-carrid, wa_sflight-connid, free.
ENDSELECT.
The statement has the same effect as:
SELECT DISTINCT * FROM sflight INTO wa_sflight
WHERE ( carrid = 'LH' AND
connid = '2415' AND
fldate = '20010228' ) OR
( carrid = 'SQ' AND
connid = '0026' AND
fldate = '20010228' ) OR
( carrid = 'LH' AND
connid = '0400' AND
fldate = '20010228' ).
free = wa_sflight-seatsocc - wa_sflight-seatsmax.
WRITE: / wa_sflight-carrid, wa_sflight-connid, free.
ENDSELECT.
Notes
You can only use ... FOR ALL ENTRIES IN itab WHERE cond in a SELECT statement.
In the logical condition cond, the symbol itab-f is always a replacement symbol, and should not be confused with the component f of the header line of the internal table itab. The internal table itab does not need to have a header line.
Each component of the internal table that occurs in a replacement symbol in the WHERE condition must have exactly the same type and length as the corresponding component in the database table.
You cannot use replacement symbols in comparisons in LIKE, BETWEEN, or IN expressions.
If you use FOR ALL ENTRIES IN itab, you cannot use ORDER BY f1 ... fn in the ORDER-BY clause.
If you use FOR ALL ENTRIES IN itab, you cannot use a HAVING clause as well.
Sameer -
VBAK,VBRP,VBRK for all entries on I_VRPMA:Please help
Hi,
I need to join 3 tables VBRK,VBAK,VBRP Tables.Actually to improve the performance first i retrieved matnr and belnr(billing records) from VRPMA Table into I_VRPMA where s_vkorg,s_fkdat,s_fkart.(selection screen)
Now i need to fetch billing records from vbrk join with vbrp and join with vbak tables into internal table I_VBRP for all records fetched from I_VRPMA with billing documents.
Key Fields are:sales doc order type-AUART. To join VBRP with VBAK i am using VBRP-AUBEL = VBAK = VBELN.
Fields which will transfer from VBAK are AUART,AUDAT,and AUGRU
Fields which will transfer from VBRK are: FKART,FKDAT,WAERK.
Fields which will tansfer from VBRP are: VBELN,POSNR,FKIMG,VRKME,MEINS,UMVKZ,WAVWR
Please help me how can i write inner join on this one.
Thanks
ShakeerShakeer,
I believe it is OK to use VRPMA table as it has VKORG, FKDAT etc in your key which matches your selection-screen.
Select vbeln posnr F2 F3 AUBEL from vbrp into table lt_vbrp
for all entries in VRPMA
where vbeln = VRPMA-vbeln
and posnr = VRPMA-posnr.
select * from vbfa into table lt_vbfa
for all entries in lt_vbrp
where vbelv = lt_vbrp-aubel
and vbeln = lt_vbrp-vbeln
and vbtyp_n in ( 'M', 'N', 'O' ....billing types you are using) .
lt_vbfa is a combined table having active links with vbelv as sales order and vbeln as billing docs.
Add more conditions wherever possible for your case.
Regards,
Diwakar -
Advice required on a select statement using "FOR ALL ENTRIES"
Hi,
this is really intresting ...
I have a small requirement where in i have to find out
the valid entries in my internal table (T_MATNR) by using a select statement to a check table (MARA) which has all the fields present in the internal table T_MATNR.
Select statement is
SELECT MATNR
MTART
from MARA
for all entries in T_MATNR
into table T_MATNR
where matnr eq T_MATNR-MATNR.
If you observe the itab in the option 'FOR ALL ENTRIES' and the destination table is the same. I want to know whether this is correct? will it cause any performance issue? right now this statement is working fine for me.Hi,
U have to use
SELECT MATNR
MTART
from MARA
<b>into table I_MATNR(different table)</b>
for all entries in T_MATNR
where matnr eq T_MATNR-MATNR.
If u r specifying both same table name then for what entries it will retrieve, if u have alreay selected some entries and appending u can use
SELECT MATNR
MTART
from MARA
<b>into table T_MATNR</b>where matnr eq T_MATNR-MATNR.
then
SELECT MATNR
MTART
from MARA
<b>appending table T_MATNR</b>
for all entries in T_MATNR
where matnr eq T_MATNR-MATNR.
In this way u can do.
Hope u got it. -
hi to all experts,
I'm a beginner in ABAP please help me out with following questions
1.what is the purpose of for all entries please please help with an example(joining 3 tables)
2. how it is different when compared with joins
3. how too use for all entries
4.performance issues
thanks in advance
helpful answers will rewardedHi,
Go through the below link, here i gave a answer on inner joins issue, you will understand.
Re: Improve performance of a SQL request
<b>Reward points if it helps,</b>
Satish -
Using delete and FOR ALL ENTRIES
Hi,
We have a error message regarding the following code :
Delete FROM TABLE FOR ALL ENTRIES IN lt_TABLE WHERE
TABLE_KEY1 = LT_TABLE_KEY1
Could we use the For All entries with "Select" ?
For information, the error message is "Unable to interpret "FOR". Possible causes: Incorrect spelling or comma error.
Thank you.Hi,
Check the below syntax, if you want to delete from database
DELETE FROM sflight
WHERE carrid = p_carrid AND
fldate = sy-datum AND
seatsocc = 0.
Just a suggestion. May be from next time you can use F1 help for syntax:
1. Place the cursor on the delete keword in your program and press F1 - You willl get all the possible syntax for delete statement
2. Else open the transaction ABAPDOCU, Click Keyword Help, Enter the required keyword(delete in this case) and press cont.. You will get the syntax.
Hope thsi will help you.
Regards,
Swarna Munukoti. -
Using for all entries of two internal tables in where clause of the select
Hi experts,
My requirement is, need to select Marc-minbe and wrpl-sobst, for all the entries of the two internal tables it_mara , and it_t001w.
here is the select queries i have used,
select matnr normt from mara into it_mara for all entries in it_data where normt = it_data-normt.
select konnr werks from t001w into it_t001w for all entries in it_data where konnr = it_data-konnr.
now i need to select minbe of marc table and sobse of wrpl table for all the entries of above internal tables, it_mara and it_t001w, using both matnr of it_mara and werks of it_t001w in where condition.
Pls advise how i can do it.
Thanks.
Moderator message: very basic, please work on this yourself first, these forums are not a substitute for ABAP training.
Edited by: Thomas Zloch on Dec 6, 2010 9:38 AMHi
call SE16 with table TFTIT in order to get a full list (it will be long...)
A list of FMs with parameters can be found in table FUNCT.
Finally go to sm37rsdf4
that will give you all the function modules with description
Here is the list:
http://www.erpgenie.com/abap/functions.htm
hope this helps...
Regards
CSM Reddy -
For all entries with 2 internal table
HI experts.
How to use 2 for all entries in a select statement.
Below refer to my below code.
select vbeln matnr lfimg vgbel posnr from lips into corresponding fields of table
it_lips for all entries in it_likp where
vbeln = it_likp-vbeln and
matnr = it_mara-matnr.
I want to add another for all entries it_mara.
Please help me .Thanks in advanced.hi,
it is possible....
use this query...
declare another internal table of the same type as it_lips.
data : it_lips_final like it_lips.
select vbeln matnr lfimg vgbel posnr from lips into corresponding fields of table
it_lips for all entries in it_likp where
vbeln = it_likp-vbeln .
loop at it_lips.
read table it_mara into it_mara with key matnr = it_lips-matnr.
if sy-subrc = 0.
append it_lips to it_lips_final.
endif.
endloop.
refresh it_lips[].
it_lips[] = it_lips_final[]
what the above code does is selects all the entries of vbeln from lips and filters it in the loop reading it from mara checking for matnr value and finally
all the entries according to your requirement is there in it_lips_final which we move it to it_lips again...
this is something similar to writing a for all entries for 2 table.... but in another fashion
Regards
Siddarth -
Extract Cube data for all entries of an internal table
Hi
I want to fetch the data from the cube for all entries of another internal table.
Scenario : Fetching the COMPANY_CODE and DATE into an internal table and for those company codes and Dates, I have to fetch the records of the Cube.,
I am using the Function Module : RSDRI_INFOPROV_READ
But not sure how to accommodate the multiple selections condition for this.
Selection Required:
*For all entries of it_cc
where comp_code = it_cc-comp_code and
date = it_cc-date.*
Please help me how to such multiple conditions and "for all entries" functionality for fetching the data from the cube.
Thanks.
Veera Karthik GHI
You can try like this
LOOP AT lt_donotcall_old .
<ls_donotcall>-examination_date = sy-date.
<ls_donotcall>-examination_time = sy-time.
ENDLOOP.
append it_donotcall_old.
Reward all helpfull answers
Regards
Pavan -
Hi,
I am new in abap reports. Now i want to know why we should use select for all entries in query. We can do retrieve directly by accessing the table in database dictionary.
Experts please give me the reasons I want to know the concepts behind it.It will be better if you kindly explain this with help of code.
With regards,
Abir.HI
GOOD
SELECT
Basic form
SELECT result [target] FROM source [where] [GROUP BY fields] [ORDER BY order].
Effect
Retrieves an extract and/or a set of data from a database table or view (see Relational database ). SELECT belongs to the OPEN SQL command set.
Each SELECT command consists of a series of clauses specifying different tasks:
The SELECT result clause specifies
whether the result of the selection is a table or a single record,
which columns the result is meant to have and
whether the result is allowed to include identical lines.
The INTO target clause specifies the target area into which the selected data is to be read. If the target area is an internal table, the INTO clause specifies
whether the selected data is to overwrite the contents of the internal table or
whether the selected data is to be appended to the contents and
whether the selected data is to be placed in the internal table all at once or in several packets.
The INTO clause can also follow the FROM clause.
You can omit the INTO clause. The system then makes the data available in the table work area (see TABLES ) dbtab . If the SELECT clause includes a "*", the command is processed like the identical SELECT * INTO dbtab FROM dbtab statement. If the SELECT clause contains a list a1 ... an , the command is executed like SELECT a1 ... an INTO CORRESPONDING FIELDS OF dbtab FROM dbtab .
If the result of the selection is meant to be a table, the data is usually (for further information, see INTO -Klausel ) read line by line within a processing loop introduced by SELECT and concluded by ENDSELECT . For each line read, the processing passes through the loop once. If the result of the selection is meant to be a single record, the closing ENDSELECT is omitted.
The FROM source clause the source (database table or view ) from which the data is to be selected. It also determines
the type of client handling,
the behavior for buffered tables and
the maximum number of lines to be read.
The WHERE where clause specifies the conditions which the result of the selection must satisfy. It thus determines the lines of the result table. Normally - i.e. unless a client field is specified in the WHERE clause - only data of the current client is selected. If you want to select across other clients, the FROM clause must include the addition ... CLIENT SPECIFIED .
The GROUP-BY fields clause combines groups of lines together into single lines. A group is a set of lines which contain the same value for every database field in the GROUP BY clause.
The ORDER-BY order clause stipulates how the lines of the result table are to be ordered.
Each time the SELECT statement is executed, the system field SY-DBCNT contains the number of lines read so far. After ENDSELECT , SY-DBCNT contains the total number of lines read.
The return code value is set as follows:
SY-SUBRC = 0 At least one line was read.
SY_SUBRC = 4 No lines were read.
SY-SUBRC = 8 The search key was not fully qualified.
(nur bei SELECT SINGLE ). The returned single record is any line of the solution set.
Example
Output the passenger list for the Lufthansa flight 0400 on 28.02.1995:
TABLES SBOOK.
SELECT * FROM SBOOK
WHERE
CARRID = 'LH ' AND
CONNID = '0400' AND
FLDATE = '19950228'
ORDER BY PRIMARY KEY.
WRITE: / SBOOK-BOOKID, SBOOK-CUSTOMID, SBOOK-CUSTTYPE,
SBOOK-SMOKER, SBOOK-LUGGWEIGHT, SBOOK-WUNIT,
SBOOK-INVOICE.
ENDSELECT.
Note
Performance
In client/server environments, storing database tables in local buffers (see SAP buffering ) can save considerable amounts of time because the time required to make an access via the network is much more than that needed to access a locally buffered table.
Notes
A SELECT command on a table for which SAP buffering is defined in the ABAP/4 Dictionary is normally satisfied from the SAP buffer by bypassing the database. This does not apply with
- SELECT SINGLE FOR UPDATE
- SELECT DISTINCT in the SELECT clause ,
- BYPASSING BUFFER in the FROM clause ,
- ORDER BY f1 ... fn in the ORDER-BY clause ,
- aggregate functions in the SELECT clause ,
- when using IS [NOT] NULL WHERE condition ,
or if the generic key part is not qualified in the WHERE-Bedingung for a generically buffered table.
Authorization checks are not supported by the SELECT statement, so you must program these yourself.
In dialog systems, the database system locking mechanism cannot always guarantee to synchronize the simultaneous access of several users to the same dataset. In many cases, it is therefore advisable to use the SAP locking mechanism .
Changes to data in a database are only finalized after a database commit (see LUW ). Prior to this, any database update can be reversed by a database rollback (see Programming transactions ). At the lowest isolation level (see the section on the "uncommitted read" under Locking mechanism ), this can result in the dataset selected by the SELECT command not really being written to the database. While a program is selecting data, a second program can add, change or delete lines at the same time. Then, the changes made by the second program are reversed by rolling back the database system. The selection of the first program thus reflects only a very temporary state of the database. If such "phantom data" is not acceptable for a program, you must either use the SAP locking mechanism or at least set the isolation level of the database system to "committed read" (see Locking mechanism ).
In a SELECT-ENDSELECT loop, the CONTINUE statement terminates the current loop pass prematurely and starts the next.
If one of the statements in a SELECT ... ENDSELECT loop results in a database commit, the cursor belonging to the SELECT ... ENDSELECT loop is lost and the processing terminates with a runtime error. Since each screen change automatically generates a database commit, statements such as CALL SCREEN , CALL DIALOG , CALL TRANSACTION or MESSAGE are not allowed within a SELECT ... ENDSELECT loop.
Related OPEN CURSOR , FETCH und CLOSE CURSOR
GO THROUGH THIS LINK
http://www.geocities.com/SiliconValley/Campus/6345/select.htm
THANKS
MRUTYUN -
Select ... for all entries problem
Hi,
I'm making select statements to BKPF and BSEG, but I can't do an inner join between this two table because BSEG it's a cluster table so I have to do a SELECT... FOR ALL ENTRIES, but in SE16 I make the same query that I have writen in my program as shown below,
SELECT BUKRS BELNR GJAHR BUDAT MONAT
FROM BKPF INTO CORRESPONDING FIELDS OF TABLE it_bkpf
WHERE BUKRS = 'XXX'
AND GJAHR = '2005'
AND BELNR = '0000000250'. "just for proof
AND MONAT = '10'
The above query returns me 1 row in program and in SE16 and then I make the next query for BSEG to do the join
SELECT BUKRS BELNR GJAHR BSCHL SHKZG WRBTR HKONT
FROM BSEG INTO CORRESPONDING FIELDS OF TABLE IT_BSEG
FOR ALL ENTRIES IN it_bkpf
WHERE bukrs = it_bkpf-bukrs
and gjahr = it_bkpf-gjahr
and belnr = it_bkpf-belnr.
this query returns 897 rows and in SE16 this same query returns 901 rows
Why SELECT...FOR ALL ENTRIES brings me less rows affected by the query in SE16
Thanks for your help!!Hi,
Please use the following code for selcting the exact number of rows.
IF it_bkpf[] IS NOT INITIAL.
SELECT *
FROM BSEG INTO CORRESPONDING FIELDS OF TABLE IT_BSEG
FOR ALL ENTRIES IN it_bkpf
WHERE bukrs = it_bkpf-bukrs
and gjahr = it_bkpf-gjahr
and belnr = it_bkpf-belnr.
ENDIF.
Instead of * ,you can specify the exact fields required along with all the key fields as selection fields.Also it is must to check the condition it_bkpf[] IS NOT INITIAL before using the statement FOR ALL ENTRIES IN it_bkpf.Suppose if this condition is not used and if it_bkpf is initial,it will fetch all entries from the table.
Reward if helpful.
Regards,
Aravind -
Data Type mismatch in for all entries.
Dear Friends,
I have a problem...please advice me for that..... I m using code as following...actually the isse is when ever i am using
WHERE docno = it_j_1iexchdr-rdoc (along with FOR ALL ENTRIES IN) the error is occured data type mismatch.
becoz DOCNO is field of(j_1iexchdr) and RDOC is a character field of same table...but i want to get reference data..so i need to compare both field...u can undersdand my requirement in following coding.. Error line is denoted by (<----
DATA: BEGIN OF it_j_1iexchdr OCCURS 0,
bukrs LIKE j_1iexchdr-bukrs, " Company Code.
exnum LIKE j_1iexchdr-exnum, " Excise Invoice No.
exdat LIKE j_1iexchdr-exdat, " Excise Invoice Dt.
kunag LIKE j_1iexchdr-kunag, " Sold-to-party
kunwe LIKE j_1iexchdr-kunwe, " Ship-to-party
rdoc LIKE j_1iexchdr-rdoc,
rdoc TYPE j_1iexchdr-docno,
addldata1 LIKE j_1iexchdr-addldata1, " Reason for Issueing Excise Invoice
exbed LIKE j_1iexchdr-exbed, " Excise Duty
ecs LIKE j_1iexchdr-ecs, " 2%Cess
exaddtax1 LIKE j_1iexchdr-exaddtax1, " Shec
trntyp LIKE j_1iexchdr-trntyp, " OTHR
END OF it_j_1iexchdr.
DATA: wa_j_1iexchdr LIKE it_j_1iexchdr.
DATA: BEGIN OF it_j_1iexchdr1 OCCURS 0,
trntyp LIKE j_1iexchdr-trntyp,
docno LIKE j_1iexchdr-rdoc,
rdoc LIKE j_1iexchdr-rdoc,
END OF it_j_1iexchdr1.
DATA: wa_j_1iexchdr1 LIKE it_j_1iexchdr1.
SELECT bukrs exnum exdat kunag kunwe rdoc
addldata1 exbed ecs exaddtax1 trntyp
FROM j_1iexchdr
INTO CORRESPONDING FIELDS OF TABLE it_j_1iexchdr
WHERE bukrs IN v_bukrs
AND exdat IN v_exdat
AND trntyp = 'OTHR'.
IF it_j_1iexchdr[] IS NOT INITIAL.
SELECT trntyp docno rdoc
FROM j_1iexchdr
INTO CORRESPONDING FIELDS OF table it_j_1iexchdr1
FOR ALL ENTRIES IN it_j_1iexchdr
WHERE docno = it_j_1iexchdr-rdoc <----
I
AND trntyp = 'DLFC'.
ENDIF.
Pl help me as soon as possible...
Thanks & Regards,
Swapnika PanseHi,
In table j_1iexchdr, there are two fields
RDOC J_1IRDOC1 CHAR 10 Reference Document 1
DOCNO J_1IDOCNO NUMC 10 Internal Excise Document Number
RDOC is of character type and DOCNO is of numeric type.
Your declaration for fields is :
docno LIKE j_1iexchdr-rdoc,
rdoc LIKE j_1iexchdr-rdoc,
And in the select query you are trying to fetch docno which is of type j_1iexchdr-rdoc. SO, change your declaration from
docno LIKE j_1iexchdr-rdoc,
to
docno LIKE j_1iexchdr-docno,
This should solve your problem.
Thanks,
Archana -
Inner Joins vs For All Entries - performance query
Hi All,
I'm a bit confused here... I see lots and lots (and lots...) of postings from people asking how to get data from multiple tables.
To me the immediate answer is to use joins in my select statement to reduce the database load but more and more I see people suggesting FOR ALL ENTRIES is better from a performance perspective.
Now, simple question time, which is more efficient in the real world when doing something like the following:- (this is a basic example but I'm sure you know what I mean.)
Select *
into table lt_sales_data
from vbap as vbap
inner join vbak as vbak
on vbak~vbeln eq vbap~vbeln
where vbak~vbeln in so_vbeln.
or
Select *
into table lt_vbak_data
from vbak
where vbeln in so_vbeln.
if lt_vbak_data[] is not initial.
select *
into table lt_vbap_data
from vbap
for all entries in lt_vbak_data
where vbeln eq lt_vbak_data-vbeln.
endif.
Basically I want to know whether joins or for all entries is better from a database performance perspective.
I want to know why as well so please don't just post links, random cut and paste answers or one liners. I'm convinced for all entries is slower but am willing to be persuaded otherwise if someone can show me proof.
Thanks,
Gareth.Thanks to all the opinions so far... You've backed up what I suspected although I maybe wasn't clear enough with my question and desired result. I was hoping someone could produce some hard and fast guidelines from SAP themselves dictating which is the better method. I know 10 years ago I was taught to use joins and to keep my database access to minimal levels, using keyed reads where applicable and using internal tables to filter data where I couldn't use key fields.
Gautham, I am aware of SM30 but that doesn't answer the general question I was asking. I've obviously used SM30 to run some comparisons but I was really hoping someone could give me a definitive answer based on hard facts or from attending some training at SAP recently. And no points for asking for them
Tamás, I agree with what you are saying about runing many comparisons - it appears to be dependant on any number of criteria which means each case may require different code. I've not managed to find a consistent comparison of the two methods that would lead me to use one method or the other...
Karan, thanks for your feelings but it doesn't really help me! Why/how does it retrieve the data faster than a join? Have you got testing/proof to back this up?
Raam, thanks for those links - they are interesting reads and seem to go through the same arguments I'm currently considering. Although I still don't have a definitie answer!
Amit, I understand exactly what yuo are saying about myths and urban legends That was my motivation for this post. To bo honest, it seems to me that a lot of the "newer" ABAP coders always go for FOR ALL ENTRIES but I wanted to know - is there a reason or do they all just cut and paste off SDN?! Are they all just scared of complex inner joins?! What would you all make of this Select statement for example? -
select afvc~arbid
afko~aufnr
aufk~objnr
afko~plnnr
afko~plnal
afko~aufpl
afko~zaehl
afpo~matnr
makt~maktx
afvc~vornr
afvc~ltxa1
afvu~aplzl
afvu~usr10
afvv~meinh
afvv~bmsch
afvv~vge02
afvv~vgw02
afvv~mgvrg
afab~aplzl_vor
into table lt_recipe_orders
from afko as afko
inner join aufk as aufk
on aufk~aufnr eq afko~aufnr
inner join afpo as afpo
on afpo~aufnr eq afko~aufnr
inner join makt as makt
on makt~matnr eq afpo~matnr
inner join afvc as afvc
on afvc~aufpl eq afko~aufpl
inner join afvu as afvu
on afvu~aufpl eq afvc~aufpl
and afvu~aplzl eq afvc~aplzl
inner join afvv as afvv
on afvv~aufpl eq afvu~aufpl
and afvv~aplzl eq afvu~aplzl
left outer join afab as afab
on afab~aufpl_nch eq afvu~aufpl
and afab~aplzl_nch eq afvu~aplzl
for all entries in t_resources
where afko~gltrs ge v_start_date
and afko~gstrs le v_start_date
and afko~plnty eq gc_task_list_type_2
and afpo~dwerk eq v_werks
and makt~spras eq sy-langu
and afvc~arbid eq t_resources-objid.
Twinkal, I've always thought less DB hits is a better performing program too - the above example compares 2 db hits to 1... I don't have issues with complex joins because I've used them so long so can discount that problem but do agree that less DB hits is the ultimate goal. Providing of course the Selects you write are actually efficient in themselves.
Murthy, if you build your select statement correctly duplicate records can be avoided in most cases. How can you say a join statement will hit the database more when in my example there is 1 DB hit compared to 2 for a for all entries? And I'd love to know the reasoning behind never using a join on more than 2 tables?! Is that just an urban myth?!
Thomas, I've just been looking at some of Siegfried's posts and like what I am reading. As you say, using full keys via joins is essential.
Gareth. -
Replacing innerjoin with for all entries
hi,
i have a requirement that i have to improve the performance of report . this the code below.
SELECT A~VBELN A~BSTNK A~AUDAT A~KUNNR B~MATNR B~WERKS B~KWMENG
FROM VBAK AS A INNER JOIN VBAP AS B ON A~VBELN = B~VBELN
INTO CORRESPONDING FIELDS OF TABLE ITEKKo WHERE
B~MATKL IN S_MATKL AND A~AUDAT IN S_BEDAT AND
A~VKORG IN S_VKORG AND A~VTWEG IN S_VTWEG
AND B~WERKS IN S_WERKS .
LOOP AT ITEKKO.
SELECT SINGLE MVGR1 MVGR5 FROM MVKE INTO (ITEKKO-MATKL, ITEKKO-MVGR5) WHERE
MATNR = ITEKKO-MATNR.
SELECT SINGLE INCO2 FROM VBKD INTO ITEKKO-NAME1 WHERe VBELN = ITEKKO-VBELN.
SELECT SINGLE LAND1 FROM KNA1 INTO CCODE WHERE
KUNNR = ITEKKO-KUNNR.
SELECT SINGLE LANDX50 FROM T005T INTO ITEKKO-CNAME WHERE
LAND1 = CCODE AND SPRAS = 'E'.
MODIFY ITEKKO.
ENDLOOP.
SELECT C~BLDAT D~VBELN D~POSNR D~VGBEL
D~MATKL D~MFRGR D~LFIMG D~MEINS D~MATNR
FROM LIKP AS C INNER JOIN LIPS AS D ON C~VBELN = D~VBELN
INNER JOIN VBAK AS A ON D~VGBEL = A~VBELN
INTO CORRESPONDING FIELDS OF TABLE IT_LIPS
WHERE A~AUDAT IN S_BEDAT
ORDER BY D~VGBEL D~MFRGR.
LOOP AT IT_LIPS.
SELECT SINGLE MVGR5 FROM MVKE INTO IT_LIPS-MVGR5 WHERE
MATNR = IT_LIPS-MATNR.
MODIFY IT_LIPS.
ENDLOOP.
it is taking very long time when the loops r executing.
can anybody please help.Hi,
Check this coding,
TYPES:BEGIN OF Y_TAB,
BLDAT TYPE LIKP-BLDAT,
VBELN TYPE LIPS-VBELN,
POSNR TYPE LIPS-POSNR,
VGBEL TYPE LIPS-VGBEL,
MATKL TYPE LIPS-MATKL,
MFRGR TYPE LIPS-MFRGR,
LFIMG TYPE LIPS-LFIMG,
MEINS TYPE LIPS-MEINS,
MATNR TYPE LIPS-MATNR,
END OF LS_TAB.
TYPES : BEGIN OF Y_VBAK,
VBELN TYPE VBAK-VBELN,
END OF Y_VBAK.
TYPES: BEGIN OF Y_LIPS,
VBELN TYPE LIPS-VBELN,
POSNR TYPE LIPS-POSNR,
VGBEL TYPE LIPS-VGBEL,
MATKL TYPE LIPS-MATKL,
MFRGR TYPE LIPS-MFRGR,
LFIMG TYPE LIPS-LFIMG,
MEINS TYPE LIPS-MEINS,
MATNR TYPE LIPS-MATNR,
END OF Y_LIPS.
TYPES : BEGIN OF Y_LIKP,
BLDAT TYPE LIKP-BLDAT,
VBELN TYPE LIKP-VBELN,
END OF Y_LIKP.
DATA IT_ITAB TYPE TABLE OF LS_TAB.
DATA WA_ITAB TYPE LS_TAB.
DATA IT_LIPS TYPE TABLE OF Y_LIPS.
DATA WA_LIPS TYPE Y_LIPS.
DATA IT_LIKP TYPE TABLE OF Y_LIKP.
DATA IT_VBAK TYPE TABLE OF Y_VBAK.
DATA WA_LIKP TYPE Y_LIKP.
SELECT VBELN FROM VBAK INTO TABLE IT_VBAK WHERE AUDAT IN S_BEDAT.
SELECT VBELN POSNR VGBEL MATKL MFRGR LFIMG MEINS MATNR FROM
LIPS INTO TABLE IT_LIPS FOR ALL ENTRIES IN IT_VBAK
WHERE VGBEL = IT_VBAK-VBELN.
SELECT BLDAT VBELN FROM LIKP INTO TABLE IT_LIKP FOR ALL ENTRIES IN IT_LIPS WHERE VBELN = IT_LIPS-VBELN.
LOOP AT IT_LIKP INTO WA_LIKP.
READ TABLE IT_LIPS INTO WA_LIPS WITH KEY VBELN = WA_LIKP-VBELN.
IF SY-SUBRC EQ 0.
MOVE-CORRESPONDING WA_LIPS TO WA_ITAB.
MOVE WA_LIKP-BLDAT TO WA_ITAB-BLDAT.
APPEND WA_ITAB TO IT_ITAB.
CLEAR WA_ITAB.
ENDIF.
ENDLOOP.
SORT IT_ITAB BY VGBEL MFRGR.
I Hope it will help.
Maybe you are looking for
-
Webdynpro - Check if a portal user has a user in R/3 Backend
Hi Experts, i have following problem, and maybe some of you can help me out with an idea or (much better) a solution: Our Company is running an Enterprise Portal on NW2004s (SPS 18). Currently i am developing a Java WebDynpro Application for the port
-
How do I reset / refresh slide elements on enter in Captivate 6?
I have a Captivate 6 movie that has a number of user-triggered advanced actions in the form of case studies / character scenarios. These interactions enable learners to watch displayed information, answer questions and recieve feedback. I need these
-
HOW TO come & Install hindi Language on Bold 9780
Hello! I tried using hindi Language on my phone and installing it from there, but no results. Can anyone please help me resolve this problem? My phone details are as follow: Blackberry 9780 PIN: 26C49BFC 6.0 Bundle 2949 (v6.0.0.668, Platform 6.6.0.23
-
Allocations across company codes
Hi Friends , We have multiple company codes and if there are several cost centers within these company codes and If we want to allocate ( assesment or distribute ) across company codes I guess we can as we still use 1 controll
-
How Do You Make an Acute Accent?
I would like to have a letter with the acute accent over the top - like you might see on the letter e in the word Cafe. Anyone know if this is possible when creating a title in Premiere Pro (CS4)? I'm on a PC.