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

read table return sy-subrc = 4

Former Member
0 Likes
8,309

hi,

may i know why the read can map a record but why sy-subrc returns 4?

loop at int_tab.

if int_tab-blart <> 'DZ'.

read table int_t2 with key kunnr = int_tab-kunnr

gjahr = int_tab-gjahr.

if sy-subrc = 0.

move.....

endif.

endif.

endloop.

thanks

hi,

may i know why the read can map a record but why sy-subrc returns 4?

loop at int_tab.

if int_tab-blart <> 'DZ'.

read table int_t2 with key kunnr = int_tab-kunnr

gjahr = int_tab-gjahr.

if sy-subrc = 0.

move.....

endif.

endif.

endloop.

thanks

17 REPLIES 17
Read only

Former Member
0 Likes
4,388

Hi,

In debugging check the int_tab values for int_tab-kunnr

int_tab-gjahr.

Regards

Adil

Read only

Former Member
0 Likes
4,388

Hi,

In your code the sy-subrc checks for the assignment of gjahr as the sy-subrc value is placed after the assignment statement and hence inspite of read statement finding a record sy-subrc may return 4.

<REMOVED BY MODERATOR>

Regards.

Edited by: Alvaro Tejada Galindo on Jun 20, 2008 9:22 AM

Read only

0 Likes
4,388

hi,

i checked already and the read table parameter with value assigned but yet return 4.

why?

thanks

Read only

0 Likes
4,388

Hi,

Write gjahr = int_tab-gjahr after the if condition. The if condition should be after the read statement.

Thanks

Nayan

Read only

0 Likes
4,388

Are you sure it returns sy-subrc 4 inspite it reads a record.

Check once again, Clear your work area before the read statement. Check if it is getting filled after READ statement. It might be a case where the workarea already has some data and read actually fails.

Regards,

Lakshmi.

Read only

Former Member
0 Likes
4,388

Before the

read table int_t2 with key kunnr = int_tab-kunnr

gjahr = int_tab-gjahr.

you are not clearing the header line

=> the first time your if condition is correct you happen to find an entry with your read statement, later on when the if is true again you don't happen to find anything but the header line of int_t2 is still filled with the previous value

So before doing the read, just add a

clear int_t2.

That should solve your problem.

Regards,

Michael

Read only

Former Member
0 Likes
4,388

hiiii

if your sy-subrc NE 0 that means defenetly its not getting values as per your condition.if its so then it will not move values also.check for that.

<REMOVED BY MODERATOR>

thx

twinkal

Edited by: Alvaro Tejada Galindo on Jun 20, 2008 9:22 AM

Read only

Former Member
0 Likes
4,388

Hi,

in the following code :

loop at int_tab.

if int_tab-blart eq 'DZ'.

read table int_t2 with key kunnr = int_tab-kunnr

gjahr = int_tab-gjahr.

if sy-subrc = 0.

move.....

endif.

endif.

endloop.

Try doing a clear int_t2 and then see.

As per my opinion the value placed in int_t2 is the previous record's one. The new record does not matches the criteria and hence sy-subrc = 4. But if a data is not found then the previous record's value is not cleared off..

Try using Clear statement and it should confirm ...

Hope it helps.

Regards,

Himanshu

Read only

Former Member
0 Likes
4,388

Hi,

if possible paste ur code here, so we can check why sy-subrc is not equal to 0.

Regards

Adil

Read only

0 Likes
4,388

hi,

this is the code. why sy-subrc returns 4?

loop at hbsid where umskz = 'A' and blart <> 'DZ' and

rebzg <> space.

v_tabix = sy-tabix.

read table hbsid_ind with key rebzg = hbsid-belnr

kunnr = hbsid-kunnr

gjahr = hbsid-gjahr.

if sy-subrc = 0.

move hbsid_ind-budat to hbsid-budat.

move hbsid_ind-bldat to hbsid-bldat.

modify hbsid index v_tabix transporting budat bldat.

endif.

endloop.

thanks

Read only

0 Likes
4,388

Hi,

read table hbsid_ind with key rebzg = hbsid-belnr

kunnr = hbsid-kunnr

gjahr = hbsid-gjahr.

after this read statement, sy-subrc is not equal to 0,

hbsid-belnr

hbsid-kunnr

hbsid-gjahr

this three fields your getting from another internal table, check whether your getting the values for this three fields or not in debugging.

if possible paste full code.

Regards

Adil

Read only

0 Likes
4,388

hi,

these 3 fields

hbsid-belnr

hbsid-kunnr

hbsid-gjahr

having value during debug and also hbsid_ind has the same record which can match.

i post after the debug and testing. if due to no value, i will not ask here.

thanks

Read only

0 Likes
4,388

Hi

Something is wrong in your code, if SY-SUBRC is equal to 4 it means the matching is fails and so:

- or there isn't the record you're searching

- or the keys used for reading are wrong

- or the way you're using to read the table is wrong

read table hbsid_ind with key rebzg = hbsid-belnr
                                           kunnr = hbsid-kunnr
                                           gjahr = hbsid-gjahr.

So now are u sure the code above is right? If you're looking for the document linked to the current document, it can be the documents belong to different fyscal years, I think the correct code should be:

read table hbsid_ind with key KUNNR = hbsid-kunnr
                                           REBZG = hbsid-belnr
                                           REBZJ  = hbsid-gjahr.

Max

Read only

Former Member
0 Likes
4,388

Hi ,

Try by adding BINARY SEARCH in your read statement .

"Read table hbsid_ind with key rebzg = hbsid-belnr

kunnr = hbsid-kunnr

gjahr = hbsid-gjahr Binary search. "

Read only

Former Member
0 Likes
4,388

Hi,

If iam not wrong your trying some thing like this

DATA: 
  i_sbook TYPE TABLE OF sbook,
  w_sbook LIKE LINE OF i_sbook.
DATA:
  i_sflight TYPE TABLE OF sflight,
  w_sflight LIKE LINE OF i_sflight.

SELECT carrid connid
  FROM sbook
  INTO CORRESPONDING FIELDS OF TABLE i_sbook.

SELECT carrid connid fldate seatsmax seatsocc
  FROM sflight
  INTO CORRESPONDING FIELDS OF  TABLE i_sflight.

LOOP AT i_sbook INTO w_sbook.

  SORT i_sflight BY carrid connid.
  READ TABLE i_sflight INTO w_sflight WITH KEY
                                carrid = w_sbook-carrid
                                connid = w_sbook-connid.
  IF sy-subrc EQ 0.
*move.......
  ENDIF.
ENDLOOP.

if so run this code and check sy-subrc value.

Regards

Adil

Read only

Former Member
0 Likes
4,388

hi,

thanks. resolved

Read only

0 Likes
4,388

Hi

Where is the problem?

Max