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 program for vendor master

Former Member
0 Likes
1,175

Hi Friends,

Could you please help me in this.

actually i have a program like this:

i have to download the data from an excel sheet and reformat it and output into a text file so that the data can be uploaded into vendor master using standard progarm

<b>"RFBIKR00".</b>

i have written the program like this:

but in the middle when formatting the data...i'm facing the problem....

plz help me in solving that...

thnx very very much...........

the program i wrote is like this:

<b>

tables: lfa1,

lfb1,

lfm1,

lfbk,

bnka,

bgr00,

blf00,

blfa1,

blfb1,

blfbk,

blfm1,

blfb5,

blfbw,

blfei,

blfza,

blflr,

blfm2,

bwyt3,

bwyt1,

blfat.

*--- Internal table for spread sheet.

data: t_filedata like alsmex_tabline occurs 0 with header line.

*--- Internal table for Vendor Master Data in Spread Sheet.

data: begin of t_sheet occurs 0,

name1 like lfa1-name1, "vendor name1

name2 like lfa1-name2, "vendor name2

altkn like lfb1-altkn, "previous master record number

bukrs like lfb1-bukrs, "company code

ekorg like lfm1-ekorg, "purchase organization

ktokk like lfa1-ktokk, "account group

stras like lfa1-stras, "street

street4 like lfa1-name4, "street4

pfach like lfa1-pfach, "po box

ort01 like lfa1-ort01, "city

regio like lfa1-regio, "region

pstlz like lfa1-pstlz, "postal code

land1 like lfa1-land1, "country

telf1 like lfa1-telf1, "first telephone number

telfx like lfa1-telfx, "first fax number

stcd1 like lfa1-stcd1, "fed tax ID#

brsch like lfa1-brsch, "commodity code

akont like lfb1-akont, "reconciliation account

mindk like lfb1-mindk, "monitory indicator

zwels like lfb1-zwels, "payment method

reprf like lfb1-reprf, "check double invoice

banka like bnka-banka, "bank name

stret like bnka-stras, "house number and street

city like bnka-ort01, "city

provz like bnka-provz, "bank state

banks like lfbk-banks, "bank country

swift like bnka-swift, "swift code

bankl like lfbk-bankl, "aba#

bankn like lfbk-bankn, "bank account no

zterm like lfb1-zterm, "payment terms

terms like lfm1-zterm, "terms of payment key

end of t_sheet.

*--- Internal table for Vendor Master data in Text File.

data: begin of t_file occurs 0,

s_session type bgr00,

s_header type blf00,

s_blfa1 type blfa1,

s_blfb1 type blfb1,

s_blfbk type blfbk,

s_blfm1 type blfm1,

s_blfbk type blfbk,

s_blfb5 type blfb5,

s_blfza type blfza,

s_blfm1 type blfm1,

s_blfat type blfat,

s_bwyt1 type bwyt1,

s_bwyt3 type bwyt3,

s_blfm2 type blfm2,

s_blfei type blfei1,

s_blfbw type blfbw,

s_blflr type blflr,

end of t_file.

----


          • SELECTION SCREEN *****

----


*---Selection Parameters.

selection-screen begin of block b1 with frame title title1.

parameters: p_xlfile like rlgrap-filename.

parameters: p_txfile type rlgrap-filename.

selection-screen end of block b1.

----


          • INITIALIZATION *****

----


initialization.

*---Initialize text fields for selection-screen.

title1 = 'Selection Parameters'.

----


          • AT SELECTION-SCREEN *****

----


at selection-screen.

at selection-screen on p_xlfile.

perform check_file using p_xlfile.

at selection-screen on value-request for p_xlfile.

perform select_file using p_xlfile.

----


          • START-OF-SELECTION *****

----


start-of-selection.

clear t_sheet.

refresh t_sheet.

*---Upload Spreadsheet.

perform read_file using p_xlfile.

*---Process data into formatted internal table.

perform format_data.

????????????????????????????????????????

?????????????????????????????????????

append t_file.

clear t_file.

endloop.

*---Download data to Text file.

perform download_data.

----


          • TOP-OF-PAGE *****

----


top-of-page.

perform top_of_page.

----


          • S-U-B-R-O-U-T-I-N-E-S *****

----


  • Form TOP_OF_PAGE

----


    • Calling the Standard Report Header

----


form top_of_page.

perform header using 'CREATE FILE FOR'

'VENDOR MASTER UPLOAD'

132.

skip 2.

endform. "TOP_OF_PAGE

----


    • Form check_file **

----


    • Checking the File entered **

----


data: p_filename type string.

form check_file using p_filename.

*---The entered File must be Excel spreadsheet.

data: l_length type i,

l_ext(4) type c.

l_length = strlen( p_xlfile ).

subtract 4 from l_length.

l_ext = p_xlfile+l_length(4).

translate l_ext to upper case.

if l_ext <> '.XLS'.

message e009 with 'Only Excel spreadsheets are supported'.

endif.

*---Check if File exits and not empty.

data: l_return(10) type c.

CALL FUNCTION 'WS_QUERY'

EXPORTING

FILENAME = p_filename

QUERY = 'FL'

IMPORTING

RETURN = l_return

EXCEPTIONS

INV_QUERY = 1

NO_BATCH = 2

FRONTEND_ERROR = 3

OTHERS = 4

.

IF l_return = space or l_return = '0'.

message e530(pj) with p_filename.

ENDIF.

endform. "CHECK_FILE

----


    • Form select_file **

----


form select_file using p_filename like rlgrap-filename.

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

EXPORTING

  • PROGRAM_NAME = SYST-REPID

  • DYNPRO_NUMBER = SYST-DYNNR

  • FIELD_NAME = ' '

STATIC = 'X'

MASK = ',MS Excel (.xls),.xls.'

CHANGING

FILE_NAME = p_filename

EXCEPTIONS

MASK_TOO_LONG = 1

OTHERS = 2

.

IF SY-SUBRC <> 0.

MESSAGE e838(29) with p_filename.

ENDIF.

endform. "SELECT_FILE

----


    • Form read_file **

----


form read_file using p_filename like rlgrap-filename.

*---Display status message for User.

CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'

EXPORTING

TEXT = 'Uploading Spreadsheet'

.

*---Upload spreadsheet.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

FILENAME = p_filename

I_BEGIN_COL = 1

I_BEGIN_ROW = 1

I_END_COL = 256

I_END_ROW = 65536

TABLES

INTERN = t_filedata

EXCEPTIONS

INCONSISTENT_PARAMETERS = 1

UPLOAD_OLE = 2

OTHERS = 3

.

IF t_filedata[] is initial.

message i009 with 'NO DATA FOUND IN FILE' p_filename.

stop.

ENDIF.

sort t_filedata by row col.

endform. "READ_FILE

----


    • Form format_data **

----


form format_data.

data: l_index type i.

field-symbols: <fs1>.

*---Display status message for user.

CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'

EXPORTING

TEXT = ' Processing Data...'

.

loop at t_filedata.

l_index = t_filedata-col.

assign component l_index of structure t_sheet to <fs1>.

<fs1> = t_filedata-value.

at end of row.

append t_sheet.

clear t_sheet.

endat.

endloop.

refresh t_filedata.

free t_filedata.

endform. "FORMAT_DATA

----


    • Form download_data.

**

----


form download_data.

OPEN DATASET p_txfile for OUTPUT.

LOOP at t_file.

TRANSFER t_file to p_txfile.

ENDLOOP.

CLOSE DATASET p_txfile.

IF SY-SUBRC = 0.

WRITE: / 'Excel to Textfile for Vendor Master Upload: ', P_TXFILE.

ENDIF.

endform. "DOWNLOAD_DATA</b>

5 REPLIES 5
Read only

Former Member
0 Likes
788

What's exactly the problem??? Do you have any compilation problem? or you don't know how to achieve something?

Greetings,

Blag.

Read only

0 Likes
788

hi.

the problem is i have to arrange the data into the format of the text file, which is to be uploaded into the vendor master.

please run the "sxdb" transaction, then select 40 in the next screen for vendor master.

in the next screen -- please select a filename and click on create...then a text file will be created .

in that format i have to format this data.

thnx

Read only

0 Likes
788

could please you tell me, if you had look into that program?

thnx

Read only

christian_wohlfahrt
Active Contributor
0 Likes
788

Hi!

You don't need to program the 'translation' from a file into input data for RFBIKR00 yourself. SAP has done this, so that you can do this (nearly) without programming. If you need some special conversion rules, then you can add some coding, but most is possible without.

Have a look at transaction LSMW. It's not so complicated it looks at the first time. Just look at <a href="http://help.sap.com/saphelp_erp2004/helpdata/en/ad/2d54a41d7011d2b42e006094b944c8/frameset.htm">help</a> for the way to use LSMW.

Regards,

Christian

P.S.: sorry for lost your efforts, but you should switch to LSMW

Read only

0 Likes
788

hi,

for this you need to use lsmw .it is also uses the same program but there you have to use option 6 for Maintain Fixed Values, Translations, User-Defined Routines.

here is the simple document..

check it.

http://www.scmexpertonline.com/downloads/SCM_LSMW_StepsOnWeb.doc

Regards

vijay