Conversion - Vendor Master
Hi All,
Is there any way where we can swap the vendor numbers - VN and OA?
Requirement - After the conversion, it has been observed that the wrong numbers got uploaded into the system.
Thanks
You can change the vendor account group but not the vendor number. You may be able to achieve your requirement by changing the account groups.
Lakshman
Similar Messages
-
Hi All,
I want to upload vendor master data from legacy system. Vendor number is internal assignment. Can any one suggest me the file formats used in any of your earlier projects. ie how general data, company code data, purchasing organization data, banking data etc was provided by legacy system.
Thanks,
DeeptiHi All,
Sorry if my question was not clear. My file will be tab de limited and I am looking for a person who has already done a vendor master conversion. I am in the process of proposing the file structure. If all the data is available in a single flat file and there are multiple company codes, purchasing organization available, vendor will get created only for the first company code. For the next company code, purchasing organization for the same vendor, LSMW session created will fail.
I would like to know the different file structures used in your earlier projects.
Thanks,
Deepthi -
Vendor Master Extraction from Legacy
Hi guys,
We have 2 different legacy systems here (4.5b and 4.6c) and I am trying to extract the vendor master from both of them and integrate them into the new mysap2004.
What is the best way to extract the vendor master along with the address , punchasing doc, bank details, partner functions,etc ? Any sample program for vendor master extraction is most welcome. Here is my extract layout.
ADDRESS
Source File /Table Name Field Name Field Type / Length Format Rule / Logic
Source File /Table Name Field Name Field Type / Length Format Rule / Logic
SZA1_D0100 Title (TITLE_MEDI) CHAR/30 Not used
ADDR1_DATA Name (NAME1) CHAR/40 Bring values over as is.
ADDR1_DATA Name (NAME 2) CHAR/40 Bring values over as is.
ADDR1_DATA Name (NAME 3) CHAR/40 Bring values over as is.
ADDR1_DATA Name (NAME 4) CHAR/40 Bring values over as is.
ADDR1_DATA Search Term 1 (SORT1) CHAR/20 Convert to HPC methodology.
O-First 8 char. of vendor name
R- First 8 char. of vendor name
B- First 8 char. of vendor name
ADDR1_DATA Search Term 2 (SORT2) CHAR/20 Bring values over as is.
ADDR1_DATA Street/House Number
(Street) CHAR/60 Bring values over as is.
ADDR1_DATA House Number
(HOUSE_NUM1) CHAR/10 Bring values over as is.
ADDR1_DATA Building (number or code)
(BUILDING) CHAR/20 Bring values over as is.
ADDR1_DATA Room or apartment number
(ROOMNUMBER) CHAR/10 Bring values over as is.
ADDR1_DATA Floor in building
(FLOOR) CHAR/10 Bring values over as is.
ADDR1_DATA c/o name
(NAME_CO) CHAR/40 Bring values over as is.
ADDR1_DATA Street 2
(STR_SUPPL1) CHAR/40 Bring values over as is.
ADDR1_DATA Street 3
(STR_SUPPL2) CHAR/40 Bring values over as is.
ADDR1_DATA Street 4
(STR_SUPPL3) CHAR/40 Bring values over as is.
ADDR1_DATA Street 5
(LOCATION) CHAR/40 Bring values over as is.
ADDR1_DATA City
(CITY1) CHAR/40 Bring values over as is.
ADDR1_DATA District
(CITY2) CHAR/40 Bring values over as is.
ADDR1_DATA City (different from postal city)
HOME_CITY CHAR/40 Bring values over as is.
ADDR1_DATA City postal code
(POST_CODE1) CHAR/10 Zip Code. Bring values over as is.
ADDR1_DATA Country
(COUNTRY) CHAR/3 Bring values over as is.
ADDR1_DATA Region (State, Province, County)
(REGION) CHAR/3 E.g., NJ New Jersey, CO Colorado, etc. Bring values over as is.
ADDR1_DATA Time Zone
(TIME_ZONE) CHAR/6 Bring values over as is.
ADDR1_DATA Transportation Zone
(TRANSPZONE) CHAR/10 Bring values over as is.
ADDR1_DATA Regional Structure Group
(REGIOGROUP) CHAR/8 Bring values over as is.
ADDR1_DATA P. O. Box
(PO_BOX) CHAR/10 Bring values over as is.
ADDR1_DATA P.O. Box Postal Code
(POST_CODE2) CHAR/10 Bring values over as is.
ADDR1_DATA Language Key
(LANGU) LANG/1 Bring values over as is.
SZA1_D0100 Telephone
(TEL_NUMBER) CHAR/30 Bring values over as is.
SZA1_D0100 Telephone Number Extension
(TEL_EXTENS) CHAR/10 Bring values over as is.
SZA1_D0100 Fax
(FAX_NUMBER) CHAR/30 Bring values over as is.
SZA1_D0100 Fax Extension Number
(FAX_EXTENS) CHAR/10 Bring values over as is.
SZA1_D0100 E-mail
(SMTP_ADDR) CHAR/240 Bring values over as is.
ADDR1_DATA Standard Communication Type
(DEFLT_COMM) CHAR/3 Bring values over as is.
ADDR1_DATA Data Line
(EXTENSION1) CHAR/40 Not used. Do not bring over field values.
Note: This field will be available to populate with other data during the conversion.
ADDR1_DATA Telebox
(EXTENSION2 CHAR/40 Not used. Do not bring over field values.
Note: This field will be available to populate with other data during the conversion.
ADDR1_DATA Comments
(REMARK) CHAR/50 Bring values over as is.
CONTROL
Source File /Table Name Field Name Field Type / Length Format Rule / Logic
LFA1 Customer
(KUNNR) CHAR/10 Bring values over as is.
LFA1 Authorization
(BEGRU) CHAR/4 It is to be determined if this field will be used in the future. If yes, bring values over as is from HPC and populate with vendor account group code for Foods.
LFA1 Trading Partner
(VBUND) CHAR/6 Bring values over as is.
LFA1 Group Key
(KONZS) CHAR/10 Not used
LFA1 Tax Code 1
(STCD1) CHAR/16 Bring values over as is.
LFA1 Tax Code 2
(STCD2) CHAR/11 Bring values over as is.
LFA1 Fiscal Address
(FISKN) CHAR/10 Bring values over as is.
LFA1 Jurisdiction Code
(TXJCD) CHAR/15 Bring values over as is.
LFA1 VAT Registration No.
(STCEG) CHAR/20 Bring values over as is.
LFA1 Tax Office
(FISKU) CHAR/10 Bring values over as is.
LFA1 Tax Number
(STENR) CHAR/18 Bring values over as is.
LFA1 Industry
(BRSCH) CHAR/4 Bring values over as is.
LFA1 Train Station
(BAHNS) CHAR/25 Not used.
LFA1 Transportation Zone
(LZONE) CHAR/10 Bring values over as is.
LFA1 Actual QM Sys.
(QSSYS) CHAR/4 Bring values over as is.
LFA1 QM System To
(QSSYSDAT) DATS/8 Bring values over as is.
LFA1 DAK
(J_1FDAK) CHAR/8 Bring values over as is.
PAYMENT TRANSACTIONS
Source File /Table Name Field Name Field Type / Length Format Rule / Logic
LFBK Bank Country Key
(BANKS) CHAR/3 Bring values over as is.
LFBK Bank Key
(BANKL) CHAR/15 Bring values over as is.
LFBK Bank Account
(BANKN) CHAR/18 Bring values over as is.
BNKA Bank Name
(BANKA) CHAR/60 Foods - Bring values over as is.
HPC Populate with Bank Account Number
LFA1 Alternative Payee
(LNRZA) CHAR/10 Bring values over as is.
LFA1 Individual Spec.
(XZEMP) CHAR/1 Bring values over as is.
LFA1 Spec. Per. Reference
(XLFZA) CHAR/1 Bring values over as is.
ACCOUNTING INFORMATION ACCOUNTING
Source File /Table Name Field Name Field Type / Length Format Rule / Logic
LFB1 Recon. Account
(AKONT) CHAR/10 Bring values over as is.
LFB1 Sort Key
(ZUAWA) CHAR/3 Bring values over as is.
LFB1 Head Office
(LNRZE) CHAR/10 Bring values over as is.
LFB1 Authorization
(BEGRU) CHAR/4 Bring values over as is.
LFB1 Cash Mgmnt Group
(FDGRV) CHAR/10 Bring values over as is.
LFB1 Release Group
(FRGRP) CHAR/4 Bring values over as is.
LFB1 Minority Indicator
(MINDK) CHAR/3 Bring values over as is.
LFB1 Certification Date
(CERDT)
DATS/8 Bring values over as is.
LFB1 Interest Indicator
(VZSKZ) CHAR/2 Bring values over as is.
LFB1 Last Key Date
(ZINDT) DATS/8 Bring values over as is.
LFB1 Interest Cycle
(ZINRT) NUMC/2 Bring values over as is.
LFB1 Last Interest Run
(DATLZ) DATS/8 Bring values over as is.
LFB1 Withholding Tax Code
(QSSKZ) CHAR /2 Bring values over as is.
LFB1 Withholding Tax Country
(QLAND) CHAR /3 Bring values over as is.
LFB1 Recipient Type
(QSREC) CHAR /2 Bring values over as is.
LFB1 Exemption Number
(QSZNR) CHAR /10 Bring values over as is.
LFB1 Valid Until
(QSZDT) DATS/8 Bring values over as is.
LFB1 Exemption Authority
(QSBGR) CHAR /1 Bring values over as is.
LFB1 Previous Account No.
(ALTKN) CHAR /10 Do not bring over existing values. Will populate during vendor conversion when legacy vendor number is replaced by a new vendor number.
LFB1 Personnel Number
(PERNR) NUMC/8 Bring values over as is.
PAYMENT TRANSACTIONS ACCOUNTING
Source File /Table Name Field Name Field Type / Length Format Rule / Logic
LFB1 Payment Terms
(ZTERM) CHAR/4 Refer to data mapping spreadsheet later in this spec.
LFB1 Tolerance Group
(TOGRU) CHAR/4 Bring values over as is.
LFB1 Credit Memo Terms
(GUZTE) CHAR/4 Bring values over as is.
LFB1 Chk. Double Inv.
(REPRF) CHAR/1 Bring values over as is.
LFB1 Chk. Cashing Time
(KULTG) DEC/3 Bring values over as is.
LFB1 Payment Methods
(ZWELS) CHAR/10 Refer to data mapping spreadsheet later in this spec.
LFB1 Alternate Payee
(LNRZB) CHAR/10 Bring values over as is.
LFB1 Individual Payment
(XPORE) CHAR/1 Bring values over as is.
LFB1 Bill of Exchange Limit
(WEBTR) CURR/13
Decimal/2 9999999999999.99 Bring values over as is.
LFB1 Payment Advance By EDI
(XEDIP) CHAR/1 Bring values over as is.
LFB1 Payment Block
(ZAHLS) CHAR/1 Bring values over as is.
LFB1 House Bank
(HBKID) CHAR/5 Not used. Do not bring forward existing values.
LFB1 Grouping Key
(ZGRUP) CHAR/2 Bring values over as is.
LFB1 Payment Method Supplement
(UZAWE) CHAR/2 Bring values over as is.
LFB1 Alternate Payee Indicator
(XLFZB) CHAR/1 Bring values over as is.
LFB1 Tolerance Group
(TOGRR) CHAR/4 Bring values over as is.
CORRESPONDENCE ACCOUNTING
Source File /Table Name Field Name Field Type / Length Format Rule / Logic
LFB5 Dunning Procedure
(MAHNA) CHAR/4 Bring values over as is.
LFB5 Dunning Recipient
(LFRMA) CHAR/10 Bring values over as is.
LFB5 Last Dunned
(MADAT) DATS/8 Bring values over as is.
LFB5 Dunning Clerk
(BUSAB) CHAR/2 Bring values over as is.
LFB5 Dunning Block
(MANSP) CHAR/1 Bring values over as is.
LFB5 Legal Dunning Proceedings
(GMVDT) DATS/8 Bring values over as is.
LFB5 Dunning Level
(MAHNS) NUMC/1 Bring values over as is.
LFB1 Grouping Key
(MGRUP) CHAR/2 Bring values over as is.
LFB1 Local Processing
(XDEZV) CHAR/1 Bring values over as is.
LFB1 Acct. Clerk
(BUSAB) CHAR/2 Bring values over as is.
LFB1 Account with Vendor
(EIKTO) CHAR/12 Bring values over as is.
LFB1 Clerk at Vendor
(ZSABE) CHAR/15 Bring values over as is.
LFB1 Acct. Clk. Tel. No.
(TLFNS) CHAR/30 Bring values over as is.
LFB1 Clerks Fax
(TLFXS) CHAR/31 Bring values over as is.
LFB1 Clerks Internet
(INTAD) CHAR/130 Bring values over as is.
LFB1 Account Memo
(KVERM) CHAR/30 Bring values over as is.
PURCHASING DATA
Source File /Table Name Field Name Field Type / Length Format Rule / Logic
LFM1 Order Currency
(WAERS) CUKY/5 Bring values over as is.
LFM1 Terms of Payment
(ZTERM) CHAR/4 Refer to data mapping spreadsheet later in this spec.
LFM1 Incoterms (Part 1)
(INCO1) CHAR/3 Refer to data mapping spreadsheet later in this spec.
LFM1 Incoterms (Part 2)
(INCO2)
CHAR/28 Bring values over as is.
LFM1 Minimum Order Value
(MINBW) CURR/13
Decimal/2 9999999999999.99 Bring values over as is.
LFM1 Schema group, vendor
(KALSK) CHAR/2 Bring values over as is.
LFM1 Pricing Date Cat.
(MEPRF) CHAR/1 Bring values over as is.
LFM1 Order Optim. Rest
(BOPNR) CHAR/4 Bring values over as is.
LFM1 Salesperson
(VERKF) CHAR/30 Bring values over as is.
LFM1 Telephone
(TELF1) CHAR/16 Bring values over as is.
LFM1 Acc. With Vendor
(EIKTO) CHAR/12 Bring values over as is.
LFM1 GR. Based Inv. Verif.
(WEBRE) CHAR/1 Bring values over as is.
LFM1 Auto.Eval. GR Setmt. Del.
(XERSY) CHAR/1 Bring values over as is.
LFM1 Auto.Eval. GR Setmt. Ret.
(XERSR) CHAR/1 Bring values over as is.
LFM1 Acknowledgement Reqd.
(KZABS) CHAR/1 Bring values over as is.
LFM1 Automatic Purchase Order
(KZAUT) CHAR/1 Bring values over as is.
LFM1 Subsequent Settlement
(BOLRE) CHAR/1 Bring values over as is.
LFM1 Subseq. Sett. Index
(BOIND) CHAR/1 Bring values over as is.
LFM1 B. Vol.Comp./Ag. Nec.
(UMSAE) CHAR/1 Bring values over as is.
LFM1 Doc. Index Active
(BLIND) CHAR/1 Bring values over as is.
LFM1 Returns Vendor
(KZRET) CHAR/1 Bring values over as is.
LFM1 Srv.-Based Inv. Ver.
(LEBRE) CHAR/1 Bring values over as is.
LFM1 ABC Indicator
(LFABC) CHAR/1 Bring values over as is.
LFM1 Mode Of Transport-Border
(EXPVZ) CHAR/1 Bring values over as is.
LFM1 Office of Entry
(ZOLLA) CHAR/6 Bring values over as is.
LFM1 Sort Criterion
(SKRIT) CHAR/1 Bring values over as is.
LFM1 PROACT Control Prof.
(PAPRF) CHAR/4 Bring values over as is.
LFM1 Revaluation Allowed
(XNBWY) CHAR/1 Bring values over as is.
LFM1 Grant Discount In Kind
(NRGEW) CHAR/1 Bring values over as is.
LFM1 Relevant for Price Determination
(PRFRE) CHAR/1 Bring values over as is.
LFM1 Relevant for Agency Business
(AGREL) CHAR/1 Bring values over as is.
LFM1 Shipping Conditions
(VSBED) CHAR/2 Bring values over as is.
LFM1 Purchasing Group
(EKGRP) CHAR/3 Bring values over as is.
LFM1 Planned Delivery Time
(PLIFZ) DEC/3 Bring values over as is.
LFM1 Confirmation Control
(BSTAE) CHAR/4 Bring values over as is.
LFM1 Unit of Measure Group
(MEGRU) CHAR/4 Bring values over as is.
LFM1 Rounding Profile
(RDPRF) CHAR/4 Bring values over as is.
LFM1 Price Marking Agreed
(LIPRE) CHAR/2 Bring values over as is.
LFM1 Rack jobbing service agreed
(LISER) CHAR/1 Bring values over as is.
LFM1 Order entry by vendor
(LIBES) CHAR/1 Bring values over as is.
LFM1 Serv. Level
(VENSL) DEC/4
Decimal/1 Bring values over as is.
PARTNER FUNCTIONS
Source File /Table Name Field Name Field Type / Length Format Rule / Logic
WYT3 Partner Function
(PARVW) CHAR/2 Bring values over as is.
WRF02K Number (Partner)
(GPARN) CHAR/10 Map to new partner number in vendor correlation table.
ALTERNATE DATA
(Purchasing Data)
Source File /Table Name Field Name Field Type / Length Format Rule / Logic
LFM2 Order Currency
(WAERS) CUKY/5 Bring values over as is.
LFM2 Terms of Payment
(ZTERM) CHAR/4 Refer to data mapping spreadsheet later in this spec.
LFM2 Incoterms (Part 1)
(INCO1) CHAR/3 Refer to data mapping spreadsheet later in this spec.
LFM2 Incoterms (Part 2)
(INCO2)
CHAR/28 Bring values over as is.
LFM2 Minimum Order Value
(MINBW) CURR/13
Decimal/2 Bring values over as is.
LFM2 Schema group, vendor
(KALSK) CHAR/2 Bring values over as is.
LFM2 Pricing Date Cat.
(MEPRF) CHAR/1 Bring values over as is.
LFM2 Order Optim. Rest
(BOPNR) CHAR/4 Bring values over as is.
LFM2 Salesperson
(VERKF) CHAR/30 Bring values over as is.
LFM2 Telephone
(TELF1) CHAR/16 Bring values over as is.
LFM2 Acc. With Vendor
(EIKTO) CHAR/12 Bring values over as is.
LFM2 GR. Based Inv. Verif.
(WEBRE) CHAR/1 Bring values over as is.
LFM2 Auto.Eval. GR Setmt. Del.
(XERSY) CHAR/1 Bring values over as is.
LFM2 Auto.Eval. GR Setmt. Ret.
(XERSR) CHAR/1 Bring values over as is.
LFM2 Acknowledgement Reqd.
(KZABS) CHAR/1 Bring values over as is.
LFM2 Automatic Purchase Order
(KZAUT) CHAR/1 Bring values over as is.
LFM2 Subsequent Settlement
(BOLRE) CHAR/1 Bring values over as is.
LFM2 Subseq. Sett. Index
(BOIND) CHAR/1 Bring values over as is.
LFM2 B. Vol.Comp./Ag. Nec.
(UMSAE) CHAR/1 Bring values over as is.
LFM2 Doc. Index Active
(BLIND) CHAR/1 Bring values over as is.
LFM2 Returns Vendor
(KZRET) CHAR/1 Bring values over as is.
LFM2 Srv.-Based Inv. Ver.
(LEBRE) CHAR/1 Bring values over as is.
LFM2 ABC Indicator
(LFABC) CHAR/1 Bring values over as is.
LFM2 Mode Of Transport-Border
(EXPVZ) CHAR/1 Bring values over as is.
LFM2 Office of Entry
(ZOLLA) CHAR/6 Bring values over as is.
LFM2 Sort Criterion
(SKRIT) CHAR/1 Bring values over as is.
LFM2 PROACT Control Prof.
(PAPRF) CHAR/4 Bring values over as is.
LFM2 Revaluation Allowed
(XNBWY) CHAR/1 Bring values over as is.
LFM2 Grant Discount In Kind
(NRGEW) CHAR/1 Bring values over as is.
LFM2 Relevant for Price Determination
(PRFRE) CHAR/1 Bring values over as is.
LFM2 Relevant for Agency Business
(AGREL) CHAR/1 Bring values over as is.
LFM2 Shipping Conditions
(VSBED) CHAR/2 Bring values over as is.
LFM2 Purchasing Group
(EKGRP) CHAR/3 Bring values over as is.
LFM2 Planned Delivery Time
(PLIFZ) DEC/3 Bring values over as is.
LFM2 Confirmation Control
(BSTAE) CHAR/4 Bring values over as is.
LFM2 Unit of Measure Group
(MEGRU) CHAR/4 Bring values over as is.
LFM2 Rounding Profile
(RDPRF) CHAR/4 Bring values over as is.
LFM2 Price Marking Agreed
(LIPRE) CHAR/2 Bring values over as is.
LFM2 Rack jobbing service agreed
(LISER) CHAR/1 Bring values over as is.
LFM2 Order entry by vendor
(LIBES) CHAR/1 Bring values over as is.
LFM2 Serv. Level
(VENSL) DEC/4
Decimal/1 Bring values over as is.
ALTERNATE DATA
(Partner Functions)
Source File /Table Name Field Name Field Type / Length Format Rule / Logic
WYT3 Partner Function
(PARVW) CHAR/2 Bring values over as is.
WRF02K Number (Partner)
(GPARN) CHAR/10 Map to new partner number in vendor correlation table.Hi Shareen,
Have you looked Master Data Distribution (ALE) for Vendor since your legacy system are SAP?
Please check t/code BD14 (Send Vendor Master Data) and BD15 (Get Vendor Master Data).
Hope this will give you an idea.
Regards,
Ferry Lianto -
Upload program for vendor master
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>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 -
Masking Certain Field in Vendor Master Data
We have a Enhancement which involves conversion of Vendor Numbers.,It so happened that a category of Vendor Codes were the Social Security Numbers.
Now that due to Privacy Laws etc they are converting that number logic which is throwing challanges.
The first Step is to convert Vendors from XSSN to Y123 and the second is also retain the social number in a encrypted field as it is used for 1099 reporting.
I am aware that there is a standard functionality for Credit Cards Numbers Masking but not sure if there is any thing for special fields on Vendor Master.
If you are aware of any options to handle the switchover or masking certain fields pls share them with me.
Thanks,
PraveenPraveen,
Did you try 'Define Screen Layout per Activity (Vendors)' and suppress/hide the fields? -
how do we upload vendor master data into SAP from legacy system.can anyone give me a detailed explination.
regards,
deepthiDeepthi,
The steps would be (in LSMW) :
1 Create a new Project, Subproject (if not existing). Then give a name for the Object, say VendorMaster.
2 On the next screen, you will see several steps (radio buttons) to be performed. You should go in sequential order.
Double click the first, I think its called Maintain Object (sorry don't have access to SAP system right now)
3 On this screen you will see various options/methods (in the second section) for loading the data.
You may select which ever is appropriate or most suitable in your case.
Let's assume you want to use the very first options - Standard program for Direct Input/Batch.
4 Pull down (F4) for the Object & select Vendor Master.
5 Pull down again for the Method & select (I think( Standard). The program name & Type will be populated by LSMW.
If let's say none of the programs in this list satisfies your requirement, then you may decide to go for a Recording or a BAPI (again pull down & select appropriate method) or IDoc (CREMAS).
So now you have decided on the method you want to use for posting the Vendor Master data. Save the information & go back to the main screen of the object.
6 Double click on the next step for maintaining the Source Structure. Give the name(s) of the Source Structure(s).
7 Next step is to define the Source Structure(s) format (fields, attributes etc).
8 Next you maintain the relationship between the Structure(s) - Source & Target. The Target structures depend upon the method elected by you in step 5.
9 Next will be the most important step - ie specifying the mapping/conversion rules for each Target field. You can even write ABAP code by double clicking on the field - it will open up the editor where you can put in your ABAP code. There are also several events available - for instance at the <i>Beginning of Processing</i> or <i>Beginning of Transaction</i> etc. where again you can specify your own logic.
10 In the Next 2 steps you will give the file name & path & also associate the file(s) to the Source structure(s).
The develoment for the object is complete. Now you are ready to read, convert & post your Vendor Master data in SAP.
Let me know if you need additional assistance.
Regards,
Homiar. -
LSMW-Vendor master data and Vendor Open items Upload
Dear Experts,
I need help on the following
Do you have any docs with you where I can familiarize myself with the AP upload programs in LSMW?
sample template for me to test the upload via LSMW? sample template and the programs used to upload the vendor master and Vendor open items.how to use the program for example like some instruction docs step by step doc etc.
Thanks n Regards
Rena.hi
there are 14 steps u have to go through while uploading...
first u create Project and Sub Projects...
1 Maintain Object Attributes
select Batch Input Recording.
click on Overview.
enter Recording
Then it wil ask for the Transaction code there u enter XK01 for creation
u enter all The details Which are Given to u in Excel by ur CTM Members.
note: Dont use Mouse while Entering the data.Use Only Key Board.
After Entering all the required details click on Save...
select Default All
System-> List -> Save -> Local File
Convert Excel to Text File(Text Tab Limited)
2 Maintain Source Structures
Create Source Structure.
3 Maintain Source Fields
click on Copy Fields
Select From Data File
Select Max Len
save + back
4 Maintain Structure Relations
save+back
5 Maintain Field Mapping and Conversion Rules
Extras -> Auto Field Mapping
select Edit All Target Fields
save + Back
7 Specify Files
Click on Execute Button or press F8.Select u201CSPECIFY FILESu201D click on Execute or press ctrl+F8.
then double click on the u201CLEGACY DATA FILEu201D and select the text file to be uploaded
Then select u201CTABULATORu201D and u201CFIELDS NAMES AT START OF FILEu201D
8 Assign Files
SAVE AND CLICK ON BACK
9 Read Data
Execute + back
10 Display Read Data
Back
11 Convert Data
Execute + back
12 Display Converted Data
back
13 Create Batch Input Session
Select u201CKeep Batch Input Folderu201D click on Execute.
14 Run Batch Input Session
Select Processing mode
1) Process in Foreground: Executes Each Step.
2) Display Errors Only: Displays only the Errors.
3) Background: Skips The Errors.
Select Extended Log and Click on Process as shown in Screen Shot.
Edited by: Smitha KB on Feb 24, 2009 10:32 AM -
LSMW Upload vendor master data problem
Hello,
I have to upload vendor master data with LSMW.
I'm using a batch input with the program RFBIKR00.
In the step "Create batch input session", I get the following error:
FB012 Session 1 : Special character for 'empty field' is /
FB007 Session 1 session name VENDOR was opened
FB112 Trans. 1 : No transaction code was transferred
FB016 ... Last header record ...
FB014 ... BLF00-STYPE 1
FB014 ... BLF00-TCODE /
FB014 ... BLF00-LIFNR DETES998
FB014 ... BLF00-BUKRS /
FB014 ... BLF00-EKORG /
FB014 ... BLF00-KTOKK 0001
FB013 ....Editing was terminated
Does anyone know how to solve this error?
Kind regards,
FrankHi ,
first up all u r not mentioning the tcode and other mandatory field values...just in the field mapping and conversion step...
click -->Extras -->Layout and select all fields
and give default values to field TCODE,and other fields also and also check whether mapping conversion with regard to source is correct or not...
If still any doubts i can clarify
Regards,
Sridhar Reddy
Message was edited by: sridhar reddy kondam
Message was edited by: sridhar reddy kondam -
Vendor master upload mapping issue in LSMW
We need to upload Vendor Master Data and it contains 72 fields we identified 69 fields for mapping through standard program (RFBIKRK0) through Batch Input in LSMW.
We are having issues to identify three fields which belongs to Address and these are not getting mapped in the program.the fields are street street1 street2 street3 street4 street5 and address notes.the mentioned fields are maintained in ADRC table but the structure is not getting populated in the standard program RFBIKRK0 in LSMW mapping section.
In the input file from legacy we have the following fields street street1 street2 street3 street4 street5 and this should get mapped in the LSMW .how to go about this problem.whether we need to do seperate conversion program for the address fields .could you please any one help me .Hi!
You don't have access to all fields of the address with batch input - you need to do something in addition:
- migrate addresses beforehand (central address handling)
- select the (hopefully few) vendors with street3 filled and migrate this later
- manually
- own batch input (recording in LSMW / eCATT)
Regards,
Christian -
Rg: How to upload Partner Functions in vendor master
Hi All,
I am doing LSMW batch input for vendor master. Since the client has different address for a single vendor, we use partner functions. So two lsmw are used, one for the different address and the lifnr is system generated. another lsme for the original vendor master witl the partner functions like Ordering Address, Invoicing party. The vendor number which is cretaed in first lsmw will be provided in the partner numbers for vendor the field is gparn. But while uploading the datas the partner numbers are not getting updated..
so does any one have solution..
thanks
srivatsanHi,
You can make use of this Tgt Structure BWYT3,
BWYT3 - Vendor Master Record: Partner Functions (Batch Input)
In this you need to pass the combination values of
PARVW Partner function
PARNR Number of contact person (batch input only),
In field mapping you need use Conversion exit for both.
Reward for helpful answer.
Regards,
Sivaram. -
Hi gurus,
How to create the vendor master data using LSMW Direct input.....
Explain step by step...Hi
Check this
Check the following link:
http://www.sapbrainsonline.com/TUTORIALS/TECHNICAL/LSMW_tutorial.html
http://www.sapbrain.com/TOOLS/LSMW/SAP_LSMW_steps_introduction.html
http://esnips.com/doc/8e732760-5548-44cc-a0bb-5982c9424f17/lsmw_sp.ppt
http://esnips.com/doc/f55fef40-fb82-4e89-9000-88316699c323/Data-Transfer-Using-LSMW.zip
http://esnips.com/doc/1cd73c19-4263-42a4-9d6f-ac5487b0ebcb/LSMW-with-Idocs.ppt
http://esnips.com/doc/ef04c89f-f3a2-473c-beee-6db5bb3dbb0e/LSMW-with-BAPI.ppt
http://esnips.com/doc/7582d072-6663-4388-803b-4b2b94d7f85e/LSMW.pdf
for Long texts Upload
Please take a look at this..
http://help.sap.com/saphelp_erp2005/helpdata/en/e1/c6d30210e6cf4eac7b054a73f8fb1d/frameset.htm
LSMW with TABLE CONTROL
Refer the links -
lsmw table control
Re: Table control in LSMW
Table control in LSMW
Table Control in LSMW
Re: Table Control in LSMW
just refer to the link below
http://www.sapmaterial.com/?gclid=CN322K28t4sCFQ-WbgodSGbK2g
1. Maintain Attributes:
Here you have to choose the second option and you can do the recording how this should work. Then assign the same to the Batch Input Recording name.
2. Maintain Source structure:
Create a structure name
3. Maintain Source field:
In this you have to create a structure same as that of the input file
eg: name
age
4. Maintain structure relations:
This will link the structure to the input file.
5. Maintain field mapping and conversion rules:
Here is the place where you can do coding, depending upon the code you have written or assignment you have done the values will get picked up from the file and get processed.
6. Maintain field mapping and conversion rules:
If you have any fixed values you can define here.
7. Specify files:
Specify the input file path and type.
8. Assign files:
This will assign ur file to the Input file
9. Read Data:
This will read ur data from teh file.
10. Dispaly Read Data:
You can see the uploaded data
11. Convert Data
This will convert the data to the corresponding format for processing
12. Display Converted data:
13. Create batch input session
Here this will create a batch input session for processing
14. Run Batch Input session:
By clicking on the session and process the same you can do teh needfu.
Regards
Anji -
Creating Vendor Master through Bapi
Hi All,
Please help me out in creating vendor master using Bapi and also send me the program logic.
Thanks in Advance,
Sridhar ChHi Sridhar,
Refer to the following and award points if useful.BAPI is like using standard function modules.We will populate the parameters and handle errors from that.See the code below which is vendor debit posting.You can get an idea by the following code.
See the start of selection if this is confusing to you and understand the usage
* TABLES
TABLES: VBAK,
ADR6,
TRDYSE01CM.
* INCLUDE
INCLUDE ZZUTI_STD_HEADER_FOOTER. "Standard header and footer
* TYPES DECLARATION
TYPES:
BEGIN OF T_CRMEMO,
VBELN TYPE VBAK-VBELN,
POSNR TYPE VBAP-POSNR,
ERDAT TYPE VBAK-ERDAT,
AUART TYPE VBAK-AUART,
AUGRU TYPE VBAK-AUGRU,
WAERK TYPE VBAK-WAERK,
VKORG TYPE VBAK-VKORG,
VTWEG TYPE VBAK-VTWEG,
SPART TYPE VBAK-SPART,
VDATU TYPE VBAK-VDATU,
BSTNK TYPE VBAK-BSTNK,
BSARK TYPE VBAK-BSARK,
BSTDK TYPE VBAK-BSTDK,
AEDAT TYPE VBAK-AEDAT,
BUKRS_VF TYPE VBAK-BUKRS_VF,
MATNR TYPE VBAP-MATNR,
ZMENG TYPE VBAP-ZMENG,
ZIEME TYPE VBAP-ZIEME,
END OF T_CRMEMO,
BEGIN OF T_CRMEMO_CHANGE,
VBELN(90) TYPE C,
POSNR TYPE VBAP-POSNR,
ERDAT TYPE VBAK-ERDAT,
AUART TYPE VBAK-AUART,
AUGRU TYPE VBAK-AUGRU,
WAERK TYPE VBAK-WAERK,
VKORG TYPE VBAK-VKORG,
VTWEG TYPE VBAK-VTWEG,
SPART TYPE VBAK-SPART,
VDATU TYPE VBAK-VDATU,
BSTNK TYPE VBAK-BSTNK,
BSARK TYPE VBAK-BSARK,
BSTDK TYPE VBAK-BSTDK,
AEDAT TYPE VBAK-AEDAT,
BUKRS_VF TYPE VBAK-BUKRS_VF,
MATNR TYPE VBAP-MATNR,
ZMENG TYPE VBAP-ZMENG,
ZIEME TYPE VBAP-ZIEME,
END OF T_CRMEMO_CHANGE,
BEGIN OF T_MVKE,
MATNR TYPE MVKE-MATNR,
VKORG TYPE MVKE-VKORG,
VTWEG TYPE MVKE-VTWEG,
MTPOS TYPE MVKE-MTPOS,
END OF T_MVKE,
BEGIN OF T_ORDERS,
VBELV TYPE VBFA-VBELV,
POSNV TYPE VBFA-POSNV,
VBELN TYPE VBFA-VBELN,
POSNN TYPE VBFA-POSNN,
VBTYP_N TYPE VBFA-VBTYP_N,
END OF T_ORDERS,
BEGIN OF T_EKPO,
EBELN TYPE EKKO-EBELN,
EBELP TYPE EKPO-EBELP,
WAERS TYPE EKKO-WAERS,
MENGE TYPE EKPO-MENGE,
MEINS TYPE EKPO-MEINS,
NETPR TYPE EKPO-NETPR,
PEINH TYPE EKPO-PEINH,
mwskz TYPE EKPO-mwskz,
TXJCD TYPE EKPO-TXJCD,
END OF T_EKPO,
BEGIN OF T_EKBE,
EBELN TYPE EKBE-EBELN,
EBELP TYPE EKBE-EBELP,
ZEKKN TYPE EKBE-ZEKKN,
VGABE TYPE EKBE-VGABE,
GJAHR TYPE EKBE-GJAHR,
BELNR TYPE EKBE-BELNR,
BUZEI TYPE EKBE-BUZEI,
END OF T_EKBE,
BEGIN OF T_RBKP,
BELNR TYPE RBKP-BELNR,
GJAHR TYPE RBKP-GJAHR,
BLDAT TYPE RBKP-BLDAT,
BUDAT TYPE RBKP-BUDAT,
XBLNR TYPE RBKP-XBLNR,
LIFNR TYPE RBKP-LIFNR,
RMWWR TYPE RBKP-RMWWR,
WMWST1 TYPE RBKP-WMWST1,
XRECH TYPE RBKP-XRECH,
STBLG TYPE RBKP-STBLG,
END OF T_RBKP,
BEGIN OF T_CDHDR,
OBJECTCLAS TYPE CDHDR-OBJECTCLAS,
OBJECTID TYPE CDHDR-OBJECTID,
CHANGENR TYPE CDHDR-CHANGENR,
UDATE TYPE CDHDR-UDATE,
UTIME TYPE CDHDR-UTIME,
END OF T_CDHDR,
BEGIN OF T_CDPOS,
OBJECTCLAS TYPE CDHDR-OBJECTCLAS,
OBJECTID TYPE CDHDR-OBJECTID,
CHANGENR TYPE CDHDR-CHANGENR,
TABNAME TYPE CDPOS-TABNAME,
TABKEY TYPE CDPOS-TABKEY,
FNAME TYPE CDPOS-FNAME,
CHNGIND TYPE CDPOS-CHNGIND,
VALUE_NEW TYPE CDPOS-VALUE_NEW,
VALUE_OLD TYPE CDPOS-VALUE_OLD,
END OF T_CDPOS,
BEGIN OF T_CHANGE_DOCS,
OBJECTCLAS TYPE CDHDR-OBJECTCLAS,
OBJECTID TYPE CDHDR-OBJECTID,
CHANGENR TYPE CDHDR-CHANGENR,
UDATE TYPE CDHDR-UDATE,
UTIME TYPE CDHDR-UTIME,
TABNAME TYPE CDPOS-TABNAME,
TABKEY TYPE CDPOS-TABKEY,
FNAME TYPE CDPOS-FNAME,
CHNGIND TYPE CDPOS-CHNGIND,
VALUE_NEW TYPE CDPOS-VALUE_NEW,
VALUE_OLD TYPE CDPOS-VALUE_OLD,
END OF T_CHANGE_DOCS,
BEGIN OF T_SUCCESS,
crmemo TYPE VBAK-vbeln,
cmemo TYPE VBAK-vbeln,
orders TYPE VBAK-vbeln,
po TYPE VBAK-vbeln,
miro_no TYPE VBAK-vbeln,
text(20) TYPE C,
END OF T_SUCCESS,
BEGIN OF T_ERROR,
crmemo TYPE VBAK-vbeln,
cmemo TYPE VBAK-vbeln,
orders TYPE VBAK-vbeln,
po TYPE VBAK-vbeln,
miro_no TYPE VBAK-vbeln,
text(100) TYPE C,
END OF T_ERROR.
* WORKAREA DECLARATION
DATA:
WA_CRMEMO TYPE T_CRMEMO,
WA_CRMEMO_CHANGE TYPE T_CRMEMO_CHANGE,
WA_MVKE TYPE T_MVKE,
WA_ORDERS TYPE T_ORDERS,
WA_CMEMO TYPE T_ORDERS,
WA_PO TYPE T_ORDERS,
WA_EKPO TYPE T_EKPO,
WA_EKBE TYPE T_EKBE,
WA_EKBE_TEMP TYPE T_EKBE,
WA_RBKP TYPE T_RBKP,
WA_RBKP_TMP TYPE T_RBKP,
WA_CDHDR TYPE T_CDHDR,
WA_CDPOS TYPE T_CDPOS,
WA_CHANGE_DOCS TYPE T_CHANGE_DOCS,
WA_CRMEMO_MR8M TYPE T_CRMEMO,
WA_SUCCESS TYPE T_SUCCESS,
WA_ERROR TYPE T_ERROR,
WA_SUCCESS_MR8M TYPE T_SUCCESS,
WA_ERROR_MR8M TYPE T_ERROR.
*--Work area for all the internal tables used for Sending Mail
DATA :
WA_OBJPACK TYPE SOPCKLSTI1,
WA_OBJHEAD TYPE SOLISTI1,
WA_OBJBIN TYPE SOLISTI1,
WA_OBJTXT TYPE SOLISTI1,
WA_RECLIST TYPE SOMLRECI1 .
DATA:
*-- Structure to hold Invoice Header Data
x_docheader LIKE bapi_incinv_create_header,
*-- Structure to hold Reversal Posting Data
x_rev_post LIKE BAPI_INCINV_FLD.
* INTERNAL TAABLE DECLARATION
DATA:
IT_CRMEMO TYPE STANDARD TABLE OF T_CRMEMO WITH HEADER LINE,
IT_CRMEMO_CHANGE TYPE STANDARD TABLE OF T_CRMEMO_CHANGE WITH HEADER LINE,
IT_MVKE TYPE STANDARD TABLE OF T_MVKE WITH HEADER LINE,
IT_CRMEMO_MIRO TYPE STANDARD TABLE OF T_CRMEMO WITH HEADER LINE,
IT_CRMEMO_MR8M TYPE STANDARD TABLE OF T_CRMEMO WITH HEADER LINE,
IT_ORDERS TYPE STANDARD TABLE OF T_ORDERS WITH HEADER LINE,
IT_CMEMO TYPE STANDARD TABLE OF T_ORDERS WITH HEADER LINE,
IT_PO TYPE STANDARD TABLE OF T_ORDERS WITH HEADER LINE,
IT_EKPO TYPE STANDARD TABLE OF T_EKPO WITH HEADER LINE,
IT_EKBE TYPE STANDARD TABLE OF T_EKBE WITH HEADER LINE,
IT_EKBE_TEMP TYPE STANDARD TABLE OF T_EKBE WITH HEADER LINE,
IT_RBKP TYPE STANDARD TABLE OF T_RBKP WITH HEADER LINE,
IT_CDHDR TYPE STANDARD TABLE OF T_CDHDR WITH HEADER LINE,
IT_CDPOS TYPE STANDARD TABLE OF T_CDPOS WITH HEADER LINE,
IT_CHANGE_DOCS TYPE STANDARD TABLE OF T_CHANGE_DOCS WITH HEADER LINE,
IT_SUCCESS TYPE STANDARD TABLE OF T_SUCCESS WITH HEADER LINE,
IT_ERROR TYPE STANDARD TABLE OF T_ERROR WITH HEADER LINE,
IT_SUCCESS_MR8M TYPE STANDARD TABLE OF T_SUCCESS WITH HEADER LINE,
IT_ERROR_MR8M TYPE STANDARD TABLE OF T_ERROR WITH HEADER LINE.
*-- Internal table to hold Invoice Item Data
DATA:BEGIN OF it_itemdata OCCURS 0.
INCLUDE STRUCTURE bapi_incinv_create_item.
DATA:END OF it_itemdata.
*-- Internal table to hold Invoice Acct Assignment Data
DATA:BEGIN OF it_ACCOUNTingdata OCCURS 0.
INCLUDE STRUCTURE BAPI_INCINV_CREATE_ACCOUNT.
DATA:END OF it_accountingdata.
*-- Internal table to hold BAPI return data
DATA: BEGIN OF it_return OCCURS 0.
INCLUDE STRUCTURE bapiret2. "Return Parameter.
DATA: END OF it_return.
*-- Internal table to hold BAPI return data
DATA: BEGIN OF it_return_mr8m OCCURS 0.
INCLUDE STRUCTURE bapiret2. "Return Parameter.
DATA: END OF it_return_mr8m.
*--MAIL related Internal tables
DATA: X_DOC_CHNG TYPE SODOCCHGI1, " document attributes
IT_OBJPACK TYPE STANDARD TABLE OF SOPCKLSTI1, " attachment table
IT_OBJHEAD TYPE STANDARD TABLE OF SOLISTI1, " object header table
IT_OBJBIN TYPE STANDARD TABLE OF SOLISTI1, " binary table
IT_OBJTXT TYPE STANDARD TABLE OF SOLISTI1, " object text
IT_RECLIST TYPE STANDARD TABLE OF SOMLRECI1, " mail recipients
it_compressed_list TYPE STANDARD TABLE OF SOLI,
it_pdf_list TYPE STANDARD TABLE OF TLINE,
it_pdf TYPE tline OCCURS 10 WITH HEADER LINE,
it_html TYPE solisti1 OCCURS 10 WITH HEADER LINE,
*-- Internal table for MIME data (in CHAR format)
it_temp TYPE bapiqcmime OCCURS 10 WITH HEADER LINE,
*-- Internal table for storing data
it_mime(255) TYPE c OCCURS 10 WITH HEADER LINE.
* GLOBAL VARIABLES *
DATA: V_PGM_ID TYPE SY-REPID, " Program id
v_zterm TYPE lfb1-zterm, " Payment Terms
v_text(75) TYPE c, " To store error or success text
v_itemno(6) TYPE n, " To Increment Item No. for BAPI
v_docnr LIKE bapi_incinv_fld-inv_doc_no, " For MIRO document number
v_year1 LIKE bapi_incinv_fld-fisc_year, " For MIRO Fiscal year
v_spono type TSP01-RQIDENT, " For Spool No.
v_type type SOODK-OBJTP, " For Spool Type
V_CRMEMO_QTY TYPE VBAP-ZMENG, " For CR Memo Qty.
V_LINE_AMOUNT TYPE EKPO-NETPR, " For CR Memo Item Qty.
V_GROSSAMT TYPE EKPO-NETPR, " For CR Memo Grand Qty.
v_tax_per(3) type n, " For CR Memo Tax amount %
v_tax_amt TYPE EKPO-NETPR, " For CR Memo Tax amount
v_flag(1) type c, " Flag to process fruther
v_tot_s_mr8m TYPE i, " For MR8M Success Records
v_tot_e_mr8m TYPE i, " For MR8M Error Records
V_DATE TYPE SY-DATUM, " For Sel. Screen Date
V_DATE2(10) TYPE C, " For EMail Date
V_TIME(10) TYPE C, " For EMail Time
V_TIME2(10) TYPE C, " For EMail Time
V_INFO(100) TYPE C, " For EMail Body Text
V_TABLE_LINES TYPE SY-TABIX, " To Increment Email Count
V_TEXT2 TYPE STRING , " For EMail Id text
v_lines TYPE i, " To Store PDF Lines
v_temp(500) TYPE c, " To Convert to 255 char format
v_offset TYPE p, " To Convert to 255 char format
v_lineslen TYPE i, " To Convert to 255 char format
v_mimelen TYPE i, " To Convert to 255 char format
v_tabix type sy-tabix. " To Convert to 255 char format
* CONSTANTS *
CONSTANTS:
C_X(1) TYPE C VALUE 'X', " Constant X or Flag
C_E(1) TYPE C VALUE 'E', " For Error check
c_v(1) TYPE C VALUE 'V', " For PO Docs
c_o(1) TYPE C VALUE 'O', " For Order Docs
c_c(1) TYPE C VALUE 'C', " For Credit Memo Docs
c_k(1) TYPE C VALUE 'K', " For CR Memo Docs
c_u(1) TYPE C VALUE 'U', " For Change tables Update
c_ali(3) TYPE C VALUE 'ALI', " For ALI Format
c_vbak(4) TYPE C VALUE 'VBAK', " For Change docs table
C_01(2) TYPE C VALUE '01', " For Serial No. & Reversal Reason
C_02(2) TYPE C VALUE '02', " For Reversal Reason
c_blart TYPE bkpf-blart VALUE 'RE', " Document type
C_MTPOS TYPE MVKE-MTPOS VALUE 'BANS', " Item Category group
C_AUGRU(5) TYPE C VALUE 'AUGRU', " Reason Code
C_0000500205(10) TYPE C VALUE '0000500205', " GL Account #
C_VERKBELEG(9) TYPE C VALUE 'VERKBELEG'. " For Object Class
*-- Horizontal tab & line feed constants
CLASS CL_ABAP_CHAR_UTILITIES DEFINITION LOAD.
CONSTANTS:
C_TAB TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB,
C_CR_LF TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF .
* SELECTION SCREEN
*-- Select Optons
SELECTION-SCREEN: BEGIN OF BLOCK B01 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: S_AUART FOR VBAK-AUART OBLIGATORY NO INTERVALS,
" Sales Document Type
S_AUGRU FOR VBAK-AUGRU OBLIGATORY NO INTERVALS,
" Order reason
S_ERDAT FOR VBAK-ERDAT OBLIGATORY.
" Date on which the record was created
SELECTION-SCREEN: END OF BLOCK B01.
*-- Mail Sending Options
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-004.
PARAMETERS:P_EMAIL AS CHECKBOX DEFAULT SPACE USER-COMMAND V_COM .
PARAMETERS : P_MODE TYPE SO_ESCAPE default 'U' MODIF ID US1.
SELECT-OPTIONS: S_EMAIL FOR ADR6-SMTP_ADDR
NO INTERVALS MODIF ID US2.
* SELECT-OPTIONS: S_EMAIL FOR TRDYSE01CM-USERNAME
* NO INTERVALS MODIF ID US2.
SELECTION-SCREEN: BEGIN OF LINE.
SELECTION-SCREEN: COMMENT 55(40) TEXT-019 MODIF ID US2.
SELECTION-SCREEN: END OF LINE.
SELECTION-SCREEN END OF BLOCK B2.
* WORK AREA for SELECT-OPTIONS
DATA : X_EMAIL LIKE S_EMAIL. "Work area for EMAIL select-options
* INITIALIZATION
INITIALIZATION.
*-- Default values for Sales Document Type
CLEAR S_AUART[].
S_AUART-SIGN = 'I'.
S_AUART-OPTION = 'EQ'.
S_AUART-LOW = 'CR'.
APPEND S_AUART.
CLEAR S_AUART.
*-- Default values for Date on which the record was created
V_DATE = ( SY-DATUM - 1 ).
CLEAR S_ERDAT[].
S_ERDAT-SIGN = 'I'.
S_ERDAT-OPTION = 'EQ'.
S_ERDAT-LOW = SY-DATUM.
S_ERDAT-HIGH = SY-DATUM.
APPEND S_ERDAT.
CLEAR S_ERDAT.
* TOP OF PAGE *
TOP-OF-PAGE.
*-- Displaying standard header.
PERFORM std_top_of_page USING sy-title.
* A T S E L E C T I O N S C R E E N O U T P U T
*-- For modifying the selection screen layout
AT SELECTION-SCREEN OUTPUT.
PERFORM F_MODIFY_SCREEN.
* AT SELECTION SCREEN. *
AT SELECTION-SCREEN.
*-- Subroutine to Validate selection screen fields
PERFORM f_validate.
* START-OF-SELECTION *
*START-OF-SELECTION.*
**-- Fetch the Credit Memo Requests documents*
*PERFORM F_GET_CREDIT_MEMO_REQUEST.*
*IF NOT IT_CRMEMO[] IS INITIAL.*
**-- Fetch Item Category Group*
*PERFORM F_GET_MVKE_DOCS.*
**-- Fetch Sales Order documents, PO Documents and Credit Memos*
*PERFORM F_GET_SO_PO_DOCS.*
*ENDIF.*
**-- If Credit memo request internal table have an change records then*
** fetch the change documents from CDHDR and CDPOS*
*IF NOT IT_CRMEMO_CHANGE[] IS INITIAL.*
**-- Fetch Change Documents for CR Memos from CDHDR and CDPOS tables*
*PERFORM F_GET_CHANGED_DOCS.*
*ENDIF.*
**-- Fetch Purchasing Document Item Details*
*IF NOT IT_PO[] IS INITIAL.*
*PERFORM F_GET_EKPO.*
*ENDIF.*
**-- Fetch MIRO Vendor based on the PO Details*
*IF NOT IT_EKPO[] IS INITIAL.*
*PERFORM F_GET_VENDOR.*
*ENDIF.*
* END-OF-SELECTION *
if v_flag is initial.
*-- Process Vendor Debit Postings
PERFORM F_PROCESS_MIRO.
*-- Process Reversal Postings of Vendor Automatic Debits using TCODE MR8M
PERFORM F_PROCESS_MR8M.
*-- Send mail,if user enters Email id's and Email Mode is not initial
IF P_EMAIL = C_X AND P_MODE IS NOT INITIAL AND S_EMAIL[] IS NOT INITIAL.
*-- Get spool id
perform f_spool_id.
*-- EMail Logic
PERFORM F_MAIL_LOGIC.
ENDIF.
*-- display the EMail RSCONN01 and Sussess and Error records of MIRO and MR8M
perform f_display_report.
else.
*-- Else exit the process
exit.
endif.
*& Form F_MODIFY_SCREEN
* A Form routine to modify the screen
FORM F_MODIFY_SCREEN .
*-- To Modify Mail Sending Options
LOOP AT SCREEN.
IF P_EMAIL = C_X.
IF SCREEN-GROUP1 = 'US1' .
SCREEN-INVISIBLE = 0.
SCREEN-ACTIVE = 1.
SCREEN-INPUT = 0.
MODIFY SCREEN.
ENDIF.
IF SCREEN-GROUP2 = 'US2' .
SCREEN-INVISIBLE = 0.
SCREEN-ACTIVE = 1.
MODIFY SCREEN.
ENDIF.
ELSEIF P_EMAIL = SPACE.
IF SCREEN-GROUP1 = 'US1' .
SCREEN-INVISIBLE = 1.
SCREEN-ACTIVE = 0.
MODIFY SCREEN.
ENDIF.
IF SCREEN-GROUP1 = 'US2' .
SCREEN-INVISIBLE = 1.
SCREEN-ACTIVE = 0.
MODIFY SCREEN.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. " F_MODIFY_SCREEN
*& Form f_validate
* Validation of Selection-Screen Inputs
FORM f_validate .
*-- Validate Sales Document Type
if not s_AUART[] is initial.
select AUART
into s_AUART-low
from TVAK up to 1 rows
where AUART in s_AUART.
endselect.
if sy-subrc <> 0.
message E000 with 'Invalid Sales Document Type'(e01) .
endif.
ENDIF.
*-- Validate Order reason (reason for the business transaction)
if not s_AUGRU[] is initial.
select AUGRU
into s_AUGRU-low
from TVAU up to 1 rows
where AUGRU in s_AUGRU.
endselect.
if sy-subrc <> 0.
message E000 with 'Invalid Order reason'(e02) .
endif.
endif.
ENDFORM. " f_validate
*& Form F_GET_CREDIT_MEMO_REQUEST
* Fetch Credit memo requests from VBAK & VBAP
FORM F_GET_CREDIT_MEMO_REQUEST .
SELECT A~VBELN
B~POSNR
A~ERDAT
A~AUART
A~AUGRU
A~WAERK
A~VKORG
A~VTWEG
A~SPART
A~VDATU
A~BSTNK
A~BSARK
A~BSTDK
A~AEDAT
A~BUKRS_VF
B~MATNR
B~ZMENG
B~ZIEME
INTO TABLE IT_CRMEMO
FROM ( VBAK AS A
INNER JOIN VBAP AS B ON A~VBELN = B~VBELN )
WHERE ( A~ERDAT IN S_ERDAT
OR A~AEDAT IN S_ERDAT )
AND A~AUART IN S_AUART.
IF SY-SUBRC = 0.
SORT IT_CRMEMO BY VBELN POSNR.
ELSE.
MESSAGE I000 WITH 'No Credit Memo Request selected'(002).
v_flag = C_X.
stop.
ENDIF.
ENDFORM. " F_GET_CREDIT_MEMO_REQUEST
*& Form F_GET_MVKE_DOCS
* Fetch Sales Data for Material
FORM F_GET_MVKE_DOCS .
DATA: LV_TABIX TYPE SY-TABIX.
*-- Fetch Sales Data for Material
SELECT MATNR " Material Number
VKORG " Sales Organization
VTWEG " Distribution Channel
MTPOS " Item category group from material master
FROM MVKE " Sales Data for Material
INTO TABLE IT_MVKE
FOR ALL ENTRIES IN IT_CRMEMO
WHERE MATNR = IT_CRMEMO-MATNR
AND VKORG = IT_CRMEMO-VKORG
AND VTWEG = IT_CRMEMO-VTWEG.
IF SY-SUBRC = 0.
SORT IT_MVKE BY MATNR VKORG VTWEG MTPOS.
ENDIF.
*-- Validate Item category group if MVKE-MTOPS <> 'BANS' then ignore CM Request line item
LOOP AT IT_CRMEMO INTO WA_CRMEMO.
LV_TABIX = SY-TABIX.
READ TABLE IT_MVKE INTO WA_MVKE WITH KEY MATNR = WA_CRMEMO-MATNR
VKORG = WA_CRMEMO-VKORG
VTWEG = WA_CRMEMO-VTWEG
MTPOS = C_MTPOS
BINARY SEARCH.
IF SY-SUBRC <> 0.
DELETE IT_CRMEMO INDEX LV_TABIX. " Delete CR memo records
ELSE.
*-- Else check for credit memo request change date is not initial, and
* append those records to IT_CRMEMO_CHANGE internal table to retrive
* change documents
IF NOT WA_CRMEMO-AEDAT IS INITIAL.
WA_CRMEMO_CHANGE-VBELN = WA_CRMEMO-VBELN.
WA_CRMEMO_CHANGE-POSNR = WA_CRMEMO-POSNR.
WA_CRMEMO_CHANGE-ERDAT = WA_CRMEMO-ERDAT.
WA_CRMEMO_CHANGE-AUART = WA_CRMEMO-AUART.
WA_CRMEMO_CHANGE-AUGRU = WA_CRMEMO-AUGRU.
WA_CRMEMO_CHANGE-WAERK = WA_CRMEMO-WAERK.
WA_CRMEMO_CHANGE-VKORG = WA_CRMEMO-VKORG.
WA_CRMEMO_CHANGE-VTWEG = WA_CRMEMO-VTWEG.
WA_CRMEMO_CHANGE-SPART = WA_CRMEMO-SPART.
WA_CRMEMO_CHANGE-VDATU = WA_CRMEMO-VDATU.
WA_CRMEMO_CHANGE-BSTNK = WA_CRMEMO-BSTNK.
WA_CRMEMO_CHANGE-BSARK = WA_CRMEMO-BSARK.
WA_CRMEMO_CHANGE-BSTDK = WA_CRMEMO-BSTDK.
WA_CRMEMO_CHANGE-AEDAT = WA_CRMEMO-AEDAT.
WA_CRMEMO_CHANGE-BUKRS_VF = WA_CRMEMO-BUKRS_VF.
WA_CRMEMO_CHANGE-MATNR = WA_CRMEMO-MATNR.
WA_CRMEMO_CHANGE-ZMENG = WA_CRMEMO-ZMENG.
WA_CRMEMO_CHANGE-ZIEME = WA_CRMEMO-ZIEME.
APPEND WA_CRMEMO_CHANGE TO IT_CRMEMO_CHANGE.
CLEAR WA_CRMEMO_CHANGE.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. " F_GET_MVKE_DOCS
*& Form F_GET_SO_PO_DOCS
* Fetch the Sales Order documents, PO documents, & Credit Memo
FORM F_GET_SO_PO_DOCS.
*-- Fetch Preceding sales orders based on the credit memo request
SELECT VBELV
POSNV
VBELN
POSNN
VBTYP_N
FROM VBFA
INTO TABLE IT_ORDERS
FOR ALL ENTRIES IN IT_CRMEMO
WHERE VBELN = IT_CRMEMO-VBELN
AND POSNN = IT_CRMEMO-POSNR
AND VBTYP_N = C_K
AND VBTYP_V = C_C.
IF SY-SUBRC = 0.
SORT IT_ORDERS BY VBELV POSNV.
*-- Fetch Subsequent PO documents & Credit Memo based on the sales orders
SELECT VBELV
POSNV
VBELN
POSNN
VBTYP_N
FROM VBFA
INTO TABLE IT_PO
FOR ALL ENTRIES IN IT_ORDERS
WHERE VBELV = IT_ORDERS-VBELV
AND POSNV = IT_ORDERS-POSNV
AND VBTYP_N IN (C_V,C_O)
AND VBTYP_V = C_C.
IF SY-SUBRC = 0.
SORT IT_PO BY VBTYP_N.
*-- Copy the IT_PO internal table contents to IT_CMEMO internal table
IT_CMEMO[] = IT_PO[].
*-- Delete PO documents from IT_CMEMO internal table
DELETE IT_CMEMO WHERE VBTYP_N = C_V.
SORT IT_CMEMO BY VBELN POSNN.
IF IT_CMEMO[] IS INITIAL.
MESSAGE I000 WITH 'No Credit Memo are available for CM Request'(003).
* v_flag = c_x.
* stop.
ENDIF.
*-- Delete Credit Memo documents from IT_PO internal table
DELETE IT_PO WHERE VBTYP_N = C_O.
SORT IT_PO BY VBELN POSNN.
ENDIF.
ENDIF.
ENDFORM. " F_GET_SO_PO_DOCS
*& Form F_GET_CHANGED_DOCS
* Fetch Change Documents for CR Memos from CDHDR and CDPOS tables
FORM F_GET_CHANGED_DOCS .
*-- Fetch Change Documents for CR Memos from CDHDR
SELECT OBJECTCLAS
OBJECTID
CHANGENR
UDATE
UTIME
FROM CDHDR
INTO TABLE IT_CDHDR
FOR ALL ENTRIES IN IT_CRMEMO_CHANGE
WHERE OBJECTCLAS = C_VERKBELEG
AND OBJECTID = IT_CRMEMO_CHANGE-VBELN
* AND UDATE = IT_CRMEMO_CHANGE-AEDAT
IF SY-SUBRC = 0.
SORT IT_CDHDR BY OBJECTCLAS OBJECTID CHANGENR.
*-- Fetch Change Documents for CR Memos from CDPOS
SELECT OBJECTCLAS
OBJECTID
CHANGENR
TABNAME
TABKEY
FNAME
CHNGIND
VALUE_NEW
VALUE_OLD
FROM CDPOS
INTO TABLE IT_CDPOS
FOR ALL ENTRIES IN IT_CDHDR
WHERE OBJECTCLAS = C_VERKBELEG
AND OBJECTID = IT_CDHDR-OBJECTID
AND CHANGENR = IT_CDHDR-CHANGENR
AND TABNAME = C_VBAK
AND FNAME = C_AUGRU
AND CHNGIND = C_U.
IF SY-SUBRC = 0.
SORT IT_CDPOS BY OBJECTCLAS OBJECTID CHANGENR.
ENDIF.
ENDIF.
ENDFORM. " F_GET_CHANGED_DOCS
*& Form F_GET_EKPO
* Fetch Purchasing Document Item Details
FORM F_GET_EKPO .
*-- Fetch Purchasing Document Item Details
SELECT A~EBELN
B~EBELP
A~WAERS
B~MENGE
B~MEINS
B~NETPR
B~PEINH
B~mwskz
B~TXJCD
INTO TABLE IT_EKPO
FROM ( EKKO AS A
INNER JOIN EKPO AS B ON A~EBELN = B~EBELN )
FOR ALL ENTRIES IN IT_PO
WHERE A~EBELN = IT_PO-VBELN
AND B~EBELP = IT_PO-POSNN+1(5).
IF SY-SUBRC = 0.
SORT IT_EKPO BY EBELN EBELP.
ENDIF.
ENDFORM. " F_GET_EKPO
*& Form F_GET_VENDOR
* Fetch MIRO Vendor details based on the PO Details
FORM F_GET_VENDOR .
DATA: LV_TABIX TYPE SY-TABIX.
*-- Fetch History per Purchasing Document records for all the PO records
SELECT EBELN
EBELP
ZEKKN
VGABE
GJAHR
BELNR
BUZEI
FROM EKBE
INTO TABLE IT_EKBE
FOR ALL ENTRIES IN IT_EKPO
WHERE EBELN = IT_EKPO-EBELN
AND EBELP = IT_EKPO-EBELP
AND VGABE = '2'.
* and STBLG = space.
IF SY-SUBRC = 0.
SORT IT_EKBE BY BELNR GJAHR.
*-- Fetch the vendor details based on table IT_EKBE internal table
SELECT BELNR
GJAHR
BLDAT
BUDAT
XBLNR
LIFNR
RMWWR
WMWST1
XRECH
STBLG
FROM RBKP
INTO TABLE IT_RBKP
FOR ALL ENTRIES IN IT_EKBE
WHERE BELNR = IT_EKBE-BELNR
AND GJAHR = IT_EKBE-GJAHR.
IF SY-SUBRC = 0.
SORT IT_RBKP BY BELNR GJAHR.
ENDIF.
ENDIF.
*-- Sort PO History documents based on PO # and PO Item
SORT IT_EKBE BY EBELN EBELP.
*-- Copy the PO History documents into IT_EKBE_TEMP internal table
IT_EKBE_TEMP[] = IT_EKBE[].
*-- Delete PO History documents from IT_EKBE_TEMP internal table
* comparing with IT_RBKP where (STBLG) Reversal document number
* is initial
LOOP AT IT_EKBE_TEMP INTO WA_EKBE_TEMP.
LV_TABIX = SY-TABIX.
READ TABLE IT_RBKP INTO WA_RBKP WITH KEY BELNR = WA_EKBE_TEMP-BELNR
GJAHR = WA_EKBE_TEMP-GJAHR
* XRECH = SPACE
STBLG = SPACE.
IF SY-SUBRC <> 0.
DELETE IT_EKBE_TEMP INDEX LV_TABIX.
ENDIF.
CLEAR: WA_EKBE_TEMP, WA_RBKP.
ENDLOOP.
ENDFORM. " F_GET_VENDOR
*& Form F_PROCESS_MIRO
* Process MIRO
FORM F_PROCESS_MIRO .
DATA:
lv_itemno TYPE i,
lv_tabix type sy-index,
lc_check(1) TYPE c VALUE 'X',
V_FILL_ITEM,
lv_rbkp_bldat type sy-datum.
clear : it_itemdata, it_accountingdata, IT_CRMEMO_MIRO, IT_CRMEMO_MR8M.
refresh : it_itemdata, it_accountingdata, IT_CRMEMO_MIRO, IT_CRMEMO_MR8M.
*-- Copy all the CR Memo Docs and delete order reason not in S_AUGRU
IT_CRMEMO_MR8M[] = IT_CRMEMO[].
*-- Delete Reversal postings which are not in S_AUGRU
DELETE IT_CRMEMO_MR8M WHERE AUGRU IN S_AUGRU.
*-- Delete Reversal postings where AEDAT is initial
DELETE IT_CRMEMO_MR8M where aedat is initial.
*-- Delete order reason which are not in S_AUGRU
DELETE IT_CRMEMO WHERE AUGRU NOT IN S_AUGRU.
*-- Loop through the credit memo request records
LOOP AT IT_CRMEMO INTO WA_CRMEMO.
lv_tabix = sy-tabix.
*-- If credit memo request change date is not initial then
* send change date (AEDAT) to lv_rbkp_bldat
if not WA_CRMEMO-aedat is initial.
lv_rbkp_bldat = WA_CRMEMO-aedat.
else.
*-- If credit memo request change date is initial then
* send create date (ERDAT) to lv_rbkp_bldat
lv_rbkp_bldat = WA_CRMEMO-erdat.
endif.
READ TABLE IT_ORDERS INTO WA_ORDERS WITH KEY VBELN = WA_CRMEMO-VBELN
POSNN = WA_CRMEMO-POSNR.
IF SY-SUBRC = 0.
READ TABLE IT_PO INTO WA_PO WITH KEY VBELV = WA_ORDERS-VBELV
POSNV = WA_ORDERS-POSNV.
IF SY-SUBRC = 0.
READ TABLE IT_EKPO INTO WA_EKPO WITH KEY EBELN = WA_PO-VBELN
EBELP = WA_PO-POSNN.
IF SY-SUBRC = 0.
*-- Read IT_EKBE_TEMP internal table which contains records which are not reversed
READ TABLE IT_EKBE_TEMP INTO WA_EKBE_TEMP WITH KEY EBELN = WA_EKPO-EBELN
EBELP = WA_EKPO-EBELP.
IF SY-SUBRC = 0.
*-- Read IT_RBKP internal table with XRECH (Indicator: post invoice) = 'X' ,
* check for invoice records for the correspnding CR Memo records
READ TABLE IT_RBKP INTO WA_RBKP WITH KEY BELNR = WA_EKBE_TEMP-BELNR
GJAHR = WA_EKBE_TEMP-GJAHR
XRECH = C_X.
IF SY-SUBRC = 0.
*-- Read IT_RBKP internal table with XRECH (Indicator: post invoice) = SPACE,
* and document date = CR Memo creation date
* and reference document number = PO number
READ TABLE IT_RBKP INTO WA_RBKP_TMP WITH KEY BELNR = WA_EKBE_TEMP-BELNR
GJAHR = WA_EKBE_TEMP-GJAHR
BLDAT = WA_CRMEMO-ERDAT
XRECH = ' '
XBLNR+0(10) = WA_EKBE_TEMP-ebeln.
* STBLG = SPACE.
IF SY-SUBRC = 0.
CONTINUE.
ELSE.
*-- Quantity Conversion (Get the Credit Memo Quantity by passing CMR unit per one PO unit)
perform f_quantity_conv.
*-- Filling the Line items data
*-- Incrementing the item no
lv_itemno = lv_itemno + 1.
v_itemno = lv_itemno.
it_itemdata-invoice_doc_item = v_itemno.
it_itemdata-po_number = WA_ekPO-ebeln.
it_itemdata-po_item = WA_EKPO-EBELP.
it_itemdata-tax_code = WA_ekpo-mwskz.
it_itemdata-TAXJURCODE = WA_ekpo-TXJCD.
*-- Converting SAP amount to BAPI format by passing line item amount and currency
PERFORM f_currency_amount_sap_to_bapi USING WA_EKPO-waers
V_LINE_AMOUNT
CHANGING it_itemdata-item_amount .
it_itemdata-quantity = ( WA_CRMEMO-ZMENG * V_CRMEMO_QTY ).
it_itemdata-po_unit = WA_EKPO-MEINS.
APPEND it_itemdata.
*-- Populate Account Assignment data
IT_ACCOUNTINGDATA-INVOICE_DOC_ITEM = v_itemno.
IT_ACCOUNTINGDATA-XUNPL = space.
IT_ACCOUNTINGDATA-SERIAL_NO = C_01.
IT_ACCOUNTINGDATA-TAX_CODE = it_itemdata-tax_code.
IT_ACCOUNTINGDATA-TAXJURCODE = it_itemdata-TAXJURCODE.
IT_ACCOUNTINGDATA-ITEM_AMOUNT = it_itemdata-item_amount.
IT_ACCOUNTINGDATA-QUANTITY = it_itemdata-quantity.
IT_ACCOUNTINGDATA-PO_UNIT = it_itemdata-po_unit.
IT_ACCOUNTINGDATA-GL_ACCOUNT = C_0000500205.
append IT_ACCOUNTINGDATA.
clear IT_ACCOUNTINGDATA.
CLEAR it_itemdata.
endif.
endif.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
*-- At end of each credit memo request fill the header details of BAPI FM and
*-- post the BAPI
AT END OF VBELN.
read table it_crmemo into wa_crmemo index lv_tabix.
*-- Populate the document Header
*-- Getting the header data for invoice
x_docheader-invoice_ind = space.
x_docheader-doc_type = c_blart.
x_docheader-doc_date = lv_rbkp_bldat.
x_docheader-pstng_date = lv_rbkp_bldat.
x_docheader-ref_doc_no = WA_RBKP-XBLNR.
x_docheader-comp_code = WA_CRMEMO-BUKRS_VF.
x_docheader-CURRENCY = WA_CRMEMO-WAERK.
x_docheader-calc_tax_ind = lc_check.
*-- Logic to find the Tax %
v_tax_per = ( WA_RBKP-WMWST1 / ( WA_RBKP-RMWWR - WA_RBKP-WMWST1 ) ) * 100.
v_tax_amt = ( V_GROSSAMT * v_tax_per ) / 100.
V_GROSSAMT = ( V_GROSSAMT + v_tax_amt ).
x_docheader-gross_amount = V_GROSSAMT.
CLEAR:v_docnr, v_year1.
*-- Calling BAPI to create PO invoice document
CHECK NOT IT_ITEMDATA[] IS INITIAL.
CALL FUNCTION 'BAPI_INCOMINGINVOICE_CREATE'
EXPORTING
headerdata = x_docheader
IMPORTING
invoicedocnumber = v_docnr
fiscalyear = v_year1
TABLES
itemdata = it_itemdata[]
ACCOUNTingDATA = it_ACCOUNTingDATA[]
* GLACCOUNTDATA =
* taxdata =
return = it_return.
*-- Commit work
IF NOT v_docnr IS INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
*-- Move the data to Success Internal Table
wa_success-crmemo = wa_crmemo-vbeln.
wa_success-cmemo = wa_cmemo-vbeln.
wa_success-orders = wa_orders-vbelv.
wa_success-po = wa_po-vbeln.
wa_success-miro_no = v_docnr.
wa_success-text = 'MIRO is Posted'.
append wa_success TO it_success.
clear wa_success.
ENDIF.
*-- Read the values in the table IT_RETURN.
CLEAR it_return.
READ TABLE it_return INDEX 1.
* If message type is error then roll back the work
IF it_return-type = C_E.
*-- Roll back
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
*-- Move the data to Error Internal Table
wa_error-crmemo = wa_crmemo-vbeln.
wa_error-cmemo = wa_cmemo-vbeln.
wa_error-orders = wa_orders-vbelv.
wa_error-po = wa_po-vbeln.
wa_error-text = it_return-MESSAGE.
append wa_error TO it_error.
clear wa_error.
ENDIF.
refresh: it_return, it_itemdata, it_accountingdata.
clear: V_GROSSAMT, it_return, it_itemdata, wa_crmemo, wa_orders, wa_po,
wa_ekpo, WA_EKBE_TEMP, wa_rbkp, wa_rbkp_tmp, v_docnr, v_year1, WA_SUCCESS,
WA_ERROR, it_accountingdata, v_tax_per, v_tax_amt, V_FILL_ITEM, lv_rbkp_bldat.
ENDAT.
ENDLOOP.
ENDFORM. " F_PROCESS_MIRO
*& Form f_quantity_conv
* Quantity Conversion
FORM f_quantity_conv .
*-- Quantity Conversion (Get the Credit Memo Quantity by passing CMR unit per one PO unit)
CLEAR: V_LINE_AMOUNT, V_CRMEMO_QTY.
call function 'MC_UNIT_CONVERSION'
EXPORTING
MATNR = WA_CRMEMO-MATNR
nach_meins = WA_EKPO-MEINS
von_meins = WA_CRMEMO-ZIEME
IMPORTING
UMREF = V_CRMEMO_QTY
EXCEPTIONS
CONVERSION_NOT_FOUND = 1
MATERIAL_NOT_FOUND = 2
NACH_MEINS_MISSING = 3
OVERFLOW = 4
VON_MEINS_MISSING = 5
OTHERS = 6.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
V_LINE_AMOUNT = ( V_CRMEMO_QTY * WA_CRMEMO-ZMENG * WA_EKPO-peinh * WA_EKPO-NETPR ).
V_GROSSAMT = V_GROSSAMT + V_LINE_AMOUNT.
ENDIF.
ENDFORM. " f_quantity_conv
*& Form f_currency_amount_sap_to_bapi
* SAP Amount to BAPI Amount
FORM f_currency_amount_sap_to_bapi USING p_waers
p_kbetr
CHANGING p_amt_doccur.
DATA : lv_waers LIKE tcurc-waers,
lv_sapamount LIKE bapicurr-bapicurr,
lv_bapi_amount LIKE bapicurr-bapicurr.
lv_waers = p_waers.
lv_sapamount = p_kbetr.
CALL FUNCTION 'CURRENCY_AMOUNT_SAP_TO_BAPI'
EXPORTING
currency = lv_waers
sap_amount = lv_sapamount
IMPORTING
bapi_amount = lv_bapi_amount.
p_amt_doccur = lv_bapi_amount.
ENDFORM. " f_currency_amount_sap_to_bapi
*& Form f_display_report
* Display Report
FORM f_display_report .
*-- Success Report
IF NOT IT_SUCCESS[] IS INITIAL.
ULINE AT /1(129).
WRITE:/1 sy-vline, 'CR Memo',
19 sy-vline, 'Credit Memo',
39 sy-vline, 'Sales Order',
59 sy-vline, 'Purchase Order',
79 sy-vline, 'MIRO Number',
99 sy-vline, 'Text',
129 sy-vline.
ULINE AT /1(129).
LOOP AT it_success into wa_success.
WRITE:/1 sy-vline, wa_success-crmemo,
19 sy-vline, wa_success-cmemo,
39 sy-vline, wa_success-orders,
59 sy-vline, wa_success-po,
79 sy-vline, wa_success-miro_no,
99 sy-vline, wa_success-text,
129 sy-vline.
ENDLOOP.
ULINE AT /1(129).
SKIP 2.
ENDIF.
*-- Error Report
IF NOT IT_ERROR[] IS INITIAL.
ULINE AT /1(179).
WRITE:/1 sy-vline, 'CR Memo',
19 sy-vline, 'Credit Memo',
39 sy-vline, 'Sales Order',
59 sy-vline, 'Purchase Order',
79 sy-vline, 'Error Text',
179 sy-vline.
ULINE AT /1(179).
LOOP AT IT_ERROR into WA_ERROR.
WRITE:/1 sy-vline, WA_ERROR-crmemo,
19 sy-vline, WA_ERROR-cmemo,
39 sy-vline, WA_ERROR-orders,
59 sy-vline, WA_ERROR-po,
79 sy-vline, WA_ERROR-text,
179 sy-vline.
ENDLOOP.
ULINE AT /1(179).
ENDIF.
IF NOT IT_SUCCESS_MR8M[] IS INITIAL.
ULINE AT /1(129).
WRITE:/1 sy-vline, 'CR Memo',
19 sy-vline, 'Credit Memo',
39 sy-vline, 'Sales Order',
59 sy-vline, 'Purchase Order',
79 sy-vline, 'Reversal Posting No.',
99 sy-vline, 'Text',
129 sy-vline.
ULINE AT /1(129).
LOOP AT it_success_mr8m into wa_success_mr8m.
WRITE:/1 sy-vline, wa_success_mr8m-crmemo,
19 sy-vline, wa_success_mr8m-cmemo,
39 sy-vline, wa_success_mr8m-orders,
59 sy-vline, wa_success_mr8m-po,
79 sy-vline, wa_success_mr8m-miro_no,
99 sy-vline, wa_success_mr8m-text,
129 sy-vline.
ENDLOOP.
ULINE AT /1(129).
SKIP 2.
ENDIF.
*-- Error Report
IF NOT IT_ERROR_MR8M[] IS INITIAL.
ULINE AT /1(179).
WRITE:/1 sy-vline, 'CR Memo',
19 sy-vline, 'Credit Memo',
39 sy-vline, 'Sales Order',
59 sy-vline, 'Purchase Order',
79 sy-vline, 'Error Text',
179 sy-vline.
ULINE AT /1(179).
LOOP AT IT_ERROR_MR8M into WA_ERROR_MR8M.
WRITE:/1 sy-vline, WA_ERROR_MR8M-crmemo,
19 sy-vline, WA_ERROR_MR8M-cmemo,
39 sy-vline, WA_ERROR_MR8M-orders,
59 sy-vline, WA_ERROR_MR8M-po,
79 sy-vline, WA_ERROR_MR8M-text,
179 sy-vline.
ENDLOOP.
ULINE AT /1(179).
ENDIF.
ENDFORM. " f_display_report
*& Form F_PROCESS_MR8M
* Process Reversal postings
FORM F_PROCESS_MR8M .
clear: wa_CRMEMO_MR8M.
LOOP AT IT_CRMEMO_MR8M into WA_CRMEMO_MR8M.
read table it_cdpos into wa_cdpos with key OBJECTID = WA_CRMEMO_MR8M-VBELN.
if sy-subrc <> 0.
CONTINUE.
ELSE.
if wa_cdpos-value_old in s_augru.
READ TABLE IT_ORDERS INTO WA_ORDERS WITH KEY VBELN = wa_CRMEMO_MR8M-VBELN
POSNN = wa_CRMEMO_MR8M-POSNR.
IF SY-SUBRC = 0.
* READ TABLE IT_CMEMO INTO WA_CMEMO WITH KEY VBELV = WA_ORDERS-VBELV
* POSNV = WA_ORDERS-POSNV.
* IF SY-SUBRC = 0.
READ TABLE IT_PO INTO WA_PO WITH KEY VBELV = WA_ORDERS-VBELV
POSNV = WA_ORDERS-POSNV.
IF SY-SUBRC = 0.
READ TABLE IT_EKPO INTO WA_EKPO WITH KEY EBELN = WA_PO-VBELN
EBELP = WA_PO-POSNN.
IF SY-SUBRC = 0.
* READ TABLE IT_EKBE INTO WA_EKBE WITH KEY EBELN = WA_EKPO-EBELN
* EBELP = WA_EKPO-EBELP.
* IF SY-SUBRC = 0.
LOOP AT IT_EKBE into WA_EKBE WHERE EBELN = WA_EKPO-EBELN
AND EBELP = WA_EKPO-EBELP.
READ TABLE IT_RBKP INTO WA_RBKP WITH KEY BELNR = WA_EKBE-BELNR
GJAHR = WA_EKBE-GJAHR
* BLDAT = WA_CRMEMO_MR8M-AEDAT
XBLNR+0(10) = WA_EKBE-EBELN
XRECH = SPACE
STBLG = SPACE.
IF SY-SUBRC = 0.
move: WA_RBKP-BELNR TO X_REV_POST-INV_DOC_NO,
WA_RBKP-GJAHR TO X_REV_POST-FISC_YEAR,
WA_RBKP-BUDAT TO X_REV_POST-PSTNG_DATE.
IF WA_RBKP-BUDAT+4(2) = SY-DATUM+4(2).
X_REV_POST-REASON_REV = C_01.
ELSE.
X_REV_POST-REASON_REV = C_02.
ENDIF.
ENDIF.
ENDLOOP.
*-- Call the FM for MIRO reversal
CALL FUNCTION 'BAPI_INCOMINGINVOICE_CANCEL'
EXPORTING
INVOICEDOCNUMBER = X_REV_POST-INV_DOC_NO
FISCALYEAR = X_REV_POST-FISC_YEAR
REASONREVERSAL = X_REV_POST-REASON_REV
POSTINGDATE = X_REV_POST-PSTNG_DATE
IMPORTING
INVOICEDOCNUMBER_REVERSAL = X_REV_POST-INV_DOC_NO
FISCALYEAR_REVERSAL = X_REV_POST-FISC_YEAR
TABLES
RETURN = it_return_mr8m.
*-- Commit work
IF NOT X_REV_POST-INV_DOC_NO IS INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
*-- Move the data to Success Internal Table
wa_success_mr8m-crmemo = wa_crmemo-vbeln.
wa_success_mr8m-cmemo = wa_cmemo-vbeln.
wa_success_mr8m-orders = wa_orders-vbelv.
wa_success_mr8m-po = wa_po-vbeln.
wa_success_mr8m-text = 'MR8M Done'.
append wa_success_mr8m TO it_success_mr8m.
clear wa_success_mr8m.
ENDIF.
*-- Read the values in the table IT_RETURN.
CLEAR it_return_mr8m.
READ TABLE it_return_mr8m INDEX 1.
*-- If message type is error then roll back the work
IF it_return_mr8m-type = 'E' .
*-- Roll back
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
*-- Move the data to Error Internal Table
wa_error_mr8m-crmemo = wa_crmemo-vbeln.
wa_error_mr8m-cmemo = wa_cmemo-vbeln.
wa_error_mr8m-orders = wa_orders-vbelv.
wa_error_mr8m-po = wa_po-vbeln.
wa_error_mr8m-text = it_return_mr8m-MESSAGE.
append wa_error_mr8m TO it_error_mr8m.
clear wa_error_mr8m.
ENDIF.
* ENDIF.
* ENDIF.
ENDIF.
ENDIF.
* ENDIF.
ENDIF.
ENDIF.
ENDIF.
CLEAR: wa_error_mr8m, wa_SUCCESS_mr8m, X_REV_POST, wa_CRMEMO_MR8M,
wa_orders, wa_po, wa_ekpo, wa_ekbe, wa_rbkp, wa_cmemo.
REFRESH: IT_RETURN_MR8M.
endloop.
ENDFORM. " F_PROCESS_MR8M
*& Form F_spool_id
* Create a new spool ID
FORM F_spool_id .
*-- Create a new spool from the data in data_tab
*-- new-page line-size sy-linsz print on
new-page line-size 255 print on
destination 'LOCL'(p19) "<<== my printer
*-- receiver 'TJOSVOB'
cover text 'Spool title'(p20) " <<== Title or Spool req. name
list name 'List name'(p21)
list dataset 'List Dataset'(p22)
immediately ' ' " X means print now
keep in spool c_x " X means keep spool
new list identification c_x
no dialog .
*-- Writing Report
*-- In this perform you will write the code for displaying the list
perform f_display_report.
*-- new-page print off
new-page print off.
ENDFORM. " F_spool_id
*& Form F_MAIL_LOGIC
* Logic to send a mail for the given Email ID's
FORM F_MAIL_LOGIC .
data : wa_tsp01sys type tsp01sys.
clear v_spono.
v_spono = sy-spono.
* v_attach_desc = sy-title.
*-- Convert the Spool ID into PDF format
perform f_pdf_conversion tables it_compressed_list
it_pdf_list
using v_spono.
*-- Send the Mail in PDF Format
perform f_send_mail.
ENDFORM. " F_MAIL_LOGIC
*& Form f_pdf_conversion
* Read the spool and convert into PDF format
* -->P_ITAB_COMPRESSED_LIST text
* -->P_ITAB_PDF_LIST text
* -->P_V_SPONO text
FORM f_pdf_conversion TABLES it_compressed_list structure soli
it_pdf_list structure tline
using lv_spooln type tsp01-rqident.
clear: it_compressed_list, it_pdf_list.
refresh: it_compressed_list, it_pdf_list.
*-- Call the FM "RSPO_RETURN_SPOOLJOB" to read the spool by passing the spool number
call function 'RSPO_RETURN_SPOOLJOB'
exporting
rqident = lv_spooln
desired_type = v_type
importing
real_type = v_type
tables
buffer = it_compressed_list
buffer_pdf = it_pdf_list
exceptions
no_such_job = 1
job_contains_no_data = 2
selection_empty = 3
no_permission = 4
can_not_access = 5
read_error = 6
type_no_match = 7
others = 8.
if sy-subrc <> 0.
message I000 with 'Error in spool reading'(017).
endif.
*-- If the List type is ALI call the FM "CONVERT_ABAPSPOOLJOB_2_PDF"
* to convert list into PDF Format
if v_type = c_ali. " for List it is ALI
call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
exporting
src_spoolid = lv_spooln
tables
pdf = it_pdf
exceptions
err_no_abap_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_destdevice = 5
user_cancelled = 6
err_spoolerror = 7
err_temseerror = 8
err_btcjob_open_failed = 9
err_btcjob_submit_failed = 10
err_btcjob_close_failed = 11
others = 12.
if sy-subrc <> 0.
message e000
with'Error in convertion of list into PDF format'(018).
endif.
*-- Logic to convert the given format into 255 character format in IT_PDF
describe table it_pdf lines v_lines.
describe field it_pdf length v_lineslen IN character MODE.
describe field it_temp length v_mimelen IN character MODE.
LOOP AT it_pdf.
v_tabix = sy-tabix.
MOVE it_pdf TO v_temp+v_offset.
IF v_tabix = v_lines.
v_lineslen = strlen( it_pdf ).
ENDIF.
v_offset = v_offset + v_lineslen.
IF v_offset GE v_mimelen.
CLEAR it_temp.
it_temp = v_temp(v_mimelen).
APPEND it_temp.
SHIFT v_temp BY v_mimelen PLACES.
v_offset = v_offset - v_mimelen.
ENDIF.
IF v_tabix = v_lines.
IF v_offset GT 0.
CLEAR it_temp.
it_temp = v_temp(v_offset).
APPEND it_temp.
ENDIF.
ENDIF.
ENDLOOP.
LOOP AT it_temp.
it_mime(255) = it_temp-line.
APPEND it_mime.
ENDLOOP.
*-- Final Data to send to EMail
it_html[] = it_mime[].
endif.
ENDFORM. " f_pdf_conversion
*& Form f_send_mail
* Send EMail Logic
FORM f_send_mail .
data : wa_tsp01sys type tsp01sys.
*-- Populate Mail Id's
WA_RECLIST-REC_TYPE = P_MODE.
WA_RECLIST-EXPRESS = C_X.
*-- Loop through the Emial select options
LOOP AT S_EMAIL INTO X_EMAIL.
WA_RECLIST-RECEIVER = X_EMAIL-LOW.
*-- append receiver table
APPEND WA_RECLIST TO IT_RECLIST.
ENDLOOP.
*-- If receiver table is not initial
CHECK IT_RECLIST[] IS NOT INITIAL.
*--To check Mail ID's internal table should not be Empty.
*--populate document attributes
*-- Mail subject line
CLEAR: X_DOC_CHNG.
X_DOC_CHNG-OBJ_NAME = 'HEADING'.
CONCATENATE 'Automatic Vendor Dedit Postings'(005)
SY-DATUM
INTO X_DOC_CHNG-OBJ_DESCR SEPARATED BY SPACE.
*-- Mail body
CONCATENATE 'Automatic Vendor Dedit Postings'(005)
' is attached.'(006)
INTO WA_OBJTXT SEPARATED BY SPACE.
APPEND WA_OBJTXT TO IT_OBJTXT.
*-- Append Date and Time into Body of em -
LSMW to upload Vendor Master Data
Hi,
I am trying to upload the vendor data for more than 1000 records from flat file structure to sap using LSMW (standard batch/ direct input) for XK01 transaction code. For uploading the house and street address i have created additional fields STR_SUPPL1 and STR_SUPPL2 in addition to STRAS. But in "Maintain Field Mapping and Conversion Rules" I am not able to locate the fields for mapping STR_SUPPL1 and STR_SUPPL2. Can any one please suggest me how to go about it. Thanks in advance.
Regards,
SangramHi sangram,
Vendor master details r stored in table LFA1..as u can c the additional fields r not loaded in this table..so i dont think u can upload the same using this LSMW alone. u may have to upload ur additional fields using another LSMW for Streets(direct input) or else use Recording method for ur requirement.
Hope it helps,
Regards,
Bikash
Hi sangram,
sorry cudnt figure out how we can relate the two. u may have to do some uploads n chk in tables how they r getting uploaded. Else, y dont u try out recording option??
Message was edited by: Bikash Agarwal -
BAPI or FM to create Vendor Master
I need a BAPI or FM/API to create a vendor master. Yes I know, there is BAPI_VENDOR_CREATE but it does not allow you to import any data. Is there a BAPI/FM/API that creates a vendor master while allowing you to import data (like BAPI_MATERIAL_SAVEDATA for materials).
Thanks,
DavisRefer to the following and award points if useful.BAPI is like using standard function modules.We will populate the parameters and handle errors from that.See the code below which is vendor debit posting.You can get an idea by the following code.
See the start of selection if this is confusing to you and understand the usage
TABLES
TABLES: VBAK,
ADR6,
TRDYSE01CM.
INCLUDE
INCLUDE ZZUTI_STD_HEADER_FOOTER. "Standard header and footer
TYPES DECLARATION
TYPES:
BEGIN OF T_CRMEMO,
VBELN TYPE VBAK-VBELN,
POSNR TYPE VBAP-POSNR,
ERDAT TYPE VBAK-ERDAT,
AUART TYPE VBAK-AUART,
AUGRU TYPE VBAK-AUGRU,
WAERK TYPE VBAK-WAERK,
VKORG TYPE VBAK-VKORG,
VTWEG TYPE VBAK-VTWEG,
SPART TYPE VBAK-SPART,
VDATU TYPE VBAK-VDATU,
BSTNK TYPE VBAK-BSTNK,
BSARK TYPE VBAK-BSARK,
BSTDK TYPE VBAK-BSTDK,
AEDAT TYPE VBAK-AEDAT,
BUKRS_VF TYPE VBAK-BUKRS_VF,
MATNR TYPE VBAP-MATNR,
ZMENG TYPE VBAP-ZMENG,
ZIEME TYPE VBAP-ZIEME,
END OF T_CRMEMO,
BEGIN OF T_CRMEMO_CHANGE,
VBELN(90) TYPE C,
POSNR TYPE VBAP-POSNR,
ERDAT TYPE VBAK-ERDAT,
AUART TYPE VBAK-AUART,
AUGRU TYPE VBAK-AUGRU,
WAERK TYPE VBAK-WAERK,
VKORG TYPE VBAK-VKORG,
VTWEG TYPE VBAK-VTWEG,
SPART TYPE VBAK-SPART,
VDATU TYPE VBAK-VDATU,
BSTNK TYPE VBAK-BSTNK,
BSARK TYPE VBAK-BSARK,
BSTDK TYPE VBAK-BSTDK,
AEDAT TYPE VBAK-AEDAT,
BUKRS_VF TYPE VBAK-BUKRS_VF,
MATNR TYPE VBAP-MATNR,
ZMENG TYPE VBAP-ZMENG,
ZIEME TYPE VBAP-ZIEME,
END OF T_CRMEMO_CHANGE,
BEGIN OF T_MVKE,
MATNR TYPE MVKE-MATNR,
VKORG TYPE MVKE-VKORG,
VTWEG TYPE MVKE-VTWEG,
MTPOS TYPE MVKE-MTPOS,
END OF T_MVKE,
BEGIN OF T_ORDERS,
VBELV TYPE VBFA-VBELV,
POSNV TYPE VBFA-POSNV,
VBELN TYPE VBFA-VBELN,
POSNN TYPE VBFA-POSNN,
VBTYP_N TYPE VBFA-VBTYP_N,
END OF T_ORDERS,
BEGIN OF T_EKPO,
EBELN TYPE EKKO-EBELN,
EBELP TYPE EKPO-EBELP,
WAERS TYPE EKKO-WAERS,
MENGE TYPE EKPO-MENGE,
MEINS TYPE EKPO-MEINS,
NETPR TYPE EKPO-NETPR,
PEINH TYPE EKPO-PEINH,
mwskz TYPE EKPO-mwskz,
TXJCD TYPE EKPO-TXJCD,
END OF T_EKPO,
BEGIN OF T_EKBE,
EBELN TYPE EKBE-EBELN,
EBELP TYPE EKBE-EBELP,
ZEKKN TYPE EKBE-ZEKKN,
VGABE TYPE EKBE-VGABE,
GJAHR TYPE EKBE-GJAHR,
BELNR TYPE EKBE-BELNR,
BUZEI TYPE EKBE-BUZEI,
END OF T_EKBE,
BEGIN OF T_RBKP,
BELNR TYPE RBKP-BELNR,
GJAHR TYPE RBKP-GJAHR,
BLDAT TYPE RBKP-BLDAT,
BUDAT TYPE RBKP-BUDAT,
XBLNR TYPE RBKP-XBLNR,
LIFNR TYPE RBKP-LIFNR,
RMWWR TYPE RBKP-RMWWR,
WMWST1 TYPE RBKP-WMWST1,
XRECH TYPE RBKP-XRECH,
STBLG TYPE RBKP-STBLG,
END OF T_RBKP,
BEGIN OF T_CDHDR,
OBJECTCLAS TYPE CDHDR-OBJECTCLAS,
OBJECTID TYPE CDHDR-OBJECTID,
CHANGENR TYPE CDHDR-CHANGENR,
UDATE TYPE CDHDR-UDATE,
UTIME TYPE CDHDR-UTIME,
END OF T_CDHDR,
BEGIN OF T_CDPOS,
OBJECTCLAS TYPE CDHDR-OBJECTCLAS,
OBJECTID TYPE CDHDR-OBJECTID,
CHANGENR TYPE CDHDR-CHANGENR,
TABNAME TYPE CDPOS-TABNAME,
TABKEY TYPE CDPOS-TABKEY,
FNAME TYPE CDPOS-FNAME,
CHNGIND TYPE CDPOS-CHNGIND,
VALUE_NEW TYPE CDPOS-VALUE_NEW,
VALUE_OLD TYPE CDPOS-VALUE_OLD,
END OF T_CDPOS,
BEGIN OF T_CHANGE_DOCS,
OBJECTCLAS TYPE CDHDR-OBJECTCLAS,
OBJECTID TYPE CDHDR-OBJECTID,
CHANGENR TYPE CDHDR-CHANGENR,
UDATE TYPE CDHDR-UDATE,
UTIME TYPE CDHDR-UTIME,
TABNAME TYPE CDPOS-TABNAME,
TABKEY TYPE CDPOS-TABKEY,
FNAME TYPE CDPOS-FNAME,
CHNGIND TYPE CDPOS-CHNGIND,
VALUE_NEW TYPE CDPOS-VALUE_NEW,
VALUE_OLD TYPE CDPOS-VALUE_OLD,
END OF T_CHANGE_DOCS,
BEGIN OF T_SUCCESS,
crmemo TYPE VBAK-vbeln,
cmemo TYPE VBAK-vbeln,
orders TYPE VBAK-vbeln,
po TYPE VBAK-vbeln,
miro_no TYPE VBAK-vbeln,
text(20) TYPE C,
END OF T_SUCCESS,
BEGIN OF T_ERROR,
crmemo TYPE VBAK-vbeln,
cmemo TYPE VBAK-vbeln,
orders TYPE VBAK-vbeln,
po TYPE VBAK-vbeln,
miro_no TYPE VBAK-vbeln,
text(100) TYPE C,
END OF T_ERROR.
WORKAREA DECLARATION
DATA:
WA_CRMEMO TYPE T_CRMEMO,
WA_CRMEMO_CHANGE TYPE T_CRMEMO_CHANGE,
WA_MVKE TYPE T_MVKE,
WA_ORDERS TYPE T_ORDERS,
WA_CMEMO TYPE T_ORDERS,
WA_PO TYPE T_ORDERS,
WA_EKPO TYPE T_EKPO,
WA_EKBE TYPE T_EKBE,
WA_EKBE_TEMP TYPE T_EKBE,
WA_RBKP TYPE T_RBKP,
WA_RBKP_TMP TYPE T_RBKP,
WA_CDHDR TYPE T_CDHDR,
WA_CDPOS TYPE T_CDPOS,
WA_CHANGE_DOCS TYPE T_CHANGE_DOCS,
WA_CRMEMO_MR8M TYPE T_CRMEMO,
WA_SUCCESS TYPE T_SUCCESS,
WA_ERROR TYPE T_ERROR,
WA_SUCCESS_MR8M TYPE T_SUCCESS,
WA_ERROR_MR8M TYPE T_ERROR.
*--Work area for all the internal tables used for Sending Mail
DATA :
WA_OBJPACK TYPE SOPCKLSTI1,
WA_OBJHEAD TYPE SOLISTI1,
WA_OBJBIN TYPE SOLISTI1,
WA_OBJTXT TYPE SOLISTI1,
WA_RECLIST TYPE SOMLRECI1 .
DATA:
*-- Structure to hold Invoice Header Data
x_docheader LIKE bapi_incinv_create_header,
*-- Structure to hold Reversal Posting Data
x_rev_post LIKE BAPI_INCINV_FLD.
INTERNAL TAABLE DECLARATION
DATA:
IT_CRMEMO TYPE STANDARD TABLE OF T_CRMEMO WITH HEADER LINE,
IT_CRMEMO_CHANGE TYPE STANDARD TABLE OF T_CRMEMO_CHANGE WITH HEADER LINE,
IT_MVKE TYPE STANDARD TABLE OF T_MVKE WITH HEADER LINE,
IT_CRMEMO_MIRO TYPE STANDARD TABLE OF T_CRMEMO WITH HEADER LINE,
IT_CRMEMO_MR8M TYPE STANDARD TABLE OF T_CRMEMO WITH HEADER LINE,
IT_ORDERS TYPE STANDARD TABLE OF T_ORDERS WITH HEADER LINE,
IT_CMEMO TYPE STANDARD TABLE OF T_ORDERS WITH HEADER LINE,
IT_PO TYPE STANDARD TABLE OF T_ORDERS WITH HEADER LINE,
IT_EKPO TYPE STANDARD TABLE OF T_EKPO WITH HEADER LINE,
IT_EKBE TYPE STANDARD TABLE OF T_EKBE WITH HEADER LINE,
IT_EKBE_TEMP TYPE STANDARD TABLE OF T_EKBE WITH HEADER LINE,
IT_RBKP TYPE STANDARD TABLE OF T_RBKP WITH HEADER LINE,
IT_CDHDR TYPE STANDARD TABLE OF T_CDHDR WITH HEADER LINE,
IT_CDPOS TYPE STANDARD TABLE OF T_CDPOS WITH HEADER LINE,
IT_CHANGE_DOCS TYPE STANDARD TABLE OF T_CHANGE_DOCS WITH HEADER LINE,
IT_SUCCESS TYPE STANDARD TABLE OF T_SUCCESS WITH HEADER LINE,
IT_ERROR TYPE STANDARD TABLE OF T_ERROR WITH HEADER LINE,
IT_SUCCESS_MR8M TYPE STANDARD TABLE OF T_SUCCESS WITH HEADER LINE,
IT_ERROR_MR8M TYPE STANDARD TABLE OF T_ERROR WITH HEADER LINE.
*-- Internal table to hold Invoice Item Data
DATA:BEGIN OF it_itemdata OCCURS 0.
INCLUDE STRUCTURE bapi_incinv_create_item.
DATA:END OF it_itemdata.
*-- Internal table to hold Invoice Acct Assignment Data
DATA:BEGIN OF it_ACCOUNTingdata OCCURS 0.
INCLUDE STRUCTURE BAPI_INCINV_CREATE_ACCOUNT.
DATA:END OF it_accountingdata.
*-- Internal table to hold BAPI return data
DATA: BEGIN OF it_return OCCURS 0.
INCLUDE STRUCTURE bapiret2. "Return Parameter.
DATA: END OF it_return.
*-- Internal table to hold BAPI return data
DATA: BEGIN OF it_return_mr8m OCCURS 0.
INCLUDE STRUCTURE bapiret2. "Return Parameter.
DATA: END OF it_return_mr8m.
*--MAIL related Internal tables
DATA: X_DOC_CHNG TYPE SODOCCHGI1, " document attributes
IT_OBJPACK TYPE STANDARD TABLE OF SOPCKLSTI1, " attachment table
IT_OBJHEAD TYPE STANDARD TABLE OF SOLISTI1, " object header table
IT_OBJBIN TYPE STANDARD TABLE OF SOLISTI1, " binary table
IT_OBJTXT TYPE STANDARD TABLE OF SOLISTI1, " object text
IT_RECLIST TYPE STANDARD TABLE OF SOMLRECI1, " mail recipients
it_compressed_list TYPE STANDARD TABLE OF SOLI,
it_pdf_list TYPE STANDARD TABLE OF TLINE,
it_pdf TYPE tline OCCURS 10 WITH HEADER LINE,
it_html TYPE solisti1 OCCURS 10 WITH HEADER LINE,
*-- Internal table for MIME data (in CHAR format)
it_temp TYPE bapiqcmime OCCURS 10 WITH HEADER LINE,
*-- Internal table for storing data
it_mime(255) TYPE c OCCURS 10 WITH HEADER LINE.
GLOBAL VARIABLES *
DATA: V_PGM_ID TYPE SY-REPID, " Program id
v_zterm TYPE lfb1-zterm, " Payment Terms
v_text(75) TYPE c, " To store error or success text
v_itemno(6) TYPE n, " To Increment Item No. for BAPI
v_docnr LIKE bapi_incinv_fld-inv_doc_no, " For MIRO document number
v_year1 LIKE bapi_incinv_fld-fisc_year, " For MIRO Fiscal year
v_spono type TSP01-RQIDENT, " For Spool No.
v_type type SOODK-OBJTP, " For Spool Type
V_CRMEMO_QTY TYPE VBAP-ZMENG, " For CR Memo Qty.
V_LINE_AMOUNT TYPE EKPO-NETPR, " For CR Memo Item Qty.
V_GROSSAMT TYPE EKPO-NETPR, " For CR Memo Grand Qty.
v_tax_per(3) type n, " For CR Memo Tax amount %
v_tax_amt TYPE EKPO-NETPR, " For CR Memo Tax amount
v_flag(1) type c, " Flag to process fruther
v_tot_s_mr8m TYPE i, " For MR8M Success Records
v_tot_e_mr8m TYPE i, " For MR8M Error Records
V_DATE TYPE SY-DATUM, " For Sel. Screen Date
V_DATE2(10) TYPE C, " For EMail Date
V_TIME(10) TYPE C, " For EMail Time
V_TIME2(10) TYPE C, " For EMail Time
V_INFO(100) TYPE C, " For EMail Body Text
V_TABLE_LINES TYPE SY-TABIX, " To Increment Email Count
V_TEXT2 TYPE STRING , " For EMail Id text
v_lines TYPE i, " To Store PDF Lines
v_temp(500) TYPE c, " To Convert to 255 char format
v_offset TYPE p, " To Convert to 255 char format
v_lineslen TYPE i, " To Convert to 255 char format
v_mimelen TYPE i, " To Convert to 255 char format
v_tabix type sy-tabix. " To Convert to 255 char format
CONSTANTS *
CONSTANTS:
C_X(1) TYPE C VALUE 'X', " Constant X or Flag
C_E(1) TYPE C VALUE 'E', " For Error check
c_v(1) TYPE C VALUE 'V', " For PO Docs
c_o(1) TYPE C VALUE 'O', " For Order Docs
c_c(1) TYPE C VALUE 'C', " For Credit Memo Docs
c_k(1) TYPE C VALUE 'K', " For CR Memo Docs
c_u(1) TYPE C VALUE 'U', " For Change tables Update
c_ali(3) TYPE C VALUE 'ALI', " For ALI Format
c_vbak(4) TYPE C VALUE 'VBAK', " For Change docs table
C_01(2) TYPE C VALUE '01', " For Serial No. & Reversal Reason
C_02(2) TYPE C VALUE '02', " For Reversal Reason
c_blart TYPE bkpf-blart VALUE 'RE', " Document type
C_MTPOS TYPE MVKE-MTPOS VALUE 'BANS', " Item Category group
C_AUGRU(5) TYPE C VALUE 'AUGRU', " Reason Code
C_0000500205(10) TYPE C VALUE '0000500205', " GL Account #
C_VERKBELEG(9) TYPE C VALUE 'VERKBELEG'. " For Object Class
*-- Horizontal tab & line feed constants
CLASS CL_ABAP_CHAR_UTILITIES DEFINITION LOAD.
CONSTANTS:
C_TAB TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB,
C_CR_LF TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF .
SELECTION SCREEN
*-- Select Optons
SELECTION-SCREEN: BEGIN OF BLOCK B01 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: S_AUART FOR VBAK-AUART OBLIGATORY NO INTERVALS,
" Sales Document Type
S_AUGRU FOR VBAK-AUGRU OBLIGATORY NO INTERVALS,
" Order reason
S_ERDAT FOR VBAK-ERDAT OBLIGATORY.
" Date on which the record was created
SELECTION-SCREEN: END OF BLOCK B01.
*-- Mail Sending Options
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-004.
PARAMETERS:P_EMAIL AS CHECKBOX DEFAULT SPACE USER-COMMAND V_COM .
PARAMETERS : P_MODE TYPE SO_ESCAPE default 'U' MODIF ID US1.
SELECT-OPTIONS: S_EMAIL FOR ADR6-SMTP_ADDR
NO INTERVALS MODIF ID US2.
SELECT-OPTIONS: S_EMAIL FOR TRDYSE01CM-USERNAME
NO INTERVALS MODIF ID US2.
SELECTION-SCREEN: BEGIN OF LINE.
SELECTION-SCREEN: COMMENT 55(40) TEXT-019 MODIF ID US2.
SELECTION-SCREEN: END OF LINE.
SELECTION-SCREEN END OF BLOCK B2.
WORK AREA for SELECT-OPTIONS
DATA : X_EMAIL LIKE S_EMAIL. "Work area for EMAIL select-options
INITIALIZATION
INITIALIZATION.
*-- Default values for Sales Document Type
CLEAR S_AUART[].
S_AUART-SIGN = 'I'.
S_AUART-OPTION = 'EQ'.
S_AUART-LOW = 'CR'.
APPEND S_AUART.
CLEAR S_AUART.
*-- Default values for Date on which the record was created
V_DATE = ( SY-DATUM - 1 ).
CLEAR S_ERDAT[].
S_ERDAT-SIGN = 'I'.
S_ERDAT-OPTION = 'EQ'.
S_ERDAT-LOW = SY-DATUM.
S_ERDAT-HIGH = SY-DATUM.
APPEND S_ERDAT.
CLEAR S_ERDAT.
TOP OF PAGE *
TOP-OF-PAGE.
*-- Displaying standard header.
PERFORM std_top_of_page USING sy-title.
A T S E L E C T I O N S C R E E N O U T P U T
*-- For modifying the selection screen layout
AT SELECTION-SCREEN OUTPUT.
PERFORM F_MODIFY_SCREEN.
AT SELECTION SCREEN. *
AT SELECTION-SCREEN.
*-- Subroutine to Validate selection screen fields
PERFORM f_validate.
START-OF-SELECTION *
*START-OF-SELECTION.*
**-- Fetch the Credit Memo Requests documents*
*PERFORM F_GET_CREDIT_MEMO_REQUEST.*
*IF NOT IT_CRMEMO[] IS INITIAL.*
**-- Fetch Item Category Group*
*PERFORM F_GET_MVKE_DOCS.*
**-- Fetch Sales Order documents, PO Documents and Credit Memos*
*PERFORM F_GET_SO_PO_DOCS.*
*ENDIF.*
**-- If Credit memo request internal table have an change records then*
fetch the change documents from CDHDR and CDPOS*
*IF NOT IT_CRMEMO_CHANGE[] IS INITIAL.*
**-- Fetch Change Documents for CR Memos from CDHDR and CDPOS tables*
*PERFORM F_GET_CHANGED_DOCS.*
*ENDIF.*
**-- Fetch Purchasing Document Item Details*
*IF NOT IT_PO[] IS INITIAL.*
*PERFORM F_GET_EKPO.*
*ENDIF.*
**-- Fetch MIRO Vendor based on the PO Details*
IF NOT IT_EKPO[] IS INITIAL.
PERFORM F_GET_VENDOR.
ENDIF.
END-OF-SELECTION *
if v_flag is initial.
*-- Process Vendor Debit Postings
PERFORM F_PROCESS_MIRO.
*-- Process Reversal Postings of Vendor Automatic Debits using TCODE MR8M
PERFORM F_PROCESS_MR8M.
*-- Send mail,if user enters Email id's and Email Mode is not initial
IF P_EMAIL = C_X AND P_MODE IS NOT INITIAL AND S_EMAIL[] IS NOT INITIAL.
*-- Get spool id
perform f_spool_id.
*-- EMail Logic
PERFORM F_MAIL_LOGIC.
ENDIF.
*-- display the EMail RSCONN01 and Sussess and Error records of MIRO and MR8M
perform f_display_report.
else.
*-- Else exit the process
exit.
endif.
*& Form F_MODIFY_SCREEN
A Form routine to modify the screen
FORM F_MODIFY_SCREEN .
*-- To Modify Mail Sending Options
LOOP AT SCREEN.
IF P_EMAIL = C_X.
IF SCREEN-GROUP1 = 'US1' .
SCREEN-INVISIBLE = 0.
SCREEN-ACTIVE = 1.
SCREEN-INPUT = 0.
MODIFY SCREEN.
ENDIF.
IF SCREEN-GROUP2 = 'US2' .
SCREEN-INVISIBLE = 0.
SCREEN-ACTIVE = 1.
MODIFY SCREEN.
ENDIF.
ELSEIF P_EMAIL = SPACE.
IF SCREEN-GROUP1 = 'US1' .
SCREEN-INVISIBLE = 1.
SCREEN-ACTIVE = 0.
MODIFY SCREEN.
ENDIF.
IF SCREEN-GROUP1 = 'US2' .
SCREEN-INVISIBLE = 1.
SCREEN-ACTIVE = 0.
MODIFY SCREEN.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. " F_MODIFY_SCREEN
*& Form f_validate
Validation of Selection-Screen Inputs
FORM f_validate .
*-- Validate Sales Document Type
if not s_AUART[] is initial.
select AUART
into s_AUART-low
from TVAK up to 1 rows
where AUART in s_AUART.
endselect.
if sy-subrc 0.
message E000 with 'Invalid Sales Document Type'(e01) .
endif.
ENDIF.
*-- Validate Order reason (reason for the business transaction)
if not s_AUGRU[] is initial.
select AUGRU
into s_AUGRU-low
from TVAU up to 1 rows
where AUGRU in s_AUGRU.
endselect.
if sy-subrc 0.
message E000 with 'Invalid Order reason'(e02) .
endif.
endif.
ENDFORM. " f_validate
*& Form F_GET_CREDIT_MEMO_REQUEST
Fetch Credit memo requests from VBAK & VBAP
FORM F_GET_CREDIT_MEMO_REQUEST .
SELECT A~VBELN
B~POSNR
A~ERDAT
A~AUART
A~AUGRU
A~WAERK
A~VKORG
A~VTWEG
A~SPART
A~VDATU
A~BSTNK
A~BSARK
A~BSTDK
A~AEDAT
A~BUKRS_VF
B~MATNR
B~ZMENG
B~ZIEME
INTO TABLE IT_CRMEMO
FROM ( VBAK AS A
INNER JOIN VBAP AS B ON AVBELN = BVBELN )
WHERE ( A~ERDAT IN S_ERDAT
OR A~AEDAT IN S_ERDAT )
AND A~AUART IN S_AUART.
IF SY-SUBRC = 0.
SORT IT_CRMEMO BY VBELN POSNR.
ELSE.
MESSAGE I000 WITH 'No Credit Memo Request selected'(002).
v_flag = C_X.
stop.
ENDIF.
ENDFORM. " F_GET_CREDIT_MEMO_REQUEST
*& Form F_GET_MVKE_DOCS
Fetch Sales Data for Material
FORM F_GET_MVKE_DOCS .
DATA: LV_TABIX TYPE SY-TABIX.
*-- Fetch Sales Data for Material
SELECT MATNR " Material Number
VKORG " Sales Organization
VTWEG " Distribution Channel
MTPOS " Item category group from material master
FROM MVKE " Sales Data for Material
INTO TABLE IT_MVKE
FOR ALL ENTRIES IN IT_CRMEMO
WHERE MATNR = IT_CRMEMO-MATNR
AND VKORG = IT_CRMEMO-VKORG
AND VTWEG = IT_CRMEMO-VTWEG.
IF SY-SUBRC = 0.
SORT IT_MVKE BY MATNR VKORG VTWEG MTPOS.
ENDIF.
*-- Validate Item category group if MVKE-MTOPS 'BANS' then ignore CM Request line item
LOOP AT IT_CRMEMO INTO WA_CRMEMO.
LV_TABIX = SY-TABIX.
READ TABLE IT_MVKE INTO WA_MVKE WITH KEY MATNR = WA_CRMEMO-MATNR
VKORG = WA_CRMEMO-VKORG
VTWEG = WA_CRMEMO-VTWEG
MTPOS = C_MTPOS
BINARY SEARCH.
IF SY-SUBRC 0.
DELETE IT_CRMEMO INDEX LV_TABIX. " Delete CR memo records
ELSE.
*-- Else check for credit memo request change date is not initial, and
append those records to IT_CRMEMO_CHANGE internal table to retrive
change documents
IF NOT WA_CRMEMO-AEDAT IS INITIAL.
WA_CRMEMO_CHANGE-VBELN = WA_CRMEMO-VBELN.
WA_CRMEMO_CHANGE-POSNR = WA_CRMEMO-POSNR.
WA_CRMEMO_CHANGE-ERDAT = WA_CRMEMO-ERDAT.
WA_CRMEMO_CHANGE-AUART = WA_CRMEMO-AUART.
WA_CRMEMO_CHANGE-AUGRU = WA_CRMEMO-AUGRU.
WA_CRMEMO_CHANGE-WAERK = WA_CRMEMO-WAERK.
WA_CRMEMO_CHANGE-VKORG = WA_CRMEMO-VKORG.
WA_CRMEMO_CHANGE-VTWEG = WA_CRMEMO-VTWEG.
WA_CRMEMO_CHANGE-SPART = WA_CRMEMO-SPART.
WA_CRMEMO_CHANGE-VDATU = WA_CRMEMO-VDATU.
WA_CRMEMO_CHANGE-BSTNK = WA_CRMEMO-BSTNK.
WA_CRMEMO_CHANGE-BSARK = WA_CRMEMO-BSARK.
WA_CRMEMO_CHANGE-BSTDK = WA_CRMEMO-BSTDK.
WA_CRMEMO_CHANGE-AEDAT = WA_CRMEMO-AEDAT.
WA_CRMEMO_CHANGE-BUKRS_VF = WA_CRMEMO-BUKRS_VF.
WA_CRMEMO_CHANGE-MATNR = WA_CRMEMO-MATNR.
WA_CRMEMO_CHANGE-ZMENG = WA_CRMEMO-ZMENG.
WA_CRMEMO_CHANGE-ZIEME = WA_CRMEMO-ZIEME.
APPEND WA_CRMEMO_CHANGE TO IT_CRMEMO_CHANGE.
CLEAR WA_CRMEMO_CHANGE.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. " F_GET_MVKE_DOCS
*& Form F_GET_SO_PO_DOCS
Fetch the Sales Order documents, PO documents, & Credit Memo
FORM F_GET_SO_PO_DOCS.
*-- Fetch Preceding sales orders based on the credit memo request
SELECT VBELV
POSNV
VBELN
POSNN
VBTYP_N
FROM VBFA
INTO TABLE IT_ORDERS
FOR ALL ENTRIES IN IT_CRMEMO
WHERE VBELN = IT_CRMEMO-VBELN
AND POSNN = IT_CRMEMO-POSNR
AND VBTYP_N = C_K
AND VBTYP_V = C_C.
IF SY-SUBRC = 0.
SORT IT_ORDERS BY VBELV POSNV.
*-- Fetch Subsequent PO documents & Credit Memo based on the sales orders
SELECT VBELV
POSNV
VBELN
POSNN
VBTYP_N
FROM VBFA
INTO TABLE IT_PO
FOR ALL ENTRIES IN IT_ORDERS
WHERE VBELV = IT_ORDERS-VBELV
AND POSNV = IT_ORDERS-POSNV
AND VBTYP_N IN (C_V,C_O)
AND VBTYP_V = C_C.
IF SY-SUBRC = 0.
SORT IT_PO BY VBTYP_N.
*-- Copy the IT_PO internal table contents to IT_CMEMO internal table
IT_CMEMO[] = IT_PO[].
*-- Delete PO documents from IT_CMEMO internal table
DELETE IT_CMEMO WHERE VBTYP_N = C_V.
SORT IT_CMEMO BY VBELN POSNN.
IF IT_CMEMO[] IS INITIAL.
MESSAGE I000 WITH 'No Credit Memo are available for CM Request'(003).
v_flag = c_x.
stop.
ENDIF.
*-- Delete Credit Memo documents from IT_PO internal table
DELETE IT_PO WHERE VBTYP_N = C_O.
SORT IT_PO BY VBELN POSNN.
ENDIF.
ENDIF.
ENDFORM. " F_GET_SO_PO_DOCS
*& Form F_GET_CHANGED_DOCS
Fetch Change Documents for CR Memos from CDHDR and CDPOS tables
FORM F_GET_CHANGED_DOCS .
*-- Fetch Change Documents for CR Memos from CDHDR
SELECT OBJECTCLAS
OBJECTID
CHANGENR
UDATE
UTIME
FROM CDHDR
INTO TABLE IT_CDHDR
FOR ALL ENTRIES IN IT_CRMEMO_CHANGE
WHERE OBJECTCLAS = C_VERKBELEG
AND OBJECTID = IT_CRMEMO_CHANGE-VBELN
AND UDATE = IT_CRMEMO_CHANGE-AEDAT
IF SY-SUBRC = 0.
SORT IT_CDHDR BY OBJECTCLAS OBJECTID CHANGENR.
*-- Fetch Change Documents for CR Memos from CDPOS
SELECT OBJECTCLAS
OBJECTID
CHANGENR
TABNAME
TABKEY
FNAME
CHNGIND
VALUE_NEW
VALUE_OLD
FROM CDPOS
INTO TABLE IT_CDPOS
FOR ALL ENTRIES IN IT_CDHDR
WHERE OBJECTCLAS = C_VERKBELEG
AND OBJECTID = IT_CDHDR-OBJECTID
AND CHANGENR = IT_CDHDR-CHANGENR
AND TABNAME = C_VBAK
AND FNAME = C_AUGRU
AND CHNGIND = C_U.
IF SY-SUBRC = 0.
SORT IT_CDPOS BY OBJECTCLAS OBJECTID CHANGENR.
ENDIF.
ENDIF.
ENDFORM. " F_GET_CHANGED_DOCS
*& Form F_GET_EKPO
Fetch Purchasing Document Item Details
FORM F_GET_EKPO .
*-- Fetch Purchasing Document Item Details
SELECT A~EBELN
B~EBELP
A~WAERS
B~MENGE
B~MEINS
B~NETPR
B~PEINH
B~mwskz
B~TXJCD
INTO TABLE IT_EKPO
FROM ( EKKO AS A
INNER JOIN EKPO AS B ON AEBELN = BEBELN )
FOR ALL ENTRIES IN IT_PO
WHERE A~EBELN = IT_PO-VBELN
AND B~EBELP = IT_PO-POSNN+1(5).
IF SY-SUBRC = 0.
SORT IT_EKPO BY EBELN EBELP.
ENDIF.
ENDFORM. " F_GET_EKPO
*& Form F_GET_VENDOR
Fetch MIRO Vendor details based on the PO Details
FORM F_GET_VENDOR .
DATA: LV_TABIX TYPE SY-TABIX.
*-- Fetch History per Purchasing Document records for all the PO records
SELECT EBELN
EBELP
ZEKKN
VGABE
GJAHR
BELNR
BUZEI
FROM EKBE
INTO TABLE IT_EKBE
FOR ALL ENTRIES IN IT_EKPO
WHERE EBELN = IT_EKPO-EBELN
AND EBELP = IT_EKPO-EBELP
AND VGABE = '2'.
and STBLG = space.
IF SY-SUBRC = 0.
SORT IT_EKBE BY BELNR GJAHR.
*-- Fetch the vendor details based on table IT_EKBE internal table
SELECT BELNR
GJAHR
BLDAT
BUDAT
XBLNR
LIFNR
RMWWR
WMWST1
XRECH
STBLG
FROM RBKP
INTO TABLE IT_RBKP
FOR ALL ENTRIES IN IT_EKBE
WHERE BELNR = IT_EKBE-BELNR
AND GJAHR = IT_EKBE-GJAHR.
IF SY-SUBRC = 0.
SORT IT_RBKP BY BELNR GJAHR.
ENDIF.
ENDIF.
*-- Sort PO History documents based on PO # and PO Item
SORT IT_EKBE BY EBELN EBELP.
*-- Copy the PO History documents into IT_EKBE_TEMP internal table
IT_EKBE_TEMP[] = IT_EKBE[].
*-- Delete PO History documents from IT_EKBE_TEMP internal table
comparing with IT_RBKP where (STBLG) Reversal document number
is initial
LOOP AT IT_EKBE_TEMP INTO WA_EKBE_TEMP.
LV_TABIX = SY-TABIX.
READ TABLE IT_RBKP INTO WA_RBKP WITH KEY BELNR = WA_EKBE_TEMP-BELNR
GJAHR = WA_EKBE_TEMP-GJAHR
XRECH = SPACE
STBLG = SPACE.
IF SY-SUBRC 0.
DELETE IT_EKBE_TEMP INDEX LV_TABIX.
ENDIF.
CLEAR: WA_EKBE_TEMP, WA_RBKP.
ENDLOOP.
ENDFORM. " F_GET_VENDOR
*& Form F_PROCESS_MIRO
Process MIRO
FORM F_PROCESS_MIRO .
DATA:
lv_itemno TYPE i,
lv_tabix type sy-index,
lc_check(1) TYPE c VALUE 'X',
V_FILL_ITEM,
lv_rbkp_bldat type sy-datum.
clear : it_itemdata, it_accountingdata, IT_CRMEMO_MIRO, IT_CRMEMO_MR8M.
refresh : it_itemdata, it_accountingdata, IT_CRMEMO_MIRO, IT_CRMEMO_MR8M.
*-- Copy all the CR Memo Docs and delete order reason not in S_AUGRU
IT_CRMEMO_MR8M[] = IT_CRMEMO[].
*-- Delete Reversal postings which are not in S_AUGRU
DELETE IT_CRMEMO_MR8M WHERE AUGRU IN S_AUGRU.
*-- Delete Reversal postings where AEDAT is initial
DELETE IT_CRMEMO_MR8M where aedat is initial.
*-- Delete order reason which are not in S_AUGRU
DELETE IT_CRMEMO WHERE AUGRU NOT IN S_AUGRU.
*-- Loop through the credit memo request records
LOOP AT IT_CRMEMO INTO WA_CRMEMO.
lv_tabix = sy-tabix.
*-- If credit memo request change date is not initial then
send change date (AEDAT) to lv_rbkp_bldat
if not WA_CRMEMO-aedat is initial.
lv_rbkp_bldat = WA_CRMEMO-aedat.
else.
*-- If credit memo request change date is initial then
send create date (ERDAT) to lv_rbkp_bldat
lv_rbkp_bldat = WA_CRMEMO-erdat.
endif.
READ TABLE IT_ORDERS INTO WA_ORDERS WITH KEY VBELN = WA_CRMEMO-VBELN
POSNN = WA_CRMEMO-POSNR.
IF SY-SUBRC = 0.
READ TABLE IT_PO INTO WA_PO WITH KEY VBELV = WA_ORDERS-VBELV
POSNV = WA_ORDERS-POSNV.
IF SY-SUBRC = 0.
READ TABLE IT_EKPO INTO WA_EKPO WITH KEY EBELN = WA_PO-VBELN
EBELP = WA_PO-POSNN.
IF SY-SUBRC = 0.
*-- Read IT_EKBE_TEMP internal table which contains records which are not reversed
READ TABLE IT_EKBE_TEMP INTO WA_EKBE_TEMP WITH KEY EBELN = WA_EKPO-EBELN
EBELP = WA_EKPO-EBELP.
IF SY-SUBRC = 0.
*-- Read IT_RBKP internal table with XRECH (Indicator: post invoice) = 'X' ,
check for invoice records for the correspnding CR Memo records
READ TABLE IT_RBKP INTO WA_RBKP WITH KEY BELNR = WA_EKBE_TEMP-BELNR
GJAHR = WA_EKBE_TEMP-GJAHR
XRECH = C_X.
IF SY-SUBRC = 0.
*-- Read IT_RBKP internal table with XRECH (Indicator: post invoice) = SPACE,
and document date = CR Memo creation date
and reference document number = PO number
READ TABLE IT_RBKP INTO WA_RBKP_TMP WITH KEY BELNR = WA_EKBE_TEMP-BELNR
GJAHR = WA_EKBE_TEMP-GJAHR
BLDAT = WA_CRMEMO-ERDAT
XRECH = ' '
XBLNR+0(10) = WA_EKBE_TEMP-ebeln.
STBLG = SPACE.
IF SY-SUBRC = 0.
CONTINUE.
ELSE.
*-- Quantity Conversion (Get the Credit Memo Quantity by passing CMR unit per one PO unit)
perform f_quantity_conv.
*-- Filling the Line items data
*-- Incrementing the item no
lv_itemno = lv_itemno + 1.
v_itemno = lv_itemno.
it_itemdata-invoice_doc_item = v_itemno.
it_itemdata-po_number = WA_ekPO-ebeln.
it_itemdata-po_item = WA_EKPO-EBELP.
it_itemdata-tax_code = WA_ekpo-mwskz.
it_itemdata-TAXJURCODE = WA_ekpo-TXJCD.
*-- Converting SAP amount to BAPI format by passing line item amount and currency
PERFORM f_currency_amount_sap_to_bapi USING WA_EKPO-waers
V_LINE_AMOUNT
CHANGING it_itemdata-item_amount .
it_itemdata-quantity = ( WA_CRMEMO-ZMENG * V_CRMEMO_QTY ).
it_itemdata-po_unit = WA_EKPO-MEINS.
APPEND it_itemdata.
*-- Populate Account Assignment data
IT_ACCOUNTINGDATA-INVOICE_DOC_ITEM = v_itemno.
IT_ACCOUNTINGDATA-XUNPL = space.
IT_ACCOUNTINGDATA-SERIAL_NO = C_01.
IT_ACCOUNTINGDATA-TAX_CODE = it_itemdata-tax_code.
IT_ACCOUNTINGDATA-TAXJURCODE = it_itemdata-TAXJURCODE.
IT_ACCOUNTINGDATA-ITEM_AMOUNT = it_itemdata-item_amount.
IT_ACCOUNTINGDATA-QUANTITY = it_itemdata-quantity.
IT_ACCOUNTINGDATA-PO_UNIT = it_itemdata-po_unit.
IT_ACCOUNTINGDATA-GL_ACCOUNT = C_0000500205.
append IT_ACCOUNTINGDATA.
clear IT_ACCOUNTINGDATA.
CLEAR it_itemdata.
endif.
endif.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
*-- At end of each credit memo request fill the header details of BAPI FM and
*-- post the BAPI
AT END OF VBELN.
read table it_crmemo into wa_crmemo index lv_tabix.
*-- Populate the document Header
*-- Getting the header data for invoice
x_docheader-invoice_ind = space.
x_docheader-doc_type = c_blart.
x_docheader-doc_date = lv_rbkp_bldat.
x_docheader-pstng_date = lv_rbkp_bldat.
x_docheader-ref_doc_no = WA_RBKP-XBLNR.
x_docheader-comp_code = WA_CRMEMO-BUKRS_VF.
x_docheader-CURRENCY = WA_CRMEMO-WAERK.
x_docheader-calc_tax_ind = lc_check.
*-- Logic to find the Tax %
v_tax_per = ( WA_RBKP-WMWST1 / ( WA_RBKP-RMWWR - WA_RBKP-WMWST1 ) ) * 100.
v_tax_amt = ( V_GROSSAMT * v_tax_per ) / 100.
V_GROSSAMT = ( V_GROSSAMT + v_tax_amt ).
x_docheader-gross_amount = V_GROSSAMT.
CLEAR:v_docnr, v_year1.
*-- Calling BAPI to create PO invoice document
CHECK NOT IT_ITEMDATA[] IS INITIAL.
CALL FUNCTION 'BAPI_INCOMINGINVOICE_CREATE'
EXPORTING
headerdata = x_docheader
IMPORTING
invoicedocnumber = v_docnr
fiscalyear = v_year1
TABLES
itemdata = it_itemdata[]
ACCOUNTingDATA = it_ACCOUNTingDATA[]
GLACCOUNTDATA =
taxdata =
return = it_return.
*-- Commit work
IF NOT v_docnr IS INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
*-- Move the data to Success Internal Table
wa_success-crmemo = wa_crmemo-vbeln.
wa_success-cmemo = wa_cmemo-vbeln.
wa_success-orders = wa_orders-vbelv.
wa_success-po = wa_po-vbeln.
wa_success-miro_no = v_docnr.
wa_success-text = 'MIRO is Posted'.
append wa_success TO it_success.
clear wa_success.
ENDIF.
*-- Read the values in the table IT_RETURN.
CLEAR it_return.
READ TABLE it_return INDEX 1.
If message type is error then roll back the work
IF it_return-type = C_E.
*-- Roll back
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
*-- Move the data to Error Internal Table
wa_error-crmemo = wa_crmemo-vbeln.
wa_error-cmemo = wa_cmemo-vbeln.
wa_error-orders = wa_orders-vbelv.
wa_error-po = wa_po-vbeln.
wa_error-text = it_return-MESSAGE.
append wa_error TO it_error.
clear wa_error.
ENDIF.
refresh: it_return, it_itemdata, it_accountingdata.
clear: V_GROSSAMT, it_return, it_itemdata, wa_crmemo, wa_orders, wa_po,
wa_ekpo, WA_EKBE_TEMP, wa_rbkp, wa_rbkp_tmp, v_docnr, v_year1, WA_SUCCESS,
WA_ERROR, it_accountingdata, v_tax_per, v_tax_amt, V_FILL_ITEM, lv_rbkp_bldat.
ENDAT.
ENDLOOP.
ENDFORM. " F_PROCESS_MIRO
*& Form f_quantity_conv
Quantity Conversion
FORM f_quantity_conv .
*-- Quantity Conversion (Get the Credit Memo Quantity by passing CMR unit per one PO unit)
CLEAR: V_LINE_AMOUNT, V_CRMEMO_QTY.
call function 'MC_UNIT_CONVERSION'
EXPORTING
MATNR = WA_CRMEMO-MATNR
nach_meins = WA_EKPO-MEINS
von_meins = WA_CRMEMO-ZIEME
IMPORTING
UMREF = V_CRMEMO_QTY
EXCEPTIONS
CONVERSION_NOT_FOUND = 1
MATERIAL_NOT_FOUND = 2
NACH_MEINS_MISSING = 3
OVERFLOW = 4
VON_MEINS_MISSING = 5
OTHERS = 6.
if sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
V_LINE_AMOUNT = ( V_CRMEMO_QTY * WA_CRMEMO-ZMENG * WA_EKPO-peinh * WA_EKPO-NETPR ).
V_GROSSAMT = V_GROSSAMT + V_LINE_AMOUNT.
ENDIF.
ENDFORM. " f_quantity_conv
*& Form f_currency_amount_sap_to_bapi
SAP Amount to BAPI Amount
FORM f_currency_amount_sap_to_bapi USING p_waers
p_kbetr
CHANGING p_amt_doccur.
DATA : lv_waers LIKE tcurc-waers,
lv_sapamount LIKE bapicurr-bapicurr,
lv_bapi_amount LIKE bapicurr-bapicurr.
lv_waers = p_waers.
lv_sapamount = p_kbetr.
CALL FUNCTION 'CURRENCY_AMOUNT_SAP_TO_BAPI'
EXPORTING
currency = lv_waers
sap_amount = lv_sapamount
IMPORTING
bapi_amount = lv_bapi_amount.
p_amt_doccur = lv_bapi_amount. -
No batch input problem with Vendor master Upload
Hi All,
I am getting a problem with Vendor Master upload conversion. We have'nt change the code and configuration but when i try to run the code today its giving an error for particular Account group. I run this code yesterday and its work fine with that particluar Account group. But i am getting an error when i run the code today. The error is as follows "No batch input data for screen SAPMF02K 0610".When i got through the code i have'nt find that screen number.
Can anyone suggest how to resolve that problem.Double click on the session name in SM35 and click on the screens tab there you can find the screen number.
process the same session in foreground mode and see if you are getting the same error.
If so, the new screen number you got is due to some change in the settings some where, show the new screen to Your Functional guy and he can help you.
There is one more chance where some data is missing in the flat file, just check it out.
Reward points if usefull.
Thanks ,
Veeru.
Maybe you are looking for
-
MacBook Pro Retina doesn't show correct colour spectrum
I'm having trouble with my late 2013 13" MBPr display, it's displaying low colour spectrum, something like 16 bit colours. I took a photo of my screen right now, and it display something like this. As you can see the cat colour look really washed out
-
We are transferring all our iTunes songs to a new computer do to space issues on old one. My daughter's ipod touch is an older generation and she cannot connect to the new computer without wiping out her current itunes songs and rebuilding them on h
-
Knowing issues with atv3 and Yosemite gm incl iTunes 12 beta
so as I wiite in the headline I have som problems to connect my media library With iTunes a tv always says:unable to connect to your media library it is also impossible to connect to the library from any other device (iPad or iPhone) i checkt it wi
-
Tabbed Panels - Tab shows over a dropdown menu
Hello, As you see in this link Tab Problem i have a problem the tabbed panel widget. The tab seems to come in front of a drop-down menu that i have (not spry) Any suggestions are much appreciated
-
How to use CS4 to control my photo scanner?
How do I use CS4 to scan slides or pics using my new Epson photo scanner?