Skip to Content
0
Former Member
Jun 02, 2008 at 08:55 AM

Performance Issue

38 Views

Hi All,

We have performance issue with this program, can anyone give suggestion.

******************************************************************************************

data: bdcdata like bdcdata occurs 0 with header line.

data:begin of itab3 occurs 0,

num(10) type n,

end of itab3.

data:begin of itab4 occurs 0,

num(10) type n,

end of itab4.

data: v1(10) type c,

date(10) type c,

grwt(10) type c,

ntwt(10) type c,

trwt(10) type c,

v2(10) type c,

count(2).

data: itab like zsd_wb occurs 0 with header line.

data : truckno like vbak-zztruckno,

mat like vbap-matnr,

qty like vbap-ntgew,

bags like vbap-kwmeng,

materialname like makt-maktx,

yesflag(1) type n,

confirmflag(1) type n,

salesno like vbak-vbeln,

bagorto like vbap-vrkme,

kgorto like vbap-gewei,

nwtstr(13) type c,

pdes like vbap-vbeln,

pqtystr(13) type c,

doctemp like mseg-mblnr,

tarewt like zsd_wb-trwt,

tareno(1) value 0,

tareyes(1) value 0,

grosswt like zsd_wb-grwt,

grossno(1) value 0,

grossyes(1) value 0,

proddoc like zsd_wb-proddoc,

timeinit like sy-uzeit,

timenext like sy-uzeit,

plant like lips-werks,

strloc like lips-lgort.

.

selection-screen begin of block bk1 with frame title text-001.

selection-screen skip .

parameters: poutdel like vbak-vbeln matchcode object vmva.

selection-screen skip .

selection-screen skip .

parameters: ptruck like vbak-zztruckno modif id md2,

pmat like lips-matnr modif id md2.

selection-screen comment 60(35) matname.

parameters: pqty like lips-lfimg modif id md2,

pbags like lips-umvkz modif id md2,

psalesno like lips-kdauf modif id md2.

selection-screen skip .

selection-screen skip .

parameters: ptrwt like likp-btgew modif id md1.

selection-screen pushbutton 55(12) but2 user-command cli2 modif id sc2. "Tare weight

selection-screen comment /55(10) comm3.

selection-screen: pushbutton 70(7) but8 user-command cli7 modif id sc7, "Correct

pushbutton 79(7) but9 user-command cli8 modif id sc8. "Wrong

selection-screen skip .

parameters:pgrwt like likp-btgew modif id md1.

selection-screen pushbutton 55(12) but1 user-command cli1 modif id sc1. "Gross weight

selection-screen comment /55(10) comm2.

selection-screen: pushbutton 70(7) but6 user-command cli5 modif id sc5, "Correct

pushbutton 79(7) but7 user-command cli6 modif id sc6. "Wrong

selection-screen skip .

parameters: pntwt like likp-ntgew modif id md1.

selection-screen skip .

parameters: pdiff(10) type p decimals 2 modif id md1.

selection-screen skip .

parameters: pmfbf like mseg-mblnr modif id md3,

poutno like lips-vgbel modif id md3.

selection-screen: pushbutton /60(16) but10 user-command cli10 modif id s10. "Generate Invoice

parameters: pinv like vbrp-vbeln modif id md3.

selection-screen end of block bk1.

----


--


INITIALIZATION--

----


initialization.

but1 = 'Gross Weight'.

but2 = 'Tare Weight'.

but6 = 'Correct'.

but7 = 'Wrong'.

but8 = 'Correct'.

but9 = 'Wrong'.

but10 = 'Print Invoice'.

at selection-screen output.

poutno = ''.

pmfbf = ''.

ptruck = ''.

pmat = ''.

pqty = ''.

pbags = ''.

psalesno = ''.

loop at screen.

modify screen.

if screen-group1 = 'MD1'. "Weight fields in display mode.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'MD2'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'MD3'.

screen-input = 0.

modify screen.

endif.

select single zztruckno from vbak into truckno where vbeln = poutdel.

ptruck = truckno.

  • SELECT SINGLE matnr kwmeng vrkme ntgew gewei FROM vbap INTO (mat , bags , bagorto , qty , kgorto) WHERE vbeln = poutdel.

select single matnr kwmeng vrkme lsmeng gewei werks lgort from vbap into (mat , bags , bagorto , qty , kgorto , plant , strloc) where vbeln = poutdel.

if strloc eq ''.

strloc = 'FG01'.

endif.

if bagorto eq 'KG'.

pqty = qty / 1000.

endif.

if bagorto eq 'TO'.

pqty = qty .

endif.

if bagorto eq 'BAG'.

pqty = qty * 20.

endif.

pqtystr = pqty.

pmat = mat .

if pqty is not initial.

pbags = pqty * 20.

endif.

if pgrwt is not initial.

pdiff = ( pqty * 1000 ) - pntwt.

endif.

select single maktx from makt into materialname where matnr = mat.

matname = materialname.

salesno = poutdel.

psalesno = salesno.

if poutdel is not initial.

select single vbeln from lips into poutno where vgbel = poutdel.

select single salesdoc from zsd_wb into pmfbf where outdel = poutdel. "SALES DOCUMENT NUMBER

select single vbeln from vbrp into pinv where aubel = poutdel. "INVOICE NUMBER

  • TARE WEIGHT

tarewt = 0.

grosswt = 0.

select single trwt from zsd_wb into tarewt where outdel = poutdel.

if tarewt ne '0.000'.

if screen-group1 = 'SC1'.

screen-input = 1.

modify screen.

endif.

if screen-group1 = 'SC2'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC5'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC6'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC7'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC8'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'S10'.

screen-input = 0.

modify screen.

endif.

elseif ptrwt is initial.

if screen-group1 = 'SC1'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC2'.

screen-input = 1.

modify screen.

endif.

if screen-group1 = 'SC5'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC6'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC7'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC8'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'S10'.

screen-input = 0.

modify screen.

endif.

elseif tareno = 1.

if screen-group1 = 'SC1'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC2'.

screen-input = 1.

modify screen.

endif.

if screen-group1 = 'SC5'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC6'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC7'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC8'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'S10'.

screen-input = 0.

modify screen.

endif.

tareno = 0.

elseif tareyes = 1.

if screen-group1 = 'SC1'.

screen-input = 1.

modify screen.

endif.

if screen-group1 = 'SC2'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC5'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC6'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC7'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC8'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'S10'.

screen-input = 0.

modify screen.

endif.

tareyes = 0.

elseif ptrwt is not initial.

if screen-group1 = 'SC1'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC2'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC5'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC6'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC7'.

screen-input = 1.

modify screen.

endif.

if screen-group1 = 'SC8'.

screen-input = 1.

modify screen.

endif.

if screen-group1 = 'S10'.

screen-input = 0.

modify screen.

endif.

endif.

  • GROSS WEIGHT

select single grwt from zsd_wb into grosswt where outdel = poutdel.

if grosswt ne '0.000'. .

if screen-group1 = 'SC1'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC2'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC5'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC6'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC7'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC8'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'S10'.

screen-input = 1.

modify screen.

endif.

elseif pgrwt is initial and tarewt ne '0.000'.

if screen-group1 = 'SC1'.

screen-input = 1.

modify screen.

endif.

if screen-group1 = 'SC2'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC5'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC6'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC7'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC8'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'S10'.

screen-input = 0.

modify screen.

endif.

elseif grossno = 1 .

if screen-group1 = 'SC1'.

screen-input = 1.

modify screen.

endif.

if screen-group1 = 'SC2'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC5'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC6'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC7'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC8'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'S10'.

screen-input = 0.

modify screen.

endif.

grossno = 0.

elseif grossyes = 1 .

if screen-group1 = 'SC1'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC2'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC5'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC6'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC7'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC8'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'S10'.

screen-input = 0.

modify screen.

endif.

grossyes = 0.

elseif pgrwt is not initial and ptrwt is not initial.

if screen-group1 = 'SC1'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC2'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC5'.

screen-input = 1.

modify screen.

endif.

if screen-group1 = 'SC6'.

screen-input = 1.

modify screen.

endif.

if screen-group1 = 'SC7'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC8'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'S10'.

screen-input = 0.

modify screen.

endif.

endif.

if ptrwt is initial and pgrwt is initial.

if screen-group1 = 'SC1'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC2'.

screen-input = 1.

modify screen.

endif.

if screen-group1 = 'SC5'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC6'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC7'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC8'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'S10'.

screen-input = 0.

modify screen.

endif.

endif.

if pgrwt is not initial and ( pmfbf is initial or poutno is initial ).

if screen-group1 = 'SC5'.

screen-input = 1.

modify screen.

endif.

if screen-group1 = 'S10'.

screen-input = 0.

modify screen.

endif.

endif.

else.

if screen-group1 = 'SC1'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC2'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC5'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC6'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC7'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'SC8'.

screen-input = 0.

modify screen.

endif.

if screen-group1 = 'S10'.

screen-input = 0.

modify screen.

endif.

endif.

endloop.

at selection-screen.

if poutdel is not initial.

select single vbeln from lips into poutno where vgbel = poutdel.

select single mblnr from mseg into pmfbf where mat_kdauf = poutdel.

pdes = poutdel.

select single * from zsd_wb into itab where outdel = poutdel.

if pgrwt is initial.

pgrwt = itab-grwt.

endif.

if ptrwt is initial.

ptrwt = itab-trwt.

endif.

pntwt = itab-ntwt.

refresh itab.

clear itab.

endif.

refresh itab.

clear itab.

case sscrfields.

when 'CLI1'.

perform grosswt.

itab-grwt = pgrwt.

if pgrwt gt ptrwt.

pntwt = pgrwt - ptrwt.

else.

pntwt = ptrwt - pgrwt.

endif.

itab-ntwt = pntwt .

grwt = pgrwt.

trwt = ptrwt.

ntwt = pntwt.

nwtstr = ntwt / 1000.

pdiff = ( pqty * 1000 ) - ntwt.

when 'CLI2'.

perform tarewt.

when 'CLI6'.

confirmflag = 2.

grossno = 1.

pgrwt = 0.

pdiff = 0.

when 'CLI5'.

itab-grwt = pgrwt.

if pgrwt gt ptrwt.

pntwt = pgrwt - ptrwt.

else.

pntwt = ptrwt - pgrwt.

endif.

itab-ntwt = pntwt .

grwt = pgrwt.

trwt = ptrwt.

ntwt = pntwt.

nwtstr = ntwt / 1000.

pdiff = ( pqty * 1000 ) - ntwt.

itab-grtime = sy-uzeit.

itab-grdate = sy-datum.

if ntwt gt 200.

update zsd_wb set grwt = itab-grwt grdate = itab-grdate grtime = itab-grtime ntwt = itab-ntwt diff = pdiff where outdel = poutdel.

clear itab.

concatenate sy-datum6(2) sy-datum4(2) sy-datum+0(4) into date separated by '.'.

grossyes = 1.

if sy-subrc = 0.

message 'Gross Weight Saved' type 'I'.

endif.

select single salesdoc from zsd_wb into doctemp where outdel = poutdel.

if doctemp = ''.

perform mfbf.

  • timeinit = sy-uzeit.

  • timenext = timeinit + 5.

while doctemp = ''.

select single mblnr from mseg into doctemp where mat_kdauf = poutdel.

  • IF sy-uzeit GT timenext.

  • MESSAGE 'Production Document Number generation Error' TYPE 'I'.

  • ENDIF.

endwhile.

count = 0.

  • timeinit = sy-uzeit.

  • timenext = timeinit + 5.

while count lt 3.

select count(*) from mseg into count where mblnr = doctemp.

  • IF sy-uzeit GT timenext.

  • MESSAGE 'Production Document Number generation Error' TYPE 'E'.

  • ENDIF.

endwhile.

update zsd_wb set salesdoc = doctemp where outdel = poutdel.

perform vl01n.

timeinit = sy-uzeit.

timenext = timeinit + 5.

while proddoc = ''.

select single vbeln from lips into proddoc where vgbel = poutdel.

  • IF sy-uzeit GT timenext.

  • MESSAGE 'Sales Document Number generation Error' TYPE 'E'.

  • ENDIF.

endwhile.

update zsd_wb set proddoc = proddoc where outdel = poutdel.

message 'Sales Document Number Generated' type 'I'.

endif.

else.

message 'Net Weight Less Than 200' type 'I'.

endif.

when 'CLI7'.

itab-outdel = poutdel.

if ptrwt is not initial.

itab-trwt = ptrwt.

itab-trtime = sy-uzeit.

itab-trdate = sy-datum.

itab-material = pmat.

append itab.

insert into zsd_wb values itab.

if sy-subrc = 0.

message 'Tare Weight Saved' type 'I'.

endif.

clear itab.

tareyes = 1.

endif.

leave to screen 0.

when 'CLI8'.

tareno = 1.

ptrwt = 0.

when 'CLI10'.

perform vf01.

endcase.

********************************************************************************

Points will be rewarded

regards

Ab