11-14-2006 2:06 AM
Hi,
here i am picking the file from APPS and also inbound IDOC creation.
just anyone check my code and give some suggestions in the areas of impovemet technically.
thanks
report znsd007.
*tables : zih001, zid001.
tables: zstbm_lots, zstbm_stages, zibmordertype.
data: t_zstbmlot like zstbm_lots occurs 0 with header line,
t_zstbmstage like zstbm_stages occurs 0 with header line.
parameters :
fromdir like rsmrgstr-path lower case default
'/apps/MQBridge/idocmsgs/',
fromfile like rsmrgstr-name lower case default '*.txt',
todir like rsmrgstr-path lower case default
'/apps/MQBridge/idoctemp/',
tofile like edi_path-pthnam lower case no-display,
procdir like rsmrgstr-path lower case default
'/apps/MQBridge/idocproc/',
procfile like edi_path-pthnam lower case no-display,
toport like edipo-port no-display.
constants: c_tst(7) value 'IBM_TST',
c_bi(6) value 'IBM_BI',
c_mrk(7) value 'IBM_MRK',
c_sbt(7) value 'IBM_SBT'.
data: w_tst(1) type c,
w_bi(1) type c,
w_mrk(1) type c,
w_sbt(1) type c,
w_err(1) type c,
w_processcd(20) type c.
data :
file_list like rsfillst occurs 100 with header line,
pattern like rsmrgstr-name,
tmpfile(128),
begin of in1 occurs 100,
dir(128),
file(128),
data(63000) occurs 0,
data(1063) occurs 0,
end of in1,
str(63000),
*str(1063),
str2 like str,
*outfile(63000) occurs 100 with header line,
*outfile(128),
crtl like edi_dc40,
*counter type i,
segment like edi_dd40-segnam,
segment_no(6) type n,
data like edi_dd40-sdata,
productid_ecid(25),
edidd40 like edi_dd40.
field-symbols : <fs2>,<fs>.
data: messtab like bdcmsgcoll occurs 0 with header line.
&----
start-of-selection.
&----
break-point.
perform getfile_list tables file_list using fromdir fromfile.
delete file_list where type = 'directory'.
toport = 'FILE'.
loop at file_list.
perform getfile tables in1 using file_list.
endloop.
sort in1 by dir file.
check not in1[] is initial.
*----
loop at in1.
at new file.
concatenate todir '/' in1-file into tofile.
replace '//' with '/' into tofile.
condense tofile no-gaps.
open dataset tofile for output in text mode encoding default.
if sy-subrc ne 0.
message e168(j4) with tofile.
endif.
Copy the populated dataset to be saved into a processed directory
concatenate procdir '/' in1-file into procfile.
replace '//' with '/' into procfile.
condense procfile no-gaps.
open dataset procfile for output in text mode encoding default.
if sy-subrc ne 0.
message e168(j4) with procfile.
endif.
clear : edidd40, crtl.
crtl-tabnam = 'EDI_DC40'.
crtl-mandt = sy-mandt.
crtl-docrel = '620'.
crtl-direct = '02'.
concatenate 'SAP' sy-sysid into crtl-rcvpor.
crtl-rcvprt = 'LS'.
crtl-rcvprn = 'SSD_PN0001'.
crtl-mestyp = 'ZCPAOC'.
crtl-idoctyp = 'ZCPAOC01'.
crtl-sndpor = 'SSD0000001'.
crtl-sndprt = 'LS'.
crtl-sndprn = 'SSD_PN0001'.
transfer crtl to : procfile.
clear segment_no.
endat.
refresh t_zstbmlot.
refresh t_zstbmstage.
loop at in1-data into str.
clear edidd40.
edidd40-mandt = sy-mandt.
check not str is initial.
search str for ','.
if sy-subrc = 0.
segment = str+0(sy-fdpos).
sy-fdpos = sy-fdpos + 1.
data = str+sy-fdpos.
case segment.
when 'ZSTBM_LOT'.
clear t_zstbmlot.
split data at ',' into t_zstbmlot-aufnr
t_zstbmlot-ordertype
t_zstbmlot-plant
t_zstbmlot-productid
t_zstbmlot-ec
t_zstbmlot-lotlabel
t_zstbmlot-other_lot_label1
t_zstbmlot-orderqty
t_zstbmlot-customercd
t_zstbmlot-srcevendor
t_zstbmlot-waferid
t_zstbmlot-lotowner
t_zstbmlot-lottype
t_zstbmlot-prty
t_zstbmlot-planstart
t_zstbmlot-planfinish
t_zstbmlot-linecodejc
t_zstbmlot-qualitycod
t_zstbmlot-poi
t_zstbmlot-poi_text
t_zstbmlot-cot
t_zstbmlot-cot_text
t_zstbmlot-lotprodtyp
t_zstbmlot-productcd
t_zstbmlot-familycd
t_zstbmlot-lot_cmmnt
t_zstbmlot-devassem
t_zstbmlot-devassemtx
t_zstbmlot-numdevices
t_zstbmlot-date_of_mfg
t_zstbmlot-pur_order
t_zstbmlot-process_cd.
append t_zstbmlot.
edidd40-segnam = 'ZSTBM_LOT'.
edidd40-hlevel = '2'.
segment_no = segment_no + 1.
edidd40-segnum = segment_no.
edidd40-sdata = t_zstbmlot.
when 'ZSTBM_STAGE'.
clear t_zstbmstage.
split data at ',' into t_zstbmstage-stage.
move data to t_zstbmstage-stage.
append t_zstbmstage.
edidd40-segnam = 'ZSTBM_STAGE'.
edidd40-hlevel = '3'.
edidd40-psgnum = segment_no.
edidd40-sdata = t_zstbmstage.
endcase.
transfer edidd40 to : procfile.
endif.
endloop.
t_zstbmlot-date_of_mfg = t_zstbmlot-date_of_mfg(8).
Determine the order type here using t_zstbmstage and t_zstbmlot
and update order type int t_zstbmlot.
clear w_tst. clear w_bi. clear w_mrk. clear w_sbt. clear w_err.
clear w_processcd.
loop at t_zstbmstage.
if t_zstbmstage-stage = c_tst.
w_tst = 'X'.
elseif t_zstbmstage-stage = c_bi.
w_bi = 'X'.
elseif t_zstbmstage-stage = c_mrk.
w_mrk = 'X'.
elseif t_zstbmstage-stage = c_sbt.
w_sbt = 'X'.
endif.
endloop.
if t_zstbmlot-process_cd = 'SubStock Release' or
t_zstbmlot-process_cd = 'SUBSTOCK RELEASE'.
w_processcd = 'SUBSTOCK RELEASE'.
endif.
select single * from zibmordertype
into zibmordertype where
ibm_tst = w_tst and
ibm_bi = w_bi and
ibm_mrk = w_mrk and
ibm_sbt = w_sbt and
processcd = w_processcd.
if sy-subrc = 0.
t_zstbmlot-ordertype = zibmordertype-ordertype.
else.
write: 'Order type not determined for lot label:',
t_zstbmlot-lotlabel.
endif.
Put into zih001 to create idoc
clear : edidd40, crtl.
crtl-tabnam = 'EDI_DC40'.
crtl-mandt = sy-mandt.
crtl-docrel = '620'.
crtl-direct = '02'.
concatenate 'SAP' sy-sysid into crtl-rcvpor.
crtl-rcvprt = 'LS'.
crtl-rcvprn = 'SSD_PN0001'.
crtl-mestyp = 'ZCPAOC'.
crtl-idoctyp = 'ZCPAOC01'.
crtl-sndpor = 'SSD0000001'.
crtl-sndprt = 'LS'.
crtl-sndprn = 'SSD_PN0001'.
transfer crtl to : tofile.
clear : edidd40.
edidd40-segnam = 'ZIH001'.
edidd40-mandt = sy-mandt.
edidd40-hlevel = 1.
edidd40-sdata = t_zstbmlot.
transfer edidd40 to : tofile.
check not in1-data[] is initial.
at end of file.
close dataset : procfile, tofile.
call function 'EDI_DATA_INCOMING'
EXPORTING
pathname = tofile
port = toport.
check sy-subrc = 0.
Remove file from idocmsgs directory after idoc processing
clear tmpfile.
concatenate in1-dir '/' in1-file into tmpfile.
replace '//' with '/' into tmpfile.
condense tmpfile no-gaps.
delete dataset tmpfile.
endat.
endloop.
&----
form getfile_list tables intab1 structure rsfillst using inval1 inval2 .
&----
call function 'SUBST_GET_FILE_LIST'
exporting
dirname = inval1
filenm = ''
pattern = inval2
tables
file_list = intab1
EXCEPTIONS
ACCESS_ERROR = 1
OTHERS = 2
.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
endform. "getfile_list
&----
*& Form getfile
&----
text
----
-->P_FIELD_LIST text
----
form getfile tables intab1 structure in1
using inval structure file_list.
data : xfile(128).
clear xfile.
concatenate inval-dirname '/' inval-name into xfile.
replace '//' with '/' into xfile.
open dataset xfile for input message messtab
in text mode encoding default.
check sy-subrc = 0.
clear : str, intab1. refresh intab1-data.
do.
replace ALL OCCURRENCES OF
cl_abap_char_utilities=>horizontal_tab
in xfile with space.
replace all occurrences of '#' in xfile with space.
replace all occurrences of ':' in xfile with space.
replace all occurrences of '_' in xfile with space.
*
read dataset xfile into str.
replace all occurrences of '#' in str with space.
replace all occurrences of ':' in str with space.
replace all occurrences of '_' in str with space.
if sy-subrc <> 0.
exit.
endif.
intab1-file = inval-name.
intab1-dir = inval-dirname.
append str to intab1-data.
enddo.
if not intab1-data[] is initial.
append intab1.
endif.
close dataset xfile.
endform. " getfile
----
form showdata changing inval indat.
----
data : xxtab like sval occurs 100 with header line,
ff0(100), ff1(30), ff2(30), yesno.
inval = indat.
do.
assign component sy-index of structure inval to <fs>.
Z1STB_HDR TO <FS>.
if sy-subrc <> 0. exit. endif.
describe field <fs> help-id ff0.
split ff0 at '-' into ff1 ff2.
clear xxtab.
xxtab-tabname = ff1. xxtab-fieldname = ff2. xxtab-value = <fs>.
append xxtab.
enddo.
call function 'POPUP_GET_VALUES_USER_HELP'
EXPORTING
popup_title = 'Enter Order Information'
TABLES
fields = xxtab
EXCEPTIONS
error_in_fields = 1
others = 2.
if sy-subrc <> 0 .
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endform. "showdata
11-14-2006 2:37 AM
hi
i can see views are increasing inmy post. bu ti am not unable to see any when i enter. where are the views stored for this thread. now i am just clicking the reply to this thread.
please let me know where can i see th eviews.
thanks