Application Development and Automation 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: 
Read only

changes

Former Member
0 Likes
514

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
476

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. "WriteFile

Kind Regards

Eswar

3 REPLIES 3
Read only

Former Member
0 Likes
477

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. "WriteFile

Kind Regards

Eswar

Read only

0 Likes
476

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

Read only

0 Likes
476

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