02-21-2007 10:28 AM
Hi,
For At End Of , Suppose I have an internal table with fields MATNR, MAKTX,POSNR,and suppose I want to do some calculations "At End Of " POSNR then the internal table should have First field as POSNR.
Is it applicable to "At New" also???
regards
Avi......
02-21-2007 10:31 AM
Hi,
Yes, You have to keep the POSNR as first field and to sort the Int table :
SORT itab by posnr matnr maktx.
Then only you can do totals using AT END OF POSNR>
Same is applicable to AT NEW also.
Regards,
Anji
Message was edited by:
Anji Reddy Vangala
02-21-2007 10:31 AM
Hi,
Yes, You have to keep the POSNR as first field and to sort the Int table :
SORT itab by posnr matnr maktx.
Then only you can do totals using AT END OF POSNR>
Same is applicable to AT NEW also.
Regards,
Anji
Message was edited by:
Anji Reddy Vangala
11-21-2007 6:09 AM
Dear Sir do have any material about Payroll-HR(SAP-HR) .
Then plz send me at : rajsap77@gmail.com
Thanx for the favor .
Regards : rajneesh
02-21-2007 10:31 AM
Yes. If it is not, then it will consider the concatenation of matnr+ vbeln +posnr as one field, and will trigger on change of any of those fields.
Regards,
Ravi
02-21-2007 10:32 AM
I believe so. If you do at end of posnr, where matnr, maktx and posnr are the table fields in that order, the routine will be entered when there is a change to matnr, maktx or posnr.
Cheers Stephen
02-21-2007 10:34 AM
ur internal table should have posnr as the first field....if this is so, then At NEW or AT END will work properly.....if this is not first field, it works but sometimes gives wrong data.....
11-21-2007 7:22 AM
hi Avi,
Better to use another primary field at AT END OF.Even though i can understand ur problem.Thats why i develop a small code for ur problem.I think that is very much helpful for u.
If u satisfy with the code plz give me the REWARD POINTS.
plz copy the below code and execute it ok.
code:
----
Tables
----
tables:vbap.
----
Internal Table
----
DATA: BEGIN OF itab OCCURS 0,
vbeln LIKE vbap-vbeln, " Sales Doc No
matnr LIKE vbap-matnr, " Material Number
posnr LIKE vbap-posnr, " Sales Doc Item
END OF itab.
data: total type i. " Toatal value is hold.
----
Selection Screen
----
SELECTION-SCREEN: BEGIN OF BLOCK b1 with frame TITLE text-001.
SELECT-OPTIONS: s_vbeln FOR vbap-vbeln.
selection-screen: END OF BLOCK b1.
initialization.
perform initial.
----
Fetch data
----
START-OF-SELECTION.
PERFORM fetch_data.
----
Fetch data
----
END-OF-SELECTION.
perform diplay_data.
&----
*& Form fetch_data
&----
text
----
--> p1 text
<-- p2 text
----
FORM fetch_data .
SELECT vbeln
matnr
posnr
FROM vbap
INTO TABLE itab
WHERE vbeln IN s_vbeln.
ENDFORM. " fetch_data
&----
*& Form diplay_data
&----
text
----
--> p1 text
<-- p2 text
----
form diplay_data .
sort itab by vbeln posnr.
loop at itab.
at first.
write:/ 'VBELN', 20 'MATNR', 40 'POSNR'.
uline.
endat.
at new vbeln.
write: / itab-vbeln.
endat.
write: /20 itab-matnr,
40 itab-posnr.
total = total + itab-posnr.
at end of vbeln.
write:/20 'TOTAL = ',total.
clear total.
endat.
at last.
write:/40 'TOTAL = ',total.
endat.
endloop.
endform. " diplay_data
&----
*& Form initial
&----
text
----
--> p1 text
<-- p2 text
----
form initial .
s_vbeln-sign = 'I'.
s_vbeln-option = 'BT'.
s_vbeln-low = '4969'.
s_vbeln-high = '5000'.
append s_vbeln.
endform. " initial