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

upload data into CS01,How to upload

Former Member
0 Likes
1,553

Hi ,

I want to upload data from legacy system to SAP...........Tcode is CS01 (BOM).

whether I have to use BAPI , LSMW or BDC. which method is preferable and why?.

I am trying to upload the data using LSMW. but in CS01 transaction, I am unable to find STOP-IDNRK ,STOP-MENGE,STOP-MEINS and STOP-ERSKZ this fields.

explain about BOM in brief.......

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,238

Hi,

Use BDC with session method. Its help full to you that if any errors occurs in uploading data, that errors can capture in log file and find out that error details.

For more information please check the following link;

http://www.sap-img.com/abap/program-loads-the-bill-of-material.htm

Regards,

Bhaskar

Hi ,

I want to upload data from legacy system to SAP...........Tcode is CS01 (BOM).

whether I have to use BAPI , LSMW or BDC. which method is preferable and why?.

I am trying to upload the data using LSMW. but in CS01 transaction, I am unable to find STOP-IDNRK ,STOP-MENGE,STOP-MEINS and STOP-ERSKZ this fields.

explain about BOM in brief.......

7 REPLIES 7
Read only

Former Member
0 Likes
1,238

perfer bdc for it...coz for looping at at the item level u need bdc..

regds

Read only

0 Likes
1,238

Thanks.......

what about BAPI. Do u have any idea about BAPI.

Read only

Former Member
0 Likes
1,238

Hi

See the sample BDC code for creation of BOM

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.

Reward points if useful

Regards

Anji

Read only

0 Likes
1,238

Hello,

Thanks, But I need to upload the data into SAP . not into application server as a file.

Read only

Former Member
0 Likes
1,239

Hi,

Use BDC with session method. Its help full to you that if any errors occurs in uploading data, that errors can capture in log file and find out that error details.

For more information please check the following link;

http://www.sap-img.com/abap/program-loads-the-bill-of-material.htm

Regards,

Bhaskar

Read only

0 Likes
1,238

Hello Mr. Bhaskar,

Can i simply copy the code and execute it existing recording will work or i have to do the new recording first to upload the data.

Regards

Vikas

Read only

Former Member
0 Likes
1,238

Or go for LSMW and choose from either BDC, BAPI or IDOC processing.

I guess it depends on what you're comfortable with.