2012 Sep 25 10:52 AM
Tried a number of hit and try but not working.
Fetching NETPR for only two records but rest of the records are 0 though data is present in the table.
LOOP AT li_contract INTO wl_contract.
IF
wl_contract-pstyp EQ '2'.
* MOVE wl_inforec-netpr TO wl_contract-netpr.
wl_contract-waers = wl_inforec-waers.
wl_contract-netpr = wl_inforec-netpr.
wl_contract-peinh = wl_inforec-peinh.
wl_contract-bprme = wl_inforec-bprme.
IF sy-subrc IS INITIAL.
MODIFY li_contract FROM wl_contract TRANSPORTING netpr.
endif.
endif.
2012 Sep 25 2:11 PM
Is there a reason you are not checking subrc until AFTER you move data from your 2nd internal table? If that read fails wl_inforec will have data from the previous read.
Why do you move other fields into your structure that you are not going to update? That is extra work that does nothing but confuse other programmers looking at your code.
How about changing your code to look like this.
LOOP AT li_contract INTO wl_contract.
IF wl_contract-pstyp EQ '2'.
READ TABLE li_inforec INTO wl_inforec WITH KEY infnr = wl_contract-infnr.
IF sy-subrc IS INITIAL.
wl_contract-netpr = wl_inforec-netpr.
MODIFY li_contract FROM wl_contract TRANSPORTING netpr.
endif.
endif.
2012 Sep 25 2:15 PM
hello,
see if there are leading zeroes for the field 'INFNR'. This moght be causing the issue.
Also the statement 'IF sy-subrc IS INITIAL.' should be just after the read.
best regards,
swanand
2012 Sep 25 11:42 PM
Also, this is probably not your problem, but I personally prefer to code if sy-subrc = '0' instead of IS INITIAL. It seems to be more descriptive to me. I suppose it is just personal preference or coding style, but it seems "cleaner" to me. (whatever that means)
2012 Sep 26 7:12 AM
Hi
Can u please paste ur entire code..will try to help..!
Regards