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

NETPR data not fetched.

Former Member
0 Likes
729

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'.
READ TABLE li_inforec INTO wl_inforec WITH KEY infnr = wl_contract-infnr.

* MOVE wl_inforec-waers TO wl_contract-waers.

 

* 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.

4 REPLIES 4
Read only

Former Member
0 Likes
669

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.

Read only

Former Member
0 Likes
669

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

Read only

0 Likes
669

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)

Read only

Former Member
0 Likes
669

Hi

Can u please paste  ur entire  code..will try to help..!

Regards