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

coding for transactional data in LSMW

Former Member
0 Likes
484

Thanks for ur reply . No I do not want to know the steps for LSMW for master data . I want to know the coding part in custom program for the LSMW for CS01 as it is transactional data . Thanks in advance

Thanks for ur reply . No I do not want to know the steps for LSMW for master data . I want to know the coding part in custom program for the LSMW for CS01 as it is transactional data . Thanks in advance

2 REPLIES 2
Read only

Former Member
0 Likes
425

Hi

see the sample program code for upload of BOM using direct input.

REPORT ZPPBDCP_BOM
line-size 150.
----------------------------------------------------------------------

Tables 
----------------------------------------------------------------------

Tables: bicsk, " BOM Header Data
bicsp, " BOM Item Data
bgr00, " Session Data
MARA,
makt. " Material Descriptions
----------------------------------------------------------------------

Internal Tables 
----------------------------------------------------------------------




Internal Table to hold bom data 

data : begin of it_bom_data occurs 0,

key(2), 
matnr(18), "MATERIAL
werks(4), "PLANT
stlan(1), "BOM USAGE
datuv(10), "DATE
bmenge(17), "QUANTITY
posnr(4), "ITEM NO
idnrk(18), "COMPONENT
menge(18), "QUANTITY
meins(3), "UNIT
postp(1), "Item category
ALPGR(2), "AltItemGroup
ALPST(1), "Strategy
ALPRF(2), "Priority
EWAHR(3), "Usage probability(%)
LGORT(4), "SLOC

end of it_bom_data.

----------------------------------------------------------------------

Start of selection 
----------------------------------------------------------------------
parameter : File like RLGRAP-FILENAME default 'BOM1.txt'.

Start-of-selection.
clear it_bom_data.
refresh it_bom_data.

*To Upload Flat file from presentation server

CALL FUNCTION 'UPLOAD'
EXPORTING
filename = 'C:\WINDOWS\Desktop\bom1.txt'
filetype = 'DAT'
TABLES
data_tab = it_bom_data
EXCEPTIONS
conversion_error = 1
invalid_table_width = 2
invalid_type = 3
no_batch = 4
unknown_error = 5
gui_refuse_filetransfer = 6
OTHERS = 7.

*--Open File on Application Server

open dataset File FOR OUTPUT IN TEXT MODE.
if sy-subrc ne 0.
write : / 'File could not be uploaded.. Check file name.'.
stop.
endif.
*--populate session header record
BGR00-STYPE = 0.
BGR00-GROUP = 'BOM'.
BGR00-MANDT = sy-mandt.
BGR00-USNAM = sy-uname.
BGR00-START = sy-datum.
BGR00-XKEEP = 'X'.
BGR00-NODATA = '/'.

transfer BGR00 to File.

loop at it_bom_data.

IF it_bom_data-MATNR NE ' ' AND it_bom_data-MATNR NE '/'.

at new key. 
read table it_bom_data index sy-tabix. 
clear mara-matnr.
select single matnr
into mara-matnr
from mara
where bismt eq it_bom_data-matnr.
*--populate bom header record
if sy-subrc eq 0.
bicsk-stype = 1.
bicsk-TCODE = 'CS01'.
bicsk-matnr = mara-matnr.
bicsk-werks = it_bom_data-werks.
bicsk-stlan = it_bom_data-stlan.
bicsk-datuv = it_bom_data-datuv.
bicsk-bmeng = it_bom_data-bmenge.

write:/ bicsk. 
transfer bicsk to File.
else.
write:/ it_bom_data-matnr,' Not exists'.
endif.

ENDIF.

endat. 
clear mara-matnr.
select single matnr
into mara-matnr
from mara
where bismt eq it_bom_data-idnrk.

*--populate bom details.
if sy-subrc eq 0.
bicsp-stype = 2.
bicsp-posnr = it_bom_data-posnr.
bicsp-idnrk = mara-matnr.
bicsp-menge = it_bom_data-menge.
bicsp-meins = it_bom_data-meins.
bicsp-postp = it_bom_data-postp.
bicsp-ALPGR = it_bom_data-ALPGR.
bicsp-ALPST = it_bom_data-ALPST.
bicsp-ALPRF = it_bom_data-ALPRF.
bicsp-EWAHR = it_bom_data-EWAHR.
bicsp-LGORT = it_bom_data-LGORT.


write:/ bicsp. 
transfer bicsp to File.
else.
write:/ it_bom_data-idnrk,' Not exists'.
endif.

endloop.

close dataset File.

With Regards

Nikunj Shah

Read only

Former Member
0 Likes
425

hi,

go thru the link :

Edited by: Poonam Naik on Jul 16, 2008 1:00 PM