14
 Upload a CSV Excel File or Text File in SAP CRM WebUI  SAP CRM Technical Consultants sometimes comes across a requirement from the clients on business scenarios where they are asked to upload a File from the Presentation Server e!" #esktop$ PC$ %aptop$ etc! & into Application Server i!e SAP CRM System! This may be due a wide ran"e of business requirements ran"in" from Mass 'perations like bulk upload of (usiness Partners in the system and mass upload of data from e)ternal sources for %ead *eneration! (ased on the business case either a plain and simple +at ,le is used or a CS- File can also be fed into! Te)t File has the +e)ibility of platform independence and can be used and downloaded across multiple environments!  .n the sample code below$ either a CS- File can be used or a te)t ,le can also be used! . have created my own / Co mponent and have used the SAP Standard Component 0 GS_FILE_UPLOAD as a component usa"e in my component! 1ere the only intention is to upload a table of (usiness Partners into the system!  Assumptions  . have made the followin" assumptions re"ardin" the technical skill which . feel is a prerequisite in order to e)ecute the sample e)ample provided in this document!  1ave knowled"e on SAP CRM 2eb 3. Pro"ramin" 1ave knowled"e on Component creation$ -iew and Runtime Repository 4ditors 1ave knowled"e on Component 3sa"e  .f you don5t have e)tensive skills in the above mentioned topics still you can proceed with this document! (ut you may need to refer some document on basics of SAP CRM 2eb 3. pro"rammin"!  . "uess ther e must be some e) ist in" compon ent in the syste m! .f you don 5t hav e an e)ist in" component then you can create a sample component with any model node! This is 6ust for your reference and will brush up your old skills of component creation!  4)ecute the CRM 2eb 3. workbench Transaction Code 7 BSP_WD_CMPWB! Create a component here and to""le o8 the enhancement set button as we will not be enhancin" any standard component here! 9e)t step is to create a new -iew as shown below 7  

Upload a CSV Excel File or Text File in SAP CRM WebUI

Embed Size (px)

DESCRIPTION

Example to upload CSV File in SSF

Citation preview

Page 1: Upload a CSV Excel File or Text File in SAP CRM WebUI

7/21/2019 Upload a CSV Excel File or Text File in SAP CRM WebUI

http://slidepdf.com/reader/full/upload-a-csv-excel-file-or-text-file-in-sap-crm-webui 1/13

Upload a CSV Excel File or Text File in SAPCRM WebUI SAP CRM Technical Consultants sometimes comes across a requirement from the clients on businessscenarios where they are asked to upload a File from the Presentation Server e!" #esktop$ PC$%aptop$ etc! & into Application Server i!e SAP CRM System! This may be due a wide ran"e of businessrequirements ran"in" from Mass 'perations like bulk upload of (usiness Partners in the system andmass upload of data from e)ternal sources for %ead *eneration! (ased on the business case either aplain and simple +at ,le is used or a CS- File can also be fed into! Te)t File has the +e)ibility of platform independence and can be used and downloaded across multiple environments! .n the sample code below$ either a CS- File can be used or a te)t ,le can also be used! . have createdmy own / Component and have used the SAP Standard Component 0 GS_FILE_UPLOAD as acomponent usa"e in my component! 1ere the only intention is to upload a table of (usiness Partnersinto the system! Assumptions . have made the followin" assumptions re"ardin" the technical skill which . feel is a prerequisite inorder to e)ecute the sample e)ample provided in this document!

• 1ave knowled"e on SAP CRM 2eb 3. Pro"ramin"• 1ave knowled"e on Component creation$ -iew and Runtime Repository 4ditors• 1ave knowled"e on Component 3sa"e

.f you don5t have e)tensive skills in the above mentioned topics still you can proceed with thisdocument! (ut you may need to refer some document on basics of SAP CRM 2eb 3. pro"rammin"! . "uess there must be some e)istin" component in the system! .f you don5t have an e)istin"component then you can create a sample component with any model node! This is 6ust for yourreference and will brush up your old skills of component creation! 4)ecute the CRM 2eb 3. workbench Transaction Code 7 BSP_WD_CMPWB ! Create a component here

and to""le o8 the enhancement set button as we will not be enhancin" any standard component here!

9e)t step is to create a new -iew as shown below 7

Page 2: Upload a CSV Excel File or Text File in SAP CRM WebUI

7/21/2019 Upload a CSV Excel File or Text File in SAP CRM WebUI

http://slidepdf.com/reader/full/upload-a-csv-excel-file-or-text-file-in-sap-crm-webui 2/13

Add or create a 9ew 9ode with the structure already de,ned as shown below and then complete thesubsequent steps to complete the view creation! Then add the view into the Runtime Repository!

Page 3: Upload a CSV Excel File or Text File in SAP CRM WebUI

7/21/2019 Upload a CSV Excel File or Text File in SAP CRM WebUI

http://slidepdf.com/reader/full/upload-a-csv-excel-file-or-text-file-in-sap-crm-webui 3/13

Then complete the con,"uration by addin" the ,elds in the result list!

Add two buttons for upload and clearin" the uploaded data as shown below7

Page 4: Upload a CSV Excel File or Text File in SAP CRM WebUI

7/21/2019 Upload a CSV Excel File or Text File in SAP CRM WebUI

http://slidepdf.com/reader/full/upload-a-csv-excel-file-or-text-file-in-sap-crm-webui 4/13

.f you have an already e)istin" 2eb 3. Component$ then in order to upload Te)t:CS- 4)cel Files in SAPCRM 2eb Client 3. the followin" steps needed to be performed! 2e will be usin" an already e)istin"2eb 3. Component as component usa"e and there is no further requirement of ;avaScript Codin"! Thee)cel ,les that need to be uploaded must be of type CS- < comma separated values e)cel! .nadditional plain te)t ,les can also be used! The uploaded data is stored as content in a strin"!

3se an already e)istin" SAP CRM 2eb 3. component

Create a 9ew -iew

Page 5: Upload a CSV Excel File or Text File in SAP CRM WebUI

7/21/2019 Upload a CSV Excel File or Text File in SAP CRM WebUI

http://slidepdf.com/reader/full/upload-a-csv-excel-file-or-text-file-in-sap-crm-webui 5/13

Add the followin" = 4vents in the -iew

Page 6: Upload a CSV Excel File or Text File in SAP CRM WebUI

7/21/2019 Upload a CSV Excel File or Text File in SAP CRM WebUI

http://slidepdf.com/reader/full/upload-a-csv-excel-file-or-text-file-in-sap-crm-webui 6/13

.n the 3pload method add the followin" piece of code

Page 7: Upload a CSV Excel File or Text File in SAP CRM WebUI

7/21/2019 Upload a CSV Excel File or Text File in SAP CRM WebUI

http://slidepdf.com/reader/full/upload-a-csv-excel-file-or-text-file-in-sap-crm-webui 7/13

#e,ne the followin" Popup Access .nterface in the .mplementation Class of the -iew

.n the other Method < 41>'93P%'A#>P'P3P>C%'S4# put the followin" piece of code! 1ere based onthe content we need to classify the data into appropriate structure!

Page 8: Upload a CSV Excel File or Text File in SAP CRM WebUI

7/21/2019 Upload a CSV Excel File or Text File in SAP CRM WebUI

http://slidepdf.com/reader/full/upload-a-csv-excel-file-or-text-file-in-sap-crm-webui 8/13

METHOD eh_onupload_popup_closed.

T PES! BEGI" OF l_#$_a##%_s#%uc#& 'us(nesspa%#ne% T PE 'u_pa%#ne%& pa%#ne%desc%(p#(on T PE 'u_desc%(p_lon)& E"D OF l_#$_a##%_s#%uc#.

DATA!l_*_+le_con#en# T PE s#%(n)& l_(_+le_con#en# T PE s#%(n)#a'& l_*_+le_#$pe T PE s#%(n)& l_*_+le_na,e T PE s#%(n)& l_o_ou#pu#node T PE -EF TO cl_'sp_ d_con#e/#_node& l_o_collec#(on_ %appe% T PE -EF TO cl_'sp_ d_collec#(on_ %appe%&

l_(0_p%ope%#$ T PE -EF TO (0_'ol_'o_p%ope%#$_access& l_o_,s)_se%*(ce T PE -EF TO cl_'sp_ d_,essa)e_se%*(ce& l_(_'p T PE 1'upa_desc& l_ a_'p T PE 1'upa_desc& l_*_s#a#us T PE 1,e,'e%_s#a#us& l_o_en#(#$ T PE -EF TO cl_c%,_'ol_en#(#$& l_(_%e#u%n T PE 'ap(%e#2_#& l_ a_%e#u%n T PE 'ap(%e#2& l_*_s#%uc#_%e0 T PE -EF TO 1accoun#_upload3& l_o_*alue_node T PE -EF TO cl_'sp_ d_*alue_node& l_(0_'o_coll T PE -EF TO (0_'ol_'o_col&

Page 9: Upload a CSV Excel File or Text File in SAP CRM WebUI

7/21/2019 Upload a CSV Excel File or Text File in SAP CRM WebUI

http://slidepdf.com/reader/full/upload-a-csv-excel-file-or-text-file-in-sap-crm-webui 9/13

l_*_+%ed_plu) T PE seoc,pna,e.

FIELD4S MBOLS! 50s_+le_con#en#6 T PE s#%(n)& 5l_0s_ a_da#a6 T PE 1accoun#_upload3.

l_*_+%ed_plu) 7 c(_(0_popup46)e#_+%ed_ou#'ound_plu)8 9.

CASE l_*_+%ed_plu). WHE" :lea*e:.; )e# %esul#s o0 popup l_o_ou#pu#node <7 c(_(0_popup46)e#_con#e/#_node8 :FILE: 9. =>EC "OTE?T

l_o_collec#(on_ %appe% 7 l_o_ou#pu#node46)e#_collec#(on_ %appe%8 9. l_(0_p%ope%#$ 7 l_o_collec#(on_ %appe%46)e#_cu%%en#8 9.

CALL METHOD l_(0_p%ope%#$46)e#_p%ope%#$_as_*alue E?PO-TI"G (*_a##%_na,e 7 :FILE_CO"TE"T_T PE: =>EC "OTE?T IMPO-TI"G e*_%esul# 7 l_*_+le_#$pe.

CALL METHOD l_(0_p%ope%#$46)e#_p%ope%#$_as_*alue E?PO-TI"G (*_a##%_na,e 7 :FILE_"AME: =>EC "OTE?T IMPO-TI"G e*_%esul# 7 l_*_+le_na,e.

; Chec@ #he MIME +le #$pe and #he +le e/#ens(on IF 8 l_*_+le_#$pe CP :#e/# pla(n: 9

O- 8 l_*_+le_#$pe CP :#e/# co,,a4sepa%a#ed4*alues: 9 O- 8 l_*_+le_#$pe CP :appl(ca#(on *nd.,s4e/cel: A"D l_*_+le_na,e CP :;.cs*: 9. =>EC"OTE?T

CALL METHOD l_(0_p%ope%#$46)e#_p%ope%#$_as_*alue E?PO-TI"G (*_a##%_na,e 7 :FILE_CO"TE"T_ST-I"G: =>EC "OTE?T IMPO-TI"G e*_%esul# 7 l_*_+le_con#en#. IF l_*_+le_con#en# IS I"ITIAL. l_o_,s)_se%*(ce <7 ,e46*(e _,ana)e%46)e#_,essa)e_se%*(ce8 9. l_o_,s)_se%*(ce46add_,essa)e8 (*_,s)_#$pe 7 :E: (*_,s)_(d 7 :C-M_UI: (*_,s)_nu,'e% 7 : : 9. =>EC "OTE?T E?IT. E"DIF. IF ,e46#$ped_con#e/#46e/upd246collec#(on_ %appe% IS BOU"D. ,e46#$ped_con#e/#46e/upd246collec#(on_ %appe%46clea%8 9. E"DIF.; Spl(# +lecon#en# (n#o sepa%a#e l(nes and s#o%e #he, (n #a'le SPLIT l_*_+le_con#en# AT cl_a'ap_cha%_u#(l(#(es76c%_l0 I"TO TABLE l_(_+le_con#en#. CLEA- l_*_+le_con#en#.; -e,o*e e,p#$ l(nes 0%o, +lecon#en# #a'le and s#o%e on *alue node LOOP AT l_(_+le_con#en# ASSIG"I"G 50s_+le_con#en#6.

Page 10: Upload a CSV Excel File or Text File in SAP CRM WebUI

7/21/2019 Upload a CSV Excel File or Text File in SAP CRM WebUI

http://slidepdf.com/reader/full/upload-a-csv-excel-file-or-text-file-in-sap-crm-webui 10/13

IF "OT 50s_+le_con#en#6 IS I"ITIAL. l_ a_'p4pa%#ne% 7 50s_+le_con#en#6. APPE"D l_ a_'p TO l_(_'p. E"DIF. E"DLOOP.

IF l_(_'p IS "OT I"ITIAL.

C-EATE OB ECT l_(0_'o_coll T PE cl_c%,_'ol_'o_col.

IF l_(0_'o_coll IS BOU"D. l_(0_'o_coll46se#_,ul#(_selec#8 a'ap_#%ue 9. E"DIF.

LOOP AT l_(_'p I"TO l_ a_'p. -EF-ESH l_(_%e#u%n. CALL FU"CTIO" :BUPA_DESC-IPTIO"_GET: E?PO-TI"G (*_pa%#ne% 7 l_ a_'p4pa%#ne% IMPO-TI"G e*_desc%(p#(on_lon) 7 l_ a_'p4pa%#ne%_desc TABLES e#_%e#u%n 7 l_(_%e#u%n.

IF l_(_%e#u%n IS "OT I"ITIAL. CLEA- l_ a_%e#u%n. -EAD TABLE l_(_%e#u%n I"TO l_ a_%e#u%n WITH E #$pe 7 :E:. IF s$4su'%c 7 . l_ a_'p4pa%#ne%_desc 7 l_ a_%e#u%n4,essa)e. E"DIF. E"DIF.

C-EATE DATA l_*_s#%uc#_%e0.

ASSIG" l_*_s#%uc#_%e046; TO 5l_0s_ a_da#a6. 5l_0s_ a_da#a64pa%#ne%_(d 7 l_ a_'p4pa%#ne%. 5l_0s_ a_da#a64pa%#ne%_desc% 7 l_ a_'p4pa%#ne%_desc. C-EATE OB ECT l_o_*alue_node E?PO-TI"G (*_da#a_%e0 7 l_*_s#%uc#_%e0.

l_(0_'o_coll46add8 l_o_*alue_node 9. l_(0_'o_coll46(0_'ol_'o_col_,ul#(_sel ,a%@8 E?PO-TI"G (*_'o 7 l_o_*alue_node 9. U"ASSIG" 5l_0s_ a_da#a6. E"DLOOP. E"DIF.; E"DIF.

,e46#$ped_con#e/#46e/upd246collec#(on_ %appe%46se#_collec#(on8 l_(0_'o_coll 9. ,e46#$ped_con#e/#46e/upd246collec#(on_ %appe%46pu'l(sh_cu%%en#8 9.

ELSE.; We assu,e an (nco%%ec# +le #$pe! (#:s ne(#he% a pla(n #e/# +le no% a .cs* +le; The%e0o%e 46 %a(se an e%%o% ,essa)e

Page 11: Upload a CSV Excel File or Text File in SAP CRM WebUI

7/21/2019 Upload a CSV Excel File or Text File in SAP CRM WebUI

http://slidepdf.com/reader/full/upload-a-csv-excel-file-or-text-file-in-sap-crm-webui 11/13

l_o_,s)_se%*(ce <7 ,e46*(e _,ana)e%46)e#_,essa)e_se%*(ce8 9. l_o_,s)_se%*(ce46add_,essa)e8 (*_,s)_#$pe 7 :E: (*_,s)_(d 7 :C-M_UI: (*_,s)_nu,'e% 7 : 3 : 9. =>EC "OTE?T E"DIF. WHE" OTHE-S. E"DCASE.

E"DMETHOD.

Add the followin" lines of code in the 1TM% ,le of the view

.n the Component a new component 3sa"e needs to be added

Page 12: Upload a CSV Excel File or Text File in SAP CRM WebUI

7/21/2019 Upload a CSV Excel File or Text File in SAP CRM WebUI

http://slidepdf.com/reader/full/upload-a-csv-excel-file-or-text-file-in-sap-crm-webui 12/13

9ow run the component

Click on 3pload

Page 13: Upload a CSV Excel File or Text File in SAP CRM WebUI

7/21/2019 Upload a CSV Excel File or Text File in SAP CRM WebUI

http://slidepdf.com/reader/full/upload-a-csv-excel-file-or-text-file-in-sap-crm-webui 13/13

Click the 3pload File

3pload the File

• Topics: Customer Relationship Mana"ement