Application Development 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:ย 

Issue In internal table data population in the o/p

former_member191434
Participant
0 Kudos

Dear Guru , I have encountered an issue for which i am not able to findout the logic . I have an internal table through which i am populating the below data for detail report format ๐Ÿ˜†

Plant	Material Number		Storage Loc	Movement Type		Avg Days
019	0820B0073		MOD3		101			space
019	0820B0073		MOD3		101			space
019	0820B0073		MOD3		101			space
019	0820B0073		MOD3		101			space
019	0820B0073		MOD3		101			space

020	0820B0074		MOD4		101			space
020	0820B0074		MOD4		101			2
020	0820B0074		MOD4		101			3

The requirment is like this the summary report should show o/p like below addition of all the rows with respect to plant , material, storage location and movement type :-

Plant	Material Number		Storage Loc	Movement Type		Avg Days
019	0820B0073		MOD3		101			space
020	0820B0074		MOD4		101			5

but when i am adding it with respect to plant, material, storage location and movement type the o/p i am getting is like below

Plant	Material Number		Storage Loc	Movement Type		Avg Days
019	0820B0073		MOD3		101			0
020	0820B0074		MOD4		101			5

becasue addition of 5 spaces ( Avg Days )of plant 019 is coming as ZERO --> 0

so Guru what logic i should use to get the proper o/p,..I have Used Following logic to perform summation with respect to plant, material , storage loc and movement type.

CLEAR: wa_mkpf_mseg, w_werks, w_matnr, w_lgort, w_bwart.

LOOP AT t_mkpf_mseg INTO wa_mkpf_mseg.

IF wa_mkpf_mseg-werks EQ w_werks AND wa_mkpf_mseg-matnr EQ w_matnr AND wa_mkpf_mseg-lgort EQ w_lgort AND wa_mkpf_mseg-bwart EQ w_bwart.

CLEAR: wa_p_coi.

READ TABLE t_p_coi INTO wa_p_coi WITH KEY werks = wa_mkpf_mseg-werks matnr = wa_mkpf_mseg-matnr lgort = wa_mkpf_mseg-lgort bwart = wa_mkpf_mseg-bwart.

IF sy-subrc = 0.

wa_p_coi-Avg Days = wa_p_coi-Avg Days + wa_mkpf_mseg-Avg Days.

MODIFY t_p_coi FROM wa_p_coi TRANSPORTING Avg Days .

CLEAR: wa_p_coi, wa_p_coi.

endif.

ELSE.

wa_p_coi-werks = wa_mkpf_mseg-werks.

wa_p_coi-matnr = wa_mkpf_mseg-matnr.

wa_p_coi-bwart = wa_mkpf_mseg-bwart.

wa_p_coi-lgort = wa_mkpf_mseg-lgort.

wa_p_coi-Avg Days = wa_mkpf_mseg-Avg Days .

APPEND wa_p_coi TO t_p_coi.

CLEAR: wa_p_coi.

ENDIF.

w_werks = wa_mkpf_mseg-werks.

w_matnr = wa_mkpf_mseg-matnr.

w_lgort = wa_mkpf_mseg-lgort.

w_bwart = wa_mkpf_mseg-bwart.

CLEAR: wa_mkpf_mseg.

ENDLOOP.

1 ACCEPTED SOLUTION

former_member156446
Active Contributor
0 Kudos

if avg days space is what you need to show then change the data type of avg date to char.

5 REPLIES 5

Former Member
0 Kudos

Hi Saifur,

Please use CONTROL BREAK PROCESSING STATEMENTS to achieve this.

Go thru this small program.

[http://wiki.sdn.sap.com/wiki/display/Snippets/controlbreakevents]

Regards

Abhii..

Former Member
0 Kudos

If you use ALV to output list,

Just set parameter NO_ZERO = 'X' is ok.

former_member156446
Active Contributor
0 Kudos

if avg days space is what you need to show then change the data type of avg date to char.

0 Kudos

The soln what i found after working out

CLEAR: wa_mkpf_mseg, w_werks, w_matnr, w_lgort, w_bwart.

LOOP AT t_mkpf_mseg INTO wa_mkpf_mseg.

IF wa_mkpf_mseg-werks EQ w_werks AND wa_mkpf_mseg-matnr EQ w_matnr AND wa_mkpf_mseg-lgort EQ w_lgort AND wa_mkpf_mseg-bwart EQ w_bwart.

CLEAR: wa_p_coi.

READ TABLE t_p_coi INTO wa_p_coi WITH KEY werks = wa_mkpf_mseg-werks matnr = wa_mkpf_mseg-matnr lgort = wa_mkpf_mseg-lgort bwart = wa_mkpf_mseg-bwart.

IF sy-subrc = 0.

if wa_p_coi-Avg Days  = ' ' and wa_mkpf_mseg-Avg Days = ' '.
wa_p_coi-Avg Days = ' '.
ELSE
wa_p_coi-Avg Days = wa_p_coi-Avg Days + wa_mkpf_mseg-Avg Days.
Endif.

MODIFY t_p_coi FROM wa_p_coi TRANSPORTING Avg Days .

CLEAR: wa_p_coi, wa_p_coi.

endif.

ELSE.

wa_p_coi-werks = wa_mkpf_mseg-werks.

wa_p_coi-matnr = wa_mkpf_mseg-matnr.

wa_p_coi-bwart = wa_mkpf_mseg-bwart.

wa_p_coi-lgort = wa_mkpf_mseg-lgort.

wa_p_coi-Avg Days = wa_mkpf_mseg-Avg Days .

APPEND wa_p_coi TO t_p_coi.

CLEAR: wa_p_coi.

ENDIF.

w_werks = wa_mkpf_mseg-werks.

w_matnr = wa_mkpf_mseg-matnr.

w_lgort = wa_mkpf_mseg-lgort.

w_bwart = wa_mkpf_mseg-bwart.

CLEAR: wa_mkpf_mseg.

ENDLOOP.

Former Member
0 Kudos

Hi,

Try changing the data type to Integer.