‎2008 Apr 29 11:06 AM
Hi Experts,
i ve writtern some peace of code like below,
loop at it_prps.
CASE month.
WHEN '01'.
loop at it_final into it_output
WHERE pspnr1 = it_prps-pspnr
AND wrttp = '04'
AND beltp = '02'
AND versn = '000'
AND ( vorga = 'COIN' OR vorga = 'RKU2' ).
MOVE it_output-wlp01 TO t_act_billing.
act_billing = act_billing + t_act_billing.
if sy-subrc EQ 0.
else.
write:/10 'There ia no data....'.
endif.
ENDLOOP.
ENDCASE.
ENDLOOP.
in above code there are 2loops,
1st is looping properly but 2nd one is not looping .
loop at it_prps-pspnr and it_final-pspnr1 same.
but loop at it_final into it_output is not looping, but in WHERE clause all cond all right. but why its not working.
is there any other way to write this.
could anybady tell me where i went wrong..
very urgent.
Rgds,
sudharsan.
‎2008 Apr 29 11:10 AM
Hi,
Just comment the below code and check.
if sy-subrc EQ 0.
else.
write:/10 'There ia no data....'.
endif.
‎2008 Apr 29 11:22 AM
Hi,
no velangini,
loop at it_prps.
loop at it_final into it_output
WHERE pspnr1 = it_prps-pspnr
AND wrttp = '04'
AND beltp = '02'
AND versn = '000'
AND ( vorga = 'COIN' OR vorga = 'RKU2' ).
if sy-subrc EQ 0.
else.
write:/ 'no data'.
endif.
MOVE it_output-wlp01 TO t_act_billing.
act_billing = act_billing + t_act_billing.
if sy-subrc EQ 0.
else.
write:/10 'There ia no data....'.
endif.
ENDLOOP.
if i check sy-subrc also, control is not coming to if statment. its not checking subrc is 0 ir not at all.
directly it is coming to last endloop.
could anyone check pls..
Rdgs,
sudharsan.
ENDLOOP.
‎2008 Apr 29 11:30 AM
Since the where clause of the loop has all constants but for it_prps-pspnr, did you check if there are no leading zeroes in one of the variables ?
As per me, there might be leading zeroes on either the left hand side or the Right hand side of the expression.
Do let me know if this helped.
Pranjal.
‎2008 Apr 29 11:36 AM
Hi pranjal,
there is no leading zeros like that , both data is same.
could check is there any other thing...
Rgds,
sudharsan.
‎2008 Apr 29 11:39 AM
Then we will require to know how you ahve defined the 2 internal tables . If you could paste that part of the data declaration?
Because if you are saying that both the tables have proper data, it only means that one of the AND conditions in the where clause is not getting satisfied...we will need to check the data declarations, if the hardcoded numbers in where clause are specified with the required length.
‎2008 Apr 29 11:41 AM
Hi!
If you wanted to check is your LOOP successful or not, you have to use the sy-subrc after the ENDLOOP statement.
loop at...
loop at it_final into it_output
WHERE pspnr1 = it_prps-pspnr
AND wrttp = '04'
AND beltp = '02'
AND versn = '000'
AND ( vorga = 'COIN' OR vorga = 'RKU2' ).
MOVE it_output-wlp01 TO t_act_billing.
act_billing = act_billing + t_act_billing.
ENDLOOP.
if sy-subrc NE 0.
write:/10 'There is no data in it_final....'.
endif.
endloop.
Regards
Tamá
‎2008 Apr 29 11:19 AM
hi,
instead of loop u can use read Table
read table it_final into it_output
WHERE pspnr1 = it_prps-pspnr
AND wrttp = '04'
AND beltp = '02'
AND versn = '000'
AND ( vorga = 'COIN' OR vorga = 'RKU2' ).
if sy-subrc EQ 0.
else.
write:/10 'There ia no data....'.
endif.
MOVE it_output-wlp01 TO t_act_billing.
act_billing = act_billing + t_act_billing.
Regards,
priya
‎2008 Apr 29 11:30 AM
Hi priya,
thanks for ur replay, if i use read stat it is giving comma error.
am nt sure can we use where clause with read stat.
Thanks & Rgds,
sudharsan.
‎2008 Apr 29 11:35 AM
Further, I do not think read will help because what if ther are more than 1 record satisfyin the conditions in the where clause? we want the sum so loop has to be there.
Also, Read statement cant have NOT EQUALTO equations, it only supports EQ and not NE/GT/LT operations.
SUdarshan, read statement cant have WHERE clause but it can have WITH KEY in place of WHERE, though you wont need read statement here.
‎2008 Apr 29 11:40 AM
Hi,
The reason is in your second loop where condition you have used wrttp beltp versn vorga with some constant values. These constant values may not be satisfiedl.
Thanks,
Sriram Ponna.
‎2008 Apr 29 11:49 AM
Hey Sudharsan,
Check whether the fields you comparing have the same type.
pspnr1 = it_prps-pspnr.
Example: pspnr in prps table in NUMC ,the field pspnr1 is also same type.
You also have to give the if sy-subrc = 0 condition at the end of loop inside.
Thanks&Regards,
Karthik.
‎2008 Apr 29 12:24 PM
Hi Friends,
After abserving in Debugging, there is a pronlem with header data.
in both tables the body data is same. but initially in header data is diff,
so body records are same. once first loop is execute the data of header is changing, so its not matching with 2nd table header data.
so before looping 2tables can i delete header data from 2tables.
if can how ? can i use clear.
Rgds,
sudharsan.
‎2008 Apr 29 12:26 PM
yes, you can.
clear itab.
this clears the header of the internal table itab.
regards,
madhu
‎2008 Apr 29 12:40 PM
Hi friends,
ur right i can clear, but the problem is, if i clear there is no data in both headers, it is ok fine,
but once 1st loop is finish ( loop at it_prps) it is having 1st record, then control comes to 2nd loop, here same time am doing looping and comparing, so once control comes to 2nd loop there is no header data to compare .
so its not comparing.
so how can i procede.
Rgds,
sudha.
‎2008 Apr 29 12:34 PM
Hi Sudharsan,
If you were not able to identify the rootcause simple comment Where conditions fields except the pspnr and try with one more condition.
For example, first have the WRTTP field condition only in the where clause and comment other validations. You can simply identify the rootcause yourself when you check this one by one.
WHERE pspnr1 = it_prps-pspnr
AND wrttp = '04'
AND beltp = '02'
AND versn = '000'
AND ( vorga = 'COIN' OR vorga = 'RKU2' ).
Your where condition would be correct but I am not sure about your constant values and format.
Please let me know the tables from which you fetch the values to the internal tables. If you give that I can analyse and provide the rootcause and solution.
regards,
Saravanan V