‎2006 Oct 15 3:06 AM
Hi
can anyone check changes to done in the following code?
here i am writing file in apps.
form writefile.
data: msg(100).
data: todir like rsmrgstr-path value '/apps/MQBridge/idocproc/'.
data: tofile like edi_path-pthnam.
clear msg.
concatenate todir 'amkor4b2' sy-datum sy-uzeit w_seqno '.xml'
into tofile.
open dataset tofile for output in text mode encoding default
message msg.
if sy-subrc ne 0.
message e168(j4) with tofile.
else.
write:/ 'File transferred:', tofile.
endif.
loop at wlines.
transfer wlines to tofile.
endloop.
close dataset tofile.
endform. "WriteFile
‎2006 Oct 15 7:15 AM
Hello
Please make highlighted changes. This is to avoid writing to the file incase of failure to open file.
form writefile.
data: msg(100).
data: todir like rsmrgstr-path value '/apps/MQBridge/idocproc/'.
data: tofile like edi_path-pthnam.
clear msg.
concatenate todir 'amkor4b2' sy-datum sy-uzeit w_seqno '.xml' into tofile.
open dataset tofile for output in text mode encoding default message msg.
if sy-subrc ne 0.
message e168(j4) with tofile.
else.
<b> loop at wlines.
transfer wlines to tofile.
endloop.
close dataset tofile.</b>
write:/ 'File transferred:', tofile.
endif.
endform. "WriteFileKind Regards
Eswar
‎2006 Oct 15 7:15 AM
Hello
Please make highlighted changes. This is to avoid writing to the file incase of failure to open file.
form writefile.
data: msg(100).
data: todir like rsmrgstr-path value '/apps/MQBridge/idocproc/'.
data: tofile like edi_path-pthnam.
clear msg.
concatenate todir 'amkor4b2' sy-datum sy-uzeit w_seqno '.xml' into tofile.
open dataset tofile for output in text mode encoding default message msg.
if sy-subrc ne 0.
message e168(j4) with tofile.
else.
<b> loop at wlines.
transfer wlines to tofile.
endloop.
close dataset tofile.</b>
write:/ 'File transferred:', tofile.
endif.
endform. "WriteFileKind Regards
Eswar
‎2006 Oct 15 7:42 AM
Hi Eswar,
thanks for the suggestion. and also can u check the following code too for any changes
form getdata.
data: wrecord type i.
data: wtime type t.
data: wtoday type d.
move sy-datum to wtoday.
move sy-uzeit to wtime.
if wtime eq '000000'.
wtoday = wtoday - 1.
endif.
status = 1.
if sy-batch = 'X'.
select mblnr mjahr bldat cputm from mkpf into table mkpftbl where bldat eq wtoday and tcode2 eq ctcode2.
else.
select mblnr mjahr bldat cputm from mkpf into table mkpftbl where mblnr in mblnr and mjahr in mjahr and tcode2 eq ctcode2.
endif.
describe table mkpftbl lines wrecord.
if wrecord > 0.
loop at mkpftbl.
select zeile matnr werks charg menge from mseg
into corresponding fields of table msegtbl
for all entries in mkpftbl
where mblnr eq mkpftbl-wmblnr and mjahr eq mkpftbl-wmjahr and
bwart eq cbwart and werks eq splant.
endloop.
status = 0.
endif.
endform. "GetData
‎2006 Oct 15 8:43 AM
HI Nihi
Please check this...
form getdata.
data: wrecord type i.
data: wtime type t.
data: wtoday type d.
move sy-datum to wtoday.
move sy-uzeit to wtime.
if wtime eq '000000'.
wtoday = wtoday - 1.
endif.
status = 1.
if sy-batch = 'X'.
select mblnr mjahr bldat cputm
from mkpf
into table mkpftbl
where bldat eq wtoday
and tcode2 eq ctcode2.
else.
select mblnr mjahr bldat cputm
from mkpf
into table mkpftbl
where mblnr in mblnr
and mjahr in mjahr
and tcode2 eq ctcode2.
endif.
<b>if not mkpftbl[] is initial.
select zeile matnr werks charg menge
from mseg
into corresponding fields of table msegtbl
for all entries in mkpftbl
where mblnr eq mkpftbl-wmblnr
and mjahr eq mkpftbl-wmjahr
and bwart eq cbwart
and werks eq spalnt.
status = 0.
endif.</b>
<b>*describe table mkpftbl lines wrecord.
*if wrecord > 0.
*loop at mkpftbl.
*select zeile matnr werks charg menge from mseg
*into corresponding fields of table msegtbl
*for all entries in mkpftbl
*where mblnr eq mkpftbl-wmblnr and mjahr eq mkpftbl-wmjahr and
*bwart eq cbwart and werks eq splant.
*endloop.
*status = 0.
*endif.</b>endform. "GetData
Also try to avoid using CORRESPONDING FIELDS of table MSEGTBL, if the structure is same.
Kind Regards
Eswar