Skip to Content
0
Former Member
Oct 15, 2006 at 09:05 AM

code formation

26 Views

Hi,

could anyone check my code below and suggest the changes for it interms of performance wise and also the pattern of writting the code. i want to cross check my code before i go for testing

thanks in adance.

form checkdata.

data: wrecord type i.

data:

begin of tmpkey,

mandt like sy-mandt,

wmblnr like mseg-mblnr, "Material Document Number

wmjahr like mseg-mjahr, "Material Document Year

wzeile like mseg-zeile, "Item in Material Document

end of tmpkey.

select * from z4b2 into table t_z4b2.

describe table msegtbl lines wrecord.

if wrecord > 0.

loop at msegtbl.

clear tmpkey.

move sy-mandt to tmpkey-mandt.

move msegtbl-wmblnr to tmpkey-wmblnr.

move msegtbl-wmjahr to tmpkey-wmjahr.

move msegtbl-wzeile to tmpkey-wzeile.

read table t_z4b2 with key tmpkey.

if sy-subrc = 0.

delete msegtbl.

endif.

endloop.

endif.

endform. "CheckDat

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

form getibminfo.

data: wrecord type i.

describe table msegtbl lines wrecord.

if wrecord > 0.

loop at msegtbl.

refresh: t_val_tab.

call function 'QC01_BATCH_VALUES_READ'

EXPORTING

i_val_matnr = msegtbl-wmatnr

i_val_werks = msegtbl-wwerks

i_val_charge = msegtbl-wcharg

TABLES

t_val_tab = t_val_tab

EXCEPTIONS

no_class

internal_error

no_values

no_chars.

if sy-subrc = 0.

read table t_val_tab with key atnam = 'SUBLOTTYPE'.

if sy-subrc = 0.

if t_val_tab-atwrt eq sublottype.

move msegtbl to 4b2tbl.

append 4b2tbl.

clear 4b2tbl.

endif.

endif.

endif.

endloop.

endif.

refresh mkpftbl.

refresh msegtbl.

endform. "GetIBMInfo

*&----


*& Form GetSeqNo

*&----


form getseqno.

data: wcount(6) type n.

data: wrecord(6) type n.

describe table t_z4b2 lines wrecord.

read table t_z4b2 index wrecord.

write t_z4b2-wseqno+5(6) to wrecord.

  • wrecord = wrecord + 1.

describe table 4b2tbl lines wcount.

if wcount > 0.

loop at 4b2tbl.

at new wmblnr. wrecord = wrecord + 1. endat.

concatenate preatsg wrecord into 4b2tbl-wseqno.

modify 4b2tbl.

move 4b2tbl to z4b2.

insert z4b2.

clear 4b2tbl.

clear z4b2.

endloop.

endif.

endform. "GetSeqNo

&----


*& Form PutInfo

&----


form putinfo.

data: wrecord type i.

data: dtmp1(10) type c.

data: dtmp2(8) type c.

data: ttmp1(8) type c.

data: ttmp2(6) type c.

describe table 4b2tbl lines wrecord.

if wrecord > 0.

loop at 4b2tbl.

write 4b2tbl-wbldat to dtmp1.

concatenate dtmp16(4) dtmp1(2) dtmp13(2) into dtmp2.

write 4b2tbl-wbldat to ttmp1.

concatenate ttmp10(2) ttmp13(2) ttmp1+6(2) into ttmp2.

concatenate dtmp2 'T' ttmp2 '.000Z' into datetime.

at new wmblnr.

refresh wlines.

perform writeline1.

perform writeline2_1.

endat.

perform writeline2_2.

w_seqno = 4b2tbl-wseqno.

at end of wmblnr.

perform writeline2_3.

perform writeline3.

perform writefile.

endat.

endloop.

endif.

endform. "PutInfo