Skip to Content
0
Former Member
May 27, 2005 at 04:53 AM

material group record.

29 Views

hi,

plz solve my issue.i'm doing a report where i'm extracting the material group afer some selections into an internal table.now my prob isif i leave the material group in selectin screen empty it is showing correct value.if i give any value in the selection screen for material group it is not showing me the exact value.i'm pasting my code plz give me the correct code.

Tables : VBAP,VBEP,VBFA,v023.

selection-screen begin of block prod with frame.

selection-screen skip 1.

select-options: Date for vbfa-erdat.

selection-screen skip 1.

select-options:MATGROUP for VBAP-MATKL.

selection-screen end of block prod.

data iVO23 like V023 occurs 0 with header Line.

DATA : Begin of ZVBFA occurs 0,

POSNV like VBFA-POSNV,

VBELV like VBFA-VBELV,

ERDAT LIKE VBFA-ERDAT,

RFMNG LIKE VBFA-RFMNG,

RFWRT LIKE VBFA-RFWRT,

End of ZVBFA.

TYPES: A TYPE I.

DATA : Begin of ZVBeP occurs 0,

vbeln like vbap-vbeln,

matkl like vbap-matkl,

EDATU like VBeP-EDATU,

POSNR like VBeP-POSNR,

bmeng like vbep-bmeng,

End of ZVBeP.

data: begin of edate occurs 0,

edatu1 like vbep-edatu,

end of edate.

data: tcount type i.

DATA : Begin of ZVBFA1 occurs 0,

POSNV1 like VBFA-POSNV,

VBELV1 like VBFA-VBELV,

ERDAT1 LIKE VBFA-ERDAT,

edatu1 like vbep-edatu,

bmeng like vbep-bmeng,

matkl like vbap-matkl,

End of ZVBFA1.

data: begin of total occurs 0,

matkl like vbap-matkl,

end of total.

data : begin of total1 occurs 0,

matkl1 like vbap-matkl,

bmeng like vbep-bmeng,

end of total1.

data :begin of sum1 occurs 0,

matkl like vbap-matkl,

bmeng like vbep-bmeng,

end of sum1.

data: begin of out occurs 0,

a like vbap-matkl,

b type i,

c type i,

d type i,

per type p decimals 2,

per1 type p decimals 2,

bmeng like vbep-bmeng,

end of out.

data: begin of out1 occurs 0,

a like vbap-matkl,

b type i,

end of out1.

data: begin of out2 occurs 0,

a like vbap-matkl,

b type i,

bmeng like vbep-bmeng,

end of out2.

data mtl like vbap-matkl.

top-of-page.

skip to line 6.

write:/40'SHIPPMENT REPORT FOR SCHEDULE LINE ITEMS'.

WRITE:/40'----


'.

start-OF-SELECTION.

select VBELV POSNV ERDAT RFMNG RFWRT into corresponding fields of

ZVBFA from VBFA where VBTYP_N = 'R' and erdat in date.

append zvbfa.

endselect.

select avbeln amatkl bposnr bedatu b~bmeng into

corresponding fields of table zvbep from

vbap as a inner join vbep as b

on avbeln = bvbeln

and aposnr = bposnr

where MATKL in MATGROUP and bmeng GE '1'.

if sy-subrc ne 0.

FORMAT COLOR COL_NEGATIVE INVERSE.

SKIP TO LINE 14.

write:/ ' NO DATA EXITS FOR SELECTED CRITERIA.'.

FORMAT RESET.

ENDIF.

loop at zvbep.

read table zvbfa with key vbelv = zvbep-vbeln

posnv = zvbep-posnr

binary search.

if sy-subrc EQ 0.

move: zvbfa-vbelv to zvbfa1-vbelv1,

zvbfa-posnv to zvbfa1-posnv1,

zvbfa-erdat to zvbfa1-erdat1,

zvbep-edatu to edate-edatu1,

zvbep-bmeng to zvbfa1-bmeng,

zvbep-matkl to zvbfa1-matkl.

append zvbfa1.

append edate.

endif.

endloop.

loop at zvbfa1.

read table edate with key edatu1 = zvbfa1-erdat1 binary search.

if sy-subrc EQ 0.

move: zvbfa1-matkl to total-matkl.

append total.

else.

move: zvbfa1-matkl to total1-matkl1,

zvbfa1-bmeng to total1-bmeng.

append total1.

endif.

endloop.

SORT total BY MATKL.

sort total1 by matkl1.

data: count1 type i,

count2 type i.

LOOP AT total.

at new matkl.

count1 = sy-tabix.

endat.

at end of matkl.

count2 = sy-tabix - count1 + 1.

out1-b = count2.

out1-a = total-matkl.

append out1.

clear total.

endat.

endloop.

loop at total1.

at new matkl1.

count1 = sy-tabix.

endat.

at end of matkl1.

count2 = sy-tabix - count1 + 1.

out2-b = count2.

out2-a = total1-matkl1.

sum.

out2-bmeng = total1-bmeng.

append out2.

clear total1.

endat.

endloop.

loop at out2.

read table out1 with key a = out2-a binary search.

move: out2-bmeng to out-bmeng.

if sy-subrc = 0.

move : out1-a to out-a,

out1-b to out-b,

out2-b to out-c.

out-d = out-b + out-c.

out-per = ( out-b * 100 / out-d ).

out-per1 = ( out-c * 100 / out-d ).

append out.

endif.

endloop.

skip to line 9.

write:/ sy-Uline(115).

write:/ sy-vline,

12 sy-vline,

28 'ON-TIME' ,

43 sy-vline,

65'LATE SHIP',

93 sy-vline,

95 'TOTAL',

110 sy-vline.

format color col_positive inverse.

write:/ sy-Uline(115).

write:/ sy-vline,

'Mat.Group',

12 sy-vline,

14 'Sch.Line',

23 sy-vline,

29 'Per (%)',

43 sy-vline,

45 'Sch.Line',

55 sy-vline,

60 'TOT.QTY',

73 sy-vline,

82 'Per (%)',

93 sy-vline,

110 sy-vline.

format reset.

write:/ sy-Uline(110).

loop at out where a in matgroup.

write :/ sy-vline,

out-a,

12 sy-vline,

13 out-b,

23 sy-vline,

24 out-per,'%',

43 sy-vline,

44 out-c,

55 sy-vline,

57 out-bmeng,

73 sy-vline,

74 out-per1,'%',

93 sy-vline,

94 out-d,

110 sy-vline,

/ sy-uline(110).

endloop.