2008 Apr 10 2:51 PM
Hi all ,
<REMOVED BY MODERATOR>
I have a ztable called ZMC_CRE with following values.
Ztable : ZMC_CRE
MATERIAL COMPONENT ZCOS
800000000000000003 800000000000000002 00010
800000000000000004 800000000000000007 00020
800000000000000005 800000000000000007 00020
800000000000000007 800000000000000010 00010
800000000000000008 800000000000000005 00010
800000000000000010 800000000000000003 00010
I must write a program such that :
Material, component and ZCOs must be displayed .
Output should be displayed like this .
MATERIAL COMPONENT ZCOS(SUM)
800000000000000003 800000000000000002 00010
800000000000000004 800000000000000007 00050
800000000000000005 800000000000000007 00050
800000000000000007 800000000000000010 00030
800000000000000008 800000000000000005 00060
800000000000000010 800000000000000003 00020
Logic :
We need to calculate zcos(SUM) for a material with all sub components like.
Eg for Material 800000000000000004 and component 800000000000000007 cost ZCOS is = 00020
and again for material 800000000000000007 and component 800000000000000010 cost zcos is = 00010
and again for material 800000000000000010 and component 800000000000000003 cost ZCOS is = 00010
and again for material 800000000000000003 and component 800000000000000002 cost ZCOS is = 00010
-
Hence total cost for material 800000000000000004 and component 800000000000000007 total cost is = 00050
-
The above logic is applied for all the other materials .
<REMOVED BY MODERATOR>
Edited by: Alvaro Tejada Galindo on Apr 10, 2008 1:42 PM
2008 Apr 10 2:54 PM
If I write a program for you, I want money, not points.
Gosh, I feel grumpy today...
In a way Thomas is right, we are not here for writing whole reports/programs for you. But let me help you a bit out, look at:
Or else find sample reports for using FM: REUSE_ALV_LIST_DISPLAY / REUSE_ALV_GRID_DISPLAY in SAP System (Do a where used on function module).
2008 Apr 10 2:54 PM
If I write a program for you, I want money, not points.
Gosh, I feel grumpy today...
2008 Apr 10 3:03 PM
2008 Apr 10 3:08 PM
lol, same thoughts...I feel embarrassed about the two points though.
2008 Apr 10 3:01 PM
In a way Thomas is right, we are not here for writing whole reports/programs for you. But let me help you a bit out, look at:
Or else find sample reports for using FM: REUSE_ALV_LIST_DISPLAY / REUSE_ALV_GRID_DISPLAY in SAP System (Do a where used on function module).
2008 Apr 10 3:07 PM
I may go to hell for this
TYPES: BEGIN OF this_table,
material(20),
component(20),
zcos(5),
sum(5),
END OF this_table.
DATA: itab TYPE TABLE OF this_table WITH HEADER LINE.
DATA: curr_line TYPE sy-tabix.
DATA: sum(5).
itab-material = 800000000000000003. itab-component = 800000000000000002.
itab-zcos = 00010. APPEND itab.
itab-material = 800000000000000004. itab-component = 800000000000000007.
itab-zcos = 00020. APPEND itab.
itab-material = 800000000000000005. itab-component = 800000000000000007.
itab-zcos = 00020. APPEND itab.
itab-material = 800000000000000007. itab-component = 800000000000000010.
itab-zcos = 00010. APPEND itab.
itab-material = 800000000000000008. itab-component = 800000000000000005.
itab-zcos = 00010. APPEND itab.
itab-material = 800000000000000010. itab-component = 800000000000000003.
itab-zcos = 00010. APPEND itab.
LOOP AT itab.
curr_line = sy-tabix.
CLEAR sum.
sum = itab-zcos.
DO.
READ TABLE itab WITH KEY material = itab-component.
IF sy-subrc NE 0.
EXIT.
ENDIF.
sum = sum + itab-zcos.
ENDDO.
itab-sum = sum.
MODIFY itab INDEX curr_line TRANSPORTING sum.
ENDLOOP.
There you got the logic, you only need the select now, it took me more time to paste the data than doing the loop.
Next time try it yourself, I hope you didn't wasted 5 years of your life in a school just to still ask people for code.
There's also better ways to ask this things
2008 Apr 10 3:10 PM
2008 Apr 10 3:25 PM
hi abdullah
check this code
data :sum type i,
wa_itab like line of itab.
loop itab.
sum = itab-zcos.
do.
read table itab into wa_itab with key material = itab-component.
if sy-subrc ne 0.
exit.
endif.
sum + = wa_itab-zcos
enddo.
itab-zcos = sum
modify itab.
write itab.
clear sum.
endloop.
2008 Apr 11 5:15 AM
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |