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

FOR ALL ENTRIES PROBLEM

Former Member
0 Likes
1,334

Moderator message: do not use ALL CAPITALS in the subject line

Hi Experts,

I have one query in ALL ENTRIES KEYWORD.

Actually I am putting one select query as

SELECT LIFNR LAND1 FROM LFA1 INTO TABLE ITAB FOR ALL ENTRIES IN JTAB WHERE NAME2 = JTAB-NAME2.

Here my JTAB having one entry but the value in field JTAB-NAME2 is blank.

My problem is that i am getting here SY-SUBRC = 4 after the above mentioned query.

Whereas in table LFA1 we have entries where NAME2 equal to blank.

Any idea how I can get here sy-subrc = 0 as we have entry in table LFA1.

Please suggest.

Regards,

Neha

Edited by: Matt on Dec 22, 2008 9:16 AM

Moderator message: do not use ALL CAPITALS in the subject line

Hi Experts,

I have one query in ALL ENTRIES KEYWORD.

Actually I am putting one select query as

SELECT LIFNR LAND1 FROM LFA1 INTO TABLE ITAB FOR ALL ENTRIES IN JTAB WHERE NAME2 = JTAB-NAME2.

Here my JTAB having one entry but the value in field JTAB-NAME2 is blank.

My problem is that i am getting here SY-SUBRC = 4 after the above mentioned query.

Whereas in table LFA1 we have entries where NAME2 equal to blank.

Any idea how I can get here sy-subrc = 0 as we have entry in table LFA1.

Please suggest.

Regards,

Neha

Edited by: Matt on Dec 22, 2008 9:16 AM

12 REPLIES 12
Read only

Former Member
0 Likes
1,306

Hi,

u write your code below this manner

SELECT LIFNR LAND1 FROM LFA1 INTO TABLE ITAB

FOR ALL ENTRIES IN JTAB

WHERE

NAME2 = JTAB-NAME2

AND

NAME2 = ' '.

I think your problem will be solve.

Regards

Tarapada D.

Read only

Former Member
0 Likes
1,306

Hi Neha,

Try like this:

SELECT LIFNR LAND1 FROM LFA1 INTO TABLE ITAB FOR ALL ENTRIES IN JTAB WHERE NAME2 = JTAB-NAME2 and NAME2 = ' '.it will take the blank values.Thn i think u will get sy-subrc =0.

Hope it helps.

Regards,

Rahul

Read only

Former Member
0 Likes
1,306

Hello,

When u r writing FOR ALL ENTIERS statement u need check table Is Initail or not...

thank u,

Santhosh

Read only

Former Member
0 Likes
1,306

hi,you can write

SELECT LIFNR LAND1 FROM LFA1 INTO TABLE ITAB

FOR ALL ENTRIES IN JTAB WHERE

NAME2 = JTAB-NAME2 or

NAME2 = space.

thanks

Read only

Former Member
0 Likes
1,306

SELECT LIFNR LAND1 FROM LFA1 INTO TABLE ITAB

FOR ALL ENTRIES IN JTAB WHERE

NAME2 = JTAB-NAME2 and

NAME2 = space.

Read only

Former Member
0 Likes
1,306

Hi Neha,

If u have that Name2 in selection screen , then make it as mandatory .

Or write your query as told by other's before this.

Read only

Former Member
0 Likes
1,306

Please check all the entries in table JTAB .

If in internal table JTAB you find other fields (a part from NAME2 ) desimilar to the entries of LFA1 the query is going to fail.

I am sure this is the reason for Sy-SUBRC = 0.

EX.

As you say NAME2 = ' ' in JTAB the other field of jtab let it be jtab-LIFNR = '10020' .

then in table LFA1 no such entry with field LIFNR = 10020 would be there .even if

its there then its NAME2 field must be having some data.

Read only

matt
Active Contributor
0 Likes
1,306

Please do not use ALL CAPITALS in the subject line

Read only

Former Member
0 Likes
1,306

Hi neha,

Remember while using FOR ALL ENTERIES statement the referencing table or field declared with where clause should not be empty. it should have atleast one record. Otherwise System take it as there is no WHERE clause and selects the all records of that client.

Regards,

Vikas

Read only

Former Member
0 Likes
1,306

Hi Neha,

As far as my knowledge goes FOR ALL ENTRIES is a dangerous SQL query since any harm if happens will be for all the entries in the database table.Please be careful and ensure that you mention the where clause.

Now coming to your query

name2 can either be blank or should hold data,

hence its advisable to use the following code

SELECT LIFNR LAND1

FROM LFA1

INTO TABLE ITAB

FOR ALL ENTRIES IN JTAB

WHERE NAME2 = JTAB-NAME2 or NAME2 = ' '.

hope this gives sy-surc = 0,the solution

thanks

srikanth.p

Read only

Former Member
0 Likes
1,306

SELECT matnr werks

FROM marc INTO TABLE i1_marc where matnr IN s_matnr

AND werks in s_werks AND mmsta = '10'.

if not i1_marc is inintial.

SELECT matnr werks

FROM mast INTO TABLE i_mast

for all entries in i1_marc

where matnr = i1_marc-matnr

AND werks = i1_marc-werks.

Read only

Former Member
0 Likes
1,306

data: i1_marc type table of marc with header line.

SELECT matnr werks

FROM marc INTO TABLE i1_marc where matnr IN s_matnr

AND werks in s_werks AND mmsta = '10'.

if not i1_marc[] is inintial.

SELECT matnr werks

FROM mast INTO TABLE i_mast

for all entries in i1_marc

where matnr = i1_marc-matnr

AND werks = i1_marc-werks

thanks and regards.

SWATI GUPTA

Edited by: swati gupta on Dec 26, 2008 6:12 AM